gallium: Add pipe_shader_state_from_nir
authorM Henning <drawoc@darkrefraction.com>
Sat, 22 Apr 2023 04:47:28 +0000 (00:47 -0400)
committerMarge Bot <emma+marge@anholt.net>
Tue, 25 Apr 2023 03:46:34 +0000 (03:46 +0000)
and use it in nouveau

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22537>

src/gallium/drivers/nouveau/nv50/nv50_surface.c
src/gallium/drivers/nouveau/nvc0/nvc0_program.c
src/gallium/drivers/nouveau/nvc0/nvc0_surface.c
src/gallium/include/pipe/p_state.h

index 347559f..787fad5 100644 (file)
@@ -1067,9 +1067,8 @@ nv50_blitter_make_fp(struct pipe_context *pipe,
    /* return shader */
    NIR_PASS_V(b.shader, nir_lower_samplers);
 
-   struct pipe_shader_state state = {};
-   state.type = PIPE_SHADER_IR_NIR;
-   state.ir.nir = b.shader;
+   struct pipe_shader_state state;
+   pipe_shader_state_from_nir(&state, b.shader);
    return pipe->create_fs_state(pipe, &state);
 }
 
index 92b070e..d3b6b9f 100644 (file)
@@ -1025,8 +1025,7 @@ nvc0_program_init_tcp_empty(struct nvc0_context *nvc0)
 
    nir_validate_shader(b.shader, "in nvc0_program_init_tcp_empty");
 
-   struct pipe_shader_state state = {0};
-   state.type = PIPE_SHADER_IR_NIR;
-   state.ir.nir = b.shader;
+   struct pipe_shader_state state;
+   pipe_shader_state_from_nir(&state, b.shader);
    nvc0->tcp_empty = nvc0->base.pipe.create_tcs_state(&nvc0->base.pipe, &state);
 }
index 93437d8..9e415f1 100644 (file)
@@ -888,9 +888,8 @@ nvc0_blitter_make_vp(struct pipe_context *pipe)
 
    NIR_PASS_V(b.shader, nir_lower_var_copies);
 
-   struct pipe_shader_state state = {};
-   state.type = PIPE_SHADER_IR_NIR;
-   state.ir.nir = b.shader;
+   struct pipe_shader_state state;
+   pipe_shader_state_from_nir(&state, b.shader);
    return pipe->create_vs_state(pipe, &state);
 }
 
index b84a333..04a60f8 100644 (file)
@@ -318,6 +318,16 @@ pipe_shader_state_from_tgsi(struct pipe_shader_state *state,
    memset(&state->stream_output, 0, sizeof(state->stream_output));
 }
 
+static inline void
+pipe_shader_state_from_nir(struct pipe_shader_state *state,
+                           void *nir)
+{
+   state->type = PIPE_SHADER_IR_NIR;
+   state->ir.nir = nir;
+   state->tokens = NULL;
+   memset(&state->stream_output, 0, sizeof(state->stream_output));
+}
+
 
 struct pipe_stencil_state
 {