Skip to content

Commit

Permalink
[spirv] Add half as allowed (RW)Buffer element type (#1678)
Browse files Browse the repository at this point in the history
Fixes #1672
  • Loading branch information
antiagainst committed Nov 8, 2018
1 parent 2a7c520 commit ee00dc1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions tools/clang/lib/SPIRV/TypeTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,7 @@ TypeTranslator::translateSampledTypeToImageFormat(QualType sampledType) {
: elemCount == 2 ? spv::ImageFormat::Rg32ui
: spv::ImageFormat::Rgba32ui;
case BuiltinType::Float:
case BuiltinType::HalfFloat:
return elemCount == 1 ? spv::ImageFormat::R32f
: elemCount == 2 ? spv::ImageFormat::Rg32f
: spv::ImageFormat::Rgba32f;
Expand Down
13 changes: 13 additions & 0 deletions tools/clang/test/CodeGenSPIRV/type.rwbuffer.half.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Run: %dxc -T cs_6_0 -E main

// CHECK: %type_buffer_image = OpTypeImage %float Buffer 2 0 0 2 Rgba32f
// CHECK: %_ptr_UniformConstant_type_buffer_image = OpTypePointer UniformConstant %type_buffer_image
// CHECK: %HalfBuffer = OpVariable %_ptr_UniformConstant_type_buffer_image UniformConstant

RWBuffer<half4> HalfBuffer;

void main()
{
HalfBuffer[0] = 1.0;
}

3 changes: 3 additions & 0 deletions tools/clang/unittests/SPIRV/CodeGenSPIRVTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ TEST_F(FileTest, BufferTypeStructError2) {
TEST_F(FileTest, BufferTypeStructError3) {
runFileTest("type.buffer.struct.error3.hlsl", Expect::Failure);
}
TEST_F(FileTest, RWBufferTypeHalfElementType) {
runFileTest("type.rwbuffer.half.hlsl");
}
TEST_F(FileTest, RWBufferTypeStructError) {
runFileTest("type.rwbuffer.struct.error.hlsl", Expect::Failure);
}
Expand Down

0 comments on commit ee00dc1

Please sign in to comment.