case GL_MAX_PROGRAM_TEXEL_OFFSET:
// Note: SwiftShader has no actual texel offset limit, so this limit can be modified if required.
// In any case, any behavior outside the specified range is valid since the spec mentions:
- // (see OpenGL ES 3.0.5, 3.8.10.1 Scale Factor and Level of Detail, p.153)\r // "If any of the offset values are outside the range of the implementation-defined values
+ // (see OpenGL ES 3.0.5, 3.8.10.1 Scale Factor and Level of Detail, p.153)
+ // "If any of the offset values are outside the range of the implementation-defined values
// MIN_PROGRAM_TEXEL_OFFSET and MAX_PROGRAM_TEXEL_OFFSET, results of the texture lookup are
// undefined."
*params = MAX_PROGRAM_TEXEL_OFFSET;
case GL_MIN_PROGRAM_TEXEL_OFFSET:
// Note: SwiftShader has no actual texel offset limit, so this limit can be modified if required.
// In any case, any behavior outside the specified range is valid since the spec mentions:
- // (see OpenGL ES 3.0.5, 3.8.10.1 Scale Factor and Level of Detail, p.153)\r // "If any of the offset values are outside the range of the implementation-defined values
+ // (see OpenGL ES 3.0.5, 3.8.10.1 Scale Factor and Level of Detail, p.153)
+ // "If any of the offset values are outside the range of the implementation-defined values
// MIN_PROGRAM_TEXEL_OFFSET and MAX_PROGRAM_TEXEL_OFFSET, results of the texture lookup are
// undefined."
*params = MIN_PROGRAM_TEXEL_OFFSET;
if(depthbuffer)
{
device->setSlopeDepthBias(mState.polygonOffsetFactor);
- float depthBias = ldexp(mState.polygonOffsetUnits, -(int)(depthbuffer->getDepthSize()));
+ float depthBias = ldexp(mState.polygonOffsetUnits, -23); // We use 32-bit floating-point for all depth formats, with 23 mantissa bits.
device->setDepthBias(depthBias);
}
}
// case sw::FORMAT_D32_LOCKABLE: return 0;
// case sw::FORMAT_S8_LOCKABLE: return 8;
default:
+ UNREACHABLE(stencilFormat);
return 0;
}
}
case sw::FORMAT_R5G6B5:
return 0;
default:
+ UNREACHABLE(colorFormat);
return 0;
}
}
case sw::FORMAT_R5G6B5:
return 5;
default:
+ UNREACHABLE(colorFormat);
return 0;
}
}
case sw::FORMAT_R5G6B5:
return 6;
default:
+ UNREACHABLE(colorFormat);
return 0;
}
}
case sw::FORMAT_R5G6B5:
return 5;
default:
+ UNREACHABLE(colorFormat);
return 0;
}
}
// case sw::FORMAT_S8_LOCKABLE: return 0;
case sw::FORMAT_D32FS8_SHADOW:
case sw::FORMAT_D32FS8_TEXTURE: return 32;
- default: return 0;
+ default:
+ UNREACHABLE(depthFormat);
+ return 0;
}
}
cullMode = CULL_CLOCKWISE;
alphaReference = 0.0f;
+ depthBias = 0.0f;
+ slopeDepthBias = 0.0f;
+
for(int i = 0; i < RENDERTARGETS; i++)
{
colorWriteMask[i] = 0x0000000F;
CullMode cullMode;
float alphaReference;
+ float depthBias;
+ float slopeDepthBias;
+
TextureStage textureStage[8];
Sampler sampler[TOTAL_IMAGE_UNITS];
state.pixelFogMode = context->pixelFogActive();
state.wBasedFog = context->wBasedFog && context->pixelFogActive() != FOG_NONE;
state.perspective = context->perspectiveActive();
+ state.depthClamp = (context->depthBias != 0.0f) || (context->slopeDepthBias != 0.0f);
if(context->alphaBlendActive())
{
bool occlusionEnabled : 1;
bool wBasedFog : 1;
bool perspective : 1;
+ bool depthClamp : 1;
bool alphaBlendActive : 1;
BlendFactor sourceBlendFactor : BITS(BLEND_LAST);
if(context->isDrawTriangle(false))
{
- N += depthBias;
+ N += context->depthBias;
}
if(complementaryDepthBuffer)
data->halfPixelX = replicate(0.5f / W);
data->halfPixelY = replicate(0.5f / H);
data->viewportHeight = abs(viewport.height);
- data->slopeDepthBias = slopeDepthBias;
+ data->slopeDepthBias = context->slopeDepthBias;
data->depthRange = Z;
data->depthNear = N;
draw->clipFlags = clipFlags;
void Renderer::setDepthBias(float bias)
{
- depthBias = bias;
+ context->depthBias = bias;
}
void Renderer::setSlopeDepthBias(float slopeBias)
{
- slopeDepthBias = slopeBias;
+ context->slopeDepthBias = slopeBias;
}
void Renderer::setRasterizerDiscard(bool rasterizerDiscard)
state.pointSprite = context->pointSpriteActive();
state.cullMode = context->cullMode;
state.twoSidedStencil = context->stencilActive() && context->twoSidedStencil;
- state.slopeDepthBias = slopeDepthBias != 0.0f;
+ state.slopeDepthBias = context->slopeDepthBias != 0.0f;
state.vFace = context->pixelShader && context->pixelShader->isVFaceDeclared();
state.positionRegister = Pos;
void setRoutineCacheSize(int cacheSize);
- float depthBias;
- float slopeDepthBias;
-
private:
Context *const context;
}
z[q] = interpolate(x, Dz[q], z[q], primitive + OFFSET(Primitive,z), false, false);
+
+ if(state.depthClamp)
+ {
+ z[q] = Min(Max(z[q], Float4(0.0f)), Float4(1.0f));
+ }
}
}