Merge pull request #734 from zeux/master
Fix Options::force_temporary to work with OpenGL GLSL
This commit is contained in:
commit
dfd1bf8c56
@ -5856,11 +5856,21 @@ std::pair<std::string, uint32_t> CompilerGLSL::flattened_access_chain_offset(con
|
|||||||
|
|
||||||
bool CompilerGLSL::should_forward(uint32_t id)
|
bool CompilerGLSL::should_forward(uint32_t id)
|
||||||
{
|
{
|
||||||
// Immutable expression can always be forwarded.
|
// If id is a variable we will try to forward it regardless of force_temporary check below
|
||||||
// If not immutable, we can speculate about it by forwarding potentially mutable variables.
|
// This is important because otherwise we'll get local sampler copies (highp sampler2D foo = bar) that are invalid in OpenGL GLSL
|
||||||
auto *var = maybe_get<SPIRVariable>(id);
|
auto *var = maybe_get<SPIRVariable>(id);
|
||||||
bool forward = var ? var->forwardable : false;
|
if (var && var->forwardable)
|
||||||
return (is_immutable(id) || forward) && !options.force_temporary;
|
return true;
|
||||||
|
|
||||||
|
// For debugging emit temporary variables for all expressions
|
||||||
|
if (options.force_temporary)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Immutable expression can always be forwarded.
|
||||||
|
if (is_immutable(id))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompilerGLSL::track_expression_read(uint32_t id)
|
void CompilerGLSL::track_expression_read(uint32_t id)
|
||||||
|
Loading…
Reference in New Issue
Block a user