Commit 196ca36c by Jamie Madill Committed by Commit Bot

D3D11: Implement multisample depth resolve.

This uses a pretty slow path with readback to the CPU. It should be possible to use SV_Depth in HLSL to resolve without a readback, but that will be left for a future optimization. Enables the WebGL 2 tests gles3/fbomultisample and fboinvalidate/sub. BUG=angleproject:1246 Change-Id: Id67178b0f6374cf53e4e107428637546ecca4124 Reviewed-on: https://chromium-review.googlesource.com/359956Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent d9fe55fe
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include "libANGLE/renderer/d3d/d3d11/shaders/compiled/passthroughlum3d11ps.h" #include "libANGLE/renderer/d3d/d3d11/shaders/compiled/passthroughlum3d11ps.h"
#include "libANGLE/renderer/d3d/d3d11/shaders/compiled/passthroughlumalpha3d11ps.h" #include "libANGLE/renderer/d3d/d3d11/shaders/compiled/passthroughlumalpha3d11ps.h"
#include "libANGLE/renderer/d3d/d3d11/shaders/compiled/resolvedepth11_ps.h"
#include "libANGLE/renderer/d3d/d3d11/shaders/compiled/resolvedepthstencil11_ps.h" #include "libANGLE/renderer/d3d/d3d11/shaders/compiled/resolvedepthstencil11_ps.h"
#include "libANGLE/renderer/d3d/d3d11/shaders/compiled/resolvedepthstencil11_vs.h" #include "libANGLE/renderer/d3d/d3d11/shaders/compiled/resolvedepthstencil11_vs.h"
#include "libANGLE/renderer/d3d/d3d11/shaders/compiled/resolvestencil11_ps.h" #include "libANGLE/renderer/d3d/d3d11/shaders/compiled/resolvestencil11_ps.h"
...@@ -258,8 +259,8 @@ void CopyDepthStencil(const gl::Box &sourceArea, ...@@ -258,8 +259,8 @@ void CopyDepthStencil(const gl::Box &sourceArea,
{ {
for (int column = 0; column < destArea.width; ++column) for (int column = 0; column < destArea.width; ++column)
{ {
const float *sourcePixel = reinterpret_cast<const float *>( ptrdiff_t offset = row * sourceRowPitch + column * srcPixelStride;
sourceData + row * sourceRowPitch + column * srcPixelStride); const float *sourcePixel = reinterpret_cast<const float *>(sourceData + offset);
uint8_t *destPixel = destData + row * destRowPitch + column * destPixelStride; uint8_t *destPixel = destData + row * destRowPitch + column * destPixelStride;
...@@ -483,6 +484,7 @@ Blit11::Blit11(Renderer11 *renderer) ...@@ -483,6 +484,7 @@ Blit11::Blit11(Renderer11 *renderer)
mResolveDepthStencilVS(g_VS_ResolveDepthStencil, mResolveDepthStencilVS(g_VS_ResolveDepthStencil,
ArraySize(g_VS_ResolveDepthStencil), ArraySize(g_VS_ResolveDepthStencil),
"Blit11::mResolveDepthStencilVS"), "Blit11::mResolveDepthStencilVS"),
mResolveDepthPS(g_PS_ResolveDepth, ArraySize(g_PS_ResolveDepth), "Blit11::mResolveDepthPS"),
mResolveDepthStencilPS(g_PS_ResolveDepthStencil, mResolveDepthStencilPS(g_PS_ResolveDepthStencil,
ArraySize(g_PS_ResolveDepthStencil), ArraySize(g_PS_ResolveDepthStencil),
"Blit11::mResolveDepthStencilPS"), "Blit11::mResolveDepthStencilPS"),
...@@ -1829,62 +1831,131 @@ gl::Error Blit11::getSwizzleShader(GLenum type, ...@@ -1829,62 +1831,131 @@ gl::Error Blit11::getSwizzleShader(GLenum type,
gl::ErrorOrResult<TextureHelper11> Blit11::resolveDepth(RenderTarget11 *depth) gl::ErrorOrResult<TextureHelper11> Blit11::resolveDepth(RenderTarget11 *depth)
{ {
// TODO(jmadill) const auto &extents = depth->getExtents();
return gl::Error(GL_INVALID_OPERATION, "Multisample depth stencil not implemented yet"); ID3D11Device *device = mRenderer->getDevice();
ID3D11DeviceContext *context = mRenderer->getDeviceContext();
ANGLE_TRY(initResolveDepthStencil(extents));
// Notify the Renderer that all state should be invalidated.
mRenderer->markAllStateDirty();
// Apply the necessary state changes to the D3D11 immediate device context.
context->IASetInputLayout(nullptr);
context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
context->VSSetShader(mResolveDepthStencilVS.resolve(device), nullptr, 0);
context->GSSetShader(nullptr, nullptr, 0);
context->RSSetState(nullptr);
context->OMSetDepthStencilState(nullptr, 0xFFFFFFFF);
context->OMSetRenderTargets(1, &mResolvedDepthStencilRTView, nullptr);
context->OMSetBlendState(nullptr, nullptr, 0xFFFFFFF);
ID3D11ShaderResourceView *pixelViews[] = {depth->getShaderResourceView()};
context->PSSetShaderResources(0, 1, pixelViews);
context->PSSetShader(mResolveDepthPS.resolve(device), nullptr, 0);
// Trigger the blit on the GPU.
context->Draw(6, 0);
gl::Box copyBox(0, 0, 0, extents.width, extents.height, 1);
auto copyFunction = GetCopyDepthStencilFunction(depth->getInternalFormat());
auto dsFormatSet = d3d11::GetANGLEFormatSet(depth->getANGLEFormat());
auto dsDxgiInfo = d3d11::GetDXGIFormatSizeInfo(dsFormatSet.texFormat);
ID3D11Texture2D *destTex = nullptr;
D3D11_TEXTURE2D_DESC destDesc;
destDesc.Width = extents.width;
destDesc.Height = extents.height;
destDesc.MipLevels = 1;
destDesc.ArraySize = 1;
destDesc.Format = dsFormatSet.texFormat;
destDesc.SampleDesc.Count = 1;
destDesc.SampleDesc.Quality = 0;
destDesc.Usage = D3D11_USAGE_DEFAULT;
destDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
destDesc.CPUAccessFlags = 0;
destDesc.MiscFlags = 0;
HRESULT hr = device->CreateTexture2D(&destDesc, nullptr, &destTex);
if (FAILED(hr))
{
return gl::Error(GL_OUT_OF_MEMORY, "Error creating depth resolve dest texture.");
}
d3d11::SetDebugName(destTex, "resolveDepthDest");
TextureHelper11 dest = TextureHelper11::MakeAndPossess2D(destTex, depth->getANGLEFormat());
ANGLE_TRY(copyAndConvert(mResolvedDepthStencil, 0, copyBox, extents, dest, 0, copyBox, extents,
nullptr, 0, 0, 0, 8, dsDxgiInfo.pixelBytes, copyFunction));
return dest;
} }
gl::ErrorOrResult<TextureHelper11> Blit11::resolveStencil(RenderTarget11 *depthStencil, gl::Error Blit11::initResolveDepthStencil(const gl::Extents &extents)
bool alsoDepth)
{ {
ID3D11Device *device = mRenderer->getDevice(); // Check if we need to recreate depth stencil view
ID3D11DeviceContext *context = mRenderer->getDeviceContext(); if (mResolvedDepthStencil.valid() && extents == mResolvedDepthStencil.getExtents())
{
return gl::NoError();
}
if (mResolvedDepthStencil.valid())
{
releaseResolveDepthStencilResources();
}
auto resolvedFormat = d3d11::ANGLE_FORMAT_R32G32_FLOAT; auto resolvedFormat = d3d11::ANGLE_FORMAT_R32G32_FLOAT;
auto formatSet = d3d11::GetANGLEFormatSet(resolvedFormat); auto formatSet = d3d11::GetANGLEFormatSet(resolvedFormat);
auto extents = depthStencil->getExtents();
// Check if we need to recreate depth stencil view D3D11_TEXTURE2D_DESC textureDesc;
if (mResolvedDepthStencil.valid() && extents != mResolvedDepthStencil.getExtents()) textureDesc.Width = extents.width;
textureDesc.Height = extents.height;
textureDesc.MipLevels = 1;
textureDesc.ArraySize = 1;
textureDesc.Format = formatSet.texFormat;
textureDesc.SampleDesc.Count = 1;
textureDesc.SampleDesc.Quality = 0;
textureDesc.Usage = D3D11_USAGE_DEFAULT;
textureDesc.BindFlags = D3D11_BIND_RENDER_TARGET;
textureDesc.CPUAccessFlags = 0;
textureDesc.MiscFlags = 0;
ID3D11Device *device = mRenderer->getDevice();
ID3D11Texture2D *resolvedDepthStencil = nullptr;
HRESULT hr = device->CreateTexture2D(&textureDesc, nullptr, &resolvedDepthStencil);
if (FAILED(hr))
{ {
releaseResolveDepthStencilResources(); return gl::Error(GL_OUT_OF_MEMORY, "Failed to allocate resolved depth stencil texture");
} }
d3d11::SetDebugName(resolvedDepthStencil, "Blit11::mResolvedDepthStencil");
if (!mResolvedDepthStencil.valid()) ASSERT(mResolvedDepthStencilRTView == nullptr);
hr =
device->CreateRenderTargetView(resolvedDepthStencil, nullptr, &mResolvedDepthStencilRTView);
if (FAILED(hr))
{ {
D3D11_TEXTURE2D_DESC textureDesc; return gl::Error(GL_OUT_OF_MEMORY,
textureDesc.Width = extents.width; "Failed to allocate Blit11::mResolvedDepthStencilRTView");
textureDesc.Height = extents.height; }
textureDesc.MipLevels = 1; d3d11::SetDebugName(mResolvedDepthStencilRTView, "Blit11::mResolvedDepthStencilRTView");
textureDesc.ArraySize = 1;
textureDesc.Format = formatSet.texFormat;
textureDesc.SampleDesc.Count = 1;
textureDesc.SampleDesc.Quality = 0;
textureDesc.Usage = D3D11_USAGE_DEFAULT;
textureDesc.BindFlags = D3D11_BIND_RENDER_TARGET;
textureDesc.CPUAccessFlags = 0;
textureDesc.MiscFlags = 0;
ID3D11Texture2D *resolvedDepthStencil = nullptr;
HRESULT hr = device->CreateTexture2D(&textureDesc, nullptr, &resolvedDepthStencil);
if (FAILED(hr))
{
return gl::Error(GL_OUT_OF_MEMORY, "Failed to allocate resolved depth stencil texture");
}
d3d11::SetDebugName(resolvedDepthStencil, "Blit11::mResolvedDepthStencil");
ASSERT(mResolvedDepthStencilRTView == nullptr); mResolvedDepthStencil = TextureHelper11::MakeAndPossess2D(resolvedDepthStencil, resolvedFormat);
hr = device->CreateRenderTargetView(resolvedDepthStencil, nullptr,
&mResolvedDepthStencilRTView);
if (FAILED(hr))
{
return gl::Error(GL_OUT_OF_MEMORY,
"Failed to allocate Blit11::mResolvedDepthStencilRTView");
}
d3d11::SetDebugName(mResolvedDepthStencilRTView, "Blit11::mResolvedDepthStencilRTView");
mResolvedDepthStencil = return gl::NoError();
TextureHelper11::MakeAndPossess2D(resolvedDepthStencil, resolvedFormat); }
}
gl::ErrorOrResult<TextureHelper11> Blit11::resolveStencil(RenderTarget11 *depthStencil,
bool alsoDepth)
{
const auto &extents = depthStencil->getExtents();
ANGLE_TRY(initResolveDepthStencil(extents));
ID3D11Device *device = mRenderer->getDevice();
ID3D11DeviceContext *context = mRenderer->getDeviceContext();
ID3D11Resource *stencilResource = depthStencil->getTexture(); ID3D11Resource *stencilResource = depthStencil->getTexture();
......
...@@ -242,6 +242,7 @@ class Blit11 : angle::NonCopyable ...@@ -242,6 +242,7 @@ class Blit11 : angle::NonCopyable
void clearShaderMap(); void clearShaderMap();
void releaseResolveDepthStencilResources(); void releaseResolveDepthStencilResources();
gl::Error initResolveDepthStencil(const gl::Extents &extents);
Renderer11 *mRenderer; Renderer11 *mRenderer;
...@@ -269,6 +270,7 @@ class Blit11 : angle::NonCopyable ...@@ -269,6 +270,7 @@ class Blit11 : angle::NonCopyable
ID3D11Buffer *mSwizzleCB; ID3D11Buffer *mSwizzleCB;
d3d11::LazyShader<ID3D11VertexShader> mResolveDepthStencilVS; d3d11::LazyShader<ID3D11VertexShader> mResolveDepthStencilVS;
d3d11::LazyShader<ID3D11PixelShader> mResolveDepthPS;
d3d11::LazyShader<ID3D11PixelShader> mResolveDepthStencilPS; d3d11::LazyShader<ID3D11PixelShader> mResolveDepthStencilPS;
d3d11::LazyShader<ID3D11PixelShader> mResolveStencilPS; d3d11::LazyShader<ID3D11PixelShader> mResolveStencilPS;
ID3D11ShaderResourceView *mStencilSRV; ID3D11ShaderResourceView *mStencilSRV;
......
...@@ -20,6 +20,17 @@ void VS_ResolveDepthStencil(in uint id : SV_VertexID, ...@@ -20,6 +20,17 @@ void VS_ResolveDepthStencil(in uint id : SV_VertexID,
Texture2DMS<float> Depth : register(t0); Texture2DMS<float> Depth : register(t0);
Texture2DMS<uint2> Stencil : register(t1); Texture2DMS<uint2> Stencil : register(t1);
void PS_ResolveDepth(in float4 position : SV_Position,
in float2 texCoord : TEXCOORD0,
out float depth : SV_Target0)
{
// MS samplers must use Load
uint width, height, samples;
Depth.GetDimensions(width, height, samples);
uint2 coord = uint2(texCoord.x * float(width), texCoord.y * float(height));
depth = Depth.Load(coord, 0).r;
}
void PS_ResolveDepthStencil(in float4 position : SV_Position, void PS_ResolveDepthStencil(in float4 position : SV_Position,
in float2 texCoord : TEXCOORD0, in float2 texCoord : TEXCOORD0,
out float2 depthStencil : SV_Target0) out float2 depthStencil : SV_Target0)
......
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// Depth texture float 2dMS 0 1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position 0 xyzw 0 POS float
// TEXCOORD 0 xy 1 NONE float xy
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target 0 x 0 TARGET float x
//
ps_4_1
dcl_globalFlags refactoringAllowed
dcl_resource_texture2dms(0) (float,float,float,float) t0
dcl_input_ps linear v1.xy
dcl_output o0.x
dcl_temps 1
resinfo_uint r0.xy, l(0), t0.xyzw
utof r0.xy, r0.xyxx
mul r0.xy, r0.xyxx, v1.xyxx
ftou r0.xy, r0.xyxx
mov r0.zw, l(0,0,0,0)
ldms r0.x, r0.xyzw, t0.xyzw, l(0)
mov o0.x, r0.x
ret
// Approximately 8 instruction slots used
#endif
const BYTE g_PS_ResolveDepth[] = {
68, 88, 66, 67, 205, 219, 191, 201, 103, 134, 243, 76, 11, 91, 23, 182, 42, 8, 17,
173, 1, 0, 0, 0, 184, 2, 0, 0, 5, 0, 0, 0, 52, 0, 0, 0, 176, 0,
0, 0, 8, 1, 0, 0, 60, 1, 0, 0, 60, 2, 0, 0, 82, 68, 69, 70, 116,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0,
1, 4, 255, 255, 0, 1, 0, 0, 66, 0, 0, 0, 60, 0, 0, 0, 2, 0, 0,
0, 5, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 1, 0, 0, 0, 68, 101, 112, 116, 104, 0, 77, 105, 99, 114, 111, 115, 111,
102, 116, 32, 40, 82, 41, 32, 72, 76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32,
67, 111, 109, 112, 105, 108, 101, 114, 32, 54, 46, 51, 46, 57, 54, 48, 48, 46, 49,
54, 51, 56, 52, 0, 73, 83, 71, 78, 80, 0, 0, 0, 2, 0, 0, 0, 8, 0,
0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 0,
0, 0, 0, 15, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 1, 0, 0, 0, 3, 3, 0, 0, 83, 86, 95, 80, 111, 115, 105,
116, 105, 111, 110, 0, 84, 69, 88, 67, 79, 79, 82, 68, 0, 171, 171, 171, 79, 83,
71, 78, 44, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 1, 14, 0, 0,
83, 86, 95, 84, 97, 114, 103, 101, 116, 0, 171, 171, 83, 72, 68, 82, 248, 0, 0,
0, 65, 0, 0, 0, 62, 0, 0, 0, 106, 8, 0, 1, 88, 32, 0, 4, 0, 112,
16, 0, 0, 0, 0, 0, 85, 85, 0, 0, 98, 16, 0, 3, 50, 16, 16, 0, 1,
0, 0, 0, 101, 0, 0, 3, 18, 32, 16, 0, 0, 0, 0, 0, 104, 0, 0, 2,
1, 0, 0, 0, 61, 16, 0, 7, 50, 0, 16, 0, 0, 0, 0, 0, 1, 64, 0,
0, 0, 0, 0, 0, 70, 126, 16, 0, 0, 0, 0, 0, 86, 0, 0, 5, 50, 0,
16, 0, 0, 0, 0, 0, 70, 0, 16, 0, 0, 0, 0, 0, 56, 0, 0, 7, 50,
0, 16, 0, 0, 0, 0, 0, 70, 0, 16, 0, 0, 0, 0, 0, 70, 16, 16, 0,
1, 0, 0, 0, 28, 0, 0, 5, 50, 0, 16, 0, 0, 0, 0, 0, 70, 0, 16,
0, 0, 0, 0, 0, 54, 0, 0, 8, 194, 0, 16, 0, 0, 0, 0, 0, 2, 64,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46,
0, 0, 9, 18, 0, 16, 0, 0, 0, 0, 0, 70, 14, 16, 0, 0, 0, 0, 0,
70, 126, 16, 0, 0, 0, 0, 0, 1, 64, 0, 0, 0, 0, 0, 0, 54, 0, 0,
5, 18, 32, 16, 0, 0, 0, 0, 0, 10, 0, 16, 0, 0, 0, 0, 0, 62, 0,
0, 1, 83, 84, 65, 84, 116, 0, 0, 0, 8, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
...@@ -88,6 +88,7 @@ call:BuildShader BufferToTexture11.hlsl PS_BufferToTexture_4I ps_4_0 co ...@@ -88,6 +88,7 @@ call:BuildShader BufferToTexture11.hlsl PS_BufferToTexture_4I ps_4_0 co
call:BuildShader BufferToTexture11.hlsl PS_BufferToTexture_4UI ps_4_0 compiled/buffertotexture11_ps_4ui.h %debug% call:BuildShader BufferToTexture11.hlsl PS_BufferToTexture_4UI ps_4_0 compiled/buffertotexture11_ps_4ui.h %debug%
call:BuildShader ResolveDepthStencil.hlsl VS_ResolveDepthStencil vs_4_1 compiled/resolvedepthstencil11_vs.h %debug% call:BuildShader ResolveDepthStencil.hlsl VS_ResolveDepthStencil vs_4_1 compiled/resolvedepthstencil11_vs.h %debug%
call:BuildShader ResolveDepthStencil.hlsl PS_ResolveDepth ps_4_1 compiled/resolvedepth11_ps.h %debug%
call:BuildShader ResolveDepthStencil.hlsl PS_ResolveDepthStencil ps_4_1 compiled/resolvedepthstencil11_ps.h %debug% call:BuildShader ResolveDepthStencil.hlsl PS_ResolveDepthStencil ps_4_1 compiled/resolvedepthstencil11_ps.h %debug%
call:BuildShader ResolveDepthStencil.hlsl PS_ResolveStencil ps_4_1 compiled/resolvestencil11_ps.h %debug% call:BuildShader ResolveDepthStencil.hlsl PS_ResolveStencil ps_4_1 compiled/resolvestencil11_ps.h %debug%
......
...@@ -197,15 +197,6 @@ ...@@ -197,15 +197,6 @@
1097 WIN : dEQP-GLES3.functional.fbo.color.repeated_clear.sample.tex2d.rg16f = FAIL 1097 WIN : dEQP-GLES3.functional.fbo.color.repeated_clear.sample.tex2d.rg16f = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.color.repeated_clear.sample.tex2d.r32f = FAIL 1097 WIN : dEQP-GLES3.functional.fbo.color.repeated_clear.sample.tex2d.r32f = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.color.repeated_clear.sample.tex2d.r16f = FAIL 1097 WIN : dEQP-GLES3.functional.fbo.color.repeated_clear.sample.tex2d.r16f = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.msaa.2_samples.depth_component32f = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.msaa.2_samples.depth_component24 = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.msaa.2_samples.depth_component16 = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.msaa.4_samples.depth_component32f = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.msaa.4_samples.depth_component24 = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.msaa.4_samples.depth_component16 = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.msaa.8_samples.depth_component32f = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.msaa.8_samples.depth_component24 = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.msaa.8_samples.depth_component16 = FAIL
1098 WIN : dEQP-GLES3.functional.uniform_api.random.8 = FAIL 1098 WIN : dEQP-GLES3.functional.uniform_api.random.8 = FAIL
1098 WIN : dEQP-GLES3.functional.uniform_api.random.81 = FAIL 1098 WIN : dEQP-GLES3.functional.uniform_api.random.81 = FAIL
1101 WIN : dEQP-GLES3.functional.polygon_offset.fixed16_render_with_units = FAIL 1101 WIN : dEQP-GLES3.functional.polygon_offset.fixed16_render_with_units = FAIL
......
...@@ -909,6 +909,74 @@ class BlitFramebufferTest : public ANGLETest ...@@ -909,6 +909,74 @@ class BlitFramebufferTest : public ANGLETest
} }
}; };
// Tests resolving a multisample depth buffer.
TEST_P(BlitFramebufferTest, MultisampleDepth)
{
GLRenderbuffer renderbuf;
glBindRenderbuffer(GL_RENDERBUFFER, renderbuf.get());
glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_DEPTH_COMPONENT24, 256, 256);
const std::string &vertex =
"#version 300 es\n"
"in vec2 position;\n"
"void main() {\n"
" gl_Position = vec4(position, 0.0, 0.5);\n"
"}";
const std::string &fragment =
"#version 300 es\n"
"out mediump vec4 red;\n"
"void main() {\n"
" red = vec4(1.0, 0.0, 0.0, 1.0);\n"
" gl_FragDepth = 0.5;\n"
"}";
ANGLE_GL_PROGRAM(drawRed, vertex, fragment);
GLFramebuffer framebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get());
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER,
renderbuf.get());
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
glClearDepthf(0.5f);
glClear(GL_DEPTH_BUFFER_BIT);
GLRenderbuffer destRenderbuf;
glBindRenderbuffer(GL_RENDERBUFFER, destRenderbuf.get());
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, 256, 256);
GLFramebuffer resolved;
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolved.get());
glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER,
destRenderbuf.get());
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer.get());
glBlitFramebuffer(0, 0, 256, 256, 0, 0, 256, 256, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL_FRAMEBUFFER, resolved.get());
GLTexture colorbuf;
glBindTexture(GL_TEXTURE_2D, colorbuf.get());
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 256, 256);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuf.get(), 0);
ASSERT_GL_NO_ERROR();
// Clear to green
glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
// Draw with 0.5f test and the test should pass.
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_EQUAL);
drawQuad(drawRed.get(), "position", 0.5f);
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
ASSERT_GL_NO_ERROR();
}
// Test resolving a multisampled stencil buffer. // Test resolving a multisampled stencil buffer.
TEST_P(BlitFramebufferTest, MultisampleStencil) TEST_P(BlitFramebufferTest, MultisampleStencil)
{ {
......
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