Skip to content

Commit

Permalink
Merge pull request #2186 from KhronosGroup/64bit-images
Browse files Browse the repository at this point in the history
GLSL: Implement 64-bit image support.
  • Loading branch information
HansKristian-Work authored Aug 17, 2023
2 parents e7e2e8c + 5e3ea64 commit a3f0268
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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;
}

16 changes: 16 additions & 0 deletions shaders-no-opt/vulkan/comp/image-64bit.vk.nocompat.comp
Original file line number Diff line number Diff line change
@@ -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);
}
12 changes: 12 additions & 0 deletions spirv_glsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,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;
Expand Down Expand Up @@ -15348,6 +15352,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:
Expand Down

0 comments on commit a3f0268

Please sign in to comment.