Skip to content

Commit

Permalink
[d3d9] Disable instancing for non-indexed draws
Browse files Browse the repository at this point in the history
  • Loading branch information
K0bin authored and misyltoad committed Jan 13, 2023
1 parent 3a84838 commit 97a91c8
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/d3d9/d3d9_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2467,15 +2467,16 @@ namespace dxvk {
EmitCs([this,
cPrimType = PrimitiveType,
cPrimCount = PrimitiveCount,
cStartVertex = StartVertex,
cInstanceCount = GetInstanceCount()
cStartVertex = StartVertex
](DxvkContext* ctx) {
auto drawInfo = GenerateDrawInfo(cPrimType, cPrimCount, cInstanceCount);
uint32_t vertexCount = GetVertexCount(cPrimType, cPrimCount);

ApplyPrimitiveType(ctx, cPrimType);

// Tests on Windows show that D3D9 does not do non-indexed instanced draws.

ctx->draw(
drawInfo.vertexCount, drawInfo.instanceCount,
vertexCount, 1,
cStartVertex, 0);
});

Expand Down Expand Up @@ -2547,17 +2548,16 @@ namespace dxvk {
EmitCs([this,
cBufferSlice = std::move(upSlice.slice),
cPrimType = PrimitiveType,
cPrimCount = PrimitiveCount,
cInstanceCount = GetInstanceCount(),
cStride = VertexStreamZeroStride
cStride = VertexStreamZeroStride,
cVertexCount = vertexCount
](DxvkContext* ctx) mutable {
auto drawInfo = GenerateDrawInfo(cPrimType, cPrimCount, cInstanceCount);

ApplyPrimitiveType(ctx, cPrimType);

// Tests on Windows show that D3D9 does not do non-indexed instanced draws.

ctx->bindVertexBuffer(0, std::move(cBufferSlice), cStride);
ctx->draw(
drawInfo.vertexCount, drawInfo.instanceCount,
cVertexCount, 1,
0, 0);
ctx->bindVertexBuffer(0, DxvkBufferSlice(), 0);
});
Expand Down Expand Up @@ -2699,8 +2699,7 @@ namespace dxvk {
cVertexCount = VertexCount,
cStartIndex = SrcStartIndex,
cInstanceCount = GetInstanceCount(),
cBufferSlice = slice,
cIndexed = m_state.indices != nullptr
cBufferSlice = slice
](DxvkContext* ctx) mutable {
Rc<DxvkShader> shader = m_swvpEmulator.GetShaderModule(this, cDecl);

Expand Down

0 comments on commit 97a91c8

Please sign in to comment.