mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-07 20:15:32 +00:00
GPU/HW: Use texture loads for native resolution
Hopefully work around sampling precision issues in older AMD drivers and Mali Midgard if we're lucky. But I don't have anything this old to verify with.
This commit is contained in:
parent
080eccd8fc
commit
19ca9cb47d
@ -883,7 +883,13 @@ float4 SampleFromVRAM(TEXPAGE_VALUE texpage, float2 coords)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// load colour/palette
|
// load colour/palette
|
||||||
|
// use texelFetch()/load for native resolution to work around point sampling precision
|
||||||
|
// in some drivers, such as older AMD and Mali Midgard
|
||||||
|
#if !UPSCALED
|
||||||
|
float4 texel = LOAD_TEXTURE(samp0, int2(vicoord), 0);
|
||||||
|
#else
|
||||||
float4 texel = SAMPLE_TEXTURE_LEVEL(samp0, float2(vicoord) * RCP_VRAM_SIZE, 0.0);
|
float4 texel = SAMPLE_TEXTURE_LEVEL(samp0, float2(vicoord) * RCP_VRAM_SIZE, 0.0);
|
||||||
|
#endif
|
||||||
uint vram_value = RGBA8ToRGBA5551(texel);
|
uint vram_value = RGBA8ToRGBA5551(texel);
|
||||||
|
|
||||||
// apply palette
|
// apply palette
|
||||||
@ -898,13 +904,17 @@ float4 SampleFromVRAM(TEXPAGE_VALUE texpage, float2 coords)
|
|||||||
uint2 palette_icoord = uint2(((texpage.z + palette_index) & 0x3FFu), texpage.w);
|
uint2 palette_icoord = uint2(((texpage.z + palette_index) & 0x3FFu), texpage.w);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !UPSCALED
|
||||||
|
return LOAD_TEXTURE(samp0, int2(palette_icoord), 0);
|
||||||
|
#else
|
||||||
return SAMPLE_TEXTURE_LEVEL(samp0, float2(palette_icoord) * RCP_VRAM_SIZE, 0.0);
|
return SAMPLE_TEXTURE_LEVEL(samp0, float2(palette_icoord) * RCP_VRAM_SIZE, 0.0);
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
// Direct texturing - usually render-to-texture effects.
|
// Direct texturing - usually render-to-texture effects.
|
||||||
#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 SAMPLE_TEXTURE_LEVEL(samp0, float2(vicoord) * RCP_VRAM_SIZE, 0.0);
|
return LOAD_TEXTURE(samp0, int2(vicoord), 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
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
|
// SPDX-FileCopyrightText: 2019-2025 Connor McLaughlin <stenzek@gmail.com>
|
||||||
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
|
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
|
||||||
|
|
||||||
#include "gpu_thread.h"
|
#include "gpu_thread.h"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
|
// SPDX-FileCopyrightText: 2019-2025 Connor McLaughlin <stenzek@gmail.com>
|
||||||
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
|
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
|
|
||||||
static constexpr u32 SHADER_CACHE_VERSION = 27;
|
static constexpr u32 SHADER_CACHE_VERSION = 28;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user