Godot Version
4.2.1 macos arm
Question
I’m trying to write a compute shader which requires atomic operations, specifically I’m trying to use imageAtomicAdd (imageAtomicAdd reference page).
This basic shader does not compile:
#[compute]
#version 450
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
layout(rgba32f, binding = 0) uniform coherent image2D image_out;
void main() {
ivec2 pixel = ivec2(gl_GlobalInvocationID.xy);
imageAtomicAdd(image_out, pixel, 500); //arbitrary uint to test
}
The error godot shows is:
ERROR: 0:9: 'imageAtomicAdd' : required extension not requested: GL_EXT_shader_atomic_float
If I add the line:
#extension GL_EXT_shader_atomic_float:enable
that error goes away:
Shader stage compiled without errors.
However, I now get an error at runtime:
Node2D.gd:44 @ setup_compute(): vkCreateComputePipelines failed with error -1000012000.
Got the hint reading another forum post that it may be significant that this is a ‘vk’ (vulkan) error, and a ‘gl’ (opengl) extension might not work? So I tried instead using:
#extension VK_EXT_shader_atomic_float:enable
That gives the original required extension not requested
error, plus this warning:
WARNING: 0:3: '#extension' : extension not supported: VK_EXT_shader_atomic_float
If anyone knows how I can make these extensions work, or otherwise how to perform an imageAtomicAdd operation, I would be very grateful! Thanks!