[spirv] Add half as allowed (RW)Buffer element type (#1678)
Fixes https://github.com/Microsoft/DirectXShaderCompiler/issues/1672
This commit is contained in:
Родитель
2a7c520fcb
Коммит
ee00dc18d6
|
@ -1490,6 +1490,7 @@ TypeTranslator::translateSampledTypeToImageFormat(QualType sampledType) {
|
||||||
: elemCount == 2 ? spv::ImageFormat::Rg32ui
|
: elemCount == 2 ? spv::ImageFormat::Rg32ui
|
||||||
: spv::ImageFormat::Rgba32ui;
|
: spv::ImageFormat::Rgba32ui;
|
||||||
case BuiltinType::Float:
|
case BuiltinType::Float:
|
||||||
|
case BuiltinType::HalfFloat:
|
||||||
return elemCount == 1 ? spv::ImageFormat::R32f
|
return elemCount == 1 ? spv::ImageFormat::R32f
|
||||||
: elemCount == 2 ? spv::ImageFormat::Rg32f
|
: elemCount == 2 ? spv::ImageFormat::Rg32f
|
||||||
: spv::ImageFormat::Rgba32f;
|
: 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) {
|
TEST_F(FileTest, BufferTypeStructError3) {
|
||||||
runFileTest("type.buffer.struct.error3.hlsl", Expect::Failure);
|
runFileTest("type.buffer.struct.error3.hlsl", Expect::Failure);
|
||||||
}
|
}
|
||||||
|
TEST_F(FileTest, RWBufferTypeHalfElementType) {
|
||||||
|
runFileTest("type.rwbuffer.half.hlsl");
|
||||||
|
}
|
||||||
TEST_F(FileTest, RWBufferTypeStructError) {
|
TEST_F(FileTest, RWBufferTypeStructError) {
|
||||||
runFileTest("type.rwbuffer.struct.error.hlsl", Expect::Failure);
|
runFileTest("type.rwbuffer.struct.error.hlsl", Expect::Failure);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче