Commit caf20889 by Bryan Bernhart (Intel Americas Inc) Committed by Commit Bot

Fix incorrect quality level with depth-stencil buffer and MSAA configs.

Using a depth buffer format requires that the DSV and RTV have equal quality levels; otherwise, the bound render target will discard writes. BUG=angleproject:1917 Change-Id: Ife25b0a8958fa2b31b43a0d877d27e440916a9bf Reviewed-on: https://chromium-review.googlesource.com/560716Reviewed-by: 's avatarBryan Bernhart <bryan.bernhart@intel.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 7ef89a42
......@@ -348,10 +348,22 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe
depthStencilTextureDesc.MipLevels = 1;
depthStencilTextureDesc.ArraySize = 1;
depthStencilTextureDesc.SampleDesc.Count = getD3DSamples();
depthStencilTextureDesc.SampleDesc.Quality = 0;
depthStencilTextureDesc.Usage = D3D11_USAGE_DEFAULT;
depthStencilTextureDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
// If there is a multisampled offscreen color texture, the offscreen depth-stencil texture
// must also have the same quality value.
if (mOffscreenTexture.valid() && getD3DSamples() > 1)
{
D3D11_TEXTURE2D_DESC offscreenTextureDesc = {0};
mOffscreenTexture.getDesc(&offscreenTextureDesc);
depthStencilTextureDesc.SampleDesc.Quality = offscreenTextureDesc.SampleDesc.Quality;
}
else
{
depthStencilTextureDesc.SampleDesc.Quality = 0;
}
if (depthBufferFormatInfo.srvFormat != DXGI_FORMAT_UNKNOWN)
{
depthStencilTextureDesc.BindFlags |= D3D11_BIND_SHADER_RESOURCE;
......
......@@ -520,6 +520,7 @@ TEST_P(D3DTextureTestMS, BindTexture)
EGLSurface pbuffer = createPBuffer(bufferSize, bufferSize, EGL_TEXTURE_RGBA, EGL_TEXTURE_2D, 4,
static_cast<UINT>(D3D11_STANDARD_MULTISAMPLE_PATTERN));
EXPECT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
EXPECT_EQ(pbuffer, nullptr);
}
......@@ -537,6 +538,53 @@ TEST_P(D3DTextureTestMS, CheckSampleMismatch)
EXPECT_EQ(pbuffer, nullptr);
}
// Test creating a pbuffer with a D3D texture and depth stencil bits in the EGL config creates keeps
// its depth stencil buffer
TEST_P(D3DTextureTestMS, DepthStencil)
{
EGLWindow *window = getEGLWindow();
EGLDisplay display = window->getDisplay();
const size_t bufferSize = 32;
EGLSurface pbuffer = createPBuffer(bufferSize, bufferSize, EGL_NO_TEXTURE, EGL_NO_TEXTURE, 4,
static_cast<UINT>(D3D11_STANDARD_MULTISAMPLE_PATTERN));
ASSERT_EGL_SUCCESS();
ASSERT_NE(EGL_NO_SURFACE, pbuffer);
// Apply the Pbuffer and clear it to purple and verify
eglMakeCurrent(display, pbuffer, pbuffer, window->getContext());
ASSERT_EGL_SUCCESS();
glViewport(0, 0, static_cast<GLsizei>(bufferSize), static_cast<GLsizei>(bufferSize));
glClearColor(0.0f, 1.0f, 1.0f, 1.0f);
glClearDepthf(0.5f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
ASSERT_GL_NO_ERROR();
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
glUseProgram(mTextureProgram);
glUniform1i(mTextureUniformLocation, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &GLColor::green);
// Draw a quad that will fail the depth test and verify that the buffer is unchanged
drawQuad(mTextureProgram, "position", 1.0f);
EXPECT_PIXEL_COLOR_EQ(static_cast<GLint>(bufferSize) / 2, static_cast<GLint>(bufferSize) / 2,
GLColor::cyan);
// Draw a quad that will pass the depth test and verify that the buffer is green
drawQuad(mTextureProgram, "position", -1.0f);
EXPECT_PIXEL_COLOR_EQ(static_cast<GLint>(bufferSize) / 2, static_cast<GLint>(bufferSize) / 2,
GLColor::green);
// Make current with fixture EGL to ensure the Surface can be released immediately.
getEGLWindow()->makeCurrent();
eglDestroySurface(display, pbuffer);
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against.
ANGLE_INSTANTIATE_TEST(D3DTextureTest, ES2_D3D9(), ES2_D3D11(), ES2_OPENGL());
......
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