Rename internal batched draw code to be more clear

This commit is contained in:
Alex Szpakowski
2020-02-27 20:08:50 -04:00
parent 20e7b1745c
commit 9425c9224b
15 changed files with 82 additions and 82 deletions
+1 -1
View File
@@ -82,7 +82,7 @@ void Deprecations::draw(Graphics *gfx)
font.set(gfx->newDefaultFont(9, hinting), Acquire::NORETAIN); font.set(gfx->newDefaultFont(9, hinting), Acquire::NORETAIN);
} }
gfx->flushStreamDraws(); gfx->flushBatchedDraws();
gfx->push(Graphics::STACK_ALL); gfx->push(Graphics::STACK_ALL);
gfx->reset(); gfx->reset();
+3 -3
View File
@@ -133,7 +133,7 @@ bool Font::loadVolatile()
void Font::createTexture() void Font::createTexture()
{ {
auto gfx = Module::getInstance<graphics::Graphics>(Module::M_GRAPHICS); auto gfx = Module::getInstance<graphics::Graphics>(Module::M_GRAPHICS);
gfx->flushStreamDraws(); gfx->flushBatchedDraws();
Texture *texture = nullptr; Texture *texture = nullptr;
TextureSize size = {textureWidth, textureHeight}; TextureSize size = {textureWidth, textureHeight};
@@ -645,13 +645,13 @@ void Font::printv(graphics::Graphics *gfx, const Matrix4 &t, const std::vector<D
for (const DrawCommand &cmd : drawcommands) for (const DrawCommand &cmd : drawcommands)
{ {
Graphics::StreamDrawCommand streamcmd; Graphics::BatchedDrawCommand streamcmd;
streamcmd.formats[0] = vertexFormat; streamcmd.formats[0] = vertexFormat;
streamcmd.indexMode = vertex::TriangleIndexMode::QUADS; streamcmd.indexMode = vertex::TriangleIndexMode::QUADS;
streamcmd.vertexCount = cmd.vertexcount; streamcmd.vertexCount = cmd.vertexcount;
streamcmd.texture = cmd.texture; streamcmd.texture = cmd.texture;
Graphics::StreamVertexData data = gfx->requestStreamDraw(streamcmd); Graphics::BatchedVertexData data = gfx->requestBatchedDraw(streamcmd);
GlyphVertex *vertexdata = (GlyphVertex *) data.stream[0]; GlyphVertex *vertexdata = (GlyphVertex *) data.stream[0];
memcpy(vertexdata, &vertices[cmd.startvertex], sizeof(GlyphVertex) * cmd.vertexcount); memcpy(vertexdata, &vertices[cmd.startvertex], sizeof(GlyphVertex) * cmd.vertexcount);
+21 -21
View File
@@ -114,7 +114,7 @@ Graphics::Graphics()
, created(false) , created(false)
, active(true) , active(true)
, writingToStencil(false) , writingToStencil(false)
, streamBufferState() , batchedDrawState()
, projectionMatrix() , projectionMatrix()
, renderTargetSwitchCount(0) , renderTargetSwitchCount(0)
, drawCalls(0) , drawCalls(0)
@@ -157,9 +157,9 @@ Graphics::~Graphics()
defaultFont.set(nullptr); defaultFont.set(nullptr);
delete streamBufferState.vb[0]; delete batchedDrawState.vb[0];
delete streamBufferState.vb[1]; delete batchedDrawState.vb[1];
delete streamBufferState.indexBuffer; delete batchedDrawState.indexBuffer;
for (int i = 0; i < (int) ShaderStage::STAGE_MAX_ENUM; i++) for (int i = 0; i < (int) ShaderStage::STAGE_MAX_ENUM; i++)
cachedShaderStages[i].clear(); cachedShaderStages[i].clear();
@@ -691,7 +691,7 @@ void Graphics::setRenderTargets(const RenderTargets &rts)
int w = firsttex->getWidth(firsttarget.mipmap); int w = firsttex->getWidth(firsttarget.mipmap);
int h = firsttex->getHeight(firsttarget.mipmap); int h = firsttex->getHeight(firsttarget.mipmap);
flushStreamDraws(); flushBatchedDraws();
if (rts.depthStencil.texture == nullptr && rts.temporaryRTFlags != 0) if (rts.depthStencil.texture == nullptr && rts.temporaryRTFlags != 0)
{ {
@@ -741,7 +741,7 @@ void Graphics::setRenderTarget()
if (state.renderTargets.colors.empty() && state.renderTargets.depthStencil.texture == nullptr) if (state.renderTargets.colors.empty() && state.renderTargets.depthStencil.texture == nullptr)
return; return;
flushStreamDraws(); flushBatchedDraws();
setRenderTargetsInternal(RenderTargets(), width, height, pixelWidth, pixelHeight, isGammaCorrect()); setRenderTargetsInternal(RenderTargets(), width, height, pixelWidth, pixelHeight, isGammaCorrect());
state.renderTargets = RenderTargetsStrongRef(); state.renderTargets = RenderTargetsStrongRef();
@@ -986,11 +986,11 @@ void Graphics::captureScreenshot(const ScreenshotInfo &info)
pendingScreenshotCallbacks.push_back(info); pendingScreenshotCallbacks.push_back(info);
} }
Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawCommand &cmd) Graphics::BatchedVertexData Graphics::requestBatchedDraw(const BatchedDrawCommand &cmd)
{ {
using namespace vertex; using namespace vertex;
StreamBufferState &state = streamBufferState; BatchedDrawState &state = batchedDrawState;
bool shouldflush = false; bool shouldflush = false;
bool shouldresize = false; bool shouldresize = false;
@@ -1052,7 +1052,7 @@ Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawCommand &
if (shouldflush || shouldresize) if (shouldflush || shouldresize)
{ {
flushStreamDraws(); flushBatchedDraws();
state.primitiveMode = cmd.primitiveMode; state.primitiveMode = cmd.primitiveMode;
state.formats[0] = cmd.formats[0]; state.formats[0] = cmd.formats[0];
@@ -1096,7 +1096,7 @@ Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawCommand &
state.indexBufferMap.data += reqIndexSize; state.indexBufferMap.data += reqIndexSize;
} }
StreamVertexData d; BatchedVertexData d;
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
@@ -1120,11 +1120,11 @@ Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawCommand &
return d; return d;
} }
void Graphics::flushStreamDraws() void Graphics::flushBatchedDraws()
{ {
using namespace vertex; using namespace vertex;
auto &sbstate = streamBufferState; auto &sbstate = batchedDrawState;
if (sbstate.vertexCount == 0 && sbstate.indexCount == 0) if (sbstate.vertexCount == 0 && sbstate.indexCount == 0)
return; return;
@@ -1195,15 +1195,15 @@ void Graphics::flushStreamDraws()
if (attributes.isEnabled(ATTRIB_COLOR)) if (attributes.isEnabled(ATTRIB_COLOR))
setColor(nc); setColor(nc);
streamBufferState.vertexCount = 0; batchedDrawState.vertexCount = 0;
streamBufferState.indexCount = 0; batchedDrawState.indexCount = 0;
} }
void Graphics::flushStreamDrawsGlobal() void Graphics::flushBatchedDrawsGlobal()
{ {
Graphics *instance = getInstance<Graphics>(M_GRAPHICS); Graphics *instance = getInstance<Graphics>(M_GRAPHICS);
if (instance != nullptr) if (instance != nullptr)
instance->flushStreamDraws(); instance->flushBatchedDraws();
} }
/** /**
@@ -1270,13 +1270,13 @@ void Graphics::points(const Vector2 *positions, const Colorf *colors, size_t num
const Matrix4 &t = getTransform(); const Matrix4 &t = getTransform();
bool is2D = t.isAffine2DTransform(); bool is2D = t.isAffine2DTransform();
StreamDrawCommand cmd; BatchedDrawCommand cmd;
cmd.primitiveMode = PRIMITIVE_POINTS; cmd.primitiveMode = PRIMITIVE_POINTS;
cmd.formats[0] = vertex::getSinglePositionFormat(is2D); cmd.formats[0] = vertex::getSinglePositionFormat(is2D);
cmd.formats[1] = vertex::CommonFormat::RGBAub; cmd.formats[1] = vertex::CommonFormat::RGBAub;
cmd.vertexCount = (int) numpoints; cmd.vertexCount = (int) numpoints;
StreamVertexData data = requestStreamDraw(cmd); BatchedVertexData data = requestBatchedDraw(cmd);
if (is2D) if (is2D)
t.transformXY((Vector2 *) data.stream[0], positions, cmd.vertexCount); t.transformXY((Vector2 *) data.stream[0], positions, cmd.vertexCount);
@@ -1566,13 +1566,13 @@ void Graphics::polygon(DrawMode mode, const Vector2 *coords, size_t count, bool
const Matrix4 &t = getTransform(); const Matrix4 &t = getTransform();
bool is2D = t.isAffine2DTransform(); bool is2D = t.isAffine2DTransform();
StreamDrawCommand cmd; BatchedDrawCommand cmd;
cmd.formats[0] = vertex::getSinglePositionFormat(is2D); cmd.formats[0] = vertex::getSinglePositionFormat(is2D);
cmd.formats[1] = vertex::CommonFormat::RGBAub; cmd.formats[1] = vertex::CommonFormat::RGBAub;
cmd.indexMode = vertex::TriangleIndexMode::FAN; cmd.indexMode = vertex::TriangleIndexMode::FAN;
cmd.vertexCount = (int)count - (skipLastFilledVertex ? 1 : 0); cmd.vertexCount = (int)count - (skipLastFilledVertex ? 1 : 0);
StreamVertexData data = requestStreamDraw(cmd); BatchedVertexData data = requestBatchedDraw(cmd);
if (is2D) if (is2D)
t.transformXY((Vector2 *) data.stream[0], coords, cmd.vertexCount); t.transformXY((Vector2 *) data.stream[0], coords, cmd.vertexCount);
@@ -1598,7 +1598,7 @@ Graphics::Stats Graphics::getStats() const
getAPIStats(stats.shaderSwitches); getAPIStats(stats.shaderSwitches);
stats.drawCalls = drawCalls; stats.drawCalls = drawCalls;
if (streamBufferState.vertexCount > 0) if (batchedDrawState.vertexCount > 0)
stats.drawCalls++; stats.drawCalls++;
stats.renderTargetSwitches = renderTargetSwitchCount; stats.renderTargetSwitches = renderTargetSwitchCount;
+9 -9
View File
@@ -253,7 +253,7 @@ public:
{} {}
}; };
struct StreamDrawCommand struct BatchedDrawCommand
{ {
PrimitiveType primitiveMode = PRIMITIVE_TRIANGLES; PrimitiveType primitiveMode = PRIMITIVE_TRIANGLES;
vertex::CommonFormat formats[2]; vertex::CommonFormat formats[2];
@@ -262,14 +262,14 @@ public:
Texture *texture = nullptr; Texture *texture = nullptr;
Shader::StandardShader standardShaderType = Shader::STANDARD_DEFAULT; Shader::StandardShader standardShaderType = Shader::STANDARD_DEFAULT;
StreamDrawCommand() BatchedDrawCommand()
{ {
// VS2013 can't initialize arrays in the above manner... // VS2013 can't initialize arrays in the above manner...
formats[1] = formats[0] = vertex::CommonFormat::NONE; formats[1] = formats[0] = vertex::CommonFormat::NONE;
} }
}; };
struct StreamVertexData struct BatchedVertexData
{ {
void *stream[2]; void *stream[2];
}; };
@@ -822,10 +822,10 @@ public:
virtual void draw(const DrawIndexedCommand &cmd) = 0; virtual void draw(const DrawIndexedCommand &cmd) = 0;
virtual void drawQuads(int start, int count, const vertex::Attributes &attributes, const vertex::BufferBindings &buffers, Texture *texture) = 0; virtual void drawQuads(int start, int count, const vertex::Attributes &attributes, const vertex::BufferBindings &buffers, Texture *texture) = 0;
void flushStreamDraws(); void flushBatchedDraws();
StreamVertexData requestStreamDraw(const StreamDrawCommand &command); BatchedVertexData requestBatchedDraw(const BatchedDrawCommand &command);
static void flushStreamDrawsGlobal(); static void flushBatchedDrawsGlobal();
virtual Shader::Language getShaderLanguageTarget() const = 0; virtual Shader::Language getShaderLanguageTarget() const = 0;
const DefaultShaderCode &getCurrentDefaultShaderCode() const; const DefaultShaderCode &getCurrentDefaultShaderCode() const;
@@ -911,7 +911,7 @@ protected:
SamplerState defaultSamplerState = SamplerState(); SamplerState defaultSamplerState = SamplerState();
}; };
struct StreamBufferState struct BatchedDrawState
{ {
StreamBuffer *vb[2]; StreamBuffer *vb[2];
StreamBuffer *indexBuffer = nullptr; StreamBuffer *indexBuffer = nullptr;
@@ -926,7 +926,7 @@ protected:
StreamBuffer::MapInfo vbMap[2]; StreamBuffer::MapInfo vbMap[2];
StreamBuffer::MapInfo indexBufferMap = StreamBuffer::MapInfo(); StreamBuffer::MapInfo indexBufferMap = StreamBuffer::MapInfo();
StreamBufferState() BatchedDrawState()
{ {
vb[0] = vb[1] = nullptr; vb[0] = vb[1] = nullptr;
formats[0] = formats[1] = vertex::CommonFormat::NONE; formats[0] = formats[1] = vertex::CommonFormat::NONE;
@@ -979,7 +979,7 @@ protected:
std::vector<ScreenshotInfo> pendingScreenshotCallbacks; std::vector<ScreenshotInfo> pendingScreenshotCallbacks;
StreamBufferState streamBufferState; BatchedDrawState batchedDrawState;
std::vector<Matrix4> transformStack; std::vector<Matrix4> transformStack;
Matrix4 projectionMatrix; Matrix4 projectionMatrix;
+1 -1
View File
@@ -584,7 +584,7 @@ void Mesh::drawInstanced(Graphics *gfx, const Matrix4 &m, int instancecount)
if (instancecount > 1 && !gfx->getCapabilities().features[Graphics::FEATURE_INSTANCING]) if (instancecount > 1 && !gfx->getCapabilities().features[Graphics::FEATURE_INSTANCING])
throw love::Exception("Instancing is not supported on this system."); throw love::Exception("Instancing is not supported on this system.");
gfx->flushStreamDraws(); gfx->flushBatchedDraws();
if (Shader::isDefaultActive()) if (Shader::isDefaultActive())
Shader::attachDefault(Shader::STANDARD_DEFAULT); Shader::attachDefault(Shader::STANDARD_DEFAULT);
+1 -1
View File
@@ -1029,7 +1029,7 @@ void ParticleSystem::draw(Graphics *gfx, const Matrix4 &m)
if (pCount == 0 || texture.get() == nullptr || pMem == nullptr || buffer == nullptr) if (pCount == 0 || texture.get() == nullptr || pMem == nullptr || buffer == nullptr)
return; return;
gfx->flushStreamDraws(); gfx->flushBatchedDraws();
if (Shader::isDefaultActive()) if (Shader::isDefaultActive())
Shader::attachDefault(Shader::STANDARD_DEFAULT); Shader::attachDefault(Shader::STANDARD_DEFAULT);
+2 -2
View File
@@ -390,13 +390,13 @@ void Polyline::draw(love::graphics::Graphics *gfx)
{ {
const Vector2 *verts = vertices + vertex_start; const Vector2 *verts = vertices + vertex_start;
Graphics::StreamDrawCommand cmd; Graphics::BatchedDrawCommand cmd;
cmd.formats[0] = vertex::getSinglePositionFormat(is2D); cmd.formats[0] = vertex::getSinglePositionFormat(is2D);
cmd.formats[1] = vertex::CommonFormat::RGBAub; cmd.formats[1] = vertex::CommonFormat::RGBAub;
cmd.indexMode = triangle_mode; cmd.indexMode = triangle_mode;
cmd.vertexCount = std::min(maxvertices, total_vertex_count - vertex_start); cmd.vertexCount = std::min(maxvertices, total_vertex_count - vertex_start);
Graphics::StreamVertexData data = gfx->requestStreamDraw(cmd); Graphics::BatchedVertexData data = gfx->requestBatchedDraw(cmd);
if (is2D) if (is2D)
t.transformXY((Vector2 *) data.stream[0], verts, cmd.vertexCount); t.transformXY((Vector2 *) data.stream[0], verts, cmd.vertexCount);
+1 -1
View File
@@ -301,7 +301,7 @@ void SpriteBatch::draw(Graphics *gfx, const Matrix4 &m)
if (next == 0) if (next == 0)
return; return;
gfx->flushStreamDraws(); gfx->flushBatchedDraws();
if (texture.get()) if (texture.get())
{ {
+1 -1
View File
@@ -246,7 +246,7 @@ void Text::draw(Graphics *gfx, const Matrix4 &m)
if (vertex_buffer == nullptr || draw_commands.empty()) if (vertex_buffer == nullptr || draw_commands.empty())
return; return;
gfx->flushStreamDraws(); gfx->flushBatchedDraws();
if (Shader::isDefaultActive()) if (Shader::isDefaultActive())
Shader::attachDefault(Shader::STANDARD_DEFAULT); Shader::attachDefault(Shader::STANDARD_DEFAULT);
+7 -7
View File
@@ -324,14 +324,14 @@ void Texture::draw(Graphics *gfx, Quad *q, const Matrix4 &localTransform)
const Matrix4 &tm = gfx->getTransform(); const Matrix4 &tm = gfx->getTransform();
bool is2D = tm.isAffine2DTransform(); bool is2D = tm.isAffine2DTransform();
Graphics::StreamDrawCommand cmd; Graphics::BatchedDrawCommand cmd;
cmd.formats[0] = vertex::getSinglePositionFormat(is2D); cmd.formats[0] = vertex::getSinglePositionFormat(is2D);
cmd.formats[1] = CommonFormat::STf_RGBAub; cmd.formats[1] = CommonFormat::STf_RGBAub;
cmd.indexMode = TriangleIndexMode::QUADS; cmd.indexMode = TriangleIndexMode::QUADS;
cmd.vertexCount = 4; cmd.vertexCount = 4;
cmd.texture = this; cmd.texture = this;
Graphics::StreamVertexData data = gfx->requestStreamDraw(cmd); Graphics::BatchedVertexData data = gfx->requestBatchedDraw(cmd);
Matrix4 t(tm, localTransform); Matrix4 t(tm, localTransform);
@@ -381,7 +381,7 @@ void Texture::drawLayer(Graphics *gfx, int layer, Quad *q, const Matrix4 &m)
Matrix4 t(tm, m); Matrix4 t(tm, m);
Graphics::StreamDrawCommand cmd; Graphics::BatchedDrawCommand cmd;
cmd.formats[0] = vertex::getSinglePositionFormat(is2D); cmd.formats[0] = vertex::getSinglePositionFormat(is2D);
cmd.formats[1] = CommonFormat::STPf_RGBAub; cmd.formats[1] = CommonFormat::STPf_RGBAub;
cmd.indexMode = TriangleIndexMode::QUADS; cmd.indexMode = TriangleIndexMode::QUADS;
@@ -389,7 +389,7 @@ void Texture::drawLayer(Graphics *gfx, int layer, Quad *q, const Matrix4 &m)
cmd.texture = this; cmd.texture = this;
cmd.standardShaderType = Shader::STANDARD_ARRAY; cmd.standardShaderType = Shader::STANDARD_ARRAY;
Graphics::StreamVertexData data = gfx->requestStreamDraw(cmd); Graphics::BatchedVertexData data = gfx->requestBatchedDraw(cmd);
if (is2D) if (is2D)
t.transformXY((Vector2 *) data.stream[0], q->getVertexPositions(), 4); t.transformXY((Vector2 *) data.stream[0], q->getVertexPositions(), 4);
@@ -464,7 +464,7 @@ void Texture::replacePixels(love::image::ImageDataBase *d, int slice, int mipmap
if (isPixelFormatCompressed(d->getFormat()) && (rect.x != 0 || rect.y != 0 || rect.w != mipw || rect.h != miph)) if (isPixelFormatCompressed(d->getFormat()) && (rect.x != 0 || rect.y != 0 || rect.w != mipw || rect.h != miph))
throw love::Exception("Compressed textures only support replacing the entire Texture."); throw love::Exception("Compressed textures only support replacing the entire Texture.");
Graphics::flushStreamDrawsGlobal(); Graphics::flushBatchedDrawsGlobal();
uploadImageData(d, mipmap, slice, x, y); uploadImageData(d, mipmap, slice, x, y);
@@ -481,7 +481,7 @@ void Texture::replacePixels(const void *data, size_t size, int slice, int mipmap
if (gfx != nullptr && gfx->isRenderTargetActive(this)) if (gfx != nullptr && gfx->isRenderTargetActive(this))
return; return;
Graphics::flushStreamDrawsGlobal(); Graphics::flushBatchedDrawsGlobal();
uploadByteData(format, data, size, mipmap, slice, rect, nullptr); uploadByteData(format, data, size, mipmap, slice, rect, nullptr);
@@ -631,7 +631,7 @@ void Texture::setSamplerState(const SamplerState &s)
if (s.depthSampleMode.hasValue && !isPixelFormatDepth(format)) if (s.depthSampleMode.hasValue && !isPixelFormatDepth(format))
throw love::Exception("Only depth textures can have a depth sample compare mode."); throw love::Exception("Only depth textures can have a depth sample compare mode.");
Graphics::flushStreamDrawsGlobal(); Graphics::flushBatchedDrawsGlobal();
samplerState = s; samplerState = s;
+3 -3
View File
@@ -120,14 +120,14 @@ void Video::draw(Graphics *gfx, const Matrix4 &m)
Matrix4 t(tm, m); Matrix4 t(tm, m);
Graphics::StreamDrawCommand cmd; Graphics::BatchedDrawCommand cmd;
cmd.formats[0] = vertex::getSinglePositionFormat(is2D); cmd.formats[0] = vertex::getSinglePositionFormat(is2D);
cmd.formats[1] = vertex::CommonFormat::STf_RGBAub; cmd.formats[1] = vertex::CommonFormat::STf_RGBAub;
cmd.indexMode = vertex::TriangleIndexMode::QUADS; cmd.indexMode = vertex::TriangleIndexMode::QUADS;
cmd.vertexCount = 4; cmd.vertexCount = 4;
cmd.standardShaderType = Shader::STANDARD_VIDEO; cmd.standardShaderType = Shader::STANDARD_VIDEO;
Graphics::StreamVertexData data = gfx->requestStreamDraw(cmd); Graphics::BatchedVertexData data = gfx->requestBatchedDraw(cmd);
if (is2D) if (is2D)
t.transformXY((Vector2 *) data.stream[0], vertices, 4); t.transformXY((Vector2 *) data.stream[0], vertices, 4);
@@ -148,7 +148,7 @@ void Video::draw(Graphics *gfx, const Matrix4 &m)
if (Shader::current != nullptr) if (Shader::current != nullptr)
Shader::current->setVideoTextures(textures[0], textures[1], textures[2]); Shader::current->setVideoTextures(textures[0], textures[1], textures[2]);
gfx->flushStreamDraws(); gfx->flushBatchedDraws();
} }
void Video::update() void Video::update()
+25 -25
View File
@@ -234,13 +234,13 @@ bool Graphics::setMode(int width, int height, int pixelwidth, int pixelheight, b
setDebug(isDebugEnabled()); setDebug(isDebugEnabled());
if (streamBufferState.vb[0] == nullptr) if (batchedDrawState.vb[0] == nullptr)
{ {
// Initial sizes that should be good enough for most cases. It will // Initial sizes that should be good enough for most cases. It will
// resize to fit if needed, later. // resize to fit if needed, later.
streamBufferState.vb[0] = CreateStreamBuffer(BUFFER_VERTEX, 1024 * 1024 * 1); batchedDrawState.vb[0] = CreateStreamBuffer(BUFFER_VERTEX, 1024 * 1024 * 1);
streamBufferState.vb[1] = CreateStreamBuffer(BUFFER_VERTEX, 256 * 1024 * 1); batchedDrawState.vb[1] = CreateStreamBuffer(BUFFER_VERTEX, 256 * 1024 * 1);
streamBufferState.indexBuffer = CreateStreamBuffer(BUFFER_INDEX, sizeof(uint16) * LOVE_UINT16_MAX); batchedDrawState.indexBuffer = CreateStreamBuffer(BUFFER_INDEX, sizeof(uint16) * LOVE_UINT16_MAX);
} }
// Reload all volatile objects. // Reload all volatile objects.
@@ -293,7 +293,7 @@ void Graphics::unSetMode()
if (!isCreated()) if (!isCreated())
return; return;
flushStreamDraws(); flushBatchedDraws();
// Unload all volatile objects. These must be reloaded after the display // Unload all volatile objects. These must be reloaded after the display
// mode change. // mode change.
@@ -321,7 +321,7 @@ void Graphics::unSetMode()
void Graphics::setActive(bool enable) void Graphics::setActive(bool enable)
{ {
flushStreamDraws(); flushBatchedDraws();
// Make sure all pending OpenGL commands have fully executed before // Make sure all pending OpenGL commands have fully executed before
// returning, when going from active to inactive. This is required on iOS. // returning, when going from active to inactive. This is required on iOS.
@@ -505,7 +505,7 @@ void Graphics::setRenderTargetsInternal(const RenderTargets &rts, int w, int h,
OpenGL::TempDebugGroup debuggroup("setRenderTargets"); OpenGL::TempDebugGroup debuggroup("setRenderTargets");
flushStreamDraws(); flushBatchedDraws();
endPass(); endPass();
bool iswindow = rts.getFirstTarget().texture == nullptr; bool iswindow = rts.getFirstTarget().texture == nullptr;
@@ -621,7 +621,7 @@ void Graphics::endPass()
void Graphics::clear(OptionalColorf c, OptionalInt stencil, OptionalDouble depth) void Graphics::clear(OptionalColorf c, OptionalInt stencil, OptionalDouble depth)
{ {
if (c.hasValue || stencil.hasValue || depth.hasValue) if (c.hasValue || stencil.hasValue || depth.hasValue)
flushStreamDraws(); flushBatchedDraws();
GLbitfield flags = 0; GLbitfield flags = 0;
@@ -678,7 +678,7 @@ void Graphics::clear(const std::vector<OptionalColorf> &colors, OptionalInt sten
return; return;
} }
flushStreamDraws(); flushBatchedDraws();
bool drawbuffersmodified = false; bool drawbuffersmodified = false;
ncolors = std::min(ncolors, ncolorRTs); ncolors = std::min(ncolors, ncolorRTs);
@@ -754,7 +754,7 @@ void Graphics::clear(const std::vector<OptionalColorf> &colors, OptionalInt sten
void Graphics::discard(const std::vector<bool> &colorbuffers, bool depthstencil) void Graphics::discard(const std::vector<bool> &colorbuffers, bool depthstencil)
{ {
flushStreamDraws(); flushBatchedDraws();
discard(OpenGL::FRAMEBUFFER_ALL, colorbuffers, depthstencil); discard(OpenGL::FRAMEBUFFER_ALL, colorbuffers, depthstencil);
} }
@@ -935,7 +935,7 @@ void Graphics::present(void *screenshotCallbackData)
deprecations.draw(this); deprecations.draw(this);
flushStreamDraws(); flushBatchedDraws();
endPass(); endPass();
gl.bindFramebuffer(OpenGL::FRAMEBUFFER_ALL, gl.getDefaultFBO()); gl.bindFramebuffer(OpenGL::FRAMEBUFFER_ALL, gl.getDefaultFBO());
@@ -1038,9 +1038,9 @@ void Graphics::present(void *screenshotCallbackData)
glBindRenderbuffer(GL_RENDERBUFFER, info.info.uikit.colorbuffer); glBindRenderbuffer(GL_RENDERBUFFER, info.info.uikit.colorbuffer);
#endif #endif
for (StreamBuffer *buffer : streamBufferState.vb) for (StreamBuffer *buffer : batchedDrawState.vb)
buffer->nextFrame(); buffer->nextFrame();
streamBufferState.indexBuffer->nextFrame(); batchedDrawState.indexBuffer->nextFrame();
auto window = getInstance<love::window::Window>(M_WINDOW); auto window = getInstance<love::window::Window>(M_WINDOW);
if (window != nullptr) if (window != nullptr)
@@ -1068,7 +1068,7 @@ void Graphics::present(void *screenshotCallbackData)
void Graphics::setScissor(const Rect &rect) void Graphics::setScissor(const Rect &rect)
{ {
flushStreamDraws(); flushBatchedDraws();
DisplayState &state = states.back(); DisplayState &state = states.back();
@@ -1093,7 +1093,7 @@ void Graphics::setScissor(const Rect &rect)
void Graphics::setScissor() void Graphics::setScissor()
{ {
if (states.back().scissor) if (states.back().scissor)
flushStreamDraws(); flushBatchedDraws();
states.back().scissor = false; states.back().scissor = false;
@@ -1111,7 +1111,7 @@ void Graphics::drawToStencilBuffer(StencilAction action, int value)
else if (isRenderTargetActive() && (rts.temporaryRTFlags & TEMPORARY_RT_STENCIL) == 0 && (dstexture == nullptr || !isPixelFormatStencil(dstexture->getPixelFormat()))) else if (isRenderTargetActive() && (rts.temporaryRTFlags & TEMPORARY_RT_STENCIL) == 0 && (dstexture == nullptr || !isPixelFormatStencil(dstexture->getPixelFormat())))
throw love::Exception("Drawing to the stencil buffer with a render target active requires either stencil=true or a custom stencil-type texture to be used, in setRenderTarget."); throw love::Exception("Drawing to the stencil buffer with a render target active requires either stencil=true or a custom stencil-type texture to be used, in setRenderTarget.");
flushStreamDraws(); flushBatchedDraws();
writingToStencil = true; writingToStencil = true;
@@ -1156,7 +1156,7 @@ void Graphics::stopDrawToStencilBuffer()
if (!writingToStencil) if (!writingToStencil)
return; return;
flushStreamDraws(); flushBatchedDraws();
writingToStencil = false; writingToStencil = false;
@@ -1174,7 +1174,7 @@ void Graphics::setStencilTest(CompareMode compare, int value)
DisplayState &state = states.back(); DisplayState &state = states.back();
if (state.stencilCompare != compare || state.stencilTestValue != value) if (state.stencilCompare != compare || state.stencilTestValue != value)
flushStreamDraws(); flushBatchedDraws();
state.stencilCompare = compare; state.stencilCompare = compare;
state.stencilTestValue = value; state.stencilTestValue = value;
@@ -1211,7 +1211,7 @@ void Graphics::setDepthMode(CompareMode compare, bool write)
DisplayState &state = states.back(); DisplayState &state = states.back();
if (state.depthTest != compare || state.depthWrite != write) if (state.depthTest != compare || state.depthWrite != write)
flushStreamDraws(); flushBatchedDraws();
state.depthTest = compare; state.depthTest = compare;
state.depthWrite = write; state.depthWrite = write;
@@ -1233,7 +1233,7 @@ void Graphics::setFrontFaceWinding(vertex::Winding winding)
DisplayState &state = states.back(); DisplayState &state = states.back();
if (state.winding != winding) if (state.winding != winding)
flushStreamDraws(); flushBatchedDraws();
state.winding = winding; state.winding = winding;
@@ -1255,7 +1255,7 @@ void Graphics::setColor(Colorf c)
void Graphics::setColorMask(ColorChannelMask mask) void Graphics::setColorMask(ColorChannelMask mask)
{ {
flushStreamDraws(); flushBatchedDraws();
glColorMask(mask.r, mask.g, mask.b, mask.a); glColorMask(mask.r, mask.g, mask.b, mask.a);
states.back().colorMask = mask; states.back().colorMask = mask;
@@ -1264,7 +1264,7 @@ void Graphics::setColorMask(ColorChannelMask mask)
void Graphics::setBlendState(const BlendState &blend) void Graphics::setBlendState(const BlendState &blend)
{ {
if (!(blend == states.back().blend)) if (!(blend == states.back().blend))
flushStreamDraws(); flushBatchedDraws();
if (blend.operationRGB == BLENDOP_MAX || blend.operationA == BLENDOP_MAX if (blend.operationRGB == BLENDOP_MAX || blend.operationA == BLENDOP_MAX
|| blend.operationRGB == BLENDOP_MIN || blend.operationA == BLENDOP_MIN) || blend.operationRGB == BLENDOP_MIN || blend.operationA == BLENDOP_MIN)
@@ -1294,8 +1294,8 @@ void Graphics::setBlendState(const BlendState &blend)
void Graphics::setPointSize(float size) void Graphics::setPointSize(float size)
{ {
if (streamBufferState.primitiveMode == PRIMITIVE_POINTS) if (batchedDrawState.primitiveMode == PRIMITIVE_POINTS)
flushStreamDraws(); flushBatchedDraws();
gl.setPointSize(size * getCurrentDPIScale()); gl.setPointSize(size * getCurrentDPIScale());
states.back().pointSize = size; states.back().pointSize = size;
@@ -1307,7 +1307,7 @@ void Graphics::setWireframe(bool enable)
if (GLAD_ES_VERSION_2_0) if (GLAD_ES_VERSION_2_0)
return; return;
flushStreamDraws(); flushBatchedDraws();
glPolygonMode(GL_FRONT_AND_BACK, enable ? GL_LINE : GL_FILL); glPolygonMode(GL_FRONT_AND_BACK, enable ? GL_LINE : GL_FILL);
states.back().wireframe = enable; states.back().wireframe = enable;
+5 -5
View File
@@ -428,7 +428,7 @@ void Shader::attach()
{ {
if (current != this) if (current != this)
{ {
Graphics::flushStreamDrawsGlobal(); Graphics::flushBatchedDrawsGlobal();
gl.useProgram(program); gl.useProgram(program);
current = this; current = this;
@@ -479,7 +479,7 @@ void Shader::updateUniform(const UniformInfo *info, int count, bool internalupda
} }
if (!internalupdate) if (!internalupdate)
flushStreamDraws(); flushBatchedDraws();
int location = info->location; int location = info->location;
UniformType type = info->baseType; UniformType type = info->baseType;
@@ -577,7 +577,7 @@ void Shader::sendTextures(const UniformInfo *info, love::graphics::Texture **tex
bool shaderactive = current == this; bool shaderactive = current == this;
if (!internalUpdate && shaderactive) if (!internalUpdate && shaderactive)
flushStreamDraws(); flushBatchedDraws();
count = std::min(count, info->count); count = std::min(count, info->count);
@@ -643,10 +643,10 @@ void Shader::sendTextures(const UniformInfo *info, love::graphics::Texture **tex
} }
} }
void Shader::flushStreamDraws() const void Shader::flushBatchedDraws() const
{ {
if (current == this) if (current == this)
Graphics::flushStreamDrawsGlobal(); Graphics::flushBatchedDrawsGlobal();
} }
bool Shader::hasUniform(const std::string &name) const bool Shader::hasUniform(const std::string &name) const
+1 -1
View File
@@ -90,7 +90,7 @@ private:
TextureType getUniformTextureType(GLenum type) const; TextureType getUniformTextureType(GLenum type) const;
bool isDepthTextureType(GLenum type) const; bool isDepthTextureType(GLenum type) const;
void flushStreamDraws() const; void flushBatchedDraws() const;
// Get any warnings or errors generated only by the shader program object. // Get any warnings or errors generated only by the shader program object.
std::string getProgramWarnings() const; std::string getProgramWarnings() const;
+1 -1
View File
@@ -3029,7 +3029,7 @@ int w_polygon(lua_State *L)
int w_flushBatch(lua_State *) int w_flushBatch(lua_State *)
{ {
instance()->flushStreamDraws(); instance()->flushBatchedDraws();
return 0; return 0;
} }