Tidy shader creation and handle property assignment

This commit is contained in:
Anthony Miles 2020-05-04 21:42:59 +12:00
parent 176dc9a38c
commit 7370a29367
1 changed files with 14 additions and 17 deletions

View File

@ -1540,31 +1540,28 @@ HRESULT CxbxImpl_CreateVertexShader(CONST DWORD *pDeclaration, CONST DWORD *pFun
} }
#endif #endif
uint64_t vertexShaderKey = 0; // Set handle declaration properties
DWORD XboxFunctionSize = 0;
if (SUCCEEDED(hRet) && pFunction)
{
vertexShaderKey = g_VertexShaderSource.CreateShader(pFunction, &XboxFunctionSize);
}
pCxbxVertexShader->Declaration.pXboxDeclarationCopy = (DWORD*)malloc(XboxDeclarationCount * sizeof(DWORD)); pCxbxVertexShader->Declaration.pXboxDeclarationCopy = (DWORD*)malloc(XboxDeclarationCount * sizeof(DWORD));
memcpy(pCxbxVertexShader->Declaration.pXboxDeclarationCopy, pDeclaration, XboxDeclarationCount * sizeof(DWORD)); memcpy(pCxbxVertexShader->Declaration.pXboxDeclarationCopy, pDeclaration, XboxDeclarationCount * sizeof(DWORD));
pCxbxVertexShader->XboxFunctionSize = 0;
pCxbxVertexShader->pXboxFunctionCopy = nullptr;
pCxbxVertexShader->XboxVertexShaderType = X_VST_NORMAL; // TODO : This can vary
pCxbxVertexShader->XboxNrAddressSlots = (XboxFunctionSize - sizeof(XTL::X_VSH_SHADER_HEADER)) / X_VSH_INSTRUCTION_SIZE_BYTES;
pCxbxVertexShader->VertexShaderKey = vertexShaderKey;
pCxbxVertexShader->Declaration.XboxDeclarationCount = XboxDeclarationCount; pCxbxVertexShader->Declaration.XboxDeclarationCount = XboxDeclarationCount;
// Save the status, to remove things later
// pCxbxVertexShader->XboxStatus = hRet; // Not even used by VshHandleIsValidShader()
if (pFunction != xbnullptr) if (pFunction != xbnullptr)
{ {
pCxbxVertexShader->XboxFunctionSize = XboxFunctionSize; // Parse and compile the shader
pCxbxVertexShader->pXboxFunctionCopy = (DWORD*)malloc(XboxFunctionSize); DWORD xboxFunctionSize = 0;
memcpy(pCxbxVertexShader->pXboxFunctionCopy, pFunction, XboxFunctionSize); pCxbxVertexShader->VertexShaderKey = g_VertexShaderSource.CreateShader(pFunction, &xboxFunctionSize);
// Set handle shader function properties
pCxbxVertexShader->XboxFunctionSize = xboxFunctionSize;
pCxbxVertexShader->pXboxFunctionCopy = (DWORD*)malloc(xboxFunctionSize);
memcpy(pCxbxVertexShader->pXboxFunctionCopy, pFunction, xboxFunctionSize);
pCxbxVertexShader->XboxNrAddressSlots = (xboxFunctionSize - sizeof(XTL::X_VSH_SHADER_HEADER)) / X_VSH_INSTRUCTION_SIZE_BYTES;
pCxbxVertexShader->XboxVertexShaderType = X_VST_NORMAL; // TODO : This can vary
} }
// Save the status, to remove things later
// pCxbxVertexShader->XboxStatus = hRet; // Not even used by VshHandleIsValidShader()
RegisterCxbxVertexShader(*pHandle, pCxbxVertexShader); RegisterCxbxVertexShader(*pHandle, pCxbxVertexShader);
if (FAILED(hRet)) if (FAILED(hRet))