-
Notifications
You must be signed in to change notification settings - Fork 58
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
Validation Error: D3D11 missing vertex attribute semantics in shader #68
Comments
desc.attrs[0].sem_name = "TEXCOORD";
desc.attrs[0].sem_index = 0;
desc.attrs[2].sem_name = "TEXCOORD";
desc.attrs[2].sem_index = 2;
desc.attrs[0].sem_name = "TEXCOORD";
desc.attrs[0].sem_index = 0;
desc.attrs[1].sem_name = "TEXCOORD";
desc.attrs[1].sem_index = 2; I'll have a look... PS: No wait, it's not as simple as that, because the CPU-side code (rightly) expects that there are 3 vertex attributes, it shouldn't need to know that one attribute was dropped by the shader compiler (only the sokol-gfx backend needs to care about this when matching the vertex attributes from the shader descriptions against the 'expected' vertex layout in the pipeline description). This looks more like a bug in the sokol-gfx D3D backend. In any case I'll have a look (and also check that the Metal and GL backends do the right thing). PPS: I'll move the ticket over to the sokol repository. |
...hm turns out it's a bit more complicated... there's also a problem on the sokol-shdc side, that there's no attribute location define generated for the dropped attribute (which figures, because at the time when the shader reflection is read, the attribute already no longer exists): #define ATTR_debug_vs_a_position (0)
#define ATTR_debug_vs_a_color (2) ...this should be: #define ATTR_debug_vs_a_position (0)
#define ATTR_debug_vs_a_texcoords (1)
#define ATTR_debug_vs_a_color (2) ...I may need to disable that particular SPIRVTools optimizer pass (hopefully it is one specific pass). But I'll look into the D3D backend first, it should accept gaps in the shader vertex attribute description. |
@floooh Thanks for looking into it. |
Hmm... I may need to paddle back on the "the shader desc vertex description doesn't need to match the pipeline vertex layout", while this seems to work on GL, Metal and D3D11 (the error you're seeing is just because of the sokol-gfx validation layer), this may not be true in WebGPU, which has very strict validation. This area is currently too weakly defined in sokol-gfx, I would prefer that the shader vertex layout doesn't need to be a perfect match, but instead just a "subset" of the pipeline vertex layout, but I need to defer this decision until I get around to check that in the WIP sokol-gfx WebGPU backend. Until then I'll keep the sokol-gfx behaviour as it is, and instead try to fix the problem in sokol-shdc. |
...moving the ticket back to sokol-tools :) |
Ok, I have found a good solution. The whole issue is caused by the SPIRVTools optimizer function This way, unused vertex attributes (and I guess also other things, like texture samplers) are not removed from the shader, so that the generated sokol-gfx shader desc looks as expected. The question whether the vertex attributes in the shader desc should perfectly match the pipeline vertex layout is a different problem which I need to tackle later (but needs to be decided until the WebGPU backend is merged). |
PS: the sokol-shdc binaries are currently building, you can try them when this job has finished: https://github.com/floooh/sokol-tools/actions/runs/2085303355 ...if you are using the fips integration for sokol-shdc, you'll need to run a './fips clean' on the project, so that the generated sources are re-generated (I forgot to bump the version stamp). |
...oh great, another python vs python3 problem in the Github Actions job, hrmpf. I'll take care of that now. |
...ok new attempt, when this is done successfully, you can update sokol-tools-bin to get the new executables: https://github.com/floooh/sokol-tools/actions/runs/2085353842 |
@floooh Great. Thanks for all the effort! |
So I tried every one of my builds now and the original issue with D3D is gone with the new executables. I also don't notice any issues with the Metal backend. However, with the GL(CORE33) backend, I now get the following message during pipeline creation:
Apparently, this means that
which looks ok despite the somewhat weird attribute order. |
Hm ok, the message is from here: Happens when glGetAttribLocation() returns -1. I think this happens because the unused vertex attribute is now removed by the shader compiler of the OpenGL driver. There's not much that can be done except removing that warning message. |
Alright, makes sense, thanks! |
Hi,
I get the validation error "D3D11 missing vertex attribute semantics in shader" when compiling the following shader for HLSL5 using D3D under Windows.
I debugged the problem a bit and found that the generated shader description is problematic:
The problem, it seems, is that the texture coordinates are unused in this particular shader which yields an incomplete semantic description:
For example, if I manually add
then the validation passes and everything runs as expected. These manually added lines are actually correctly generated if I enforce usage of the texture coordinates in the shader. For obvious reasons, I don't want to do that. Also, the shader is perfectly accepted when having a GL or Metal backend.
Is this a straight up bug or does somebody have a painless workaround?
Thanks!
The text was updated successfully, but these errors were encountered: