[spirv] add unittest for sizeof() (#2231)

This commit is contained in:
Jaebaek Seo 2019-06-04 17:50:22 -04:00 коммит произвёл Ehsan
Родитель b61633ad00
Коммит 6422947c35
2 изменённых файлов: 49 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,48 @@
// Run: %dxc -E main -T vs_6_2 -HV 2018 -enable-16bit-types
struct Empty {};
AppendStructuredBuffer<int> buf;
void main() {
// Test size and packing of scalar types, vectors and arrays all at once.
// CHECK: [[buf:%\d+]] = OpAccessChain %_ptr_Uniform_int %buf %uint_0
// CHECK-NEXT: OpStore [[buf]] %int_12
buf.Append(sizeof(int16_t3[2]));
// CHECK: [[buf:%\d+]] = OpAccessChain %_ptr_Uniform_int %buf %uint_0
// CHECK-NEXT: OpStore [[buf]] %int_12
buf.Append(sizeof(half3[2]));
// CHECK: [[buf:%\d+]] = OpAccessChain %_ptr_Uniform_int %buf %uint_0
// CHECK-NEXT: OpStore [[buf]] %int_24
buf.Append(sizeof(int3[2]));
// CHECK: [[buf:%\d+]] = OpAccessChain %_ptr_Uniform_int %buf %uint_0
// CHECK-NEXT: OpStore [[buf]] %int_24
buf.Append(sizeof(float3[2]));
// CHECK: [[buf:%\d+]] = OpAccessChain %_ptr_Uniform_int %buf %uint_0
// CHECK-NEXT: OpStore [[buf]] %int_24
buf.Append(sizeof(bool3[2]));
// CHECK: [[buf:%\d+]] = OpAccessChain %_ptr_Uniform_int %buf %uint_0
// CHECK-NEXT: OpStore [[buf]] %int_48
buf.Append(sizeof(int64_t3[2]));
// CHECK: [[buf:%\d+]] = OpAccessChain %_ptr_Uniform_int %buf %uint_0
// CHECK-NEXT: OpStore [[buf]] %int_48
buf.Append(sizeof(double3[2]));
// CHECK: [[buf:%\d+]] = OpAccessChain %_ptr_Uniform_int %buf %uint_0
// CHECK-NEXT: OpStore [[buf]] %int_0
buf.Append(sizeof(Empty[2]));
// CHECK: [[buf:%\d+]] = OpAccessChain %_ptr_Uniform_int %buf %uint_0
// CHECK-NEXT: OpStore [[buf]] %int_8
struct
{
int16_t i16;
// 2-byte padding
struct { float f32; } s; // Nested type
struct {} _; // Zero-sized field.
} complexStruct;
buf.Append(sizeof(complexStruct));
}

Просмотреть файл

@ -377,6 +377,7 @@ TEST_F(FileTest, OpTextureMipsAccess) {
TEST_F(FileTest, OpTextureSampleAccess) {
runFileTest("op.texture.sample-access.hlsl");
}
TEST_F(FileTest, OpSizeOf) { runFileTest("op.sizeof.hlsl"); }
// For casting
TEST_F(FileTest, CastNoOp) { runFileTest("cast.no-op.hlsl"); }