Moved from from SWR_RASTSTATE to SWR_BACKEND_STATE.
Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
AR_END(BEBarycentric, 0);
// interpolate user clip distance if available
- if (state.rastState.clipDistanceMask)
+ if (state.backendState.clipDistanceMask)
{
- coverageMask &= ~ComputeUserClipMask(state.rastState.clipDistanceMask, work.pUserClipBuffer, psContext.vI.sample, psContext.vJ.sample);
+ coverageMask &= ~ComputeUserClipMask(state.backendState.clipDistanceMask, work.pUserClipBuffer, psContext.vI.sample, psContext.vJ.sample);
}
simdscalar vCoverageMask = _simd_vmask_ps(coverageMask);
AR_END(BESetup, 0);
- PixelRateZTestLoop<T> PixelRateZTest(pDC, workerId, work, coeffs, state, pDepthBuffer, pStencilBuffer, state.rastState.clipDistanceMask);
+ PixelRateZTestLoop<T> PixelRateZTest(pDC, workerId, work, coeffs, state, pDepthBuffer, pStencilBuffer, state.backendState.clipDistanceMask);
psContext.vY.UL = _simd_add_ps(vULOffsetsY, _simd_set1_ps(static_cast<float>(y)));
psContext.vY.center = _simd_add_ps(vCenterOffsetsY, _simd_set1_ps(static_cast<float>(y)));
AR_END(BEBarycentric, 0);
// interpolate user clip distance if available
- if (state.rastState.clipDistanceMask)
+ if (state.backendState.clipDistanceMask)
{
- coverageMask &= ~ComputeUserClipMask(state.rastState.clipDistanceMask, work.pUserClipBuffer, psContext.vI.sample, psContext.vJ.sample);
+ coverageMask &= ~ComputeUserClipMask(state.backendState.clipDistanceMask, work.pUserClipBuffer, psContext.vI.sample, psContext.vJ.sample);
}
simdscalar vCoverageMask = _simd_vmask_ps(coverageMask);
AR_END(BEBarycentric, 1);
// interpolate user clip distance if available
- if (state.rastState.clipDistanceMask)
+ if (state.backendState.clipDistanceMask)
{
- coverageMask &= ~ComputeUserClipMask(state.rastState.clipDistanceMask, work.pUserClipBuffer, psContext.vI.center, psContext.vJ.center);
+ coverageMask &= ~ComputeUserClipMask(state.backendState.clipDistanceMask, work.pUserClipBuffer, psContext.vI.center, psContext.vJ.center);
}
simdscalar vCoverageMask = _simd_vmask_ps(coverageMask);
SIMD128::store_ps(&desc.pTriBuffer[12], vHorizW[triIndex]);
// store user clip distances
- if (rastState.clipDistanceMask)
+ if (state.backendState.clipDistanceMask)
{
- uint32_t numClipDist = _mm_popcnt_u32(rastState.clipDistanceMask);
+ uint32_t numClipDist = _mm_popcnt_u32(state.backendState.clipDistanceMask);
desc.pUserClipBuffer = (float*)pArena->Alloc(numClipDist * 3 * sizeof(float));
- ProcessUserClipDist<3>(pa, triIndex, rastState.clipDistanceMask, &desc.pTriBuffer[12], desc.pUserClipBuffer);
+ ProcessUserClipDist<3>(pa, triIndex, state.backendState.clipDistanceMask, &desc.pTriBuffer[12], desc.pUserClipBuffer);
}
for (uint32_t y = aMTTop[triIndex]; y <= aMTBottom[triIndex]; ++y)
*pTriBuffer = aPrimVertsZ[primIndex];
// store user clip distances
- if (rastState.clipDistanceMask)
+ if (backendState.clipDistanceMask)
{
- uint32_t numClipDist = _mm_popcnt_u32(rastState.clipDistanceMask);
+ uint32_t numClipDist = _mm_popcnt_u32(backendState.clipDistanceMask);
desc.pUserClipBuffer = (float*)pArena->Alloc(numClipDist * 3 * sizeof(float));
float dists[8];
float one = 1.0f;
- ProcessUserClipDist<1>(pa, primIndex, rastState.clipDistanceMask, &one, dists);
+ ProcessUserClipDist<1>(pa, primIndex, backendState.clipDistanceMask, &one, dists);
for (uint32_t i = 0; i < numClipDist; i++) {
desc.pUserClipBuffer[3 * i + 0] = 0.0f;
desc.pUserClipBuffer[3 * i + 1] = 0.0f;
_mm_store_ps(&desc.pTriBuffer[12], vHorizW[primIndex]);
// store user clip distances
- if (rastState.clipDistanceMask)
+ if (state.backendState.clipDistanceMask)
{
- uint32_t numClipDist = _mm_popcnt_u32(rastState.clipDistanceMask);
+ uint32_t numClipDist = _mm_popcnt_u32(state.backendState.clipDistanceMask);
desc.pUserClipBuffer = (float*)pArena->Alloc(numClipDist * 2 * sizeof(float));
- ProcessUserClipDist<2>(pa, primIndex, rastState.clipDistanceMask, &desc.pTriBuffer[12], desc.pUserClipBuffer);
+ ProcessUserClipDist<2>(pa, primIndex, state.backendState.clipDistanceMask, &desc.pTriBuffer[12], desc.pUserClipBuffer);
}
MacroTileMgr *pTileMgr = pDC->pTileMgr;
int ComputeUserClipCullMask(PA_STATE &pa, typename SIMD_T::Vec4 prim[])
{
- uint8_t cullMask = state.rastState.cullDistanceMask;
+ uint8_t cullMask = state.backendState.cullDistanceMask;
typename SIMD_T::Float vClipCullMask = SIMD_T::setzero_ps();
typename SIMD_T::Vec4 vClipCullDistLo[3];
}
// clipper should also discard any primitive with NAN clip distance
- uint8_t clipMask = state.rastState.clipDistanceMask;
+ uint8_t clipMask = state.backendState.clipDistanceMask;
while (_BitScanForward(&index, clipMask))
{
clipMask &= ~(1 << index);
}
// assemble user clip distances if enabled
- if (state.rastState.clipDistanceMask & 0xf)
+ if (state.backendState.clipDistanceMask & 0xf)
{
pa.Assemble(VERTEX_CLIPCULL_DIST_LO_SLOT, tmpVector);
for (uint32_t i = 0; i < NumVertsPerPrim; ++i)
}
}
- if (state.rastState.clipDistanceMask & 0xf0)
+ if (state.backendState.clipDistanceMask & 0xf0)
{
pa.Assemble(VERTEX_CLIPCULL_DIST_HI_SLOT, tmpVector);
for (uint32_t i = 0; i < NumVertsPerPrim; ++i)
}
// transpose user clip distances if enabled
- if (state.rastState.clipDistanceMask & 0x0f)
+ if (state.backendState.clipDistanceMask & 0x0f)
{
pBase = reinterpret_cast<uint8_t *>(&vertices[0].attrib[VERTEX_CLIPCULL_DIST_LO_SLOT]) + sizeof(float) * inputPrim;
}
}
- if (state.rastState.clipDistanceMask & 0xf0)
+ if (state.backendState.clipDistanceMask & 0xf0)
{
pBase = reinterpret_cast<uint8_t *>(&vertices[0].attrib[VERTEX_CLIPCULL_DIST_HI_SLOT]) + sizeof(float) * inputPrim;
primMask &= ~ComputeNaNMask(prim);
// user cull distance cull
- if (this->state.rastState.cullDistanceMask)
+ if (state.backendState.cullDistanceMask)
{
primMask &= ~ComputeUserClipCullMask(pa, prim);
}
}
// interpolate clip distance if enabled
- if (this->state.rastState.clipDistanceMask & 0xf)
+ if (this->state.backendState.clipDistanceMask & 0xf)
{
uint32_t attribSlot = VERTEX_CLIPCULL_DIST_LO_SLOT;
for (uint32_t c = 0; c < 4; ++c)
}
}
- if (this->state.rastState.clipDistanceMask & 0xf0)
+ if (this->state.backendState.clipDistanceMask & 0xf0)
{
uint32_t attribSlot = VERTEX_CLIPCULL_DIST_HI_SLOT;
for (uint32_t c = 0; c < 4; ++c)
}
// store clip distance if enabled
- if (this->state.rastState.clipDistanceMask & 0xf)
+ if (this->state.backendState.clipDistanceMask & 0xf)
{
uint32_t attribSlot = VERTEX_CLIPCULL_DIST_LO_SLOT;
for (uint32_t c = 0; c < 4; ++c)
}
}
- if (this->state.rastState.clipDistanceMask & 0xf0)
+ if (this->state.backendState.clipDistanceMask & 0xf0)
{
uint32_t attribSlot = VERTEX_CLIPCULL_DIST_HI_SLOT;
for (uint32_t c = 0; c < 4; ++c)
// Store user clip distances for triangle 0
float newClipBuffer[3 * 8];
- uint32_t numClipDist = _mm_popcnt_u32(state.rastState.clipDistanceMask);
+ uint32_t numClipDist = _mm_popcnt_u32(state.backendState.clipDistanceMask);
if (numClipDist)
{
newWorkDesc.pUserClipBuffer = newClipBuffer;
uint32_t pixelLocation; // UL or Center
SWR_MULTISAMPLE_POS samplePositions; // @llvm_struct
bool bIsCenterPattern; // @llvm_enum
-
- // user clip/cull distance enables
- uint8_t cullDistanceMask;
- uint8_t clipDistanceMask;
};
bool readRenderTargetArrayIndex; // Forward render target array index from last FE stage to the backend
bool readViewportArrayIndex; // Read viewport array index from last FE stage during binning
+ // user clip/cull distance enables
+ uint8_t cullDistanceMask;
+ uint8_t clipDistanceMask;
+
// Offset to the start of the attributes of the input vertices, in simdvector units
uint32_t vertexAttribOffset;
};
rastState->depthClipEnable = rasterizer->depth_clip;
rastState->clipHalfZ = rasterizer->clip_halfz;
- rastState->clipDistanceMask =
- ctx->vs->info.base.num_written_clipdistance ?
- ctx->vs->info.base.clipdist_writemask & rasterizer->clip_plane_enable :
- rasterizer->clip_plane_enable;
-
- rastState->cullDistanceMask =
- ctx->vs->info.base.culldist_writemask << ctx->vs->info.base.num_written_clipdistance;
-
ctx->api.pfnSwrSetRastState(ctx->swrContext, rastState);
}
backendState.readViewportArrayIndex = pLastFE->writes_viewport_index;
backendState.vertexAttribOffset = VERTEX_ATTRIB_START_SLOT; // TODO: optimize
+ backendState.clipDistanceMask =
+ ctx->vs->info.base.num_written_clipdistance ?
+ ctx->vs->info.base.clipdist_writemask & ctx->rasterizer->clip_plane_enable :
+ ctx->rasterizer->clip_plane_enable;
+
+ backendState.cullDistanceMask =
+ ctx->vs->info.base.culldist_writemask << ctx->vs->info.base.num_written_clipdistance;
+
ctx->api.pfnSwrSetBackendState(ctx->swrContext, &backendState);
/* Ensure that any in-progress attachment change StoreTiles finish */