Prevent wasted call to WalkIndexBuffer when drawing indexed quadlists

This commit is contained in:
Luke Usher 2019-06-26 07:09:30 +01:00 committed by PatrickvL
parent f36cd0540a
commit 7851af5378
1 changed files with 6 additions and 5 deletions

View File

@ -7058,11 +7058,6 @@ void XTL::CxbxDrawIndexed(CxbxDrawContext &DrawContext)
assert(IsValidCurrentShader()); assert(IsValidCurrentShader());
CxbxUpdateActiveIndexBuffer(DrawContext.pIndexData, DrawContext.dwVertexCount); CxbxUpdateActiveIndexBuffer(DrawContext.pIndexData, DrawContext.dwVertexCount);
//Walk through index buffer
// Determine highest and lowest index in use :
INDEX16 LowIndex, HighIndex;
WalkIndexBuffer(LowIndex, HighIndex, &(DrawContext.pIndexData[DrawContext.dwStartVertex]), DrawContext.dwVertexCount);
VertexBufferConverter.Apply(&DrawContext); VertexBufferConverter.Apply(&DrawContext);
if (DrawContext.XboxPrimitiveType == X_D3DPT_QUADLIST) { if (DrawContext.XboxPrimitiveType == X_D3DPT_QUADLIST) {
@ -7076,6 +7071,7 @@ void XTL::CxbxDrawIndexed(CxbxDrawContext &DrawContext)
// Test-cases : XDK samples reaching this case are : DisplacementMap, Ripple // Test-cases : XDK samples reaching this case are : DisplacementMap, Ripple
// Test-case : XDK Samples (Billboard, BumpLens, DebugKeyboard, Gamepad, Lensflare, PerfTest?VolumeLight, PointSprites, Tiling, VolumeFog, VolumeSprites, etc) // Test-case : XDK Samples (Billboard, BumpLens, DebugKeyboard, Gamepad, Lensflare, PerfTest?VolumeLight, PointSprites, Tiling, VolumeFog, VolumeSprites, etc)
while (iNumVertices >= VERTICES_PER_QUAD) { while (iNumVertices >= VERTICES_PER_QUAD) {
INDEX16 LowIndex, HighIndex;
WalkIndexBuffer(LowIndex, HighIndex, &(DrawContext.pIndexData[uiStartIndex]), VERTICES_PER_QUAD); WalkIndexBuffer(LowIndex, HighIndex, &(DrawContext.pIndexData[uiStartIndex]), VERTICES_PER_QUAD);
// Emulate a quad by drawing each as a fan of 2 triangles // Emulate a quad by drawing each as a fan of 2 triangles
@ -7095,6 +7091,11 @@ void XTL::CxbxDrawIndexed(CxbxDrawContext &DrawContext)
} }
} }
else { else {
//Walk through index buffer
// Determine highest and lowest index in use :
INDEX16 LowIndex, HighIndex;
WalkIndexBuffer(LowIndex, HighIndex, &(DrawContext.pIndexData[DrawContext.dwStartVertex]), DrawContext.dwVertexCount);
// Primitives other than X_D3DPT_QUADLIST can be drawn using one DrawIndexedPrimitive call : // Primitives other than X_D3DPT_QUADLIST can be drawn using one DrawIndexedPrimitive call :
HRESULT hRet = g_pD3DDevice->DrawIndexedPrimitive( HRESULT hRet = g_pD3DDevice->DrawIndexedPrimitive(
EmuXB2PC_D3DPrimitiveType(DrawContext.XboxPrimitiveType), EmuXB2PC_D3DPrimitiveType(DrawContext.XboxPrimitiveType),