GPU/ShaderGen: Use sample instead of load at 1x as well

Consistency. Mali ends up ever-so-slightly faster with sample versus
texel loads, apparently.

Also fixes compile errors when using texture filtering on GLSL ES.
This commit is contained in:
Stenzek 2024-12-12 20:19:27 +10:00
parent db848d1381
commit 8f19912c64
No known key found for this signature in database
3 changed files with 5 additions and 3 deletions

View File

@ -883,7 +883,7 @@ float4 SampleFromVRAM(TEXPAGE_VALUE texpage, float2 coords)
#if !UPSCALED #if !UPSCALED
uint2 icoord = ApplyTextureWindow(FloatToIntegerCoords(coords)); uint2 icoord = ApplyTextureWindow(FloatToIntegerCoords(coords));
uint2 vicoord = (texpage.xy + icoord) & uint2(1023, 511); uint2 vicoord = (texpage.xy + icoord) & uint2(1023, 511);
return LOAD_TEXTURE(samp0, int2(vicoord), 0); return SAMPLE_TEXTURE_LEVEL(samp0, float2(vicoord) * RCP_VRAM_SIZE, 0.0);
#else #else
// Coordinates are already upscaled, we need to downscale them to apply the texture // Coordinates are already upscaled, we need to downscale them to apply the texture
// window, then re-upscale/offset. We can't round here, because it could result in // window, then re-upscale/offset. We can't round here, because it could result in
@ -979,7 +979,7 @@ float4 SampleFromVRAM(TEXPAGE_VALUE texpage, float2 coords)
ialpha = 1.0; ialpha = 1.0;
#elif TEXTURE_FILTERING #elif TEXTURE_FILTERING
#if PAGE_TEXTURE #if PAGE_TEXTURE
FilteredSampleFromVRAM(int2(0, 0), v_tex0, v_uv_limits, texcol, ialpha); FilteredSampleFromVRAM(VECTOR_BROADCAST(TEXPAGE_VALUE, 0u), v_tex0, v_uv_limits, texcol, ialpha);
#else #else
FilteredSampleFromVRAM(v_texpage, v_tex0, v_uv_limits, texcol, ialpha); FilteredSampleFromVRAM(v_texpage, v_tex0, v_uv_limits, texcol, ialpha);
#endif #endif

View File

@ -5,4 +5,4 @@
#include "common/types.h" #include "common/types.h"
static constexpr u32 SHADER_CACHE_VERSION = 23; static constexpr u32 SHADER_CACHE_VERSION = 24;

View File

@ -298,6 +298,7 @@ void ShaderGen::WriteHeader(std::stringstream& ss, bool enable_rov /* = false */
ss << "#define LOAD_TEXTURE_BUFFER(name, index) texelFetch(name, index)\n"; ss << "#define LOAD_TEXTURE_BUFFER(name, index) texelFetch(name, index)\n";
ss << "#define BEGIN_ARRAY(type, size) type[size](\n"; ss << "#define BEGIN_ARRAY(type, size) type[size](\n";
ss << "#define END_ARRAY )\n"; ss << "#define END_ARRAY )\n";
ss << "#define VECTOR_BROADCAST(type, value) (type(value))\n";
ss << "float saturate(float value) { return clamp(value, 0.0, 1.0); }\n"; ss << "float saturate(float value) { return clamp(value, 0.0, 1.0); }\n";
ss << "float2 saturate(float2 value) { return clamp(value, float2(0.0, 0.0), float2(1.0, 1.0)); }\n"; ss << "float2 saturate(float2 value) { return clamp(value, float2(0.0, 0.0), float2(1.0, 1.0)); }\n";
@ -344,6 +345,7 @@ void ShaderGen::WriteHeader(std::stringstream& ss, bool enable_rov /* = false */
ss << "#define LOAD_TEXTURE_BUFFER(name, index) name.Load(index)\n"; ss << "#define LOAD_TEXTURE_BUFFER(name, index) name.Load(index)\n";
ss << "#define BEGIN_ARRAY(type, size) {\n"; ss << "#define BEGIN_ARRAY(type, size) {\n";
ss << "#define END_ARRAY }\n"; ss << "#define END_ARRAY }\n";
ss << "#define VECTOR_BROADCAST(type, value) ((type)(value))\n";
} }
ss << "\n"; ss << "\n";