Skip to content

Commit b8bdf16

Browse files
blueskythlikescloudssquidbus
authored andcommitted
Apply half pixel offset in the vertex shader. (#1391)
1 parent abf576a commit b8bdf16

5 files changed

Lines changed: 12 additions & 5 deletions

File tree

MarathonRecomp/gpu/shader/csd_no_tex_vs.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void main(
4343
out float4 oColor0 : COLOR0,
4444
out float4 oColor1 : COLOR1)
4545
{
46-
oPos.xy = (iPosition0.xy - 0.5) * g_ViewportSize.zw * float2(2.0, -2.0) + float2(-1.0, 1.0);
46+
oPos.xy = iPosition0.xy * g_ViewportSize.zw * float2(2.0, -2.0) + float2(-1.0, 1.0);
4747
oPos.z = g_Z.x;
4848
oPos.w = 1.0;
4949
oTexCoord0 = iColor0.wxyz;

MarathonRecomp/gpu/shader/csd_vs.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void main(
4444
out float4 oColor0 : COLOR0,
4545
out float4 oColor1 : COLOR1)
4646
{
47-
oPos.xy = (iPosition0.xy - 0.5) * g_ViewportSize.zw * float2(2.0, -2.0) + float2(-1.0, 1.0);
47+
oPos.xy = iPosition0.xy * g_ViewportSize.zw * float2(2.0, -2.0) + float2(-1.0, 1.0);
4848
oPos.z = g_Z.x;
4949
oPos.w = 1.0;
5050
oTexCoord0 = iColor0.wxyz;

MarathonRecomp/gpu/shader/movie_vs.hlsl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Interpolators main(in VertexShaderInput In)
44
{
55
Interpolators Out;
66
Out.ProjPos = In.ObjPos;
7+
Out.ProjPos.xy += g_HalfPixelOffset * Out.ProjPos.w;
78
Out.UV = In.UV;
89
return Out;
910
}

MarathonRecomp/gpu/video.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ struct SharedConstants
166166
uint32_t samplerIndices[16]{};
167167
uint32_t booleans{};
168168
uint32_t swappedTexcoords{};
169+
float halfPixelOffsetX{};
170+
float halfPixelOffsetY{};
169171
float alphaThreshold{};
170172
};
171173

@@ -3192,8 +3194,6 @@ static void FlushViewport()
31923194
if (g_dirtyStates.viewport)
31933195
{
31943196
auto viewport = g_viewport;
3195-
viewport.x += 0.5f;
3196-
viewport.y += 0.5f;
31973197

31983198
// if (viewport.minDepth > viewport.maxDepth)
31993199
// std::swap(viewport.minDepth, viewport.maxDepth);
@@ -3624,6 +3624,12 @@ static void SetFramebuffer(GuestSurface* renderTarget, GuestSurface* depthStenci
36243624
g_framebuffer = nullptr;
36253625
}
36263626

3627+
if (g_framebuffer != nullptr)
3628+
{
3629+
SetDirtyValue(g_dirtyStates.sharedConstants, g_sharedConstants.halfPixelOffsetX, 1.0f / float(g_framebuffer->getWidth()));
3630+
SetDirtyValue(g_dirtyStates.sharedConstants, g_sharedConstants.halfPixelOffsetY, -1.0f / float(g_framebuffer->getHeight()));
3631+
}
3632+
36273633
g_dirtyStates.renderTargetAndDepthStencil = settingForClear;
36283634
}
36293635
}

tools/XenosRecomp

0 commit comments

Comments
 (0)