-
Notifications
You must be signed in to change notification settings - Fork 882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[d3d9] Disable instancing for non-indexed draws #3158
Conversation
73c936b
to
148dedd
Compare
@K0bin Look at the two examples, they both call Indexed Geometry Performance Comparisonif( SUCCEEDED( pd3dDevice->BeginScene() ) )
{
// Set up the geometry data stream
pd3dDevice->SetStreamSourceFreq(0,
(D3DSTREAMSOURCE_INDEXEDDATA | g_numInstancesToDraw));
pd3dDevice->SetStreamSource(0, g_VB_Geometry, 0,
D3DXGetDeclVertexSize( g_VBDecl_Geometry, 0 ));
// Set up the instance data stream
pd3dDevice->SetStreamSourceFreq(1,
(D3DSTREAMSOURCE_INSTANCEDATA | 1));
pd3dDevice->SetStreamSource(1, g_VB_InstanceData, 0,
D3DXGetDeclVertexSize( g_VBDecl_InstanceData, 1 ));
pd3dDevice->SetVertexDeclaration( ... );
pd3dDevice->SetVertexShader( ... );
pd3dDevice->SetIndices( ... );
pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0,
g_dwNumVertices, 0, g_dwNumIndices/3 );
pd3dDevice->EndScene();
} Non-Indexed Geometry Performance Comparisonif( SUCCEEDED( pd3dDevice->BeginScene() ) )
{
// Set the divider
pd3dDevice->SetStreamSourceFreq(0, 1);
pd3dDevice->SetStreamSource(0, g_VB_Geometry, 0,
D3DXGetDeclVertexSize( g_VBDecl_Geometry, 0 ));
// Set up the instance data stream
pd3dDevice->SetStreamSourceFreq(1, verticesPerInstance));
pd3dDevice->SetStreamSource(1, g_VB_InstanceData, 0,
D3DXGetDeclVertexSize( g_VBDecl_InstanceData, 1 ));
pd3dDevice->SetVertexDeclaration( ... );
pd3dDevice->SetVertexShader( ... );
pd3dDevice->SetIndices( ... );
pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0,
g_dwNumVertices, 0, g_dwNumIndices/3 );
pd3dDevice->EndScene();
} I think what we should be checking for is |
Needs more investigation |
I tested this on Windows and instancing indeed only happens with indexed draws. |
148dedd
to
8f708c0
Compare
8f708c0
to
b7cdfe0
Compare
Fixes #2473
https://learn.microsoft.com/en-us/windows/win32/direct3d9/efficiently-drawing-multiple-instances-of-geometry#drawing-non-indexed-geometry
The docs say the following about instancing with non-indexed draws:
It also seems to work differently in the non-indexed example with seemingly no way to set the instance count. On the other hand they also use
DrawIndexedPrimitive
in the example for non-indexed draws, so I don't really understand it.The best I can deduce is that instancing is not supported for non-indexed draws. This probably needs to be tested on Windows.