pState->rastState.cullMode = SWR_CULLMODE_NONE;
pState->rastState.frontWinding = SWR_FRONTWINDING_CCW;
+
+ pState->depthBoundsState.depthBoundsTestEnable = false;
+ pState->depthBoundsState.depthBoundsTestMinValue = 0.0f;
+ pState->depthBoundsState.depthBoundsTestMaxValue = 1.0f;
}
void SwrSync(HANDLE hContext, PFN_CALLBACK_FUNC pfnFunc, uint64_t userData, uint64_t userData2, uint64_t userData3)
pState->backendState = *pBEState;
}
+void SwrSetDepthBoundsState(
+ HANDLE hContext,
+ SWR_DEPTH_BOUNDS_STATE *pDBState)
+{
+ API_STATE* pState = GetDrawState(GetContext(hContext));
+
+ pState->depthBoundsState = *pDBState;
+}
+
void SwrSetPixelShaderState(
HANDLE hContext,
SWR_PS_STATE *pPSState)
simdmask clipCoverageMask = coverageMask & MASK;
// interpolate user clip distance if available
- if(rastState.clipDistanceMask)
+ if (rastState.clipDistanceMask)
{
clipCoverageMask &= ~ComputeUserClipMask(rastState.clipDistanceMask, work.pUserClipBuffer,
- psContext.vI.center, psContext.vJ.center);
+ psContext.vI.center, psContext.vJ.center);
+ }
+
+ if (state.depthHottileEnable && state.depthBoundsState.depthBoundsTestEnable)
+ {
+ static_assert(KNOB_DEPTH_HOT_TILE_FORMAT == R32_FLOAT, "Unsupported depth hot tile format");
+
+ const simdscalar z = _simd_load_ps(reinterpret_cast<const float *>(pDepthBase));
+
+ const float minz = state.depthBoundsState.depthBoundsTestMinValue;
+ const float maxz = state.depthBoundsState.depthBoundsTestMaxValue;
+
+ clipCoverageMask &= CalcDepthBoundsAcceptMask(z, minz, maxz);
}
simdscalar vCoverageMask = vMask(clipCoverageMask);
psContext.vI.sample, psContext.vJ.sample);
}
- simdscalar vCoverageMask = vMask(coverageMask);
- simdscalar depthPassMask = vCoverageMask;
- simdscalar stencilPassMask = vCoverageMask;
-
// offset depth/stencil buffers current sample
uint8_t *pDepthSample = pDepthBase + RasterTileDepthOffset(sample);
uint8_t *pStencilSample = pStencilBase + RasterTileStencilOffset(sample);
+ if (state.depthHottileEnable && state.depthBoundsState.depthBoundsTestEnable)
+ {
+ static_assert(KNOB_DEPTH_HOT_TILE_FORMAT == R32_FLOAT, "Unsupported depth hot tile format");
+
+ const simdscalar z = _simd_load_ps(reinterpret_cast<const float *>(pDepthSample));
+
+ const float minz = state.depthBoundsState.depthBoundsTestMinValue;
+ const float maxz = state.depthBoundsState.depthBoundsTestMaxValue;
+
+ coverageMask &= CalcDepthBoundsAcceptMask(z, minz, maxz);
+ }
+
+ simdscalar vCoverageMask = vMask(coverageMask);
+ simdscalar depthPassMask = vCoverageMask;
+ simdscalar stencilPassMask = vCoverageMask;
+
// Early-Z?
if (T::bCanEarlyZ)
{
}
work.coverageMask[sample] >>= (SIMD_TILE_Y_DIM * SIMD_TILE_X_DIM);
}
+
+Endtile:
AR_BEGIN(BEEndTile, pDC->drawId);
if(T::InputCoverage == SWR_INPUT_COVERAGE_INNER_CONSERVATIVE)
{
psContext.vI.sample, psContext.vJ.sample);
}
- simdscalar vCoverageMask = vMask(coverageMask);
- simdscalar stencilPassMask = vCoverageMask;
-
// offset depth/stencil buffers current sample
uint8_t *pDepthSample = pDepthBase + RasterTileDepthOffset(sample);
uint8_t *pStencilSample = pStencilBase + RasterTileStencilOffset(sample);
+ if (state.depthHottileEnable && state.depthBoundsState.depthBoundsTestEnable)
+ {
+ static_assert(KNOB_DEPTH_HOT_TILE_FORMAT == R32_FLOAT, "Unsupported depth hot tile format");
+
+ const simdscalar z = _simd_load_ps(reinterpret_cast<const float *>(pDepthSample));
+
+ const float minz = state.depthBoundsState.depthBoundsTestMinValue;
+ const float maxz = state.depthBoundsState.depthBoundsTestMaxValue;
+
+ coverageMask &= CalcDepthBoundsAcceptMask(z, minz, maxz);
+ }
+
+ simdscalar vCoverageMask = vMask(coverageMask);
+ simdscalar stencilPassMask = vCoverageMask;
+
AR_BEGIN(BEEarlyDepthTest, pDC->drawId);
simdscalar depthPassMask = DepthStencilTest(&state, work.triFlags.frontFacing, work.triFlags.viewportIndex,
psContext.vZ, pDepthSample, vCoverageMask, pStencilSample, &stencilPassMask);
uint32_t statCount = _mm_popcnt_u32(statMask);
UPDATE_STAT(DepthPassCount, statCount);
}
+
+Endtile:
work.coverageMask[sample] >>= (SIMD_TILE_Y_DIM * SIMD_TILE_X_DIM);
}
pDepthBase += (KNOB_SIMD_WIDTH * FormatTraits<KNOB_DEPTH_HOT_TILE_FORMAT>::bpp) / 8;
psContext.vOneOverW.centroid = vplaneps(coeffs.vAOneOverW, coeffs.vBOneOverW, coeffs.vCOneOverW, psContext.vI.centroid, psContext.vJ.centroid);
}
+INLINE simdmask CalcDepthBoundsAcceptMask(simdscalar z, float minz, float maxz)
+{
+ const simdscalar minzMask = _simd_cmpge_ps(z, _simd_set1_ps(minz));
+ const simdscalar maxzMask = _simd_cmple_ps(z, _simd_set1_ps(maxz));
+
+ return _simd_movemask_ps(_simd_and_ps(minzMask, maxzMask));
+}
+
template<typename T>
INLINE uint32_t GetNumOMSamples(SWR_MULTISAMPLE_COUNT blendSampleCount)
{
uint8_t *pDepthSample = pDepthBase + RasterTileDepthOffset(sample);
uint8_t * pStencilSample = pStencilBase + RasterTileStencilOffset(sample);
+ if (state.depthHottileEnable && state.depthBoundsState.depthBoundsTestEnable)
+ {
+ static_assert(KNOB_DEPTH_HOT_TILE_FORMAT == R32_FLOAT, "Unsupported depth hot tile format");
+
+ const simdscalar z = _simd_load_ps(reinterpret_cast<const float *>(pDepthSample));
+
+ const float minz = state.depthBoundsState.depthBoundsTestMinValue;
+ const float maxz = state.depthBoundsState.depthBoundsTestMaxValue;
+
+ vCoverageMask[sample] = _simd_and_ps(vCoverageMask[sample], vMask(CalcDepthBoundsAcceptMask(z, minz, maxz)));
+ }
+
// ZTest for this sample
///@todo Need to uncomment out this bucket.
//AR_BEGIN(BEDepthBucket, pDC->drawId);