DirectXShaderCompiler icon indicating copy to clipboard operation
DirectXShaderCompiler copied to clipboard

[SPIR-V] Scalar layout to follow C structure layout

Open Dolkar opened this issue 1 month ago • 5 comments

See #7894 for context.

Note that this is a backwards incompatible change and may break code that relies on the current odd behavior of -fvk-use-scalar-layout. It also fixes a case found by @s-perron that currently generates invalid SPIR-V (scalar.layout.struct.array test) because structs don't get properly aligned inside arrays.

Dolkar avatar Dec 10 '25 15:12 Dolkar

Thanks for the contribution. That is great.

We'll have to see if this causes regressions for anyone. It could be that people depend on the old behaviour, and this could break them. If that is significant, then we will have to add a new option.

@gjaegy, @devshgraphicsprogramming, @sajjadmirzanv, @LukasBanana, @EpicJeanNoeMorissette

If any of you use the scalar layout option in DXC, let me know if this will cause problems for you. I think this is the right direction in spirit, but it might not be pragmatic.

s-perron avatar Dec 10 '25 16:12 s-perron

We don't use the "vk-use-scalar-layout" option, so not a problem for us, thanks for asking !

gjaegy avatar Dec 10 '25 16:12 gjaegy

Thanks for the contribution. That is great.

We'll have to see if this causes regressions for anyone. It could be that people depend on the old behaviour, and this could break them. If that is significant, then we will have to add a new option.

@gjaegy, @devshgraphicsprogramming, @sajjadmirzanv, @LukasBanana, @EpicJeanNoeMorissette

If any of you use the scalar layout option in DXC, let me know if this will cause problems for you. I think this is the right direction in spirit, but it might not be pragmatic.

It actually fixes stuff for us, LGTM

Following the description in #7894, this makes sense to me. If the intention was to have C-like structures, this sounds like a reasonable fix. We do use this layout in UE5 as the extension VK_EXT_scalar_block_layout is required for ray-tracing and Nanite, so we'll keep an eye on this extension when we merge our next update from this mainstream. @EpicJeanNoeMorissette for vis.

LukasBanana avatar Dec 11 '25 09:12 LukasBanana

/AzurePiplines run

s-perron avatar Dec 15 '25 22:12 s-perron

@microsoft-github-policy-service agree company="BAE Systems OneArc"

Dolkar avatar Dec 16 '25 11:12 Dolkar

/AzurePipelines run

s-perron avatar Dec 16 '25 11:12 s-perron

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Dec 16 '25 11:12 azure-pipelines[bot]

/azp run

s-perron avatar Dec 16 '25 21:12 s-perron

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Dec 16 '25 21:12 azure-pipelines[bot]