Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Rep having the same int name #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

steam-test1
Copy link
Contributor

Currently it names them i0 even if there's multiple loops

Currently has i0 for multiple loops
@AndresTraks
Copy link
Owner

Currently the idea is that the loop variable name is incremented for each rep/loop instruction and decremented for each endrep/endloop, so you get i0 in outer loops , i1 in inner loops and so on. If there are multiple loops on the same level, then the name i0 should be fine, because each loop variable is in the scope of its own loop.

I didn't realize that in previous versions of HLSL, the loop variable was contained in the scope outside of the loop, which would cause a problem. https://devblogs.microsoft.com/directx/hlsl-2021-migration-guide/ Visual Studio still gives a warning if i0 is used twice, but FXC will compile it.

This change doesn't seem consistent either, because the variable name is still decremented at endrep/endloop, so the name could still end up being reused. Also, the same logic isn't applied to the loop instruction as for rep. I'll think about it. We should also check that a loop variable isn't named the same as some user-defined global variable, but that'll take a while to implement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants