Skip to content

Commit

Permalink
- fixed: The viewpoint buffer was mapped write only but read from. On…
Browse files Browse the repository at this point in the history
… old hardware it wasn't even mapped.

Changed to cache the needed value in a CPU-side array so that the buffer access is not needed.
  • Loading branch information
coelckers committed Aug 18, 2018
1 parent 17813b4 commit b03add8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/gl/data/gl_viewpointbuffer.cpp
Expand Up @@ -41,6 +41,7 @@ GLViewpointBuffer::GLViewpointBuffer()
Allocate();
Clear();
mLastMappedIndex = UINT_MAX;
mClipPlaneInfo.Push(0);
}

GLViewpointBuffer::~GLViewpointBuffer()
Expand Down Expand Up @@ -121,8 +122,7 @@ int GLViewpointBuffer::Bind(unsigned int index)
glBindBufferRange(GL_UNIFORM_BUFFER, VIEWPOINT_BINDINGPOINT, mBufferId, index * mBlockAlign, mBlockAlign);

// Update the viewpoint-related clip plane setting.
auto *vp = (HWViewpointUniforms*)(((char*)mBufferPointer) + mUploadIndex * mBlockAlign);
if (index > 0 && (vp->mClipHeightDirection != 0.f || vp->mClipLine.X > -10000000.0f))
if (mClipPlaneInfo[index])
{
glEnable(GL_CLIP_DISTANCE0);
}
Expand Down Expand Up @@ -159,12 +159,14 @@ int GLViewpointBuffer::SetViewpoint(HWViewpointUniforms *vp)
memcpy(((char*)mBufferPointer) + mUploadIndex * mBlockAlign, vp, sizeof(*vp));
Unmap();

mClipPlaneInfo.Push(vp->mClipHeightDirection != 0.f || vp->mClipLine.X > -10000000.0f);
return Bind(mUploadIndex++);
}

void GLViewpointBuffer::Clear()
{
// Index 0 is reserved for the 2D projection.
mUploadIndex = 1;
mClipPlaneInfo.Resize(1);
}

1 change: 1 addition & 0 deletions src/gl/data/gl_viewpointbuffer.h
Expand Up @@ -13,6 +13,7 @@ class GLViewpointBuffer
unsigned int mLastMappedIndex;
unsigned int mByteSize;
void * mBufferPointer;
TArray<bool> mClipPlaneInfo;

int m2DWidth = -1, m2DHeight = -1;

Expand Down

0 comments on commit b03add8

Please sign in to comment.