Can anyone help me with this hlsl error please?

Started by
7 comments, last by Adam Miles 4 years, 6 months ago
This is my vertex shader and I am getting this error, i tried googling which said something about not using a semantic so they discard it. So further down I tried “using” the semantic but I think I did it wrong.
Here is my pixel shader, when I remove lines 7-10 the error goes away.
Here is my input layout creation. Any help would be greatly appreciated! Usually I google error but I can't find much on this error.
Advertisement

your “TexCoord” input element should have an offset of 12 + 12 = 24.. Does that help with the issue?

Also, I always use float4x4 for matrices, does matrix work the same?

.:vinterberg:.

@vinterberg Thanks for replying! I was under the impression that the byte offset is supposed to be from the previous element as I see it in the docs https://docs.microsoft.com/en-us/windows/win32/api/d3d11/ns-d3d11-d3d11_input_element_desc

Is this not the case? I originally had it at 24 and it kept giving errors until I saw and changed it to 12. I think the matrix does work the same for the constant buffer as its been working fine for me until I tried adding the normal data :(. Before this I only had position and texcoords, but when trying to add in normal data I face this problem.

It builds and run fine when I remove lines 7-10 in my pixel shader, which I am totally unsure why. Whats wrong with lines 7-10 they look normal to me.

Try arranging input element array and your vshader struct so they are in the same order, does that help?
Normal
TexCoord
Position

- and your vshader output position is float4, but input element is float3..

.:vinterberg:.

@vinterberg

My input layout position is float3 but I convert it to float4 for my SV_POSITION here, I'm not sure if its wrong or not but it wasn't giving me any problems before setting my position like this
I tried rearranging it but I still face the same error..

The creation of the shaders and input layout code I wrote is here https://github.com/zacharytay1994/GPPAssignment2/blob/TREES/DirectXFramework/SourceFiles/Graphics.cpp

at line 717, in case you want to take a look. I create the shader and inputlayout pointers upon construction and only bind them when I need to. I bind them in a function further down at line 853 called SetUseType() before drawing stuff that needs them.

@vinterberg Just wanted to let you know that your were right! Input element description is the byte offset from the first element and not in between elements, no idea why the documentation says otherwise. Also the problem was because of my Shader Model Level, I guess it was too low so I had to increase it and the error went away! Thanks for the help!

I have a pull request out to update the documentation for AlignedByteOffset - it doesn't seem correct in its current form. Thanks!

Adam Miles - Principal Software Development Engineer - Microsoft Xbox Advanced Technology Group

This topic is closed to new replies.

Advertisement