2 * Copyright 2010 Red Hat Inc.
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:
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
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.
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"
33 static void noop_draw_vbo(struct pipe_context
*ctx
, const struct pipe_draw_info
*info
)
37 static void noop_launch_grid(struct pipe_context
*ctx
,
38 const struct pipe_grid_info
*info
)
42 static void noop_set_blend_color(struct pipe_context
*ctx
,
43 const struct pipe_blend_color
*state
)
47 static void *noop_create_blend_state(struct pipe_context
*ctx
,
48 const struct pipe_blend_state
*state
)
53 static void *noop_create_dsa_state(struct pipe_context
*ctx
,
54 const struct pipe_depth_stencil_alpha_state
*state
)
59 static void *noop_create_rs_state(struct pipe_context
*ctx
,
60 const struct pipe_rasterizer_state
*state
)
65 static void *noop_create_sampler_state(struct pipe_context
*ctx
,
66 const struct pipe_sampler_state
*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
)
75 struct pipe_sampler_view
*sampler_view
= CALLOC_STRUCT(pipe_sampler_view
);
79 /* initialize base object */
80 pipe_resource_reference(&sampler_view
->texture
, texture
);
81 pipe_reference_init(&sampler_view
->reference
, 1);
82 sampler_view
->context
= ctx
;
86 static struct pipe_surface
*noop_create_surface(struct pipe_context
*ctx
,
87 struct pipe_resource
*texture
,
88 const struct pipe_surface
*surf_tmpl
)
90 struct pipe_surface
*surface
= CALLOC_STRUCT(pipe_surface
);
94 pipe_reference_init(&surface
->reference
, 1);
95 pipe_resource_reference(&surface
->texture
, texture
);
96 surface
->context
= ctx
;
97 surface
->format
= surf_tmpl
->format
;
98 surface
->width
= texture
->width0
;
99 surface
->height
= texture
->height0
;
100 surface
->texture
= texture
;
101 surface
->u
.tex
.first_layer
= surf_tmpl
->u
.tex
.first_layer
;
102 surface
->u
.tex
.last_layer
= surf_tmpl
->u
.tex
.last_layer
;
103 surface
->u
.tex
.level
= surf_tmpl
->u
.tex
.level
;
108 static void noop_set_sampler_views(struct pipe_context
*ctx
,
109 enum pipe_shader_type shader
,
110 unsigned start
, unsigned count
,
111 struct pipe_sampler_view
**views
)
115 static void noop_bind_sampler_states(struct pipe_context
*ctx
,
116 enum pipe_shader_type shader
,
117 unsigned start
, unsigned count
,
122 static void noop_set_clip_state(struct pipe_context
*ctx
,
123 const struct pipe_clip_state
*state
)
127 static void noop_set_polygon_stipple(struct pipe_context
*ctx
,
128 const struct pipe_poly_stipple
*state
)
132 static void noop_set_sample_mask(struct pipe_context
*pipe
, unsigned sample_mask
)
136 static void noop_set_scissor_states(struct pipe_context
*ctx
,
138 unsigned num_scissors
,
139 const struct pipe_scissor_state
*state
)
143 static void noop_set_stencil_ref(struct pipe_context
*ctx
,
144 const struct pipe_stencil_ref
*state
)
148 static void noop_set_viewport_states(struct pipe_context
*ctx
,
150 unsigned num_viewports
,
151 const struct pipe_viewport_state
*state
)
155 static void noop_set_framebuffer_state(struct pipe_context
*ctx
,
156 const struct pipe_framebuffer_state
*state
)
160 static void noop_set_constant_buffer(struct pipe_context
*ctx
,
161 uint shader
, uint index
,
162 const struct pipe_constant_buffer
*cb
)
167 static void noop_sampler_view_destroy(struct pipe_context
*ctx
,
168 struct pipe_sampler_view
*state
)
170 pipe_resource_reference(&state
->texture
, NULL
);
175 static void noop_surface_destroy(struct pipe_context
*ctx
,
176 struct pipe_surface
*surface
)
178 pipe_resource_reference(&surface
->texture
, NULL
);
182 static void noop_bind_state(struct pipe_context
*ctx
, void *state
)
186 static void noop_delete_state(struct pipe_context
*ctx
, void *state
)
191 static void noop_set_index_buffer(struct pipe_context
*ctx
,
192 const struct pipe_index_buffer
*ib
)
196 static void noop_set_vertex_buffers(struct pipe_context
*ctx
,
197 unsigned start_slot
, unsigned count
,
198 const struct pipe_vertex_buffer
*buffers
)
202 static void *noop_create_vertex_elements(struct pipe_context
*ctx
,
204 const struct pipe_vertex_element
*state
)
209 static void *noop_create_shader_state(struct pipe_context
*ctx
,
210 const struct pipe_shader_state
*state
)
215 static void *noop_create_compute_state(struct pipe_context
*ctx
,
216 const struct pipe_compute_state
*state
)
221 static struct pipe_stream_output_target
*noop_create_stream_output_target(
222 struct pipe_context
*ctx
,
223 struct pipe_resource
*res
,
224 unsigned buffer_offset
,
225 unsigned buffer_size
)
227 struct pipe_stream_output_target
*t
= CALLOC_STRUCT(pipe_stream_output_target
);
231 pipe_reference_init(&t
->reference
, 1);
232 pipe_resource_reference(&t
->buffer
, res
);
233 t
->buffer_offset
= buffer_offset
;
234 t
->buffer_size
= buffer_size
;
238 static void noop_stream_output_target_destroy(struct pipe_context
*ctx
,
239 struct pipe_stream_output_target
*t
)
241 pipe_resource_reference(&t
->buffer
, NULL
);
245 static void noop_set_stream_output_targets(struct pipe_context
*ctx
,
246 unsigned num_targets
,
247 struct pipe_stream_output_target
**targets
,
248 const unsigned *offsets
)
252 void noop_init_state_functions(struct pipe_context
*ctx
);
254 void noop_init_state_functions(struct pipe_context
*ctx
)
256 ctx
->create_blend_state
= noop_create_blend_state
;
257 ctx
->create_depth_stencil_alpha_state
= noop_create_dsa_state
;
258 ctx
->create_fs_state
= noop_create_shader_state
;
259 ctx
->create_rasterizer_state
= noop_create_rs_state
;
260 ctx
->create_sampler_state
= noop_create_sampler_state
;
261 ctx
->create_sampler_view
= noop_create_sampler_view
;
262 ctx
->create_surface
= noop_create_surface
;
263 ctx
->create_vertex_elements_state
= noop_create_vertex_elements
;
264 ctx
->create_compute_state
= noop_create_compute_state
;
265 ctx
->create_tcs_state
= noop_create_shader_state
;
266 ctx
->create_tes_state
= noop_create_shader_state
;
267 ctx
->create_gs_state
= noop_create_shader_state
;
268 ctx
->create_vs_state
= noop_create_shader_state
;
269 ctx
->bind_blend_state
= noop_bind_state
;
270 ctx
->bind_depth_stencil_alpha_state
= noop_bind_state
;
271 ctx
->bind_sampler_states
= noop_bind_sampler_states
;
272 ctx
->bind_fs_state
= noop_bind_state
;
273 ctx
->bind_rasterizer_state
= noop_bind_state
;
274 ctx
->bind_vertex_elements_state
= noop_bind_state
;
275 ctx
->bind_compute_state
= noop_bind_state
;
276 ctx
->bind_tcs_state
= noop_bind_state
;
277 ctx
->bind_tes_state
= noop_bind_state
;
278 ctx
->bind_gs_state
= noop_bind_state
;
279 ctx
->bind_vs_state
= noop_bind_state
;
280 ctx
->delete_blend_state
= noop_delete_state
;
281 ctx
->delete_depth_stencil_alpha_state
= noop_delete_state
;
282 ctx
->delete_fs_state
= noop_delete_state
;
283 ctx
->delete_rasterizer_state
= noop_delete_state
;
284 ctx
->delete_sampler_state
= noop_delete_state
;
285 ctx
->delete_vertex_elements_state
= noop_delete_state
;
286 ctx
->delete_compute_state
= noop_delete_state
;
287 ctx
->delete_tcs_state
= noop_delete_state
;
288 ctx
->delete_tes_state
= noop_delete_state
;
289 ctx
->delete_gs_state
= noop_delete_state
;
290 ctx
->delete_vs_state
= noop_delete_state
;
291 ctx
->set_blend_color
= noop_set_blend_color
;
292 ctx
->set_clip_state
= noop_set_clip_state
;
293 ctx
->set_constant_buffer
= noop_set_constant_buffer
;
294 ctx
->set_sampler_views
= noop_set_sampler_views
;
295 ctx
->set_framebuffer_state
= noop_set_framebuffer_state
;
296 ctx
->set_polygon_stipple
= noop_set_polygon_stipple
;
297 ctx
->set_sample_mask
= noop_set_sample_mask
;
298 ctx
->set_scissor_states
= noop_set_scissor_states
;
299 ctx
->set_stencil_ref
= noop_set_stencil_ref
;
300 ctx
->set_vertex_buffers
= noop_set_vertex_buffers
;
301 ctx
->set_index_buffer
= noop_set_index_buffer
;
302 ctx
->set_viewport_states
= noop_set_viewport_states
;
303 ctx
->sampler_view_destroy
= noop_sampler_view_destroy
;
304 ctx
->surface_destroy
= noop_surface_destroy
;
305 ctx
->draw_vbo
= noop_draw_vbo
;
306 ctx
->launch_grid
= noop_launch_grid
;
307 ctx
->create_stream_output_target
= noop_create_stream_output_target
;
308 ctx
->stream_output_target_destroy
= noop_stream_output_target_destroy
;
309 ctx
->set_stream_output_targets
= noop_set_stream_output_targets
;