D3D9: Fix texel to pixel mapping when sampling textures properly.
This commit is contained in:
parent
fee98b426b
commit
7a1744575d
|
@ -24,7 +24,7 @@
|
||||||
// Increment this every time you change shader generation code.
|
// Increment this every time you change shader generation code.
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
LINEAR_DISKCACHE_VER = 6969
|
LINEAR_DISKCACHE_VER = 6973
|
||||||
};
|
};
|
||||||
|
|
||||||
// On disk format:
|
// On disk format:
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include "XFMemory.h"
|
#include "XFMemory.h"
|
||||||
#include "FifoPlayer/FifoRecorder.h"
|
#include "FifoPlayer/FifoRecorder.h"
|
||||||
#include "AVIDump.h"
|
#include "AVIDump.h"
|
||||||
|
#include "VertexShaderManager.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -193,6 +194,7 @@ bool Renderer::CalculateTargetSize(int multiplier)
|
||||||
{
|
{
|
||||||
s_target_width = newEFBWidth;
|
s_target_width = newEFBWidth;
|
||||||
s_target_height = newEFBHeight;
|
s_target_height = newEFBHeight;
|
||||||
|
VertexShaderManager::SetViewportChanged();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -493,6 +493,13 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
|
||||||
//seems to get rather complicated
|
//seems to get rather complicated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (api_type & API_D3D9)
|
||||||
|
{
|
||||||
|
// D3D9 is addressing pixel centers instead of pixel boundaries in clip space.
|
||||||
|
// Thus we need to offset the final position by half a pixel
|
||||||
|
WRITE(p, "o.pos = o.pos + float4("I_DEPTHPARAMS".z, "I_DEPTHPARAMS".w, 0.f, 0.f);\n");
|
||||||
|
}
|
||||||
|
|
||||||
WRITE(p, "return o;\n}\n");
|
WRITE(p, "return o;\n}\n");
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#define I_TRANSFORMMATRICES "ctrmtx"
|
#define I_TRANSFORMMATRICES "ctrmtx"
|
||||||
#define I_NORMALMATRICES "cnmtx"
|
#define I_NORMALMATRICES "cnmtx"
|
||||||
#define I_POSTTRANSFORMMATRICES "cpostmtx"
|
#define I_POSTTRANSFORMMATRICES "cpostmtx"
|
||||||
#define I_DEPTHPARAMS "cDepth"
|
#define I_DEPTHPARAMS "cDepth" // farZ, zRange, scaled viewport width, scaled viewport height
|
||||||
|
|
||||||
#define C_POSNORMALMATRIX 0
|
#define C_POSNORMALMATRIX 0
|
||||||
#define C_PROJECTION (C_POSNORMALMATRIX + 6)
|
#define C_PROJECTION (C_POSNORMALMATRIX + 6)
|
||||||
|
|
|
@ -306,7 +306,11 @@ void VertexShaderManager::SetConstants()
|
||||||
if (bViewportChanged)
|
if (bViewportChanged)
|
||||||
{
|
{
|
||||||
bViewportChanged = false;
|
bViewportChanged = false;
|
||||||
SetVSConstant4f(C_DEPTHPARAMS,xfregs.viewport.farZ / 16777216.0f,xfregs.viewport.zRange / 16777216.0f,0.0f,0.0f);
|
SetVSConstant4f(C_DEPTHPARAMS,
|
||||||
|
xfregs.viewport.farZ / 16777216.0f,
|
||||||
|
xfregs.viewport.zRange / 16777216.0f,
|
||||||
|
-1.f / (float)g_renderer->EFBToScaledX((int)ceil(2.0f * xfregs.viewport.wd)),
|
||||||
|
1.f / (float)g_renderer->EFBToScaledY((int)ceil(-2.0f * xfregs.viewport.ht)));
|
||||||
// This is so implementation-dependent that we can't have it here.
|
// This is so implementation-dependent that we can't have it here.
|
||||||
UpdateViewport(s_viewportCorrection);
|
UpdateViewport(s_viewportCorrection);
|
||||||
bProjectionChanged = true;
|
bProjectionChanged = true;
|
||||||
|
|
Loading…
Reference in New Issue