Merge pull request #1678 from LukeUsher/loadvertexshaderprogram

Allow LoadVertexShaderProgram to work in games without their own CreateVertexShaderFunction
This commit is contained in:
RadWolfie 2019-07-20 14:49:37 -05:00 committed by GitHub
commit b20185b797
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 5 deletions

View File

@ -3518,11 +3518,23 @@ HRESULT WINAPI XTL::EMUPATCH(D3DDevice_CreateVertexShader)
// Sets other fields
// pHandle recieves the addres of the new shader, or-ed with 1 (D3DFVF_RESERVED0)
XB_trampoline(HRESULT, WINAPI, D3DDevice_CreateVertexShader, (CONST DWORD*, CONST DWORD*, DWORD*, DWORD));
HRESULT hRet = XB_D3DDevice_CreateVertexShader(pDeclaration, pFunction, pHandle, Usage);
if (FAILED(hRet)) {
LOG_TEST_CASE("XB_D3DDevice_CreateVertexShader failed");
RETURN(hRet);
}
HRESULT hRet = D3D_OK;
if (XB_D3DDevice_CreateVertexShader) {
HRESULT hRet = XB_D3DDevice_CreateVertexShader(pDeclaration, pFunction, pHandle, Usage);
if (FAILED(hRet)) {
LOG_TEST_CASE("XB_D3DDevice_CreateVertexShader failed");
RETURN(hRet);
}
} else {
// Due to how our LoadVertexShader patch is implemented, it may call this function without the Xbox version existing
// As a result, we have to build our own vertex shader handle if the trampoline was not found
// We don't do the full steps listed above intentionally so: If this situation is reached, the game
// does not have a CreateVertexShader function, so those actions should not happen anyway!
LOG_TEST_CASE("CreateVertexShader with no trampoline");
*pHandle = ((DWORD)malloc(sizeof(X_D3DVertexShader)) & D3DFVF_RESERVED0);
}
if (g_pD3DDevice == nullptr) {
LOG_TEST_CASE("D3DDevice_CreateVertexShader called before Direct3D_CreateDevice");