Graphics
Intel® graphics drivers and software, compatibility, troubleshooting, performance, and optimization
22654 Discussions

SPIR-V GLSL imageSize returns 0 on OpenGL 4.6 with Intel UHD Graphics

debaze
Beginner
757 Views

Hello.

I have a test application which copies the width and height of an image2D to a shader storage buffer. The shader I'm using is a SPIR-V compute shader generated from GLSL.

I'm using GLSL's imageSize function to get the image dimensions, however it returns 0.

I've written an minimum reproducible sample to demonstrate the issue.

 

Description

 

I have an HP Victus (7L1J7EA) laptop with an Intel Core i5-12450H and Windows 11 Home 24H2.

I can reproduce the issue when every requirement below is met:

  • The graphics API is OpenGL 4.6
  • The GPU is Intel UHD Graphics for 12th Gen Intel Processors (Intel Graphics Driver 31.0.101.4502)
  • The shader code is a SPIR-V binary generated from GLSL

I cannot reproduce the issue when at least one of the requirements below is not met:

  • The graphics API is Vulkan
  • The GPU is an AMD Radeon RX 7900 XTX
  • The GPU is an Intel UHD Graphics 770 (Intel Core i7-13700K)
  • The GPU is a Nvidia GeForce RTX 3050
  • The shader code is a GLSL string

I've not found many issues about it but this may be related.

 

Steps to reproduce

 

  1. Install GLFW, glad and the Vulkan SDK.
  2. Link GLFW and glad to the project.
  3. Run ImageSize.bat to generate the SPIR-V binary.
  4. Build and run the project.

 

Observations

 

Expected console output:

Using Intel(R) UHD Graphics
Width = 64
Height = 32
 

Actual console output:

Using Intel(R) UHD Graphics
Width = 0
Height = 0

 

This is not a blocking issue since I can pass the dimensions as an uniform but it is still an invalid behavior.

Labels (1)
0 Kudos
8 Replies
VonM_Intel
Moderator
705 Views

Hello debaze,

Thank you for providing such a clear and detailed report, including a reproducible test case and hardware/software conditions. Your observations are highly valuable, and your investigative approach is commendable. I would like to know the following details:

  • What target environment and version were specified during SPIR-V compilation?
  • Is the image2D declared with proper layout qualifiers (like binding, format)?
  • Are you using any intermediate tools or post-processing steps (e.g., SPIR-V optimizer, reflection tools) between GLSL and execution?
  • Can you confirm if the shader is successfully compiled and linked at runtime, and no OpenGL errors (e.g.,
  • GL_INVALID_OPERATION) are being thrown?
  • Does the issue occur with other driver versions (newer or older than 31.0.101.4502)?

 

Best regards,

Von M.

Intel Customer Support Technician


0 Kudos
debaze
Beginner
633 Views

Edit: My reply didn't appear on the discussion, so I copied it below.

0 Kudos
debaze
Beginner
438 Views

Hello.

Thank you for your reply.

 

The target environment is vulkan1.0. glslangvalidator -v returns:

Glslang Version: 11:15.0.0
ESSL Version: OpenGL ES GLSL 3.20 glslang Khronos. 15.0.0
GLSL Version: 4.60 glslang Khronos. 15.0.0
SPIR-V Version 0x00010600, Revision 1
GLSL.std.450 Version 100, Revision 1
Khronos Tool ID 8
SPIR-V Generator Version 11
GL_KHR_vulkan_glsl version 100
ARB_GL_gl_spirv version 100

 

The texture is declared as a readonly RGBA8 image2D. Here is the full GLSL code for the compute shader (also available on the MRS).

#version 460

layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

layout(set = 0, binding = 0, rgba8) uniform readonly image2D image;
layout(set = 0, binding = 1) buffer OutputBuffer {
	uint width;
	uint height;
} outputBuffer;

void main() {
	uvec2 size = uvec2(imageSize(image));

	outputBuffer.width = size[0];
	outputBuffer.height = size[1];
}

 

I could not test with OpenGL < 4.6 because SPIR-V support was added in that version. However I tried changing the GLSL version to 430, 440 and 450 and the issue was still there.

 

The image is bound like this:

glBindImageTexture(0, texture, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA8);

 

I'm not using any intermediate tool/post-processing step in both the project in which I found the bug and the minimum reproducible sample.

 

The shader is successfully compiled and the program is successfully linked.

No OpenGL errors are thrown (I have debug output enabled).

 

I have got the issue with driver versions before 31.0.101.4502, but I don't have the version numbers.

 

Regards,

debaze

0 Kudos
debaze
Beginner
438 Views

Hello.

Thank you for your reply.

 

The target environment is vulkan1.0. glslangvalidator -v returns:

Glslang Version: 11:15.0.0
ESSL Version: OpenGL ES GLSL 3.20 glslang Khronos. 15.0.0
GLSL Version: 4.60 glslang Khronos. 15.0.0
SPIR-V Version 0x00010600, Revision 1
GLSL.std.450 Version 100, Revision 1
Khronos Tool ID 8
SPIR-V Generator Version 11
GL_KHR_vulkan_glsl version 100
ARB_GL_gl_spirv version 100

 

The texture is declared as a readonly RGBA8 image2D. Here is the full GLSL code for the compute shader (also available on the MRS).

