Merge pull request #537 from KhronosGroup/fix-535
Unsigned integers are disallowed on legacy targets.
diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp
index 805c88f..0c79892 100644
--- a/spirv_glsl.cpp
+++ b/spirv_glsl.cpp
@@ -767,7 +767,7 @@
//if (flags & (1ull << DecorationColMajor))
// attr.push_back("column_major");
- if (dec.decoration_flags.get(DecorationLocation) && can_use_io_location(type.storage))
+ if (dec.decoration_flags.get(DecorationLocation) && can_use_io_location(type.storage, true))
attr.push_back(join("location = ", dec.location));
// DecorationCPacked is set by layout_for_variable earlier to mark that we need to emit offset qualifiers.
@@ -1183,14 +1183,17 @@
return true;
}
-bool CompilerGLSL::can_use_io_location(StorageClass storage)
+bool CompilerGLSL::can_use_io_location(StorageClass storage, bool block)
{
// Location specifiers are must have in SPIR-V, but they aren't really supported in earlier versions of GLSL.
// Be very explicit here about how to solve the issue.
if ((get_execution_model() != ExecutionModelVertex && storage == StorageClassInput) ||
(get_execution_model() != ExecutionModelFragment && storage == StorageClassOutput))
{
- if (!options.es && options.version < 410 && !options.separate_shader_objects)
+ uint32_t minimum_desktop_version = block ? 440 : 410;
+ // ARB_enhanced_layouts vs ARB_separate_shader_objects ...
+
+ if (!options.es && options.version < minimum_desktop_version && !options.separate_shader_objects)
return false;
else if (options.es && options.version < 310)
return false;
@@ -1246,7 +1249,8 @@
attr.push_back(join("input_attachment_index = ", dec.input_attachment));
}
- if (flags.get(DecorationLocation) && can_use_io_location(var.storage))
+ bool is_block = has_decoration(type.self, DecorationBlock);
+ if (flags.get(DecorationLocation) && can_use_io_location(var.storage, is_block))
{
Bitset combined_decoration;
for (uint32_t i = 0; i < meta[type.self].members.size(); i++)
diff --git a/spirv_glsl.hpp b/spirv_glsl.hpp
index c896787..5ace45d 100644
--- a/spirv_glsl.hpp
+++ b/spirv_glsl.hpp
@@ -547,7 +547,7 @@
static std::string sanitize_underscores(const std::string &str);
- bool can_use_io_location(spv::StorageClass storage);
+ bool can_use_io_location(spv::StorageClass storage, bool block);
const Instruction *get_next_instruction_in_block(const Instruction &instr);
static uint32_t mask_relevant_memory_semantics(uint32_t semantics);