Second Stage: re implement zcomplock and correct all the logic error in PixelShaderGen.cpp. i disable fastzcomlock for the moment to avoid confusions.

please test for regressions
This commit is contained in:
rodolfoosvaldobogado
2012-04-03 00:08:36 -03:00
parent a0d60210fd
commit 6a446efd5f
13 changed files with 201 additions and 140 deletions

View File

@ -330,11 +330,11 @@ void PixelShaderCache::Shutdown()
unique_shaders.clear();
}
bool PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components)
bool PixelShaderCache::SetShader(PSGRENDER_MODE PSGRenderMode, u32 components)
{
const API_TYPE api = ((D3D::GetCaps().PixelShaderVersion >> 8) & 0xFF) < 3 ? API_D3D9_SM20 : API_D3D9_SM30;
PIXELSHADERUID uid;
GetPixelShaderId(&uid, dstAlphaMode, components);
GetPixelShaderId(&uid, PSGRenderMode, components);
// Check if the shader is already set
if (last_entry)
@ -342,7 +342,7 @@ bool PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components)
if (uid == last_uid)
{
GFX_DEBUGGER_PAUSE_AT(NEXT_PIXEL_SHADER_CHANGE, true);
ValidatePixelShaderIDs(api, last_entry->safe_uid, last_entry->code, dstAlphaMode, components);
ValidatePixelShaderIDs(api, last_entry->safe_uid, last_entry->code, PSGRenderMode, components);
return last_entry->shader != NULL;
}
}
@ -359,13 +359,13 @@ bool PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components)
if (entry.shader) D3D::SetPixelShader(entry.shader);
GFX_DEBUGGER_PAUSE_AT(NEXT_PIXEL_SHADER_CHANGE, true);
ValidatePixelShaderIDs(api, entry.safe_uid, entry.code, dstAlphaMode, components);
ValidatePixelShaderIDs(api, entry.safe_uid, entry.code, PSGRenderMode, components);
return (entry.shader != NULL);
}
// Need to compile a new shader
const char *code = GeneratePixelShaderCode(dstAlphaMode, api, components);
const char *code = GeneratePixelShaderCode(PSGRenderMode, api, components);
if (g_ActiveConfig.bEnableShaderDebugging)
{
@ -401,7 +401,7 @@ bool PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components)
if (g_ActiveConfig.bEnableShaderDebugging && success)
{
PixelShaders[uid].code = code;
GetSafePixelShaderId(&PixelShaders[uid].safe_uid, dstAlphaMode, components);
GetSafePixelShaderId(&PixelShaders[uid].safe_uid, PSGRenderMode, components);
}
GFX_DEBUGGER_PAUSE_AT(NEXT_PIXEL_SHADER_CHANGE, true);

View File

@ -63,7 +63,7 @@ private:
public:
static void Init();
static void Shutdown();
static bool SetShader(DSTALPHA_MODE dstAlphaMode, u32 componets);
static bool SetShader(PSGRENDER_MODE PSGRenderMode, u32 componets);
static bool InsertByteCode(const PIXELSHADERUID &uid, const u8 *bytecode, int bytecodelen, bool activate);
static LPDIRECT3DPIXELSHADER9 GetColorMatrixProgram(int SSAAMode);
static LPDIRECT3DPIXELSHADER9 GetColorCopyProgram(int SSAAMode);

View File

@ -154,7 +154,7 @@ void VertexManager::vFlush()
VertexShaderManager::SetConstants();
PixelShaderManager::SetConstants();
if (!PixelShaderCache::SetShader(DSTALPHA_NONE,g_nativeVertexFmt->m_components))
if (!PixelShaderCache::SetShader(PSGRENDER_NORMAL,g_nativeVertexFmt->m_components))
{
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set pixel shader\n");});
goto shader_fail;
@ -175,8 +175,7 @@ void VertexManager::vFlush()
bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;
if (useDstAlpha)
{
DWORD write = 0;
if (!PixelShaderCache::SetShader(DSTALPHA_ALPHA_PASS, g_nativeVertexFmt->m_components))
if (!PixelShaderCache::SetShader(PSGRENDER_DSTALPHA_ALPHA_PASS, g_nativeVertexFmt->m_components))
{
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set pixel shader\n");});
goto shader_fail;
@ -186,6 +185,20 @@ void VertexManager::vFlush()
Draw(stride);
g_renderer->RestoreState();
}
bool useZcomploc = bpmem.zcontrol.zcomploc && bpmem.zmode.updateenable;
if(useZcomploc)
{
if (!PixelShaderCache::SetShader(PSGRENDER_ZCOMPLOCK, g_nativeVertexFmt->m_components))
{
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set pixel shader\n");});
goto shader_fail;
}
// update Depth only
g_renderer->ApplyState(RSM_Zcomploc);
Draw(stride);
g_renderer->RestoreState();
}
GFX_DEBUGGER_PAUSE_AT(NEXT_FLUSH, true);
shader_fail: