Skip to content

Commit

Permalink
Make loop unrolling completely whitespace-insensitive
Browse files Browse the repository at this point in the history
This is just another #19726.
Since #20012 is accepted, I think it's okay to make loop unrolling
completely whitespace-insensitive.
  • Loading branch information
yushijinhun committed Aug 23, 2020
1 parent 8258225 commit e6cb904
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 8 deletions.
3 changes: 0 additions & 3 deletions docs/api/en/materials/ShaderMaterial.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ <h1>[name]</h1>
<li>
The loop variable has to be *i*.
</li>
<li>
The loop has to use a certain whitespace formatting.
</li>
</ul>
<code>
#pragma unroll_loop_start
Expand Down
3 changes: 0 additions & 3 deletions docs/api/zh/materials/ShaderMaterial.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ <h1>着色器材质([name])</h1>
<li>
循环变量必须是*i*。
</li>
<li>
循环必须使用某种空格格式。
</li>
</ul>
<code>
#pragma unroll_loop_start
Expand Down
4 changes: 2 additions & 2 deletions src/renderers/webgl/WebGLProgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function includeReplacer( match, include ) {
// Unroll Loops

const deprecatedUnrollLoopPattern = /#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;
const unrollLoopPattern = /#pragma unroll_loop_start[\s]+?for\s*\(\s*int i \= (\d+)\; i < (\d+)\; i\s*\+\+\s*\)\s*{([\s\S]+?)(?=\})\}[\s]+?#pragma unroll_loop_end/g;
const unrollLoopPattern = /#pragma\s+unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma\s+unroll_loop_end/g;

function unrollLoops( string ) {

Expand All @@ -244,7 +244,7 @@ function loopReplacer( match, start, end, snippet ) {
for ( let i = parseInt( start ); i < parseInt( end ); i ++ ) {

string += snippet
.replace( /\[ i \]/g, '[ ' + i + ' ]' )
.replace( /\[\s*i\s*\]/g, '[ ' + i + ' ]' )
.replace( /UNROLLED_LOOP_INDEX/g, i );

}
Expand Down

0 comments on commit e6cb904

Please sign in to comment.