Merge branch 'master' into zcomploc-support

This commit is contained in:
Pierre Bourdon 2012-03-24 18:41:51 +01:00
commit b5ba2eb030
19 changed files with 83 additions and 111 deletions

View File

@ -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 = 6972 LINEAR_DISKCACHE_VER = 6973
}; };
// On disk format: // On disk format:

View File

@ -253,7 +253,7 @@ bool RunActiveCodes()
void RunCodeHandler() void RunCodeHandler()
{ {
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableCheats) if (SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableCheats && active_codes.size() > 1)
{ {
u8 *gameId = Memory::GetPointer(0x80000000); u8 *gameId = Memory::GetPointer(0x80000000);
u8 *wiirdId = Memory::GetPointer(0x80001800); u8 *wiirdId = Memory::GetPointer(0x80001800);

View File

@ -43,9 +43,9 @@ bool CVolumeGC::Read(u64 _Offset, u64 _Length, u8* _pBuffer) const
return m_pReader->Read(_Offset, _Length, _pBuffer); return m_pReader->Read(_Offset, _Length, _pBuffer);
} }
bool CVolumeGC::RAWRead( u64 _Offset, u64 _Length, u8* _pBuffer ) const bool CVolumeGC::RAWRead(u64 _Offset, u64 _Length, u8* _pBuffer) const
{ {
return false; return Read(_Offset, _Length, _pBuffer);
} }
std::string CVolumeGC::GetUniqueID() const std::string CVolumeGC::GetUniqueID() const

View File

@ -90,7 +90,7 @@ static const wxLanguage langIds[] =
#define EXIDEV_GECKO_STR "USBGecko" #define EXIDEV_GECKO_STR "USBGecko"
#define CSTR_TRANS(a) wxString(wxGetTranslation(wxT(a))).mb_str() #define CSTR_TRANS(a) wxString(wxGetTranslation(wxT(a))).mb_str()
#define WXSTR_TRANS(a) wxString(wxGetTranslation(wxT(a)))
#ifdef WIN32 #ifdef WIN32
//only used with xgettext to be picked up as translatable string. //only used with xgettext to be picked up as translatable string.
//win32 does not have wx on its path, the provided wxALL_FILES //win32 does not have wx on its path, the provided wxALL_FILES
@ -979,7 +979,7 @@ void CConfigMain::GCSettingsChanged(wxCommandEvent& event)
case ID_GC_EXIDEVICE_SLOTB: case ID_GC_EXIDEVICE_SLOTB:
exidevice++; exidevice++;
case ID_GC_EXIDEVICE_SLOTA: case ID_GC_EXIDEVICE_SLOTA:
ChooseEXIDevice(std::string(event.GetString().mb_str()), exidevice); ChooseEXIDevice(event.GetString(), exidevice);
break; break;
case ID_GC_EXIDEVICE_SLOTA_PATH: case ID_GC_EXIDEVICE_SLOTA_PATH:
ChooseMemcardPath(SConfig::GetInstance().m_strMemoryCardA, true); ChooseMemcardPath(SConfig::GetInstance().m_strMemoryCardA, true);
@ -994,7 +994,7 @@ void CConfigMain::GCSettingsChanged(wxCommandEvent& event)
case ID_GC_SIDEVICE1: case ID_GC_SIDEVICE1:
sidevice++; sidevice++;
case ID_GC_SIDEVICE0: case ID_GC_SIDEVICE0:
ChooseSIDevice(std::string(event.GetString().mb_str()), sidevice); ChooseSIDevice(event.GetString(), sidevice);
break; break;
} }
} }
@ -1044,16 +1044,16 @@ void CConfigMain::ChooseMemcardPath(std::string& strMemcard, bool isSlotA)
} }
} }
void CConfigMain::ChooseSIDevice(std::string deviceName, int deviceNum) void CConfigMain::ChooseSIDevice(wxString deviceName, int deviceNum)
{ {
SIDevices tempType; SIDevices tempType;
if (!deviceName.compare(CSTR_TRANS(SIDEV_STDCONT_STR))) if (!deviceName.compare(WXSTR_TRANS(SIDEV_STDCONT_STR)))
tempType = SIDEVICE_GC_CONTROLLER; tempType = SIDEVICE_GC_CONTROLLER;
else if (!deviceName.compare(CSTR_TRANS(SIDEV_BONGO_STR))) else if (!deviceName.compare(WXSTR_TRANS(SIDEV_BONGO_STR)))
tempType = SIDEVICE_GC_TARUKONGA; tempType = SIDEVICE_GC_TARUKONGA;
else if (!deviceName.compare(SIDEV_GBA_STR)) else if (!deviceName.compare(wxT(SIDEV_GBA_STR)))
tempType = SIDEVICE_GC_GBA; tempType = SIDEVICE_GC_GBA;
else if (!deviceName.compare(CSTR_TRANS(SIDEV_AM_BB_STR))) else if (!deviceName.compare(WXSTR_TRANS(SIDEV_AM_BB_STR)))
tempType = SIDEVICE_AM_BASEBOARD; tempType = SIDEVICE_AM_BASEBOARD;
else else
tempType = SIDEVICE_NONE; tempType = SIDEVICE_NONE;
@ -1067,21 +1067,21 @@ void CConfigMain::ChooseSIDevice(std::string deviceName, int deviceNum)
} }
} }
void CConfigMain::ChooseEXIDevice(std::string deviceName, int deviceNum) void CConfigMain::ChooseEXIDevice(wxString deviceName, int deviceNum)
{ {
TEXIDevices tempType; TEXIDevices tempType;
if (!deviceName.compare(CSTR_TRANS(EXIDEV_MEMCARD_STR))) if (!deviceName.compare(WXSTR_TRANS(EXIDEV_MEMCARD_STR)))
tempType = EXIDEVICE_MEMORYCARD; tempType = EXIDEVICE_MEMORYCARD;
else if (!deviceName.compare(CSTR_TRANS(EXIDEV_MIC_STR))) else if (!deviceName.compare(WXSTR_TRANS(EXIDEV_MIC_STR)))
tempType = EXIDEVICE_MIC; tempType = EXIDEVICE_MIC;
else if (!deviceName.compare(EXIDEV_BBA_STR)) else if (!deviceName.compare(wxT(EXIDEV_BBA_STR)))
tempType = EXIDEVICE_ETH; tempType = EXIDEVICE_ETH;
else if (!deviceName.compare(CSTR_TRANS(EXIDEV_AM_BB_STR))) else if (!deviceName.compare(WXSTR_TRANS(EXIDEV_AM_BB_STR)))
tempType = EXIDEVICE_AM_BASEBOARD; tempType = EXIDEVICE_AM_BASEBOARD;
else if (!deviceName.compare(EXIDEV_GECKO_STR)) else if (!deviceName.compare(wxT(EXIDEV_GECKO_STR)))
tempType = EXIDEVICE_GECKO; tempType = EXIDEVICE_GECKO;
else if (!deviceName.compare(CSTR_TRANS(DEV_NONE_STR))) else if (!deviceName.compare(WXSTR_TRANS(DEV_NONE_STR)))
tempType = EXIDEVICE_NONE; tempType = EXIDEVICE_NONE;
else else
tempType = EXIDEVICE_DUMMY; tempType = EXIDEVICE_DUMMY;

View File

@ -253,8 +253,8 @@ private:
void GCSettingsChanged(wxCommandEvent& event); void GCSettingsChanged(wxCommandEvent& event);
void ChooseMemcardPath(std::string& strMemcard, bool isSlotA); void ChooseMemcardPath(std::string& strMemcard, bool isSlotA);
void ChooseSIDevice(std::string deviceName, int deviceNum); void ChooseSIDevice(wxString deviceName, int deviceNum);
void ChooseEXIDevice(std::string deviceName, int deviceNum); void ChooseEXIDevice(wxString deviceName, int deviceNum);
void WiiSettingsChanged(wxCommandEvent& event); void WiiSettingsChanged(wxCommandEvent& event);
// Change from IPL.LNG value to country code // Change from IPL.LNG value to country code

View File

@ -476,10 +476,15 @@ void BPWritten(const BPCmd& bp)
// if this is different from 0, manual TMEM management is used. // if this is different from 0, manual TMEM management is used.
if (bp.newvalue != 0) if (bp.newvalue != 0)
{ {
// NOTE(neobrain): Apparently tmemodd doesn't affect hardware behavior at all (libogc uses it just as a buffer and switches its contents with tmemeven whenever this is called)
BPS_TmemConfig& tmem_cfg = bpmem.tmem_config; BPS_TmemConfig& tmem_cfg = bpmem.tmem_config;
u8* ram_ptr = Memory::GetPointer(tmem_cfg.preload_addr << 5); u8* ram_ptr = Memory::GetPointer(tmem_cfg.preload_addr << 5);
u32 tmem_addr = tmem_cfg.preload_tmem_even * TMEM_LINE_SIZE; u32 tmem_addr = 0;
if (bp.newvalue >> 16)
tmem_addr = tmem_cfg.preload_tmem_odd * TMEM_LINE_SIZE;
else
tmem_addr = tmem_cfg.preload_tmem_even * TMEM_LINE_SIZE;
u32 size = tmem_cfg.preload_tile_info.count * 32; u32 size = tmem_cfg.preload_tile_info.count * 32;
memcpy(texMem + tmem_addr, ram_ptr, size); memcpy(texMem + tmem_addr, ram_ptr, size);
} }

View File

@ -560,10 +560,6 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
WRITE(p, "uniform float4 "I_KCOLORS"[4] : register(c%d);\n", C_KCOLORS); WRITE(p, "uniform float4 "I_KCOLORS"[4] : register(c%d);\n", C_KCOLORS);
WRITE(p, "uniform float4 "I_ALPHA"[1] : register(c%d);\n", C_ALPHA); WRITE(p, "uniform float4 "I_ALPHA"[1] : register(c%d);\n", C_ALPHA);
WRITE(p, "uniform float4 "I_TEXDIMS"[8] : register(c%d);\n", C_TEXDIMS); WRITE(p, "uniform float4 "I_TEXDIMS"[8] : register(c%d);\n", C_TEXDIMS);
if (ApiType & API_D3D9)
{
WRITE(p, "uniform float4 "I_VTEXSCALE"[4] : register(c%d);\n", C_VTEXSCALE);
}
WRITE(p, "uniform float4 "I_ZBIAS"[2] : register(c%d);\n", C_ZBIAS); WRITE(p, "uniform float4 "I_ZBIAS"[2] : register(c%d);\n", C_ZBIAS);
WRITE(p, "uniform float4 "I_INDTEXSCALE"[2] : register(c%d);\n", C_INDTEXSCALE); WRITE(p, "uniform float4 "I_INDTEXSCALE"[2] : register(c%d);\n", C_INDTEXSCALE);
WRITE(p, "uniform float4 "I_INDTEXMTX"[6] : register(c%d);\n", C_INDTEXMTX); WRITE(p, "uniform float4 "I_INDTEXMTX"[6] : register(c%d);\n", C_INDTEXMTX);
@ -1103,15 +1099,9 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
void SampleTexture(char *&p, const char *destination, const char *texcoords, const char *texswap, int texmap, API_TYPE ApiType) void SampleTexture(char *&p, const char *destination, const char *texcoords, const char *texswap, int texmap, API_TYPE ApiType)
{ {
if (ApiType == API_D3D11) if (ApiType == API_D3D11)
WRITE(p, "%s=Tex%d.Sample(samp%d, %s.xy * "I_TEXDIMS"[%d].xy).%s;\n", destination, texmap,texmap, texcoords, texmap, texswap); WRITE(p, "%s=Tex%d.Sample(samp%d,%s.xy * "I_TEXDIMS"[%d].xy).%s;\n", destination, texmap,texmap, texcoords, texmap, texswap);
else if (ApiType & API_D3D9)
{
// D3D9 uses different pixel to texel mapping, so we need to offset our sampling address by half a pixel (assuming native and virtual texture dimensions match each other, otherwise some math is involved).
// Read the MSDN article "Directly Mapping Texels to Pixels (Direct3D 9)" for further info.
WRITE(p, "%s=tex2D(samp%d, (%s.xy + 0.5f*"I_VTEXSCALE"[%d].%s) * "I_TEXDIMS"[%d].xy).%s;\n", destination, texmap, texcoords, texmap/2, (texmap&1)?"zw":"xy", texmap, texswap);
}
else else
WRITE(p, "%s=tex2D(samp%d, %s.xy * "I_TEXDIMS"[%d].xy).%s;\n", destination, texmap, texcoords, texmap, texswap); WRITE(p, "%s=tex2D(samp%d,%s.xy * "I_TEXDIMS"[%d].xy).%s;\n", destination, texmap, texcoords, texmap, texswap);
} }
static const char *tevAlphaFuncsTable[] = static const char *tevAlphaFuncsTable[] =

View File

@ -24,27 +24,26 @@
#define I_KCOLORS "k" #define I_KCOLORS "k"
#define I_ALPHA "alphaRef" #define I_ALPHA "alphaRef"
#define I_TEXDIMS "texdim" #define I_TEXDIMS "texdim"
#define I_VTEXSCALE "vtexscale"
#define I_ZBIAS "czbias" #define I_ZBIAS "czbias"
#define I_INDTEXSCALE "cindscale" #define I_INDTEXSCALE "cindscale"
#define I_INDTEXMTX "cindmtx" #define I_INDTEXMTX "cindmtx"
#define I_FOG "cfog" #define I_FOG "cfog"
#define I_PLIGHTS "cLights" #define I_PLIGHTS "cLights"
#define I_PMATERIALS "cmtrl" #define I_PMATERIALS "cmtrl"
#define C_COLORMATRIX 0 // 0 #define C_COLORMATRIX 0 // 0
#define C_COLORS 0 // 0 #define C_COLORS 0 // 0
#define C_KCOLORS (C_COLORS + 4) // 4 #define C_KCOLORS (C_COLORS + 4) // 4
#define C_ALPHA (C_KCOLORS + 4) // 8 #define C_ALPHA (C_KCOLORS + 4) // 8
#define C_TEXDIMS (C_ALPHA + 1) // 9 #define C_TEXDIMS (C_ALPHA + 1) // 9
#define C_VTEXSCALE (C_TEXDIMS + 8) //17 - virtual texture scaling factor (e.g. custom textures, scaled EFB copies) #define C_ZBIAS (C_TEXDIMS + 8) //17
#define C_ZBIAS (C_VTEXSCALE + 4) //21 #define C_INDTEXSCALE (C_ZBIAS + 2) //19
#define C_INDTEXSCALE (C_ZBIAS + 2) //23 #define C_INDTEXMTX (C_INDTEXSCALE + 2) //21
#define C_INDTEXMTX (C_INDTEXSCALE + 2) //25 #define C_FOG (C_INDTEXMTX + 6) //27
#define C_FOG (C_INDTEXMTX + 6) //31
#define C_PLIGHTS (C_FOG + 3) //34 #define C_PLIGHTS (C_FOG + 3)
#define C_PMATERIALS (C_PLIGHTS + 40) //74 #define C_PMATERIALS (C_PLIGHTS + 40)
#define C_PENVCONST_END (C_PMATERIALS + 4) //78 #define C_PENVCONST_END (C_PMATERIALS + 4)
#define PIXELSHADERUID_MAX_VALUES 70 #define PIXELSHADERUID_MAX_VALUES 70
#define PIXELSHADERUID_MAX_VALUES_SAFE 120 #define PIXELSHADERUID_MAX_VALUES_SAFE 120

View File

@ -36,11 +36,9 @@ static bool s_bFogRangeAdjustChanged;
static int nLightsChanged[2]; // min,max static int nLightsChanged[2]; // min,max
static float lastRGBAfull[2][4][4]; static float lastRGBAfull[2][4][4];
static u8 s_nTexDimsChanged; static u8 s_nTexDimsChanged;
static u8 s_nVirtualTexScalesChanged;
static u8 s_nIndTexScaleChanged; static u8 s_nIndTexScaleChanged;
static u32 lastAlpha; static u32 lastAlpha;
static u32 lastTexDims[8]; // width | height << 16 | wrap_s << 28 | wrap_t << 30 static u32 lastTexDims[8]; // width | height << 16 | wrap_s << 28 | wrap_t << 30
static float lastVirtualTexScales[16]; // even fields: width ratio; odd fields: height ratio
static u32 lastZBias; static u32 lastZBias;
static int nMaterialsChanged; static int nMaterialsChanged;
@ -63,7 +61,6 @@ void PixelShaderManager::Init()
{ {
lastAlpha = 0; lastAlpha = 0;
memset(lastTexDims, 0, sizeof(lastTexDims)); memset(lastTexDims, 0, sizeof(lastTexDims));
memset(lastVirtualTexScales, 0, sizeof(lastVirtualTexScales));
lastZBias = 0; lastZBias = 0;
memset(lastRGBAfull, 0, sizeof(lastRGBAfull)); memset(lastRGBAfull, 0, sizeof(lastRGBAfull));
Dirty(); Dirty();
@ -73,7 +70,6 @@ void PixelShaderManager::Dirty()
{ {
s_nColorsChanged[0] = s_nColorsChanged[1] = 15; s_nColorsChanged[0] = s_nColorsChanged[1] = 15;
s_nTexDimsChanged = 0xFF; s_nTexDimsChanged = 0xFF;
s_nVirtualTexScalesChanged = 0xFF;
s_nIndTexScaleChanged = 0xFF; s_nIndTexScaleChanged = 0xFF;
s_nIndTexMtxChanged = 15; s_nIndTexMtxChanged = 15;
s_bAlphaChanged = s_bZBiasChanged = s_bZTextureTypeChanged = s_bDepthRangeChanged = true; s_bAlphaChanged = s_bZBiasChanged = s_bZTextureTypeChanged = s_bDepthRangeChanged = true;
@ -87,7 +83,7 @@ void PixelShaderManager::Shutdown()
} }
void PixelShaderManager::SetConstants(API_TYPE api_type) void PixelShaderManager::SetConstants()
{ {
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
@ -113,16 +109,6 @@ void PixelShaderManager::SetConstants(API_TYPE api_type)
s_nTexDimsChanged = 0; s_nTexDimsChanged = 0;
} }
if ((api_type & API_D3D9) && s_nVirtualTexScalesChanged)
{
for (int i = 0; i < 8; i += 2)
{
if (s_nVirtualTexScalesChanged & (3<<i))
SetPSVirtualTexScalePair(i/2);
}
s_nVirtualTexScalesChanged = 0;
}
if (s_bAlphaChanged) if (s_bAlphaChanged)
{ {
SetPSConstant4f(C_ALPHA, (lastAlpha&0xff)/255.0f, ((lastAlpha>>8)&0xff)/255.0f, 0, ((lastAlpha>>16)&0xff)/255.0f); SetPSConstant4f(C_ALPHA, (lastAlpha&0xff)/255.0f, ((lastAlpha>>8)&0xff)/255.0f, 0, ((lastAlpha>>16)&0xff)/255.0f);
@ -352,13 +338,6 @@ void PixelShaderManager::SetPSTextureDims(int texid)
SetPSConstant4fv(C_TEXDIMS + texid, fdims); SetPSConstant4fv(C_TEXDIMS + texid, fdims);
} }
void PixelShaderManager::SetPSVirtualTexScalePair(int texpairid)
{
PRIM_LOG("vtexscale%d: %f %f %f %f\n", texpairid, lastVirtualTexScales[texpairid*4], lastVirtualTexScales[texpairid*4+1],
lastVirtualTexScales[texpairid*4+2], lastVirtualTexScales[texpairid*4+3]);
SetPSConstant4fv(C_VTEXSCALE + texpairid, &lastVirtualTexScales[texpairid*4]);
}
// This one is high in profiles (0.5%). TODO: Move conversion out, only store the raw color value // This one is high in profiles (0.5%). TODO: Move conversion out, only store the raw color value
// and update it when the shader constant is set, only. // and update it when the shader constant is set, only.
void PixelShaderManager::SetColorChanged(int type, int num, bool high) void PixelShaderManager::SetColorChanged(int type, int num, bool high)
@ -397,25 +376,14 @@ void PixelShaderManager::SetDestAlpha(const ConstantAlpha& alpha)
} }
} }
void PixelShaderManager::SetTexDims(int texmapid, u32 width, u32 height, u32 virtual_width, u32 virtual_height, u32 wraps, u32 wrapt, API_TYPE api_type) void PixelShaderManager::SetTexDims(int texmapid, u32 width, u32 height, u32 wraps, u32 wrapt)
{ {
u32 wh = width | (height << 16) | (wraps << 28) | (wrapt << 30); u32 wh = width | (height << 16) | (wraps << 28) | (wrapt << 30);
if (lastTexDims[texmapid] != wh)
bool refresh = lastTexDims[texmapid] != wh;
if (api_type & API_D3D9)
{ {
refresh |= (lastVirtualTexScales[texmapid*2] != (float)width / (float)virtual_width); lastTexDims[texmapid] = wh;
refresh |= (lastVirtualTexScales[texmapid*2+1] != (float)height / (float)virtual_height);
}
if (refresh)
{
lastTexDims[texmapid] = wh;
lastVirtualTexScales[texmapid*2] = (float)width / (float)virtual_width;
lastVirtualTexScales[texmapid*2+1] = (float)height / (float)virtual_height;
s_nTexDimsChanged |= 1 << texmapid; s_nTexDimsChanged |= 1 << texmapid;
s_nVirtualTexScalesChanged |= 1 << texmapid; }
}
} }
void PixelShaderManager::SetZTextureBias(u32 bias) void PixelShaderManager::SetZTextureBias(u32 bias)

View File

@ -26,20 +26,18 @@
class PixelShaderManager class PixelShaderManager
{ {
static void SetPSTextureDims(int texid); static void SetPSTextureDims(int texid);
static void SetPSVirtualTexScalePair(int texpairid);
public: public:
static void Init(); static void Init();
static void Dirty(); static void Dirty();
static void Shutdown(); static void Shutdown();
static void SetConstants(API_TYPE api_type); // sets pixel shader constants static void SetConstants(); // sets pixel shader constants
// constant management, should be called after memory is committed // constant management, should be called after memory is committed
static void SetColorChanged(int type, int index, bool high); static void SetColorChanged(int type, int index, bool high);
static void SetAlpha(const AlphaFunc& alpha); static void SetAlpha(const AlphaFunc& alpha);
static void SetDestAlpha(const ConstantAlpha& alpha); static void SetDestAlpha(const ConstantAlpha& alpha);
static void SetTexDims(int texmapid, u32 width, u32 height, u32 virtual_width, u32 virtual_height, u32 wraps, u32 wrapt, API_TYPE api_type); static void SetTexDims(int texmapid, u32 width, u32 height, u32 wraps, u32 wrapt);
static void SetZTextureBias(u32 bias); static void SetZTextureBias(u32 bias);
static void SetViewportChanged(); static void SetViewportChanged();
static void SetIndMatrixChanged(int matrixidx); static void SetIndMatrixChanged(int matrixidx);

View File

@ -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;

View File

@ -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");

View File

@ -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)

View File

@ -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;

View File

@ -552,22 +552,20 @@ static const unsigned int ps_constant_offset_table[] = {
16, 20, 24, 28, // C_KCOLORS, 16 16, 20, 24, 28, // C_KCOLORS, 16
32, // C_ALPHA, 4 32, // C_ALPHA, 4
36, 40, 44, 48, 52, 56, 60, 64, // C_TEXDIMS, 32 36, 40, 44, 48, 52, 56, 60, 64, // C_TEXDIMS, 32
68, 72, 76, 80, // C_VTEXSCALE, 16 (unused) 68, 72, // C_ZBIAS, 8
84, 88, // C_ZBIAS, 8 76, 80, // C_INDTEXSCALE, 8
92, 96, // C_INDTEXSCALE, 8 84, 88, 92, 96, 100, 104, // C_INDTEXMTX, 24
100, 104, 108, 112, 116, 120, // C_INDTEXMTX, 24 108, 112, 116, // C_FOG, 12
124, 128, 132, // C_FOG, 12 120, 124, 128, 132, 136, // C_PLIGHTS0, 20
136, 140, 144, 148, 152, // C_PLIGHTS0, 20 140, 144, 148, 152, 156, // C_PLIGHTS1, 20
156, 160, 164, 168, 172, // C_PLIGHTS1, 20 160, 164, 168, 172, 176, // C_PLIGHTS2, 20
176, 180, 184, 188, 192, // C_PLIGHTS2, 20 180, 184, 188, 192, 196, // C_PLIGHTS3, 20
196, 200, 204, 208, 212, // C_PLIGHTS3, 20 200, 204, 208, 212, 216, // C_PLIGHTS4, 20
216, 220, 224, 228, 232, // C_PLIGHTS4, 20 220, 224, 228, 232, 236, // C_PLIGHTS5, 20
236, 240, 244, 248, 252, // C_PLIGHTS5, 20 240, 244, 248, 252, 256, // C_PLIGHTS6, 20
256, 260, 264, 268, 272, // C_PLIGHTS6, 20 260, 264, 268, 272, 276, // C_PLIGHTS7, 20
276, 280, 284, 288, 292, // C_PLIGHTS7, 20 280, 284, 288, 292 // C_PMATERIALS, 16
296, 300, 304, 308, // C_PMATERIALS, 16
}; };
void Renderer::SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) void Renderer::SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
{ {
psconstants[ps_constant_offset_table[const_number] ] = f1; psconstants[ps_constant_offset_table[const_number] ] = f1;

View File

@ -1420,9 +1420,10 @@ void Renderer::SetSamplerState(int stage, int texindex)
gx_state.sampdc[stage].AddressU = d3dClamps[tm0.wrap_s]; gx_state.sampdc[stage].AddressU = d3dClamps[tm0.wrap_s];
gx_state.sampdc[stage].AddressV = d3dClamps[tm0.wrap_t]; gx_state.sampdc[stage].AddressV = d3dClamps[tm0.wrap_t];
gx_state.sampdc[stage].MipLODBias = (float)tm0.lod_bias/32.0f; // When mipfilter is set to "none", just disable mipmapping altogether
gx_state.sampdc[stage].MaxLOD = (float)tm1.max_lod/16.f; gx_state.sampdc[stage].MaxLOD = (mip == TEXF_NONE) ? 0.0f : (float)tm1.max_lod/16.f;
gx_state.sampdc[stage].MinLOD = (float)tm1.min_lod/16.f; gx_state.sampdc[stage].MinLOD = (float)tm1.min_lod/16.f;
gx_state.sampdc[stage].MipLODBias = (float)tm0.lod_bias/32.0f;
} }
void Renderer::SetInterlacingMode() void Renderer::SetInterlacingMode()

View File

@ -234,7 +234,7 @@ void VertexManager::vFlush()
if (tentry) if (tentry)
{ {
// 0s are probably for no manual wrapping needed. // 0s are probably for no manual wrapping needed.
PixelShaderManager::SetTexDims(i, tentry->native_width, tentry->native_height, tentry->virtual_width, tentry->virtual_height, 0, 0, API_D3D11); PixelShaderManager::SetTexDims(i, tentry->native_width, tentry->native_height, 0, 0);
} }
else else
ERROR_LOG(VIDEO, "error loading texture"); ERROR_LOG(VIDEO, "error loading texture");
@ -243,7 +243,7 @@ void VertexManager::vFlush()
// set global constants // set global constants
VertexShaderManager::SetConstants(); VertexShaderManager::SetConstants();
PixelShaderManager::SetConstants(API_D3D11); PixelShaderManager::SetConstants();
bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate && bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate &&
bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24; bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;

View File

@ -143,7 +143,7 @@ void VertexManager::vFlush()
if (tentry) if (tentry)
{ {
// 0s are probably for no manual wrapping needed. // 0s are probably for no manual wrapping needed.
PixelShaderManager::SetTexDims(i, tentry->native_width, tentry->native_height, tentry->virtual_width, tentry->virtual_height, 0, 0, API_D3D9); PixelShaderManager::SetTexDims(i, tentry->native_width, tentry->native_height, 0, 0);
} }
else else
ERROR_LOG(VIDEO, "error loading texture"); ERROR_LOG(VIDEO, "error loading texture");
@ -152,7 +152,7 @@ void VertexManager::vFlush()
// set global constants // set global constants
VertexShaderManager::SetConstants(); VertexShaderManager::SetConstants();
PixelShaderManager::SetConstants(API_D3D9); PixelShaderManager::SetConstants();
if (!PixelShaderCache::SetShader(DSTALPHA_NONE,g_nativeVertexFmt->m_components)) if (!PixelShaderCache::SetShader(DSTALPHA_NONE,g_nativeVertexFmt->m_components))
{ {

View File

@ -161,7 +161,7 @@ void VertexManager::vFlush()
if (tentry) if (tentry)
{ {
// 0s are probably for no manual wrapping needed. // 0s are probably for no manual wrapping needed.
PixelShaderManager::SetTexDims(i, tentry->native_width, tentry->native_height, tentry->virtual_width, tentry->virtual_height, 0, 0, API_OPENGL); PixelShaderManager::SetTexDims(i, tentry->native_width, tentry->native_height, 0, 0);
if (g_ActiveConfig.iLog & CONF_SAVETEXTURES) if (g_ActiveConfig.iLog & CONF_SAVETEXTURES)
{ {
@ -179,7 +179,7 @@ void VertexManager::vFlush()
// set global constants // set global constants
VertexShaderManager::SetConstants(); VertexShaderManager::SetConstants();
PixelShaderManager::SetConstants(API_OPENGL); PixelShaderManager::SetConstants();
bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate
&& bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24; && bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;