From 06ad146d9ffd430f0965d2585cbf4b669c7dd125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Tue, 10 Feb 2015 14:22:56 -0800 Subject: [PATCH] Updated compute shader header. --- src/bgfx_compute.sh | 31 ++++++++++++++++++++++++++----- src/bgfx_p.h | 2 +- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/bgfx_compute.sh b/src/bgfx_compute.sh index 2ce9b608..5ad2959b 100644 --- a/src/bgfx_compute.sh +++ b/src/bgfx_compute.sh @@ -20,6 +20,10 @@ 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); } #define SHARED groupshared @@ -38,6 +42,16 @@ vec4 imageLoad(Texture2D _image, ivec2 _uv) return _image.Load(uint3(_uv.xy, 0) ); } +uint imageLoad(Texture2D _image, ivec2 _uv) +{ + return _image.Load(uint3(_uv.xy, 0) ); +} + +uint imageLoad(RWTexture2D _image, ivec2 _uv) +{ + return _image[_uv.xy]; +} + ivec2 imageSize(Texture2D _image) { ivec2 result; @@ -45,11 +59,6 @@ ivec2 imageSize(Texture2D _image) return result; } -//vec4 imageLoad(RWTexture2D _image, ivec2 _uv) -//{ -// return _image[_uv]; -//} - ivec2 imageSize(RWTexture2D _image) { ivec2 result; @@ -57,11 +66,23 @@ ivec2 imageSize(RWTexture2D _image) return result; } +ivec2 imageSize(RWTexture2D _image) +{ + ivec2 result; + _image.GetDimensions(result.x, result.y); + return result; +} + void imageStore(RWTexture2D _image, ivec2 _uv, vec4 _rgba) { _image[_uv] = _rgba; } +void imageStore(RWTexture2D _image, ivec2 _uv, uvec4 _r) +{ + _image[_uv] = _r.x; +} + #define __ATOMIC_IMPL_TYPE(_genType, _glFunc, _dxFunc) \ _genType _glFunc(_genType _mem, _genType _data) \ { \ diff --git a/src/bgfx_p.h b/src/bgfx_p.h index e158b602..c0b2ad71 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -2178,7 +2178,7 @@ namespace bgfx return ptr; } - BGFX_API_FUNC(DynamicVertexBufferHandle createDynamicVertexBuffer(uint16_t _num, const VertexDecl& _decl, uint8_t _flags) ) + BGFX_API_FUNC(DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexDecl& _decl, uint8_t _flags) ) { DynamicVertexBufferHandle handle = BGFX_INVALID_HANDLE; uint32_t size = strideAlign16( (_num+1)*_decl.m_stride, _decl.m_stride);