swr/rast: Fix read-back of render target array index
authorTim Rowley <timothy.o.rowley@intel.com>
Fri, 9 Jun 2017 17:57:39 +0000 (12:57 -0500)
committerTim Rowley <timothy.o.rowley@intel.com>
Fri, 16 Jun 2017 21:20:16 +0000 (16:20 -0500)
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.

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/core/api.cpp
src/gallium/drivers/swr/rasterizer/core/binner.cpp
src/gallium/drivers/swr/rasterizer/core/state.h
src/gallium/drivers/swr/swr_shader.cpp
src/gallium/drivers/swr/swr_state.cpp

index 5dd4dc3430c6893c0fdc43f644314bf33e5152a1..eacce1cc5e95af53833435d3dede95103e526ce4 100644 (file)
@@ -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)
     {
index 4f8498d8b9735e44dd3356d9a1adffbd3cd67355..a73816b8bceb9e4a4ce1545594d10c2675f7709d 100644 (file)
@@ -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);
index 0cf9ad65dbc0a1c21e6ff226802d898c91722958..7609d51ed49f4dfbe7f122263ee16f6d99bc95a1 100644 (file)
@@ -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
 };
 
 
index 2a772939e2da4a52ae99f161ee5c84ee4d6750a4..f4029be89aa0f1d9eff320ac7f672ce37548753e 100644 (file)
@@ -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...
index abdcef7b2f3f4658baa88e9421433cc733b6321a..19d961f05aee55746603430b279538d5e3d2e6e3 100644 (file)
@@ -1755,6 +1755,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 */