Skip to content

HLSL array size limited to 255 #5994

@Jjagg

Description

@Jjagg

MG uses a byte in the binary effect format to store the number of parameters in an effect (written out here). In the effect writer, the function to write parameters is called recursively for an array, treating each element as a parameter. Because of this the number of elements in that array is also written out as a byte. The number of elements is internally stored as an integer and only casted to byte (without checking for overflow) when the effect is written out. So when users have arrays of > 255 elements, the build will succeed, but things will go wrong when the effect is read back in at runtime.

I locally patched this to write out and read in the parameter count as an integer and that fixed this. If that's alright I'll set up a PR. I know I have to upgrade the version in 2MGFX and the runtime, and rebuild stock effects afterwards.

EDIT: It seems parameter/element count is limited to 2^16, so using a short would be better.

Metadata

Metadata

Assignees

No one assigned

    Labels

    MGFXShader compilation tool

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions