- Remove any special casing in the PS stage when primitive ID is input.
Treat as a normal attribute that must be set up properly in the FE linkage.
- Remove primitive id from the PS_CONTEXT and TRI_FLAGS
Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
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
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];
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];
// points are always front facing
desc.triFlags.frontFacing = 1;
- desc.triFlags.primID = pPrimID[primIndex];
desc.triFlags.renderTargetArrayIndex = aRTAI[primIndex];
desc.triFlags.viewportIndex = pViewportIndex[primIndex];
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];
// points are always front facing
desc.triFlags.frontFacing = 1;
- desc.triFlags.primID = pPrimID[primIndex];
desc.triFlags.renderTargetArrayIndex = aRTAI[primIndex];
desc.triFlags.viewportIndex = pViewportIndex[primIndex];
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];
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];
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];
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;
};
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;
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;
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,
};
// 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
// geometry shader emits renderTargetArrayIndex
bool emitsRenderTargetArrayIndex;
- // geometry shader emits PrimitiveID
- bool emitsPrimitiveID;
-
// geometry shader emits ViewportArrayIndex
bool emitsViewportArrayIndex;
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;
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...
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));
// 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++)