Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Operand mixup for variable-sized arrays in translateTopToBottom #57

Open
Avopeac opened this issue Sep 7, 2017 · 0 comments
Open

Operand mixup for variable-sized arrays in translateTopToBottom #57

Avopeac opened this issue Sep 7, 2017 · 0 comments

Comments

@Avopeac
Copy link

Avopeac commented Sep 7, 2017

Running the following shader through the Standalone LunarGOO.exe results in clearly erroneous code, as seen below:

#version 450
layout (binding = 0) buffer IntBuffer {
   int IntList[];
};
layout (location = 0) out int outInt;
void main() {
    outInt = IntList[1];
}

becomes

#version 450 core
// LunarGOO output
layout(binding=0) buffer IntBuffer {
        int IntList[];
} ;
layout(location=0) out int outInt;
void main() {
        outInt = [1].IntList;
}

Inspecting the AST as well as the intermediate Top IR suggest that this problem is a result of some optimizations run in translateTopToBottom, where apparently the order of the operands of a "direct indexing" operation gets reversed. The behaviour can not be observed when using fixed-size arrays.
I can't speak of the exact place this error occurs, however the period between the two operands seems to be an artifact of IntList being part of an anonymous block and it would be dealt with, were the operands ordered correctly as .IntList[1]

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

No branches or pull requests

1 participant