- merged gzdoom-gles2 and fixed some issues with pipeline size validation.

This commit is contained in:
Christoph Oelckers 2021-08-03 18:46:45 +02:00
commit 441cd0796f
116 changed files with 12502 additions and 80 deletions

View file

@ -170,6 +170,29 @@ void GLBuffer::Resize(size_t newsize)
}
}
void GLBuffer::GPUDropSync()
{
if (mGLSync != NULL)
{
glDeleteSync(mGLSync);
}
mGLSync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
}
void GLBuffer::GPUWaitSync()
{
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;
}
//===========================================================================
//

View file

@ -1,6 +1,7 @@
#pragma once
#include "buffers.h"
#include "gl_load.h"
#ifdef _MSC_VER
// silence bogus warning C4250: 'GLVertexBuffer': inherits 'GLBuffer::GLBuffer::SetData' via dominance
@ -19,6 +20,7 @@ protected:
int mAllocationSize = 0;
bool mPersistent = false;
bool nomap = true;
GLsync mGLSync = 0;
GLBuffer(int usetype);
~GLBuffer();
@ -29,6 +31,9 @@ protected:
void Resize(size_t newsize) override;
void *Lock(unsigned int size) override;
void Unlock() override;
void GPUDropSync();
void GPUWaitSync();
public:
void Bind();
};

View file

@ -65,6 +65,7 @@ EXTERN_CVAR (Bool, vid_vsync)
EXTERN_CVAR(Bool, r_drawvoxels)
EXTERN_CVAR(Int, gl_tonemap)
EXTERN_CVAR(Bool, cl_capfps)
EXTERN_CVAR(Int, gl_pipeline_depth);
void gl_LoadExtensions();
void gl_PrintStartupLog();
@ -133,6 +134,9 @@ void OpenGLFrameBuffer::InitializeState()
gl_LoadExtensions();
mPipelineNbr = clamp(*gl_pipeline_depth, 1, HW_MAX_PIPELINE_BUFFERS);
mPipelineType = gl_pipeline_depth < 1;
// Move some state to the framebuffer object for easier access.
hwcaps = gl.flags;
glslversion = gl.glslversion;
@ -164,10 +168,10 @@ void OpenGLFrameBuffer::InitializeState()
SetViewportRects(nullptr);
mVertexData = new FFlatVertexBuffer(GetWidth(), GetHeight());
mVertexData = new FFlatVertexBuffer(GetWidth(), GetHeight(), screen->mPipelineNbr);
mSkyData = new FSkyVertexBuffer;
mViewpoints = new HWViewpointBuffer;
mLights = new FLightBuffer();
mViewpoints = new HWViewpointBuffer(screen->mPipelineNbr);
mLights = new FLightBuffer(screen->mPipelineNbr);
GLRenderer = new FGLRenderer(this);
GLRenderer->Initialize(GetWidth(), GetHeight());
static_cast<GLDataBuffer*>(mLights->GetBuffer())->BindBase();
@ -256,10 +260,25 @@ void OpenGLFrameBuffer::Swap()
bool swapbefore = gl_finishbeforeswap && camtexcount == 0;
Finish.Reset();
Finish.Clock();
if (swapbefore) glFinish();
FPSLimit();
SwapBuffers();
if (!swapbefore) glFinish();
if (gl_pipeline_depth < 1)
{
if (swapbefore) glFinish();
FPSLimit();
SwapBuffers();
if (!swapbefore) glFinish();
}
else
{
mVertexData->DropSync();
FPSLimit();
SwapBuffers();
mVertexData->NextPipelineBuffer();
mVertexData->WaitSync();
RenderState()->SetVertexBuffer(screen->mVertexData); // Needed for Raze because it does not reset it
}
Finish.Unclock();
camtexcount = 0;
FHardwareTexture::UnbindAll();

View file

@ -204,7 +204,7 @@ bool FGLRenderState::ApplyShader()
size_t start, size;
index = screen->mLights->GetBinding(index, &start, &size);
if (start != mLastMappedLightIndex)
if (start != mLastMappedLightIndex || screen->mPipelineNbr > 1) // If multiple buffers always bind
{
mLastMappedLightIndex = start;
static_cast<GLDataBuffer*>(screen->mLights->GetBuffer())->BindRange(nullptr, start, size);

View file

@ -382,7 +382,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
vp_comb = "#version 430 core\n#define SHADER_STORAGE_LIGHTS\n";
}
if (gl.flags & RFL_SHADER_STORAGE_BUFFER)
if ((gl.flags & RFL_SHADER_STORAGE_BUFFER) && screen->mPipelineType == 0)
{
vp_comb << "#define SUPPORTS_SHADOWMAPS\n";
}