aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/drivers/swr/rasterizer/core/backend.h1
-rw-r--r--src/gallium/drivers/swr/rasterizer/core/binner.cpp8
-rw-r--r--src/gallium/drivers/swr/rasterizer/core/context.h1
-rw-r--r--src/gallium/drivers/swr/rasterizer/core/frontend.cpp26
-rw-r--r--src/gallium/drivers/swr/rasterizer/core/state.h13
-rw-r--r--src/gallium/drivers/swr/swr_shader.cpp21
-rw-r--r--src/gallium/drivers/swr/swr_state.cpp21
7 files changed, 33 insertions, 58 deletions
diff --git a/src/gallium/drivers/swr/rasterizer/core/backend.h b/src/gallium/drivers/swr/rasterizer/core/backend.h
index dba5041140f..035948652bc 100644
--- a/src/gallium/drivers/swr/rasterizer/core/backend.h
+++ b/src/gallium/drivers/swr/rasterizer/core/backend.h
@@ -498,7 +498,6 @@ void SetupPixelShaderContext(SWR_PS_CONTEXT *psContext, const SWR_MULTISAMPLE_PO
psContext->pAttribs = work.pAttribs;
psContext->pPerspAttribs = work.pPerspAttribs;
psContext->frontFace = work.triFlags.frontFacing;
- psContext->primID = work.triFlags.primID;
psContext->renderTargetArrayIndex = work.triFlags.renderTargetArrayIndex;
// save Ia/Ib/Ic and Ja/Jb/Jc if we need to reevaluate i/j/k in the shader because of pull attribs
diff --git a/src/gallium/drivers/swr/rasterizer/core/binner.cpp b/src/gallium/drivers/swr/rasterizer/core/binner.cpp
index daadd5f3d33..06078cdcfa1 100644
--- a/src/gallium/drivers/swr/rasterizer/core/binner.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/binner.cpp
@@ -809,7 +809,6 @@ endBinTriangles:
TRIANGLE_WORK_DESC &desc = work.desc.tri;
desc.triFlags.frontFacing = state.forceFront ? 1 : ((frontFaceMask >> triIndex) & 1);
- desc.triFlags.primID = pPrimID[triIndex];
desc.triFlags.renderTargetArrayIndex = aRTAI[triIndex];
desc.triFlags.viewportIndex = pViewportIndex[triIndex];
@@ -1257,7 +1256,6 @@ endBinTriangles:
TRIANGLE_WORK_DESC &desc = work.desc.tri;
desc.triFlags.frontFacing = state.forceFront ? 1 : ((frontFaceMask >> triIndex) & 1);
- desc.triFlags.primID = pPrimID[triIndex];
desc.triFlags.renderTargetArrayIndex = aRTAI[triIndex];
desc.triFlags.viewportIndex = pViewportIndex[triIndex];
@@ -1451,7 +1449,6 @@ void BinPostSetupPoints(
// points are always front facing
desc.triFlags.frontFacing = 1;
- desc.triFlags.primID = pPrimID[primIndex];
desc.triFlags.renderTargetArrayIndex = aRTAI[primIndex];
desc.triFlags.viewportIndex = pViewportIndex[primIndex];
@@ -1601,7 +1598,6 @@ void BinPostSetupPoints(
TRIANGLE_WORK_DESC &desc = work.desc.tri;
desc.triFlags.frontFacing = 1;
- desc.triFlags.primID = pPrimID[primIndex];
desc.triFlags.pointSize = aPointSize[primIndex];
desc.triFlags.renderTargetArrayIndex = aRTAI[primIndex];
desc.triFlags.viewportIndex = pViewportIndex[primIndex];
@@ -1823,7 +1819,6 @@ void BinPostSetupPoints_simd16(
// points are always front facing
desc.triFlags.frontFacing = 1;
- desc.triFlags.primID = pPrimID[primIndex];
desc.triFlags.renderTargetArrayIndex = aRTAI[primIndex];
desc.triFlags.viewportIndex = pViewportIndex[primIndex];
@@ -1978,7 +1973,6 @@ void BinPostSetupPoints_simd16(
TRIANGLE_WORK_DESC &desc = work.desc.tri;
desc.triFlags.frontFacing = 1;
- desc.triFlags.primID = pPrimID[primIndex];
desc.triFlags.pointSize = aPointSize[primIndex];
desc.triFlags.renderTargetArrayIndex = aRTAI[primIndex];
desc.triFlags.viewportIndex = pViewportIndex[primIndex];
@@ -2246,7 +2240,6 @@ void BinPostSetupLines(
TRIANGLE_WORK_DESC &desc = work.desc.tri;
desc.triFlags.frontFacing = 1;
- desc.triFlags.primID = pPrimID[primIndex];
desc.triFlags.yMajor = (yMajorMask >> primIndex) & 1;
desc.triFlags.renderTargetArrayIndex = aRTAI[primIndex];
desc.triFlags.viewportIndex = pViewportIndex[primIndex];
@@ -2464,7 +2457,6 @@ void BinPostSetupLines_simd16(
TRIANGLE_WORK_DESC &desc = work.desc.tri;
desc.triFlags.frontFacing = 1;
- desc.triFlags.primID = pPrimID[primIndex];
desc.triFlags.yMajor = (yMajorMask >> primIndex) & 1;
desc.triFlags.renderTargetArrayIndex = aRTAI[primIndex];
desc.triFlags.viewportIndex = pViewportIndex[primIndex];
diff --git a/src/gallium/drivers/swr/rasterizer/core/context.h b/src/gallium/drivers/swr/rasterizer/core/context.h
index 62332db173b..fa308feade2 100644
--- a/src/gallium/drivers/swr/rasterizer/core/context.h
+++ b/src/gallium/drivers/swr/rasterizer/core/context.h
@@ -62,7 +62,6 @@ struct TRI_FLAGS
uint32_t coverageMask : (SIMD_TILE_X_DIM * SIMD_TILE_Y_DIM);
uint32_t reserved : 32 - 1 - 1 - (SIMD_TILE_X_DIM * SIMD_TILE_Y_DIM);
float pointSize;
- uint32_t primID;
uint32_t renderTargetArrayIndex;
uint32_t viewportIndex;
};
diff --git a/src/gallium/drivers/swr/rasterizer/core/frontend.cpp b/src/gallium/drivers/swr/rasterizer/core/frontend.cpp
index dfbbc580b63..e2660c1cc90 100644
--- a/src/gallium/drivers/swr/rasterizer/core/frontend.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/frontend.cpp
@@ -948,18 +948,7 @@ static void GeometryShaderStage(
if (HasRastT::value && state.soState.streamToRasterizer == stream)
{
#if USE_SIMD16_FRONTEND
- simd16scalari vPrimId;
- // pull primitiveID from the GS output if available
- if (state.gsState.emitsPrimitiveID)
- {
- simd16vector primIdAttrib[3];
- gsPa.Assemble_simd16(VERTEX_PRIMID_SLOT, primIdAttrib);
- vPrimId = _simd16_castps_si(primIdAttrib[state.frontendState.topologyProvokingVertex].x);
- }
- else
- {
- vPrimId = _simd16_set1_epi32(pPrimitiveId[inputPrim]);
- }
+ simd16scalari vPrimId = _simd16_set1_epi32(pPrimitiveId[inputPrim]);
// use viewport array index if GS declares it as an output attribute. Otherwise use index 0.
simd16scalari vViewPortIdx;
@@ -983,18 +972,7 @@ static void GeometryShaderStage(
gsPa.useAlternateOffset = false;
pfnClipFunc(pDC, gsPa, workerId, attrib_simd16, GenMask(gsPa.NumPrims()), vPrimId, vViewPortIdx);
#else
- simdscalari vPrimId;
- // pull primitiveID from the GS output if available
- if (state.gsState.emitsPrimitiveID)
- {
- simdvector primIdAttrib[3];
- gsPa.Assemble(VERTEX_PRIMID_SLOT, primIdAttrib);
- vPrimId = _simd_castps_si(primIdAttrib[state.frontendState.topologyProvokingVertex].x);
- }
- else
- {
- vPrimId = _simd_set1_epi32(pPrimitiveId[inputPrim]);
- }
+ simdscalari vPrimId = _simd_set1_epi32(pPrimitiveId[inputPrim]);
// use viewport array index if GS declares it as an output attribute. Otherwise use index 0.
simdscalari vViewPortIdx;
diff --git a/src/gallium/drivers/swr/rasterizer/core/state.h b/src/gallium/drivers/swr/rasterizer/core/state.h
index 3db637036cd..f7030511474 100644
--- a/src/gallium/drivers/swr/rasterizer/core/state.h
+++ b/src/gallium/drivers/swr/rasterizer/core/state.h
@@ -186,11 +186,10 @@ enum SWR_VTX_SLOTS
VERTEX_ATTRIB_START_SLOT = ( 1 + VERTEX_POSITION_END_SLOT),
VERTEX_ATTRIB_END_SLOT = (32 + VERTEX_POSITION_END_SLOT),
VERTEX_RTAI_SLOT = (33 + VERTEX_POSITION_END_SLOT), // GS writes RenderTargetArrayIndex here
- VERTEX_PRIMID_SLOT = (34 + VERTEX_POSITION_END_SLOT), // GS writes PrimId here
- VERTEX_CLIPCULL_DIST_LO_SLOT = (35 + VERTEX_POSITION_END_SLOT), // VS writes lower 4 clip/cull dist
- VERTEX_CLIPCULL_DIST_HI_SLOT = (36 + VERTEX_POSITION_END_SLOT), // VS writes upper 4 clip/cull dist
- VERTEX_POINT_SIZE_SLOT = (37 + VERTEX_POSITION_END_SLOT), // VS writes point size here
- VERTEX_VIEWPORT_ARRAY_INDEX_SLOT = (38 + VERTEX_POSITION_END_SLOT),
+ VERTEX_CLIPCULL_DIST_LO_SLOT = (34 + VERTEX_POSITION_END_SLOT), // VS writes lower 4 clip/cull dist
+ VERTEX_CLIPCULL_DIST_HI_SLOT = (35 + VERTEX_POSITION_END_SLOT), // VS writes upper 4 clip/cull dist
+ VERTEX_POINT_SIZE_SLOT = (36 + VERTEX_POSITION_END_SLOT), // VS writes point size here
+ VERTEX_VIEWPORT_ARRAY_INDEX_SLOT = (37 + VERTEX_POSITION_END_SLOT),
SWR_VTX_NUM_SLOTS = VERTEX_VIEWPORT_ARRAY_INDEX_SLOT,
};
@@ -343,7 +342,6 @@ struct SWR_PS_CONTEXT
// OUT: result color per rendertarget
uint32_t frontFace; // IN: front- 1, back- 0
- uint32_t primID; // IN: primitive ID
uint32_t sampleIndex; // IN: sampleIndex
uint32_t renderTargetArrayIndex; // IN: render target array index from GS
uint32_t rasterizerSampleCount; // IN: sample count used by the rasterizer
@@ -716,9 +714,6 @@ struct SWR_GS_STATE
// geometry shader emits renderTargetArrayIndex
bool emitsRenderTargetArrayIndex;
- // geometry shader emits PrimitiveID
- bool emitsPrimitiveID;
-
// geometry shader emits ViewportArrayIndex
bool emitsViewportArrayIndex;
diff --git a/src/gallium/drivers/swr/swr_shader.cpp b/src/gallium/drivers/swr/swr_shader.cpp
index 2f495f59c23..44988892691 100644
--- a/src/gallium/drivers/swr/swr_shader.cpp
+++ b/src/gallium/drivers/swr/swr_shader.cpp
@@ -406,8 +406,6 @@ BuilderSWR::swr_gs_llvm_emit_vertex(const struct lp_build_tgsi_gs_iface *gs_base
uint32_t attribSlot = attrib;
if (iface->info->output_semantic_name[attrib] == TGSI_SEMANTIC_PSIZE)
attribSlot = VERTEX_POINT_SIZE_SLOT;
- else if (iface->info->output_semantic_name[attrib] == TGSI_SEMANTIC_PRIMID)
- attribSlot = VERTEX_PRIMID_SLOT;
else if (iface->info->output_semantic_name[attrib] == TGSI_SEMANTIC_LAYER)
attribSlot = VERTEX_RTAI_SLOT;
@@ -534,7 +532,6 @@ BuilderSWR::CompileGS(struct swr_context *ctx, swr_jit_gs_key &key)
pGS->instanceCount = info->properties[TGSI_PROPERTY_GS_INVOCATIONS];
pGS->emitsRenderTargetArrayIndex = info->writes_layer;
- pGS->emitsPrimitiveID = info->writes_primid;
pGS->emitsViewportArrayIndex = info->writes_viewport_index;
// XXX: single stream for now...
@@ -1043,23 +1040,23 @@ BuilderSWR::CompileFS(struct swr_context *ctx, swr_jit_fs_key &key)
inputs[attrib][3] =
wrap(LOAD(pPS, {0, SWR_PS_CONTEXT_vOneOverW, PixelPositions_center}, "vOneOverW"));
continue;
- } else if (semantic_name == TGSI_SEMANTIC_PRIMID) {
- Value *primID = LOAD(pPS, {0, SWR_PS_CONTEXT_primID}, "primID");
- inputs[attrib][0] = wrap(VECTOR_SPLAT(JM()->mVWidth, primID));
- inputs[attrib][1] = wrap(VIMMED1(0));
- inputs[attrib][2] = wrap(VIMMED1(0));
- inputs[attrib][3] = wrap(VIMMED1(0));
- continue;
}
unsigned linkedAttrib =
locate_linkage(semantic_name, semantic_idx, pPrevShader);
- if (semantic_name == TGSI_SEMANTIC_GENERIC &&
+ uint32_t extraAttribs = 0;
+ if (semantic_name == TGSI_SEMANTIC_PRIMID && !ctx->gs) {
+ /* non-gs generated primID - need to grab from swizzleMap override */
+ linkedAttrib = pPrevShader->num_outputs - 1;
+ swr_fs->constantMask |= 1 << linkedAttrib;
+ extraAttribs++;
+ } else if (semantic_name == TGSI_SEMANTIC_GENERIC &&
key.sprite_coord_enable & (1 << semantic_idx)) {
/* we add an extra attrib to the backendState in swr_update_derived. */
- linkedAttrib = pPrevShader->num_outputs - 1;
+ linkedAttrib = pPrevShader->num_outputs + extraAttribs - 1;
swr_fs->pointSpriteMask |= (1 << linkedAttrib);
+ extraAttribs++;
} else if (linkedAttrib == 0xFFFFFFFF) {
inputs[attrib][0] = wrap(VIMMED1(0.0f));
inputs[attrib][1] = wrap(VIMMED1(0.0f));
diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp
index 2d036f91abf..abdcef7b2f3 100644
--- a/src/gallium/drivers/swr/swr_state.cpp
+++ b/src/gallium/drivers/swr/swr_state.cpp
@@ -1729,9 +1729,24 @@ swr_update_derived(struct pipe_context *pipe,
// set up backend state
SWR_BACKEND_STATE backendState = {0};
- backendState.numAttributes =
- ((ctx->gs ? ctx->gs->info.base.num_outputs : ctx->vs->info.base.num_outputs) - 1) +
- (ctx->rasterizer->sprite_coord_enable ? 1 : 0);
+ if (ctx->gs) {
+ backendState.numAttributes = ctx->gs->info.base.num_outputs - 1;
+ } else {
+ backendState.numAttributes = ctx->vs->info.base.num_outputs - 1;
+ if (ctx->fs->info.base.uses_primid) {
+ backendState.numAttributes++;
+ backendState.swizzleEnable = true;
+ for (unsigned i = 0; i < sizeof(backendState.numComponents); i++) {
+ backendState.swizzleMap[i].sourceAttrib = i;
+ }
+ backendState.swizzleMap[ctx->vs->info.base.num_outputs - 1].constantSource =
+ SWR_CONSTANT_SOURCE_PRIM_ID;
+ backendState.swizzleMap[ctx->vs->info.base.num_outputs - 1].componentOverrideMask = 1;
+ }
+ }
+ if (ctx->rasterizer->sprite_coord_enable)
+ backendState.numAttributes++;
+
backendState.numAttributes = std::min((size_t)backendState.numAttributes,
sizeof(backendState.numComponents));
for (unsigned i = 0; i < backendState.numAttributes; i++)