Fix Vulkan constant buffer reflection data parsing by ThomasFOG · Pull Request #8941 · MonoGame/MonoGame
This fixes a regression introduced by #8544 in Vulkan constant buffers parsing.
This should repair shader building and usage (notably the stock shaders).
| // First gather the uniforms. | ||
| VkStruct globals; | ||
| if (structs.TryGetValue("%type__Globals", out globals)) | ||
| if (structs.TryGetValue("%type__MG_Globals", out globals)) |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be fine with this, and that would allow shaders not built using the Macros.fxh.
I can edit that to throw an error with explanations if more than one cb is defined.
Alternatively... I could hack something like putting all constants into a unique buffer with an automatic 4-register aligned offset...
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can edit that to throw an error with explanations if more than one cb is defined.
An error may be best as multiple buffers likely means something is broken.
Alternatively... I could hack something like putting all constants into a unique buffer with an automatic 4-register aligned offset...
This would mean hacking at the incoming shader HLSL file?
Seems like a lot of work and really we need to switch to our goal of supporting multiple cbuffers natively. So maybe lets not spend time on that.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, I'll update the PR in a moment accordingly.
ThomasFOG
marked this pull request as ready for review
@tomspilman I made the uniform buffer discovery generic. It tries to read the first cbuffer hit, and will fail with a message if more than one cbuffer is encountered. I've tested with different cbuffer, with and without Macros.fxh, and it seems fine.
EDIT: we have a stock effect failing, investigating... TextureCube are uniform buffers on Spir-v. Checking if I can do something about that...
@tomspilman Fixed it, stock shaders are a go. TextureCube are single buffers, so I worked around that by only gathering uniforms when there's a corresponding struct with the expected name. That should do it.
My only concern is that I don't think TextureCube will work, they are not _type_2d_image but _type_cube_image and this descriptor is currently not parsed. But I've noticed that it's not implemented in MGG_Texture_Create(), so I left that as-is.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters