writer/hlsl: Use SampleCmpLevelZero instead of SampleCmp

Currently WGSL does not allow a mip-level to be specified for `sampleCompare`, and cs_5_1 does not allow SampleCmp to be used.

Bug: tint:684
Change-Id: I53f35205185a0a1ee0dd5224fa1d8cd0ffedbea1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47429
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Ben Clayton 2021-04-09 18:20:18 +00:00 committed by Commit Bot service account
parent 804a699ea5
commit 6f7986d9b5
2 changed files with 7 additions and 7 deletions

View File

@ -1077,7 +1077,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& pre,
out << ".SampleGrad("; out << ".SampleGrad(";
break; break;
case semantic::IntrinsicType::kTextureSampleCompare: case semantic::IntrinsicType::kTextureSampleCompare:
out << ".SampleCmp("; out << ".SampleCmpLevelZero(";
break; break;
case semantic::IntrinsicType::kTextureLoad: case semantic::IntrinsicType::kTextureLoad:
out << ".Load("; out << ".Load(";

View File

@ -290,17 +290,17 @@ ExpectedResult expected_texture_overload(
case ValidTextureOverload::kSampleGradCubeArrayF32: case ValidTextureOverload::kSampleGradCubeArrayF32:
return R"(_tint_texture.SampleGrad(_tint_sampler, float4(1.0f, 2.0f, 3.0f, float(4)), float3(5.0f, 6.0f, 7.0f), float3(8.0f, 9.0f, 10.0f)))"; return R"(_tint_texture.SampleGrad(_tint_sampler, float4(1.0f, 2.0f, 3.0f, float(4)), float3(5.0f, 6.0f, 7.0f), float3(8.0f, 9.0f, 10.0f)))";
case ValidTextureOverload::kSampleCompareDepth2dF32: case ValidTextureOverload::kSampleCompareDepth2dF32:
return R"(_tint_texture.SampleCmp(_tint_sampler, float2(1.0f, 2.0f), 3.0f))"; return R"(_tint_texture.SampleCmpLevelZero(_tint_sampler, float2(1.0f, 2.0f), 3.0f))";
case ValidTextureOverload::kSampleCompareDepth2dOffsetF32: case ValidTextureOverload::kSampleCompareDepth2dOffsetF32:
return R"(_tint_texture.SampleCmp(_tint_sampler, float2(1.0f, 2.0f), 3.0f, int2(4, 5)))"; return R"(_tint_texture.SampleCmpLevelZero(_tint_sampler, float2(1.0f, 2.0f), 3.0f, int2(4, 5)))";
case ValidTextureOverload::kSampleCompareDepth2dArrayF32: case ValidTextureOverload::kSampleCompareDepth2dArrayF32:
return R"(_tint_texture.SampleCmp(_tint_sampler, float3(1.0f, 2.0f, float(4)), 3.0f))"; return R"(_tint_texture.SampleCmpLevelZero(_tint_sampler, float3(1.0f, 2.0f, float(4)), 3.0f))";
case ValidTextureOverload::kSampleCompareDepth2dArrayOffsetF32: case ValidTextureOverload::kSampleCompareDepth2dArrayOffsetF32:
return R"(_tint_texture.SampleCmp(_tint_sampler, float3(1.0f, 2.0f, float(4)), 3.0f, int2(5, 6)))"; return R"(_tint_texture.SampleCmpLevelZero(_tint_sampler, float3(1.0f, 2.0f, float(4)), 3.0f, int2(5, 6)))";
case ValidTextureOverload::kSampleCompareDepthCubeF32: case ValidTextureOverload::kSampleCompareDepthCubeF32:
return R"(_tint_texture.SampleCmp(_tint_sampler, float3(1.0f, 2.0f, 3.0f), 4.0f))"; return R"(_tint_texture.SampleCmpLevelZero(_tint_sampler, float3(1.0f, 2.0f, 3.0f), 4.0f))";
case ValidTextureOverload::kSampleCompareDepthCubeArrayF32: case ValidTextureOverload::kSampleCompareDepthCubeArrayF32:
return R"(_tint_texture.SampleCmp(_tint_sampler, float4(1.0f, 2.0f, 3.0f, float(4)), 5.0f))"; return R"(_tint_texture.SampleCmpLevelZero(_tint_sampler, float4(1.0f, 2.0f, 3.0f, float(4)), 5.0f))";
case ValidTextureOverload::kLoad1dLevelF32: case ValidTextureOverload::kLoad1dLevelF32:
return R"(_tint_texture.Load(int2(1, 0), 3))"; return R"(_tint_texture.Load(int2(1, 0), 3))";
case ValidTextureOverload::kLoad1dLevelU32: case ValidTextureOverload::kLoad1dLevelU32: