mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
GLQueueRunner: Make DrawIndexed parameters more consistent.
This commit is contained in:
parent
ac5f981311
commit
84da0327d6
6 changed files with 27 additions and 23 deletions
|
@ -1229,8 +1229,8 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last
|
|||
{
|
||||
// TODO: Add fast path for glBindVertexBuffer
|
||||
GLRInputLayout *layout = c.draw.inputLayout;
|
||||
GLuint buf = c.draw.buffer ? c.draw.buffer->buffer_ : 0;
|
||||
_dbg_assert_(!c.draw.buffer || !c.draw.buffer->Mapped());
|
||||
GLuint buf = c.draw.vertexBuffer ? c.draw.vertexBuffer->buffer_ : 0;
|
||||
_dbg_assert_(!c.draw.vertexBuffer || !c.draw.vertexBuffer->Mapped());
|
||||
if (buf != curArrayBuffer) {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buf);
|
||||
curArrayBuffer = buf;
|
||||
|
@ -1241,7 +1241,7 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last
|
|||
}
|
||||
for (size_t i = 0; i < layout->entries.size(); i++) {
|
||||
auto &entry = layout->entries[i];
|
||||
glVertexAttribPointer(entry.location, entry.count, entry.type, entry.normalized, entry.stride, (const void *)(c.draw.offset + entry.offset));
|
||||
glVertexAttribPointer(entry.location, entry.count, entry.type, entry.normalized, entry.stride, (const void *)(c.draw.vertexOffset + entry.offset));
|
||||
}
|
||||
if (c.draw.indexBuffer) {
|
||||
GLuint buf = c.draw.indexBuffer->buffer_;
|
||||
|
@ -1251,9 +1251,9 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last
|
|||
curElemArrayBuffer = buf;
|
||||
}
|
||||
if (c.draw.instances == 1) {
|
||||
glDrawElements(c.draw.mode, c.draw.count, c.draw.indexType, c.draw.indices);
|
||||
glDrawElements(c.draw.mode, c.draw.count, c.draw.indexType, (void *)(intptr_t)c.draw.indexOffset);
|
||||
} else {
|
||||
glDrawElementsInstanced(c.draw.mode, c.draw.count, c.draw.indexType, c.draw.indices, c.draw.instances);
|
||||
glDrawElementsInstanced(c.draw.mode, c.draw.count, c.draw.indexType, (void *)(intptr_t)c.draw.indexOffset, c.draw.instances);
|
||||
}
|
||||
} else {
|
||||
glDrawArrays(c.draw.mode, c.draw.first, c.draw.count);
|
||||
|
|
|
@ -106,14 +106,14 @@ struct GLRRenderData {
|
|||
} stencil;
|
||||
struct {
|
||||
GLRInputLayout *inputLayout;
|
||||
GLRBuffer *buffer;
|
||||
size_t offset;
|
||||
GLRBuffer *vertexBuffer;
|
||||
GLRBuffer *indexBuffer;
|
||||
uint32_t vertexOffset;
|
||||
uint32_t indexOffset;
|
||||
GLenum mode; // primitive
|
||||
GLint first;
|
||||
GLint count;
|
||||
GLint indexType;
|
||||
void *indices;
|
||||
GLint instances;
|
||||
} draw;
|
||||
struct {
|
||||
|
|
|
@ -746,13 +746,13 @@ public:
|
|||
data.clear.scissorH = scissorH;
|
||||
}
|
||||
|
||||
void Draw(GLRInputLayout *inputLayout, GLRBuffer *buffer, size_t offset, GLenum mode, int first, int count) {
|
||||
void Draw(GLRInputLayout *inputLayout, GLRBuffer *vertexBuffer, uint32_t vertexOffset, GLenum mode, int first, int count) {
|
||||
_dbg_assert_(curRenderStep_ && curRenderStep_->stepType == GLRStepType::RENDER);
|
||||
GLRRenderData &data = curRenderStep_->commands.push_uninitialized();
|
||||
data.cmd = GLRRenderCommand::DRAW;
|
||||
data.draw.inputLayout = inputLayout;
|
||||
data.draw.offset = offset;
|
||||
data.draw.buffer = buffer;
|
||||
data.draw.vertexOffset = vertexOffset;
|
||||
data.draw.vertexBuffer = vertexBuffer;
|
||||
data.draw.indexBuffer = nullptr;
|
||||
data.draw.mode = mode;
|
||||
data.draw.first = first;
|
||||
|
@ -760,18 +760,19 @@ public:
|
|||
data.draw.indexType = 0;
|
||||
}
|
||||
|
||||
void DrawIndexed(GLRInputLayout *inputLayout, GLRBuffer *buffer, size_t offset, GLRBuffer *indexBuffer, GLenum mode, int count, GLenum indexType, void *indices, int instances = 1) {
|
||||
// Would really love to have a basevertex parameter, but impossible in unextended GLES, without glDrawElementsBaseVertex, unfortunately.
|
||||
void DrawIndexed(GLRInputLayout *inputLayout, GLRBuffer *vertexBuffer, uint32_t vertexOffset, GLRBuffer *indexBuffer, uint32_t indexOffset, GLenum mode, int count, GLenum indexType, int instances = 1) {
|
||||
_dbg_assert_(curRenderStep_ && curRenderStep_->stepType == GLRStepType::RENDER);
|
||||
GLRRenderData &data = curRenderStep_->commands.push_uninitialized();
|
||||
data.cmd = GLRRenderCommand::DRAW;
|
||||
data.draw.inputLayout = inputLayout;
|
||||
data.draw.offset = offset;
|
||||
data.draw.buffer = buffer;
|
||||
data.draw.vertexOffset = vertexOffset;
|
||||
data.draw.vertexBuffer = vertexBuffer;
|
||||
data.draw.indexBuffer = indexBuffer;
|
||||
data.draw.indexOffset = indexOffset;
|
||||
data.draw.mode = mode;
|
||||
data.draw.count = count;
|
||||
data.draw.indexType = indexType;
|
||||
data.draw.indices = indices;
|
||||
data.draw.instances = instances;
|
||||
}
|
||||
|
||||
|
|
|
@ -1347,8 +1347,10 @@ void OpenGLContext::DrawIndexed(int vertexCount, int offset) {
|
|||
ApplySamplers();
|
||||
_assert_(curPipeline_->inputLayout);
|
||||
renderManager_.DrawIndexed(
|
||||
curPipeline_->inputLayout->inputLayout_, curVBuffers_[0]->buffer_, curVBufferOffsets_[0], curIBuffer_->buffer_,
|
||||
curPipeline_->prim, vertexCount, GL_UNSIGNED_SHORT, (void *)((intptr_t)curIBufferOffset_ + offset * sizeof(uint32_t)));
|
||||
curPipeline_->inputLayout->inputLayout_,
|
||||
curVBuffers_[0]->buffer_, curVBufferOffsets_[0],
|
||||
curIBuffer_->buffer_, curIBufferOffset_ + offset * sizeof(uint32_t),
|
||||
curPipeline_->prim, vertexCount, GL_UNSIGNED_SHORT);
|
||||
}
|
||||
|
||||
void OpenGLContext::DrawUP(const void *vdata, int vertexCount) {
|
||||
|
|
|
@ -573,7 +573,7 @@ void PreprocessSkyplane(GLRStep* step) {
|
|||
for (auto& command : step->commands) {
|
||||
if (command.cmd == GLRRenderCommand::DEPTH) {
|
||||
depthEnabled = command.depth.enabled;
|
||||
} else if ((command.cmd == GLRRenderCommand::DRAW && command.draw.indices != nullptr) && !depthEnabled) {
|
||||
} else if ((command.cmd == GLRRenderCommand::DRAW && command.draw.indexBuffer != nullptr) && !depthEnabled) {
|
||||
command.draw.count = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -322,9 +322,10 @@ void DrawEngineGLES::DoFlush() {
|
|||
void *dest = frameData.pushIndex->Allocate(esz, 2, &indexBuffer, &indexBufferOffset);
|
||||
memcpy(dest, decIndex, esz);
|
||||
}
|
||||
render_->DrawIndexed(
|
||||
inputLayout, vertexBuffer, vertexBufferOffset, indexBuffer,
|
||||
glprim[prim], vertexCount, GL_UNSIGNED_SHORT, (GLvoid*)(intptr_t)indexBufferOffset);
|
||||
render_->DrawIndexed(inputLayout,
|
||||
vertexBuffer, vertexBufferOffset,
|
||||
indexBuffer, indexBufferOffset,
|
||||
glprim[prim], vertexCount, GL_UNSIGNED_SHORT);
|
||||
} else {
|
||||
render_->Draw(
|
||||
inputLayout, vertexBuffer, vertexBufferOffset,
|
||||
|
@ -427,8 +428,8 @@ void DrawEngineGLES::DoFlush() {
|
|||
vertexBufferOffset = (uint32_t)frameData.pushVertex->Push(result.drawBuffer, maxIndex * sizeof(TransformedVertex), 4, &vertexBuffer);
|
||||
indexBufferOffset = (uint32_t)frameData.pushIndex->Push(inds, sizeof(uint16_t) * result.drawNumTrans, 2, &indexBuffer);
|
||||
render_->DrawIndexed(
|
||||
softwareInputLayout_, vertexBuffer, vertexBufferOffset, indexBuffer,
|
||||
glprim[prim], result.drawNumTrans, GL_UNSIGNED_SHORT, (void *)(intptr_t)indexBufferOffset);
|
||||
softwareInputLayout_, vertexBuffer, vertexBufferOffset, indexBuffer, indexBufferOffset,
|
||||
glprim[prim], result.drawNumTrans, GL_UNSIGNED_SHORT);
|
||||
} else {
|
||||
vertexBufferOffset = (uint32_t)frameData.pushVertex->Push(result.drawBuffer, result.drawNumTrans * sizeof(TransformedVertex), 4, &vertexBuffer);
|
||||
render_->Draw(
|
||||
|
|
Loading…
Add table
Reference in a new issue