]> git.tdb.fi Git - libs/gl.git/commitdiff
Mark storage buffers in compute shaders as outputs
authorMikko Rasa <tdb@tdb.fi>
Thu, 1 Aug 2024 14:57:02 +0000 (17:57 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 1 Aug 2024 14:57:02 +0000 (17:57 +0300)
source/glsl/optimize.cpp

index 51377594272734db5a5de7d233a3fc033c2a8dab..d544e343b76fa26e647bcb00f34586698e1fa371 100644 (file)
@@ -1485,9 +1485,10 @@ void UnusedVariableRemover::visit(VariableDeclaration &var)
        VariableInfo &var_info = variables[&var];
 
        /* Mark variables as output if they're used by the next stage or the
-       graphics API. */
+       graphics API.  Also mark storage buffers as output in compute stage. */
        bool builtin = (!var.name.compare(0, 3, "gl_") || (var.block_declaration && !var.block_declaration->block_name.compare(0, 3, "gl_")));
-       var_info.output = (var.interface=="out" && (stage->type==Stage::FRAGMENT || var.linked_declaration || builtin));
+       var_info.output = ((var.interface=="out" && (stage->type==Stage::FRAGMENT || var.linked_declaration || builtin)) ||
+               (var.interface=="buffer" && stage->type==Stage::COMPUTE));
 
        // Linked outputs are automatically referenced.
        if(var_info.output && var.linked_declaration)