noop: simplify some functions
authorMarek Olšák <marek.olsak@amd.com>
Sun, 28 Aug 2016 11:57:44 +0000 (13:57 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 5 Sep 2016 14:12:04 +0000 (16:12 +0200)
src/gallium/drivers/noop/noop_state.c

index 4f63e4d8959e0c3feac08d4fbced781cc988fa97..8a4938b97f5a08b19fae0b007460eaa82696d487 100644 (file)
@@ -42,49 +42,25 @@ static void noop_set_blend_color(struct pipe_context *ctx,
 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,
@@ -207,12 +183,6 @@ 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)
 {
@@ -228,25 +198,13 @@ 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(
@@ -305,7 +263,7 @@ void noop_init_state_functions(struct pipe_context *ctx)
    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;