Merge branch 'lp-offset-twoside'
[mesa.git] / src / gallium / drivers / noop / noop_state.c
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
32 static void noop_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
33 {
34 }
35
36 static void noop_set_blend_color(struct pipe_context *ctx,
37 const struct pipe_blend_color *state)
38 {
39 }
40
41 static void *noop_create_blend_state(struct pipe_context *ctx,
42 const struct pipe_blend_state *state)
43 {
44 struct pipe_blend_state *nstate = CALLOC_STRUCT(pipe_blend_state);
45
46 if (nstate == NULL) {
47 return NULL;
48 }
49 *nstate = *state;
50 return nstate;
51 }
52
53 static void *noop_create_dsa_state(struct pipe_context *ctx,
54 const struct pipe_depth_stencil_alpha_state *state)
55 {
56 struct pipe_depth_stencil_alpha_state *nstate = CALLOC_STRUCT(pipe_depth_stencil_alpha_state);
57
58 if (nstate == NULL) {
59 return NULL;
60 }
61 *nstate = *state;
62 return nstate;
63 }
64
65 static void *noop_create_rs_state(struct pipe_context *ctx,
66 const struct pipe_rasterizer_state *state)
67 {
68 struct pipe_rasterizer_state *nstate = CALLOC_STRUCT(pipe_rasterizer_state);
69
70 if (nstate == NULL) {
71 return NULL;
72 }
73 *nstate = *state;
74 return nstate;
75 }
76
77 static void *noop_create_sampler_state(struct pipe_context *ctx,
78 const struct pipe_sampler_state *state)
79 {
80 struct pipe_sampler_state *nstate = CALLOC_STRUCT(pipe_sampler_state);
81
82 if (nstate == NULL) {
83 return NULL;
84 }
85 *nstate = *state;
86 return nstate;
87 }
88
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)
92 {
93 struct pipe_sampler_view *sampler_view = CALLOC_STRUCT(pipe_sampler_view);
94
95 if (sampler_view == NULL)
96 return 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;
101 return sampler_view;
102 }
103
104 static void noop_set_vs_sampler_view(struct pipe_context *ctx, unsigned count,
105 struct pipe_sampler_view **views)
106 {
107 }
108
109 static void noop_set_ps_sampler_view(struct pipe_context *ctx, unsigned count,
110 struct pipe_sampler_view **views)
111 {
112 }
113
114 static void noop_bind_sampler(struct pipe_context *ctx, unsigned count, void **states)
115 {
116 }
117
118 static void noop_set_clip_state(struct pipe_context *ctx,
119 const struct pipe_clip_state *state)
120 {
121 }
122
123 static void noop_set_polygon_stipple(struct pipe_context *ctx,
124 const struct pipe_poly_stipple *state)
125 {
126 }
127
128 static void noop_set_sample_mask(struct pipe_context *pipe, unsigned sample_mask)
129 {
130 }
131
132 static void noop_set_scissor_state(struct pipe_context *ctx,
133 const struct pipe_scissor_state *state)
134 {
135 }
136
137 static void noop_set_stencil_ref(struct pipe_context *ctx,
138 const struct pipe_stencil_ref *state)
139 {
140 }
141
142 static void noop_set_viewport_state(struct pipe_context *ctx,
143 const struct pipe_viewport_state *state)
144 {
145 }
146
147 static void noop_set_framebuffer_state(struct pipe_context *ctx,
148 const struct pipe_framebuffer_state *state)
149 {
150 }
151
152 static void noop_set_constant_buffer(struct pipe_context *ctx,
153 uint shader, uint index,
154 struct pipe_resource *buffer)
155 {
156 }
157
158
159 static void noop_sampler_view_destroy(struct pipe_context *ctx,
160 struct pipe_sampler_view *state)
161 {
162 pipe_resource_reference(&state->texture, NULL);
163 FREE(state);
164 }
165
166 static void noop_bind_state(struct pipe_context *ctx, void *state)
167 {
168 }
169
170 static void noop_delete_state(struct pipe_context *ctx, void *state)
171 {
172 FREE(state);
173 }
174
175 static void noop_delete_vertex_element(struct pipe_context *ctx, void *state)
176 {
177 FREE(state);
178 }
179
180
181 static void noop_set_index_buffer(struct pipe_context *ctx,
182 const struct pipe_index_buffer *ib)
183 {
184 }
185
186 static void noop_set_vertex_buffers(struct pipe_context *ctx, unsigned count,
187 const struct pipe_vertex_buffer *buffers)
188 {
189 }
190
191 static void *noop_create_vertex_elements(struct pipe_context *ctx,
192 unsigned count,
193 const struct pipe_vertex_element *state)
194 {
195 struct pipe_vertex_element *nstate = CALLOC_STRUCT(pipe_vertex_element);
196
197 if (nstate == NULL) {
198 return NULL;
199 }
200 *nstate = *state;
201 return nstate;
202 }
203
204 static void *noop_create_shader_state(struct pipe_context *ctx,
205 const struct pipe_shader_state *state)
206 {
207 struct pipe_shader_state *nstate = CALLOC_STRUCT(pipe_shader_state);
208
209 if (nstate == NULL) {
210 return NULL;
211 }
212 *nstate = *state;
213 return nstate;
214 }
215
216 void noop_init_state_functions(struct pipe_context *ctx)
217 {
218 ctx->create_blend_state = noop_create_blend_state;
219 ctx->create_depth_stencil_alpha_state = noop_create_dsa_state;
220 ctx->create_fs_state = noop_create_shader_state;
221 ctx->create_rasterizer_state = noop_create_rs_state;
222 ctx->create_sampler_state = noop_create_sampler_state;
223 ctx->create_sampler_view = noop_create_sampler_view;
224 ctx->create_vertex_elements_state = noop_create_vertex_elements;
225 ctx->create_vs_state = noop_create_shader_state;
226 ctx->bind_blend_state = noop_bind_state;
227 ctx->bind_depth_stencil_alpha_state = noop_bind_state;
228 ctx->bind_fragment_sampler_states = noop_bind_sampler;
229 ctx->bind_fs_state = noop_bind_state;
230 ctx->bind_rasterizer_state = noop_bind_state;
231 ctx->bind_vertex_elements_state = noop_bind_state;
232 ctx->bind_vertex_sampler_states = noop_bind_sampler;
233 ctx->bind_vs_state = noop_bind_state;
234 ctx->delete_blend_state = noop_delete_state;
235 ctx->delete_depth_stencil_alpha_state = noop_delete_state;
236 ctx->delete_fs_state = noop_delete_state;
237 ctx->delete_rasterizer_state = noop_delete_state;
238 ctx->delete_sampler_state = noop_delete_state;
239 ctx->delete_vertex_elements_state = noop_delete_vertex_element;
240 ctx->delete_vs_state = noop_delete_state;
241 ctx->set_blend_color = noop_set_blend_color;
242 ctx->set_clip_state = noop_set_clip_state;
243 ctx->set_constant_buffer = noop_set_constant_buffer;
244 ctx->set_fragment_sampler_views = noop_set_ps_sampler_view;
245 ctx->set_framebuffer_state = noop_set_framebuffer_state;
246 ctx->set_polygon_stipple = noop_set_polygon_stipple;
247 ctx->set_sample_mask = noop_set_sample_mask;
248 ctx->set_scissor_state = noop_set_scissor_state;
249 ctx->set_stencil_ref = noop_set_stencil_ref;
250 ctx->set_vertex_buffers = noop_set_vertex_buffers;
251 ctx->set_index_buffer = noop_set_index_buffer;
252 ctx->set_vertex_sampler_views = noop_set_vs_sampler_view;
253 ctx->set_viewport_state = noop_set_viewport_state;
254 ctx->sampler_view_destroy = noop_sampler_view_destroy;
255 ctx->draw_vbo = noop_draw_vbo;
256 }