Some renaming to follow the standard of appending _ to member vars

This commit is contained in:
Henrik Rydgård 2023-05-23 18:00:50 +02:00
parent 84da0327d6
commit f16f879b41
11 changed files with 108 additions and 103 deletions

View file

@ -39,17 +39,17 @@ DrawEngineCommon::DrawEngineCommon() : decoderMap_(16) {
if (g_Config.bVertexDecoderJit && g_Config.iCpuCore == (int)CPUCore::JIT) {
decJitCache_ = new VertexDecoderJitCache();
}
transformed = (TransformedVertex *)AllocateMemoryPages(TRANSFORMED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
transformedExpanded = (TransformedVertex *)AllocateMemoryPages(3 * TRANSFORMED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
transformed_ = (TransformedVertex *)AllocateMemoryPages(TRANSFORMED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
transformedExpanded_ = (TransformedVertex *)AllocateMemoryPages(3 * TRANSFORMED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
decoded_ = (u8 *)AllocateMemoryPages(DECODED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
decIndex = (u16 *)AllocateMemoryPages(DECODED_INDEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
decIndex_ = (u16 *)AllocateMemoryPages(DECODED_INDEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
}
DrawEngineCommon::~DrawEngineCommon() {
FreeMemoryPages(decoded_, DECODED_VERTEX_BUFFER_SIZE);
FreeMemoryPages(decIndex, DECODED_INDEX_BUFFER_SIZE);
FreeMemoryPages(transformed, TRANSFORMED_VERTEX_BUFFER_SIZE);
FreeMemoryPages(transformedExpanded, 3 * TRANSFORMED_VERTEX_BUFFER_SIZE);
FreeMemoryPages(decIndex_, DECODED_INDEX_BUFFER_SIZE);
FreeMemoryPages(transformed_, TRANSFORMED_VERTEX_BUFFER_SIZE);
FreeMemoryPages(transformedExpanded_, 3 * TRANSFORMED_VERTEX_BUFFER_SIZE);
delete decJitCache_;
decoderMap_.Iterate([&](const uint32_t vtype, VertexDecoder *decoder) {
delete decoder;
@ -74,25 +74,25 @@ VertexDecoder *DrawEngineCommon::GetVertexDecoder(u32 vtype) {
int DrawEngineCommon::ComputeNumVertsToDecode() const {
int vertsToDecode = 0;
if (drawCalls[0].indexType == GE_VTYPE_IDX_NONE >> GE_VTYPE_IDX_SHIFT) {
for (int i = 0; i < numDrawCalls; i++) {
const DeferredDrawCall &dc = drawCalls[i];
if (drawCalls_[0].indexType == GE_VTYPE_IDX_NONE >> GE_VTYPE_IDX_SHIFT) {
for (int i = 0; i < numDrawCalls_; i++) {
const DeferredDrawCall &dc = drawCalls_[i];
vertsToDecode += dc.vertexCount;
}
} else {
// TODO: Share this computation with DecodeVertsStep?
for (int i = 0; i < numDrawCalls; i++) {
const DeferredDrawCall &dc = drawCalls[i];
for (int i = 0; i < numDrawCalls_; i++) {
const DeferredDrawCall &dc = drawCalls_[i];
int lastMatch = i;
const int total = numDrawCalls;
const int total = numDrawCalls_;
int indexLowerBound = dc.indexLowerBound;
int indexUpperBound = dc.indexUpperBound;
for (int j = i + 1; j < total; ++j) {
if (drawCalls[j].verts != dc.verts)
if (drawCalls_[j].verts != dc.verts)
break;
indexLowerBound = std::min(indexLowerBound, (int)drawCalls[j].indexLowerBound);
indexUpperBound = std::max(indexUpperBound, (int)drawCalls[j].indexUpperBound);
indexLowerBound = std::min(indexLowerBound, (int)drawCalls_[j].indexLowerBound);
indexUpperBound = std::max(indexUpperBound, (int)drawCalls_[j].indexUpperBound);
lastMatch = j;
}
vertsToDecode += indexUpperBound - indexLowerBound + 1;
@ -104,8 +104,8 @@ int DrawEngineCommon::ComputeNumVertsToDecode() const {
void DrawEngineCommon::DecodeVerts(u8 *dest) {
const UVScale origUV = gstate_c.uv;
for (; decodeCounter_ < numDrawCalls; decodeCounter_++) {
gstate_c.uv = drawCalls[decodeCounter_].uvScale;
for (; decodeCounter_ < numDrawCalls_; decodeCounter_++) {
gstate_c.uv = drawCalls_[decodeCounter_].uvScale;
DecodeVertsStep(dest, decodeCounter_, decodedVerts_); // NOTE! DecodeVertsStep can modify decodeCounter_!
}
gstate_c.uv = origUV;
@ -615,7 +615,7 @@ void DrawEngineCommon::ApplyFramebufferRead(FBOTexState *fboTexState) {
void DrawEngineCommon::DecodeVertsStep(u8 *dest, int &i, int &decodedVerts) {
PROFILE_THIS_SCOPE("vertdec");
const DeferredDrawCall &dc = drawCalls[i];
const DeferredDrawCall &dc = drawCalls_[i];
indexGen.SetIndex(decodedVerts);
int indexLowerBound = dc.indexLowerBound;
@ -641,13 +641,13 @@ void DrawEngineCommon::DecodeVertsStep(u8 *dest, int &i, int &decodedVerts) {
// 1. Look ahead to find the max index, only looking as "matching" drawcalls.
// Expand the lower and upper bounds as we go.
int lastMatch = i;
const int total = numDrawCalls;
const int total = numDrawCalls_;
for (int j = i + 1; j < total; ++j) {
if (drawCalls[j].verts != dc.verts)
if (drawCalls_[j].verts != dc.verts)
break;
indexLowerBound = std::min(indexLowerBound, (int)drawCalls[j].indexLowerBound);
indexUpperBound = std::max(indexUpperBound, (int)drawCalls[j].indexUpperBound);
indexLowerBound = std::min(indexLowerBound, (int)drawCalls_[j].indexLowerBound);
indexUpperBound = std::max(indexUpperBound, (int)drawCalls_[j].indexUpperBound);
lastMatch = j;
}
@ -656,28 +656,28 @@ void DrawEngineCommon::DecodeVertsStep(u8 *dest, int &i, int &decodedVerts) {
case GE_VTYPE_IDX_8BIT >> GE_VTYPE_IDX_SHIFT:
for (int j = i; j <= lastMatch; j++) {
bool clockwise = true;
if (gstate.isCullEnabled() && gstate.getCullMode() != drawCalls[j].cullMode) {
if (gstate.isCullEnabled() && gstate.getCullMode() != drawCalls_[j].cullMode) {
clockwise = false;
}
indexGen.TranslatePrim(drawCalls[j].prim, drawCalls[j].vertexCount, (const u8 *)drawCalls[j].inds, indexLowerBound, clockwise);
indexGen.TranslatePrim(drawCalls_[j].prim, drawCalls_[j].vertexCount, (const u8 *)drawCalls_[j].inds, indexLowerBound, clockwise);
}
break;
case GE_VTYPE_IDX_16BIT >> GE_VTYPE_IDX_SHIFT:
for (int j = i; j <= lastMatch; j++) {
bool clockwise = true;
if (gstate.isCullEnabled() && gstate.getCullMode() != drawCalls[j].cullMode) {
if (gstate.isCullEnabled() && gstate.getCullMode() != drawCalls_[j].cullMode) {
clockwise = false;
}
indexGen.TranslatePrim(drawCalls[j].prim, drawCalls[j].vertexCount, (const u16_le *)drawCalls[j].inds, indexLowerBound, clockwise);
indexGen.TranslatePrim(drawCalls_[j].prim, drawCalls_[j].vertexCount, (const u16_le *)drawCalls_[j].inds, indexLowerBound, clockwise);
}
break;
case GE_VTYPE_IDX_32BIT >> GE_VTYPE_IDX_SHIFT:
for (int j = i; j <= lastMatch; j++) {
bool clockwise = true;
if (gstate.isCullEnabled() && gstate.getCullMode() != drawCalls[j].cullMode) {
if (gstate.isCullEnabled() && gstate.getCullMode() != drawCalls_[j].cullMode) {
clockwise = false;
}
indexGen.TranslatePrim(drawCalls[j].prim, drawCalls[j].vertexCount, (const u32_le *)drawCalls[j].inds, indexLowerBound, clockwise);
indexGen.TranslatePrim(drawCalls_[j].prim, drawCalls_[j].vertexCount, (const u32_le *)drawCalls_[j].inds, indexLowerBound, clockwise);
}
break;
}
@ -724,15 +724,15 @@ u32 DrawEngineCommon::ComputeMiniHash() {
const int indexSize = IndexSize(dec_->VertexType());
int step;
if (numDrawCalls < 3) {
if (numDrawCalls_ < 3) {
step = 1;
} else if (numDrawCalls < 8) {
} else if (numDrawCalls_ < 8) {
step = 4;
} else {
step = numDrawCalls / 8;
step = numDrawCalls_ / 8;
}
for (int i = 0; i < numDrawCalls; i += step) {
const DeferredDrawCall &dc = drawCalls[i];
for (int i = 0; i < numDrawCalls_; i += step) {
const DeferredDrawCall &dc = drawCalls_[i];
if (!dc.inds) {
fullhash += ComputeMiniHashRange(dc.verts, vertexSize * dc.vertexCount);
} else {
@ -750,18 +750,18 @@ uint64_t DrawEngineCommon::ComputeHash() {
const int vertexSize = dec_->GetDecVtxFmt().stride;
const int indexSize = IndexSize(dec_->VertexType());
// TODO: Add some caps both for numDrawCalls and num verts to check?
// TODO: Add some caps both for numDrawCalls_ and num verts to check?
// It is really very expensive to check all the vertex data so often.
for (int i = 0; i < numDrawCalls; i++) {
const DeferredDrawCall &dc = drawCalls[i];
for (int i = 0; i < numDrawCalls_; i++) {
const DeferredDrawCall &dc = drawCalls_[i];
if (!dc.inds) {
fullhash += XXH3_64bits((const char *)dc.verts, vertexSize * dc.vertexCount);
} else {
int indexLowerBound = dc.indexLowerBound, indexUpperBound = dc.indexUpperBound;
int j = i + 1;
int lastMatch = i;
while (j < numDrawCalls) {
if (drawCalls[j].verts != dc.verts)
while (j < numDrawCalls_) {
if (drawCalls_[j].verts != dc.verts)
break;
indexLowerBound = std::min(indexLowerBound, (int)dc.indexLowerBound);
indexUpperBound = std::max(indexUpperBound, (int)dc.indexUpperBound);
@ -778,7 +778,7 @@ uint64_t DrawEngineCommon::ComputeHash() {
}
}
fullhash += XXH3_64bits(&drawCalls[0].uvScale, sizeof(drawCalls[0].uvScale) * numDrawCalls);
fullhash += XXH3_64bits(&drawCalls_[0].uvScale, sizeof(drawCalls_[0].uvScale) * numDrawCalls_);
return fullhash;
}
@ -794,7 +794,7 @@ inline uint32_t lowbias32_r(uint32_t x) {
// vertTypeID is the vertex type but with the UVGen mode smashed into the top bits.
void DrawEngineCommon::SubmitPrim(const void *verts, const void *inds, GEPrimitiveType prim, int vertexCount, u32 vertTypeID, int cullMode, int *bytesRead) {
if (!indexGen.PrimCompatible(prevPrim_, prim) || numDrawCalls >= MAX_DEFERRED_DRAW_CALLS || vertexCountInDrawCalls_ + vertexCount > VERTEX_BUFFER_MAX) {
if (!indexGen.PrimCompatible(prevPrim_, prim) || numDrawCalls_ >= MAX_DEFERRED_DRAW_CALLS || vertexCountInDrawCalls_ + vertexCount > VERTEX_BUFFER_MAX) {
DispatchFlush();
}
@ -830,7 +830,7 @@ void DrawEngineCommon::SubmitPrim(const void *verts, const void *inds, GEPrimiti
dcid_ = lowbias32_r(dhash ^ (u32)prim);
}
DeferredDrawCall &dc = drawCalls[numDrawCalls];
DeferredDrawCall &dc = drawCalls_[numDrawCalls_];
dc.verts = verts;
dc.inds = inds;
dc.vertexCount = vertexCount;
@ -845,7 +845,7 @@ void DrawEngineCommon::SubmitPrim(const void *verts, const void *inds, GEPrimiti
dc.indexUpperBound = vertexCount - 1;
}
numDrawCalls++;
numDrawCalls_++;
vertexCountInDrawCalls_ += vertexCount;
if (decOptions_.applySkinInDecode && (vertTypeID & GE_VTYPE_WEIGHT_MASK)) {

View file

@ -122,7 +122,7 @@ public:
return false;
}
int GetNumDrawCalls() const {
return numDrawCalls;
return numDrawCalls_;
}
VertexDecoder *GetVertexDecoder(u32 vtype);
@ -186,7 +186,7 @@ protected:
// Vertex collector buffers
u8 *decoded_ = nullptr;
u16 *decIndex = nullptr;
u16 *decIndex_ = nullptr;
// Cached vertex decoders
u32 lastVType_ = -1; // corresponds to dec_. Could really just pick it out of dec_...
@ -195,8 +195,8 @@ protected:
VertexDecoderJitCache *decJitCache_ = nullptr;
VertexDecoderOptions decOptions_{};
TransformedVertex *transformed = nullptr;
TransformedVertex *transformedExpanded = nullptr;
TransformedVertex *transformed_ = nullptr;
TransformedVertex *transformedExpanded_ = nullptr;
// Defer all vertex decoding to a "Flush" (except when software skinning)
struct DeferredDrawCall {
@ -212,8 +212,8 @@ protected:
};
enum { MAX_DEFERRED_DRAW_CALLS = 128 };
DeferredDrawCall drawCalls[MAX_DEFERRED_DRAW_CALLS];
int numDrawCalls = 0;
DeferredDrawCall drawCalls_[MAX_DEFERRED_DRAW_CALLS];
int numDrawCalls_ = 0;
int vertexCountInDrawCalls_ = 0;
int decimationCounter_ = 0;

View file

@ -545,7 +545,7 @@ void DrawEngineCommon::SubmitCurve(const void *control_points, const void *indic
OutputBuffers output;
output.vertices = (SimpleVertex *)(decoded_ + DECODED_VERTEX_BUFFER_SIZE / 2);
output.indices = decIndex;
output.indices = decIndex_;
output.count = 0;
int maxVerts = DECODED_VERTEX_BUFFER_SIZE / 2 / vertexSize;

View file

@ -88,7 +88,7 @@ DrawEngineD3D11::DrawEngineD3D11(Draw::DrawContext *draw, ID3D11Device *device,
// Allocate nicely aligned memory. Maybe graphics drivers will
// appreciate it.
// All this is a LOT of memory, need to see if we can cut down somehow.
indexGen.Setup(decIndex);
indexGen.Setup(decIndex_);
InitDeviceObjects();
@ -327,7 +327,7 @@ void DrawEngineD3D11::Invalidate(InvalidationCallbackFlags flags) {
}
}
// The inline wrapper in the header checks for numDrawCalls == 0
// The inline wrapper in the header checks for numDrawCalls_ == 0
void DrawEngineD3D11::DoFlush() {
bool textureNeedsApply = false;
if (gstate_c.IsDirty(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS) && !gstate.isModeClear() && gstate.isTextureMapEnabled()) {
@ -450,7 +450,7 @@ void DrawEngineD3D11::DoFlush() {
if (useElements) {
u32 size = sizeof(short) * indexGen.VertexCount();
D3D11_BUFFER_DESC desc{ size, D3D11_USAGE_IMMUTABLE, D3D11_BIND_INDEX_BUFFER, 0 };
D3D11_SUBRESOURCE_DATA data{ decIndex };
D3D11_SUBRESOURCE_DATA data{ decIndex_ };
ASSERT_SUCCESS(device_->CreateBuffer(&desc, &data, &vai->ebo));
} else {
vai->ebo = 0;
@ -556,7 +556,7 @@ rotateVBO:
UINT iOffset;
int iSize = 2 * indexGen.VertexCount();
uint8_t *iptr = pushInds_->BeginPush(context_, &iOffset, iSize);
memcpy(iptr, decIndex, iSize);
memcpy(iptr, decIndex_, iSize);
pushInds_->EndPush(context_);
context_->IASetIndexBuffer(pushInds_->Buf(), DXGI_FORMAT_R16_UINT, iOffset);
context_->DrawIndexed(vertexCount, 0, 0);
@ -595,12 +595,12 @@ rotateVBO:
prim = GE_PRIM_TRIANGLES;
VERBOSE_LOG(G3D, "Flush prim %i SW! %i verts in one go", prim, indexGen.VertexCount());
u16 *inds = decIndex;
u16 *inds = decIndex_;
SoftwareTransformResult result{};
SoftwareTransformParams params{};
params.decoded = decoded_;
params.transformed = transformed;
params.transformedExpanded = transformedExpanded;
params.transformed = transformed_;
params.transformedExpanded = transformedExpanded_;
params.fbman = framebufferManager_;
params.texCache = textureCache_;
params.allowClear = true;
@ -716,12 +716,12 @@ rotateVBO:
}
gpuStats.numFlushes++;
gpuStats.numDrawCalls += numDrawCalls;
gpuStats.numDrawCalls += numDrawCalls_;
gpuStats.numVertsSubmitted += vertexCountInDrawCalls_;
indexGen.Reset();
decodedVerts_ = 0;
numDrawCalls = 0;
numDrawCalls_ = 0;
vertexCountInDrawCalls_ = 0;
decodeCounter_ = 0;
dcid_ = 0;

View file

@ -138,19 +138,19 @@ public:
// So that this can be inlined
void Flush() {
if (!numDrawCalls)
if (!numDrawCalls_)
return;
DoFlush();
}
void FinishDeferred() {
if (!numDrawCalls)
if (!numDrawCalls_)
return;
DecodeVerts(decoded_);
}
void DispatchFlush() override {
if (!numDrawCalls)
if (!numDrawCalls_)
return;
Flush();
}

View file

@ -92,7 +92,7 @@ DrawEngineDX9::DrawEngineDX9(Draw::DrawContext *draw) : draw_(draw), vai_(256),
decimationCounter_ = VERTEXCACHE_DECIMATION_INTERVAL;
indexGen.Setup(decIndex);
indexGen.Setup(decIndex_);
InitDeviceObjects();
@ -312,7 +312,7 @@ void DrawEngineDX9::Invalidate(InvalidationCallbackFlags flags) {
}
}
// The inline wrapper in the header checks for numDrawCalls == 0
// The inline wrapper in the header checks for numDrawCalls_ == 0
void DrawEngineDX9::DoFlush() {
bool textureNeedsApply = false;
if (gstate_c.IsDirty(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS) && !gstate.isModeClear() && gstate.isTextureMapEnabled()) {
@ -435,7 +435,7 @@ void DrawEngineDX9::DoFlush() {
u32 size = sizeof(short) * indexGen.VertexCount();
device_->CreateIndexBuffer(size, D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_DEFAULT, &vai->ebo, NULL);
vai->ebo->Lock(0, size, &pIb, 0);
memcpy(pIb, decIndex, size);
memcpy(pIb, decIndex_, size);
vai->ebo->Unlock();
} else {
vai->ebo = 0;
@ -521,7 +521,7 @@ rotateVBO:
device_->SetVertexDeclaration(pHardwareVertexDecl);
if (vb_ == NULL) {
if (useElements) {
device_->DrawIndexedPrimitiveUP(d3d_prim[prim], 0, maxIndex + 1, D3DPrimCount(d3d_prim[prim], vertexCount), decIndex, D3DFMT_INDEX16, decoded_, dec_->GetDecVtxFmt().stride);
device_->DrawIndexedPrimitiveUP(d3d_prim[prim], 0, maxIndex + 1, D3DPrimCount(d3d_prim[prim], vertexCount), decIndex_, D3DFMT_INDEX16, decoded_, dec_->GetDecVtxFmt().stride);
} else {
device_->DrawPrimitiveUP(d3d_prim[prim], D3DPrimCount(d3d_prim[prim], vertexCount), decoded_, dec_->GetDecVtxFmt().stride);
}
@ -558,12 +558,12 @@ rotateVBO:
prim = GE_PRIM_TRIANGLES;
VERBOSE_LOG(G3D, "Flush prim %i SW! %i verts in one go", prim, indexGen.VertexCount());
u16 *inds = decIndex;
u16 *inds = decIndex_;
SoftwareTransformResult result{};
SoftwareTransformParams params{};
params.decoded = decoded_;
params.transformed = transformed;
params.transformedExpanded = transformedExpanded;
params.transformed = transformed_;
params.transformedExpanded = transformedExpanded_;
params.fbman = framebufferManager_;
params.texCache = textureCache_;
params.allowClear = true;
@ -658,12 +658,12 @@ rotateVBO:
}
gpuStats.numFlushes++;
gpuStats.numDrawCalls += numDrawCalls;
gpuStats.numDrawCalls += numDrawCalls_;
gpuStats.numVertsSubmitted += vertexCountInDrawCalls_;
indexGen.Reset();
decodedVerts_ = 0;
numDrawCalls = 0;
numDrawCalls_ = 0;
vertexCountInDrawCalls_ = 0;
decodeCounter_ = 0;
dcid_ = 0;

View file

@ -128,19 +128,19 @@ public:
// So that this can be inlined
void Flush() {
if (!numDrawCalls)
if (!numDrawCalls_)
return;
DoFlush();
}
void FinishDeferred() {
if (!numDrawCalls)
if (!numDrawCalls_)
return;
DecodeVerts(decoded_);
}
void DispatchFlush() override {
if (!numDrawCalls)
if (!numDrawCalls_)
return;
Flush();
}

View file

@ -67,7 +67,7 @@ DrawEngineGLES::DrawEngineGLES(Draw::DrawContext *draw) : inputLayoutMap_(16), d
decOptions_.expandAllWeightsToFloat = false;
decOptions_.expand8BitNormalsToFloat = false;
indexGen.Setup(decIndex);
indexGen.Setup(decIndex_);
InitDeviceObjects();
@ -245,7 +245,7 @@ void DrawEngineGLES::DoFlush() {
// can't goto bail here, skips too many variable initializations. So let's wipe the most important stuff.
indexGen.Reset();
decodedVerts_ = 0;
numDrawCalls = 0;
numDrawCalls_ = 0;
vertexCountInDrawCalls_ = 0;
decodeCounter_ = 0;
dcid_ = 0;
@ -276,7 +276,8 @@ void DrawEngineGLES::DoFlush() {
bool useElements = true;
if (decOptions_.applySkinInDecode && (lastVType_ & GE_VTYPE_WEIGHT_MASK)) {
// If software skinning, we've already predecoded into "decoded_". So push that content.
// If software skinning, we've already predecoded into "decoded_", and indices
// into decIndex_. So push that content.
uint32_t size = decodedVerts_ * dec_->GetDecVtxFmt().stride;
u8 *dest = (u8 *)frameData.pushVertex->Allocate(size, 4, &vertexBuffer, &vertexBufferOffset);
memcpy(dest, decoded_, size);
@ -284,6 +285,7 @@ void DrawEngineGLES::DoFlush() {
// Figure out how much pushbuffer space we need to allocate.
int vertsToDecode = ComputeNumVertsToDecode();
u8 *dest = (u8 *)frameData.pushVertex->Allocate(vertsToDecode * dec_->GetDecVtxFmt().stride, 4, &vertexBuffer, &vertexBufferOffset);
// Indices are decoded in here.
DecodeVerts(dest);
}
@ -291,12 +293,20 @@ void DrawEngineGLES::DoFlush() {
// If there's only been one primitive type, and it's either TRIANGLES, LINES or POINTS,
// there is no need for the index buffer we built. We can then use glDrawArrays instead
// for a very minor speed boost.
// for a very minor speed boost. TODO: We can probably detect this case earlier, like before
// actually doing any vertex decoding (unless we're doing soft skinning and pre-decode on submit).
useElements = !indexGen.SeenOnlyPurePrims();
vertexCount = indexGen.VertexCount();
if (!useElements && indexGen.PureCount()) {
vertexCount = indexGen.PureCount();
}
if (useElements) {
uint32_t esz = sizeof(uint16_t) * indexGen.VertexCount();
void *dest = frameData.pushIndex->Allocate(esz, 2, &indexBuffer, &indexBufferOffset);
// TODO: When we need to apply an index offset, we can apply it directly when copying the indices here.
// Of course, minding the maximum value of 65535...
memcpy(dest, decIndex_, esz);
}
prim = indexGen.Prim();
bool hasColor = (lastVType_ & GE_VTYPE_COL_MASK) != GE_VTYPE_COL_NONE;
@ -317,11 +327,6 @@ void DrawEngineGLES::DoFlush() {
LinkedShader *program = shaderManager_->ApplyFragmentShader(vsid, vshader, pipelineState_, framebufferManager_->UseBufferedRendering());
GLRInputLayout *inputLayout = SetupDecFmtForDraw(program, dec_->GetDecVtxFmt());
if (useElements) {
if (!indexBuffer) {
uint32_t esz = sizeof(uint16_t) * indexGen.VertexCount();
void *dest = frameData.pushIndex->Allocate(esz, 2, &indexBuffer, &indexBufferOffset);
memcpy(dest, decIndex, esz);
}
render_->DrawIndexed(inputLayout,
vertexBuffer, vertexBufferOffset,
indexBuffer, indexBufferOffset,
@ -353,13 +358,13 @@ void DrawEngineGLES::DoFlush() {
if (prim == GE_PRIM_TRIANGLE_STRIP)
prim = GE_PRIM_TRIANGLES;
u16 *inds = decIndex;
u16 *inds = decIndex_;
SoftwareTransformResult result{};
// TODO: Keep this static? Faster than repopulating?
SoftwareTransformParams params{};
params.decoded = decoded_;
params.transformed = transformed;
params.transformedExpanded = transformedExpanded;
params.transformed = transformed_;
params.transformedExpanded = transformedExpanded_;
params.fbman = framebufferManager_;
params.texCache = textureCache_;
params.allowClear = true; // Clear in OpenGL respects scissor rects, so we'll use it.
@ -467,12 +472,12 @@ void DrawEngineGLES::DoFlush() {
bail:
gpuStats.numFlushes++;
gpuStats.numDrawCalls += numDrawCalls;
gpuStats.numDrawCalls += numDrawCalls_;
gpuStats.numVertsSubmitted += vertexCountInDrawCalls_;
indexGen.Reset();
decodedVerts_ = 0;
numDrawCalls = 0;
numDrawCalls_ = 0;
vertexCountInDrawCalls_ = 0;
decodeCounter_ = 0;
dcid_ = 0;

View file

@ -86,19 +86,19 @@ public:
// So that this can be inlined
void Flush() {
if (!numDrawCalls)
if (!numDrawCalls_)
return;
DoFlush();
}
void FinishDeferred() {
if (!numDrawCalls)
if (!numDrawCalls_)
return;
DoFlush();
}
void DispatchFlush() override {
if (!numDrawCalls)
if (!numDrawCalls_)
return;
Flush();
}

View file

@ -75,7 +75,7 @@ DrawEngineVulkan::DrawEngineVulkan(Draw::DrawContext *draw)
decOptions_.alignOutputToWord = true;
#endif
indexGen.Setup(decIndex);
indexGen.Setup(decIndex_);
}
void DrawEngineVulkan::InitDeviceObjects() {
@ -552,7 +552,7 @@ void DrawEngineVulkan::Invalidate(InvalidationCallbackFlags flags) {
}
}
// The inline wrapper in the header checks for numDrawCalls == 0
// The inline wrapper in the header checks for numDrawCalls_ == 0
void DrawEngineVulkan::DoFlush() {
VulkanRenderManager *renderManager = (VulkanRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
@ -685,7 +685,7 @@ void DrawEngineVulkan::DoFlush() {
if (useElements) {
u32 size = sizeof(uint16_t) * indexGen.VertexCount();
void *dest = vertexCache_->Allocate(size, 4, &vai->ib, &vai->ibOffset);
memcpy(dest, decIndex, size);
memcpy(dest, decIndex_, size);
} else {
vai->ib = VK_NULL_HANDLE;
vai->ibOffset = 0;
@ -828,7 +828,7 @@ void DrawEngineVulkan::DoFlush() {
};
if (useElements) {
if (!ibuf) {
ibOffset = (uint32_t)pushIndex_->Push(decIndex, sizeof(uint16_t) * indexGen.VertexCount(), 4, &ibuf);
ibOffset = (uint32_t)pushIndex_->Push(decIndex_, sizeof(uint16_t) * indexGen.VertexCount(), 4, &ibuf);
}
renderManager->DrawIndexed(ds, ARRAY_SIZE(dynamicUBOOffsets), dynamicUBOOffsets, vbuf, vbOffset, ibuf, ibOffset, vertexCount, 1, VK_INDEX_TYPE_UINT16);
} else {
@ -855,12 +855,12 @@ void DrawEngineVulkan::DoFlush() {
if (prim == GE_PRIM_TRIANGLE_STRIP)
prim = GE_PRIM_TRIANGLES;
u16 *inds = decIndex;
u16 *inds = decIndex_;
SoftwareTransformResult result{};
SoftwareTransformParams params{};
params.decoded = decoded_;
params.transformed = transformed;
params.transformedExpanded = transformedExpanded;
params.transformed = transformed_;
params.transformedExpanded = transformedExpanded_;
params.fbman = framebufferManager_;
params.texCache = textureCache_;
// In Vulkan, we have to force drawing of primitives if !framebufferManager_->UseBufferedRendering() because Vulkan clears
@ -929,7 +929,7 @@ void DrawEngineVulkan::DoFlush() {
if (!pipeline || !pipeline->pipeline) {
// Already logged, let's bail out.
decodedVerts_ = 0;
numDrawCalls = 0;
numDrawCalls_ = 0;
decodeCounter_ = 0;
decOptions_.applySkinInDecode = g_Config.bSoftwareSkinning;
return;
@ -1003,12 +1003,12 @@ void DrawEngineVulkan::DoFlush() {
}
gpuStats.numFlushes++;
gpuStats.numDrawCalls += numDrawCalls;
gpuStats.numDrawCalls += numDrawCalls_;
gpuStats.numVertsSubmitted += vertexCountInDrawCalls_;
indexGen.Reset();
decodedVerts_ = 0;
numDrawCalls = 0;
numDrawCalls_ = 0;
vertexCountInDrawCalls_ = 0;
decodeCounter_ = 0;
dcid_ = 0;

View file

@ -163,13 +163,13 @@ public:
// So that this can be inlined
void Flush() {
if (!numDrawCalls)
if (!numDrawCalls_)
return;
DoFlush();
}
void FinishDeferred() {
if (!numDrawCalls)
if (!numDrawCalls_)
return;
// Decode any pending vertices. And also flush while we're at it, for simplicity.
// It might be possible to only decode like in the other backends, but meh, it can't matter.
@ -178,7 +178,7 @@ public:
}
void DispatchFlush() override {
if (!numDrawCalls)
if (!numDrawCalls_)
return;
Flush();
}