Pass the VertexDecoder pointer around

This commit is contained in:
Henrik Rydgård
2024-12-17 18:24:26 +01:00
parent e74101a2fb
commit 20ecbfdf57
8 changed files with 19 additions and 18 deletions
+3 -3
View File
@@ -1038,10 +1038,10 @@ bool DrawEngineCommon::SubmitPrim(const void *verts, const void *inds, GEPrimiti
return true;
}
void DrawEngineCommon::DecodeVerts(u8 *dest) {
void DrawEngineCommon::DecodeVerts(VertexDecoder *dec, u8 *dest) {
// Note that this should be able to continue a partial decode - we don't necessarily start from zero here (although we do most of the time).
int i = decodeVertsCounter_;
int stride = (int)dec_->GetDecVtxFmt().stride;
int stride = (int)dec->GetDecVtxFmt().stride;
for (; i < numDrawVerts_; i++) {
DeferredVerts &dv = drawVerts_[i];
@@ -1056,7 +1056,7 @@ void DrawEngineCommon::DecodeVerts(u8 *dest) {
}
// Decode the verts (and at the same time apply morphing/skinning). Simple.
dec_->DecodeVerts(dest + numDecodedVerts_ * stride, dv.verts, &dv.uvScale, indexLowerBound, indexUpperBound);
dec->DecodeVerts(dest + numDecodedVerts_ * stride, dv.verts, &dv.uvScale, indexLowerBound, indexUpperBound);
numDecodedVerts_ += indexUpperBound - indexLowerBound + 1;
}
decodeVertsCounter_ = i;
+2 -2
View File
@@ -109,7 +109,7 @@ public:
void FlushSkin() {
if (dec_->skinInDecode) {
DecodeVerts(decoded_);
DecodeVerts(dec_, decoded_);
}
}
@@ -153,7 +153,7 @@ protected:
virtual bool UpdateUseHWTessellation(bool enabled) const { return enabled; }
void UpdatePlanes();
void DecodeVerts(u8 *dest);
void DecodeVerts(VertexDecoder *dec, u8 *dest);
int DecodeInds();
// Preprocessing for spline/bezier
+2 -2
View File
@@ -282,7 +282,7 @@ void DrawEngineD3D11::Flush() {
int vertexCount;
int maxIndex;
bool useElements;
DecodeVerts(decoded_);
DecodeVerts(dec_, decoded_);
DecodeIndsAndGetData(&prim, &vertexCount, &maxIndex, &useElements, false);
gpuStats.numUncachedVertsDrawn += vertexCount;
@@ -351,7 +351,7 @@ void DrawEngineD3D11::Flush() {
lastVType_ |= (1 << 26);
dec_ = GetVertexDecoder(lastVType_);
}
DecodeVerts(decoded_);
DecodeVerts(dec_, decoded_);
int vertexCount = DecodeInds();
bool hasColor = (lastVType_ & GE_VTYPE_COL_MASK) != GE_VTYPE_COL_NONE;
+1 -1
View File
@@ -80,7 +80,7 @@ public:
void Flush() override;
void FinishDeferred() {
DecodeVerts(decoded_);
DecodeVerts(dec_, decoded_);
}
void NotifyConfigChanged() override;
+2 -2
View File
@@ -256,7 +256,7 @@ void DrawEngineDX9::Flush() {
int vertexCount;
int maxIndex;
bool useElements;
DecodeVerts(decoded_);
DecodeVerts(dec_, decoded_);
DecodeIndsAndGetData(&prim, &vertexCount, &maxIndex, &useElements, false);
gpuStats.numUncachedVertsDrawn += vertexCount;
@@ -306,7 +306,7 @@ void DrawEngineDX9::Flush() {
lastVType_ |= (1 << 26);
dec_ = GetVertexDecoder(lastVType_);
}
DecodeVerts(decoded_);
DecodeVerts(dec_, decoded_);
int vertexCount = DecodeInds();
bool hasColor = (lastVType_ & GE_VTYPE_COL_MASK) != GE_VTYPE_COL_NONE;
+1 -1
View File
@@ -71,7 +71,7 @@ public:
void Flush() override;
void FinishDeferred() {
DecodeVerts(decoded_);
DecodeVerts(dec_, decoded_);
}
protected:
+4 -4
View File
@@ -274,7 +274,7 @@ void DrawEngineGLES::Flush() {
if (vshader->UseHWTransform()) {
if (applySkinInDecode_ && (lastVType_ & GE_VTYPE_WEIGHT_MASK)) {
// If software skinning, we're predecoding into "decoded". So make sure we're done, then push that content.
DecodeVerts(decoded_);
DecodeVerts(dec_, decoded_);
uint32_t size = numDecodedVerts_ * dec_->GetDecVtxFmt().stride;
u8 *dest = (u8 *)frameData.pushVertex->Allocate(size, 4, &vertexBuffer, &vertexBufferOffset);
memcpy(dest, decoded_, size);
@@ -282,13 +282,13 @@ void DrawEngineGLES::Flush() {
// 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);
DecodeVerts(dest);
DecodeVerts(dec_, dest);
}
int vertexCount;
int maxIndex;
bool useElements;
DecodeVerts(decoded_);
DecodeVerts(dec_, decoded_);
DecodeIndsAndGetData(&prim, &vertexCount, &maxIndex, &useElements, false);
if (useElements) {
@@ -333,7 +333,7 @@ void DrawEngineGLES::Flush() {
lastVType_ |= (1 << 26);
dec_ = GetVertexDecoder(lastVType_);
}
DecodeVerts(decoded_);
DecodeVerts(dec_, decoded_);
int vertexCount = DecodeInds();
bool hasColor = (lastVType_ & GE_VTYPE_COL_MASK) != GE_VTYPE_COL_NONE;
+4 -3
View File
@@ -260,7 +260,7 @@ void DrawEngineVulkan::Flush() {
VkBuffer vbuf = VK_NULL_HANDLE;
if (applySkinInDecode_ && (lastVType_ & GE_VTYPE_WEIGHT_MASK)) {
// If software skinning, we're predecoding into "decoded". So make sure we're done, then push that content.
DecodeVerts(decoded_);
DecodeVerts(dec_, decoded_);
VkDeviceSize size = numDecodedVerts_ * dec_->GetDecVtxFmt().stride;
u8 *dest = (u8 *)pushVertex_->Allocate(size, 4, &vbuf, &vbOffset);
memcpy(dest, decoded_, size);
@@ -269,7 +269,7 @@ void DrawEngineVulkan::Flush() {
int vertsToDecode = ComputeNumVertsToDecode();
// Decode directly into the pushbuffer
u8 *dest = pushVertex_->Allocate(vertsToDecode * dec_->GetDecVtxFmt().stride, 4, &vbuf, &vbOffset);
DecodeVerts(dest);
DecodeVerts(dec_, dest);
}
int vertexCount;
@@ -381,6 +381,7 @@ void DrawEngineVulkan::Flush() {
}
} else {
PROFILE_THIS_SCOPE("soft");
if (!applySkinInDecode_) {
applySkinInDecode_ = true;
lastVType_ |= (1 << 26);
@@ -388,7 +389,7 @@ void DrawEngineVulkan::Flush() {
}
int prevDecodedVerts = numDecodedVerts_;
DecodeVerts(decoded_);
DecodeVerts(dec_, decoded_);
int vertexCount = DecodeInds();
bool hasColor = (lastVType_ & GE_VTYPE_COL_MASK) != GE_VTYPE_COL_NONE;