Add support for multiple 2d drawer viewpoints in the same frame

This commit is contained in:
Magnus Norddahl 2022-07-25 00:54:54 +02:00 committed by Christoph Oelckers
parent 6c3fd3cc4d
commit 753822359e
2 changed files with 18 additions and 30 deletions

View file

@ -48,7 +48,6 @@ HWViewpointBuffer::HWViewpointBuffer(int pipelineNbr):
Clear(); Clear();
mLastMappedIndex = UINT_MAX; mLastMappedIndex = UINT_MAX;
mClipPlaneInfo.Push(0);
} }
HWViewpointBuffer::~HWViewpointBuffer() HWViewpointBuffer::~HWViewpointBuffer()
@ -67,7 +66,6 @@ void HWViewpointBuffer::CheckSize()
{ {
mBufferPipeline[n]->Resize(mByteSize); mBufferPipeline[n]->Resize(mByteSize);
} }
m2DHeight = m2DWidth = -1;
} }
} }
@ -83,8 +81,6 @@ int HWViewpointBuffer::Bind(FRenderState &di, unsigned int index)
} }
void HWViewpointBuffer::Set2D(FRenderState &di, int width, int height, int pll) void HWViewpointBuffer::Set2D(FRenderState &di, int width, int height, int pll)
{
if (width != m2DWidth || height != m2DHeight)
{ {
HWViewpointUniforms matrices; HWViewpointUniforms matrices;
@ -99,18 +95,13 @@ void HWViewpointBuffer::Set2D(FRenderState &di, int width, int height, int pll)
matrices.mProjectionMatrix.ortho(0, (float)width, (float)height, 0, -1.0f, 1.0f); matrices.mProjectionMatrix.ortho(0, (float)width, (float)height, 0, -1.0f, 1.0f);
matrices.CalcDependencies(); matrices.CalcDependencies();
for (int n = 0; n < mPipelineNbr; n++) mBuffer->Map();
{ memcpy(((char*)mBuffer->Memory()) + mUploadIndex * mBlockAlign, &matrices, sizeof(matrices));
mBufferPipeline[n]->Map(); mBuffer->Unmap();
memcpy(mBufferPipeline[n]->Memory(), &matrices, sizeof(matrices));
mBufferPipeline[n]->Unmap();
}
m2DWidth = width; mClipPlaneInfo.Push(0);
m2DHeight = height;
mLastMappedIndex = -1; Bind(di, mUploadIndex++);
}
Bind(di, 0);
} }
int HWViewpointBuffer::SetViewpoint(FRenderState &di, HWViewpointUniforms *vp) int HWViewpointBuffer::SetViewpoint(FRenderState &di, HWViewpointUniforms *vp)
@ -126,9 +117,8 @@ int HWViewpointBuffer::SetViewpoint(FRenderState &di, HWViewpointUniforms *vp)
void HWViewpointBuffer::Clear() void HWViewpointBuffer::Clear()
{ {
// Index 0 is reserved for the 2D projection. mUploadIndex = 0;
mUploadIndex = 1; mClipPlaneInfo.Clear();
mClipPlaneInfo.Resize(1);
mPipelinePos++; mPipelinePos++;
mPipelinePos %= mPipelineNbr; mPipelinePos %= mPipelineNbr;

View file

@ -19,8 +19,6 @@ class HWViewpointBuffer
unsigned int mByteSize; unsigned int mByteSize;
TArray<bool> mClipPlaneInfo; TArray<bool> mClipPlaneInfo;
int m2DWidth = -1, m2DHeight = -1;
unsigned int mBlockSize; unsigned int mBlockSize;
void CheckSize(); void CheckSize();