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,unsigned drawid_offset,const struct pipe_draw_indirect_info * indirect,const struct pipe_draw_start_count_bias * draws,unsigned num_draws)33 static void noop_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info,
34 unsigned drawid_offset,
35 const struct pipe_draw_indirect_info *indirect,
36 const struct pipe_draw_start_count_bias *draws,
37 unsigned num_draws)
38 {
39 }
40
noop_draw_vertex_state(struct pipe_context * ctx,struct pipe_vertex_state * state,uint32_t partial_velem_mask,struct pipe_draw_vertex_state_info info,const struct pipe_draw_start_count_bias * draws,unsigned num_draws)41 static void noop_draw_vertex_state(struct pipe_context *ctx,
42 struct pipe_vertex_state *state,
43 uint32_t partial_velem_mask,
44 struct pipe_draw_vertex_state_info info,
45 const struct pipe_draw_start_count_bias *draws,
46 unsigned num_draws)
47 {
48 }
49
noop_launch_grid(struct pipe_context * ctx,const struct pipe_grid_info * info)50 static void noop_launch_grid(struct pipe_context *ctx,
51 const struct pipe_grid_info *info)
52 {
53 }
54
noop_set_blend_color(struct pipe_context * ctx,const struct pipe_blend_color * state)55 static void noop_set_blend_color(struct pipe_context *ctx,
56 const struct pipe_blend_color *state)
57 {
58 }
59
noop_create_blend_state(struct pipe_context * ctx,const struct pipe_blend_state * state)60 static void *noop_create_blend_state(struct pipe_context *ctx,
61 const struct pipe_blend_state *state)
62 {
63 return MALLOC(1);
64 }
65
noop_create_dsa_state(struct pipe_context * ctx,const struct pipe_depth_stencil_alpha_state * state)66 static void *noop_create_dsa_state(struct pipe_context *ctx,
67 const struct pipe_depth_stencil_alpha_state *state)
68 {
69 return MALLOC(1);
70 }
71
noop_create_rs_state(struct pipe_context * ctx,const struct pipe_rasterizer_state * state)72 static void *noop_create_rs_state(struct pipe_context *ctx,
73 const struct pipe_rasterizer_state *state)
74 {
75 return MALLOC(1);
76 }
77
noop_create_sampler_state(struct pipe_context * ctx,const struct pipe_sampler_state * state)78 static void *noop_create_sampler_state(struct pipe_context *ctx,
79 const struct pipe_sampler_state *state)
80 {
81 return MALLOC(1);
82 }
83
noop_create_sampler_view(struct pipe_context * ctx,struct pipe_resource * texture,const struct pipe_sampler_view * state)84 static struct pipe_sampler_view *noop_create_sampler_view(struct pipe_context *ctx,
85 struct pipe_resource *texture,
86 const struct pipe_sampler_view *state)
87 {
88 struct pipe_sampler_view *sampler_view = CALLOC_STRUCT(pipe_sampler_view);
89
90 if (!sampler_view)
91 return NULL;
92
93 /* initialize base object */
94 *sampler_view = *state;
95 sampler_view->texture = NULL;
96 pipe_resource_reference(&sampler_view->texture, texture);
97 pipe_reference_init(&sampler_view->reference, 1);
98 sampler_view->context = ctx;
99 return sampler_view;
100 }
101
noop_create_surface(struct pipe_context * ctx,struct pipe_resource * texture,const struct pipe_surface * surf_tmpl)102 static struct pipe_surface *noop_create_surface(struct pipe_context *ctx,
103 struct pipe_resource *texture,
104 const struct pipe_surface *surf_tmpl)
105 {
106 struct pipe_surface *surface = CALLOC_STRUCT(pipe_surface);
107
108 if (!surface)
109 return NULL;
110 pipe_reference_init(&surface->reference, 1);
111 pipe_resource_reference(&surface->texture, texture);
112 surface->context = ctx;
113 surface->format = surf_tmpl->format;
114 surface->width = texture->width0;
115 surface->height = texture->height0;
116 surface->texture = texture;
117 surface->u.tex.first_layer = surf_tmpl->u.tex.first_layer;
118 surface->u.tex.last_layer = surf_tmpl->u.tex.last_layer;
119 surface->u.tex.level = surf_tmpl->u.tex.level;
120
121 return surface;
122 }
123
noop_set_sampler_views(struct pipe_context * ctx,enum pipe_shader_type shader,unsigned start,unsigned count,unsigned unbind_num_trailing_slots,bool take_ownership,struct pipe_sampler_view ** views)124 static void noop_set_sampler_views(struct pipe_context *ctx,
125 enum pipe_shader_type shader,
126 unsigned start, unsigned count,
127 unsigned unbind_num_trailing_slots,
128 bool take_ownership,
129 struct pipe_sampler_view **views)
130 {
131 }
132
noop_bind_sampler_states(struct pipe_context * ctx,enum pipe_shader_type shader,unsigned start,unsigned count,void ** states)133 static void noop_bind_sampler_states(struct pipe_context *ctx,
134 enum pipe_shader_type shader,
135 unsigned start, unsigned count,
136 void **states)
137 {
138 }
139
noop_set_clip_state(struct pipe_context * ctx,const struct pipe_clip_state * state)140 static void noop_set_clip_state(struct pipe_context *ctx,
141 const struct pipe_clip_state *state)
142 {
143 }
144
noop_set_polygon_stipple(struct pipe_context * ctx,const struct pipe_poly_stipple * state)145 static void noop_set_polygon_stipple(struct pipe_context *ctx,
146 const struct pipe_poly_stipple *state)
147 {
148 }
149
noop_set_sample_mask(struct pipe_context * pipe,unsigned sample_mask)150 static void noop_set_sample_mask(struct pipe_context *pipe, unsigned sample_mask)
151 {
152 }
153
noop_set_scissor_states(struct pipe_context * ctx,unsigned start_slot,unsigned num_scissors,const struct pipe_scissor_state * state)154 static void noop_set_scissor_states(struct pipe_context *ctx,
155 unsigned start_slot,
156 unsigned num_scissors,
157 const struct pipe_scissor_state *state)
158 {
159 }
160
noop_set_stencil_ref(struct pipe_context * ctx,const struct pipe_stencil_ref state)161 static void noop_set_stencil_ref(struct pipe_context *ctx,
162 const struct pipe_stencil_ref state)
163 {
164 }
165
noop_set_viewport_states(struct pipe_context * ctx,unsigned start_slot,unsigned num_viewports,const struct pipe_viewport_state * state)166 static void noop_set_viewport_states(struct pipe_context *ctx,
167 unsigned start_slot,
168 unsigned num_viewports,
169 const struct pipe_viewport_state *state)
170 {
171 }
172
noop_set_framebuffer_state(struct pipe_context * ctx,const struct pipe_framebuffer_state * state)173 static void noop_set_framebuffer_state(struct pipe_context *ctx,
174 const struct pipe_framebuffer_state *state)
175 {
176 }
177
noop_set_constant_buffer(struct pipe_context * ctx,enum pipe_shader_type shader,uint index,bool take_ownership,const struct pipe_constant_buffer * cb)178 static void noop_set_constant_buffer(struct pipe_context *ctx,
179 enum pipe_shader_type shader, uint index,
180 bool take_ownership,
181 const struct pipe_constant_buffer *cb)
182 {
183 }
184
noop_set_inlinable_constants(struct pipe_context * ctx,enum pipe_shader_type shader,uint num_values,uint32_t * values)185 static void noop_set_inlinable_constants(struct pipe_context *ctx,
186 enum pipe_shader_type shader,
187 uint num_values, uint32_t *values)
188 {
189 }
190
191
noop_sampler_view_destroy(struct pipe_context * ctx,struct pipe_sampler_view * state)192 static void noop_sampler_view_destroy(struct pipe_context *ctx,
193 struct pipe_sampler_view *state)
194 {
195 pipe_resource_reference(&state->texture, NULL);
196 FREE(state);
197 }
198
199
noop_surface_destroy(struct pipe_context * ctx,struct pipe_surface * surface)200 static void noop_surface_destroy(struct pipe_context *ctx,
201 struct pipe_surface *surface)
202 {
203 pipe_resource_reference(&surface->texture, NULL);
204 FREE(surface);
205 }
206
noop_bind_state(struct pipe_context * ctx,void * state)207 static void noop_bind_state(struct pipe_context *ctx, void *state)
208 {
209 }
210
noop_delete_state(struct pipe_context * ctx,void * state)211 static void noop_delete_state(struct pipe_context *ctx, void *state)
212 {
213 FREE(state);
214 }
215
noop_set_vertex_buffers(struct pipe_context * ctx,unsigned start_slot,unsigned count,unsigned unbind_num_trailing_slots,bool take_ownership,const struct pipe_vertex_buffer * buffers)216 static void noop_set_vertex_buffers(struct pipe_context *ctx,
217 unsigned start_slot, unsigned count,
218 unsigned unbind_num_trailing_slots,
219 bool take_ownership,
220 const struct pipe_vertex_buffer *buffers)
221 {
222 }
223
noop_create_vertex_elements(struct pipe_context * ctx,unsigned count,const struct pipe_vertex_element * state)224 static void *noop_create_vertex_elements(struct pipe_context *ctx,
225 unsigned count,
226 const struct pipe_vertex_element *state)
227 {
228 return MALLOC(1);
229 }
230
noop_create_shader_state(struct pipe_context * ctx,const struct pipe_shader_state * state)231 static void *noop_create_shader_state(struct pipe_context *ctx,
232 const struct pipe_shader_state *state)
233 {
234 return MALLOC(1);
235 }
236
noop_create_compute_state(struct pipe_context * ctx,const struct pipe_compute_state * state)237 static void *noop_create_compute_state(struct pipe_context *ctx,
238 const struct pipe_compute_state *state)
239 {
240 return MALLOC(1);
241 }
242
noop_create_stream_output_target(struct pipe_context * ctx,struct pipe_resource * res,unsigned buffer_offset,unsigned buffer_size)243 static struct pipe_stream_output_target *noop_create_stream_output_target(
244 struct pipe_context *ctx,
245 struct pipe_resource *res,
246 unsigned buffer_offset,
247 unsigned buffer_size)
248 {
249 struct pipe_stream_output_target *t = CALLOC_STRUCT(pipe_stream_output_target);
250 if (!t)
251 return NULL;
252
253 pipe_reference_init(&t->reference, 1);
254 pipe_resource_reference(&t->buffer, res);
255 t->buffer_offset = buffer_offset;
256 t->buffer_size = buffer_size;
257 return t;
258 }
259
noop_stream_output_target_destroy(struct pipe_context * ctx,struct pipe_stream_output_target * t)260 static void noop_stream_output_target_destroy(struct pipe_context *ctx,
261 struct pipe_stream_output_target *t)
262 {
263 pipe_resource_reference(&t->buffer, NULL);
264 FREE(t);
265 }
266
noop_set_stream_output_targets(struct pipe_context * ctx,unsigned num_targets,struct pipe_stream_output_target ** targets,const unsigned * offsets)267 static void noop_set_stream_output_targets(struct pipe_context *ctx,
268 unsigned num_targets,
269 struct pipe_stream_output_target **targets,
270 const unsigned *offsets)
271 {
272 }
273
noop_set_window_rectangles(struct pipe_context * ctx,bool include,unsigned num_rectangles,const struct pipe_scissor_state * rects)274 static void noop_set_window_rectangles(struct pipe_context *ctx,
275 bool include,
276 unsigned num_rectangles,
277 const struct pipe_scissor_state *rects)
278 {
279 }
280
noop_set_shader_buffers(struct pipe_context * ctx,enum pipe_shader_type shader,unsigned start_slot,unsigned count,const struct pipe_shader_buffer * buffers,unsigned writable_bitmask)281 static void noop_set_shader_buffers(struct pipe_context *ctx,
282 enum pipe_shader_type shader,
283 unsigned start_slot, unsigned count,
284 const struct pipe_shader_buffer *buffers,
285 unsigned writable_bitmask)
286 {
287 }
288
noop_set_shader_images(struct pipe_context * ctx,enum pipe_shader_type shader,unsigned start_slot,unsigned count,unsigned unbind_num_trailing_slots,const struct pipe_image_view * images)289 static void noop_set_shader_images(struct pipe_context *ctx,
290 enum pipe_shader_type shader,
291 unsigned start_slot, unsigned count,
292 unsigned unbind_num_trailing_slots,
293 const struct pipe_image_view *images)
294 {
295 }
296
noop_render_condition(struct pipe_context * pipe,struct pipe_query * query,bool condition,enum pipe_render_cond_flag mode)297 static void noop_render_condition( struct pipe_context *pipe,
298 struct pipe_query *query,
299 bool condition,
300 enum pipe_render_cond_flag mode )
301 {
302 }
303
noop_get_query_result_resource(struct pipe_context * pipe,struct pipe_query * q,enum pipe_query_flags flags,enum pipe_query_value_type result_type,int index,struct pipe_resource * resource,unsigned offset)304 static void noop_get_query_result_resource(struct pipe_context *pipe,
305 struct pipe_query *q,
306 enum pipe_query_flags flags,
307 enum pipe_query_value_type result_type,
308 int index,
309 struct pipe_resource *resource,
310 unsigned offset)
311 {
312 }
313
noop_set_min_samples(struct pipe_context * ctx,unsigned min_samples)314 static void noop_set_min_samples( struct pipe_context *ctx,
315 unsigned min_samples )
316 {
317 }
318
noop_set_sample_locations(struct pipe_context * ctx,size_t size,const uint8_t * locations)319 static void noop_set_sample_locations( struct pipe_context *ctx,
320 size_t size, const uint8_t *locations )
321 {
322 }
323
noop_set_tess_state(struct pipe_context * ctx,const float default_outer_level[4],const float default_inner_level[2])324 static void noop_set_tess_state(struct pipe_context *ctx,
325 const float default_outer_level[4],
326 const float default_inner_level[2])
327 {
328 }
329
noop_clear_texture(struct pipe_context * pipe,struct pipe_resource * res,unsigned level,const struct pipe_box * box,const void * data)330 static void noop_clear_texture(struct pipe_context *pipe,
331 struct pipe_resource *res,
332 unsigned level,
333 const struct pipe_box *box,
334 const void *data)
335 {
336 }
337
noop_clear_buffer(struct pipe_context * pipe,struct pipe_resource * res,unsigned offset,unsigned size,const void * clear_value,int clear_value_size)338 static void noop_clear_buffer(struct pipe_context *pipe,
339 struct pipe_resource *res,
340 unsigned offset,
341 unsigned size,
342 const void *clear_value,
343 int clear_value_size)
344 {
345 }
346
noop_fence_server_sync(struct pipe_context * pipe,struct pipe_fence_handle * fence)347 static void noop_fence_server_sync(struct pipe_context *pipe,
348 struct pipe_fence_handle *fence)
349 {
350 }
351
noop_texture_barrier(struct pipe_context * ctx,unsigned flags)352 static void noop_texture_barrier(struct pipe_context *ctx, unsigned flags)
353 {
354 }
355
noop_memory_barrier(struct pipe_context * ctx,unsigned flags)356 static void noop_memory_barrier(struct pipe_context *ctx, unsigned flags)
357 {
358 }
359
noop_resource_commit(struct pipe_context * ctx,struct pipe_resource * res,unsigned level,struct pipe_box * box,bool commit)360 static bool noop_resource_commit(struct pipe_context *ctx, struct pipe_resource *res,
361 unsigned level, struct pipe_box *box, bool commit)
362 {
363 return true;
364 }
365
noop_get_sample_position(struct pipe_context * context,unsigned sample_count,unsigned sample_index,float * out_value)366 static void noop_get_sample_position(struct pipe_context *context,
367 unsigned sample_count,
368 unsigned sample_index,
369 float *out_value)
370 {
371 }
372
noop_get_device_reset_status(struct pipe_context * ctx)373 static enum pipe_reset_status noop_get_device_reset_status(struct pipe_context *ctx)
374 {
375 return PIPE_NO_RESET;
376 }
377
noop_create_texture_handle(struct pipe_context * ctx,struct pipe_sampler_view * view,const struct pipe_sampler_state * state)378 static uint64_t noop_create_texture_handle(struct pipe_context *ctx,
379 struct pipe_sampler_view *view,
380 const struct pipe_sampler_state *state)
381 {
382 return 1;
383 }
384
noop_delete_texture_handle(struct pipe_context * ctx,uint64_t handle)385 static void noop_delete_texture_handle(struct pipe_context *ctx, uint64_t handle)
386 {
387 }
388
noop_make_texture_handle_resident(struct pipe_context * ctx,uint64_t handle,bool resident)389 static void noop_make_texture_handle_resident(struct pipe_context *ctx,
390 uint64_t handle, bool resident)
391 {
392 }
393
noop_create_image_handle(struct pipe_context * ctx,const struct pipe_image_view * image)394 static uint64_t noop_create_image_handle(struct pipe_context *ctx,
395 const struct pipe_image_view *image)
396 {
397 return 2;
398 }
399
noop_delete_image_handle(struct pipe_context * ctx,uint64_t handle)400 static void noop_delete_image_handle(struct pipe_context *ctx, uint64_t handle)
401 {
402 }
403
noop_make_image_handle_resident(struct pipe_context * ctx,uint64_t handle,unsigned access,bool resident)404 static void noop_make_image_handle_resident(struct pipe_context *ctx, uint64_t handle,
405 unsigned access, bool resident)
406 {
407 }
408
noop_set_patch_vertices(struct pipe_context * ctx,uint8_t patch_vertices)409 static void noop_set_patch_vertices(struct pipe_context *ctx,
410 uint8_t patch_vertices)
411 {
412 }
413
414 void noop_init_state_functions(struct pipe_context *ctx);
415
noop_init_state_functions(struct pipe_context * ctx)416 void noop_init_state_functions(struct pipe_context *ctx)
417 {
418 ctx->create_blend_state = noop_create_blend_state;
419 ctx->create_depth_stencil_alpha_state = noop_create_dsa_state;
420 ctx->create_fs_state = noop_create_shader_state;
421 ctx->create_rasterizer_state = noop_create_rs_state;
422 ctx->create_sampler_state = noop_create_sampler_state;
423 ctx->create_sampler_view = noop_create_sampler_view;
424 ctx->create_surface = noop_create_surface;
425 ctx->create_vertex_elements_state = noop_create_vertex_elements;
426 ctx->create_compute_state = noop_create_compute_state;
427 ctx->create_tcs_state = noop_create_shader_state;
428 ctx->create_tes_state = noop_create_shader_state;
429 ctx->create_gs_state = noop_create_shader_state;
430 ctx->create_vs_state = noop_create_shader_state;
431 ctx->bind_blend_state = noop_bind_state;
432 ctx->bind_depth_stencil_alpha_state = noop_bind_state;
433 ctx->bind_sampler_states = noop_bind_sampler_states;
434 ctx->bind_fs_state = noop_bind_state;
435 ctx->bind_rasterizer_state = noop_bind_state;
436 ctx->bind_vertex_elements_state = noop_bind_state;
437 ctx->bind_compute_state = noop_bind_state;
438 ctx->bind_tcs_state = noop_bind_state;
439 ctx->bind_tes_state = noop_bind_state;
440 ctx->bind_gs_state = noop_bind_state;
441 ctx->bind_vs_state = noop_bind_state;
442 ctx->delete_blend_state = noop_delete_state;
443 ctx->delete_depth_stencil_alpha_state = noop_delete_state;
444 ctx->delete_fs_state = noop_delete_state;
445 ctx->delete_rasterizer_state = noop_delete_state;
446 ctx->delete_sampler_state = noop_delete_state;
447 ctx->delete_vertex_elements_state = noop_delete_state;
448 ctx->delete_compute_state = noop_delete_state;
449 ctx->delete_tcs_state = noop_delete_state;
450 ctx->delete_tes_state = noop_delete_state;
451 ctx->delete_gs_state = noop_delete_state;
452 ctx->delete_vs_state = noop_delete_state;
453 ctx->set_blend_color = noop_set_blend_color;
454 ctx->set_clip_state = noop_set_clip_state;
455 ctx->set_constant_buffer = noop_set_constant_buffer;
456 ctx->set_inlinable_constants = noop_set_inlinable_constants;
457 ctx->set_sampler_views = noop_set_sampler_views;
458 ctx->set_shader_buffers = noop_set_shader_buffers;
459 ctx->set_shader_images = noop_set_shader_images;
460 ctx->set_framebuffer_state = noop_set_framebuffer_state;
461 ctx->set_polygon_stipple = noop_set_polygon_stipple;
462 ctx->set_sample_mask = noop_set_sample_mask;
463 ctx->set_scissor_states = noop_set_scissor_states;
464 ctx->set_stencil_ref = noop_set_stencil_ref;
465 ctx->set_vertex_buffers = noop_set_vertex_buffers;
466 ctx->set_viewport_states = noop_set_viewport_states;
467 ctx->set_window_rectangles = noop_set_window_rectangles;
468 ctx->sampler_view_destroy = noop_sampler_view_destroy;
469 ctx->surface_destroy = noop_surface_destroy;
470 ctx->draw_vbo = noop_draw_vbo;
471 ctx->draw_vertex_state = noop_draw_vertex_state;
472 ctx->launch_grid = noop_launch_grid;
473 ctx->create_stream_output_target = noop_create_stream_output_target;
474 ctx->stream_output_target_destroy = noop_stream_output_target_destroy;
475 ctx->set_stream_output_targets = noop_set_stream_output_targets;
476 ctx->render_condition = noop_render_condition;
477 ctx->get_query_result_resource = noop_get_query_result_resource;
478 ctx->set_min_samples = noop_set_min_samples;
479 ctx->set_sample_locations = noop_set_sample_locations;
480 ctx->set_tess_state = noop_set_tess_state;
481 ctx->clear_texture = noop_clear_texture;
482 ctx->clear_buffer = noop_clear_buffer;
483 ctx->fence_server_sync = noop_fence_server_sync;
484 ctx->texture_barrier = noop_texture_barrier;
485 ctx->memory_barrier = noop_memory_barrier;
486 ctx->resource_commit = noop_resource_commit;
487 ctx->get_sample_position = noop_get_sample_position;
488 ctx->get_device_reset_status = noop_get_device_reset_status;
489 ctx->create_texture_handle = noop_create_texture_handle;
490 ctx->delete_texture_handle = noop_delete_texture_handle;
491 ctx->make_texture_handle_resident = noop_make_texture_handle_resident;
492 ctx->create_image_handle = noop_create_image_handle;
493 ctx->delete_image_handle = noop_delete_image_handle;
494 ctx->make_image_handle_resident = noop_make_image_handle_resident;
495 ctx->set_patch_vertices = noop_set_patch_vertices;
496 }
497