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>
32 static void noop_draw_vbo(struct pipe_context
*ctx
, const struct pipe_draw_info
*info
)
36 static void noop_set_blend_color(struct pipe_context
*ctx
,
37 const struct pipe_blend_color
*state
)
41 static void *noop_create_blend_state(struct pipe_context
*ctx
,
42 const struct pipe_blend_state
*state
)
44 struct pipe_blend_state
*nstate
= CALLOC_STRUCT(pipe_blend_state
);
53 static void *noop_create_dsa_state(struct pipe_context
*ctx
,
54 const struct pipe_depth_stencil_alpha_state
*state
)
56 struct pipe_depth_stencil_alpha_state
*nstate
= CALLOC_STRUCT(pipe_depth_stencil_alpha_state
);
65 static void *noop_create_rs_state(struct pipe_context
*ctx
,
66 const struct pipe_rasterizer_state
*state
)
68 struct pipe_rasterizer_state
*nstate
= CALLOC_STRUCT(pipe_rasterizer_state
);
77 static void *noop_create_sampler_state(struct pipe_context
*ctx
,
78 const struct pipe_sampler_state
*state
)
80 struct pipe_sampler_state
*nstate
= CALLOC_STRUCT(pipe_sampler_state
);
89 static struct pipe_sampler_view
*noop_create_sampler_view(struct pipe_context
*ctx
,
90 struct pipe_resource
*texture
,
91 const struct pipe_sampler_view
*state
)
93 struct pipe_sampler_view
*sampler_view
= CALLOC_STRUCT(pipe_sampler_view
);
95 if (sampler_view
== NULL
)
97 /* initialize base object */
98 pipe_resource_reference(&sampler_view
->texture
, texture
);
99 pipe_reference_init(&sampler_view
->reference
, 1);
100 sampler_view
->context
= ctx
;
104 static struct pipe_surface
*noop_create_surface(struct pipe_context
*ctx
,
105 struct pipe_resource
*texture
,
106 const struct pipe_surface
*surf_tmpl
)
108 struct pipe_surface
*surface
= CALLOC_STRUCT(pipe_surface
);
112 pipe_reference_init(&surface
->reference
, 1);
113 pipe_resource_reference(&surface
->texture
, texture
);
114 surface
->context
= ctx
;
115 surface
->format
= surf_tmpl
->format
;
116 surface
->width
= texture
->width0
;
117 surface
->height
= texture
->height0
;
118 surface
->usage
= surf_tmpl
->usage
;
119 surface
->texture
= texture
;
120 surface
->u
.tex
.first_layer
= surf_tmpl
->u
.tex
.first_layer
;
121 surface
->u
.tex
.last_layer
= surf_tmpl
->u
.tex
.last_layer
;
122 surface
->u
.tex
.level
= surf_tmpl
->u
.tex
.level
;
126 static void noop_set_vs_sampler_view(struct pipe_context
*ctx
, unsigned count
,
127 struct pipe_sampler_view
**views
)
131 static void noop_set_ps_sampler_view(struct pipe_context
*ctx
, unsigned count
,
132 struct pipe_sampler_view
**views
)
136 static void noop_bind_sampler(struct pipe_context
*ctx
, unsigned count
, void **states
)
140 static void noop_set_clip_state(struct pipe_context
*ctx
,
141 const struct pipe_clip_state
*state
)
145 static void noop_set_polygon_stipple(struct pipe_context
*ctx
,
146 const struct pipe_poly_stipple
*state
)
150 static void noop_set_sample_mask(struct pipe_context
*pipe
, unsigned sample_mask
)
154 static void noop_set_scissor_state(struct pipe_context
*ctx
,
155 const struct pipe_scissor_state
*state
)
159 static void noop_set_stencil_ref(struct pipe_context
*ctx
,
160 const struct pipe_stencil_ref
*state
)
164 static void noop_set_viewport_state(struct pipe_context
*ctx
,
165 const struct pipe_viewport_state
*state
)
169 static void noop_set_framebuffer_state(struct pipe_context
*ctx
,
170 const struct pipe_framebuffer_state
*state
)
174 static void noop_set_constant_buffer(struct pipe_context
*ctx
,
175 uint shader
, uint index
,
176 struct pipe_resource
*buffer
)
181 static void noop_sampler_view_destroy(struct pipe_context
*ctx
,
182 struct pipe_sampler_view
*state
)
184 pipe_resource_reference(&state
->texture
, NULL
);
189 static void noop_surface_destroy(struct pipe_context
*ctx
,
190 struct pipe_surface
*surface
)
192 pipe_resource_reference(&surface
->texture
, NULL
);
196 static void noop_bind_state(struct pipe_context
*ctx
, void *state
)
200 static void noop_delete_state(struct pipe_context
*ctx
, void *state
)
205 static void noop_delete_vertex_element(struct pipe_context
*ctx
, void *state
)
211 static void noop_set_index_buffer(struct pipe_context
*ctx
,
212 const struct pipe_index_buffer
*ib
)
216 static void noop_set_vertex_buffers(struct pipe_context
*ctx
, unsigned count
,
217 const struct pipe_vertex_buffer
*buffers
)
221 static void *noop_create_vertex_elements(struct pipe_context
*ctx
,
223 const struct pipe_vertex_element
*state
)
225 struct pipe_vertex_element
*nstate
= CALLOC_STRUCT(pipe_vertex_element
);
227 if (nstate
== NULL
) {
234 static void *noop_create_shader_state(struct pipe_context
*ctx
,
235 const struct pipe_shader_state
*state
)
237 struct pipe_shader_state
*nstate
= CALLOC_STRUCT(pipe_shader_state
);
239 if (nstate
== NULL
) {
246 void noop_init_state_functions(struct pipe_context
*ctx
);
248 void noop_init_state_functions(struct pipe_context
*ctx
)
250 ctx
->create_blend_state
= noop_create_blend_state
;
251 ctx
->create_depth_stencil_alpha_state
= noop_create_dsa_state
;
252 ctx
->create_fs_state
= noop_create_shader_state
;
253 ctx
->create_rasterizer_state
= noop_create_rs_state
;
254 ctx
->create_sampler_state
= noop_create_sampler_state
;
255 ctx
->create_sampler_view
= noop_create_sampler_view
;
256 ctx
->create_surface
= noop_create_surface
;
257 ctx
->create_vertex_elements_state
= noop_create_vertex_elements
;
258 ctx
->create_vs_state
= noop_create_shader_state
;
259 ctx
->bind_blend_state
= noop_bind_state
;
260 ctx
->bind_depth_stencil_alpha_state
= noop_bind_state
;
261 ctx
->bind_fragment_sampler_states
= noop_bind_sampler
;
262 ctx
->bind_fs_state
= noop_bind_state
;
263 ctx
->bind_rasterizer_state
= noop_bind_state
;
264 ctx
->bind_vertex_elements_state
= noop_bind_state
;
265 ctx
->bind_vertex_sampler_states
= noop_bind_sampler
;
266 ctx
->bind_vs_state
= noop_bind_state
;
267 ctx
->delete_blend_state
= noop_delete_state
;
268 ctx
->delete_depth_stencil_alpha_state
= noop_delete_state
;
269 ctx
->delete_fs_state
= noop_delete_state
;
270 ctx
->delete_rasterizer_state
= noop_delete_state
;
271 ctx
->delete_sampler_state
= noop_delete_state
;
272 ctx
->delete_vertex_elements_state
= noop_delete_vertex_element
;
273 ctx
->delete_vs_state
= noop_delete_state
;
274 ctx
->set_blend_color
= noop_set_blend_color
;
275 ctx
->set_clip_state
= noop_set_clip_state
;
276 ctx
->set_constant_buffer
= noop_set_constant_buffer
;
277 ctx
->set_fragment_sampler_views
= noop_set_ps_sampler_view
;
278 ctx
->set_framebuffer_state
= noop_set_framebuffer_state
;
279 ctx
->set_polygon_stipple
= noop_set_polygon_stipple
;
280 ctx
->set_sample_mask
= noop_set_sample_mask
;
281 ctx
->set_scissor_state
= noop_set_scissor_state
;
282 ctx
->set_stencil_ref
= noop_set_stencil_ref
;
283 ctx
->set_vertex_buffers
= noop_set_vertex_buffers
;
284 ctx
->set_index_buffer
= noop_set_index_buffer
;
285 ctx
->set_vertex_sampler_views
= noop_set_vs_sampler_view
;
286 ctx
->set_viewport_state
= noop_set_viewport_state
;
287 ctx
->sampler_view_destroy
= noop_sampler_view_destroy
;
288 ctx
->surface_destroy
= noop_surface_destroy
;
289 ctx
->draw_vbo
= noop_draw_vbo
;