Pragma unroll_loop does not work with nested code blocks
See original GitHub issueWhen unrolling a loop that has a block statement in it the shader breaks because it considers the first }
encountered to be closing the for loop. For example this works:
#pragma unroll_loop
for ( int i = 0; i < 6; i ++ ) {
if ( i < NUM_DIR_LIGHT_SHADOWS ) directLight.color *= getShadow( /* ... */ );
}
But this breaks:
#pragma unroll_loop
for ( int i = 0; i < 6; i ++ ) {
if ( i < NUM_DIR_LIGHT_SHADOWS ) {
directLight.color *= getShadow( /* ... */ );
}
}
The problematic regex is here:
https://github.com/mrdoob/three.js/blob/dev/src/renderers/webgl/WebGLProgram.js#L224
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to unroll nested for loops in c++? - Stack Overflow
I found ways to unroll it without any code (and conditions) between nested 'for' loops using template metaprogramming, but that did not help...
Read more >30201 – gcc doesn't unroll nested loops
While developing a Free C++ library, I am facing what I think is a bug in gcc: it doesn't unroll nested loops.
Read more >HLS LOOP UNROLL in nested loops doesn't seem to help
I tried reading the generated Verilog code, but it doesn't make much sense with ... I have the same problem with unrolling the...
Read more >Optimization Guide — SmartHLS 2022.2.1 documentation
This example shows a nested loop, which performs an element-wise multiplication of two 2-dimensional arrays and accumulates the sum. The inner loop is...
Read more >lib/Transforms/Scalar/LoopUnrollPass.cpp Source File - LLVM
105 cl::desc("Don't allow loop unrolling to simulate more than this number of" ... 135 cl::desc("Unroll loops with run-time trip counts"));.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
According to #13090, certain Macbooks with radeon cards required the loop unrool, too.
From my point of view, it is required until the opposite can be demonstrated with a few tests. I would not blindly remove it and risk shadow breakage on user devices.
That seems interesting!
I prefer this syntax: