Cleaned up some internal love.graphics code.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-12-03 23:04:40 -04:00
parent cbcb1a8606
commit e099e57052
7 changed files with 40 additions and 51 deletions
+16 -5
View File
@@ -323,7 +323,13 @@ void Graphics::draw(PrimitiveType primtype, int vertexstart, int vertexcount, in
gl.bindTextureToUnit(texture, 0, false);
GLenum glprimitivetype = OpenGL::getGLPrimitiveType(primtype);
gl.drawArrays(glprimitivetype, vertexstart, vertexcount, instancecount);
if (instancecount > 1)
glDrawArraysInstanced(glprimitivetype, vertexstart, vertexcount, instancecount);
else
glDrawArrays(glprimitivetype, vertexstart, vertexcount);
++drawCalls;
}
void Graphics::drawIndexed(PrimitiveType primtype, int indexcount, int instancecount, IndexDataType datatype, Resource *indexbuffer, size_t indexoffset, const vertex::Attributes &attribs, const vertex::Buffers &buffers, love::graphics::Texture *texture)
@@ -337,7 +343,13 @@ void Graphics::drawIndexed(PrimitiveType primtype, int indexcount, int instancec
GLenum gldatatype = OpenGL::getGLIndexDataType(datatype);
gl.bindBuffer(BUFFER_INDEX, indexbuffer->getHandle());
gl.drawElements(glprimitivetype, indexcount, gldatatype, gloffset, instancecount);
if (instancecount > 1)
glDrawElementsInstanced(glprimitivetype, indexcount, gldatatype, gloffset, instancecount);
else
glDrawElements(glprimitivetype, indexcount, gldatatype, gloffset);
++drawCalls;
}
static void APIENTRY debugCB(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei /*len*/, const GLchar *msg, const GLvoid* /*usr*/)
@@ -949,7 +961,7 @@ void Graphics::present(void *screenshotCallbackData)
window->swapBuffers();
// Reset the per-frame stat counts.
gl.stats.drawCalls = 0;
drawCalls = 0;
gl.stats.shaderSwitches = 0;
canvasSwitchCount = 0;
drawCallsBatched = 0;
@@ -1260,9 +1272,8 @@ Graphics::RendererInfo Graphics::getRendererInfo() const
return info;
}
void Graphics::getAPIStats(int &drawcalls, int &shaderswitches) const
void Graphics::getAPIStats(int &shaderswitches) const
{
drawcalls = gl.stats.drawCalls;
shaderswitches = gl.stats.shaderSwitches;
}
+1 -1
View File
@@ -115,7 +115,7 @@ private:
love::graphics::StreamBuffer *newStreamBuffer(BufferType type, size_t size) override;
void setCanvasInternal(const RenderTargets &rts, int w, int h, int pixelw, int pixelh, bool hasSRGBcanvas) override;
void initCapabilities() override;
void getAPIStats(int &drawcalls, int &shaderswitches) const override;
void getAPIStats(int &shaderswitches) const override;
void endPass();
void bindCachedFBO(const RenderTargets &targets);
-20
View File
@@ -627,26 +627,6 @@ void OpenGL::deleteBuffer(GLuint buffer)
}
}
void OpenGL::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instancecount)
{
if (instancecount > 1)
glDrawArraysInstanced(mode, first, count, instancecount);
else
glDrawArrays(mode, first, count);
++stats.drawCalls;
}
void OpenGL::drawElements(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount)
{
if (instancecount > 1)
glDrawElementsInstanced(mode, count, type, indices, instancecount);
else
glDrawElements(mode, count, type, indices);
++stats.drawCalls;
}
void OpenGL::setVertexAttributes(const vertex::Attributes &attributes, const vertex::Buffers &buffers)
{
uint32 enablediff = attributes.enablebits ^ state.enabledAttribArrays;
+1 -6
View File
@@ -115,7 +115,6 @@ public:
struct Stats
{
int drawCalls;
int shaderSwitches;
} stats;
@@ -201,12 +200,8 @@ public:
void deleteBuffer(GLuint buffer);
/**
* glDrawArrays and glDrawElements which increment the draw-call counter by
* themselves.
* Set all vertex attribute state.
**/
void drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instancecount = 1);
void drawElements(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount = 1);
void setVertexAttributes(const vertex::Attributes &attributes, const vertex::Buffers &buffers);
/**