Merge branch '12.0-development' into GraphicsBuffer

This commit is contained in:
Alex Szpakowski
2020-02-28 23:10:21 -04:00
32 changed files with 338 additions and 332 deletions
+21 -21
View File
@@ -114,7 +114,7 @@ Graphics::Graphics()
, created(false)
, active(true)
, writingToStencil(false)
, streamBufferState()
, batchedDrawState()
, projectionMatrix()
, renderTargetSwitchCount(0)
, drawCalls(0)
@@ -157,9 +157,9 @@ Graphics::~Graphics()
defaultFont.set(nullptr);
delete streamBufferState.vb[0];
delete streamBufferState.vb[1];
delete streamBufferState.indexBuffer;
delete batchedDrawState.vb[0];
delete batchedDrawState.vb[1];
delete batchedDrawState.indexBuffer;
for (int i = 0; i < (int) ShaderStage::STAGE_MAX_ENUM; i++)
cachedShaderStages[i].clear();
@@ -694,7 +694,7 @@ void Graphics::setRenderTargets(const RenderTargets &rts)
int w = firsttex->getWidth(firsttarget.mipmap);
int h = firsttex->getHeight(firsttarget.mipmap);
flushStreamDraws();
flushBatchedDraws();
if (rts.depthStencil.texture == nullptr && rts.temporaryRTFlags != 0)
{
@@ -744,7 +744,7 @@ void Graphics::setRenderTarget()
if (state.renderTargets.colors.empty() && state.renderTargets.depthStencil.texture == nullptr)
return;
flushStreamDraws();
flushBatchedDraws();
setRenderTargetsInternal(RenderTargets(), width, height, pixelWidth, pixelHeight, isGammaCorrect());
state.renderTargets = RenderTargetsStrongRef();
@@ -989,9 +989,9 @@ void Graphics::captureScreenshot(const ScreenshotInfo &info)
pendingScreenshotCallbacks.push_back(info);
}
Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawCommand &cmd)
Graphics::BatchedVertexData Graphics::requestBatchedDraw(const BatchedDrawCommand &cmd)
{
StreamBufferState &state = streamBufferState;
BatchedDrawState &state = batchedDrawState;
bool shouldflush = false;
bool shouldresize = false;
@@ -1053,7 +1053,7 @@ Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawCommand &
if (shouldflush || shouldresize)
{
flushStreamDraws();
flushBatchedDraws();
state.primitiveMode = cmd.primitiveMode;
state.formats[0] = cmd.formats[0];
@@ -1097,7 +1097,7 @@ Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawCommand &
state.indexBufferMap.data += reqIndexSize;
}
StreamVertexData d;
BatchedVertexData d;
for (int i = 0; i < 2; i++)
{
@@ -1121,9 +1121,9 @@ Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawCommand &
return d;
}
void Graphics::flushStreamDraws()
void Graphics::flushBatchedDraws()
{
auto &sbstate = streamBufferState;
auto &sbstate = batchedDrawState;
if (sbstate.vertexCount == 0 && sbstate.indexCount == 0)
return;
@@ -1194,15 +1194,15 @@ void Graphics::flushStreamDraws()
if (attributes.isEnabled(ATTRIB_COLOR))
setColor(nc);
streamBufferState.vertexCount = 0;
streamBufferState.indexCount = 0;
batchedDrawState.vertexCount = 0;
batchedDrawState.indexCount = 0;
}
void Graphics::flushStreamDrawsGlobal()
void Graphics::flushBatchedDrawsGlobal()
{
Graphics *instance = getInstance<Graphics>(M_GRAPHICS);
if (instance != nullptr)
instance->flushStreamDraws();
instance->flushBatchedDraws();
}
/**
@@ -1269,13 +1269,13 @@ void Graphics::points(const Vector2 *positions, const Colorf *colors, size_t num
const Matrix4 &t = getTransform();
bool is2D = t.isAffine2DTransform();
StreamDrawCommand cmd;
BatchedDrawCommand cmd;
cmd.primitiveMode = PRIMITIVE_POINTS;
cmd.formats[0] = getSinglePositionFormat(is2D);
cmd.formats[1] = CommonFormat::RGBAub;
cmd.vertexCount = (int) numpoints;
StreamVertexData data = requestStreamDraw(cmd);
BatchedVertexData data = requestBatchedDraw(cmd);
if (is2D)
t.transformXY((Vector2 *) data.stream[0], positions, cmd.vertexCount);
@@ -1565,13 +1565,13 @@ void Graphics::polygon(DrawMode mode, const Vector2 *coords, size_t count, bool
const Matrix4 &t = getTransform();
bool is2D = t.isAffine2DTransform();
StreamDrawCommand cmd;
BatchedDrawCommand cmd;
cmd.formats[0] = getSinglePositionFormat(is2D);
cmd.formats[1] = CommonFormat::RGBAub;
cmd.indexMode = TRIANGLEINDEX_FAN;
cmd.vertexCount = (int)count - (skipLastFilledVertex ? 1 : 0);
StreamVertexData data = requestStreamDraw(cmd);
BatchedVertexData data = requestBatchedDraw(cmd);
if (is2D)
t.transformXY((Vector2 *) data.stream[0], coords, cmd.vertexCount);
@@ -1597,7 +1597,7 @@ Graphics::Stats Graphics::getStats() const
getAPIStats(stats.shaderSwitches);
stats.drawCalls = drawCalls;
if (streamBufferState.vertexCount > 0)
if (batchedDrawState.vertexCount > 0)
stats.drawCalls++;
stats.renderTargetSwitches = renderTargetSwitchCount;