Sign in to follow this  

AMD Driver 16.11.2 fails passing uniform from vs to fs

This topic is 406 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

 

Before updating from 16.10.3 AMD Driver version to 16.11.2 I have not had any problem with shader code. But with new update. vkCreateGraphicsPipelines fails with error:

 

"The thread tried to read or write data that is misaligned on hardware that does not provide alignment. For example, 16-bit values must be aligned on 2-byte boundaries; 32-bit values on 4-byte boundaries, and so on."

 

 

I tried to find the problem why it is like this and what I noticed:

Assigning and passing data like this from  vertex to fragment resulted in these problems.

 

Vertex Shader:

 

out VS_OUT
{
    vec3 eyeDir;
    vec3 lightDir;
    vec3 normal;
    vec2 texcoord;
} vs_out;
 
void main()
{
    vs_out.texcoord = vec2(1.0); //Will give here error for access. Uncomenting this line will run shader properly.
}
 
Fragment Shader:
in VS_OUT
{
    vec3 eyeDir;
    vec3 lightDir;
    vec3 normal;
vec2 texcoord;
} fs_in;
 
 
but once I added layout and location to them:
Vertex Shader:
layout (location = 5) out VS_OUT
{
    vec3 eyeDir;
    vec3 lightDir;
    vec3 normal;
vec2 texcoord;
} vs_out;
 
Fragment Shader:
layout (location = 5) in VS_OUT
{
    vec3 eyeDir;
    vec3 lightDir;
    vec3 normal;
vec2 texcoord;
} fs_in;
 
The shader code was not failing anymore.
 
 
Can anyone confirm if anyone have the same problem with new AMD Driver?

 

Share this post


Link to post
Share on other sites
I also noticed that old Imgui Vulkan code was not working anymore but I saw that he does the same thing for in and out.

 

Have had a similar issue (forgot details) but fixed it following this thread:

https://community.amd.com/thread/206802

 

Edit:

Here is the chaged shader code that now works for me - it was a bit work to figure it out from the thread.

 

Vertex:

#version 450 core
layout(location = 0) in vec2 aPos;
layout(location = 1) in vec2 aUV;
layout(location = 2) in vec4 aColor;


layout(push_constant) uniform uPushConstant
{
    vec2 uScale;
    vec2 uTranslate;
} pc;

layout(location = 0) out struct
{
    vec4 Color;
    vec2 UV;
} Out;

out gl_PerVertex
{
        vec4 gl_Position;
        float gl_PointSize;
};

void main()
{
    Out.Color = aColor;
    Out.UV = aUV;
    gl_Position = vec4(aPos*pc.uScale+pc.uTranslate, 0, 1);
}
 

 

Frag:

 

#version 450 core
layout(location = 0, index = 0) out vec4 fColor;

layout(set=0, binding=0) uniform sampler2D sTexture;

layout (location = 0) in struct
{
     vec4 Color;
     vec2 UV;
} In;

void main()
{
    fColor = In.Color * texture(sTexture, In.UV.st);
}
Edited by JoeJ

Share this post


Link to post
Share on other sites

This topic is 406 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this