Commit 78a9c733 by Jamie Madill Committed by Commit Bot

D3D11: Implement multisampled stencil resolve.

This implements a fairly slow path with readback for stencil blits, and depth/stencil resolve. In a subsequent patch I'll implement the depth blits. BUG=angleproject:1246 Change-Id: I04151d1f49ca404d858172dff8286608eae29864 Reviewed-on: https://chromium-review.googlesource.com/359955Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent e58e1416
......@@ -62,7 +62,7 @@ void SafeRelease(T& resource)
}
template <typename T>
void SafeDelete(T*& resource)
void SafeDelete(T *&resource)
{
delete resource;
resource = NULL;
......
......@@ -17,35 +17,22 @@ namespace rx
{
struct D3DCompilerWorkarounds
{
D3DCompilerWorkarounds()
: skipOptimization(false), useMaxOptimization(false), enableIEEEStrictness(false)
{
}
bool skipOptimization;
bool useMaxOptimization;
bool skipOptimization = false;
bool useMaxOptimization = false;
// IEEE strictness needs to be enabled for NANs to work.
bool enableIEEEStrictness;
bool enableIEEEStrictness = false;
};
struct WorkaroundsD3D
{
WorkaroundsD3D()
: mrtPerfWorkaround(false),
setDataFasterThanImageUpload(false),
zeroMaxLodWorkaround(false),
useInstancedPointSpriteEmulation(false)
{
}
// On some systems, having extra rendertargets than necessary slows down the shader.
// We can fix this by optimizing those out of the shader. At the same time, we can
// work around a bug on some nVidia drivers that they ignore "null" render targets
// in D3D11, by compacting the active color attachments list to omit null entries.
bool mrtPerfWorkaround;
bool mrtPerfWorkaround = false;
bool setDataFasterThanImageUpload;
bool setDataFasterThanImageUpload = false;
// Some renderers can't disable mipmaps on a mipmapped texture (i.e. solely sample from level
// zero, and ignore the other levels). D3D11 Feature Level 10+ does this by setting MaxLOD to
......@@ -54,13 +41,19 @@ struct WorkaroundsD3D
// application creates a mipmapped texture2D, but sets GL_TEXTURE_MIN_FILTER to GL_NEAREST
// (i.e disables mipmaps). To work around this, D3D11 FL9_3 has to create two copies of the
// texture. The textures' level zeros are identical, but only one texture has mips.
bool zeroMaxLodWorkaround;
bool zeroMaxLodWorkaround = false;
// Some renderers do not support Geometry Shaders so the Geometry Shader-based PointSprite
// emulation will not work. To work around this, D3D11 FL9_3 has to use a different pointsprite
// emulation that is implemented using instanced quads.
bool useInstancedPointSpriteEmulation;
bool useInstancedPointSpriteEmulation = false;
// NVIDIA driver versions 347.88 <= x < 368.69 have a bug where using CopySubresourceRegion
// from a staging texture to a depth/stencil texture triggers a timeout/TDR. The workaround
// is to use UpdateSubresource to trigger an extra copy.
bool depthStencilBlitExtraCopy = false;
};
}
} // namespace rx
#endif // LIBANGLE_RENDERER_D3D_WORKAROUNDSD3D_H_
......@@ -70,9 +70,23 @@ class Blit11 : angle::NonCopyable
const gl::Extents &destSize,
const gl::Rectangle *scissor);
gl::ErrorOrResult<TextureHelper11> resolveDepthStencil(RenderTarget11 *dsRenderTarget,
bool resolveDepth,
bool resolveStencil);
gl::ErrorOrResult<TextureHelper11> resolveDepth(RenderTarget11 *depth);
gl::ErrorOrResult<TextureHelper11> resolveStencil(RenderTarget11 *depthStencil, bool alsoDepth);
using BlitConvertFunction = void(const gl::Box &sourceArea,
const gl::Box &destArea,
const gl::Rectangle &clipRect,
const gl::Extents &sourceSize,
unsigned int sourceRowPitch,
unsigned int destRowPitch,
ptrdiff_t readOffset,
ptrdiff_t writeOffset,
size_t copySize,
size_t srcPixelStride,
size_t destPixelStride,
const uint8_t *sourceData,
uint8_t *destData);
private:
enum BlitShaderType
......@@ -168,20 +182,6 @@ class Blit11 : angle::NonCopyable
ShaderDimension dimension);
static SwizzleShaderType GetSwizzleShaderType(GLenum type, D3D11_SRV_DIMENSION dimensionality);
typedef void BlitConvertFunction(const gl::Box &sourceArea,
const gl::Box &destArea,
const gl::Rectangle &clipRect,
const gl::Extents &sourceSize,
unsigned int sourceRowPitch,
unsigned int destRowPitch,
ptrdiff_t readOffset,
ptrdiff_t writeOffset,
size_t copySize,
size_t srcPixelStride,
size_t destPixelStride,
const uint8_t *sourceData,
uint8_t *destData);
gl::Error copyDepthStencilImpl(const TextureHelper11 &source,
unsigned int sourceSubresource,
const gl::Box &sourceArea,
......@@ -193,6 +193,21 @@ class Blit11 : angle::NonCopyable
const gl::Rectangle *scissor,
bool stencilOnly);
gl::Error copyAndConvertImpl(const TextureHelper11 &source,
unsigned int sourceSubresource,
const gl::Box &sourceArea,
const gl::Extents &sourceSize,
const TextureHelper11 &destStaging,
const gl::Box &destArea,
const gl::Extents &destSize,
const gl::Rectangle *scissor,
size_t readOffset,
size_t writeOffset,
size_t copySize,
size_t srcPixelStride,
size_t destPixelStride,
BlitConvertFunction *convertFunction);
gl::Error copyAndConvert(const TextureHelper11 &source,
unsigned int sourceSubresource,
const gl::Box &sourceArea,
......@@ -226,6 +241,7 @@ class Blit11 : angle::NonCopyable
ID3D11PixelShader *ps);
void clearShaderMap();
void releaseResolveDepthStencilResources();
Renderer11 *mRenderer;
......@@ -251,6 +267,13 @@ class Blit11 : angle::NonCopyable
d3d11::LazyBlendState mAlphaMaskBlendState;
ID3D11Buffer *mSwizzleCB;
d3d11::LazyShader<ID3D11VertexShader> mResolveDepthStencilVS;
d3d11::LazyShader<ID3D11PixelShader> mResolveDepthStencilPS;
d3d11::LazyShader<ID3D11PixelShader> mResolveStencilPS;
ID3D11ShaderResourceView *mStencilSRV;
TextureHelper11 mResolvedDepthStencil;
ID3D11RenderTargetView *mResolvedDepthStencilRTView;
};
} // namespace rx
......
......@@ -3084,14 +3084,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
bool bindRTV = false, bindDSV = false, bindSRV = false;
bindRTV = (formatInfo.formatSet->rtvFormat != DXGI_FORMAT_UNKNOWN);
bindDSV = (formatInfo.formatSet->dsvFormat != DXGI_FORMAT_UNKNOWN);
if (formatInfo.formatSet->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 = !(formatInfo.formatSet->dsvFormat != DXGI_FORMAT_UNKNOWN &&
desc.SampleDesc.Count > 1);
}
bindSRV = (formatInfo.formatSet->srvFormat != DXGI_FORMAT_UNKNOWN);
desc.BindFlags = (bindRTV ? D3D11_BIND_RENDER_TARGET : 0) |
(bindDSV ? D3D11_BIND_DEPTH_STENCIL : 0) |
......@@ -3785,20 +3778,24 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRectIn,
auto readRT11 = GetAs<RenderTarget11>(readRenderTarget);
ANGLE_TRY_RESULT(resolveMultisampledTexture(readRT11, depthBlit, stencilBlit), readTexture);
const auto &formatSet = d3d11::GetANGLEFormatSet(readTexture.getANGLEFormat());
if (!stencilBlit)
{
const auto &readFormatSet = d3d11::GetANGLEFormatSet(readTexture.getANGLEFormat());
D3D11_SHADER_RESOURCE_VIEW_DESC srViewDesc;
srViewDesc.Format = formatSet.srvFormat;
srViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
srViewDesc.Texture2D.MipLevels = 1;
srViewDesc.Texture2D.MostDetailedMip = 0;
D3D11_SHADER_RESOURCE_VIEW_DESC viewDesc;
viewDesc.Format = readFormatSet.srvFormat;
viewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
viewDesc.Texture2D.MipLevels = 1;
viewDesc.Texture2D.MostDetailedMip = 0;
HRESULT hresult =
mDevice->CreateShaderResourceView(readTexture.getResource(), &srViewDesc, &readSRV);
if (FAILED(hresult))
{
return gl::Error(GL_OUT_OF_MEMORY,
"Renderer11::blitRenderbufferRect: Failed to create temporary SRV.");
HRESULT hresult =
mDevice->CreateShaderResourceView(readTexture.getResource(), &viewDesc, &readSRV);
if (FAILED(hresult))
{
return gl::Error(
GL_OUT_OF_MEMORY,
"Renderer11::blitRenderbufferRect: Failed to create temporary SRV.");
}
}
}
else
......@@ -3817,10 +3814,8 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRectIn,
readSRV->AddRef();
}
if (!readSRV)
{
return gl::Error(GL_OUT_OF_MEMORY, "Failed to retrieve the internal read render target view from the read render target.");
}
// Stencil blits don't use shaders.
ASSERT(readSRV || stencilBlit);
const gl::Extents readSize(readRenderTarget->getWidth(), readRenderTarget->getHeight(), 1);
const gl::Extents drawSize(drawRenderTarget->getWidth(), drawRenderTarget->getHeight(), 1);
......@@ -3988,6 +3983,7 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRectIn,
}
else if (depthBlit)
{
ASSERT(readSRV);
ANGLE_TRY(mBlit->copyDepth(readSRV, readArea, readSize, drawDSV, drawArea, drawSize,
scissor));
}
......@@ -4001,6 +3997,7 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRectIn,
{
// We don't currently support masking off any other channel than alpha
bool maskOffAlpha = colorMaskingNeeded && colorMask.alpha;
ASSERT(readSRV);
ANGLE_TRY(mBlit->copyTexture(readSRV, readArea, readSize, drawRTV, drawArea, drawSize,
scissor, destFormatInfo.format, filter, maskOffAlpha));
}
......@@ -4059,9 +4056,14 @@ void Renderer11::onBufferDelete(const Buffer11 *deleted)
gl::ErrorOrResult<TextureHelper11>
Renderer11::resolveMultisampledTexture(RenderTarget11 *renderTarget, bool depth, bool stencil)
{
if (depth || stencil)
if (depth && !stencil)
{
return mBlit->resolveDepth(renderTarget);
}
if (stencil)
{
return mBlit->resolveDepthStencil(renderTarget, depth, stencil);
return mBlit->resolveStencil(renderTarget, depth);
}
const auto &formatSet = d3d11::GetANGLEFormatSet(renderTarget->getANGLEFormat());
......@@ -4169,7 +4171,7 @@ void Renderer11::generateCaps(gl::Caps *outCaps, gl::TextureCapsMap *outTextureC
WorkaroundsD3D Renderer11::generateWorkarounds() const
{
return d3d11::GenerateWorkarounds(mRenderer11DeviceCaps.featureLevel);
return d3d11::GenerateWorkarounds(mRenderer11DeviceCaps, mAdapterDescription);
}
gl::Error Renderer11::clearTextures(gl::SamplerType samplerType, size_t rangeStart, size_t rangeEnd)
......
......@@ -1506,13 +1506,20 @@ ID3D11BlendState *LazyBlendState::resolve(ID3D11Device *device)
return mResource;
}
WorkaroundsD3D GenerateWorkarounds(D3D_FEATURE_LEVEL featureLevel)
WorkaroundsD3D GenerateWorkarounds(const Renderer11DeviceCaps &deviceCaps,
const DXGI_ADAPTER_DESC &adapterDesc)
{
bool is9_3 = (deviceCaps.featureLevel <= D3D_FEATURE_LEVEL_9_3);
WorkaroundsD3D workarounds;
workarounds.mrtPerfWorkaround = true;
workarounds.setDataFasterThanImageUpload = true;
workarounds.zeroMaxLodWorkaround = (featureLevel <= D3D_FEATURE_LEVEL_9_3);
workarounds.useInstancedPointSpriteEmulation = (featureLevel <= D3D_FEATURE_LEVEL_9_3);
workarounds.zeroMaxLodWorkaround = is9_3;
workarounds.useInstancedPointSpriteEmulation = is9_3;
// TODO(jmadill): Narrow problematic driver range.
workarounds.depthStencilBlitExtraCopy = (adapterDesc.VendorId == VENDOR_ID_NVIDIA);
return workarounds;
}
......@@ -1654,6 +1661,11 @@ void TextureHelper11::reset()
mTexture3D = nullptr;
}
bool TextureHelper11::valid() const
{
return (mTextureType != GL_NONE);
}
gl::ErrorOrResult<TextureHelper11> CreateStagingTexture(GLenum textureType,
d3d11::ANGLEFormat angleFormat,
const gl::Extents &size,
......
......@@ -346,7 +346,8 @@ void SetBufferData(ID3D11DeviceContext *context, ID3D11Buffer *constantBuffer, c
}
}
WorkaroundsD3D GenerateWorkarounds(D3D_FEATURE_LEVEL featureLevel);
WorkaroundsD3D GenerateWorkarounds(const Renderer11DeviceCaps &deviceCaps,
const DXGI_ADAPTER_DESC &adapterDesc);
enum ReservedConstantBufferSlot
{
......@@ -383,6 +384,7 @@ class TextureHelper11 : angle::NonCopyable
ID3D11Texture2D *getTexture2D() const { return mTexture2D; }
ID3D11Texture3D *getTexture3D() const { return mTexture3D; }
ID3D11Resource *getResource() const;
bool valid() const;
private:
void reset();
......
static const float2 g_Corners[6] =
{
float2(-1.0f, 1.0f),
float2( 1.0f, -1.0f),
float2(-1.0f, -1.0f),
float2(-1.0f, 1.0f),
float2( 1.0f, 1.0f),
float2( 1.0f, -1.0f),
};
void VS_ResolveDepthStencil(in uint id : SV_VertexID,
out float4 position : SV_Position,
out float2 texCoord : TEXCOORD0)
{
float2 corner = g_Corners[id];
position = float4(corner.x, corner.y, 0.0f, 1.0f);
texCoord = float2((corner.x + 1.0f) * 0.5f, (-corner.y + 1.0f) * 0.5f);
}
Texture2DMS<float> Depth : register(t0);
Texture2DMS<uint2> Stencil : register(t1);
void PS_ResolveDepthStencil(in float4 position : SV_Position,
in float2 texCoord : TEXCOORD0,
out float2 depthStencil : 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));
depthStencil.r = Depth.Load(coord, 0).r;
depthStencil.g = float(Stencil.Load(coord, 0).g);
}
void PS_ResolveStencil(in float4 position : SV_Position,
in float2 texCoord : TEXCOORD0,
out float2 stencil : SV_Target0)
{
// MS samplers must use Load
uint width, height, samples;
Stencil.GetDimensions(width, height, samples);
uint2 coord = uint2(texCoord.x * float(width), texCoord.y * float(height));
stencil.r = 0.0f;
stencil.g = float(Stencil.Load(coord, 0).g);
}
#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
// Stencil texture uint2 2dMS 1 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 xy 0 TARGET float xy
//
ps_4_1
dcl_globalFlags refactoringAllowed
dcl_resource_texture2dms(0) (float,float,float,float) t0
dcl_resource_texture2dms(0) (uint,uint,uint,uint) t1
dcl_input_ps linear v1.xy
dcl_output o0.xy
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.z, r0.xyzw, t1.xzyw, l(0)
ldms r0.x, r0.xyww, t0.xyzw, l(0)
mov o0.x, r0.x
utof o0.y, r0.z
ret
// Approximately 10 instruction slots used
#endif
const BYTE g_PS_ResolveDepthStencil[] = {
68, 88, 66, 67, 229, 191, 254, 12, 10, 19, 181, 162, 222, 203, 244, 146, 104, 226, 195,
177, 1, 0, 0, 0, 40, 3, 0, 0, 5, 0, 0, 0, 52, 0, 0, 0, 216, 0,
0, 0, 48, 1, 0, 0, 100, 1, 0, 0, 172, 2, 0, 0, 82, 68, 69, 70, 156,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 28, 0, 0, 0,
1, 4, 255, 255, 0, 1, 0, 0, 106, 0, 0, 0, 92, 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, 98, 0, 0, 0, 2, 0, 0, 0, 4, 0, 0, 0, 6,
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 5, 0, 0, 0,
68, 101, 112, 116, 104, 0, 83, 116, 101, 110, 99, 105, 108, 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, 3, 12,
0, 0, 83, 86, 95, 84, 97, 114, 103, 101, 116, 0, 171, 171, 83, 72, 68, 82, 64,
1, 0, 0, 65, 0, 0, 0, 80, 0, 0, 0, 106, 8, 0, 1, 88, 32, 0, 4,
0, 112, 16, 0, 0, 0, 0, 0, 85, 85, 0, 0, 88, 32, 0, 4, 0, 112, 16,
0, 1, 0, 0, 0, 68, 68, 0, 0, 98, 16, 0, 3, 50, 16, 16, 0, 1, 0,
0, 0, 101, 0, 0, 3, 50, 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, 66, 0, 16, 0, 0, 0, 0, 0, 70, 14, 16, 0, 0, 0, 0, 0, 134,
125, 16, 0, 1, 0, 0, 0, 1, 64, 0, 0, 0, 0, 0, 0, 46, 0, 0, 9,
18, 0, 16, 0, 0, 0, 0, 0, 70, 15, 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, 86, 0, 0, 5, 34,
32, 16, 0, 0, 0, 0, 0, 42, 0, 16, 0, 0, 0, 0, 0, 62, 0, 0, 1,
83, 84, 65, 84, 116, 0, 0, 0, 10, 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, 2, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 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};
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_VertexID 0 x 0 VERTID uint x
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position 0 xyzw 0 POS float xyzw
// TEXCOORD 0 xy 1 NONE float xy
//
vs_4_1
dcl_globalFlags refactoringAllowed
dcl_immediateConstantBuffer { { -1.000000, 1.000000, 0, 0},
{ 1.000000, -1.000000, 0, 0},
{ -1.000000, -1.000000, 0, 0},
{ -1.000000, 1.000000, 0, 0},
{ 1.000000, 1.000000, 0, 0},
{ 1.000000, -1.000000, 0, 0} }
dcl_input_sgv v0.x, vertex_id
dcl_output_siv o0.xyzw, position
dcl_output o1.xy
dcl_temps 1
mov o0.zw, l(0,0,0,1.000000)
mov r0.x, v0.x
mov o0.xy, icb[r0.x + 0].xyxx
add r0.y, l(1.000000), icb[r0.x + 0].x
add r0.x, l(1.000000), -icb[r0.x + 0].y
mul o1.xy, r0.yxyy, l(0.500000, 0.500000, 0.000000, 0.000000)
ret
// Approximately 7 instruction slots used
#endif
const BYTE g_VS_ResolveDepthStencil[] = {
68, 88, 66, 67, 205, 15, 103, 70, 202, 235, 195, 98, 255, 82, 84, 239, 130, 6, 12,
104, 1, 0, 0, 0, 0, 3, 0, 0, 5, 0, 0, 0, 52, 0, 0, 0, 140, 0,
0, 0, 192, 0, 0, 0, 24, 1, 0, 0, 132, 2, 0, 0, 82, 68, 69, 70, 80,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 0, 0, 0,
1, 4, 254, 255, 0, 1, 0, 0, 28, 0, 0, 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, 171, 171, 73, 83, 71, 78, 44, 0, 0, 0, 1, 0, 0, 0,
8, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 1, 1, 0, 0, 83, 86, 95, 86, 101, 114, 116, 101, 120, 73,
68, 0, 79, 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, 12, 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, 83, 72, 68, 82, 100,
1, 0, 0, 65, 0, 1, 0, 89, 0, 0, 0, 106, 8, 0, 1, 53, 24, 0, 0,
26, 0, 0, 0, 0, 0, 128, 191, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 128, 63, 0, 0, 128, 191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
128, 191, 0, 0, 128, 191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 191, 0,
0, 128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 128, 63,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 128, 191, 0, 0, 0,
0, 0, 0, 0, 0, 96, 0, 0, 4, 18, 16, 16, 0, 0, 0, 0, 0, 6, 0,
0, 0, 103, 0, 0, 4, 242, 32, 16, 0, 0, 0, 0, 0, 1, 0, 0, 0, 101,
0, 0, 3, 50, 32, 16, 0, 1, 0, 0, 0, 104, 0, 0, 2, 1, 0, 0, 0,
54, 0, 0, 8, 194, 32, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 63, 54, 0, 0, 5, 18, 0,
16, 0, 0, 0, 0, 0, 10, 16, 16, 0, 0, 0, 0, 0, 54, 0, 0, 6, 50,
32, 16, 0, 0, 0, 0, 0, 70, 144, 144, 0, 10, 0, 16, 0, 0, 0, 0, 0,
0, 0, 0, 8, 34, 0, 16, 0, 0, 0, 0, 0, 1, 64, 0, 0, 0, 0, 128,
63, 10, 144, 144, 0, 10, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 9, 18, 0,
16, 0, 0, 0, 0, 0, 1, 64, 0, 0, 0, 0, 128, 63, 26, 144, 144, 128, 65,
0, 0, 0, 10, 0, 16, 0, 0, 0, 0, 0, 56, 0, 0, 10, 50, 32, 16, 0,
1, 0, 0, 0, 22, 5, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0, 0, 0, 0,
63, 0, 0, 0, 63, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 1, 83, 84,
65, 84, 116, 0, 0, 0, 7, 0, 0, 0, 1, 0, 0, 0, 6, 0, 0, 0, 3,
0, 0, 0, 3, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 3, 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,
0, 0, 0, 0, 0, 0, 0, 0};
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// Stencil texture uint2 2dMS 1 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 xy 0 TARGET float xy
//
ps_4_1
dcl_globalFlags refactoringAllowed
dcl_resource_texture2dms(0) (uint,uint,uint,uint) t1
dcl_input_ps linear v1.xy
dcl_output o0.xy
dcl_temps 1
resinfo_uint r0.xy, l(0), t1.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, t1.yxzw, l(0)
utof o0.y, r0.x
mov o0.x, l(0)
ret
// Approximately 9 instruction slots used
#endif
const BYTE g_PS_ResolveStencil[] = {
68, 88, 66, 67, 122, 29, 34, 146, 254, 203, 175, 97, 151, 254, 255, 190, 91, 40, 55,
118, 1, 0, 0, 0, 208, 2, 0, 0, 5, 0, 0, 0, 52, 0, 0, 0, 180, 0,
0, 0, 12, 1, 0, 0, 64, 1, 0, 0, 84, 2, 0, 0, 82, 68, 69, 70, 120,
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, 68, 0, 0, 0, 60, 0, 0, 0, 2, 0, 0,
0, 4, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0,
0, 0, 5, 0, 0, 0, 83, 116, 101, 110, 99, 105, 108, 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, 171, 171, 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,
3, 12, 0, 0, 83, 86, 95, 84, 97, 114, 103, 101, 116, 0, 171, 171, 83, 72, 68,
82, 12, 1, 0, 0, 65, 0, 0, 0, 67, 0, 0, 0, 106, 8, 0, 1, 88, 32,
0, 4, 0, 112, 16, 0, 1, 0, 0, 0, 68, 68, 0, 0, 98, 16, 0, 3, 50,
16, 16, 0, 1, 0, 0, 0, 101, 0, 0, 3, 50, 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, 1, 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, 22, 126, 16, 0, 1, 0, 0, 0, 1, 64, 0, 0, 0, 0, 0,
0, 86, 0, 0, 5, 34, 32, 16, 0, 0, 0, 0, 0, 10, 0, 16, 0, 0, 0,
0, 0, 54, 0, 0, 5, 18, 32, 16, 0, 0, 0, 0, 0, 1, 64, 0, 0, 0,
0, 0, 0, 62, 0, 0, 1, 83, 84, 65, 84, 116, 0, 0, 0, 9, 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, 3, 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};
......@@ -200,21 +200,12 @@
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.2_samples.depth32f_stencil8 = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.msaa.2_samples.depth24_stencil8 = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.msaa.2_samples.stencil_index8 = 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.4_samples.depth32f_stencil8 = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.msaa.4_samples.depth24_stencil8 = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.msaa.4_samples.stencil_index8 = 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
1097 WIN : dEQP-GLES3.functional.fbo.msaa.8_samples.depth32f_stencil8 = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.msaa.8_samples.depth24_stencil8 = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.msaa.8_samples.stencil_index8 = FAIL
1098 WIN : dEQP-GLES3.functional.uniform_api.random.8 = FAIL
1098 WIN : dEQP-GLES3.functional.uniform_api.random.81 = FAIL
1101 WIN : dEQP-GLES3.functional.polygon_offset.fixed16_render_with_units = FAIL
......
......@@ -6,6 +6,8 @@
#include "test_utils/ANGLETest.h"
#include "test_utils/gl_raii.h"
using namespace angle;
class BlitFramebufferANGLETest : public ANGLETest
......@@ -891,8 +893,96 @@ TEST_P(BlitFramebufferANGLETest, Errors)
// TODO(geofflang): Fix the dependence on glBlitFramebufferANGLE without checks and assuming the
// default framebuffer is BGRA to enable the GL and GLES backends. (http://anglebug.com/1289)
class BlitFramebufferTest : public ANGLETest
{
protected:
BlitFramebufferTest()
{
setWindowWidth(256);
setWindowHeight(256);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
setConfigDepthBits(24);
setConfigStencilBits(8);
}
};
// Test resolving a multisampled stencil buffer.
TEST_P(BlitFramebufferTest, MultisampleStencil)
{
GLRenderbuffer renderbuf;
glBindRenderbuffer(GL_RENDERBUFFER, renderbuf.get());
glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_STENCIL_INDEX8, 256, 256);
const std::string &vertex =
"#version 300 es\n"
"in vec2 position;\n"
"void main() {\n"
" gl_Position = vec4(position, 0.0, 1.0);\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"
"}";
ANGLE_GL_PROGRAM(drawRed, vertex, fragment);
GLFramebuffer framebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get());
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
renderbuf.get());
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
// fill the stencil buffer with 0x1
glStencilFunc(GL_ALWAYS, 0x1, 0xFF);
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
glEnable(GL_STENCIL_TEST);
drawQuad(drawRed.get(), "position", 0.5f);
GLTexture destColorbuf;
glBindTexture(GL_TEXTURE_2D, destColorbuf.get());
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 256, 256);
GLRenderbuffer destRenderbuf;
glBindRenderbuffer(GL_RENDERBUFFER, destRenderbuf.get());
glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, 256, 256);
GLFramebuffer resolved;
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolved.get());
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
destColorbuf.get(), 0);
glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
destRenderbuf.get());
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer.get());
glBlitFramebuffer(0, 0, 256, 256, 0, 0, 256, 256, GL_STENCIL_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL_FRAMEBUFFER, resolved.get());
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 red if the stencil is 0x1, which should be true after the blit/resolve.
glStencilFunc(GL_EQUAL, 0x1, 0xFF);
drawQuad(drawRed.get(), "position", 0.5f);
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
ASSERT_GL_NO_ERROR();
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(BlitFramebufferANGLETest,
ES2_D3D9(),
ES2_D3D11(EGL_EXPERIMENTAL_PRESENT_PATH_COPY_ANGLE),
ES2_D3D11(EGL_EXPERIMENTAL_PRESENT_PATH_FAST_ANGLE));
ANGLE_INSTANTIATE_TEST(BlitFramebufferTest, ES3_D3D11());
\ No newline at end of file
......@@ -6,6 +6,9 @@
// gl_raii:
// Helper methods for containing GL objects like buffers and textures.
#ifndef ANGLE_TESTS_GL_RAII_H_
#define ANGLE_TESTS_GL_RAII_H_
#include <functional>
#include "angle_gl.h"
......@@ -44,4 +47,35 @@ using GLTexture = GLWrapper<glGenTextures, glDeleteTextures>;
using GLFramebuffer = GLWrapper<glGenFramebuffers, glDeleteFramebuffers>;
using GLRenderbuffer = GLWrapper<glGenRenderbuffers, glDeleteRenderbuffers>;
class GLProgram
{
public:
GLProgram(const std::string &vertexShader, const std::string &fragmentShader)
: mHandle(0), mVertexShader(vertexShader), mFragmentShader(fragmentShader)
{
}
~GLProgram() { glDeleteProgram(mHandle); }
GLuint get()
{
if (mHandle == 0)
{
mHandle = CompileProgram(mVertexShader, mFragmentShader);
}
return mHandle;
}
private:
GLuint mHandle;
const std::string mVertexShader;
const std::string mFragmentShader;
};
#define ANGLE_GL_PROGRAM(name, vertex, fragment) \
GLProgram name(vertex, fragment); \
ASSERT_NE(0u, name.get());
} // namespace angle
#endif // ANGLE_TESTS_GL_RAII_H_
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