GLSL: Implement 64-bit image support.

This commit is contained in:
Hans-Kristian Arntzen 2023-08-17 12:17:37 +02:00
parent 637c211c6f
commit 5e3ea64843
3 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,22 @@
#version 450
#if defined(GL_ARB_gpu_shader_int64)
#extension GL_ARB_gpu_shader_int64 : require
#else
#error No extension available for 64-bit integers.
#endif
#extension GL_EXT_shader_image_int64 : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(set = 0, binding = 0, r64ui) uniform u64image2D uimg;
layout(set = 0, binding = 1, r64i) uniform i64image2D iimg;
void main()
{
uint64_t uv = imageLoad(uimg, ivec2(gl_GlobalInvocationID.xy + uvec2(50u))).x;
int64_t iv = imageLoad(iimg, ivec2(gl_GlobalInvocationID.xy + uvec2(50u))).x;
uint64_t _52 = imageAtomicMax(uimg, ivec2(gl_GlobalInvocationID.xy), uv);
uv = _52;
int64_t _59 = imageAtomicMax(iimg, ivec2(gl_GlobalInvocationID.xy), iv);
iv = _59;
}

View File

@ -0,0 +1,16 @@
#version 450
#extension GL_ARB_gpu_shader_int64 : require
#extension GL_EXT_shader_image_int64 : require
layout(local_size_x = 1) in;
layout(set = 0, binding = 0, r64ui) uniform u64image2D uimg;
layout(set = 0, binding = 1, r64i) uniform i64image2D iimg;
void main()
{
uint64_t uv = imageLoad(uimg, ivec2(gl_GlobalInvocationID.xy + 50)).x;
int64_t iv = imageLoad(iimg, ivec2(gl_GlobalInvocationID.xy + 50)).x;
uv = imageAtomicMax(uimg, ivec2(gl_GlobalInvocationID.xy), uv);
iv = imageAtomicMax(iimg, ivec2(gl_GlobalInvocationID.xy), iv);
}

View File

@ -1486,6 +1486,10 @@ const char *CompilerGLSL::format_to_glsl(spv::ImageFormat format)
return "rg8i";
case ImageFormatR16i:
return "r16i";
case ImageFormatR64i:
return "r64i";
case ImageFormatR64ui:
return "r64ui";
default:
case ImageFormatUnknown:
return nullptr;
@ -15345,6 +15349,14 @@ string CompilerGLSL::image_type_glsl(const SPIRType &type, uint32_t id)
switch (imagetype.basetype)
{
case SPIRType::Int64:
res = "i64";
require_extension_internal("GL_EXT_shader_image_int64");
break;
case SPIRType::UInt64:
res = "u64";
require_extension_internal("GL_EXT_shader_image_int64");
break;
case SPIRType::Int:
case SPIRType::Short:
case SPIRType::SByte: