mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
reduced frequency of dx9 ps_2_0 pixel generation errors, and made dx9 efb depth peek of 16-bit depth buffer not use 24-bit adjustment factor. shouldn't affect other the plugins.
(probably nobody else cares, but I need at least one video plugin that actually works on this computer) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6618 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -26,7 +26,7 @@
|
||||
// shader cache for every revision, graphics-related or not, which is simply annoying.
|
||||
enum
|
||||
{
|
||||
LINEAR_DISKCACHE_VER = 6592
|
||||
LINEAR_DISKCACHE_VER = 6618
|
||||
};
|
||||
|
||||
// On disk format:
|
||||
|
@ -101,21 +101,21 @@ void GFXDebuggerBase::DumpPixelShader(const char* path)
|
||||
if (!useDstAlpha)
|
||||
{
|
||||
output = "Destination alpha disabled:\n";
|
||||
output += GeneratePixelShaderCode(DSTALPHA_NONE, g_ActiveConfig.backend_info.APIType, g_nativeVertexFmt->m_components);
|
||||
output += GeneratePixelShaderCode(DSTALPHA_NONE, g_ActiveConfig.backend_info.APIType, 65536, g_nativeVertexFmt->m_components);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(g_ActiveConfig.backend_info.bSupportsDualSourceBlend)
|
||||
{
|
||||
output = "Using dual source blending for destination alpha:\n";
|
||||
output += GeneratePixelShaderCode(DSTALPHA_DUAL_SOURCE_BLEND, g_ActiveConfig.backend_info.APIType, g_nativeVertexFmt->m_components);
|
||||
output += GeneratePixelShaderCode(DSTALPHA_DUAL_SOURCE_BLEND, g_ActiveConfig.backend_info.APIType, 65536, g_nativeVertexFmt->m_components);
|
||||
}
|
||||
else
|
||||
{
|
||||
output = "Using two passes for emulating destination alpha:\n";
|
||||
output += GeneratePixelShaderCode(DSTALPHA_NONE, g_ActiveConfig.backend_info.APIType, g_nativeVertexFmt->m_components);
|
||||
output += GeneratePixelShaderCode(DSTALPHA_NONE, g_ActiveConfig.backend_info.APIType, 65536, g_nativeVertexFmt->m_components);
|
||||
output += "\n\nDestination alpha pass shader:\n";
|
||||
output += GeneratePixelShaderCode(DSTALPHA_ALPHA_PASS, g_ActiveConfig.backend_info.APIType, g_nativeVertexFmt->m_components);
|
||||
output += GeneratePixelShaderCode(DSTALPHA_ALPHA_PASS, g_ActiveConfig.backend_info.APIType, 65536, g_nativeVertexFmt->m_components);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode)
|
||||
// output is given by .outreg
|
||||
// tevtemp is set according to swapmodetables and
|
||||
|
||||
static void WriteStage(char *&p, int n, API_TYPE ApiType);
|
||||
static void WriteStage(char *&p, int n, API_TYPE ApiType,int maxUniforms);
|
||||
static void SampleTexture(char *&p, const char *destination, const char *texcoords, const char *texswap, int texmap, API_TYPE ApiType);
|
||||
// static void WriteAlphaCompare(char *&p, int num, int comp);
|
||||
static bool WriteAlphaTest(char *&p, API_TYPE ApiType);
|
||||
@ -442,7 +442,7 @@ char *GeneratePixelLightShader(char *p, int index, const LitChannel& chan, const
|
||||
|
||||
|
||||
|
||||
const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType,u32 components)
|
||||
const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType,u32 maxUniforms, u32 components)
|
||||
{
|
||||
setlocale(LC_NUMERIC, "C"); // Reset locale for compilation
|
||||
text[sizeof(text) - 1] = 0x7C; // canary
|
||||
@ -504,10 +504,13 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
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_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_INDTEXMTX"[6] : register(c%d);\n", C_INDTEXMTX);
|
||||
WRITE(p, "uniform float4 "I_FOG"[2] : register(c%d);\n", C_FOG);
|
||||
if(g_ActiveConfig.bEnablePixelLigting)
|
||||
if(C_INDTEXSCALE + 2 <= maxUniforms)
|
||||
WRITE(p, "uniform float4 "I_INDTEXSCALE"[2] : register(c%d);\n", C_INDTEXSCALE);
|
||||
if(C_INDTEXMTX + 6 <= maxUniforms)
|
||||
WRITE(p, "uniform float4 "I_INDTEXMTX"[6] : register(c%d);\n", C_INDTEXMTX);
|
||||
if(C_FOG + 2 <= maxUniforms)
|
||||
WRITE(p, "uniform float4 "I_FOG"[2] : register(c%d);\n", C_FOG);
|
||||
if(g_ActiveConfig.bEnablePixelLigting && C_PLIGHTS + 40 <= maxUniforms && C_PMATERIALS + 4 <= maxUniforms)
|
||||
{
|
||||
WRITE(p,"typedef struct { float4 col; float4 cosatt; float4 distatt; float4 pos; float4 dir; } Light;\n");
|
||||
WRITE(p,"typedef struct { Light lights[8]; } s_"I_PLIGHTS";\n");
|
||||
@ -588,7 +591,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
" float2 wrappedcoord, tempcoord;\n"
|
||||
" float4 cc0, cc1, cc2, cprev,crastemp,ckonsttemp;\n\n");
|
||||
|
||||
if(g_ActiveConfig.bEnablePixelLigting)
|
||||
if(g_ActiveConfig.bEnablePixelLigting && C_PLIGHTS + 40 <= maxUniforms && C_PMATERIALS + 4 <= maxUniforms)
|
||||
{
|
||||
if (xfregs.numTexGens < 7)
|
||||
{
|
||||
@ -748,7 +751,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
{
|
||||
int texcoord = bpmem.tevindref.getTexCoord(i);
|
||||
|
||||
if (texcoord < numTexgen)
|
||||
if (texcoord < numTexgen && C_INDTEXSCALE + 2 <= maxUniforms)
|
||||
WRITE(p, "tempcoord = uv%d.xy * "I_INDTEXSCALE"[%d].%s;\n", texcoord, i/2, (i&1)?"zw":"xy");
|
||||
else
|
||||
WRITE(p, "tempcoord = float2(0.0f, 0.0f);\n");
|
||||
@ -770,7 +773,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
}
|
||||
|
||||
for (int i = 0; i < numStages; i++)
|
||||
WriteStage(p, i, ApiType); //build the equation for this stage
|
||||
WriteStage(p, i, ApiType,maxUniforms); //build the equation for this stage
|
||||
|
||||
if(numStages)
|
||||
{
|
||||
@ -832,7 +835,8 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
WRITE(p, " ocol0 = float4(prev.rgb, "I_ALPHA"[0].a);\n");
|
||||
else
|
||||
{
|
||||
WriteFog(p);
|
||||
if(C_FOG + 2 <= maxUniforms)
|
||||
WriteFog(p);
|
||||
WRITE(p, " ocol0 = prev;\n");
|
||||
}
|
||||
|
||||
@ -900,7 +904,7 @@ static const char *TEVCMPAlphaOPTable[16] =
|
||||
};
|
||||
|
||||
|
||||
static void WriteStage(char *&p, int n, API_TYPE ApiType)
|
||||
static void WriteStage(char *&p, int n, API_TYPE ApiType,int maxUniforms)
|
||||
{
|
||||
char *rasswap = swapModeTable[bpmem.combiners[n].alphaC.rswap];
|
||||
char *texswap = swapModeTable[bpmem.combiners[n].alphaC.tswap];
|
||||
@ -934,18 +938,18 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
|
||||
// multiply by offset matrix and scale
|
||||
if (bpmem.tevind[n].mid != 0)
|
||||
{
|
||||
if (bpmem.tevind[n].mid <= 3)
|
||||
if (bpmem.tevind[n].mid <= 3 && C_INDTEXMTX + 6 <= maxUniforms)
|
||||
{
|
||||
int mtxidx = 2*(bpmem.tevind[n].mid-1);
|
||||
WRITE(p, "float2 indtevtrans%d = float2(dot("I_INDTEXMTX"[%d].xyz, indtevcrd%d), dot("I_INDTEXMTX"[%d].xyz, indtevcrd%d));\n",
|
||||
n, mtxidx, n, mtxidx+1, n);
|
||||
}
|
||||
else if (bpmem.tevind[n].mid <= 7 && bHasTexCoord)
|
||||
else if (bpmem.tevind[n].mid <= 7 && bHasTexCoord && C_INDTEXMTX + 6 <= maxUniforms)
|
||||
{ // s matrix
|
||||
int mtxidx = 2*(bpmem.tevind[n].mid-5);
|
||||
WRITE(p, "float2 indtevtrans%d = "I_INDTEXMTX"[%d].ww * uv%d.xy * indtevcrd%d.xx;\n", n, mtxidx, texcoord, n);
|
||||
}
|
||||
else if (bpmem.tevind[n].mid <= 11 && bHasTexCoord)
|
||||
else if (bpmem.tevind[n].mid <= 11 && bHasTexCoord && C_INDTEXMTX + 6 <= maxUniforms)
|
||||
{ // t matrix
|
||||
int mtxidx = 2*(bpmem.tevind[n].mid-9);
|
||||
WRITE(p, "float2 indtevtrans%d = "I_INDTEXMTX"[%d].ww * uv%d.xy * indtevcrd%d.yy;\n", n, mtxidx, texcoord, n);
|
||||
|
@ -112,7 +112,7 @@ enum DSTALPHA_MODE
|
||||
DSTALPHA_DUAL_SOURCE_BLEND // Use dual-source blending
|
||||
};
|
||||
|
||||
const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType,u32 components);
|
||||
const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType,u32 maxUniforms, u32 components);
|
||||
void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode);
|
||||
|
||||
extern PIXELSHADERUID last_pixel_shader_uid;
|
||||
|
@ -215,7 +215,7 @@ void PixelShaderManager::SetConstants()
|
||||
s_bFogParamChanged = false;
|
||||
}
|
||||
|
||||
if (nLightsChanged[0] >= 0)
|
||||
if (g_ActiveConfig.bEnablePixelLigting && nLightsChanged[0] >= 0) // config check added because the code in here was crashing for me inside SetPSConstant4f
|
||||
{
|
||||
// lights don't have a 1 to 1 mapping, the color component needs to be converted to 4 floats
|
||||
int istart = nLightsChanged[0] / 0x10;
|
||||
|
Reference in New Issue
Block a user