noop_state.c revision 4c7001462607e6e99e474d6271dd481d3f8f201c
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 32static void noop_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info) 33{ 34} 35 36static void noop_set_blend_color(struct pipe_context *ctx, 37 const struct pipe_blend_color *state) 38{ 39} 40 41static 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 53static 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 65static 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 77static 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 89static 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 104static struct pipe_surface *noop_create_surface(struct pipe_context *ctx, 105 struct pipe_resource *texture, 106 const struct pipe_surface *surf_tmpl) 107{ 108 struct pipe_surface *surface = CALLOC_STRUCT(pipe_surface); 109 110 if (surface == NULL) 111 return NULL; 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; 123 124 return surface; 125} 126static void noop_set_vs_sampler_view(struct pipe_context *ctx, unsigned count, 127 struct pipe_sampler_view **views) 128{ 129} 130 131static void noop_set_ps_sampler_view(struct pipe_context *ctx, unsigned count, 132 struct pipe_sampler_view **views) 133{ 134} 135 136static void noop_bind_sampler(struct pipe_context *ctx, unsigned count, void **states) 137{ 138} 139 140static void noop_set_clip_state(struct pipe_context *ctx, 141 const struct pipe_clip_state *state) 142{ 143} 144 145static void noop_set_polygon_stipple(struct pipe_context *ctx, 146 const struct pipe_poly_stipple *state) 147{ 148} 149 150static void noop_set_sample_mask(struct pipe_context *pipe, unsigned sample_mask) 151{ 152} 153 154static void noop_set_scissor_state(struct pipe_context *ctx, 155 const struct pipe_scissor_state *state) 156{ 157} 158 159static void noop_set_stencil_ref(struct pipe_context *ctx, 160 const struct pipe_stencil_ref *state) 161{ 162} 163 164static void noop_set_viewport_state(struct pipe_context *ctx, 165 const struct pipe_viewport_state *state) 166{ 167} 168 169static void noop_set_framebuffer_state(struct pipe_context *ctx, 170 const struct pipe_framebuffer_state *state) 171{ 172} 173 174static void noop_set_constant_buffer(struct pipe_context *ctx, 175 uint shader, uint index, 176 struct pipe_resource *buffer) 177{ 178} 179 180 181static void noop_sampler_view_destroy(struct pipe_context *ctx, 182 struct pipe_sampler_view *state) 183{ 184 pipe_resource_reference(&state->texture, NULL); 185 FREE(state); 186} 187 188 189static void noop_surface_destroy(struct pipe_context *ctx, 190 struct pipe_surface *surface) 191{ 192 pipe_resource_reference(&surface->texture, NULL); 193 FREE(surface); 194} 195 196static void noop_bind_state(struct pipe_context *ctx, void *state) 197{ 198} 199 200static void noop_delete_state(struct pipe_context *ctx, void *state) 201{ 202 FREE(state); 203} 204 205static void noop_delete_vertex_element(struct pipe_context *ctx, void *state) 206{ 207 FREE(state); 208} 209 210 211static void noop_set_index_buffer(struct pipe_context *ctx, 212 const struct pipe_index_buffer *ib) 213{ 214} 215 216static void noop_set_vertex_buffers(struct pipe_context *ctx, unsigned count, 217 const struct pipe_vertex_buffer *buffers) 218{ 219} 220 221static void *noop_create_vertex_elements(struct pipe_context *ctx, 222 unsigned count, 223 const struct pipe_vertex_element *state) 224{ 225 struct pipe_vertex_element *nstate = CALLOC_STRUCT(pipe_vertex_element); 226 227 if (nstate == NULL) { 228 return NULL; 229 } 230 *nstate = *state; 231 return nstate; 232} 233 234static void *noop_create_shader_state(struct pipe_context *ctx, 235 const struct pipe_shader_state *state) 236{ 237 struct pipe_shader_state *nstate = CALLOC_STRUCT(pipe_shader_state); 238 239 if (nstate == NULL) { 240 return NULL; 241 } 242 *nstate = *state; 243 return nstate; 244} 245 246void noop_init_state_functions(struct pipe_context *ctx) 247{ 248 ctx->create_blend_state = noop_create_blend_state; 249 ctx->create_depth_stencil_alpha_state = noop_create_dsa_state; 250 ctx->create_fs_state = noop_create_shader_state; 251 ctx->create_rasterizer_state = noop_create_rs_state; 252 ctx->create_sampler_state = noop_create_sampler_state; 253 ctx->create_sampler_view = noop_create_sampler_view; 254 ctx->create_surface = noop_create_surface; 255 ctx->create_vertex_elements_state = noop_create_vertex_elements; 256 ctx->create_vs_state = noop_create_shader_state; 257 ctx->bind_blend_state = noop_bind_state; 258 ctx->bind_depth_stencil_alpha_state = noop_bind_state; 259 ctx->bind_fragment_sampler_states = noop_bind_sampler; 260 ctx->bind_fs_state = noop_bind_state; 261 ctx->bind_rasterizer_state = noop_bind_state; 262 ctx->bind_vertex_elements_state = noop_bind_state; 263 ctx->bind_vertex_sampler_states = noop_bind_sampler; 264 ctx->bind_vs_state = noop_bind_state; 265 ctx->delete_blend_state = noop_delete_state; 266 ctx->delete_depth_stencil_alpha_state = noop_delete_state; 267 ctx->delete_fs_state = noop_delete_state; 268 ctx->delete_rasterizer_state = noop_delete_state; 269 ctx->delete_sampler_state = noop_delete_state; 270 ctx->delete_vertex_elements_state = noop_delete_vertex_element; 271 ctx->delete_vs_state = noop_delete_state; 272 ctx->set_blend_color = noop_set_blend_color; 273 ctx->set_clip_state = noop_set_clip_state; 274 ctx->set_constant_buffer = noop_set_constant_buffer; 275 ctx->set_fragment_sampler_views = noop_set_ps_sampler_view; 276 ctx->set_framebuffer_state = noop_set_framebuffer_state; 277 ctx->set_polygon_stipple = noop_set_polygon_stipple; 278 ctx->set_sample_mask = noop_set_sample_mask; 279 ctx->set_scissor_state = noop_set_scissor_state; 280 ctx->set_stencil_ref = noop_set_stencil_ref; 281 ctx->set_vertex_buffers = noop_set_vertex_buffers; 282 ctx->set_index_buffer = noop_set_index_buffer; 283 ctx->set_vertex_sampler_views = noop_set_vs_sampler_view; 284 ctx->set_viewport_state = noop_set_viewport_state; 285 ctx->sampler_view_destroy = noop_sampler_view_destroy; 286 ctx->surface_destroy = noop_surface_destroy; 287 ctx->draw_vbo = noop_draw_vbo; 288} 289