[Mesa-dev] [PATCH 06/17] nir/info: Add a few bits of info for fragment shaders

Jason Ekstrand jason at jlekstrand.net
Thu Oct 8 17:22:38 PDT 2015


---
 src/glsl/nir/glsl_to_nir.cpp   |  9 +++++++++
 src/glsl/nir/nir.h             | 13 +++++++++++++
 src/mesa/program/prog_to_nir.c |  6 ++++++
 3 files changed, 28 insertions(+)

diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
index e4aa709..ddacb4e 100644
--- a/src/glsl/nir/glsl_to_nir.cpp
+++ b/src/glsl/nir/glsl_to_nir.cpp
@@ -173,6 +173,15 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
       shader->info.gs.invocations = sh->Geom.Invocations;
       break;
 
+   case MESA_SHADER_FRAGMENT: {
+      struct gl_fragment_program *fp =
+         (struct gl_fragment_program *)sh->Program;
+
+      shader->info.fs.uses_discard = fp->UsesKill;
+      shader->info.fs.early_fragment_tests = sh->EarlyFragmentTests;
+      shader->info.fs.depth_layout = fp->FragDepthLayout;
+   }
+
    case MESA_SHADER_COMPUTE: {
       struct gl_compute_program *cp = (struct gl_compute_program *)sh->Program;
       shader->info.cs.local_size[0] = cp->LocalSize[0];
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 2ce958a..14f5535 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1503,6 +1503,19 @@ typedef struct nir_shader_info {
       } gs;
 
       struct {
+         bool uses_discard;
+
+         /**
+          * Whether early fragment tests are enabled as defined by
+          * ARB_shader_image_load_store.
+          */
+         bool early_fragment_tests;
+
+         /** gl_FragDepth layout for ARB_conservative_depth. */
+         enum gl_frag_depth_layout depth_layout;
+      } fs;
+
+      struct {
          unsigned local_size[3];
       } cs;
    };
diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c
index fc00534..3d91b3b 100644
--- a/src/mesa/program/prog_to_nir.c
+++ b/src/mesa/program/prog_to_nir.c
@@ -1135,6 +1135,12 @@ prog_to_nir(const struct gl_program *prog,
    s->info.uses_clip_distance_out = false;
    s->info.separate_shader = false;
 
+   if (stage == MESA_SHADER_FRAGMENT) {
+      struct gl_fragment_program *fp = (struct gl_fragment_program *)prog;
+
+      s->info.fs.uses_discard = fp->UsesKill;
+   }
+
 fail:
    if (c->error) {
       ralloc_free(s);
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list