Skip to content

Commit

Permalink
GLR: Share union struct between Draw/DrawIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed May 10, 2023
1 parent c882046 commit d5e0299
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
7 changes: 3 additions & 4 deletions Common/GPU/OpenGL/GLQueueRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1196,12 +1196,11 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last
glDrawArrays(c.draw.mode, c.draw.first, c.draw.count);
break;
case GLRRenderCommand::DRAW_INDEXED:
if (c.drawIndexed.instances == 1) {
glDrawElements(c.drawIndexed.mode, c.drawIndexed.count, c.drawIndexed.indexType, c.drawIndexed.indices);
if (c.draw.instances == 1) {
glDrawElements(c.draw.mode, c.draw.count, c.draw.indexType, c.draw.indices);
} else {
glDrawElementsInstanced(c.drawIndexed.mode, c.drawIndexed.count, c.drawIndexed.indexType, c.drawIndexed.indices, c.drawIndexed.instances);
glDrawElementsInstanced(c.draw.mode, c.draw.count, c.draw.indexType, c.draw.indices, c.draw.instances);
}
CHECK_GL_ERROR_IF_DEBUG();
break;
case GLRRenderCommand::TEXTURESAMPLER:
{
Expand Down
9 changes: 2 additions & 7 deletions Common/GPU/OpenGL/GLQueueRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,12 @@ struct GLRRenderData {
} stencilOp; // also write mask
struct {
GLenum mode; // primitive
GLint buffer;
GLint first;
GLint count;
} draw;
struct {
GLenum mode; // primitive
GLint count;
void *indices;
GLint instances;
GLint indexType;
void *indices;
} drawIndexed;
} draw;
struct {
const char *name; // if null, use loc
const GLint *loc; // NOTE: This is a pointer so we can immediately use things that are "queried" during program creation.
Expand Down
12 changes: 6 additions & 6 deletions Common/GPU/OpenGL/GLRenderManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -923,19 +923,19 @@ class GLRenderManager {
data.draw.mode = mode;
data.draw.first = first;
data.draw.count = count;
data.draw.buffer = 0;
data.draw.indices = nullptr;
curRenderStep_->commands.push_back(data);
curRenderStep_->render.numDraws++;
}

void DrawIndexed(GLenum mode, int count, GLenum indexType, void *indices, int instances = 1) {
_dbg_assert_(curRenderStep_ && curRenderStep_->stepType == GLRStepType::RENDER);
GLRRenderData data{ GLRRenderCommand::DRAW_INDEXED };
data.drawIndexed.mode = mode;
data.drawIndexed.count = count;
data.drawIndexed.indexType = indexType;
data.drawIndexed.instances = instances;
data.drawIndexed.indices = indices;
data.draw.mode = mode;
data.draw.count = count;
data.draw.indices = indices;
data.draw.indexType = indexType;
data.draw.instances = instances;
curRenderStep_->commands.push_back(data);
curRenderStep_->render.numDraws++;
}
Expand Down
2 changes: 1 addition & 1 deletion Common/VR/PPSSPPVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ void PreprocessSkyplane(GLRStep* step) {
if (command.cmd == GLRRenderCommand::DEPTH) {
depthEnabled = command.depth.enabled;
} else if ((command.cmd == GLRRenderCommand::DRAW_INDEXED) && !depthEnabled) {
command.drawIndexed.count = 0;
command.draw.count = 0;
}
}
}
Expand Down

0 comments on commit d5e0299

Please sign in to comment.