Empty error list on shader compilation

Hello !
I’m getting an error that seems specific to my PC. I’m on windows, with an AMD Radeon RX560X GPU, and it is not present on other pcs I tried my program on.

I’m trying to compile a shader that uses an SSBO, and it is not compiling (some casts are missing in it), except the glGetShaderInfoLog returns “Vertex shader failed to compile with the following errors:” without any error printed afterwards.

here is the shader code :

#version 450

struct Rect 
{
	float x, y, w, h;
	float clip_x, clip_y, clip_w, clip_h;
	int color;
};

struct Circle
{
	float x, y, r;
	int color;
	int subdivisions;
};

struct Draw_Command
{
	Rect rect;
	Circle circle;
};

//struct Commands
//{
//	Draw_Command commands[1000];
//};
//Commands draw_commands;

layout(std430, binding=3) readonly buffer draw_commands
{
	Draw_Command commands[];
};

out vec4 frag_color;
out vec2 frag_pos;
out vec2 frag_uv;

uniform vec2 screenSize;

void main()
{
	int primitive_type = gl_VertexID % (1 << 4);
	int primitive_index = (gl_VertexID >> 4) % (1 << 4);
	int vertex_index = gl_VertexID >> 8;

	vec2 pos;
	if(primitive_type == 0)
	{
		Rect rect = draw_commands.commands[primitive_index].rect;
		pos.x = (vertex_index % 2) ? rect.x : rect.x + rect.w;
		pos.y = (vertex_index / 2) ? rect.y : rect.y + rect.h;
		frag_uv.x = (vertex_index % 2) ? rect.clip_x : rect.clip_x + rect.clip_w;
		frag_uv.y = (vertex_index / 2) ? rect.clip_y : rect.clip_y + rect.clip_h;
		frag_color = vec4(rect.color%256, (rect.color >> 8) % 256, (rect.color >> 16) % 256, (rect.color >> 24));
	}
	else
	{

	}
    vec2 screenPos = pos.xy * 2 / screenSize - vec2(1, 1);
    gl_Position = vec4(screenPos.x, -screenPos.y, 0, 1);
}

Even stranger, it compiles if I replace the draw_commands definition by the lines that are commented, even though it does not solve the cast problems that is supposed to make the compilation fail.

I tried to update my graphics drivers but it did not solve the problem.

This should be

		Rect rect = commands[primitive_index].rect;

draw_commands is a block name, not an instance name. The block members exist in the global scope.

1 Like

Oh thanks, it makes my shader compile :grinning:
Any idea why it did not output any error ? Other compiling errors (like syntax errors) are properly displayed.
I hope I won’t have any other similar problems, no error makes debugging really hard…

In the future if/when you have similar problems, you might consider copy/pasting it into here:

Select GLSL in the top-left choice box. And in the mid-panel, select glslang / trunk / vert / OpenGL / SPIR-V.

This pointed out the 1st error immediately:

ERROR: ...:49: 'draw_commands' : cannot be used (maybe an instance name is needed) 
ERROR: ...:49: 'draw_commands' : undeclared identifier 
ERROR: ...:49: '=' :  cannot convert from ' temp float' to 
     ' temp structure{ global float x,  global float y,  global float w,  global float h,  
     global float clip_x,  global float clip_y,  global float clip_w,  global float clip_h,  
     global int color}'
ERROR: ...:49: '' : compilation terminated 
ERROR: 4 compilation errors.  No code generated.

Iterative fixing the source live also pointed out the missing bool() casts in the next 4 lines needed to clear implicit int-to-bool conversions:

		Rect rect = commands[primitive_index].rect;
		pos.x = bool(vertex_index % 2) ? rect.x : rect.x + rect.w;
		pos.y = bool(vertex_index / 2) ? rect.y : rect.y + rect.h;
		frag_uv.x = bool(vertex_index % 2) ? rect.clip_x : rect.clip_x + rect.clip_w;
		frag_uv.y = bool(vertex_index / 2) ? rect.clip_y : rect.clip_y + rect.clip_h;

You might show the code for how your compiling, linking, and querying for compile and link error logs.

Also, which GPU and GL driver are you using to compile/link?

Thank you for the link, that tool looks really useful :slight_smile:
I think there was a problem with some drivers, my graphic card started to become unstable these days, and my whole pc started to get freezes that forced me to hard reboot, until the last windows update, that solved everything at once. I’m quite relieved :grin:
Thank you for your quick and useful answers, it allowed me to keep working even with that problem.