Invalid vertex shader filtering
This commit is contained in:
parent
fb2d865fe3
commit
22ca41954c
|
@ -70,6 +70,9 @@ extern HRESULT EmuRecompileVshFunction
|
||||||
|
|
||||||
extern void FreeVertexDynamicPatch(VERTEX_SHADER *pVertexShader);
|
extern void FreeVertexDynamicPatch(VERTEX_SHADER *pVertexShader);
|
||||||
|
|
||||||
|
// Checks for failed vertex shaders, and shaders that would need patching
|
||||||
|
extern boolean IsValidCurrentShader(void);
|
||||||
|
|
||||||
inline boolean VshHandleIsVertexShader(DWORD Handle) { return (Handle & 0x80000000) ? TRUE : FALSE; }
|
inline boolean VshHandleIsVertexShader(DWORD Handle) { return (Handle & 0x80000000) ? TRUE : FALSE; }
|
||||||
inline X_D3DVertexShader *VshHandleGetVertexShader(DWORD Handle) { return (X_D3DVertexShader *)(Handle & 0x7FFFFFFF); }
|
inline X_D3DVertexShader *VshHandleGetVertexShader(DWORD Handle) { return (X_D3DVertexShader *)(Handle & 0x7FFFFFFF); }
|
||||||
|
|
||||||
|
|
|
@ -141,6 +141,7 @@ typedef struct _VERTEX_SHADER
|
||||||
DWORD *pFunction;
|
DWORD *pFunction;
|
||||||
DWORD FunctionSize;
|
DWORD FunctionSize;
|
||||||
DWORD Type;
|
DWORD Type;
|
||||||
|
DWORD Status;
|
||||||
|
|
||||||
// Needed for dynamic stream patching
|
// Needed for dynamic stream patching
|
||||||
VERTEX_DYNAMIC_PATCH VertexDynamicPatch;
|
VERTEX_DYNAMIC_PATCH VertexDynamicPatch;
|
||||||
|
|
|
@ -2141,6 +2141,8 @@ HRESULT WINAPI XTL::EmuIDirect3DDevice8_CreateVertexShader
|
||||||
pRecompiledBuffer = NULL;
|
pRecompiledBuffer = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Save the status, to remove things later
|
||||||
|
pVertexShader->Status = hRet;
|
||||||
|
|
||||||
CxbxFree(pRecompiledDeclaration);
|
CxbxFree(pRecompiledDeclaration);
|
||||||
|
|
||||||
|
@ -6026,28 +6028,31 @@ VOID WINAPI XTL::EmuIDirect3DDevice8_DrawVertices
|
||||||
|
|
||||||
uint32 nStride = EmuFixupVerticesA(PrimitiveType, PrimitiveCount, pOrigVertexBuffer8, pHackVertexBuffer8, StartVertex, 0, 0, 0);
|
uint32 nStride = EmuFixupVerticesA(PrimitiveType, PrimitiveCount, pOrigVertexBuffer8, pHackVertexBuffer8, StartVertex, 0, 0, 0);
|
||||||
|
|
||||||
#ifdef _DEBUG_TRACK_VB
|
if (IsValidCurrentShader())
|
||||||
if(g_bVBSkipStream)
|
|
||||||
{
|
{
|
||||||
g_pD3DDevice8->DrawPrimitive
|
#ifdef _DEBUG_TRACK_VB
|
||||||
(
|
if(g_bVBSkipStream)
|
||||||
PCPrimitiveType,
|
{
|
||||||
StartVertex,
|
g_pD3DDevice8->DrawPrimitive
|
||||||
0
|
(
|
||||||
);
|
PCPrimitiveType,
|
||||||
|
StartVertex,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
g_pD3DDevice8->DrawPrimitive
|
||||||
|
(
|
||||||
|
PCPrimitiveType,
|
||||||
|
StartVertex,
|
||||||
|
PrimitiveCount
|
||||||
|
);
|
||||||
|
#ifdef _DEBUG_TRACK_VB
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
g_pD3DDevice8->DrawPrimitive
|
|
||||||
(
|
|
||||||
PCPrimitiveType,
|
|
||||||
StartVertex,
|
|
||||||
PrimitiveCount
|
|
||||||
);
|
|
||||||
#ifdef _DEBUG_TRACK_VB
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// TODO: use original stride here (duh!)
|
// TODO: use original stride here (duh!)
|
||||||
if(nStride != -1)
|
if(nStride != -1)
|
||||||
|
@ -6098,22 +6103,25 @@ VOID WINAPI XTL::EmuIDirect3DDevice8_DrawVerticesUP
|
||||||
|
|
||||||
uint32 nStride = EmuFixupVerticesA(PrimitiveType, PrimitiveCount, pOrigVertexBuffer8, pHackVertexBuffer8, 0, pVertexStreamZeroData, VertexStreamZeroStride, &pNewVertexStreamZeroData);
|
uint32 nStride = EmuFixupVerticesA(PrimitiveType, PrimitiveCount, pOrigVertexBuffer8, pHackVertexBuffer8, 0, pVertexStreamZeroData, VertexStreamZeroStride, &pNewVertexStreamZeroData);
|
||||||
|
|
||||||
#ifdef _DEBUG_TRACK_VB
|
if (IsValidCurrentShader())
|
||||||
if(!g_bVBSkipStream)
|
|
||||||
{
|
{
|
||||||
#endif
|
#ifdef _DEBUG_TRACK_VB
|
||||||
|
if(!g_bVBSkipStream)
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
g_pD3DDevice8->DrawPrimitiveUP
|
g_pD3DDevice8->DrawPrimitiveUP
|
||||||
(
|
(
|
||||||
PCPrimitiveType,
|
PCPrimitiveType,
|
||||||
PrimitiveCount,
|
PrimitiveCount,
|
||||||
pNewVertexStreamZeroData,
|
pNewVertexStreamZeroData,
|
||||||
VertexStreamZeroStride
|
VertexStreamZeroStride
|
||||||
);
|
);
|
||||||
|
|
||||||
#ifdef _DEBUG_TRACK_VB
|
#ifdef _DEBUG_TRACK_VB
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if(nStride != -1)
|
if(nStride != -1)
|
||||||
{
|
{
|
||||||
|
@ -6248,10 +6256,13 @@ VOID WINAPI XTL::EmuIDirect3DDevice8_DrawIndexedVertices
|
||||||
uiStartIndex = ((DWORD)pIndexData)/2;
|
uiStartIndex = ((DWORD)pIndexData)/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pD3DDevice8->DrawIndexedPrimitive
|
if (IsValidCurrentShader())
|
||||||
(
|
{
|
||||||
PCPrimitiveType, 0, uiNumVertices, uiStartIndex, PrimitiveCount
|
g_pD3DDevice8->DrawIndexedPrimitive
|
||||||
);
|
(
|
||||||
|
PCPrimitiveType, 0, uiNumVertices, uiStartIndex, PrimitiveCount
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if(!bActiveIB)
|
if(!bActiveIB)
|
||||||
{
|
{
|
||||||
|
@ -6321,10 +6332,13 @@ VOID WINAPI XTL::EmuIDirect3DDevice8_DrawIndexedVerticesUP
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_pD3DDevice8->DrawIndexedPrimitiveUP
|
if (IsValidCurrentShader())
|
||||||
(
|
{
|
||||||
PCPrimitiveType, 0, VertexCount, PrimitiveCount, pIndexData, D3DFMT_INDEX16, pNewVertexStreamZeroData, VertexStreamZeroStride
|
g_pD3DDevice8->DrawIndexedPrimitiveUP
|
||||||
);
|
(
|
||||||
|
PCPrimitiveType, 0, VertexCount, PrimitiveCount, pIndexData, D3DFMT_INDEX16, pNewVertexStreamZeroData, VertexStreamZeroStride
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _DEBUG_TRACK_VB
|
#ifdef _DEBUG_TRACK_VB
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,10 +241,13 @@ void XTL::EmuExecutePushBuffer
|
||||||
|
|
||||||
if(!g_bPBSkipPusher)
|
if(!g_bPBSkipPusher)
|
||||||
{
|
{
|
||||||
g_pD3DDevice8->DrawIndexedPrimitive
|
if (IsValidCurrentShader())
|
||||||
(
|
{
|
||||||
PCPrimitiveType, 0, dwCount*2, 0, EmuD3DVertex2PrimitiveCount(XBPrimitiveType, dwCount*2)
|
g_pD3DDevice8->DrawIndexedPrimitive
|
||||||
);
|
(
|
||||||
|
PCPrimitiveType, 0, dwCount*2, 0, EmuD3DVertex2PrimitiveCount(XBPrimitiveType, dwCount*2)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _DEBUG_TRACK_PB
|
#ifdef _DEBUG_TRACK_PB
|
||||||
|
|
|
@ -1976,4 +1976,30 @@ extern void XTL::FreeVertexDynamicPatch(VERTEX_SHADER *pVertexShader)
|
||||||
CxbxFree(pVertexShader->VertexDynamicPatch.pStreamPatches);
|
CxbxFree(pVertexShader->VertexDynamicPatch.pStreamPatches);
|
||||||
pVertexShader->VertexDynamicPatch.pStreamPatches = NULL;
|
pVertexShader->VertexDynamicPatch.pStreamPatches = NULL;
|
||||||
pVertexShader->VertexDynamicPatch.NbrStreams = 0;
|
pVertexShader->VertexDynamicPatch.NbrStreams = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern boolean XTL::IsValidCurrentShader(void)
|
||||||
|
{
|
||||||
|
DWORD Handle;
|
||||||
|
|
||||||
|
EmuIDirect3DDevice8_GetVertexShader(&Handle);
|
||||||
|
if (VshHandleIsVertexShader(Handle))
|
||||||
|
{
|
||||||
|
X_D3DVertexShader *pD3DVertexShader = (X_D3DVertexShader *)(Handle & 0x7FFFFFFF);
|
||||||
|
VERTEX_SHADER *pVertexShader = (VERTEX_SHADER *)pD3DVertexShader->Handle;
|
||||||
|
if (pVertexShader->Status != 0)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
for (uint32 i = 0; i < pVertexShader->VertexDynamicPatch.NbrStreams; i++)
|
||||||
|
{
|
||||||
|
if (pVertexShader->VertexDynamicPatch.pStreamPatches[i].NeedPatch)
|
||||||
|
{
|
||||||
|
// Just for caching purposes
|
||||||
|
pVertexShader->Status = 0x80000001;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
Loading…
Reference in New Issue