From f80d31f1f423589968077dd34b43410250cfa722 Mon Sep 17 00:00:00 2001 From: pezcode Date: Wed, 25 Aug 2021 02:26:03 +0200 Subject: [PATCH] HLSL: add textureGather for all components (#2595) --- src/bgfx_shader.sh | 54 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/src/bgfx_shader.sh b/src/bgfx_shader.sh index 15cee368b..45c59775b 100644 --- a/src/bgfx_shader.sh +++ b/src/bgfx_shader.sh @@ -315,17 +315,55 @@ vec2 bgfxTextureSize(BgfxUSampler2D _sampler, int _lod) return result; } -vec4 bgfxTextureGather(BgfxSampler2D _sampler, vec2 _coord) +vec4 bgfxTextureGather0(BgfxSampler2D _sampler, vec2 _coord) { - return _sampler.m_texture.GatherRed(_sampler.m_sampler, _coord ); + return _sampler.m_texture.GatherRed(_sampler.m_sampler, _coord); } -vec4 bgfxTextureGatherOffset(BgfxSampler2D _sampler, vec2 _coord, ivec2 _offset) +vec4 bgfxTextureGather1(BgfxSampler2D _sampler, vec2 _coord) { - return _sampler.m_texture.GatherRed(_sampler.m_sampler, _coord, _offset ); + return _sampler.m_texture.GatherGreen(_sampler.m_sampler, _coord); } -vec4 bgfxTextureGather(BgfxSampler2DArray _sampler, vec3 _coord) +vec4 bgfxTextureGather2(BgfxSampler2D _sampler, vec2 _coord) { - return _sampler.m_texture.GatherRed(_sampler.m_sampler, _coord ); + return _sampler.m_texture.GatherBlue(_sampler.m_sampler, _coord); +} +vec4 bgfxTextureGather3(BgfxSampler2D _sampler, vec2 _coord) +{ + return _sampler.m_texture.GatherAlpha(_sampler.m_sampler, _coord); +} + +vec4 bgfxTextureGatherOffset0(BgfxSampler2D _sampler, vec2 _coord, ivec2 _offset) +{ + return _sampler.m_texture.GatherRed(_sampler.m_sampler, _coord, _offset); +} +vec4 bgfxTextureGatherOffset1(BgfxSampler2D _sampler, vec2 _coord, ivec2 _offset) +{ + return _sampler.m_texture.GatherGreen(_sampler.m_sampler, _coord, _offset); +} +vec4 bgfxTextureGatherOffset2(BgfxSampler2D _sampler, vec2 _coord, ivec2 _offset) +{ + return _sampler.m_texture.GatherBlue(_sampler.m_sampler, _coord, _offset); +} +vec4 bgfxTextureGatherOffset3(BgfxSampler2D _sampler, vec2 _coord, ivec2 _offset) +{ + return _sampler.m_texture.GatherAlpha(_sampler.m_sampler, _coord, _offset); +} + +vec4 bgfxTextureGather0(BgfxSampler2DArray _sampler, vec3 _coord) +{ + return _sampler.m_texture.GatherRed(_sampler.m_sampler, _coord); +} +vec4 bgfxTextureGather1(BgfxSampler2DArray _sampler, vec3 _coord) +{ + return _sampler.m_texture.GatherGreen(_sampler.m_sampler, _coord); +} +vec4 bgfxTextureGather2(BgfxSampler2DArray _sampler, vec3 _coord) +{ + return _sampler.m_texture.GatherBlue(_sampler.m_sampler, _coord); +} +vec4 bgfxTextureGather3(BgfxSampler2DArray _sampler, vec3 _coord) +{ + return _sampler.m_texture.GatherAlpha(_sampler.m_sampler, _coord); } ivec4 bgfxTexelFetch(BgfxISampler2D _sampler, ivec2 _coord, int _lod) @@ -440,8 +478,8 @@ vec3 bgfxTextureSize(BgfxSampler3D _sampler, int _lod) # define texelFetch(_sampler, _coord, _lod) bgfxTexelFetch(_sampler, _coord, _lod) # define texelFetchOffset(_sampler, _coord, _lod, _offset) bgfxTexelFetchOffset(_sampler, _coord, _lod, _offset) # define textureSize(_sampler, _lod) bgfxTextureSize(_sampler, _lod) -# define textureGather(_sampler, _coord) bgfxTextureGather(_sampler, _coord) -# define textureGatherOffset(_sampler, _coord, _offset) bgfxTextureGatherOffset(_sampler, _coord, _offset) +# define textureGather(_sampler, _coord, _comp) bgfxTextureGather ## _comp(_sampler, _coord) +# define textureGatherOffset(_sampler, _coord, _offset, _comp) bgfxTextureGatherOffset ## _comp(_sampler, _coord, _offset) # else # define sampler2DShadow sampler2D