From 5a4afee0eac27e5eaca8ca20493d366fe0984ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Thu, 19 Feb 2015 16:23:27 -0800 Subject: [PATCH] Fixed compute unsigned image. --- src/bgfx_compute.sh | 33 +++++++++++++++++++++------------ src/renderer_gl.cpp | 4 ++++ src/renderer_gl.h | 16 ++++++++++++++++ 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/src/bgfx_compute.sh b/src/bgfx_compute.sh index f0a7b029..4bb11dcd 100644 --- a/src/bgfx_compute.sh +++ b/src/bgfx_compute.sh @@ -16,14 +16,21 @@ float uintBitsToFloat(uint _x) { return asfloat(_x); } vec2 uintBitsToFloat(uint2 _x) { return asfloat(_x); } vec3 uintBitsToFloat(uint3 _x) { return asfloat(_x); } vec4 uintBitsToFloat(uint4 _x) { return asfloat(_x); } -uint floatBitsToUint(float _x) { return asuint(_x); } -uvec2 floatBitsToUint(vec2 _x) { return asuint(_x); } -uvec3 floatBitsToUint(vec3 _x) { return asuint(_x); } -uvec4 floatBitsToUint(vec4 _x) { return asuint(_x); } -int floatBitsToInt(float _x) { return asint(_x); } -ivec2 floatBitsToInt(vec2 _x) { return asint(_x); } -ivec3 floatBitsToInt(vec3 _x) { return asint(_x); } -ivec4 floatBitsToInt(vec4 _x) { return asint(_x); } + +uint floatBitsToUint(float _x) { return asuint(_x); } +uvec2 floatBitsToUint(vec2 _x) { return asuint(_x); } +uvec3 floatBitsToUint(vec3 _x) { return asuint(_x); } +uvec4 floatBitsToUint(vec4 _x) { return asuint(_x); } + +int floatBitsToInt(float _x) { return asint(_x); } +ivec2 floatBitsToInt(vec2 _x) { return asint(_x); } +ivec3 floatBitsToInt(vec3 _x) { return asint(_x); } +ivec4 floatBitsToInt(vec4 _x) { return asint(_x); } + +uint bitfieldReverse(uint _x) { return reversebits(_x); } +uint2 bitfieldReverse(uint2 _x) { return reversebits(_x); } +uint3 bitfieldReverse(uint3 _x) { return reversebits(_x); } +uint4 bitfieldReverse(uint4 _x) { return reversebits(_x); } uint packHalf2x16(vec2 _x) { @@ -52,14 +59,16 @@ vec4 imageLoad(Texture2D _image, ivec2 _uv) return _image.Load(uint3(_uv.xy, 0) ); } -uint imageLoad(Texture2D _image, ivec2 _uv) +uint4 imageLoad(Texture2D _image, ivec2 _uv) { - return _image.Load(uint3(_uv.xy, 0) ); + uint rr = _image.Load(uint3(_uv.xy, 0) ); + return uint4(rr, rr, rr, rr); } -uint imageLoad(RWTexture2D _image, ivec2 _uv) +uint4 imageLoad(RWTexture2D _image, ivec2 _uv) { - return _image[_uv.xy]; + uint rr = _image[_uv.xy]; + return uint4(rr, rr, rr, rr); } ivec2 imageSize(Texture2D _image) diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index eb25d6a7..8b880f80 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -2554,6 +2554,10 @@ namespace bgfx GLSL_TYPE(GL_IMAGE_2D); GLSL_TYPE(GL_IMAGE_3D); GLSL_TYPE(GL_IMAGE_CUBE); + GLSL_TYPE(GL_UNSIGNED_INT_IMAGE_1D); + GLSL_TYPE(GL_UNSIGNED_INT_IMAGE_2D); + GLSL_TYPE(GL_UNSIGNED_INT_IMAGE_3D); + GLSL_TYPE(GL_UNSIGNED_INT_IMAGE_CUBE); } #undef GLSL_TYPE diff --git a/src/renderer_gl.h b/src/renderer_gl.h index 1218392b..6d0523e5 100644 --- a/src/renderer_gl.h +++ b/src/renderer_gl.h @@ -472,6 +472,22 @@ typedef uint64_t GLuint64; # define GL_IMAGE_CUBE 0x9050 #endif // GL_IMAGE_CUBE +#ifndef GL_UNSIGNED_INT_IMAGE_1D +# define GL_UNSIGNED_INT_IMAGE_1D 0x9062 +#endif // GL_UNSIGNED_INT_IMAGE_1D + +#ifndef GL_UNSIGNED_INT_IMAGE_2D +# define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#endif // GL_UNSIGNED_INT_IMAGE_2D + +#ifndef GL_UNSIGNED_INT_IMAGE_3D +# define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#endif // GL_UNSIGNED_INT_IMAGE_3D + +#ifndef GL_UNSIGNED_INT_IMAGE_CUBE +# define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#endif // GL_UNSIGNED_INT_IMAGE_CUBE + #ifndef GL_PROGRAM_INPUT # define GL_PROGRAM_INPUT 0x92E3 #endif // GL_PROGRAM_INPUT