diff options
author | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2017-06-23 19:12:57 +0200 |
---|---|---|
committer | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2017-07-13 13:27:43 +0200 |
commit | e9e63254b21afebc8a9acf49754025997864dd43 (patch) | |
tree | 1f6ff21ec64e0a69f7fe430c4d083eb269660018 | |
parent | 4736296f947bb856f7330cc49d6988c4797d178b (diff) |
st/mesa: use NIR program path for SPIR-V shaders
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_nir.cpp | 13 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 2 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index 5d05dbf0cc..8d29aa93d6 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -240,7 +240,10 @@ st_glsl_to_nir(struct st_context *st, struct gl_program *prog, if (prog->nir) return prog->nir; - nir = glsl_to_nir(shader_program, stage, options); + if (shader_program->_LinkedShaders[stage]->nir) + nir = nir_shader_clone(NULL, shader_program->_LinkedShaders[stage]->nir); + else + nir = glsl_to_nir(shader_program, stage, options); NIR_PASS_V(nir, nir_lower_io_to_temporaries, nir_shader_get_entrypoint(nir), @@ -397,7 +400,13 @@ st_nir_get_mesa_program(struct gl_context *ctx, prog->Parameters = _mesa_new_parameter_list(); - do_set_program_inouts(shader->ir, prog, shader->Stage); + if (shader->nir) { + nir_function *main_function = ((nir_function *)shader->nir->functions.get_head()); + nir_shader_gather_info(shader->nir, main_function->impl); + memcpy(&prog->info, &shader->nir->info, sizeof(prog->info)); + } else { + do_set_program_inouts(shader->ir, prog, shader->Stage); + } _mesa_copy_linked_program_data(shader_program, shader); _mesa_generate_parameters_list_for_uniforms(shader_program, shader, diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index e6201cff14..ef87f52876 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -7182,7 +7182,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) PIPE_SHADER_CAP_PREFERRED_IR); struct gl_program *linked_prog = NULL; - if (preferred_ir == PIPE_SHADER_IR_NIR) { + if (shader->nir || preferred_ir == PIPE_SHADER_IR_NIR) { /* TODO only for GLSL VS/FS/CS for now: */ switch (shader->Stage) { case MESA_SHADER_VERTEX: |