]> git.tdb.fi Git - libs/gl.git/commitdiff
Tweaks and fixes to OpNames in SPIR-V
authorMikko Rasa <tdb@tdb.fi>
Tue, 30 Nov 2021 21:46:59 +0000 (23:46 +0200)
committerMikko Rasa <tdb@tdb.fi>
Tue, 30 Nov 2021 21:46:59 +0000 (23:46 +0200)
Interface blocks without an instance name must not have a non-empty
OpName or the reflection code gets confused.

source/glsl/spirv.cpp

index 1f7d6a1b722c98289446f95a40aacd0c8101a09b..e1ba981b552f1b63de515334bdd516ed0846159f 100644 (file)
@@ -1512,7 +1512,7 @@ void SpirVGenerator::visit(StructDeclaration &strct)
                return;
 
        Id type_id = allocate_id(strct, 0);
-       writer.write_op_name(type_id, strct.name);
+       writer.write_op_name(type_id, (strct.block_name.empty() ? strct.name : strct.block_name));
 
        if(!strct.block_name.empty())
                writer.write_op_decorate(type_id, DECO_BLOCK);
@@ -1670,7 +1670,8 @@ void SpirVGenerator::visit(VariableDeclaration &var)
                }
        }
 
-       writer.write_op_name(var_id, var.name);
+       if(var.name.find(' ')==string::npos)
+               writer.write_op_name(var_id, var.name);
 }
 
 void SpirVGenerator::visit_entry_point(FunctionDeclaration &func, Id func_id)
@@ -1776,6 +1777,7 @@ void SpirVGenerator::visit(FunctionDeclaration &func)
        {
                Id param_id = allocate_id(*func.parameters[i], param_type_ids[i]);
                writer.write_op(content.functions, OP_FUNCTION_PARAMETER, param_type_ids[i], param_id);
+               writer.write_op_name(param_id, func.parameters[i]->name);
                // TODO This is probably incorrect if the parameter is assigned to.
                variable_load_ids[func.parameters[i].get()] = param_id;
        }