Hash :
1aa728e3
Author :
Date :
2017-01-30T15:09:40
D3D11: Faster multisample depth resolve. We can use a faster path to write out depth values. Previous attempts were foiled by a D3D quirk: we need to clear a new DSV before we write to it the first time. Multisampled stencil resolve still requires a CPU readback. BUG=angleproject:1710 Change-Id: I7a7d2f929644f61854d51dd096a8aa599ad648bd Reviewed-on: https://chromium-review.googlesource.com/435571 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
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_ResolveDepth(in float4 position : SV_Position,
in float2 texCoord : TEXCOORD0,
out float depth : SV_Depth)
{
// 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,
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);
}