Skip to content

Commit 7b5d547

Browse files
authored
[spirv] report error for invalid tex2d multiplication (#3175)
Calling tex2D must report an error but the multiplication using it crashes instead of an error report.
1 parent 4ee59f6 commit 7b5d547

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

tools/clang/lib/SPIRV/SpirvEmitter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5556,6 +5556,8 @@ SpirvInstruction *SpirvEmitter::processBinaryOp(
55565556
} else {
55575557
// Evalute lhs before rhs
55585558
lhsPtr = doExpr(lhs);
5559+
if (!lhsPtr)
5560+
return nullptr;
55595561
lhsVal = loadIfGLValue(lhs, lhsPtr);
55605562
rhsVal = loadIfGLValue(rhs);
55615563
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Run: %dxc -T ps_6_0 -E main
2+
3+
// CHECK: deprecated tex2D intrinsic function will not be supported
4+
sampler Sampler;
5+
6+
float4 main(float2 texCoord : TEXCOORD0) : SV_TARGET0
7+
{
8+
return tex2D(Sampler, texCoord) * 1;
9+
}

tools/clang/unittests/SPIRV/CodeGenSpirvTest.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,9 @@ TEST_F(FileTest, TextureArraySampleCmpLevelZero) {
921921
TEST_F(FileTest, TextureSampleInvalidImplicitLod) {
922922
runFileTest("texture.sample-invalid-implicit-lod.hlsl", Expect::Failure);
923923
}
924+
TEST_F(FileTest, TextureInvalidTex2D) {
925+
runFileTest("texture.sample.invalid.tex2d.hlsl", Expect::Failure);
926+
}
924927

925928
// For structured buffer methods
926929
TEST_F(FileTest, StructuredBufferLoad) {

0 commit comments

Comments
 (0)