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

Uniform float array appears to have a wrong stride on D3D11 #769

Open
tcdude opened this issue Feb 21, 2023 · 0 comments
Open

Uniform float array appears to have a wrong stride on D3D11 #769

tcdude opened this issue Feb 21, 2023 · 0 comments

Comments

@tcdude
Copy link
Contributor

tcdude commented Feb 21, 2023

Describe the bug
When I use a uniform float array in a shader like this:

uniform float some_data[10];

I only get every 4th element from the float array I pass to the shader at runtime. It seems that the constant buffer used has an alignment requirement of 16 bytes.

To Reproduce
Passing in data to such a uniform float array (e.g. in my case using kinc_g4_set_floats) and either color debugging the data or using something like RenderDoc

Expected behavior
I would like to be able to access all the data with respective indexing to the original data.

Screenshots
This is how RenderDoc sees the data:
image

Execution Environment:

  • Host system (where you compile your code): Windows 10 x64
  • Target system (where you run your code): Windows 10 x64 D3D11
  • IDE and/or compiler used: Visual Studio / MSVC
  • Kinc revision: 273d365
  • Kinc build output:
Using Kinc (273d3650) from C:\code\kraymarch\krink\Kinc
kfile found.
Creating Windows project files.
Compiling shader 1 of 14 (kr-painter-colored.frag).
Compiling shader 4 of 14 (kr-painter-image.vert).
Compiling shader 5 of 14 (kr-painter-sdf-circle.frag).
Compiling shader 6 of 14 (kr-painter-sdf-circle.vert).
Compiling shader 7 of 14 (kr-painter-sdf-line.frag).
Compiling shader 8 of 14 (kr-painter-sdf-line.vert).
Compiling shader 9 of 14 (kr-painter-sdf-rect.frag).
Compiling shader 10 of 14 (kr-painter-sdf-rect.vert).
Compiling shader 11 of 14 (kr-painter-text.frag).
Compiling shader 12 of 14 (kr-painter-text.vert).
Compiling shader 13 of 14 (g1.frag).
Compiling shader 14 of 14 (g1.vert).
Done.
  • Application output (if it runs): Not applicable

Additional context
I changed the type from float to vec4 and changed the logic of indexing, which resolves the issue for me. But I do believe this could be worth either documenting or handling internally in either Kinc or Krafix

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

No branches or pull requests

1 participant