Force stencil swizzled output to only output green

* On some GPUs the stencil output comes in all channels, not just green, and
  it's unclear if this is legal or not. To be safe just mask out the green we
  expect.
This commit is contained in:
baldurk
2020-01-08 19:10:51 +00:00
parent 365d2e9075
commit a05622b37e
2 changed files with 11 additions and 2 deletions
+1 -1
View File
@@ -300,7 +300,7 @@ int4 main(float4 pos : SV_Position, uint samp : SV_SampleIndex) : SV_Target0
src.replace(src.find("&params"), 7, "0");
if(isStencilOut)
src.replace(src.find("&swizzle"), 8, "zyzz");
src.replace(src.find("&swizzle"), 8, "zyzz*float4(0,1,0,0)");
else
src.replace(src.find("&swizzle"), 8, "xyzw");
+10 -1
View File
@@ -35,7 +35,7 @@ RD_TEST(D3D12_Texture_Zoo, D3D12GraphicsTest)
float4 main() : SV_Target0
{
return intex.Load(&params);
return intex.Load(&params).&swizzle;
}
)EOSHADER";
@@ -270,9 +270,13 @@ int4 main(float4 pos : SV_Position, uint samp : SV_SampleIndex) : SV_Target0
{
static std::map<uint32_t, ID3D12PipelineStatePtr> PSOs;
bool isStencilOut = (test.fmt.viewFmt == DXGI_FORMAT_X32_TYPELESS_G8X24_UINT ||
test.fmt.viewFmt == DXGI_FORMAT_X24_TYPELESS_G8_UINT);
uint32_t key = uint32_t(test.fmt.cfg.data);
key |= test.dim << 6;
key |= test.isMSAA ? 0x80000 : 0;
key |= isStencilOut ? 0x100000 : 0;
ID3D12PipelineStatePtr ret = PSOs[key];
if(!ret)
@@ -298,6 +302,11 @@ int4 main(float4 pos : SV_Position, uint samp : SV_SampleIndex) : SV_Target0
else
src.replace(src.find("&params"), 7, "0");
if(isStencilOut)
src.replace(src.find("&swizzle"), 8, "zyzz*float4(0,1,0,0)");
else
src.replace(src.find("&swizzle"), 8, "xyzw");
ID3DBlobPtr psblob = Compile(src, "main", "ps_5_0");
ret = PSOs[key] =
MakePSO().RootSig(sig).VS(vsblob).PS(psblob).RTVs({DXGI_FORMAT_R32G32B32A32_FLOAT});