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();
mLastMappedIndex = UINT_MAX;
mClipPlaneInfo.Push(0);
}
HWViewpointBuffer::~HWViewpointBuffer()
@ -67,7 +66,6 @@ void HWViewpointBuffer::CheckSize()
{
mBufferPipeline[n]->Resize(mByteSize);
}
m2DHeight = m2DWidth = -1;
}
}
@ -84,33 +82,26 @@ int HWViewpointBuffer::Bind(FRenderState &di, unsigned int index)
void HWViewpointBuffer::Set2D(FRenderState &di, int width, int height, int pll)
{
if (width != m2DWidth || height != m2DHeight)
{
HWViewpointUniforms matrices;
HWViewpointUniforms matrices;
matrices.mViewMatrix.loadIdentity();
matrices.mNormalViewMatrix.loadIdentity();
matrices.mViewHeight = 0;
matrices.mGlobVis = 1.f;
matrices.mPalLightLevels = pll;
matrices.mClipLine.X = -10000000.0f;
matrices.mShadowmapFilter = gl_shadowmap_filter;
matrices.mViewMatrix.loadIdentity();
matrices.mNormalViewMatrix.loadIdentity();
matrices.mViewHeight = 0;
matrices.mGlobVis = 1.f;
matrices.mPalLightLevels = pll;
matrices.mClipLine.X = -10000000.0f;
matrices.mShadowmapFilter = gl_shadowmap_filter;
matrices.mProjectionMatrix.ortho(0, (float)width, (float)height, 0, -1.0f, 1.0f);
matrices.CalcDependencies();
matrices.mProjectionMatrix.ortho(0, (float)width, (float)height, 0, -1.0f, 1.0f);
matrices.CalcDependencies();
for (int n = 0; n < mPipelineNbr; n++)
{
mBufferPipeline[n]->Map();
memcpy(mBufferPipeline[n]->Memory(), &matrices, sizeof(matrices));
mBufferPipeline[n]->Unmap();
}
mBuffer->Map();
memcpy(((char*)mBuffer->Memory()) + mUploadIndex * mBlockAlign, &matrices, sizeof(matrices));
mBuffer->Unmap();
m2DWidth = width;
m2DHeight = height;
mLastMappedIndex = -1;
}
Bind(di, 0);
mClipPlaneInfo.Push(0);
Bind(di, mUploadIndex++);
}
int HWViewpointBuffer::SetViewpoint(FRenderState &di, HWViewpointUniforms *vp)
@ -126,9 +117,8 @@ int HWViewpointBuffer::SetViewpoint(FRenderState &di, HWViewpointUniforms *vp)
void HWViewpointBuffer::Clear()
{
// Index 0 is reserved for the 2D projection.
mUploadIndex = 1;
mClipPlaneInfo.Resize(1);
mUploadIndex = 0;
mClipPlaneInfo.Clear();
mPipelinePos++;
mPipelinePos %= mPipelineNbr;

View file

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