From 078fc108626435debba180159ec9f9a2c9f169a3 Mon Sep 17 00:00:00 2001 From: Miksel12 Date: Sun, 31 Jan 2021 02:38:16 +0100 Subject: [PATCH] Add point sampling --- Source/Core/VideoCommon/GXPipelineTypes.h | 2 +- Source/Core/VideoCommon/PixelShaderGen.cpp | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Source/Core/VideoCommon/GXPipelineTypes.h b/Source/Core/VideoCommon/GXPipelineTypes.h index 1ddd853597a0..4ef702e49057 100644 --- a/Source/Core/VideoCommon/GXPipelineTypes.h +++ b/Source/Core/VideoCommon/GXPipelineTypes.h @@ -20,7 +20,7 @@ namespace VideoCommon // As pipelines encompass both shader UIDs and render states, changes to either of these should // also increment the pipeline UID version. Incrementing the UID version will cause all UID // caches to be invalidated. -constexpr u32 GX_PIPELINE_UID_VERSION = 2; // Last changed in PR 9122 +constexpr u32 GX_PIPELINE_UID_VERSION = 3; // Last changed in PR 9473 struct GXPipelineUid { diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index 30bd725cb79d..a9e30112ea02 100644 --- a/Source/Core/VideoCommon/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/PixelShaderGen.cpp @@ -16,6 +16,7 @@ #include "VideoCommon/LightingShaderGen.h" #include "VideoCommon/NativeVertexFormat.h" #include "VideoCommon/RenderState.h" +#include "VideoCommon/SamplerCommon.h" #include "VideoCommon/VertexLoaderManager.h" #include "VideoCommon/VideoCommon.h" #include "VideoCommon/VideoConfig.h" @@ -808,7 +809,15 @@ ShaderCode GeneratePixelShaderCode(APIType api_type, const ShaderHostConfig& hos } out.Write("\tint3 iindtex{} = ", i); - SampleTexture(out, "float2(tempcoord)", "abg", texmap, stereo, api_type); + + FourTexUnits& texUnit = bpmem.tex[(texmap >> 2) & 1]; + TexMode0& tm0 = texUnit.texMode0[texmap & 3]; + + SampleTexture(out, + SamplerCommon::IsBpTexMode0PointFiltering(tm0) ? + "((float2(tempcoord >> 7) + 0.5f) * 128.0f)" : + "(float2(tempcoord))", + "abg", texmap, stereo, api_type); } } @@ -1201,7 +1210,15 @@ static void WriteStage(ShaderCode& out, const pixel_shader_uid_data* uid_data, i out.Write("\ttevcoord.xy = int2(0, 0);\n"); } out.Write("\ttextemp = "); - SampleTexture(out, "float2(tevcoord.xy)", texswap, stage.tevorders_texmap, stereo, api_type); + + FourTexUnits& texUnit = bpmem.tex[(stage.tevorders_texmap >> 2) & 1]; + TexMode0& tm0 = texUnit.texMode0[stage.tevorders_texmap & 3]; + + SampleTexture(out, + SamplerCommon::IsBpTexMode0PointFiltering(tm0) ? + "((float2(tevcoord.xy >> 7) + 0.5f) * 128.0f)" : + "float2(tevcoord.xy)", + texswap, stage.tevorders_texmap, stereo, api_type); } else {