From aea8e947d3f07df76086009293be59570354a174 Mon Sep 17 00:00:00 2001 From: Nicolas Capens Date: Fri, 9 May 2014 19:14:08 -0400 Subject: [PATCH] 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/199200 Tested-by: Nicolas Capens Reviewed-by: Jamie Madill Reviewed-by: Shannon Woods --- src/libGLESv2/renderer/d3d11/RenderStateCache.cpp | 10 ++++------ src/libGLESv2/renderer/d3d11/RenderStateCache.h | 6 ++---- src/libGLESv2/renderer/d3d11/Renderer11.cpp | 14 ++------------ src/libGLESv2/renderer/d3d11/Renderer11.h | 2 -- 4 files changed, 8 insertions(+), 24 deletions(-) diff --git a/src/libGLESv2/renderer/d3d11/RenderStateCache.cpp b/src/libGLESv2/renderer/d3d11/RenderStateCache.cpp index a59f0802a..d0bfd6c8b 100644 --- a/src/libGLESv2/renderer/d3d11/RenderStateCache.cpp +++ b/src/libGLESv2/renderer/d3d11/RenderStateCache.cpp @@ -1,6 +1,6 @@ #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 // found in the LICENSE file. // @@ -196,8 +196,7 @@ bool RenderStateCache::compareRasterizerStates(const RasterizerStateKey &a, cons return memcmp(&a, &b, sizeof(RasterizerStateKey)) == 0; } -ID3D11RasterizerState *RenderStateCache::getRasterizerState(const gl::RasterizerState &rasterState, - bool scissorEnabled, unsigned int depthSize) +ID3D11RasterizerState *RenderStateCache::getRasterizerState(const gl::RasterizerState &rasterState, bool scissorEnabled) { if (!mDevice) { @@ -208,7 +207,6 @@ ID3D11RasterizerState *RenderStateCache::getRasterizerState(const gl::Rasterizer RasterizerStateKey key = { 0 }; key.rasterizerState = rasterState; key.scissorEnabled = scissorEnabled; - key.depthSize = depthSize; RasterizerStateMap::iterator keyIter = mRasterizerStateCache.find(key); if (keyIter != mRasterizerStateCache.end()) @@ -257,12 +255,12 @@ ID3D11RasterizerState *RenderStateCache::getRasterizerState(const gl::Rasterizer if (rasterState.polygonOffsetFill) { rasterDesc.SlopeScaledDepthBias = rasterState.polygonOffsetFactor; - rasterDesc.DepthBias = ldexp(rasterState.polygonOffsetUnits, -static_cast(depthSize)); + rasterDesc.DepthBias = (INT)rasterState.polygonOffsetUnits; } else { rasterDesc.SlopeScaledDepthBias = 0.0f; - rasterDesc.DepthBias = 0.0f; + rasterDesc.DepthBias = 0; } ID3D11RasterizerState *dx11RasterizerState = NULL; diff --git a/src/libGLESv2/renderer/d3d11/RenderStateCache.h b/src/libGLESv2/renderer/d3d11/RenderStateCache.h index 660fe7af7..7f3349627 100644 --- a/src/libGLESv2/renderer/d3d11/RenderStateCache.h +++ b/src/libGLESv2/renderer/d3d11/RenderStateCache.h @@ -1,5 +1,5 @@ // -// 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 // found in the LICENSE file. // @@ -31,8 +31,7 @@ class RenderStateCache void clear(); ID3D11BlendState *getBlendState(const gl::Framebuffer *framebuffer, const gl::BlendState &blendState); - ID3D11RasterizerState *getRasterizerState(const gl::RasterizerState &rasterState, - bool scissorEnabled, unsigned int depthSize); + ID3D11RasterizerState *getRasterizerState(const gl::RasterizerState &rasterState, bool scissorEnabled); ID3D11DepthStencilState *getDepthStencilState(const gl::DepthStencilState &dsState); ID3D11SamplerState *getSamplerState(const gl::SamplerState &samplerState); @@ -62,7 +61,6 @@ class RenderStateCache { gl::RasterizerState rasterizerState; bool scissorEnabled; - unsigned int depthSize; }; static std::size_t hashRasterizerState(const RasterizerStateKey &rasterState); static bool compareRasterizerStates(const RasterizerStateKey &a, const RasterizerStateKey &b); diff --git a/src/libGLESv2/renderer/d3d11/Renderer11.cpp b/src/libGLESv2/renderer/d3d11/Renderer11.cpp index 8d7791994..224de3592 100644 --- a/src/libGLESv2/renderer/d3d11/Renderer11.cpp +++ b/src/libGLESv2/renderer/d3d11/Renderer11.cpp @@ -739,8 +739,7 @@ void Renderer11::setRasterizerState(const gl::RasterizerState &rasterState) { if (mForceSetRasterState || memcmp(&rasterState, &mCurRasterState, sizeof(gl::RasterizerState)) != 0) { - ID3D11RasterizerState *dxRasterState = mStateCache.getRasterizerState(rasterState, mScissorEnabled, - mCurDepthSize); + ID3D11RasterizerState *dxRasterState = mStateCache.getRasterizerState(rasterState, mScissorEnabled); if (!dxRasterState) { ERR("NULL rasterizer state returned by RenderStateCache::getRasterizerState, setting the default" @@ -1055,9 +1054,6 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer) stencilbufferSerial = depthStencil->getSerial(); } - // Extract the depth stencil sizes and view - unsigned int depthSize = 0; - unsigned int stencilSize = 0; ID3D11DepthStencilView* framebufferDSV = NULL; if (depthStencil) { @@ -1085,9 +1081,6 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer) renderTargetHeight = depthStencil->getHeight(); renderTargetFormat = depthStencil->getActualFormat(); } - - depthSize = depthStencil->getDepthSize(); - stencilSize = depthStencil->getStencilSize(); } // Apply the render target and depth stencil @@ -1105,14 +1098,11 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer) mForceSetScissor = true; mForceSetBlendState = true; - if (!mDepthStencilInitialized || depthSize != mCurDepthSize) + if (!mDepthStencilInitialized) { - mCurDepthSize = depthSize; mForceSetRasterState = true; } - mCurStencilSize = stencilSize; - for (unsigned int rtIndex = 0; rtIndex < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; rtIndex++) { mAppliedRenderTargetSerials[rtIndex] = renderTargetSerials[rtIndex]; diff --git a/src/libGLESv2/renderer/d3d11/Renderer11.h b/src/libGLESv2/renderer/d3d11/Renderer11.h index 4cfcc6d5b..3e6a54a2a 100644 --- a/src/libGLESv2/renderer/d3d11/Renderer11.h +++ b/src/libGLESv2/renderer/d3d11/Renderer11.h @@ -310,8 +310,6 @@ class Renderer11 : public Renderer bool mDepthStencilInitialized; bool mRenderTargetDescInitialized; rx::RenderTarget::Desc mRenderTargetDesc; - unsigned int mCurDepthSize; - unsigned int mCurStencilSize; // Currently applied sampler states bool mForceSetVertexSamplerStates[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];