From 20c8e6787cdb3eb4faf53349c1ed1dde757458e5 Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Tue, 21 Aug 2018 12:17:40 +0200 Subject: [PATCH] Get fallback name for block if name is empty. --- spirv_glsl.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index 2d47911c..542ec733 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -1601,11 +1601,16 @@ void CompilerGLSL::emit_interface_block(const SPIRVariable &var) // Shaders never use the block by interface name, so we don't // have to track this other than updating name caches. - if (block_namespace.find(block_name) != end(block_namespace)) + if (block_name.empty() || block_namespace.find(block_name) != end(block_namespace)) block_name = get_fallback_name(type.self); else block_namespace.insert(block_name); + // If for some reason buffer_name is an illegal name, make a final fallback to a workaround name. + // This cannot conflict with anything else, so we're safe now. + if (block_name.empty()) + block_name = join("_", get(var.basetype).self, "_", var.self); + // Instance names cannot alias block names. resource_names.insert(block_name);