Mesa (main): microsoft/compiler: Support gl_Layer

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 15 22:47:33 UTC 2022


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

Author: Boris Brezillon <boris.brezillon at collabora.com>
Date:   Tue Jun 14 22:28:39 2022 +0200

microsoft/compiler: Support gl_Layer

Maps pretty nicely to SV_RenderTargetArrayIndex, so nothing complicated
here.

Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17039>

---

 src/gallium/drivers/d3d12/ci/d3d12-quick_gl.txt    | 8 ++------
 src/gallium/drivers/d3d12/d3d12_compiler.cpp       | 2 +-
 src/gallium/drivers/d3d12/d3d12_pipeline_state.cpp | 3 +++
 src/microsoft/compiler/dxil_signature.c            | 8 ++++++++
 src/microsoft/compiler/nir_to_dxil.c               | 4 +++-
 5 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/d3d12/ci/d3d12-quick_gl.txt b/src/gallium/drivers/d3d12/ci/d3d12-quick_gl.txt
index b84f749850c..838019baa6a 100644
--- a/src/gallium/drivers/d3d12/ci/d3d12-quick_gl.txt
+++ b/src/gallium/drivers/d3d12/ci/d3d12-quick_gl.txt
@@ -212,10 +212,6 @@ spec/!opengl 3.2/gl-3.2-adj-prims line cull-front pv-first: fail
 spec/!opengl 3.2/gl-3.2-adj-prims line cull-front pv-last: fail
 spec/!opengl 3.2/gl-3.2-adj-prims pv-first: fail
 spec/!opengl 3.2/gl-3.2-adj-prims pv-last: fail
-spec/!opengl 3.2/layered-rendering/gl-layer-cube-map: fail
-spec/!opengl 3.2/layered-rendering/gl-layer-render: fail
-spec/!opengl 3.2/layered-rendering/gl-layer-render-clipped: fail
-spec/!opengl 3.2/layered-rendering/gl-layer-render-storage: fail
 spec/!opengl 4.2/gl-max-vertex-attrib-stride: skip
 spec/!opengl 4.3/get_glsl_version: skip
 spec/!opengl 4.5/compare-framebuffer-parameter-with-get: skip
@@ -3521,8 +3517,8 @@ wgl/wgl-sanity: skip
 summary:
        name:  results
        ----  --------
-       pass:    17849
-       fail:     2039
+       pass:    17853
+       fail:     2035
       crash:       12
        skip:     1450
     timeout:        0
diff --git a/src/gallium/drivers/d3d12/d3d12_compiler.cpp b/src/gallium/drivers/d3d12/d3d12_compiler.cpp
index e7cdba8c610..b88255b1368 100644
--- a/src/gallium/drivers/d3d12/d3d12_compiler.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_compiler.cpp
@@ -876,7 +876,7 @@ d3d12_fill_shader_key(struct d3d12_selection_context *sel_ctx,
       if (stage == PIPE_SHADER_FRAGMENT || stage == PIPE_SHADER_GEOMETRY)
          system_out_values |= VARYING_BIT_POS;
       if (stage == PIPE_SHADER_FRAGMENT)
-         system_out_values |= VARYING_BIT_PSIZ | VARYING_BIT_VIEWPORT;
+         system_out_values |= VARYING_BIT_PSIZ | VARYING_BIT_VIEWPORT | VARYING_BIT_LAYER;
       uint64_t mask = prev->current->nir->info.outputs_written & ~system_out_values;
       fill_varyings(&key->required_varying_inputs, prev->current->nir,
                     nir_var_shader_out, mask, false);
diff --git a/src/gallium/drivers/d3d12/d3d12_pipeline_state.cpp b/src/gallium/drivers/d3d12/d3d12_pipeline_state.cpp
index e4a09b4f91f..0d9d74cb8cf 100644
--- a/src/gallium/drivers/d3d12/d3d12_pipeline_state.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_pipeline_state.cpp
@@ -68,6 +68,9 @@ get_semantic_name(int location, int driver_location, unsigned *index)
    case VARYING_SLOT_VIEWPORT:
       return "SV_ViewportArrayIndex";
 
+   case VARYING_SLOT_LAYER:
+      return "SV_RenderTargetArrayIndex";
+
    default: {
          *index = driver_location;
          return "TEXCOORD";
diff --git a/src/microsoft/compiler/dxil_signature.c b/src/microsoft/compiler/dxil_signature.c
index 2636ff428a2..9ea7d86b56e 100644
--- a/src/microsoft/compiler/dxil_signature.c
+++ b/src/microsoft/compiler/dxil_signature.c
@@ -104,6 +104,8 @@ in_sysvalue_name(nir_variable *var)
       return "POS";
    case VARYING_SLOT_FACE:
       return "FACE";
+   case VARYING_SLOT_LAYER:
+      return "RTINDEX";
    default:
       return "NONE";
    }
@@ -326,6 +328,12 @@ get_semantic_name(nir_variable *var, struct semantic_info *info,
       info->kind = DXIL_SEM_VIEWPORT_ARRAY_INDEX;
       break;
 
+   case VARYING_SLOT_LAYER:
+      assert(glsl_get_components(var->type) == 1);
+      snprintf(info->name, 64, "%s", "SV_RenderTargetArrayIndex");
+      info->kind = DXIL_SEM_RENDERTARGET_ARRAY_INDEX;
+      break;
+
    default: {
          info->index = var->data.driver_location;
          strcpy(info->name, "TEXCOORD");
diff --git a/src/microsoft/compiler/nir_to_dxil.c b/src/microsoft/compiler/nir_to_dxil.c
index 7cec75b32b8..5995aab4203 100644
--- a/src/microsoft/compiler/nir_to_dxil.c
+++ b/src/microsoft/compiler/nir_to_dxil.c
@@ -5440,7 +5440,8 @@ emit_module(struct ntd_context *ctx, const struct nir_to_dxil_options *opts)
       }
    } else if (ctx->shader->info.stage == MESA_SHADER_VERTEX ||
               ctx->shader->info.stage == MESA_SHADER_TESS_EVAL) {
-      if (ctx->shader->info.outputs_written & VARYING_BIT_VIEWPORT)
+      if (ctx->shader->info.outputs_written &
+          (VARYING_BIT_VIEWPORT | VARYING_BIT_LAYER))
          ctx->mod.feats.array_layer_from_vs_or_ds = true;
    }
 
@@ -5880,6 +5881,7 @@ nir_var_to_dxil_sysvalue_type(nir_variable *var, uint64_t other_stage_mask)
    case VARYING_SLOT_TESS_LEVEL_INNER:
    case VARYING_SLOT_TESS_LEVEL_OUTER:
    case VARYING_SLOT_VIEWPORT:
+   case VARYING_SLOT_LAYER:
       if (!((1ull << var->data.location) & other_stage_mask))
          return DXIL_SYSVALUE;
       FALLTHROUGH;



More information about the mesa-commit mailing list