mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-31 01:59:52 -06:00
VideoCommon: flush vertex manager if components change
This commit is contained in:
@ -525,14 +525,14 @@ void PixelShaderCache::Shutdown()
|
||||
g_ps_disk_cache.Close();
|
||||
}
|
||||
|
||||
bool PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components)
|
||||
bool PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode)
|
||||
{
|
||||
PixelShaderUid uid;
|
||||
GetPixelShaderUid(uid, dstAlphaMode, API_D3D, components);
|
||||
GetPixelShaderUid(uid, dstAlphaMode, API_D3D);
|
||||
if (g_ActiveConfig.bEnableShaderDebugging)
|
||||
{
|
||||
ShaderCode code;
|
||||
GeneratePixelShaderCode(code, dstAlphaMode, API_D3D, components);
|
||||
GeneratePixelShaderCode(code, dstAlphaMode, API_D3D);
|
||||
pixel_uid_checker.AddToIndexAndCheck(code, uid, "Pixel", "p");
|
||||
}
|
||||
|
||||
@ -562,7 +562,7 @@ bool PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components)
|
||||
|
||||
// Need to compile a new shader
|
||||
ShaderCode code;
|
||||
GeneratePixelShaderCode(code, dstAlphaMode, API_D3D, components);
|
||||
GeneratePixelShaderCode(code, dstAlphaMode, API_D3D);
|
||||
|
||||
D3DBlob* pbytecode;
|
||||
if (!D3D::CompilePixelShader(code.GetBuffer(), &pbytecode))
|
||||
|
@ -20,7 +20,7 @@ public:
|
||||
static void Init();
|
||||
static void Clear();
|
||||
static void Shutdown();
|
||||
static bool SetShader(DSTALPHA_MODE dstAlphaMode, u32 components); // TODO: Should be renamed to LoadShader
|
||||
static bool SetShader(DSTALPHA_MODE dstAlphaMode); // TODO: Should be renamed to LoadShader
|
||||
static bool InsertByteCode(const PixelShaderUid &uid, const void* bytecode, unsigned int bytecodelen);
|
||||
|
||||
static ID3D11PixelShader* GetActiveShader() { return last_entry->shader; }
|
||||
|
@ -151,16 +151,14 @@ void VertexManager::Draw(u32 stride)
|
||||
|
||||
void VertexManager::vFlush(bool useDstAlpha)
|
||||
{
|
||||
u32 components = VertexLoaderManager::GetCurrentVertexFormat()->m_components;
|
||||
|
||||
if (!PixelShaderCache::SetShader(
|
||||
useDstAlpha ? DSTALPHA_DUAL_SOURCE_BLEND : DSTALPHA_NONE, components))
|
||||
useDstAlpha ? DSTALPHA_DUAL_SOURCE_BLEND : DSTALPHA_NONE))
|
||||
{
|
||||
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set pixel shader\n");});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!VertexShaderCache::SetShader(components))
|
||||
if (!VertexShaderCache::SetShader())
|
||||
{
|
||||
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set pixel shader\n");});
|
||||
return;
|
||||
|
@ -184,14 +184,14 @@ void VertexShaderCache::Shutdown()
|
||||
g_vs_disk_cache.Close();
|
||||
}
|
||||
|
||||
bool VertexShaderCache::SetShader(u32 components)
|
||||
bool VertexShaderCache::SetShader()
|
||||
{
|
||||
VertexShaderUid uid;
|
||||
GetVertexShaderUid(uid, components, API_D3D);
|
||||
GetVertexShaderUid(uid, API_D3D);
|
||||
if (g_ActiveConfig.bEnableShaderDebugging)
|
||||
{
|
||||
ShaderCode code;
|
||||
GenerateVertexShaderCode(code, components, API_D3D);
|
||||
GenerateVertexShaderCode(code, API_D3D);
|
||||
vertex_uid_checker.AddToIndexAndCheck(code, uid, "Vertex", "v");
|
||||
}
|
||||
|
||||
@ -217,7 +217,7 @@ bool VertexShaderCache::SetShader(u32 components)
|
||||
}
|
||||
|
||||
ShaderCode code;
|
||||
GenerateVertexShaderCode(code, components, API_D3D);
|
||||
GenerateVertexShaderCode(code, API_D3D);
|
||||
|
||||
D3DBlob* pbytecode = nullptr;
|
||||
D3D::CompileVertexShader(code.GetBuffer(), &pbytecode);
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
static void Init();
|
||||
static void Clear();
|
||||
static void Shutdown();
|
||||
static bool SetShader(u32 components); // TODO: Should be renamed to LoadShader
|
||||
static bool SetShader(); // TODO: Should be renamed to LoadShader
|
||||
|
||||
static ID3D11VertexShader* GetActiveShader() { return last_entry->shader; }
|
||||
static D3DBlob* GetActiveShaderBytecode() { return last_entry->bytecode; }
|
||||
|
@ -176,10 +176,10 @@ void ProgramShaderCache::UploadConstants()
|
||||
}
|
||||
}
|
||||
|
||||
SHADER* ProgramShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components, u32 primitive_type)
|
||||
SHADER* ProgramShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 primitive_type)
|
||||
{
|
||||
SHADERUID uid;
|
||||
GetShaderId(&uid, dstAlphaMode, components, primitive_type);
|
||||
GetShaderId(&uid, dstAlphaMode, primitive_type);
|
||||
|
||||
// Check if the shader is already set
|
||||
if (last_entry)
|
||||
@ -214,8 +214,8 @@ SHADER* ProgramShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components
|
||||
ShaderCode vcode;
|
||||
ShaderCode pcode;
|
||||
ShaderCode gcode;
|
||||
GenerateVertexShaderCode(vcode, components, API_OPENGL);
|
||||
GeneratePixelShaderCode(pcode, dstAlphaMode, API_OPENGL, components);
|
||||
GenerateVertexShaderCode(vcode, API_OPENGL);
|
||||
GeneratePixelShaderCode(pcode, dstAlphaMode, API_OPENGL);
|
||||
if (g_ActiveConfig.backend_info.bSupportsGeometryShaders && !uid.guid.GetUidData()->IsPassthrough())
|
||||
GenerateGeometryShaderCode(gcode, primitive_type, API_OPENGL);
|
||||
|
||||
@ -396,20 +396,20 @@ GLuint ProgramShaderCache::CompileSingleShader(GLuint type, const char* code)
|
||||
return result;
|
||||
}
|
||||
|
||||
void ProgramShaderCache::GetShaderId(SHADERUID* uid, DSTALPHA_MODE dstAlphaMode, u32 components, u32 primitive_type)
|
||||
void ProgramShaderCache::GetShaderId(SHADERUID* uid, DSTALPHA_MODE dstAlphaMode, u32 primitive_type)
|
||||
{
|
||||
GetPixelShaderUid(uid->puid, dstAlphaMode, API_OPENGL, components);
|
||||
GetVertexShaderUid(uid->vuid, components, API_OPENGL);
|
||||
GetPixelShaderUid(uid->puid, dstAlphaMode, API_OPENGL);
|
||||
GetVertexShaderUid(uid->vuid, API_OPENGL);
|
||||
GetGeometryShaderUid(uid->guid, primitive_type, API_OPENGL);
|
||||
|
||||
if (g_ActiveConfig.bEnableShaderDebugging)
|
||||
{
|
||||
ShaderCode pcode;
|
||||
GeneratePixelShaderCode(pcode, dstAlphaMode, API_OPENGL, components);
|
||||
GeneratePixelShaderCode(pcode, dstAlphaMode, API_OPENGL);
|
||||
pixel_uid_checker.AddToIndexAndCheck(pcode, uid->puid, "Pixel", "p");
|
||||
|
||||
ShaderCode vcode;
|
||||
GenerateVertexShaderCode(vcode, components, API_OPENGL);
|
||||
GenerateVertexShaderCode(vcode, API_OPENGL);
|
||||
vertex_uid_checker.AddToIndexAndCheck(vcode, uid->vuid, "Vertex", "v");
|
||||
|
||||
ShaderCode gcode;
|
||||
|
@ -88,8 +88,8 @@ public:
|
||||
|
||||
|
||||
static PCacheEntry GetShaderProgram();
|
||||
static SHADER* SetShader(DSTALPHA_MODE dstAlphaMode, u32 components, u32 primitive_type);
|
||||
static void GetShaderId(SHADERUID *uid, DSTALPHA_MODE dstAlphaMode, u32 components, u32 primitive_type);
|
||||
static SHADER* SetShader(DSTALPHA_MODE dstAlphaMode, u32 primitive_type);
|
||||
static void GetShaderId(SHADERUID *uid, DSTALPHA_MODE dstAlphaMode, u32 primitive_type);
|
||||
|
||||
static bool CompileShader(SHADER &shader, const char* vcode, const char* pcode, const char* gcode = nullptr);
|
||||
static GLuint CompileSingleShader(GLuint type, const char *code);
|
||||
|
@ -160,11 +160,11 @@ void VertexManager::vFlush(bool useDstAlpha)
|
||||
// the same pass as regular rendering.
|
||||
if (useDstAlpha && dualSourcePossible)
|
||||
{
|
||||
ProgramShaderCache::SetShader(DSTALPHA_DUAL_SOURCE_BLEND, nativeVertexFmt->m_components, current_primitive_type);
|
||||
ProgramShaderCache::SetShader(DSTALPHA_DUAL_SOURCE_BLEND, current_primitive_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
ProgramShaderCache::SetShader(DSTALPHA_NONE, nativeVertexFmt->m_components, current_primitive_type);
|
||||
ProgramShaderCache::SetShader(DSTALPHA_NONE, current_primitive_type);
|
||||
}
|
||||
|
||||
// upload global constants
|
||||
@ -178,7 +178,7 @@ void VertexManager::vFlush(bool useDstAlpha)
|
||||
// run through vertex groups again to set alpha
|
||||
if (useDstAlpha && !dualSourcePossible)
|
||||
{
|
||||
ProgramShaderCache::SetShader(DSTALPHA_ALPHA_PASS, nativeVertexFmt->m_components, current_primitive_type);
|
||||
ProgramShaderCache::SetShader(DSTALPHA_ALPHA_PASS, current_primitive_type);
|
||||
|
||||
// only update alpha
|
||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
|
||||
|
Reference in New Issue
Block a user