Browse Source

swr: [rasterizer core] implement legacy depth bias enable

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
tags/12.0-branchpoint
Tim Rowley 10 years ago
parent
commit
24f23817d2

+ 2
- 2
src/gallium/drivers/swr/rasterizer/core/api.cpp View File

@@ -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;


+ 7
- 1
src/gallium/drivers/swr/rasterizer/core/rasterizer.cpp View File

@@ -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);

+ 15
- 17
src/gallium/drivers/swr/rasterizer/core/state.h View File

@@ -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


+ 1
- 1
src/gallium/drivers/swr/swr_state.cpp View File

@@ -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) {

Loading…
Cancel
Save