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 <nicolascapens@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
This commit is contained in:
Nicolas Capens 2014-05-09 19:14:08 -04:00
Родитель 5075e13bd2
Коммит aea8e947d3
4 изменённых файлов: 8 добавлений и 24 удалений

Просмотреть файл

@ -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<int>(depthSize));
rasterDesc.DepthBias = (INT)rasterState.polygonOffsetUnits;
}
else
{
rasterDesc.SlopeScaledDepthBias = 0.0f;
rasterDesc.DepthBias = 0.0f;
rasterDesc.DepthBias = 0;
}
ID3D11RasterizerState *dx11RasterizerState = NULL;

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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