1 /*
2 * Copyright 2010 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23 #include <stdio.h>
24 #include <errno.h>
25 #include "pipe/p_defines.h"
26 #include "pipe/p_state.h"
27 #include "pipe/p_context.h"
28 #include "pipe/p_screen.h"
29 #include "util/u_memory.h"
30 #include "util/u_inlines.h"
31 #include "util/u_transfer.h"
32
noop_draw_vbo(struct pipe_context * ctx,const struct pipe_draw_info * info)33 static void noop_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
34 {
35 }
36
noop_launch_grid(struct pipe_context * ctx,const struct pipe_grid_info * info)37 static void noop_launch_grid(struct pipe_context *ctx,
38 const struct pipe_grid_info *info)
39 {
40 }
41
noop_set_blend_color(struct pipe_context * ctx,const struct pipe_blend_color * state)42 static void noop_set_blend_color(struct pipe_context *ctx,
43 const struct pipe_blend_color *state)
44 {
45 }
46
noop_create_blend_state(struct pipe_context * ctx,const struct pipe_blend_state * state)47 static void *noop_create_blend_state(struct pipe_context *ctx,
48 const struct pipe_blend_state *state)
49 {
50 return MALLOC(1);
51 }
52
noop_create_dsa_state(struct pipe_context * ctx,const struct pipe_depth_stencil_alpha_state * state)53 static void *noop_create_dsa_state(struct pipe_context *ctx,
54 const struct pipe_depth_stencil_alpha_state *state)
55 {
56 return MALLOC(1);
57 }
58
noop_create_rs_state(struct pipe_context * ctx,const struct pipe_rasterizer_state * state)59 static void *noop_create_rs_state(struct pipe_context *ctx,
60 const struct pipe_rasterizer_state *state)
61 {
62 return MALLOC(1);
63 }
64
noop_create_sampler_state(struct pipe_context * ctx,const struct pipe_sampler_state * state)65 static void *noop_create_sampler_state(struct pipe_context *ctx,
66 const struct pipe_sampler_state *state)
67 {
68 return MALLOC(1);
69 }
70
noop_create_sampler_view(struct pipe_context * ctx,struct pipe_resource * texture,const struct pipe_sampler_view * state)71 static struct pipe_sampler_view *noop_create_sampler_view(struct pipe_context *ctx,
72 struct pipe_resource *texture,
73 const struct pipe_sampler_view *state)
74 {
75 struct pipe_sampler_view *sampler_view = CALLOC_STRUCT(pipe_sampler_view);
76
77 if (!sampler_view)
78 return NULL;
79
80 /* initialize base object */
81 *sampler_view = *state;
82 sampler_view->texture = NULL;
83 pipe_resource_reference(&sampler_view->texture, texture);
84 pipe_reference_init(&sampler_view->reference, 1);
85 sampler_view->context = ctx;
86 return sampler_view;
87 }
88
noop_create_surface(struct pipe_context * ctx,struct pipe_resource * texture,const struct pipe_surface * surf_tmpl)89 static struct pipe_surface *noop_create_surface(struct pipe_context *ctx,
90 struct pipe_resource *texture,
91 const struct pipe_surface *surf_tmpl)
92 {
93 struct pipe_surface *surface = CALLOC_STRUCT(pipe_surface);
94
95 if (!surface)
96 return NULL;
97 pipe_reference_init(&surface->reference, 1);
98 pipe_resource_reference(&surface->texture, texture);
99 surface->context = ctx;
100 surface->format = surf_tmpl->format;
101 surface->width = texture->width0;
102 surface->height = texture->height0;
103 surface->texture = texture;
104 surface->u.tex.first_layer = surf_tmpl->u.tex.first_layer;
105 surface->u.tex.last_layer = surf_tmpl->u.tex.last_layer;
106 surface->u.tex.level = surf_tmpl->u.tex.level;
107
108 return surface;
109 }
110
noop_set_sampler_views(struct pipe_context * ctx,enum pipe_shader_type shader,unsigned start,unsigned count,struct pipe_sampler_view ** views)111 static void noop_set_sampler_views(struct pipe_context *ctx,
112 enum pipe_shader_type shader,
113 unsigned start, unsigned count,
114 struct pipe_sampler_view **views)
115 {
116 }
117
noop_bind_sampler_states(struct pipe_context * ctx,enum pipe_shader_type shader,unsigned start,unsigned count,void ** states)118 static void noop_bind_sampler_states(struct pipe_context *ctx,
119 enum pipe_shader_type shader,
120 unsigned start, unsigned count,
121 void **states)
122 {
123 }
124
noop_set_clip_state(struct pipe_context * ctx,const struct pipe_clip_state * state)125 static void noop_set_clip_state(struct pipe_context *ctx,
126 const struct pipe_clip_state *state)
127 {
128 }
129
noop_set_polygon_stipple(struct pipe_context * ctx,const struct pipe_poly_stipple * state)130 static void noop_set_polygon_stipple(struct pipe_context *ctx,
131 const struct pipe_poly_stipple *state)
132 {
133 }
134
noop_set_sample_mask(struct pipe_context * pipe,unsigned sample_mask)135 static void noop_set_sample_mask(struct pipe_context *pipe, unsigned sample_mask)
136 {
137 }
138
noop_set_scissor_states(struct pipe_context * ctx,unsigned start_slot,unsigned num_scissors,const struct pipe_scissor_state * state)139 static void noop_set_scissor_states(struct pipe_context *ctx,
140 unsigned start_slot,
141 unsigned num_scissors,
142 const struct pipe_scissor_state *state)
143 {
144 }
145
noop_set_stencil_ref(struct pipe_context * ctx,const struct pipe_stencil_ref * state)146 static void noop_set_stencil_ref(struct pipe_context *ctx,
147 const struct pipe_stencil_ref *state)
148 {
149 }
150
noop_set_viewport_states(struct pipe_context * ctx,unsigned start_slot,unsigned num_viewports,const struct pipe_viewport_state * state)151 static void noop_set_viewport_states(struct pipe_context *ctx,
152 unsigned start_slot,
153 unsigned num_viewports,
154 const struct pipe_viewport_state *state)
155 {
156 }
157
noop_set_framebuffer_state(struct pipe_context * ctx,const struct pipe_framebuffer_state * state)158 static void noop_set_framebuffer_state(struct pipe_context *ctx,
159 const struct pipe_framebuffer_state *state)
160 {
161 }
162
noop_set_constant_buffer(struct pipe_context * ctx,enum pipe_shader_type shader,uint index,const struct pipe_constant_buffer * cb)163 static void noop_set_constant_buffer(struct pipe_context *ctx,
164 enum pipe_shader_type shader, uint index,
165 const struct pipe_constant_buffer *cb)
166 {
167 }
168
noop_set_inlinable_constants(struct pipe_context * ctx,enum pipe_shader_type shader,uint num_values,uint32_t * values)169 static void noop_set_inlinable_constants(struct pipe_context *ctx,
170 enum pipe_shader_type shader,
171 uint num_values, uint32_t *values)
172 {
173 }
174
175
noop_sampler_view_destroy(struct pipe_context * ctx,struct pipe_sampler_view * state)176 static void noop_sampler_view_destroy(struct pipe_context *ctx,
177 struct pipe_sampler_view *state)
178 {
179 pipe_resource_reference(&state->texture, NULL);
180 FREE(state);
181 }
182
183
noop_surface_destroy(struct pipe_context * ctx,struct pipe_surface * surface)184 static void noop_surface_destroy(struct pipe_context *ctx,
185 struct pipe_surface *surface)
186 {
187 pipe_resource_reference(&surface->texture, NULL);
188 FREE(surface);
189 }
190
noop_bind_state(struct pipe_context * ctx,void * state)191 static void noop_bind_state(struct pipe_context *ctx, void *state)
192 {
193 }
194
noop_delete_state(struct pipe_context * ctx,void * state)195 static void noop_delete_state(struct pipe_context *ctx, void *state)
196 {
197 FREE(state);
198 }
199
noop_set_vertex_buffers(struct pipe_context * ctx,unsigned start_slot,unsigned count,const struct pipe_vertex_buffer * buffers)200 static void noop_set_vertex_buffers(struct pipe_context *ctx,
201 unsigned start_slot, unsigned count,
202 const struct pipe_vertex_buffer *buffers)
203 {
204 }
205
noop_create_vertex_elements(struct pipe_context * ctx,unsigned count,const struct pipe_vertex_element * state)206 static void *noop_create_vertex_elements(struct pipe_context *ctx,
207 unsigned count,
208 const struct pipe_vertex_element *state)
209 {
210 return MALLOC(1);
211 }
212
noop_create_shader_state(struct pipe_context * ctx,const struct pipe_shader_state * state)213 static void *noop_create_shader_state(struct pipe_context *ctx,
214 const struct pipe_shader_state *state)
215 {
216 return MALLOC(1);
217 }
218
noop_create_compute_state(struct pipe_context * ctx,const struct pipe_compute_state * state)219 static void *noop_create_compute_state(struct pipe_context *ctx,
220 const struct pipe_compute_state *state)
221 {
222 return MALLOC(1);
223 }
224
noop_create_stream_output_target(struct pipe_context * ctx,struct pipe_resource * res,unsigned buffer_offset,unsigned buffer_size)225 static struct pipe_stream_output_target *noop_create_stream_output_target(
226 struct pipe_context *ctx,
227 struct pipe_resource *res,
228 unsigned buffer_offset,
229 unsigned buffer_size)
230 {
231 struct pipe_stream_output_target *t = CALLOC_STRUCT(pipe_stream_output_target);
232 if (!t)
233 return NULL;
234
235 pipe_reference_init(&t->reference, 1);
236 pipe_resource_reference(&t->buffer, res);
237 t->buffer_offset = buffer_offset;
238 t->buffer_size = buffer_size;
239 return t;
240 }
241
noop_stream_output_target_destroy(struct pipe_context * ctx,struct pipe_stream_output_target * t)242 static void noop_stream_output_target_destroy(struct pipe_context *ctx,
243 struct pipe_stream_output_target *t)
244 {
245 pipe_resource_reference(&t->buffer, NULL);
246 FREE(t);
247 }
248
noop_set_stream_output_targets(struct pipe_context * ctx,unsigned num_targets,struct pipe_stream_output_target ** targets,const unsigned * offsets)249 static void noop_set_stream_output_targets(struct pipe_context *ctx,
250 unsigned num_targets,
251 struct pipe_stream_output_target **targets,
252 const unsigned *offsets)
253 {
254 }
255
noop_set_window_rectangles(struct pipe_context * ctx,bool include,unsigned num_rectangles,const struct pipe_scissor_state * rects)256 static void noop_set_window_rectangles(struct pipe_context *ctx,
257 bool include,
258 unsigned num_rectangles,
259 const struct pipe_scissor_state *rects)
260 {
261 }
262
263 void noop_init_state_functions(struct pipe_context *ctx);
264
noop_init_state_functions(struct pipe_context * ctx)265 void noop_init_state_functions(struct pipe_context *ctx)
266 {
267 ctx->create_blend_state = noop_create_blend_state;
268 ctx->create_depth_stencil_alpha_state = noop_create_dsa_state;
269 ctx->create_fs_state = noop_create_shader_state;
270 ctx->create_rasterizer_state = noop_create_rs_state;
271 ctx->create_sampler_state = noop_create_sampler_state;
272 ctx->create_sampler_view = noop_create_sampler_view;
273 ctx->create_surface = noop_create_surface;
274 ctx->create_vertex_elements_state = noop_create_vertex_elements;
275 ctx->create_compute_state = noop_create_compute_state;
276 ctx->create_tcs_state = noop_create_shader_state;
277 ctx->create_tes_state = noop_create_shader_state;
278 ctx->create_gs_state = noop_create_shader_state;
279 ctx->create_vs_state = noop_create_shader_state;
280 ctx->bind_blend_state = noop_bind_state;
281 ctx->bind_depth_stencil_alpha_state = noop_bind_state;
282 ctx->bind_sampler_states = noop_bind_sampler_states;
283 ctx->bind_fs_state = noop_bind_state;
284 ctx->bind_rasterizer_state = noop_bind_state;
285 ctx->bind_vertex_elements_state = noop_bind_state;
286 ctx->bind_compute_state = noop_bind_state;
287 ctx->bind_tcs_state = noop_bind_state;
288 ctx->bind_tes_state = noop_bind_state;
289 ctx->bind_gs_state = noop_bind_state;
290 ctx->bind_vs_state = noop_bind_state;
291 ctx->delete_blend_state = noop_delete_state;
292 ctx->delete_depth_stencil_alpha_state = noop_delete_state;
293 ctx->delete_fs_state = noop_delete_state;
294 ctx->delete_rasterizer_state = noop_delete_state;
295 ctx->delete_sampler_state = noop_delete_state;
296 ctx->delete_vertex_elements_state = noop_delete_state;
297 ctx->delete_compute_state = noop_delete_state;
298 ctx->delete_tcs_state = noop_delete_state;
299 ctx->delete_tes_state = noop_delete_state;
300 ctx->delete_gs_state = noop_delete_state;
301 ctx->delete_vs_state = noop_delete_state;
302 ctx->set_blend_color = noop_set_blend_color;
303 ctx->set_clip_state = noop_set_clip_state;
304 ctx->set_constant_buffer = noop_set_constant_buffer;
305 ctx->set_inlinable_constants = noop_set_inlinable_constants;
306 ctx->set_sampler_views = noop_set_sampler_views;
307 ctx->set_framebuffer_state = noop_set_framebuffer_state;
308 ctx->set_polygon_stipple = noop_set_polygon_stipple;
309 ctx->set_sample_mask = noop_set_sample_mask;
310 ctx->set_scissor_states = noop_set_scissor_states;
311 ctx->set_stencil_ref = noop_set_stencil_ref;
312 ctx->set_vertex_buffers = noop_set_vertex_buffers;
313 ctx->set_viewport_states = noop_set_viewport_states;
314 ctx->set_window_rectangles = noop_set_window_rectangles;
315 ctx->sampler_view_destroy = noop_sampler_view_destroy;
316 ctx->surface_destroy = noop_surface_destroy;
317 ctx->draw_vbo = noop_draw_vbo;
318 ctx->launch_grid = noop_launch_grid;
319 ctx->create_stream_output_target = noop_create_stream_output_target;
320 ctx->stream_output_target_destroy = noop_stream_output_target_destroy;
321 ctx->set_stream_output_targets = noop_set_stream_output_targets;
322 }
323