From 96befca6bd79fbaed431105369a876aa00409fbc Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 6 Sep 2022 14:54:35 +0300 Subject: [PATCH] Declare capability for extended storage image formats if required --- source/glsl/spirv.cpp | 6 +++++- source/glsl/spirvconstants.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/source/glsl/spirv.cpp b/source/glsl/spirv.cpp index 1fc9799f..b263fe87 100644 --- a/source/glsl/spirv.cpp +++ b/source/glsl/spirv.cpp @@ -1605,6 +1605,7 @@ void SpirVGenerator::visit(ImageTypeDeclaration &image) return; Id type_id = allocate_id(image, 0); + SpirVFormat format = get_format(image.format); Id image_id = (image.sampled ? next_id++ : type_id); writer.begin_op(content.globals, OP_TYPE_IMAGE, 9); @@ -1615,7 +1616,7 @@ void SpirVGenerator::visit(ImageTypeDeclaration &image) writer.write(image.array); writer.write(image.multisample); writer.write(image.sampled ? 1 : 2); - writer.write(get_format(image.format)); + writer.write(format); writer.end_op(OP_TYPE_IMAGE); if(image.sampled) @@ -1632,6 +1633,9 @@ void SpirVGenerator::visit(ImageTypeDeclaration &image) if(image.multisample && !image.sampled) use_capability(CAP_STORAGE_IMAGE_MULTISAMPLE); + + if(format>=FORMAT_RG32F && format<=FORMAT_R8_SNORM) + use_capability(CAP_STORAGE_IMAGE_EXTENDED_FORMATS); } void SpirVGenerator::visit(StructDeclaration &strct) diff --git a/source/glsl/spirvconstants.h b/source/glsl/spirvconstants.h index e3c245fb..2e952e05 100644 --- a/source/glsl/spirvconstants.h +++ b/source/glsl/spirvconstants.h @@ -168,6 +168,7 @@ enum SpirVCapability CAP_SAMPLED_1D = 43, CAP_IMAGE_1D = 44, CAP_SAMPLED_CUBE_ARRAY = 45, + CAP_STORAGE_IMAGE_EXTENDED_FORMATS = 49, CAP_IMAGE_QUERY = 50, CAP_DERIVATIVE_CONTROL = 51, CAP_INTERPOLATION_FUNCTION = 52 -- 2.45.2