Skip to content

Commit a228113

Browse files
committed
address comments
1 parent b8ebfeb commit a228113

3 files changed

Lines changed: 40 additions & 2 deletions

File tree

tools/clang/lib/SPIRV/LowerTypeVisitor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,8 +861,8 @@ const SpirvType *LowerTypeVisitor::lowerVkTypeInVkNamespace(
861861
loweredType = spvContext.getUIntType(32);
862862
}
863863

864-
// Drop the "SampledTexture" prefix.
865-
StringRef suffix = name.drop_front(14);
864+
constexpr size_t sampledTexturePrefixLength = sizeof("SampledTexture") - 1;
865+
StringRef suffix = name.drop_front(sampledTexturePrefixLength);
866866
const spv::Dim dimension =
867867
suffix.startswith("1D") ? spv::Dim::Dim1D : spv::Dim::Dim2D;
868868
const bool isArray = suffix.endswith("Array");

tools/clang/test/CodeGenSPIRV/SampledTexture/SampledTexture1D/vk.sampledtexture1d.access.hlsl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
// RUN: %dxc -T ps_6_7 -E main -fcgl %s -spirv | FileCheck %s
2+
// RUN: not %dxc -T ps_6_7 -E main -fcgl %s -spirv -DERROR 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
23

34
// CHECK: %type_1d_image = OpTypeImage %float 1D 0 0 0 1 Unknown
45
// CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image
56

67
vk::SampledTexture1D<float4> tex1d;
78

9+
struct S { int a; };
10+
811
void main() {
912
// CHECK: OpStore %pos1 %uint_1
1013
uint pos1 = 1;
@@ -16,4 +19,20 @@ void main() {
1619
// CHECK: OpStore %a1 [[fetch_result]]
1720
float4 a1 = tex1d[pos1];
1821

22+
#ifdef ERROR
23+
S s = { 1 };
24+
// CHECK-ERROR: error: no viable overloaded operator[]
25+
// CHECK-ERROR: note: candidate function {{.*}} no known conversion from 'S' to 'unsigned int' for 1st argument
26+
float4 val2 = tex1d[s];
27+
28+
int2 i2 = int2(1, 2);
29+
// CHECK-ERROR: error: no viable overloaded operator[]
30+
// CHECK-ERROR: note: candidate function {{.*}} no known conversion from '{{int2|vector<int, 2>}}' to 'unsigned int' for 1st argument
31+
float4 val3 = tex1d[i2];
32+
33+
int3 i3 = int3(1, 2, 3);
34+
// CHECK-ERROR: error: no viable overloaded operator[]
35+
// CHECK-ERROR: note: candidate function {{.*}} no known conversion from '{{int3|vector<int, 3>}}' to 'unsigned int' for 1st argument
36+
float4 val4 = tex1d[i3];
37+
#endif
1938
}

tools/clang/test/CodeGenSPIRV/SampledTexture/SampledTexture1DArray/vk.sampledtexture1darray.access.hlsl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
// RUN: %dxc -T ps_6_7 -E main -fcgl %s -spirv | FileCheck %s
2+
// RUN: not %dxc -T ps_6_7 -E main -fcgl %s -spirv -DERROR 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
23

34
// CHECK: %type_1d_image_array = OpTypeImage %float 1D 0 1 0 1 Unknown
45
// CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image_array
56

67
vk::SampledTexture1DArray<float4> tex1dArray;
78

9+
struct S { int a; };
10+
811
void main() {
912
// CHECK: OpStore %pos1 [[pos1_init:%[a-zA-Z0-9_]+]]
1013

@@ -17,4 +20,20 @@ void main() {
1720

1821
float4 a1 = tex1dArray[pos1];
1922

23+
#ifdef ERROR
24+
S s = { 1 };
25+
// CHECK-ERROR: error: no viable overloaded operator[]
26+
// CHECK-ERROR: note: candidate function {{.*}} no known conversion from 'S' to 'vector<uint, 2>' for 1st argument
27+
float4 val2 = tex1dArray[s];
28+
29+
uint pos2 = 2;
30+
// CHECK-ERROR: error: no viable overloaded operator[]
31+
// CHECK-ERROR: note: candidate function {{.*}} no known conversion from '{{uint|unsigned int}}' to 'vector<uint, 2>' for 1st argument
32+
float4 val3 = tex1dArray[pos2];
33+
34+
int3 i3 = int3(1, 2, 3);
35+
// CHECK-ERROR: error: no viable overloaded operator[]
36+
// CHECK-ERROR: note: candidate function {{.*}} no known conversion from '{{int3|vector<int, 3>}}' to 'vector<uint, 2>' for 1st argument
37+
float4 val4 = tex1dArray[i3];
38+
#endif
2039
}

0 commit comments

Comments
 (0)