Move D3DDevice_DeleteVertexShader implementation to XbVertexShader.cpp

This commit is contained in:
patrickvl 2020-04-30 14:53:10 +02:00
parent 311e1037a6
commit ab6bb98758
3 changed files with 38 additions and 30 deletions

View File

@ -7793,36 +7793,7 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_DeleteVertexShader)
XB_TRMP(D3DDevice_DeleteVertexShader)(Handle);
// Handle is always address of an Xbox VertexShader struct, or-ed with 1 (X_D3DFVF_RESERVED0)
// It's reference count is lowered. If it reaches zero (0), the struct is freed.
if (VshHandleIsVertexShader(Handle))
{
CxbxVertexShader *pCxbxVertexShader = GetCxbxVertexShader(Handle);
SetCxbxVertexShader(Handle, nullptr);
if (pCxbxVertexShader->Declaration.pHostVertexDeclaration) {
HRESULT hRet = pCxbxVertexShader->Declaration.pHostVertexDeclaration->Release();
DEBUG_D3DRESULT(hRet, "g_pD3DDevice->DeleteVertexShader(pHostVertexDeclaration)");
}
// Release the host vertex shader
g_VertexShaderSource.ReleaseShader(pCxbxVertexShader->VertexShaderKey);
if (pCxbxVertexShader->Declaration.pXboxDeclarationCopy)
{
free(pCxbxVertexShader->Declaration.pXboxDeclarationCopy);
}
if (pCxbxVertexShader->pXboxFunctionCopy)
{
free(pCxbxVertexShader->pXboxFunctionCopy);
}
FreeVertexDynamicPatch(pCxbxVertexShader);
free(pCxbxVertexShader);
}
CxbxImpl_DeleteVertexShader(Handle);
}
// ******************************************************************

View File

@ -1426,6 +1426,42 @@ void CxbxImpl_SetVertexShader(DWORD Handle)
}
}
void CxbxImpl_DeleteVertexShader(DWORD Handle)
{
LOG_INIT // Allows use of DEBUG_D3DRESULT
// Handle is always address of an Xbox VertexShader struct, or-ed with 1 (X_D3DFVF_RESERVED0)
// It's reference count is lowered. If it reaches zero (0), the struct is freed.
if (VshHandleIsVertexShader(Handle))
{
CxbxVertexShader* pCxbxVertexShader = GetCxbxVertexShader(Handle);
SetCxbxVertexShader(Handle, nullptr);
if (pCxbxVertexShader->Declaration.pHostVertexDeclaration) {
HRESULT hRet = pCxbxVertexShader->Declaration.pHostVertexDeclaration->Release();
DEBUG_D3DRESULT(hRet, "g_pD3DDevice->DeleteVertexShader(pHostVertexDeclaration)");
}
// Release the host vertex shader
g_VertexShaderSource.ReleaseShader(pCxbxVertexShader->VertexShaderKey);
if (pCxbxVertexShader->Declaration.pXboxDeclarationCopy)
{
free(pCxbxVertexShader->Declaration.pXboxDeclarationCopy);
}
if (pCxbxVertexShader->pXboxFunctionCopy)
{
free(pCxbxVertexShader->pXboxFunctionCopy);
}
FreeVertexDynamicPatch(pCxbxVertexShader);
free(pCxbxVertexShader);
}
}
void CxbxImpl_SetVertexShaderConstant(INT Register, PVOID pConstantData, DWORD ConstantCount)
{
LOG_INIT // Allows use of DEBUG_D3DRESULT

View File

@ -243,5 +243,6 @@ extern void CxbxImpl_SelectVertexShaderDirect(XTL::X_VERTEXATTRIBUTEFORMAT* pVAF
extern void CxbxImpl_SelectVertexShader(DWORD Handle, DWORD Address);
extern void CxbxImpl_SetVertexShaderInput(DWORD Handle, UINT StreamCount, XTL::X_STREAMINPUT* pStreamInputs);
extern void CxbxImpl_SetVertexShaderConstant(INT Register, PVOID pConstantData, DWORD ConstantCount);
extern void CxbxImpl_DeleteVertexShader(DWORD Handle);
#endif