[Mesa-dev] [PATCH 1/3] noop: simplify some functions

Marek Olšák maraeo at gmail.com
Mon Aug 29 15:29:46 UTC 2016


From: Marek Olšák <marek.olsak at amd.com>

---
 src/gallium/drivers/noop/noop_state.c | 56 +++++------------------------------
 1 file changed, 7 insertions(+), 49 deletions(-)

diff --git a/src/gallium/drivers/noop/noop_state.c b/src/gallium/drivers/noop/noop_state.c
index 0c0ad9f..01538bfe27 100644
--- a/src/gallium/drivers/noop/noop_state.c
+++ b/src/gallium/drivers/noop/noop_state.c
@@ -35,63 +35,39 @@ static void noop_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info
 }
 
 static void noop_set_blend_color(struct pipe_context *ctx,
                                  const struct pipe_blend_color *state)
 {
 }
 
 static void *noop_create_blend_state(struct pipe_context *ctx,
                                      const struct pipe_blend_state *state)
 {
-   struct pipe_blend_state *nstate = CALLOC_STRUCT(pipe_blend_state);
-
-   if (!nstate) {
-      return NULL;
-   }
-   *nstate = *state;
-   return nstate;
+   return malloc(1);
 }
 
 static void *noop_create_dsa_state(struct pipe_context *ctx,
                                    const struct pipe_depth_stencil_alpha_state *state)
 {
-   struct pipe_depth_stencil_alpha_state *nstate = CALLOC_STRUCT(pipe_depth_stencil_alpha_state);
-
-   if (!nstate) {
-      return NULL;
-   }
-   *nstate = *state;
-   return nstate;
+   return malloc(1);
 }
 
 static void *noop_create_rs_state(struct pipe_context *ctx,
                                   const struct pipe_rasterizer_state *state)
 {
-   struct pipe_rasterizer_state *nstate = CALLOC_STRUCT(pipe_rasterizer_state);
-
-   if (!nstate) {
-      return NULL;
-   }
-   *nstate = *state;
-   return nstate;
+   return malloc(1);
 }
 
 static void *noop_create_sampler_state(struct pipe_context *ctx,
                                        const struct pipe_sampler_state *state)
 {
-   struct pipe_sampler_state *nstate = CALLOC_STRUCT(pipe_sampler_state);
-
-   if (!nstate) {
-      return NULL;
-   }
-   *nstate = *state;
-   return nstate;
+   return malloc(1);
 }
 
 static struct pipe_sampler_view *noop_create_sampler_view(struct pipe_context *ctx,
                                                           struct pipe_resource *texture,
                                                           const struct pipe_sampler_view *state)
 {
    struct pipe_sampler_view *sampler_view = CALLOC_STRUCT(pipe_sampler_view);
 
    if (!sampler_view)
       return NULL;
@@ -198,60 +174,42 @@ static void noop_surface_destroy(struct pipe_context *ctx,
 
 static void noop_bind_state(struct pipe_context *ctx, void *state)
 {
 }
 
 static void noop_delete_state(struct pipe_context *ctx, void *state)
 {
    FREE(state);
 }
 
-static void noop_delete_vertex_element(struct pipe_context *ctx, void *state)
-{
-   FREE(state);
-}
-
-
 static void noop_set_index_buffer(struct pipe_context *ctx,
                                   const struct pipe_index_buffer *ib)
 {
 }
 
 static void noop_set_vertex_buffers(struct pipe_context *ctx,
                                     unsigned start_slot, unsigned count,
                                     const struct pipe_vertex_buffer *buffers)
 {
 }
 
 static void *noop_create_vertex_elements(struct pipe_context *ctx,
                                          unsigned count,
                                          const struct pipe_vertex_element *state)
 {
-   struct pipe_vertex_element *nstate = CALLOC_STRUCT(pipe_vertex_element);
-
-   if (!nstate) {
-      return NULL;
-   }
-   *nstate = *state;
-   return nstate;
+   return malloc(1);
 }
 
 static void *noop_create_shader_state(struct pipe_context *ctx,
                                       const struct pipe_shader_state *state)
 {
-   struct pipe_shader_state *nstate = CALLOC_STRUCT(pipe_shader_state);
-
-   if (!nstate) {
-      return NULL;
-   }
-   *nstate = *state;
-   return nstate;
+   return malloc(1);
 }
 
 static struct pipe_stream_output_target *noop_create_stream_output_target(
       struct pipe_context *ctx,
       struct pipe_resource *res,
       unsigned buffer_offset,
       unsigned buffer_size)
 {
    struct pipe_stream_output_target *t = CALLOC_STRUCT(pipe_stream_output_target);
    if (!t)
@@ -296,21 +254,21 @@ void noop_init_state_functions(struct pipe_context *ctx)
    ctx->bind_sampler_states = noop_bind_sampler_states;
    ctx->bind_fs_state = noop_bind_state;
    ctx->bind_rasterizer_state = noop_bind_state;
    ctx->bind_vertex_elements_state = noop_bind_state;
    ctx->bind_vs_state = noop_bind_state;
    ctx->delete_blend_state = noop_delete_state;
    ctx->delete_depth_stencil_alpha_state = noop_delete_state;
    ctx->delete_fs_state = noop_delete_state;
    ctx->delete_rasterizer_state = noop_delete_state;
    ctx->delete_sampler_state = noop_delete_state;
-   ctx->delete_vertex_elements_state = noop_delete_vertex_element;
+   ctx->delete_vertex_elements_state = noop_delete_state;
    ctx->delete_vs_state = noop_delete_state;
    ctx->set_blend_color = noop_set_blend_color;
    ctx->set_clip_state = noop_set_clip_state;
    ctx->set_constant_buffer = noop_set_constant_buffer;
    ctx->set_sampler_views = noop_set_sampler_views;
    ctx->set_framebuffer_state = noop_set_framebuffer_state;
    ctx->set_polygon_stipple = noop_set_polygon_stipple;
    ctx->set_sample_mask = noop_set_sample_mask;
    ctx->set_scissor_states = noop_set_scissor_states;
    ctx->set_stencil_ref = noop_set_stencil_ref;
-- 
2.7.4



More information about the mesa-dev mailing list