Uniform float array appears to have a wrong stride on D3D11 · Issue #769 · Kode/Kore · GitHub
Skip to content

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

Open

Description

@tcdude

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions