[spirv] Add half as allowed (RW)Buffer element type (#1678)

Fixes https://github.com/Microsoft/DirectXShaderCompiler/issues/1672
This commit is contained in:
Lei Zhang 2018-11-07 17:26:35 -07:00 коммит произвёл GitHub
Родитель 2a7c520fcb
Коммит ee00dc18d6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 17 добавлений и 0 удалений

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

@ -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;

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

@ -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;
}

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

@ -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);
}