aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2019-09-27 17:43:42 -0400
committerMarek Olšák <[email protected]>2019-10-16 20:10:47 -0400
commitf54dcaf232e58e4b4288605b1f58263862116cc4 (patch)
treebf58aae5100e79d9b20ea5fd4fadc4bc1d5bf720 /src/mesa
parentf86b28dfdc2503e9bbf669f8f675b58df92d53e5 (diff)
st/mesa: don't call translate_*_program functions for NIR
move the initializaton to st_link_nir Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_cb_program.c9
-rw-r--r--src/mesa/state_tracker/st_glsl_to_nir.cpp13
-rw-r--r--src/mesa/state_tracker/st_program.c26
3 files changed, 21 insertions, 27 deletions
diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
index 7e23c0875f6..e4b9248db7d 100644
--- a/src/mesa/state_tracker/st_cb_program.c
+++ b/src/mesa/state_tracker/st_cb_program.c
@@ -160,7 +160,8 @@ st_program_string_notify( struct gl_context *ctx,
}
st_release_fp_variants(st, stfp);
- if (!st_translate_fragment_program(st, stfp))
+ if (!stfp->shader_program && /* not GLSL->NIR */
+ !st_translate_fragment_program(st, stfp))
return false;
if (st->fp == stfp)
@@ -169,7 +170,8 @@ st_program_string_notify( struct gl_context *ctx,
struct st_vertex_program *stvp = (struct st_vertex_program *) prog;
st_release_vp_variants(st, stvp);
- if (!st_translate_vertex_program(st, stvp))
+ if (!stvp->shader_program && /* not GLSL->NIR */
+ !st_translate_vertex_program(st, stvp))
return false;
if (st->vp == stvp)
@@ -178,7 +180,8 @@ st_program_string_notify( struct gl_context *ctx,
struct st_common_program *stcp = st_common_program(prog);
st_release_basic_variants(st, stcp);
- if (!st_translate_common_program(st, stcp))
+ if (!stcp->shader_program && /* not GLSL->NIR */
+ !st_translate_common_program(st, stcp))
return false;
if ((prog->info.stage == MESA_SHADER_TESS_CTRL && st->tcp == stcp) ||
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index f34ed7fa6a6..35494761ac1 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -41,6 +41,7 @@
#include "st_context.h"
#include "st_glsl_types.h"
#include "st_program.h"
+#include "st_shader_cache.h"
#include "compiler/nir/nir.h"
#include "compiler/glsl_types.h"
@@ -803,6 +804,18 @@ st_link_nir(struct gl_context *ctx,
struct gl_program *prog = shader->Program;
st_glsl_to_nir_post_opts(st, prog, shader_program);
+ /* Initialize st_vertex_program members. */
+ if (i == MESA_SHADER_VERTEX)
+ st_prepare_vertex_program(st_vertex_program(prog));
+
+ /* Get pipe_stream_output_info. */
+ if (i == MESA_SHADER_VERTEX ||
+ i == MESA_SHADER_TESS_EVAL ||
+ i == MESA_SHADER_GEOMETRY)
+ st_translate_stream_output_info(prog);
+
+ st_store_ir_in_disk_cache(st, prog, true);
+
if (!ctx->Driver.ProgramStringNotify(ctx,
_mesa_shader_stage_to_program(i),
prog)) {
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 9f0aaba4430..fc351cd9ee7 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -525,7 +525,7 @@ st_translate_vertex_program(struct st_context *st,
output_semantic_index[num_outputs] = 0;
/* ARB_vp: */
- if (!stvp->glsl_to_tgsi && !stvp->shader_program) {
+ if (!stvp->glsl_to_tgsi) {
_mesa_remove_output_reads(&stvp->Base, PROGRAM_OUTPUT);
/* This determines which states will be updated when the assembly
@@ -541,12 +541,6 @@ st_translate_vertex_program(struct st_context *st,
/* No samplers are allowed in ARB_vp. */
}
- if (stvp->shader_program) {
- st_translate_stream_output_info(&stvp->Base);
- st_store_ir_in_disk_cache(st, &stvp->Base, true);
- return true;
- }
-
ureg = ureg_create_with_screen(PIPE_SHADER_VERTEX, st->pipe->screen);
if (ureg == NULL)
return false;
@@ -766,12 +760,6 @@ bool
st_translate_fragment_program(struct st_context *st,
struct st_fragment_program *stfp)
{
- /* We have already compiled to NIR so just return */
- if (stfp->shader_program) {
- st_store_ir_in_disk_cache(st, &stfp->Base, true);
- return true;
- }
-
ubyte outputMapping[2 * FRAG_RESULT_MAX];
ubyte inputMapping[VARYING_SLOT_MAX];
ubyte inputSlotToAttr[VARYING_SLOT_MAX];
@@ -793,7 +781,7 @@ st_translate_fragment_program(struct st_context *st,
memset(inputSlotToAttr, ~0, sizeof(inputSlotToAttr));
/* Non-GLSL programs: */
- if (!stfp->glsl_to_tgsi && !stfp->shader_program) {
+ if (!stfp->glsl_to_tgsi) {
_mesa_remove_output_reads(&stfp->Base, PROGRAM_OUTPUT);
if (st->ctx->Const.GLSLFragCoordIsSysVal)
_mesa_program_fragment_position_to_sysval(&stfp->Base);
@@ -1446,16 +1434,6 @@ bool
st_translate_common_program(struct st_context *st,
struct st_common_program *stcp)
{
- /* We have already compiled to NIR so just return */
- if (stcp->shader_program) {
- /* No variants */
- if (stcp->Base.info.stage == MESA_SHADER_TESS_EVAL ||
- stcp->Base.info.stage == MESA_SHADER_GEOMETRY)
- st_translate_stream_output_info(&stcp->Base);
- st_store_ir_in_disk_cache(st, &stcp->Base, true);
- return true;
- }
-
struct gl_program *prog = &stcp->Base;
enum pipe_shader_type stage =
pipe_shader_type_from_mesa(stcp->Base.info.stage);