mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-15 03:38:37 +00:00
Merge pull request #17494 from hrydgard/drawengine-minor-refactor
DrawEngine minor refactors
This commit is contained in:
commit
ac5f981311
@ -61,7 +61,7 @@ bool GLRBuffer::Unmap() {
|
||||
return glUnmapBuffer(target_) == GL_TRUE;
|
||||
}
|
||||
|
||||
GLPushBuffer::GLPushBuffer(GLRenderManager *render, GLuint target, size_t size) : render_(render), size_(size), target_(target) {
|
||||
GLPushBuffer::GLPushBuffer(GLRenderManager *render, GLuint target, size_t size, const char *tag) : render_(render), size_(size), target_(target), tag_(tag) {
|
||||
bool res = AddBuffer();
|
||||
_assert_(res);
|
||||
}
|
||||
@ -136,6 +136,7 @@ void GLPushBuffer::Flush() {
|
||||
}
|
||||
|
||||
bool GLPushBuffer::AddBuffer() {
|
||||
// INFO_LOG(G3D, "GLPushBuffer(%s): Allocating %d bytes", tag_, size_);
|
||||
BufInfo info;
|
||||
info.localMemory = (uint8_t *)AllocateAlignedMemory(size_, 16);
|
||||
if (!info.localMemory)
|
||||
|
@ -73,11 +73,14 @@ public:
|
||||
size_t size;
|
||||
};
|
||||
|
||||
GLPushBuffer(GLRenderManager *render, GLuint target, size_t size);
|
||||
GLPushBuffer(GLRenderManager *render, GLuint target, size_t size, const char *tag);
|
||||
~GLPushBuffer();
|
||||
|
||||
void Reset() { offset_ = 0; }
|
||||
|
||||
// Utility for users of this class, not used internally.
|
||||
const uint32_t INVALID_OFFSET = 0xFFFFFFFF;
|
||||
|
||||
private:
|
||||
// Needs context in case of defragment.
|
||||
void Begin() {
|
||||
@ -105,7 +108,9 @@ public:
|
||||
return writePtr_ != nullptr;
|
||||
}
|
||||
|
||||
// Recommended - write directly into the buffer through the returned pointer.
|
||||
// Recommended - lets you write directly into the buffer through the returned pointer.
|
||||
// If you didn't end up using all the memory you grabbed here, then before calling Allocate or Push
|
||||
// again, call Rewind (see below).
|
||||
uint8_t *Allocate(uint32_t numBytes, uint32_t alignment, GLRBuffer **buf, uint32_t *bindOffset) {
|
||||
uint32_t offset = ((uint32_t)offset_ + alignment - 1) & ~(alignment - 1);
|
||||
if (offset + numBytes <= size_) {
|
||||
@ -130,6 +135,12 @@ public:
|
||||
return bindOffset;
|
||||
}
|
||||
|
||||
// If you didn't use all of the previous allocation you just made (obviously can't be another one),
|
||||
// you can return memory to the buffer by specifying the offset up until which you wrote data.
|
||||
void Rewind(uint32_t offset) {
|
||||
offset_ = offset;
|
||||
}
|
||||
|
||||
size_t GetOffset() const { return offset_; }
|
||||
size_t GetTotalSize() const;
|
||||
|
||||
@ -153,4 +164,5 @@ private:
|
||||
uint8_t *writePtr_ = nullptr;
|
||||
GLuint target_;
|
||||
GLBufferStrategy strategy_ = GLBufferStrategy::SUBDATA;
|
||||
const char *tag_;
|
||||
};
|
||||
|
@ -334,8 +334,8 @@ public:
|
||||
return step.create_input_layout.inputLayout;
|
||||
}
|
||||
|
||||
GLPushBuffer *CreatePushBuffer(int frame, GLuint target, size_t size) {
|
||||
GLPushBuffer *push = new GLPushBuffer(this, target, size);
|
||||
GLPushBuffer *CreatePushBuffer(int frame, GLuint target, size_t size, const char *tag) {
|
||||
GLPushBuffer *push = new GLPushBuffer(this, target, size, tag);
|
||||
RegisterPushBuffer(frame, push);
|
||||
return push;
|
||||
}
|
||||
|
@ -631,7 +631,7 @@ OpenGLContext::OpenGLContext() {
|
||||
caps_.isTilingGPU = gl_extensions.IsGLES && caps_.vendor != GPUVendor::VENDOR_NVIDIA && caps_.vendor != GPUVendor::VENDOR_INTEL;
|
||||
|
||||
for (int i = 0; i < GLRenderManager::MAX_INFLIGHT_FRAMES; i++) {
|
||||
frameData_[i].push = renderManager_.CreatePushBuffer(i, GL_ARRAY_BUFFER, 64 * 1024);
|
||||
frameData_[i].push = renderManager_.CreatePushBuffer(i, GL_ARRAY_BUFFER, 64 * 1024, "thin3d_vbuf");
|
||||
}
|
||||
|
||||
if (!gl_extensions.VersionGEThan(3, 0, 0)) {
|
||||
@ -1359,7 +1359,9 @@ void OpenGLContext::DrawUP(const void *vdata, int vertexCount) {
|
||||
FrameData &frameData = frameData_[renderManager_.GetCurFrame()];
|
||||
|
||||
GLRBuffer *buf;
|
||||
uint32_t offset = frameData.push->Push(vdata, dataSize, 4, &buf);
|
||||
uint32_t offset;
|
||||
uint8_t *dest = frameData.push->Allocate(dataSize, 4, &buf, &offset);
|
||||
memcpy(dest, vdata, dataSize);
|
||||
|
||||
ApplySamplers();
|
||||
_assert_(curPipeline_->inputLayout);
|
||||
|
@ -787,14 +787,14 @@ bool VKTexture::Create(VkCommandBuffer cmd, VulkanPushPool *push, const TextureD
|
||||
uint32_t offset;
|
||||
VkBuffer buf;
|
||||
size_t size = w * h * d * bytesPerPixel;
|
||||
uint8_t *dest = (uint8_t *)push->Allocate(size, 16, &buf, &offset);
|
||||
if (desc.initDataCallback) {
|
||||
uint8_t *dest = (uint8_t *)push->Allocate(size, 16, &buf, &offset);
|
||||
_assert_(dest != nullptr);
|
||||
if (!desc.initDataCallback(dest, desc.initData[i], w, h, d, w * bytesPerPixel, h * w * bytesPerPixel)) {
|
||||
memcpy(dest, desc.initData[i], size);
|
||||
}
|
||||
} else {
|
||||
offset = push->Push((const void *)desc.initData[i], size, 16, &buf);
|
||||
memcpy(dest, desc.initData[i], size);
|
||||
}
|
||||
TextureCopyBatch batch;
|
||||
vkTex_->CopyBufferToMipLevel(cmd, &batch, i, w, h, 0, buf, offset, w);
|
||||
|
@ -41,12 +41,12 @@ DrawEngineCommon::DrawEngineCommon() : decoderMap_(16) {
|
||||
}
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
DrawEngineCommon::~DrawEngineCommon() {
|
||||
FreeMemoryPages(decoded, DECODED_VERTEX_BUFFER_SIZE);
|
||||
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);
|
||||
@ -255,8 +255,8 @@ void DrawEngineCommon::DispatchSubmitImm(GEPrimitiveType prim, TransformedVertex
|
||||
// It does the simplest and safest test possible: If all points of a bbox is outside a single of
|
||||
// our clipping planes, we reject the box. Tighter bounds would be desirable but would take more calculations.
|
||||
bool DrawEngineCommon::TestBoundingBox(const void *control_points, const void *inds, int vertexCount, u32 vertType) {
|
||||
SimpleVertex *corners = (SimpleVertex *)(decoded + 65536 * 12);
|
||||
float *verts = (float *)(decoded + 65536 * 18);
|
||||
SimpleVertex *corners = (SimpleVertex *)(decoded_ + 65536 * 12);
|
||||
float *verts = (float *)(decoded_ + 65536 * 18);
|
||||
|
||||
// Although this may lead to drawing that shouldn't happen, the viewport is more complex on VR.
|
||||
// Let's always say objects are within bounds.
|
||||
@ -279,7 +279,7 @@ bool DrawEngineCommon::TestBoundingBox(const void *control_points, const void *i
|
||||
}
|
||||
} else {
|
||||
// Simplify away indices, bones, and morph before proceeding.
|
||||
u8 *temp_buffer = decoded + 65536 * 24;
|
||||
u8 *temp_buffer = decoded_ + 65536 * 24;
|
||||
int vertexSize = 0;
|
||||
|
||||
u16 indexLowerBound = 0;
|
||||
@ -849,7 +849,7 @@ void DrawEngineCommon::SubmitPrim(const void *verts, const void *inds, GEPrimiti
|
||||
vertexCountInDrawCalls_ += vertexCount;
|
||||
|
||||
if (decOptions_.applySkinInDecode && (vertTypeID & GE_VTYPE_WEIGHT_MASK)) {
|
||||
DecodeVertsStep(decoded, decodeCounter_, decodedVerts_);
|
||||
DecodeVertsStep(decoded_, decodeCounter_, decodedVerts_);
|
||||
decodeCounter_++;
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,7 @@ protected:
|
||||
bool everUsedExactEqualDepth_ = false;
|
||||
|
||||
// Vertex collector buffers
|
||||
u8 *decoded = nullptr;
|
||||
u8 *decoded_ = nullptr;
|
||||
u16 *decIndex = nullptr;
|
||||
|
||||
// Cached vertex decoders
|
||||
|
@ -498,7 +498,7 @@ void DrawEngineCommon::SubmitCurve(const void *control_points, const void *indic
|
||||
if (surface.num_points_u < 4 || surface.num_points_v < 4)
|
||||
return;
|
||||
|
||||
SimpleBufferManager managedBuf(decoded, DECODED_VERTEX_BUFFER_SIZE / 2);
|
||||
SimpleBufferManager managedBuf(decoded_, DECODED_VERTEX_BUFFER_SIZE / 2);
|
||||
|
||||
int num_points = surface.num_points_u * surface.num_points_v;
|
||||
u16 index_lower_bound = 0;
|
||||
@ -544,7 +544,7 @@ void DrawEngineCommon::SubmitCurve(const void *control_points, const void *indic
|
||||
points[idx] = simplified_control_points + (indices ? ConvertIndex(idx) : idx);
|
||||
|
||||
OutputBuffers output;
|
||||
output.vertices = (SimpleVertex *)(decoded + DECODED_VERTEX_BUFFER_SIZE / 2);
|
||||
output.vertices = (SimpleVertex *)(decoded_ + DECODED_VERTEX_BUFFER_SIZE / 2);
|
||||
output.indices = decIndex;
|
||||
output.count = 0;
|
||||
|
||||
|
@ -380,7 +380,7 @@ void DrawEngineD3D11::DoFlush() {
|
||||
vai->minihash = ComputeMiniHash();
|
||||
vai->status = VertexArrayInfoD3D11::VAI_HASHING;
|
||||
vai->drawsUntilNextFullHash = 0;
|
||||
DecodeVerts(decoded); // writes to indexGen
|
||||
DecodeVerts(decoded_); // writes to indexGen
|
||||
vai->numVerts = indexGen.VertexCount();
|
||||
vai->prim = indexGen.Prim();
|
||||
vai->maxIndex = indexGen.MaxIndex();
|
||||
@ -405,7 +405,7 @@ void DrawEngineD3D11::DoFlush() {
|
||||
}
|
||||
if (newMiniHash != vai->minihash || newHash != vai->hash) {
|
||||
MarkUnreliable(vai);
|
||||
DecodeVerts(decoded);
|
||||
DecodeVerts(decoded_);
|
||||
goto rotateVBO;
|
||||
}
|
||||
if (vai->numVerts > 64) {
|
||||
@ -424,13 +424,13 @@ void DrawEngineD3D11::DoFlush() {
|
||||
u32 newMiniHash = ComputeMiniHash();
|
||||
if (newMiniHash != vai->minihash) {
|
||||
MarkUnreliable(vai);
|
||||
DecodeVerts(decoded);
|
||||
DecodeVerts(decoded_);
|
||||
goto rotateVBO;
|
||||
}
|
||||
}
|
||||
|
||||
if (vai->vbo == 0) {
|
||||
DecodeVerts(decoded);
|
||||
DecodeVerts(decoded_);
|
||||
vai->numVerts = indexGen.VertexCount();
|
||||
vai->prim = indexGen.Prim();
|
||||
vai->maxIndex = indexGen.MaxIndex();
|
||||
@ -445,7 +445,7 @@ void DrawEngineD3D11::DoFlush() {
|
||||
// TODO: Combine these two into one buffer?
|
||||
u32 size = dec_->GetDecVtxFmt().stride * indexGen.MaxIndex();
|
||||
D3D11_BUFFER_DESC desc{ size, D3D11_USAGE_IMMUTABLE, D3D11_BIND_VERTEX_BUFFER, 0 };
|
||||
D3D11_SUBRESOURCE_DATA data{ decoded };
|
||||
D3D11_SUBRESOURCE_DATA data{ decoded_ };
|
||||
ASSERT_SUCCESS(device_->CreateBuffer(&desc, &data, &vai->vbo));
|
||||
if (useElements) {
|
||||
u32 size = sizeof(short) * indexGen.VertexCount();
|
||||
@ -496,14 +496,14 @@ void DrawEngineD3D11::DoFlush() {
|
||||
if (vai->lastFrame != gpuStats.numFlips) {
|
||||
vai->numFrames++;
|
||||
}
|
||||
DecodeVerts(decoded);
|
||||
DecodeVerts(decoded_);
|
||||
goto rotateVBO;
|
||||
}
|
||||
}
|
||||
|
||||
vai->lastFrame = gpuStats.numFlips;
|
||||
} else {
|
||||
DecodeVerts(decoded);
|
||||
DecodeVerts(decoded_);
|
||||
rotateVBO:
|
||||
gpuStats.numUncachedVertsDrawn += indexGen.VertexCount();
|
||||
useElements = !indexGen.SeenOnlyPurePrims() || prim == GE_PRIM_TRIANGLE_FAN;
|
||||
@ -548,7 +548,7 @@ rotateVBO:
|
||||
UINT vOffset;
|
||||
int vSize = (maxIndex + 1) * dec_->GetDecVtxFmt().stride;
|
||||
uint8_t *vptr = pushVerts_->BeginPush(context_, &vOffset, vSize);
|
||||
memcpy(vptr, decoded, vSize);
|
||||
memcpy(vptr, decoded_, vSize);
|
||||
pushVerts_->EndPush(context_);
|
||||
ID3D11Buffer *buf = pushVerts_->Buf();
|
||||
context_->IASetVertexBuffers(0, 1, &buf, &stride, &vOffset);
|
||||
@ -580,7 +580,7 @@ rotateVBO:
|
||||
lastVType_ |= (1 << 26);
|
||||
dec_ = GetVertexDecoder(lastVType_);
|
||||
}
|
||||
DecodeVerts(decoded);
|
||||
DecodeVerts(decoded_);
|
||||
bool hasColor = (lastVType_ & GE_VTYPE_COL_MASK) != GE_VTYPE_COL_NONE;
|
||||
if (gstate.isModeThrough()) {
|
||||
gstate_c.vertexFullAlpha = gstate_c.vertexFullAlpha && (hasColor || gstate.getMaterialAmbientA() == 255);
|
||||
@ -598,7 +598,7 @@ rotateVBO:
|
||||
u16 *inds = decIndex;
|
||||
SoftwareTransformResult result{};
|
||||
SoftwareTransformParams params{};
|
||||
params.decoded = decoded;
|
||||
params.decoded = decoded_;
|
||||
params.transformed = transformed;
|
||||
params.transformedExpanded = transformedExpanded;
|
||||
params.fbman = framebufferManager_;
|
||||
|
@ -146,7 +146,7 @@ public:
|
||||
void FinishDeferred() {
|
||||
if (!numDrawCalls)
|
||||
return;
|
||||
DecodeVerts(decoded);
|
||||
DecodeVerts(decoded_);
|
||||
}
|
||||
|
||||
void DispatchFlush() override {
|
||||
|
@ -361,7 +361,7 @@ void DrawEngineDX9::DoFlush() {
|
||||
vai->minihash = ComputeMiniHash();
|
||||
vai->status = VertexArrayInfoDX9::VAI_HASHING;
|
||||
vai->drawsUntilNextFullHash = 0;
|
||||
DecodeVerts(decoded); // writes to indexGen
|
||||
DecodeVerts(decoded_); // writes to indexGen
|
||||
vai->numVerts = indexGen.VertexCount();
|
||||
vai->prim = indexGen.Prim();
|
||||
vai->maxIndex = indexGen.MaxIndex();
|
||||
@ -387,7 +387,7 @@ void DrawEngineDX9::DoFlush() {
|
||||
}
|
||||
if (newMiniHash != vai->minihash || newHash != vai->hash) {
|
||||
MarkUnreliable(vai);
|
||||
DecodeVerts(decoded);
|
||||
DecodeVerts(decoded_);
|
||||
goto rotateVBO;
|
||||
}
|
||||
if (vai->numVerts > 64) {
|
||||
@ -406,13 +406,13 @@ void DrawEngineDX9::DoFlush() {
|
||||
u32 newMiniHash = ComputeMiniHash();
|
||||
if (newMiniHash != vai->minihash) {
|
||||
MarkUnreliable(vai);
|
||||
DecodeVerts(decoded);
|
||||
DecodeVerts(decoded_);
|
||||
goto rotateVBO;
|
||||
}
|
||||
}
|
||||
|
||||
if (vai->vbo == 0) {
|
||||
DecodeVerts(decoded);
|
||||
DecodeVerts(decoded_);
|
||||
vai->numVerts = indexGen.VertexCount();
|
||||
vai->prim = indexGen.Prim();
|
||||
vai->maxIndex = indexGen.MaxIndex();
|
||||
@ -428,7 +428,7 @@ void DrawEngineDX9::DoFlush() {
|
||||
u32 size = dec_->GetDecVtxFmt().stride * indexGen.MaxIndex();
|
||||
device_->CreateVertexBuffer(size, D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &vai->vbo, NULL);
|
||||
vai->vbo->Lock(0, size, &pVb, 0);
|
||||
memcpy(pVb, decoded, size);
|
||||
memcpy(pVb, decoded_, size);
|
||||
vai->vbo->Unlock();
|
||||
if (useElements) {
|
||||
void * pIb;
|
||||
@ -481,14 +481,14 @@ void DrawEngineDX9::DoFlush() {
|
||||
if (vai->lastFrame != gpuStats.numFlips) {
|
||||
vai->numFrames++;
|
||||
}
|
||||
DecodeVerts(decoded);
|
||||
DecodeVerts(decoded_);
|
||||
goto rotateVBO;
|
||||
}
|
||||
}
|
||||
|
||||
vai->lastFrame = gpuStats.numFlips;
|
||||
} else {
|
||||
DecodeVerts(decoded);
|
||||
DecodeVerts(decoded_);
|
||||
rotateVBO:
|
||||
gpuStats.numUncachedVertsDrawn += indexGen.VertexCount();
|
||||
useElements = !indexGen.SeenOnlyPurePrims();
|
||||
@ -521,9 +521,9 @@ 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);
|
||||
device_->DrawPrimitiveUP(d3d_prim[prim], D3DPrimCount(d3d_prim[prim], vertexCount), decoded_, dec_->GetDecVtxFmt().stride);
|
||||
}
|
||||
} else {
|
||||
device_->SetStreamSource(0, vb_, 0, dec_->GetDecVtxFmt().stride);
|
||||
@ -543,7 +543,7 @@ rotateVBO:
|
||||
lastVType_ |= (1 << 26);
|
||||
dec_ = GetVertexDecoder(lastVType_);
|
||||
}
|
||||
DecodeVerts(decoded);
|
||||
DecodeVerts(decoded_);
|
||||
bool hasColor = (lastVType_ & GE_VTYPE_COL_MASK) != GE_VTYPE_COL_NONE;
|
||||
if (gstate.isModeThrough()) {
|
||||
gstate_c.vertexFullAlpha = gstate_c.vertexFullAlpha && (hasColor || gstate.getMaterialAmbientA() == 255);
|
||||
@ -561,7 +561,7 @@ rotateVBO:
|
||||
u16 *inds = decIndex;
|
||||
SoftwareTransformResult result{};
|
||||
SoftwareTransformParams params{};
|
||||
params.decoded = decoded;
|
||||
params.decoded = decoded_;
|
||||
params.transformed = transformed;
|
||||
params.transformedExpanded = transformedExpanded;
|
||||
params.fbman = framebufferManager_;
|
||||
|
@ -136,7 +136,7 @@ public:
|
||||
void FinishDeferred() {
|
||||
if (!numDrawCalls)
|
||||
return;
|
||||
DecodeVerts(decoded);
|
||||
DecodeVerts(decoded_);
|
||||
}
|
||||
|
||||
void DispatchFlush() override {
|
||||
|
@ -97,8 +97,8 @@ void DrawEngineGLES::InitDeviceObjects() {
|
||||
_assert_msg_(render_ != nullptr, "Render manager must be set");
|
||||
|
||||
for (int i = 0; i < GLRenderManager::MAX_INFLIGHT_FRAMES; i++) {
|
||||
frameData_[i].pushVertex = render_->CreatePushBuffer(i, GL_ARRAY_BUFFER, 1024 * 1024);
|
||||
frameData_[i].pushIndex = render_->CreatePushBuffer(i, GL_ELEMENT_ARRAY_BUFFER, 256 * 1024);
|
||||
frameData_[i].pushVertex = render_->CreatePushBuffer(i, GL_ARRAY_BUFFER, 2048 * 1024, "game_vertex");
|
||||
frameData_[i].pushIndex = render_->CreatePushBuffer(i, GL_ELEMENT_ARRAY_BUFFER, 256 * 1024, "game_index");
|
||||
}
|
||||
|
||||
int vertexSize = sizeof(TransformedVertex);
|
||||
@ -225,18 +225,6 @@ GLRInputLayout *DrawEngineGLES::SetupDecFmtForDraw(LinkedShader *program, const
|
||||
return inputLayout;
|
||||
}
|
||||
|
||||
void *DrawEngineGLES::DecodeVertsToPushBuffer(GLPushBuffer *push, uint32_t *bindOffset, GLRBuffer **buf) {
|
||||
u8 *dest = decoded;
|
||||
|
||||
// Figure out how much pushbuffer space we need to allocate.
|
||||
if (push) {
|
||||
int vertsToDecode = ComputeNumVertsToDecode();
|
||||
dest = (u8 *)push->Allocate(vertsToDecode * dec_->GetDecVtxFmt().stride, 4, buf, bindOffset);
|
||||
}
|
||||
DecodeVerts(dest);
|
||||
return dest;
|
||||
}
|
||||
|
||||
// A new render step means we need to flush any dynamic state. Really, any state that is reset in
|
||||
// GLQueueRunner::PerformRenderPass.
|
||||
void DrawEngineGLES::Invalidate(InvalidationCallbackFlags flags) {
|
||||
@ -288,13 +276,15 @@ 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_". 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);
|
||||
memcpy(dest, decoded_, size);
|
||||
} else {
|
||||
// Decode directly into the pushbuffer
|
||||
u8 *dest = (u8 *)DecodeVertsToPushBuffer(frameData.pushVertex, &vertexBufferOffset, &vertexBuffer);
|
||||
// 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);
|
||||
}
|
||||
|
||||
gpuStats.numUncachedVertsDrawn += indexGen.VertexCount();
|
||||
@ -347,7 +337,7 @@ void DrawEngineGLES::DoFlush() {
|
||||
lastVType_ |= (1 << 26);
|
||||
dec_ = GetVertexDecoder(lastVType_);
|
||||
}
|
||||
DecodeVerts(decoded);
|
||||
DecodeVerts(decoded_);
|
||||
|
||||
bool hasColor = (lastVType_ & GE_VTYPE_COL_MASK) != GE_VTYPE_COL_NONE;
|
||||
if (gstate.isModeThrough()) {
|
||||
@ -366,7 +356,7 @@ void DrawEngineGLES::DoFlush() {
|
||||
SoftwareTransformResult result{};
|
||||
// TODO: Keep this static? Faster than repopulating?
|
||||
SoftwareTransformParams params{};
|
||||
params.decoded = decoded;
|
||||
params.decoded = decoded_;
|
||||
params.transformed = transformed;
|
||||
params.transformedExpanded = transformedExpanded;
|
||||
params.fbman = framebufferManager_;
|
||||
|
@ -103,13 +103,6 @@ public:
|
||||
Flush();
|
||||
}
|
||||
|
||||
GLPushBuffer *GetPushVertexBuffer() {
|
||||
return frameData_[render_->GetCurFrame()].pushVertex;
|
||||
}
|
||||
GLPushBuffer *GetPushIndexBuffer() {
|
||||
return frameData_[render_->GetCurFrame()].pushIndex;
|
||||
}
|
||||
|
||||
void ClearInputLayoutMap();
|
||||
|
||||
bool SupportsHWTessellation() const;
|
||||
@ -129,8 +122,6 @@ private:
|
||||
|
||||
GLRInputLayout *SetupDecFmtForDraw(LinkedShader *program, const DecVtxFormat &decFmt);
|
||||
|
||||
void *DecodeVertsToPushBuffer(GLPushBuffer *push, uint32_t *bindOffset, GLRBuffer **buf);
|
||||
|
||||
struct FrameData {
|
||||
GLPushBuffer *pushVertex;
|
||||
GLPushBuffer *pushIndex;
|
||||
@ -153,7 +144,6 @@ private:
|
||||
ViewportAndScissor vpAndScissor;
|
||||
|
||||
int bufferDecimationCounter_ = 0;
|
||||
|
||||
int lastRenderStepId_ = -1;
|
||||
|
||||
// Hardware tessellation
|
||||
|
@ -352,7 +352,7 @@ void DrawEngineVulkan::EndFrame() {
|
||||
}
|
||||
|
||||
void DrawEngineVulkan::DecodeVertsToPushBuffer(VulkanPushBuffer *push, uint32_t *bindOffset, VkBuffer *vkbuf) {
|
||||
u8 *dest = decoded;
|
||||
u8 *dest = decoded_;
|
||||
|
||||
// Figure out how much pushbuffer space we need to allocate.
|
||||
if (push) {
|
||||
@ -363,7 +363,7 @@ void DrawEngineVulkan::DecodeVertsToPushBuffer(VulkanPushBuffer *push, uint32_t
|
||||
}
|
||||
|
||||
void DrawEngineVulkan::DecodeVertsToPushPool(VulkanPushPool *push, uint32_t *bindOffset, VkBuffer *vkbuf) {
|
||||
u8 *dest = decoded;
|
||||
u8 *dest = decoded_;
|
||||
|
||||
// Figure out how much pushbuffer space we need to allocate.
|
||||
if (push) {
|
||||
@ -742,7 +742,7 @@ void DrawEngineVulkan::DoFlush() {
|
||||
// If software skinning, we've already predecoded into "decoded". So push that content.
|
||||
VkDeviceSize size = decodedVerts_ * dec_->GetDecVtxFmt().stride;
|
||||
u8 *dest = (u8 *)pushVertex_->Allocate(size, 4, &vbuf, &vbOffset);
|
||||
memcpy(dest, decoded, size);
|
||||
memcpy(dest, decoded_, size);
|
||||
} else {
|
||||
// Decode directly into the pushbuffer
|
||||
DecodeVertsToPushPool(pushVertex_, &vbOffset, &vbuf);
|
||||
@ -841,7 +841,7 @@ void DrawEngineVulkan::DoFlush() {
|
||||
lastVType_ |= (1 << 26);
|
||||
dec_ = GetVertexDecoder(lastVType_);
|
||||
}
|
||||
DecodeVerts(decoded);
|
||||
DecodeVerts(decoded_);
|
||||
bool hasColor = (lastVType_ & GE_VTYPE_COL_MASK) != GE_VTYPE_COL_NONE;
|
||||
if (gstate.isModeThrough()) {
|
||||
gstate_c.vertexFullAlpha = gstate_c.vertexFullAlpha && (hasColor || gstate.getMaterialAmbientA() == 255);
|
||||
@ -858,7 +858,7 @@ void DrawEngineVulkan::DoFlush() {
|
||||
u16 *inds = decIndex;
|
||||
SoftwareTransformResult result{};
|
||||
SoftwareTransformParams params{};
|
||||
params.decoded = decoded;
|
||||
params.decoded = decoded_;
|
||||
params.transformed = transformed;
|
||||
params.transformedExpanded = transformedExpanded;
|
||||
params.fbman = framebufferManager_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user