From: Tim Rowley Date: Mon, 18 Apr 2016 20:35:21 +0000 (-0600) Subject: swr: [rasterizer core] implement legacy depth bias enable X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=24f23817d2b15941c84f42c202eba5b24599286b;p=mesa.git swr: [rasterizer core] implement legacy depth bias enable Reviewed-by: Bruce Cherniak --- diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp b/src/gallium/drivers/swr/rasterizer/core/api.cpp index e3127923b6f..3c253702ec0 100644 --- a/src/gallium/drivers/swr/rasterizer/core/api.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/api.cpp @@ -767,7 +767,7 @@ void SetupPipeline(DRAW_CONTEXT *pDC) const SWR_RASTSTATE &rastState = pState->state.rastState; const SWR_PS_STATE &psState = pState->state.psState; BACKEND_FUNCS& backendFuncs = pState->backendFuncs; - const uint32_t forcedSampleCount = (rastState.bForcedSampleCount) ? 1 : 0; + const uint32_t forcedSampleCount = (rastState.forcedSampleCount) ? 1 : 0; // setup backend if (psState.pfnPixelShader == nullptr) @@ -776,7 +776,7 @@ void SetupPipeline(DRAW_CONTEXT *pDC) } else { - const bool bMultisampleEnable = ((rastState.sampleCount > SWR_MULTISAMPLE_1X) || rastState.bForcedSampleCount) ? 1 : 0; + const bool bMultisampleEnable = ((rastState.sampleCount > SWR_MULTISAMPLE_1X) || rastState.forcedSampleCount) ? 1 : 0; const uint32_t centroid = ((psState.barycentricsMask & SWR_BARYCENTRIC_CENTROID_MASK) > 0) ? 1 : 0; const uint32_t canEarlyZ = (psState.forceEarlyZ || (!psState.writesODepth && !psState.usesSourceDepth && !psState.usesUAV)) ? 1 : 0; diff --git a/src/gallium/drivers/swr/rasterizer/core/rasterizer.cpp b/src/gallium/drivers/swr/rasterizer/core/rasterizer.cpp index 3144a901c91..f7a462c3174 100644 --- a/src/gallium/drivers/swr/rasterizer/core/rasterizer.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/rasterizer.cpp @@ -363,7 +363,13 @@ INLINE float ComputeDepthBias(const SWR_RASTSTATE* pState, const SWR_TRIANGLE_DE scale *= ComputeMaxDepthSlope(pTri); } - float bias = pState->depthBias * ComputeBiasFactor(pState, pTri, z) + scale; + float bias = pState->depthBias; + if (!pState->depthBiasPreAdjusted) + { + bias *= ComputeBiasFactor(pState, pTri, z); + } + bias += scale; + if (pState->depthBiasClamp > 0.0f) { bias = std::min(bias, pState->depthBiasClamp); diff --git a/src/gallium/drivers/swr/rasterizer/core/state.h b/src/gallium/drivers/swr/rasterizer/core/state.h index 88ec4b02033..f4813e42395 100644 --- a/src/gallium/drivers/swr/rasterizer/core/state.h +++ b/src/gallium/drivers/swr/rasterizer/core/state.h @@ -495,7 +495,6 @@ struct SWR_SURFACE_STATE uint32_t lod; // for render targets, the lod being rendered to uint32_t arrayIndex; // for render targets, the array index being rendered to for arrayed surfaces SWR_TILE_MODE tileMode; // @llvm_enum - bool bInterleavedSamples; // are MSAA samples stored interleaved or planar uint32_t halign; uint32_t valign; uint32_t xOffset; @@ -504,6 +503,8 @@ struct SWR_SURFACE_STATE uint32_t lodOffsets[2][15]; // lod offsets for sampled surfaces uint8_t *pAuxBaseAddress; // Used for compression, append/consume counter, etc. + + bool bInterleavedSamples; // are MSAA samples stored interleaved or planar }; // vertex fetch state @@ -895,22 +896,22 @@ enum SWR_MSAA_RASTMODE ////////////////////////////////////////////////////////////////////////// struct SWR_RASTSTATE { - uint32_t cullMode : 2; - uint32_t fillMode : 2; - uint32_t frontWinding : 1; - uint32_t scissorEnable : 1; - uint32_t depthClipEnable : 1; + uint32_t cullMode : 2; + uint32_t fillMode : 2; + uint32_t frontWinding : 1; + uint32_t scissorEnable : 1; + uint32_t depthClipEnable : 1; + uint32_t pointParam : 1; + uint32_t pointSpriteEnable : 1; + uint32_t pointSpriteTopOrigin : 1; + uint32_t msaaRastEnable : 1; + uint32_t forcedSampleCount : 1; + uint32_t pixelOffset : 1; + uint32_t depthBiasPreAdjusted : 1; ///< depth bias constant is in float units, not per-format Z units + float pointSize; float lineWidth; - // point size output from the VS - bool pointParam; - - // point sprite - bool pointSpriteEnable; - bool pointSpriteTopOrigin; - - // depth bias float depthBias; float slopeScaledDepthBias; float depthBiasClamp; @@ -918,14 +919,11 @@ struct SWR_RASTSTATE ///@todo: MSAA lines // multisample state for MSAA lines - bool msaaRastEnable; SWR_MSAA_RASTMODE rastMode; // @llvm_enum // sample count the rasterizer is running at SWR_MULTISAMPLE_COUNT sampleCount; // @llvm_enum - bool bForcedSampleCount; uint32_t pixelLocation; // UL or Center - bool pixelOffset; // offset pixel positions by .5 in both the horizontal and vertical direction SWR_MULTISAMPLE_POS iSamplePos[SWR_MAX_NUM_MULTISAMPLES]; SWR_MSAA_SAMPLE_PATTERN samplePattern; // @llvm_enum diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp index 18c4fb23c9b..7eb904988bd 100644 --- a/src/gallium/drivers/swr/swr_state.cpp +++ b/src/gallium/drivers/swr/swr_state.cpp @@ -831,7 +831,7 @@ swr_update_derived(struct pipe_context *pipe, rastState->msaaRastEnable = false; rastState->rastMode = SWR_MSAA_RASTMODE_OFF_PIXEL; rastState->sampleCount = SWR_MULTISAMPLE_1X; - rastState->bForcedSampleCount = false; + rastState->forcedSampleCount = false; bool do_offset = false; switch (rasterizer->fill_front) {