Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Cross.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Kristian Arntzen <post@arntzen-software.no>2022-01-17 14:49:02 +0300
committerHans-Kristian Arntzen <post@arntzen-software.no>2022-01-17 15:45:12 +0300
commitef6bde658021dae7732d9b628d58b2e0905c938c (patch)
treea355bdba0a17af8bf2eb85236d05c90fa72bbbf2 /spirv_glsl.cpp
parenta1bb29ccbb285618028a24efb3fe4f6718cee0b5 (diff)
Do not forward expressions which carry a huge amount of dependencies.
Need to force temporaries eventually, or compilers have a tendency to explode.
Diffstat (limited to 'spirv_glsl.cpp')
-rw-r--r--spirv_glsl.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp
index a96c9671..e43398a1 100644
--- a/spirv_glsl.cpp
+++ b/spirv_glsl.cpp
@@ -9498,6 +9498,7 @@ bool CompilerGLSL::should_forward(uint32_t id) const
{
// If id is a variable we will try to forward it regardless of force_temporary check below
// 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);
if (var && var->forwardable)
return true;
@@ -9506,6 +9507,13 @@ bool CompilerGLSL::should_forward(uint32_t id) const
if (options.force_temporary)
return false;
+ // If an expression carries enough dependencies we need to stop forwarding at some point,
+ // or we explode compilers. There are usually limits to how much we can nest expressions.
+ auto *expr = maybe_get<SPIRExpression>(id);
+ const uint32_t max_expression_dependencies = 64;
+ if (expr && expr->expression_dependencies.size() >= max_expression_dependencies)
+ return false;
+
// Immutable expression can always be forwarded.
if (is_immutable(id))
return true;