Skip to content

Commit a69d92c

Browse files
committed
We never draw non-indexed in software transform mode, so get rid of the path.
1 parent 9cec7bc commit a69d92c

File tree

6 files changed

+23
-52
lines changed

6 files changed

+23
-52
lines changed

GPU/Common/SoftwareTransformCommon.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -497,13 +497,11 @@ void SoftwareTransform::BuildDrawingParams(int prim, int vertexCount, u32 vertTy
497497

498498
if (prim == GE_PRIM_RECTANGLES) {
499499
if (!ExpandRectangles(vertexCount, numDecodedVerts, vertsSize, inds, indsSize, transformed, transformedExpanded, numTrans, throughmode, &result->pixelMapped)) {
500-
result->drawIndexed = false;
501500
result->drawNumTrans = 0;
502501
result->pixelMapped = false;
503502
return;
504503
}
505504
result->drawBuffer = transformedExpanded;
506-
result->drawIndexed = true;
507505

508506
// We don't know the color until here, so we have to do it now, instead of in StateMapping.
509507
// Might want to reconsider the order of things later...
@@ -521,25 +519,20 @@ void SoftwareTransform::BuildDrawingParams(int prim, int vertexCount, u32 vertTy
521519
} else if (prim == GE_PRIM_POINTS) {
522520
result->pixelMapped = false;
523521
if (!ExpandPoints(vertexCount, numDecodedVerts, vertsSize, inds, indsSize, transformed, transformedExpanded, numTrans, throughmode)) {
524-
result->drawIndexed = false;
525522
result->drawNumTrans = 0;
526523
return;
527524
}
528525
result->drawBuffer = transformedExpanded;
529-
result->drawIndexed = true;
530526
} else if (prim == GE_PRIM_LINES) {
531527
result->pixelMapped = false;
532528
if (!ExpandLines(vertexCount, numDecodedVerts, vertsSize, inds, indsSize, transformed, transformedExpanded, numTrans, throughmode)) {
533-
result->drawIndexed = false;
534529
result->drawNumTrans = 0;
535530
return;
536531
}
537532
result->drawBuffer = transformedExpanded;
538-
result->drawIndexed = true;
539533
} else {
540534
// We can simply draw the unexpanded buffer.
541535
numTrans = vertexCount;
542-
result->drawIndexed = true;
543536
result->pixelMapped = false;
544537

545538
// If we don't support custom cull in the shader, process it here.
@@ -635,7 +628,7 @@ void SoftwareTransform::BuildDrawingParams(int prim, int vertexCount, u32 vertTy
635628
gpuStats.numClears++;
636629
}
637630

638-
result->action = SW_DRAW_PRIMITIVES;
631+
result->action = SW_DRAW_INDEXED;
639632
result->drawNumTrans = numTrans;
640633
}
641634

GPU/Common/SoftwareTransformCommon.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class TextureCacheCommon;
2626

2727
enum SoftwareTransformAction {
2828
SW_NOT_READY,
29-
SW_DRAW_PRIMITIVES,
29+
SW_DRAW_INDEXED,
3030
SW_CLEAR,
3131
};
3232

@@ -44,8 +44,6 @@ struct SoftwareTransformResult {
4444

4545
TransformedVertex *drawBuffer;
4646
int drawNumTrans;
47-
bool drawIndexed;
48-
4947
bool pixelMapped;
5048
};
5149

GPU/D3D11/DrawEngineD3D11.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ void DrawEngineD3D11::DoFlush() {
424424

425425
ApplyDrawStateLate(result.setStencil, result.stencilValue);
426426

427-
if (result.action == SW_DRAW_PRIMITIVES) {
427+
if (result.action == SW_DRAW_INDEXED) {
428428
D3D11VertexShader *vshader;
429429
D3D11FragmentShader *fshader;
430430
shaderManager_->GetShaders(prim, dec_, &vshader, &fshader, pipelineState_, false, false, decOptions_.expandAllWeightsToFloat, true);
@@ -452,17 +452,13 @@ void DrawEngineD3D11::DoFlush() {
452452
pushVerts_->EndPush(context_);
453453
ID3D11Buffer *buf = pushVerts_->Buf();
454454
context_->IASetVertexBuffers(0, 1, &buf, &stride, &vOffset);
455-
if (result.drawIndexed) {
456-
UINT iOffset;
457-
int iSize = sizeof(uint16_t) * result.drawNumTrans;
458-
uint8_t *iptr = pushInds_->BeginPush(context_, &iOffset, iSize);
459-
memcpy(iptr, inds, iSize);
460-
pushInds_->EndPush(context_);
461-
context_->IASetIndexBuffer(pushInds_->Buf(), DXGI_FORMAT_R16_UINT, iOffset);
462-
context_->DrawIndexed(result.drawNumTrans, 0, 0);
463-
} else {
464-
context_->Draw(result.drawNumTrans, 0);
465-
}
455+
UINT iOffset;
456+
int iSize = sizeof(uint16_t) * result.drawNumTrans;
457+
uint8_t *iptr = pushInds_->BeginPush(context_, &iOffset, iSize);
458+
memcpy(iptr, inds, iSize);
459+
pushInds_->EndPush(context_);
460+
context_->IASetIndexBuffer(pushInds_->Buf(), DXGI_FORMAT_R16_UINT, iOffset);
461+
context_->DrawIndexed(result.drawNumTrans, 0, 0);
466462
} else if (result.action == SW_CLEAR) {
467463
u32 clearColor = result.color;
468464
float clearDepth = result.depth;

GPU/Directx9/DrawEngineDX9.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ void DrawEngineDX9::DoFlush() {
382382

383383
VSShader *vshader = shaderManager_->ApplyShader(false, false, dec_, decOptions_.expandAllWeightsToFloat, true, pipelineState_);
384384

385-
if (result.action == SW_DRAW_PRIMITIVES) {
385+
if (result.action == SW_DRAW_INDEXED) {
386386
if (result.setStencil) {
387387
dxstate.stencilFunc.set(D3DCMP_ALWAYS);
388388
dxstate.stencilRef.set(result.stencilValue);
@@ -393,11 +393,7 @@ void DrawEngineDX9::DoFlush() {
393393
// Might help for text drawing.
394394

395395
device_->SetVertexDeclaration(transformedVertexDecl_);
396-
if (result.drawIndexed) {
397-
device_->DrawIndexedPrimitiveUP(d3d_prim[prim], 0, numDecodedVerts_, D3DPrimCount(d3d_prim[prim], result.drawNumTrans), inds, D3DFMT_INDEX16, result.drawBuffer, sizeof(TransformedVertex));
398-
} else {
399-
device_->DrawPrimitiveUP(d3d_prim[prim], D3DPrimCount(d3d_prim[prim], result.drawNumTrans), result.drawBuffer, sizeof(TransformedVertex));
400-
}
396+
device_->DrawIndexedPrimitiveUP(d3d_prim[prim], 0, numDecodedVerts_, D3DPrimCount(d3d_prim[prim], result.drawNumTrans), inds, D3DFMT_INDEX16, result.drawBuffer, sizeof(TransformedVertex));
401397
} else if (result.action == SW_CLEAR) {
402398
u32 clearColor = result.color;
403399
float clearDepth = result.depth;

GPU/GLES/DrawEngineGLES.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -415,18 +415,12 @@ void DrawEngineGLES::DoFlush() {
415415
goto bail;
416416
}
417417

418-
if (result.action == SW_DRAW_PRIMITIVES) {
419-
if (result.drawIndexed) {
420-
vertexBufferOffset = (uint32_t)frameData.pushVertex->Push(result.drawBuffer, numDecodedVerts_ * sizeof(TransformedVertex), 4, &vertexBuffer);
421-
indexBufferOffset = (uint32_t)frameData.pushIndex->Push(inds, sizeof(uint16_t) * result.drawNumTrans, 2, &indexBuffer);
422-
render_->DrawIndexed(
423-
softwareInputLayout_, vertexBuffer, vertexBufferOffset, indexBuffer, indexBufferOffset,
424-
glprim[prim], result.drawNumTrans, GL_UNSIGNED_SHORT);
425-
} else {
426-
vertexBufferOffset = (uint32_t)frameData.pushVertex->Push(result.drawBuffer, result.drawNumTrans * sizeof(TransformedVertex), 4, &vertexBuffer);
427-
render_->Draw(
428-
softwareInputLayout_, vertexBuffer, vertexBufferOffset, glprim[prim], 0, result.drawNumTrans);
429-
}
418+
if (result.action == SW_DRAW_INDEXED) {
419+
vertexBufferOffset = (uint32_t)frameData.pushVertex->Push(result.drawBuffer, numDecodedVerts_ * sizeof(TransformedVertex), 4, &vertexBuffer);
420+
indexBufferOffset = (uint32_t)frameData.pushIndex->Push(inds, sizeof(uint16_t) * result.drawNumTrans, 2, &indexBuffer);
421+
render_->DrawIndexed(
422+
softwareInputLayout_, vertexBuffer, vertexBufferOffset, indexBuffer, indexBufferOffset,
423+
glprim[prim], result.drawNumTrans, GL_UNSIGNED_SHORT);
430424
} else if (result.action == SW_CLEAR) {
431425
u32 clearColor = result.color;
432426
float clearDepth = result.depth;

GPU/Vulkan/DrawEngineVulkan.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ void DrawEngineVulkan::DoFlush() {
448448

449449
// Only here, where we know whether to clear or to draw primitives, should we actually set the current framebuffer! Because that gives use the opportunity
450450
// to use a "pre-clear" render pass, for high efficiency on tilers.
451-
if (result.action == SW_DRAW_PRIMITIVES) {
451+
if (result.action == SW_DRAW_INDEXED) {
452452
if (textureNeedsApply) {
453453
gstate_c.pixelMapped = result.pixelMapped;
454454
textureCache_->ApplyTexture();
@@ -525,16 +525,10 @@ void DrawEngineVulkan::DoFlush() {
525525

526526
PROFILE_THIS_SCOPE("renderman_q");
527527

528-
if (result.drawIndexed) {
529-
VkBuffer vbuf, ibuf;
530-
vbOffset = (uint32_t)pushVertex_->Push(result.drawBuffer, numDecodedVerts_ * sizeof(TransformedVertex), 4, &vbuf);
531-
ibOffset = (uint32_t)pushIndex_->Push(inds, sizeof(short) * result.drawNumTrans, 4, &ibuf);
532-
renderManager->DrawIndexed(descSetIndex, ARRAY_SIZE(dynamicUBOOffsets), dynamicUBOOffsets, vbuf, vbOffset, ibuf, ibOffset, result.drawNumTrans, 1);
533-
} else {
534-
VkBuffer vbuf;
535-
vbOffset = (uint32_t)pushVertex_->Push(result.drawBuffer, result.drawNumTrans * sizeof(TransformedVertex), 4, &vbuf);
536-
renderManager->Draw(descSetIndex, ARRAY_SIZE(dynamicUBOOffsets), dynamicUBOOffsets, vbuf, vbOffset, result.drawNumTrans);
537-
}
528+
VkBuffer vbuf, ibuf;
529+
vbOffset = (uint32_t)pushVertex_->Push(result.drawBuffer, numDecodedVerts_ * sizeof(TransformedVertex), 4, &vbuf);
530+
ibOffset = (uint32_t)pushIndex_->Push(inds, sizeof(short) * result.drawNumTrans, 4, &ibuf);
531+
renderManager->DrawIndexed(descSetIndex, ARRAY_SIZE(dynamicUBOOffsets), dynamicUBOOffsets, vbuf, vbOffset, ibuf, ibOffset, result.drawNumTrans, 1);
538532
} else if (result.action == SW_CLEAR) {
539533
// Note: we won't get here if the clear is alpha but not color, or color but not alpha.
540534
bool clearColor = gstate.isClearModeColorMask();

0 commit comments

Comments
 (0)