Fix a crash if SampleBias is used with an unbound sampler on D3D11

This commit is contained in:
baldurk committed 2024-03-20 12:53:17 +00:00
1 parent 323bc7007a
commit 0ea1df4dd3
2 files changed
+27 -3

No files matched your search

+16 -3
View File
@@ -1226,10 +1226,23 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather(
context->PSSetShaderResources(texSlot, 1, &usedSRV);
if(opcode == OPCODE_SAMPLE_B && samplerData.bias != 0.0f)
{
RDCASSERT(usedSamp);
D3D11_SAMPLER_DESC desc = {};
D3D11_SAMPLER_DESC desc;
usedSamp->GetDesc(&desc);
if(usedSamp)
{
usedSamp->GetDesc(&desc);
}
else
{
desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
desc.AddressU = desc.AddressV = desc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
desc.MipLODBias = 0.0f;
desc.MaxAnisotropy = 1;
desc.ComparisonFunc = D3D11_COMPARISON_NEVER;
desc.BorderColor[0] = desc.BorderColor[1] = desc.BorderColor[2] = desc.BorderColor[3] = 1.0f;
desc.MinLOD = -FLT_MAX;
desc.MaxLOD = FLT_MAX;
}
desc.MipLODBias = RDCCLAMP(desc.MipLODBias + samplerData.bias, -15.99f, 15.99f);
@@ -124,6 +124,7 @@ RWTexture2D<float> unbounduav2 : register(u5);
SamplerState linearclamp : register(s0);
SamplerState linearwrap : register(s1);
SamplerState unboundsamp : register(s2);
float4 main(v2f IN) : SV_Target0
{
@@ -740,6 +741,16 @@ float4 main(v2f IN) : SV_Target0
float2 uv = posone * float2(1.81f, 0.48f);
return smileyuint.Load(int3(uv*16,0));
}
if(IN.tri == 91)
{
float2 uv = posone * float2(0.55f, 0.48f);
return smiley.Sample(unboundsamp, uv);
}
if(IN.tri == 92)
{
float2 uv = posone * float2(0.55f, 0.48f);
return smiley.SampleBias(unboundsamp, uv, 0.5f);
}
return float4(0.4f, 0.4f, 0.4f, 0.4f);
}