Skip to content

Commit

Permalink
Add point sampling
Browse files Browse the repository at this point in the history
  • Loading branch information
Miksel12 committed Jan 31, 2021
1 parent caff472 commit 078fc10
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Source/Core/VideoCommon/GXPipelineTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
21 changes: 19 additions & 2 deletions Source/Core/VideoCommon/PixelShaderGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit 078fc10

Please sign in to comment.