diff options
author | Rob Clark <[email protected]> | 2017-12-05 09:53:56 -0500 |
---|---|---|
committer | Rob Clark <[email protected]> | 2017-12-05 16:03:38 -0500 |
commit | fd6a96635e2008d152f4bd9836a94cdaf08fb8d2 (patch) | |
tree | c2b8c85f44a868762defdcb84f6fa49678370166 /src/mesa | |
parent | 12a96aaf907ac3a64dc61943234f9bb479bef701 (diff) |
mesa/st: move cloning of NIR shader for compute
Since in the NIR case, driver takes ownership of the NIR shader, we need
to clone what is passed to the driver. Normally this is done as part of
creating the shader variant (where is clone is anyways needed). But
compute shaders have no variants, so we were cloning earlier.
The problem is that after the NIR linking optimizations, we ended up
cloning *before* all the lowering passes where done.
So move this into st_get_cp_variant(), to make compute shaders work more
like other shader stages.
Signed-off-by: Rob Clark <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_nir.cpp | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_program.c | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index 5d18e7b62bf..36adf55cd45 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -431,7 +431,7 @@ set_st_program(struct gl_program *prog, stcp = (struct st_compute_program *)prog; stcp->shader_program = shader_program; stcp->tgsi.ir_type = PIPE_SHADER_IR_NIR; - stcp->tgsi.prog = nir_shader_clone(NULL, nir); + stcp->tgsi.prog = nir; break; default: unreachable("unknown shader stage"); diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 5c0a58104fc..05e6042f425 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -1659,7 +1659,10 @@ st_get_cp_variant(struct st_context *st, v = CALLOC_STRUCT(st_basic_variant); if (v) { /* fill in new variant */ - v->driver_shader = pipe->create_compute_state(pipe, tgsi); + struct pipe_compute_state cs = *tgsi; + if (tgsi->ir_type == PIPE_SHADER_IR_NIR) + cs.prog = nir_shader_clone(NULL, tgsi->prog); + v->driver_shader = pipe->create_compute_state(pipe, &cs); v->key = key; /* insert into list */ |