#version 460

layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

layout(set = 0, binding = 0, rgba8) uniform readonly image2D image;
layout(set = 0, binding = 1) buffer OutputBuffer {
    uint width;
    uint height;
} outputBuffer;

void main() {
    uvec2 size = uvec2(imageSize(image));

    outputBuffer.width = size[0];
    outputBuffer.height = size[1];
}

 

I could not test with OpenGL < 4.6 because SPIR-V support was added in that version. However I tried changing the GLSL version to 430, 440 and 450 and the issue was still there.

 

The image is bound like this:

glBindImageTexture(0, texture, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA8);

 

I'm not using any intermediate tool/post-processing step in both the project in which I found the bug and the minimum reproducible sample.

 

The shader is successfully compiled and the program is successfully linked.

No OpenGL errors are thrown (I have debug output enabled).

 

I have got the issue with driver versions before 31.0.101.4502, but I don't have the version numbers.

 

Regards,

debaze

0 Kudos
debaze
Beginner
653 Views

Hello.

Thank you for your reply.

 

The target environment is vulkan1.0. glslangvalidator -v returns:

Glslang Version: 11:15.0.0
ESSL Version: OpenGL ES GLSL 3.20 glslang Khronos. 15.0.0
GLSL Version: 4.60 glslang Khronos. 15.0.0
SPIR-V Version 0x00010600, Revision 1
GLSL.std.450 Version 100, Revision 1
Khronos Tool ID 8
SPIR-V Generator Version 11
GL_KHR_vulkan_glsl version 100
ARB_GL_gl_spirv version 100

 

The texture is declared as a readonly RGBA8 image2D. Here is the full GLSL code for the compute shader (also available on the MRS).

#version 460

layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

layout(set = 0, binding = 0, rgba8) uniform readonly image2D image;
layout(set = 0, binding = 1) buffer OutputBuffer {
uint width;
uint height;
} outputBuffer;

void main() {
uvec2 size = uvec2(imageSize(image));

outputBuffer.width = size[0];
outputBuffer.height = size[1];
}

 

I could not test with OpenGL < 4.6 because SPIR-V support was added in that version (I didn't try with the pre-4.6 extension). However I tried changing the GLSL version to 430/440/450 and the issue was still there.

 

The image is bound like this:

glBindImageTexture(0, texture, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA8);

 

I'm not using any intermediate tool/post-processing step in both the project in which I found the bug and the minimum reproducible sample.

 

The shader is successfully compiled and the program is successfully linked.

No OpenGL errors are thrown (debug output is enabled).

 

I've got the issue with driver versions before 31.0.101.4502, but I don't remember the exact version numbers.

 

Regards,

debaze

0 Kudos
TheExpertGuy
New Contributor I
577 Views

Hey man, ...so while this might not be a deal breaker, it does look like a possible quirk or non-compliance on Intels side when it comes to handling SPIR-V in OpenGL .. yes specifically with how their driver interprets things Definitely feels like something under the hood isn’t playing nice. Here’s what Id suggest trying next,,,
Well, grab the latest Intel driver from their site or run the Intel® Driver & Support Assistant. There might’ve been SPIR-V-related fixes after version 31.0.101.4502 that patch this exact behavior. Try Skipping SPIR-V for Now-Since plain GLSL works, it’s clear this is isolated to SPIR-V usage. That’s a solid workaround for now... Double-Check Your Image Binding Setup-Make sure your image2D is correctly bound layout, format, binding point, and qualifiers. Intel’s OpenGL SPIR-V path might be more picky than others when it comes to exact declarations.

0 Kudos
jbruceyu
New Contributor I
566 Views

Intel's OpenGL SPIR-V implementation on UHD Graphics for 12th Gen CPUs. The use of imageSize() in compute shaders via SPIR-V paths. It is likely not an application bug, but a low-level issue in the OpenGL SPIR-V front-end or image handling pipeline in the affected driver version. 

try these:

Confirm SPIR-V Compilation Details.

Make sure the image variable in GLSL has appropriate qualifiers (binding, format, and readonly/writeonly) to ensure correct layout in SPIR-V.

Example:

 

glsl
layout (binding = 0, rgba8) uniform readonly image2D inputImage;

 

0 Kudos
debaze
Beginner
544 Views

Thank you for your replies.

 

@TheExpertGuy: The driver is up-to-date at the time of writing (31.0.101.4502). Thank you for the workaround. This is not a blocking issue on my side (most of the time I'm testing on discrete GPUs but I figured I should also try the integrated one). I'm not really searching for a workaround, but to get Intel to fix it because as @jbruceyu said it's likely not an application bug.

 

@jbruceyu: Here is how I'm creating + binding the texture in C++:

GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glBindImageTexture(0, texture, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA8);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 64, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
So, it's an 8-bit RGBA 2D texture of size 64x32, and it is bound to location 0 in READ_ONLY mode.
I declare it like this in GLSL:
layout(set = 0, binding = 0, rgba8) uniform readonly image2D image;
 
I'm using this to generate SPIR-V:
glslangvalidator -V ImageSize.comp -o ImageSize.comp.spv
 
You can find the full example code here.
 
Regards,
debaze
0 Kudos
Reply