Have Draw and DrawIndexed share command and struct. Will make the next change easier.
This commit is contained in:
parent
d5e0299b0b
commit
c7caefe6d8
4 changed files with 15 additions and 15 deletions
|
@ -1187,20 +1187,21 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last
|
|||
CHECK_GL_ERROR_IF_DEBUG();
|
||||
break;
|
||||
}
|
||||
case GLRRenderCommand::GENMIPS:
|
||||
// TODO: Should we include the texture handle in the command?
|
||||
// Also, should this not be an init command?
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
break;
|
||||
case GLRRenderCommand::DRAW:
|
||||
glDrawArrays(c.draw.mode, c.draw.first, c.draw.count);
|
||||
break;
|
||||
case GLRRenderCommand::DRAW_INDEXED:
|
||||
if (c.draw.instances == 1) {
|
||||
if (c.draw.indexType == 0) {
|
||||
glDrawArrays(c.draw.mode, c.draw.first, c.draw.count);
|
||||
} else if (c.draw.instances == 1) {
|
||||
glDrawElements(c.draw.mode, c.draw.count, c.draw.indexType, c.draw.indices);
|
||||
} else {
|
||||
glDrawElementsInstanced(c.draw.mode, c.draw.count, c.draw.indexType, c.draw.indices, c.draw.instances);
|
||||
}
|
||||
CHECK_GL_ERROR_IF_DEBUG();
|
||||
break;
|
||||
case GLRRenderCommand::GENMIPS:
|
||||
// TODO: Should we include the texture handle in the command?
|
||||
// Also, should this not be an init command?
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
CHECK_GL_ERROR_IF_DEBUG();
|
||||
break;
|
||||
case GLRRenderCommand::TEXTURESAMPLER:
|
||||
{
|
||||
|
|
|
@ -63,7 +63,6 @@ enum class GLRRenderCommand : uint8_t {
|
|||
BIND_VERTEX_BUFFER,
|
||||
GENMIPS,
|
||||
DRAW,
|
||||
DRAW_INDEXED,
|
||||
TEXTURE_SUBIMAGE,
|
||||
};
|
||||
|
||||
|
@ -111,9 +110,9 @@ struct GLRRenderData {
|
|||
GLenum mode; // primitive
|
||||
GLint first;
|
||||
GLint count;
|
||||
GLint indexType;
|
||||
void *indices;
|
||||
GLint instances;
|
||||
GLint indexType;
|
||||
} draw;
|
||||
struct {
|
||||
const char *name; // if null, use loc
|
||||
|
|
|
@ -923,18 +923,18 @@ public:
|
|||
data.draw.mode = mode;
|
||||
data.draw.first = first;
|
||||
data.draw.count = count;
|
||||
data.draw.indices = nullptr;
|
||||
data.draw.indexType = 0;
|
||||
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 };
|
||||
GLRRenderData data{ GLRRenderCommand::DRAW };
|
||||
data.draw.mode = mode;
|
||||
data.draw.count = count;
|
||||
data.draw.indices = indices;
|
||||
data.draw.indexType = indexType;
|
||||
data.draw.indices = indices;
|
||||
data.draw.instances = instances;
|
||||
curRenderStep_->commands.push_back(data);
|
||||
curRenderStep_->render.numDraws++;
|
||||
|
|
|
@ -574,7 +574,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_INDEXED) && !depthEnabled) {
|
||||
} else if ((command.cmd == GLRRenderCommand::DRAW && command.draw.indices != nullptr) && !depthEnabled) {
|
||||
command.draw.count = 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue