mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-03-13 04:01:57 +00:00
Rendering and platform changes from GZDoom
This commit is contained in:
parent
52e29d4112
commit
494e21f318
22 changed files with 232 additions and 49 deletions
|
@ -636,6 +636,7 @@ file( GLOB HEADER_FILES
|
|||
common/thirdparty/libsmackerdec/include/*.h
|
||||
common/rendering/*.h
|
||||
common/rendering/gl_load/*.h
|
||||
common/rendering/gles/*.h
|
||||
common/rendering/hwrenderer/*.h
|
||||
common/rendering/hwrenderer/data/*.h
|
||||
common/rendering/polyrenderer/*.h
|
||||
|
@ -971,6 +972,24 @@ if (HAVE_VULKAN)
|
|||
set (FASTMATH_SOURCES ${FASTMATH_SOURCES} ${VULKAN_SOURCES})
|
||||
endif()
|
||||
|
||||
set (GLES_SOURCES
|
||||
common/rendering/gles/gles_system.cpp
|
||||
common/rendering/gles/gles_renderer.cpp
|
||||
common/rendering/gles/gles_framebuffer.cpp
|
||||
common/rendering/gles/gles_renderstate.cpp
|
||||
common/rendering/gles/gles_renderbuffers.cpp
|
||||
common/rendering/gles/gles_postprocess.cpp
|
||||
common/rendering/gles/gles_postprocessstate.cpp
|
||||
common/rendering/gles/gles_buffers.cpp
|
||||
common/rendering/gles/gles_hwtexture.cpp
|
||||
common/rendering/gles/gles_shader.cpp
|
||||
common/rendering/gles/gles_shaderprogram.cpp
|
||||
common/rendering/gles/gles_samplers.cpp
|
||||
common/rendering/gles/glad/src/glad.c
|
||||
)
|
||||
|
||||
set (FASTMATH_SOURCES ${FASTMATH_SOURCES} ${GLES_SOURCES})
|
||||
|
||||
set (POLYBACKEND_SOURCES
|
||||
common/rendering/polyrenderer/backend/poly_framebuffer.cpp
|
||||
common/rendering/polyrenderer/backend/poly_buffers.cpp
|
||||
|
@ -1381,6 +1400,8 @@ include_directories(
|
|||
common/rendering/hwrenderer/data
|
||||
common/rendering/gl_load
|
||||
common/rendering/gl
|
||||
common/rendering/gles
|
||||
common/rendering/gles/glad/include
|
||||
common/rendering/vulkan/thirdparty
|
||||
common/rendering/polyrenderer/backend
|
||||
common/rendering/polyrenderer/drawers
|
||||
|
@ -1546,6 +1567,7 @@ source_group("Common\\Rendering\\Hardware Renderer\\Data" REGULAR_EXPRESSION "^$
|
|||
source_group("Common\\Rendering\\Hardware Renderer\\Postprocessing" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/hwrenderer/postprocessing/.+")
|
||||
source_group("Common\\Rendering\\OpenGL Loader" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/gl_load/.+")
|
||||
source_group("Common\\Rendering\\OpenGL Backend" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/gl/.+")
|
||||
source_group("Common\\Rendering\\GLES Backend" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/gles/.+")
|
||||
source_group("Common\\Rendering\\Vulkan Renderer\\System" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/vulkan/system/.+")
|
||||
source_group("Common\\Rendering\\Vulkan Renderer\\Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/vulkan/renderer/.+")
|
||||
source_group("Common\\Rendering\\Vulkan Renderer\\Shaders" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/vulkan/shaders/.+")
|
||||
|
|
|
@ -52,8 +52,9 @@
|
|||
#include "v_text.h"
|
||||
#include "version.h"
|
||||
#include "printf.h"
|
||||
|
||||
#include "gl_framebuffer.h"
|
||||
#include "gles_framebuffer.h"
|
||||
|
||||
#ifdef HAVE_VULKAN
|
||||
#include "vulkan/system/vk_framebuffer.h"
|
||||
#endif
|
||||
|
@ -462,7 +463,10 @@ public:
|
|||
|
||||
if (fb == nullptr)
|
||||
{
|
||||
fb = new OpenGLRenderer::OpenGLFrameBuffer(0, vid_fullscreen);
|
||||
if( Args->CheckParm ("-gles2_renderer") )
|
||||
fb = new OpenGLESRenderer::OpenGLFrameBuffer(0, vid_fullscreen);
|
||||
else
|
||||
fb = new OpenGLRenderer::OpenGLFrameBuffer(0, vid_fullscreen);
|
||||
}
|
||||
|
||||
fb->SetWindow(ms_window);
|
||||
|
|
|
@ -50,7 +50,8 @@
|
|||
|
||||
#include "gl_renderer.h"
|
||||
#include "gl_framebuffer.h"
|
||||
|
||||
#include "gles_framebuffer.h"
|
||||
|
||||
#ifdef HAVE_VULKAN
|
||||
#include "vulkan/system/vk_framebuffer.h"
|
||||
#endif
|
||||
|
@ -449,14 +450,13 @@ DFrameBuffer *SDLVideo::CreateFrameBuffer ()
|
|||
device = new VulkanDevice();
|
||||
fb = new VulkanFrameBuffer(nullptr, vid_fullscreen, device);
|
||||
}
|
||||
catch (CVulkanError const &error)
|
||||
catch (CVulkanError const&)
|
||||
{
|
||||
if (Priv::window != nullptr)
|
||||
{
|
||||
Priv::DestroyWindow();
|
||||
}
|
||||
|
||||
Printf(TEXTCOLOR_RED "Initialization of Vulkan failed: %s\n", error.what());
|
||||
Priv::vulkanEnabled = false;
|
||||
}
|
||||
}
|
||||
|
@ -470,7 +470,10 @@ DFrameBuffer *SDLVideo::CreateFrameBuffer ()
|
|||
#endif
|
||||
if (fb == nullptr)
|
||||
{
|
||||
fb = new OpenGLRenderer::OpenGLFrameBuffer(0, vid_fullscreen);
|
||||
if( Args->CheckParm ("-gles2_renderer") )
|
||||
fb = new OpenGLESRenderer::OpenGLFrameBuffer(0, vid_fullscreen);
|
||||
else
|
||||
fb = new OpenGLRenderer::OpenGLFrameBuffer(0, vid_fullscreen);
|
||||
}
|
||||
|
||||
return fb;
|
||||
|
|
|
@ -71,7 +71,7 @@ PFNWGLSWAPINTERVALEXTPROC myWglSwapIntervalExtProc;
|
|||
|
||||
SystemGLFrameBuffer::SystemGLFrameBuffer(void *hMonitor, bool fullscreen) : SystemBaseFrameBuffer(hMonitor, fullscreen)
|
||||
{
|
||||
if (!static_cast<Win32GLVideo *>(Video)->InitHardware(Window, 0))
|
||||
if (!static_cast<Win32GLVideo*>(Video)->InitHardware(Window, 0))
|
||||
{
|
||||
I_FatalError("Unable to initialize OpenGL");
|
||||
return;
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "win32glvideo.h"
|
||||
|
||||
#include "gl_framebuffer.h"
|
||||
#include "gles_framebuffer.h"
|
||||
|
||||
extern "C" {
|
||||
HGLRC zd_wglCreateContext(HDC Arg1);
|
||||
|
@ -105,7 +106,11 @@ DFrameBuffer *Win32GLVideo::CreateFrameBuffer()
|
|||
{
|
||||
SystemGLFrameBuffer *fb;
|
||||
|
||||
fb = new OpenGLRenderer::OpenGLFrameBuffer(m_hMonitor, vid_fullscreen);
|
||||
if (Args->CheckParm("-gles2_renderer"))
|
||||
fb = new OpenGLESRenderer::OpenGLFrameBuffer(m_hMonitor, vid_fullscreen);
|
||||
else
|
||||
fb = new OpenGLRenderer::OpenGLFrameBuffer(m_hMonitor, vid_fullscreen);
|
||||
|
||||
return fb;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
|
|
@ -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,8 @@ void OpenGLFrameBuffer::InitializeState()
|
|||
|
||||
gl_LoadExtensions();
|
||||
|
||||
mPipelineNbr = gl_pipeline_depth;
|
||||
|
||||
// Move some state to the framebuffer object for easier access.
|
||||
hwcaps = gl.flags;
|
||||
glslversion = gl.glslversion;
|
||||
|
@ -164,10 +167,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 +259,18 @@ void OpenGLFrameBuffer::Swap()
|
|||
bool swapbefore = gl_finishbeforeswap && camtexcount == 0;
|
||||
Finish.Reset();
|
||||
Finish.Clock();
|
||||
if (swapbefore) glFinish();
|
||||
//if (swapbefore) glFinish();
|
||||
mVertexData->DropSync();
|
||||
|
||||
FPSLimit();
|
||||
SwapBuffers();
|
||||
if (!swapbefore) glFinish();
|
||||
|
||||
mVertexData->NextPipelineBuffer();
|
||||
mVertexData->WaitSync();
|
||||
|
||||
RenderState()->SetVertexBuffer(screen->mVertexData); // Needed for Raze because it does not reset it
|
||||
|
||||
//if (!swapbefore) glFinish();
|
||||
Finish.Unclock();
|
||||
camtexcount = 0;
|
||||
FHardwareTexture::UnbindAll();
|
||||
|
|
|
@ -138,4 +138,4 @@ void FSamplerManager::SetTextureFilterMode()
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -420,4 +420,4 @@ void FGLRenderer::PresentStereo()
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,6 +161,8 @@ void gl_LoadExtensions()
|
|||
#endif
|
||||
gl.glslversion = 3.31f; // Force GLSL down to 3.3.
|
||||
}
|
||||
|
||||
#if 0 // Shader storage breaks buffer pipeline. Pipelined buffers are much faster anyway
|
||||
else if (gl_version < 4.5f)
|
||||
{
|
||||
// don't use GL 4.x features when running a GL 3.x context.
|
||||
|
@ -180,6 +182,7 @@ void gl_LoadExtensions()
|
|||
// Assume that everything works without problems on GL 4.5 drivers where these things are core features.
|
||||
gl.flags |= RFL_SHADER_STORAGE_BUFFER | RFL_BUFFER_STORAGE;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Mesa implements shader storage only for fragment shaders.
|
||||
// Just disable the feature there. The light buffer may just use a uniform buffer without any adverse effects.
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
class FRenderState;
|
||||
|
||||
#define HW_MAX_PIPELINE_BUFFERS 8
|
||||
|
||||
// The low level code needs to know which attributes exist.
|
||||
// OpenGL needs to change the state of all of them per buffer binding.
|
||||
// VAOs are mostly useless for this because they lump buffer and binding state together which the model code does not want.
|
||||
|
@ -54,10 +56,15 @@ public:
|
|||
virtual void *Lock(unsigned int size) = 0;
|
||||
virtual void Unlock() = 0;
|
||||
virtual void Resize(size_t newsize) = 0;
|
||||
|
||||
virtual void Upload(size_t start, size_t size) {} // For unmappable buffers
|
||||
|
||||
virtual void Map() {} // Only needed by old OpenGL but this needs to be in the interface.
|
||||
virtual void Unmap() {}
|
||||
void *Memory() { return map; }
|
||||
size_t Size() { return buffersize; }
|
||||
virtual void GPUDropSync() {}
|
||||
virtual void GPUWaitSync() {}
|
||||
};
|
||||
|
||||
class IVertexBuffer : virtual public IBuffer
|
||||
|
|
|
@ -45,7 +45,8 @@
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FFlatVertexBuffer::FFlatVertexBuffer(int width, int height)
|
||||
FFlatVertexBuffer::FFlatVertexBuffer(int width, int height, int pipelineNbr):
|
||||
mPipelineNbr(pipelineNbr)
|
||||
{
|
||||
vbo_shadowdata.Resize(NUM_RESERVED);
|
||||
|
||||
|
@ -78,19 +79,27 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height)
|
|||
vbo_shadowdata[18].Set(32767.0f, -32767.0f, 32767.0f, 0, 0);
|
||||
vbo_shadowdata[19].Set(32767.0f, -32767.0f, -32767.0f, 0, 0);
|
||||
|
||||
mVertexBuffer = screen->CreateVertexBuffer();
|
||||
mIndexBuffer = screen->CreateIndexBuffer();
|
||||
int data[4] = {};
|
||||
mIndexBuffer->SetData(4, data); // On Vulkan this may not be empty, so set some dummy defaults to avoid crashes.
|
||||
|
||||
unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex);
|
||||
mVertexBuffer->SetData(bytesize, nullptr, false);
|
||||
|
||||
static const FVertexBufferAttribute format[] = {
|
||||
{ 0, VATTR_VERTEX, VFmt_Float3, (int)myoffsetof(FFlatVertex, x) },
|
||||
{ 0, VATTR_TEXCOORD, VFmt_Float2, (int)myoffsetof(FFlatVertex, u) }
|
||||
};
|
||||
mVertexBuffer->SetFormat(1, 2, sizeof(FFlatVertex), format);
|
||||
for (int n = 0; n < mPipelineNbr; n++)
|
||||
{
|
||||
mVertexBufferPipeline[n] = screen->CreateVertexBuffer();
|
||||
|
||||
unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex);
|
||||
mVertexBufferPipeline[n]->SetData(bytesize, nullptr, false);
|
||||
|
||||
static const FVertexBufferAttribute format[] = {
|
||||
{ 0, VATTR_VERTEX, VFmt_Float3, (int)myoffsetof(FFlatVertex, x) },
|
||||
{ 0, VATTR_TEXCOORD, VFmt_Float2, (int)myoffsetof(FFlatVertex, u) }
|
||||
};
|
||||
|
||||
mVertexBufferPipeline[n]->SetFormat(1, 2, sizeof(FFlatVertex), format);
|
||||
}
|
||||
|
||||
mVertexBuffer = mVertexBufferPipeline[mPipelinePos];
|
||||
|
||||
mIndex = mCurIndex = NUM_RESERVED;
|
||||
mNumReserved = NUM_RESERVED;
|
||||
|
@ -105,8 +114,12 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height)
|
|||
|
||||
FFlatVertexBuffer::~FFlatVertexBuffer()
|
||||
{
|
||||
for (int n = 0; n < mPipelineNbr; n++)
|
||||
{
|
||||
delete mVertexBufferPipeline[n];
|
||||
}
|
||||
|
||||
delete mIndexBuffer;
|
||||
delete mVertexBuffer;
|
||||
mIndexBuffer = nullptr;
|
||||
mVertexBuffer = nullptr;
|
||||
}
|
||||
|
@ -153,8 +166,17 @@ std::pair<FFlatVertex *, unsigned int> FFlatVertexBuffer::AllocVertices(unsigned
|
|||
|
||||
void FFlatVertexBuffer::Copy(int start, int count)
|
||||
{
|
||||
Map();
|
||||
memcpy(GetBuffer(start), &vbo_shadowdata[0], count * sizeof(FFlatVertex));
|
||||
Unmap();
|
||||
IVertexBuffer* old = mVertexBuffer;
|
||||
|
||||
for (int n = 0; n < mPipelineNbr; n++)
|
||||
{
|
||||
mVertexBuffer = mVertexBufferPipeline[n];
|
||||
Map();
|
||||
memcpy(GetBuffer(start), &vbo_shadowdata[0], count * sizeof(FFlatVertex));
|
||||
Unmap();
|
||||
mVertexBuffer->Upload(start * sizeof(FFlatVertex), count * sizeof(FFlatVertex));
|
||||
}
|
||||
|
||||
mVertexBuffer = old;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,13 +45,20 @@ public:
|
|||
TArray<FFlatVertex> vbo_shadowdata;
|
||||
TArray<uint32_t> ibo_data;
|
||||
|
||||
IVertexBuffer *mVertexBuffer;
|
||||
int mPipelineNbr;
|
||||
int mPipelinePos = 0;
|
||||
|
||||
IVertexBuffer* mVertexBuffer;
|
||||
IVertexBuffer *mVertexBufferPipeline[HW_MAX_PIPELINE_BUFFERS];
|
||||
IIndexBuffer *mIndexBuffer;
|
||||
|
||||
|
||||
|
||||
unsigned int mIndex;
|
||||
std::atomic<unsigned int> mCurIndex;
|
||||
unsigned int mNumReserved;
|
||||
|
||||
unsigned int mMapStart;
|
||||
|
||||
static const unsigned int BUFFER_SIZE = 2000000;
|
||||
static const unsigned int BUFFER_SIZE_TO_USE = BUFFER_SIZE-500;
|
||||
|
@ -68,7 +75,7 @@ public:
|
|||
NUM_RESERVED = 20
|
||||
};
|
||||
|
||||
FFlatVertexBuffer(int width, int height);
|
||||
FFlatVertexBuffer(int width, int height, int pipelineNbr = 1);
|
||||
~FFlatVertexBuffer();
|
||||
|
||||
void OutputResized(int width, int height);
|
||||
|
@ -95,18 +102,43 @@ public:
|
|||
void Reset()
|
||||
{
|
||||
mCurIndex = mIndex;
|
||||
|
||||
}
|
||||
|
||||
void NextPipelineBuffer()
|
||||
{
|
||||
mPipelinePos++;
|
||||
mPipelinePos %= mPipelineNbr;
|
||||
|
||||
mVertexBuffer = mVertexBufferPipeline[mPipelinePos];
|
||||
}
|
||||
|
||||
void Map()
|
||||
{
|
||||
mMapStart = mCurIndex;
|
||||
mVertexBuffer->Map();
|
||||
}
|
||||
|
||||
void Unmap()
|
||||
{
|
||||
mVertexBuffer->Unmap();
|
||||
mVertexBuffer->Upload(mMapStart * sizeof(FFlatVertex), (mCurIndex - mMapStart) * sizeof(FFlatVertex));
|
||||
}
|
||||
|
||||
void DropSync()
|
||||
{
|
||||
mVertexBuffer->GPUDropSync();
|
||||
}
|
||||
|
||||
void WaitSync()
|
||||
{
|
||||
mVertexBuffer->GPUWaitSync();
|
||||
}
|
||||
|
||||
int GetPipelinePos()
|
||||
{
|
||||
return mPipelinePos;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,7 +33,8 @@ static const int ELEMENTS_PER_LIGHT = 4; // each light needs 4 vec4's.
|
|||
static const int ELEMENT_SIZE = (4*sizeof(float));
|
||||
|
||||
|
||||
FLightBuffer::FLightBuffer()
|
||||
FLightBuffer::FLightBuffer(int pipelineNbr):
|
||||
mPipelineNbr(pipelineNbr)
|
||||
{
|
||||
int maxNumberOfLights = 80000;
|
||||
|
||||
|
@ -56,11 +57,15 @@ FLightBuffer::FLightBuffer()
|
|||
mBlockSize = screen->maxuniformblock / ELEMENT_SIZE;
|
||||
mBlockAlign = screen->uniformblockalignment / ELEMENT_SIZE;
|
||||
mMaxUploadSize = (mBlockSize - mBlockAlign);
|
||||
mByteSize += screen->maxuniformblock; // to avoid mapping beyond the end of the buffer.
|
||||
|
||||
//mByteSize += screen->maxuniformblock; // to avoid mapping beyond the end of the buffer. REMOVED this...This can try to allocate 100's of MB..
|
||||
}
|
||||
|
||||
mBuffer = screen->CreateDataBuffer(LIGHTBUF_BINDINGPOINT, mBufferType, false);
|
||||
mBuffer->SetData(mByteSize, nullptr, false);
|
||||
for (int n = 0; n < mPipelineNbr; n++)
|
||||
{
|
||||
mBufferPipeline[n] = screen->CreateDataBuffer(LIGHTBUF_BINDINGPOINT, mBufferType, false);
|
||||
mBufferPipeline[n]->SetData(mByteSize, nullptr, false);
|
||||
}
|
||||
|
||||
Clear();
|
||||
}
|
||||
|
@ -73,6 +78,11 @@ FLightBuffer::~FLightBuffer()
|
|||
void FLightBuffer::Clear()
|
||||
{
|
||||
mIndex = 0;
|
||||
|
||||
mPipelinePos++;
|
||||
mPipelinePos %= mPipelineNbr;
|
||||
|
||||
mBuffer = mBufferPipeline[mPipelinePos];
|
||||
}
|
||||
|
||||
int FLightBuffer::UploadLights(FDynLightData &data)
|
||||
|
|
|
@ -12,6 +12,9 @@ class FRenderState;
|
|||
class FLightBuffer
|
||||
{
|
||||
IDataBuffer *mBuffer;
|
||||
IDataBuffer* mBufferPipeline[HW_MAX_PIPELINE_BUFFERS];
|
||||
int mPipelineNbr;
|
||||
int mPipelinePos = 0;
|
||||
|
||||
bool mBufferType;
|
||||
std::atomic<unsigned int> mIndex;
|
||||
|
@ -25,7 +28,7 @@ class FLightBuffer
|
|||
|
||||
public:
|
||||
|
||||
FLightBuffer();
|
||||
FLightBuffer(int pipelineNbr = 1);
|
||||
~FLightBuffer();
|
||||
void Clear();
|
||||
int UploadLights(FDynLightData &data);
|
||||
|
|
|
@ -226,6 +226,10 @@ protected:
|
|||
float mAlphaThreshold;
|
||||
float mClipSplit[2];
|
||||
|
||||
|
||||
int mColorMapSpecial;
|
||||
float mColorMapFlash;
|
||||
|
||||
StreamData mStreamData = {};
|
||||
PalEntry mFogColor;
|
||||
|
||||
|
@ -278,6 +282,9 @@ public:
|
|||
mBias.Reset();
|
||||
mPassType = NORMAL_PASS;
|
||||
|
||||
mColorMapSpecial = 0;
|
||||
mColorMapFlash = 1;
|
||||
|
||||
mVertexBuffer = nullptr;
|
||||
mVertexOffsets[0] = mVertexOffsets[1] = 0;
|
||||
mIndexBuffer = nullptr;
|
||||
|
@ -676,6 +683,12 @@ public:
|
|||
return mPassType;
|
||||
}
|
||||
|
||||
void SetSpecialColormap(int cm, float flash)
|
||||
{
|
||||
mColorMapSpecial = cm;
|
||||
mColorMapFlash = flash;
|
||||
}
|
||||
|
||||
// API-dependent render interface
|
||||
|
||||
// Draw commands
|
||||
|
|
|
@ -33,13 +33,19 @@
|
|||
|
||||
static const int INITIAL_BUFFER_SIZE = 100; // 100 viewpoints per frame should nearly always be enough
|
||||
|
||||
HWViewpointBuffer::HWViewpointBuffer()
|
||||
HWViewpointBuffer::HWViewpointBuffer(int pipelineNbr):
|
||||
mPipelineNbr(pipelineNbr)
|
||||
{
|
||||
mBufferSize = INITIAL_BUFFER_SIZE;
|
||||
mBlockAlign = ((sizeof(HWViewpointUniforms) / screen->uniformblockalignment) + 1) * screen->uniformblockalignment;
|
||||
mByteSize = mBufferSize * mBlockAlign;
|
||||
mBuffer = screen->CreateDataBuffer(VIEWPOINT_BINDINGPOINT, false, true);
|
||||
mBuffer->SetData(mByteSize, nullptr, false);
|
||||
|
||||
for (int n = 0; n < mPipelineNbr; n++)
|
||||
{
|
||||
mBufferPipeline[n] = screen->CreateDataBuffer(VIEWPOINT_BINDINGPOINT, false, true);
|
||||
mBufferPipeline[n]->SetData(mByteSize, nullptr, false);
|
||||
}
|
||||
|
||||
Clear();
|
||||
mLastMappedIndex = UINT_MAX;
|
||||
mClipPlaneInfo.Push(0);
|
||||
|
@ -57,7 +63,10 @@ void HWViewpointBuffer::CheckSize()
|
|||
{
|
||||
mBufferSize *= 2;
|
||||
mByteSize *= 2;
|
||||
mBuffer->Resize(mByteSize);
|
||||
for (int n = 0; n < mPipelineNbr; n++)
|
||||
{
|
||||
mBufferPipeline[n]->Resize(mByteSize);
|
||||
}
|
||||
m2DHeight = m2DWidth = -1;
|
||||
}
|
||||
}
|
||||
|
@ -89,9 +98,14 @@ 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.CalcDependencies();
|
||||
mBuffer->Map();
|
||||
memcpy(mBuffer->Memory(), &matrices, sizeof(matrices));
|
||||
mBuffer->Unmap();
|
||||
|
||||
for (int n = 0; n < mPipelineNbr; n++)
|
||||
{
|
||||
mBufferPipeline[n]->Map();
|
||||
memcpy(mBufferPipeline[n]->Memory(), &matrices, sizeof(matrices));
|
||||
mBufferPipeline[n]->Unmap();
|
||||
}
|
||||
|
||||
m2DWidth = width;
|
||||
m2DHeight = height;
|
||||
mLastMappedIndex = -1;
|
||||
|
@ -115,5 +129,10 @@ void HWViewpointBuffer::Clear()
|
|||
// Index 0 is reserved for the 2D projection.
|
||||
mUploadIndex = 1;
|
||||
mClipPlaneInfo.Resize(1);
|
||||
|
||||
mPipelinePos++;
|
||||
mPipelinePos %= mPipelineNbr;
|
||||
|
||||
mBuffer = mBufferPipeline[mPipelinePos];
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@ class FRenderState;
|
|||
class HWViewpointBuffer
|
||||
{
|
||||
IDataBuffer *mBuffer;
|
||||
IDataBuffer* mBufferPipeline[HW_MAX_PIPELINE_BUFFERS];
|
||||
int mPipelineNbr;
|
||||
int mPipelinePos = 0;
|
||||
|
||||
unsigned int mBufferSize;
|
||||
unsigned int mBlockAlign;
|
||||
|
@ -24,7 +27,7 @@ class HWViewpointBuffer
|
|||
|
||||
public:
|
||||
|
||||
HWViewpointBuffer();
|
||||
HWViewpointBuffer(int pipelineNbr = 1);
|
||||
~HWViewpointBuffer();
|
||||
void Clear();
|
||||
int Bind(FRenderState &di, unsigned int index);
|
||||
|
|
|
@ -72,6 +72,8 @@ CVAR(Int, win_w, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
|||
CVAR(Int, win_h, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, win_maximized, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
||||
|
||||
CVAR(Int, gl_pipeline_depth, 4, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
|
||||
|
||||
CUSTOM_CVAR(Int, vid_maxfps, 200, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < GameTicRate && self != 0)
|
||||
|
|
|
@ -148,6 +148,7 @@ public:
|
|||
IntRect mOutputLetterbox;
|
||||
float mSceneClearColor[4]{ 0,0,0,255 };
|
||||
|
||||
int mPipelineNbr = 1; // Number of HW buffers to pipeline
|
||||
public:
|
||||
DFrameBuffer (int width=1, int height=1);
|
||||
virtual ~DFrameBuffer();
|
||||
|
|
|
@ -239,13 +239,8 @@ void VkRenderBuffers::CreateShadowmap()
|
|||
|
||||
ImageBuilder builder;
|
||||
builder.setSize(gl_shadowmap_quality, 1024);
|
||||
builder.setFormat(SceneNormalFormat);
|
||||
builder.setFormat(VK_FORMAT_R32_SFLOAT);
|
||||
builder.setUsage(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT);
|
||||
if (!builder.isFormatSupported(fb->device, VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT))
|
||||
{
|
||||
SceneNormalFormat = VK_FORMAT_R8G8B8A8_UNORM;
|
||||
builder.setFormat(SceneNormalFormat);
|
||||
}
|
||||
Shadowmap.Image = builder.create(fb->device);
|
||||
Shadowmap.Image->SetDebugName("VkRenderBuffers.Shadowmap");
|
||||
|
||||
|
|
Loading…
Reference in a new issue