[Mesa-dev] [PATCH 14/16] swr/rast: Fix read-back of render target array index

Tim Rowley timothy.o.rowley at intel.com
Thu Jun 15 18:37:15 UTC 2017


The last FE stage can emit render target array index. Currently we only
check to see if GS is emitting it. Moved the state to BACKEND_STATE and
plumbed the driver to set it.
---
 src/gallium/drivers/swr/rasterizer/core/api.cpp    |  2 +-
 src/gallium/drivers/swr/rasterizer/core/binner.cpp | 16 ++++++++--------
 src/gallium/drivers/swr/rasterizer/core/state.h    |  5 ++---
 src/gallium/drivers/swr/swr_shader.cpp             |  1 -
 src/gallium/drivers/swr/swr_state.cpp              |  7 +++++++
 5 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp b/src/gallium/drivers/swr/rasterizer/core/api.cpp
index 5dd4dc3..eacce1c 100644
--- a/src/gallium/drivers/swr/rasterizer/core/api.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/api.cpp
@@ -680,7 +680,7 @@ void SwrSetBlendFunc(
 // update guardband multipliers for the viewport
 void updateGuardbands(API_STATE *pState)
 {
-    uint32_t numGbs = pState->gsState.emitsRenderTargetArrayIndex ? KNOB_NUM_VIEWPORTS_SCISSORS : 1;
+    uint32_t numGbs = pState->backendState.readRenderTargetArrayIndex ? KNOB_NUM_VIEWPORTS_SCISSORS : 1;
 
     for(uint32_t i = 0; i < numGbs; ++i)
     {
diff --git a/src/gallium/drivers/swr/rasterizer/core/binner.cpp b/src/gallium/drivers/swr/rasterizer/core/binner.cpp
index 4f8498d..a73816b 100644
--- a/src/gallium/drivers/swr/rasterizer/core/binner.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/binner.cpp
@@ -763,7 +763,7 @@ endBinTriangles:
 
     // store render target array index
     OSALIGNSIMD(uint32_t) aRTAI[KNOB_SIMD_WIDTH];
-    if (gsState.gsEnable && gsState.emitsRenderTargetArrayIndex)
+    if (state.backendState.readRenderTargetArrayIndex)
     {
         simdvector vRtai[3];
         pa.Assemble(VERTEX_SGV_SLOT, vRtai);
@@ -1213,7 +1213,7 @@ endBinTriangles:
 
     // store render target array index
     OSALIGNSIMD16(uint32_t) aRTAI[KNOB_SIMD16_WIDTH];
-    if (gsState.gsEnable && gsState.emitsRenderTargetArrayIndex)
+    if (state.backendState.readRenderTargetArrayIndex)
     {
         simd16vector vRtai[3];
         pa.Assemble_simd16(VERTEX_SGV_SLOT, vRtai);
@@ -1423,7 +1423,7 @@ void BinPostSetupPoints(
 
         // store render target array index
         OSALIGNSIMD(uint32_t) aRTAI[KNOB_SIMD_WIDTH];
-        if (gsState.gsEnable && gsState.emitsRenderTargetArrayIndex)
+        if (state.backendState.readRenderTargetArrayIndex)
         {
             simdvector vRtai;
             pa.Assemble(VERTEX_SGV_SLOT, &vRtai);
@@ -1563,7 +1563,7 @@ void BinPostSetupPoints(
 
         // store render target array index
         OSALIGNSIMD(uint32_t) aRTAI[KNOB_SIMD_WIDTH];
-        if (gsState.gsEnable && gsState.emitsRenderTargetArrayIndex)
+        if (state.backendState.readRenderTargetArrayIndex)
         {
             simdvector vRtai[2];
             pa.Assemble(VERTEX_SGV_SLOT, vRtai);
@@ -1793,7 +1793,7 @@ void BinPostSetupPoints_simd16(
 
         // store render target array index
         OSALIGNSIMD16(uint32_t) aRTAI[KNOB_SIMD16_WIDTH];
-        if (gsState.gsEnable && gsState.emitsRenderTargetArrayIndex)
+        if (state.backendState.readRenderTargetArrayIndex)
         {
             simd16vector vRtai;
             pa.Assemble_simd16(VERTEX_SGV_SLOT, &vRtai);
@@ -1938,7 +1938,7 @@ void BinPostSetupPoints_simd16(
 
         // store render target array index
         OSALIGNSIMD16(uint32_t) aRTAI[KNOB_SIMD16_WIDTH];
-        if (gsState.gsEnable && gsState.emitsRenderTargetArrayIndex)
+        if (state.backendState.readRenderTargetArrayIndex)
         {
             simd16vector vRtai[2];
             pa.Assemble_simd16(VERTEX_SGV_SLOT, vRtai);
@@ -2219,7 +2219,7 @@ void BinPostSetupLines(
 
     // store render target array index
     OSALIGNSIMD(uint32_t) aRTAI[KNOB_SIMD_WIDTH];
-    if (gsState.gsEnable && gsState.emitsRenderTargetArrayIndex)
+    if (state.backendState.readRenderTargetArrayIndex)
     {
         simdvector vRtai[2];
         pa.Assemble(VERTEX_SGV_SLOT, vRtai);
@@ -2436,7 +2436,7 @@ void BinPostSetupLines_simd16(
 
     // store render target array index
     OSALIGNSIMD16(uint32_t) aRTAI[KNOB_SIMD16_WIDTH];
-    if (gsState.gsEnable && gsState.emitsRenderTargetArrayIndex)
+    if (state.backendState.readRenderTargetArrayIndex)
     {
         simd16vector vRtai[2];
         pa.Assemble_simd16(VERTEX_SGV_SLOT, vRtai);
diff --git a/src/gallium/drivers/swr/rasterizer/core/state.h b/src/gallium/drivers/swr/rasterizer/core/state.h
index 0cf9ad6..7609d51 100644
--- a/src/gallium/drivers/swr/rasterizer/core/state.h
+++ b/src/gallium/drivers/swr/rasterizer/core/state.h
@@ -710,9 +710,6 @@ struct SWR_GS_STATE
     // instance count
     uint32_t instanceCount;
 
-    // geometry shader emits renderTargetArrayIndex
-    bool emitsRenderTargetArrayIndex;
-
     // geometry shader emits ViewportArrayIndex
     bool emitsViewportArrayIndex;
 
@@ -1074,6 +1071,8 @@ struct SWR_BACKEND_STATE
                                         // setting up attributes for the backend, otherwise
                                         // all attributes up to numAttributes will be sent
     SWR_ATTRIB_SWIZZLE swizzleMap[32];
+
+    bool readRenderTargetArrayIndex;    // Forward render target array index from last FE stage to the backend
 };
 
 
diff --git a/src/gallium/drivers/swr/swr_shader.cpp b/src/gallium/drivers/swr/swr_shader.cpp
index 2a77293..f4029be 100644
--- a/src/gallium/drivers/swr/swr_shader.cpp
+++ b/src/gallium/drivers/swr/swr_shader.cpp
@@ -547,7 +547,6 @@ BuilderSWR::CompileGS(struct swr_context *ctx, swr_jit_gs_key &key)
    pGS->maxNumVerts = info->properties[TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES];
    pGS->instanceCount = info->properties[TGSI_PROPERTY_GS_INVOCATIONS];
 
-   pGS->emitsRenderTargetArrayIndex = info->writes_layer;
    pGS->emitsViewportArrayIndex = info->writes_viewport_index;
 
    // XXX: single stream for now...
diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp
index 953b679..0620860 100644
--- a/src/gallium/drivers/swr/swr_state.cpp
+++ b/src/gallium/drivers/swr/swr_state.cpp
@@ -1744,6 +1744,13 @@ swr_update_derived(struct pipe_context *pipe,
       (ctx->rasterizer->flatshade ? ctx->fs->flatConstantMask : 0);
    backendState.pointSpriteTexCoordMask = ctx->fs->pointSpriteMask;
 
+   if (ctx->gs)
+      backendState.readRenderTargetArrayIndex =
+         ctx->gs->info.base.writes_layer;
+   else
+      backendState.readRenderTargetArrayIndex =
+         ctx->vs->info.base.writes_layer;
+
    SwrSetBackendState(ctx->swrContext, &backendState);
 
    /* Ensure that any in-progress attachment change StoreTiles finish */
-- 
2.7.4



More information about the mesa-dev mailing list