Commit 7865b70c by Jamie Madill

Fix D3D11 Hazard warnings in Debug.

BUG=angle:756 BUG=417424 Change-Id: I827f1db6bb0a3ba33f116e4cfbf8556da0e884d1 Reviewed-on: https://chromium-review.googlesource.com/221220Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org>
parent de1e00e1
...@@ -59,6 +59,9 @@ ...@@ -59,6 +59,9 @@
namespace rx namespace rx
{ {
namespace
{
static const DXGI_FORMAT RenderTargetFormats[] = static const DXGI_FORMAT RenderTargetFormats[] =
{ {
DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM,
...@@ -77,6 +80,34 @@ enum ...@@ -77,6 +80,34 @@ enum
MAX_TEXTURE_IMAGE_UNITS_VTF_SM4 = 16 MAX_TEXTURE_IMAGE_UNITS_VTF_SM4 = 16
}; };
// Does *not* increment the resource ref count!!
ID3D11Resource *GetSRVResource(ID3D11ShaderResourceView *srv)
{
ID3D11Resource *resource = NULL;
ASSERT(srv);
srv->GetResource(&resource);
resource->Release();
return resource;
}
bool UnsetSRVsWithResource(std::vector<ID3D11ShaderResourceView *> &srvs, const ID3D11Resource *resource)
{
bool foundAny = false;
for (auto &srv : srvs)
{
if (srv && GetSRVResource(srv) == resource)
{
srv = NULL;
foundAny = true;
}
}
return foundAny;
}
}
Renderer11::Renderer11(egl::Display *display, EGLNativeDisplayType hDc, EGLint requestedDisplay) Renderer11::Renderer11(egl::Display *display, EGLNativeDisplayType hDc, EGLint requestedDisplay)
: Renderer(display), : Renderer(display),
mDc(hDc), mDc(hDc),
...@@ -869,8 +900,21 @@ gl::Error Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer) ...@@ -869,8 +900,21 @@ gl::Error Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer)
missingColorRenderTarget = false; missingColorRenderTarget = false;
} }
// TODO: Detect if this color buffer is already bound as a texture and unbind it first to prevent #if !defined(NDEBUG)
// Detect if this color buffer is already bound as a texture and unbind it first to prevent
// D3D11 warnings. // D3D11 warnings.
ID3D11Resource *renderTargetResource = renderTarget->getTexture();
if (UnsetSRVsWithResource(mCurVertexSRVs, renderTargetResource))
{
mDeviceContext->VSSetShaderResources(0, static_cast<UINT>(mCurVertexSRVs.size()), mCurVertexSRVs.data());
}
if (UnsetSRVsWithResource(mCurPixelSRVs, renderTargetResource))
{
mDeviceContext->PSSetShaderResources(0, static_cast<UINT>(mCurPixelSRVs.size()), mCurPixelSRVs.data());
}
#endif
} }
} }
......
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