зеркало из https://github.com/AvaloniaUI/angle.git
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:
Родитель
5075e13bd2
Коммит
aea8e947d3
|
@ -1,6 +1,6 @@
|
||||||
#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.
|
||||||
//
|
//
|
||||||
|
@ -196,8 +196,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)
|
||||||
{
|
{
|
||||||
|
@ -208,7 +207,6 @@ ID3D11RasterizerState *RenderStateCache::getRasterizerState(const gl::Rasterizer
|
||||||
RasterizerStateKey key = { 0 };
|
RasterizerStateKey key = { 0 };
|
||||||
key.rasterizerState = rasterState;
|
key.rasterizerState = rasterState;
|
||||||
key.scissorEnabled = scissorEnabled;
|
key.scissorEnabled = scissorEnabled;
|
||||||
key.depthSize = depthSize;
|
|
||||||
|
|
||||||
RasterizerStateMap::iterator keyIter = mRasterizerStateCache.find(key);
|
RasterizerStateMap::iterator keyIter = mRasterizerStateCache.find(key);
|
||||||
if (keyIter != mRasterizerStateCache.end())
|
if (keyIter != mRasterizerStateCache.end())
|
||||||
|
@ -257,12 +255,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;
|
||||||
|
|
|
@ -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
|
// 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.
|
||||||
//
|
//
|
||||||
|
@ -31,8 +31,7 @@ class RenderStateCache
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
ID3D11BlendState *getBlendState(const gl::Framebuffer *framebuffer, const gl::BlendState &blendState);
|
ID3D11BlendState *getBlendState(const 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);
|
||||||
|
|
||||||
|
@ -62,7 +61,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);
|
||||||
|
|
|
@ -739,8 +739,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"
|
||||||
|
@ -1055,9 +1054,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)
|
||||||
{
|
{
|
||||||
|
@ -1085,9 +1081,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
|
||||||
|
@ -1105,14 +1098,11 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer)
|
||||||
mForceSetScissor = true;
|
mForceSetScissor = true;
|
||||||
mForceSetBlendState = true;
|
mForceSetBlendState = 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];
|
||||||
|
|
|
@ -310,8 +310,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];
|
||||||
|
|
Загрузка…
Ссылка в новой задаче