Commit 0bd27742 by Nicolas Capens

Fix D3D11 'units' polygon offset bias.

D3D11 DepthBias is an integer corresponding directly to GL polygon offset units. BUG=371604 Change-Id: I20a126bd9c6298efff95f3edbf1babc0dd495b18 Reviewed-on: https://chromium-review.googlesource.com/199351Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarNicolas Capens <nicolascapens@chromium.org>
parent 6f182c12
#include "precompiled.h" #include "precompiled.h"
// //
// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
...@@ -206,8 +206,7 @@ bool RenderStateCache::compareRasterizerStates(const RasterizerStateKey &a, cons ...@@ -206,8 +206,7 @@ bool RenderStateCache::compareRasterizerStates(const RasterizerStateKey &a, cons
return memcmp(&a, &b, sizeof(RasterizerStateKey)) == 0; return memcmp(&a, &b, sizeof(RasterizerStateKey)) == 0;
} }
ID3D11RasterizerState *RenderStateCache::getRasterizerState(const gl::RasterizerState &rasterState, ID3D11RasterizerState *RenderStateCache::getRasterizerState(const gl::RasterizerState &rasterState, bool scissorEnabled)
bool scissorEnabled, unsigned int depthSize)
{ {
if (!mDevice) if (!mDevice)
{ {
...@@ -218,7 +217,6 @@ ID3D11RasterizerState *RenderStateCache::getRasterizerState(const gl::Rasterizer ...@@ -218,7 +217,6 @@ ID3D11RasterizerState *RenderStateCache::getRasterizerState(const gl::Rasterizer
RasterizerStateKey key; RasterizerStateKey key;
key.rasterizerState = rasterState; key.rasterizerState = rasterState;
key.scissorEnabled = scissorEnabled; key.scissorEnabled = scissorEnabled;
key.depthSize = depthSize;
RasterizerStateMap::iterator i = mRasterizerStateCache.find(key); RasterizerStateMap::iterator i = mRasterizerStateCache.find(key);
if (i != mRasterizerStateCache.end()) if (i != mRasterizerStateCache.end())
...@@ -267,12 +265,12 @@ ID3D11RasterizerState *RenderStateCache::getRasterizerState(const gl::Rasterizer ...@@ -267,12 +265,12 @@ ID3D11RasterizerState *RenderStateCache::getRasterizerState(const gl::Rasterizer
if (rasterState.polygonOffsetFill) if (rasterState.polygonOffsetFill)
{ {
rasterDesc.SlopeScaledDepthBias = rasterState.polygonOffsetFactor; rasterDesc.SlopeScaledDepthBias = rasterState.polygonOffsetFactor;
rasterDesc.DepthBias = ldexp(rasterState.polygonOffsetUnits, -static_cast<int>(depthSize)); rasterDesc.DepthBias = (INT)rasterState.polygonOffsetUnits;
} }
else else
{ {
rasterDesc.SlopeScaledDepthBias = 0.0f; rasterDesc.SlopeScaledDepthBias = 0.0f;
rasterDesc.DepthBias = 0.0f; rasterDesc.DepthBias = 0;
} }
ID3D11RasterizerState *dx11RasterizerState = NULL; ID3D11RasterizerState *dx11RasterizerState = NULL;
......
// //
// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
...@@ -32,8 +32,7 @@ class RenderStateCache ...@@ -32,8 +32,7 @@ class RenderStateCache
// Increments refcount on the returned blend state, Release() must be called. // Increments refcount on the returned blend state, Release() must be called.
ID3D11BlendState *getBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &blendState); ID3D11BlendState *getBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &blendState);
ID3D11RasterizerState *getRasterizerState(const gl::RasterizerState &rasterState, ID3D11RasterizerState *getRasterizerState(const gl::RasterizerState &rasterState, bool scissorEnabled);
bool scissorEnabled, unsigned int depthSize);
ID3D11DepthStencilState *getDepthStencilState(const gl::DepthStencilState &dsState); ID3D11DepthStencilState *getDepthStencilState(const gl::DepthStencilState &dsState);
ID3D11SamplerState *getSamplerState(const gl::SamplerState &samplerState); ID3D11SamplerState *getSamplerState(const gl::SamplerState &samplerState);
...@@ -63,7 +62,6 @@ class RenderStateCache ...@@ -63,7 +62,6 @@ class RenderStateCache
{ {
gl::RasterizerState rasterizerState; gl::RasterizerState rasterizerState;
bool scissorEnabled; bool scissorEnabled;
unsigned int depthSize;
}; };
static std::size_t hashRasterizerState(const RasterizerStateKey &rasterState); static std::size_t hashRasterizerState(const RasterizerStateKey &rasterState);
static bool compareRasterizerStates(const RasterizerStateKey &a, const RasterizerStateKey &b); static bool compareRasterizerStates(const RasterizerStateKey &a, const RasterizerStateKey &b);
......
...@@ -678,8 +678,7 @@ void Renderer11::setRasterizerState(const gl::RasterizerState &rasterState) ...@@ -678,8 +678,7 @@ void Renderer11::setRasterizerState(const gl::RasterizerState &rasterState)
{ {
if (mForceSetRasterState || memcmp(&rasterState, &mCurRasterState, sizeof(gl::RasterizerState)) != 0) if (mForceSetRasterState || memcmp(&rasterState, &mCurRasterState, sizeof(gl::RasterizerState)) != 0)
{ {
ID3D11RasterizerState *dxRasterState = mStateCache.getRasterizerState(rasterState, mScissorEnabled, ID3D11RasterizerState *dxRasterState = mStateCache.getRasterizerState(rasterState, mScissorEnabled);
mCurDepthSize);
if (!dxRasterState) if (!dxRasterState)
{ {
ERR("NULL rasterizer state returned by RenderStateCache::getRasterizerState, setting the default" ERR("NULL rasterizer state returned by RenderStateCache::getRasterizerState, setting the default"
...@@ -1004,9 +1003,6 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer) ...@@ -1004,9 +1003,6 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer)
stencilbufferSerial = depthStencil->getSerial(); stencilbufferSerial = depthStencil->getSerial();
} }
// Extract the depth stencil sizes and view
unsigned int depthSize = 0;
unsigned int stencilSize = 0;
ID3D11DepthStencilView* framebufferDSV = NULL; ID3D11DepthStencilView* framebufferDSV = NULL;
if (depthStencil) if (depthStencil)
{ {
...@@ -1034,9 +1030,6 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer) ...@@ -1034,9 +1030,6 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer)
renderTargetHeight = depthStencil->getHeight(); renderTargetHeight = depthStencil->getHeight();
renderTargetFormat = depthStencil->getActualFormat(); renderTargetFormat = depthStencil->getActualFormat();
} }
depthSize = depthStencil->getDepthSize();
stencilSize = depthStencil->getStencilSize();
} }
// Apply the render target and depth stencil // Apply the render target and depth stencil
...@@ -1053,14 +1046,11 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer) ...@@ -1053,14 +1046,11 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer)
mForceSetViewport = true; mForceSetViewport = true;
mForceSetScissor = true; mForceSetScissor = true;
if (!mDepthStencilInitialized || depthSize != mCurDepthSize) if (!mDepthStencilInitialized)
{ {
mCurDepthSize = depthSize;
mForceSetRasterState = true; mForceSetRasterState = true;
} }
mCurStencilSize = stencilSize;
for (unsigned int rtIndex = 0; rtIndex < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; rtIndex++) for (unsigned int rtIndex = 0; rtIndex < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; rtIndex++)
{ {
mAppliedRenderTargetSerials[rtIndex] = renderTargetSerials[rtIndex]; mAppliedRenderTargetSerials[rtIndex] = renderTargetSerials[rtIndex];
......
...@@ -247,8 +247,6 @@ class Renderer11 : public Renderer ...@@ -247,8 +247,6 @@ class Renderer11 : public Renderer
bool mDepthStencilInitialized; bool mDepthStencilInitialized;
bool mRenderTargetDescInitialized; bool mRenderTargetDescInitialized;
rx::RenderTarget::Desc mRenderTargetDesc; rx::RenderTarget::Desc mRenderTargetDesc;
unsigned int mCurDepthSize;
unsigned int mCurStencilSize;
// Currently applied sampler states // Currently applied sampler states
bool mForceSetVertexSamplerStates[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS]; bool mForceSetVertexSamplerStates[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment