mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 20:43:15 +00:00
Add buffer synchronisation for GLES when using mapped buffers.
This commit is contained in:
parent
76875f0a3c
commit
db59a4f9af
5 changed files with 37 additions and 6 deletions
|
@ -232,6 +232,34 @@ void GLBuffer::Resize(size_t newsize)
|
|||
}
|
||||
}
|
||||
|
||||
void GLBuffer::GPUDropSync()
|
||||
{
|
||||
#if !(USE_GLES2) // Only applicable when running on desktop for now
|
||||
if (mGLSync != NULL)
|
||||
{
|
||||
glDeleteSync(mGLSync);
|
||||
}
|
||||
|
||||
mGLSync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GLBuffer::GPUWaitSync()
|
||||
{
|
||||
#if !(USE_GLES2) // Only applicable when running on desktop for now
|
||||
GLenum status = glClientWaitSync(mGLSync, GL_SYNC_FLUSH_COMMANDS_BIT, 1000 * 1000 * 50); // Wait for a max of 50ms...
|
||||
|
||||
if (status != GL_ALREADY_SIGNALED && status != GL_CONDITION_SATISFIED)
|
||||
{
|
||||
//Printf("Error on glClientWaitSync: %d\n", status);
|
||||
}
|
||||
|
||||
glDeleteSync(mGLSync);
|
||||
|
||||
mGLSync = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
|
@ -288,15 +316,11 @@ void GLDataBuffer::BindRange(FRenderState *state, size_t start, size_t length)
|
|||
{
|
||||
static_cast<FGLRenderState*>(state)->ApplyViewport(memory + start);
|
||||
}
|
||||
else
|
||||
{
|
||||
//glBindBufferRange(mUseType, mBindingPoint, mBufferId, start, length);
|
||||
}
|
||||
}
|
||||
|
||||
void GLDataBuffer::BindBase()
|
||||
{
|
||||
//glBindBufferBase(mUseType, mBindingPoint, mBufferId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ protected:
|
|||
int mAllocationSize = 0;
|
||||
bool mPersistent = false;
|
||||
bool nomap = true;
|
||||
GLsync mGLSync = 0;
|
||||
|
||||
bool isData = false;
|
||||
char *memory = nullptr;
|
||||
|
@ -32,6 +33,9 @@ protected:
|
|||
void Resize(size_t newsize) override;
|
||||
void *Lock(unsigned int size) override;
|
||||
void Unlock() override;
|
||||
|
||||
void GPUDropSync();
|
||||
void GPUWaitSync();
|
||||
public:
|
||||
void Bind();
|
||||
void Upload(size_t start, size_t end);
|
||||
|
|
|
@ -240,11 +240,13 @@ void OpenGLFrameBuffer::Swap()
|
|||
Finish.Reset();
|
||||
Finish.Clock();
|
||||
|
||||
mVertexData->DropSync();
|
||||
|
||||
FPSLimit();
|
||||
SwapBuffers();
|
||||
|
||||
mVertexData->NextPipelineBuffer();
|
||||
mVertexData->WaitSync();
|
||||
|
||||
RenderState()->SetVertexBuffer(screen->mVertexData); // Needed for Raze because it does not reset it
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ EXTERN_CVAR(Bool, gl_customshader);
|
|||
|
||||
PFNGLMAPBUFFERRANGEEXTPROC glMapBufferRange = NULL;
|
||||
PFNGLUNMAPBUFFEROESPROC glUnmapBuffer = NULL;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <dlfcn.h>
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
class FRenderState;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#define HW_MAX_PIPELINE_BUFFERS 8
|
||||
#define HW_MAX_PIPELINE_BUFFERS 4
|
||||
#define HW_BLOCK_SSBO 1
|
||||
#else
|
||||
// On desktop this is only useful fpr letting the GPU run in parallel with the playsim and for that 2 buffers are enough.
|
||||
|
|
Loading…
Reference in a new issue