diff --git a/src/bgfx_shader.sh b/src/bgfx_shader.sh index f5f791645..5002c0738 100644 --- a/src/bgfx_shader.sh +++ b/src/bgfx_shader.sh @@ -242,6 +242,13 @@ vec4 bgfxTexelFetch(BgfxSampler2D _sampler, ivec2 _coord, int _lod) return _sampler.m_texture.Load(ivec3(_coord, _lod) ); } +vec2 bgfxTextureSize(BgfxSampler2D _sampler, int _lod) +{ + vec2 result; + _sampler.m_texture.GetDimensions(result.x, result.y); + return result; +} + ivec4 bgfxTexelFetch(BgfxISampler2D _sampler, ivec2 _coord, int _lod) { return _sampler.m_texture.Load(ivec3(_coord, _lod) ); @@ -262,6 +269,13 @@ vec4 bgfxTexelFetch(BgfxSampler3D _sampler, ivec3 _coord, int _lod) return _sampler.m_texture.Load(ivec4(_coord, _lod) ); } +vec3 bgfxTextureSize(BgfxSampler3D _sampler, int _lod) +{ + vec3 result; + _sampler.m_texture.GetDimensions(result.x, result.y, result.z); + return result; +} + # define SAMPLER2D(_name, _reg) \ uniform SamplerState _name ## Sampler : REGISTER(s, _reg); \ uniform Texture2D _name ## Texture : REGISTER(t, _reg); \ @@ -322,6 +336,7 @@ vec4 bgfxTexelFetch(BgfxSampler3D _sampler, ivec3 _coord, int _lod) # define textureCubeLod(_sampler, _coord, _level) bgfxTextureCubeLod(_sampler, _coord, _level) # define texelFetch(_sampler, _coord, _lod) bgfxTexelFetch(_sampler, _coord, _lod) +# define textureSize(_sampler, _lod) bgfxTextureSize(_sampler, _lod) # else # define sampler2DShadow sampler2D @@ -477,6 +492,24 @@ uvec3 uvec3_splat(uint _x) { return uvec3(_x, _x, _x); } uvec4 uvec4_splat(uint _x) { return uvec4(_x, _x, _x, _x); } #endif // BGFX_SHADER_LANGUAGE_GLSL >= 130 || BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_SPIRV +mat4 mtxFromRows(vec4 _0, vec4 _1, vec4 _2, vec4 _3) +{ +#if BGFX_SHADER_LANGUAGE_GLSL + return transpose(mat4(_0, _1, _2, _3) ); +#else + return mat4(_0, _1, _2, _3); +#endif // BGFX_SHADER_LANGUAGE_GLSL +} + +mat4 mtxFromCols(vec4 _0, vec4 _1, vec4 _2, vec4 _3) +{ +#if BGFX_SHADER_LANGUAGE_GLSL + return mat4(_0, _1, _2, _3); +#else + return transpose(mat4(_0, _1, _2, _3) ); +#endif // BGFX_SHADER_LANGUAGE_GLSL +} + uniform vec4 u_viewRect; uniform vec4 u_viewTexel; uniform mat4 u_view;