Mesa (master): nir/info: Move the GS info into a stage-specific info union

Jason Ekstrand jekstrand at kemper.freedesktop.org
Mon Oct 19 17:18:41 UTC 2015


Module: Mesa
Branch: master
Commit: fe399f3a69689a78ca4a5fb5a6b76435adcd41e5
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=fe399f3a69689a78ca4a5fb5a6b76435adcd41e5

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Thu Oct  8 15:36:51 2015 -0700

nir/info: Move the GS info into a stage-specific info union

This way we can have other stage-specific info without consuming too much
extra space.  While we're at it, we make sure that the geometry info is
only set if we're actually a goemetry shader.

Reviewed-by: Topi Pohjolainen <topi.pohjolainen at intel.com>

---

 src/glsl/nir/glsl_to_nir.cpp |   12 ++++++++++--
 src/glsl/nir/nir.h           |   14 ++++++++------
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
index edc6f5b..95b2312 100644
--- a/src/glsl/nir/glsl_to_nir.cpp
+++ b/src/glsl/nir/glsl_to_nir.cpp
@@ -164,11 +164,19 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
    shader->info.uses_texture_gather = sh->Program->UsesGather;
    shader->info.uses_clip_distance_out = sh->Program->UsesClipDistanceOut;
    shader->info.separate_shader = shader_prog->SeparateShader;
-   shader->info.gs.vertices_out = sh->Geom.VerticesOut;
-   shader->info.gs.invocations = sh->Geom.Invocations;
    shader->info.has_transform_feedback_varyings =
       shader_prog->TransformFeedback.NumVarying > 0;
 
+   switch (stage) {
+   case MESA_SHADER_GEOMETRY:
+      shader->info.gs.vertices_out = sh->Geom.VerticesOut;
+      shader->info.gs.invocations = sh->Geom.Invocations;
+      break;
+
+   default:
+      break; /* No stage-specific info */
+   }
+
    return shader;
 }
 
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index fb8d590..719e6ce 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1493,13 +1493,15 @@ typedef struct nir_shader_info {
    /** Was this shader linked with any transform feedback varyings? */
    bool has_transform_feedback_varyings;
 
-   struct {
-      /** The maximum number of vertices the geometry shader might write. */
-      unsigned vertices_out;
+   union {
+      struct {
+         /** The maximum number of vertices the geometry shader might write. */
+         unsigned vertices_out;
 
-      /** 1 .. MAX_GEOMETRY_SHADER_INVOCATIONS */
-      unsigned invocations;
-   } gs;
+         /** 1 .. MAX_GEOMETRY_SHADER_INVOCATIONS */
+         unsigned invocations;
+      } gs;
+   };
 } nir_shader_info;
 
 typedef struct nir_shader {




More information about the mesa-commit mailing list