mirror of
https://github.com/KhronosGroup/SPIRV-Cross.git
synced 2024-11-12 15:10:30 +00:00
Add option to disable storage image qualifier deduction.
This commit is contained in:
parent
3ebc83da46
commit
01968c4486
@ -323,7 +323,7 @@ if (SPIRV_CROSS_STATIC)
|
||||
endif()
|
||||
|
||||
set(spirv-cross-abi-major 0)
|
||||
set(spirv-cross-abi-minor 25)
|
||||
set(spirv-cross-abi-minor 26)
|
||||
set(spirv-cross-abi-patch 0)
|
||||
|
||||
if (SPIRV_CROSS_SHARED)
|
||||
|
@ -420,6 +420,9 @@ spvc_result spvc_compiler_options_set_uint(spvc_compiler_options options, spvc_c
|
||||
case SPVC_COMPILER_OPTION_EMIT_LINE_DIRECTIVES:
|
||||
options->glsl.emit_line_directives = value != 0;
|
||||
break;
|
||||
case SPVC_COMPILER_OPTION_ENABLE_STORAGE_IMAGE_QUALIFIER_DEDUCTION:
|
||||
options->glsl.enable_storage_image_qualifier_deduction = value != 0;
|
||||
break;
|
||||
|
||||
case SPVC_COMPILER_OPTION_GLSL_SUPPORT_NONZERO_BASE_INSTANCE:
|
||||
options->glsl.vertex.support_nonzero_base_instance = value != 0;
|
||||
|
@ -33,7 +33,7 @@ extern "C" {
|
||||
/* Bumped if ABI or API breaks backwards compatibility. */
|
||||
#define SPVC_C_API_VERSION_MAJOR 0
|
||||
/* Bumped if APIs or enumerations are added in a backwards compatible way. */
|
||||
#define SPVC_C_API_VERSION_MINOR 25
|
||||
#define SPVC_C_API_VERSION_MINOR 26
|
||||
/* Bumped if internal implementation details change. */
|
||||
#define SPVC_C_API_VERSION_PATCH 0
|
||||
|
||||
@ -574,6 +574,8 @@ typedef enum spvc_compiler_option
|
||||
SPVC_COMPILER_OPTION_MSL_FORCE_ACTIVE_ARGUMENT_BUFFER_RESOURCES = 50 | SPVC_COMPILER_OPTION_MSL_BIT,
|
||||
SPVC_COMPILER_OPTION_MSL_FORCE_NATIVE_ARRAYS = 51 | SPVC_COMPILER_OPTION_MSL_BIT,
|
||||
|
||||
SPVC_COMPILER_OPTION_ENABLE_STORAGE_IMAGE_QUALIFIER_DEDUCTION = 52 | SPVC_COMPILER_OPTION_COMMON_BIT,
|
||||
|
||||
SPVC_COMPILER_OPTION_INT_MAX = 0x7fffffff
|
||||
} spvc_compiler_option;
|
||||
|
||||
|
@ -2504,11 +2504,14 @@ void CompilerGLSL::emit_pls()
|
||||
|
||||
void CompilerGLSL::fixup_image_load_store_access()
|
||||
{
|
||||
if (!options.enable_storage_image_qualifier_deduction)
|
||||
return;
|
||||
|
||||
ir.for_each_typed_id<SPIRVariable>([&](uint32_t var, const SPIRVariable &) {
|
||||
auto &vartype = expression_type(var);
|
||||
if (vartype.basetype == SPIRType::Image)
|
||||
{
|
||||
// Older glslangValidator does not emit required qualifiers here.
|
||||
// Very old glslangValidator and HLSL compilers do not emit required qualifiers here.
|
||||
// Solve this by making the image access as restricted as possible and loosen up if we need to.
|
||||
// If any no-read/no-write flags are actually set, assume that the compiler knows what it's doing.
|
||||
|
||||
|
@ -108,6 +108,13 @@ public:
|
||||
// May not correspond exactly to original source, but should be a good approximation.
|
||||
bool emit_line_directives = false;
|
||||
|
||||
// In cases where readonly/writeonly decoration are not used at all,
|
||||
// we try to deduce which qualifier(s) we should actually used, since actually emitting
|
||||
// read-write decoration is very rare, and older glslang/HLSL compilers tend to just emit readwrite as a matter of fact.
|
||||
// The default (true) is to enable automatic deduction for these cases, but if you trust the decorations set
|
||||
// by the SPIR-V, it's recommended to set this to false.
|
||||
bool enable_storage_image_qualifier_deduction = true;
|
||||
|
||||
enum Precision
|
||||
{
|
||||
DontCare,
|
||||
|
Loading…
Reference in New Issue
Block a user