Commit afeeda93 by Shannon Woods

Prevents multisample depthstencil from being bound as an SRV

BUG=381413 Multisample textures can only be bound as both depth stencil views and shader resource views at feature level 10_1 and above. We don't need to bind textures as SRVs if they're multisample depth targets, so we should avoid the SRV flag in that case. Change-Id: I28ca98bdc4a86eb5442b39ea3cf2b42aa9216aab Reviewed-on: https://chromium-review.googlesource.com/202921Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarShannon Woods <shannonwoods@chromium.org>
parent afc21c06
......@@ -307,9 +307,24 @@ RenderTarget11::RenderTarget11(Renderer *renderer, GLsizei width, GLsizei height
desc.Usage = D3D11_USAGE_DEFAULT;
desc.CPUAccessFlags = 0;
desc.MiscFlags = 0;
desc.BindFlags = ((srvFormat != DXGI_FORMAT_UNKNOWN) ? D3D11_BIND_SHADER_RESOURCE : 0) |
((dsvFormat != DXGI_FORMAT_UNKNOWN) ? D3D11_BIND_DEPTH_STENCIL : 0) |
((rtvFormat != DXGI_FORMAT_UNKNOWN) ? D3D11_BIND_RENDER_TARGET : 0);
// If a rendertarget or depthstencil format exists for this texture format,
// we'll flag it to allow binding that way. Shader resource views are a little
// more complicated.
bool bindRTV = false, bindDSV = false, bindSRV = false;
bindRTV = (rtvFormat != DXGI_FORMAT_UNKNOWN);
bindDSV = (dsvFormat != DXGI_FORMAT_UNKNOWN);
if (srvFormat != DXGI_FORMAT_UNKNOWN)
{
// Multisample targets flagged for binding as depth stencil cannot also be
// flagged for binding as SRV, so make certain not to add the SRV flag for
// these targets.
bindSRV = !(dsvFormat != DXGI_FORMAT_UNKNOWN && desc.SampleDesc.Count > 1);
}
desc.BindFlags = (bindRTV ? D3D11_BIND_RENDER_TARGET : 0) |
(bindDSV ? D3D11_BIND_DEPTH_STENCIL : 0) |
(bindSRV ? D3D11_BIND_SHADER_RESOURCE : 0);
ID3D11Device *device = mRenderer->getDevice();
ID3D11Texture2D *texture = NULL;
......@@ -323,7 +338,7 @@ RenderTarget11::RenderTarget11(Renderer *renderer, GLsizei width, GLsizei height
}
ASSERT(SUCCEEDED(result));
if (srvFormat != DXGI_FORMAT_UNKNOWN)
if (bindSRV)
{
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
srvDesc.Format = srvFormat;
......@@ -341,7 +356,7 @@ RenderTarget11::RenderTarget11(Renderer *renderer, GLsizei width, GLsizei height
ASSERT(SUCCEEDED(result));
}
if (dsvFormat != DXGI_FORMAT_UNKNOWN)
if (bindDSV)
{
D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
dsvDesc.Format = dsvFormat;
......@@ -360,7 +375,7 @@ RenderTarget11::RenderTarget11(Renderer *renderer, GLsizei width, GLsizei height
ASSERT(SUCCEEDED(result));
}
if (rtvFormat != DXGI_FORMAT_UNKNOWN)
if (bindRTV)
{
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = rtvFormat;
......
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