xref: /aosp_15_r20/external/mesa3d/src/gallium/winsys/sw/null/null_sw_winsys.c (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /**************************************************************************
2  *
3  * Copyright 2010 VMware, Inc.
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sub license, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20  * USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * The above copyright notice and this permission notice (including the
23  * next paragraph) shall be included in all copies or substantial portions
24  * of the Software.
25  *
26  **************************************************************************/
27 
28 /**
29  * @file
30  * Null software rasterizer winsys.
31  *
32  * There is no present support. Framebuffer data needs to be obtained via
33  * transfers.
34  *
35  * @author Jose Fonseca
36  */
37 
38 #include <stdio.h>
39 
40 #include "util/format/u_formats.h"
41 #include "util/u_memory.h"
42 #include "frontend/sw_winsys.h"
43 #include "null_sw_winsys.h"
44 
45 
46 static bool
null_sw_is_displaytarget_format_supported(struct sw_winsys * ws,unsigned tex_usage,enum pipe_format format)47 null_sw_is_displaytarget_format_supported(struct sw_winsys *ws,
48                                           unsigned tex_usage,
49                                           enum pipe_format format )
50 {
51    return false;
52 }
53 
54 
55 static void *
null_sw_displaytarget_map(struct sw_winsys * ws,struct sw_displaytarget * dt,unsigned flags)56 null_sw_displaytarget_map(struct sw_winsys *ws,
57                           struct sw_displaytarget *dt,
58                           unsigned flags )
59 {
60    assert(0);
61    return NULL;
62 }
63 
64 
65 static void
null_sw_displaytarget_unmap(struct sw_winsys * ws,struct sw_displaytarget * dt)66 null_sw_displaytarget_unmap(struct sw_winsys *ws,
67                             struct sw_displaytarget *dt )
68 {
69    assert(0);
70 }
71 
72 
73 static void
null_sw_displaytarget_destroy(struct sw_winsys * winsys,struct sw_displaytarget * dt)74 null_sw_displaytarget_destroy(struct sw_winsys *winsys,
75                               struct sw_displaytarget *dt)
76 {
77    assert(0);
78 }
79 
80 
81 static struct sw_displaytarget *
null_sw_displaytarget_create(struct sw_winsys * winsys,unsigned tex_usage,enum pipe_format format,unsigned width,unsigned height,unsigned alignment,const void * front_private,unsigned * stride)82 null_sw_displaytarget_create(struct sw_winsys *winsys,
83                              unsigned tex_usage,
84                              enum pipe_format format,
85                              unsigned width, unsigned height,
86                              unsigned alignment,
87                              const void *front_private,
88                              unsigned *stride)
89 {
90    fprintf(stderr, "null_sw_displaytarget_create() returning NULL\n");
91    return NULL;
92 }
93 
94 static struct sw_displaytarget *
null_sw_displaytarget_create_mapped(struct sw_winsys * winsys,unsigned tex_usage,enum pipe_format format,unsigned width,unsigned height,unsigned stride,void * data)95 null_sw_displaytarget_create_mapped(struct sw_winsys *winsys,
96                                     unsigned tex_usage,
97                                     enum pipe_format format,
98                                     unsigned width, unsigned height,
99                                     unsigned stride,
100                                     void *data)
101 {
102    fprintf(stderr, "null_sw_displaytarget_create_mapped() returning NULL\n");
103    return NULL;
104 }
105 
106 
107 static struct sw_displaytarget *
null_sw_displaytarget_from_handle(struct sw_winsys * winsys,const struct pipe_resource * templat,struct winsys_handle * whandle,unsigned * stride)108 null_sw_displaytarget_from_handle(struct sw_winsys *winsys,
109                                   const struct pipe_resource *templat,
110                                   struct winsys_handle *whandle,
111                                   unsigned *stride)
112 {
113    return NULL;
114 }
115 
116 
117 static bool
null_sw_displaytarget_get_handle(struct sw_winsys * winsys,struct sw_displaytarget * dt,struct winsys_handle * whandle)118 null_sw_displaytarget_get_handle(struct sw_winsys *winsys,
119                                  struct sw_displaytarget *dt,
120                                  struct winsys_handle *whandle)
121 {
122    assert(0);
123    return false;
124 }
125 
126 
127 static void
null_sw_displaytarget_display(struct sw_winsys * winsys,struct sw_displaytarget * dt,void * context_private,unsigned nboxes,struct pipe_box * box)128 null_sw_displaytarget_display(struct sw_winsys *winsys,
129                               struct sw_displaytarget *dt,
130                               void *context_private,
131                               unsigned nboxes,
132                               struct pipe_box *box)
133 {
134    assert(0);
135 }
136 
137 
138 static void
null_sw_destroy(struct sw_winsys * winsys)139 null_sw_destroy(struct sw_winsys *winsys)
140 {
141    FREE(winsys);
142 }
143 
144 
145 struct sw_winsys *
null_sw_create(void)146 null_sw_create(void)
147 {
148    static struct sw_winsys *winsys;
149 
150    winsys = CALLOC_STRUCT(sw_winsys);
151    if (!winsys)
152       return NULL;
153 
154    winsys->destroy = null_sw_destroy;
155    winsys->is_displaytarget_format_supported = null_sw_is_displaytarget_format_supported;
156    winsys->displaytarget_create = null_sw_displaytarget_create;
157    winsys->displaytarget_create_mapped = null_sw_displaytarget_create_mapped;
158    winsys->displaytarget_from_handle = null_sw_displaytarget_from_handle;
159    winsys->displaytarget_get_handle = null_sw_displaytarget_get_handle;
160    winsys->displaytarget_map = null_sw_displaytarget_map;
161    winsys->displaytarget_unmap = null_sw_displaytarget_unmap;
162    winsys->displaytarget_display = null_sw_displaytarget_display;
163    winsys->displaytarget_destroy = null_sw_displaytarget_destroy;
164 
165    return winsys;
166 }
167