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

Sampler Array Indexing Issues #12

Closed
Abdul-AZ opened this issue Sep 14, 2020 · 1 comment
Closed

Sampler Array Indexing Issues #12

Abdul-AZ opened this issue Sep 14, 2020 · 1 comment

Comments

@Abdul-AZ
Copy link

I have come to the following problem while trying to cross-compile from glsl to hlsl bytecode (D3D11).

One of my shaders contains the following code

int index = int(fsIn.tTexture); //casting from float to int
    switch(index)
    {
        case 0:
            return u_Textures[0].Sample(...);
        case 1:
            return u_Textures[1].Sample(...);
     ...

This is all fine if it is ported the same way in hlsl, however, it gets shortened to

int _21 = int(Texture);
FragColor = u_Textures[_21]

Which is not valid D3D11 hlsl code.

Any possible workarounds without having to rewrite the shaders completely?

May thanks.

@Abdul-AZ
Copy link
Author

It turns out I was compiling old not updated shaders and the library indeed outputs the correct shaders.

My apologies for the inconvenience.

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