Merge branch 'master' of https://github.com/coelckers/gzdoom into lightmaps2

# Conflicts:
#	src/common/rendering/gl/gl_shader.cpp
#	src/common/rendering/hwrenderer/data/buffers.h
#	src/common/rendering/v_video.h
This commit is contained in:
nashmuhandes 2022-01-16 01:57:38 +08:00
commit 57112742fe
298 changed files with 7614 additions and 3373 deletions

View file

@ -192,12 +192,12 @@ void GLBuffer::GPUDropSync()
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;
@ -213,10 +213,10 @@ void GLVertexBuffer::SetFormat(int numBindingPoints, int numAttributes, size_t s
{
static int VFmtToGLFmt[] = { GL_FLOAT, GL_FLOAT, GL_FLOAT, GL_FLOAT, GL_UNSIGNED_BYTE, GL_INT_2_10_10_10_REV };
static uint8_t VFmtToSize[] = {4, 3, 2, 1, 4, 4};
mStride = stride;
mNumBindingPoints = numBindingPoints;
for(int i = 0; i < numAttributes; i++)
{
if (attrs[i].location >= 0 && attrs[i].location < VATTR_MAX)

View file

@ -69,7 +69,6 @@ EXTERN_CVAR(Int, gl_pipeline_depth);
void gl_LoadExtensions();
void gl_PrintStartupLog();
void Draw2D(F2DDrawer *drawer, FRenderState &state);
extern bool vid_hdr_active;
@ -326,7 +325,6 @@ void OpenGLFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
{
if (mat->Source()->GetUseType() == ETextureType::SWCanvas) return;
int flags = mat->GetScaleFlags();
int numLayers = mat->NumLayers();
MaterialLayerInfo* layer;
auto base = static_cast<FHardwareTexture*>(mat->GetLayer(0, translation, &layer));

View file

@ -67,7 +67,7 @@ public:
bool HWGammaActive = false; // Are we using hardware or software gamma?
std::shared_ptr<FGLDebug> mDebug; // Debug API
FTexture *WipeStartScreen() override;
FTexture *WipeEndScreen() override;

View file

@ -148,7 +148,7 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int
{
sourcetype = GL_BGRA;
}
if (!firstCall && glBufferID > 0)
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, rw, rh, sourcetype, GL_UNSIGNED_BYTE, buffer);
else
@ -301,8 +301,6 @@ void FHardwareTexture::BindToFrameBuffer(int width, int height)
bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, int translation, int flags)
{
int usebright = false;
bool needmipmap = (clampmode <= CLAMP_XY) && !forcenofilter;
// Bind it to the system.
@ -317,7 +315,7 @@ bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, i
int w = 0, h = 0;
// Create this texture
FTextureBuffer texbuffer;
if (!tex->isHardwareCanvas())

View file

@ -444,8 +444,6 @@ bool FGLRenderBuffers::CheckFrameBufferCompleteness()
if (result == GL_FRAMEBUFFER_COMPLETE)
return true;
bool FailedCreate = true;
if (gl_debug_level > 0)
{
FString error = "glCheckFramebufferStatus failed: ";

View file

@ -82,7 +82,7 @@ public:
void DrawPresentTexture(const IntRect &box, bool applyGamma);
void Flush();
void BeginFrame();
bool StartOffscreen();
void EndOffscreen();

View file

@ -311,14 +311,13 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio
if (tex->isHardwareCanvas()) static_cast<FCanvasTexture*>(tex->GetTexture())->NeedUpdate();
clampmode = tex->GetClampMode(clampmode);
// avoid rebinding the same texture multiple times.
if (mat == lastMaterial && lastClamp == clampmode && translation == lastTranslation) return;
lastMaterial = mat;
lastClamp = clampmode;
lastTranslation = translation;
int usebright = false;
int maxbound = 0;
int numLayers = mat->NumLayers();

View file

@ -98,7 +98,7 @@ void FSamplerManager::UnbindAll()
glBindSampler(i, 0);
}
}
uint8_t FSamplerManager::Bind(int texunit, int num, int lastval)
{
unsigned int samp = mSamplers[num];
@ -106,11 +106,11 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval)
return 255;
}
void FSamplerManager::SetTextureFilterMode()
{
GLint bounds[IHardwareTexture::MAX_TEXTURES];
// Unbind all
for(int i = IHardwareTexture::MAX_TEXTURES-1; i >= 0; i--)
{
@ -138,4 +138,4 @@ void FSamplerManager::SetTextureFilterMode()
}
}
}

View file

@ -337,7 +337,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
#endif
)";
#ifdef __APPLE__
// The noise functions are completely broken in macOS OpenGL drivers
@ -621,7 +621,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
{
char stringbuf[20];
mysnprintf(stringbuf, 20, "texture%d", i);
int tempindex = glGetUniformLocation(hShader, stringbuf);
tempindex = glGetUniformLocation(hShader, stringbuf);
if (tempindex != -1) glUniform1i(tempindex, i - 1);
}
@ -787,8 +787,8 @@ void FShaderCollection::CompileShaders(EPassType passType)
mMaterialShaders.Push(shc);
if (i < SHADER_NoTexture)
{
FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, defaultshaders[i].lightfunc, defaultshaders[i].Defines, false, passType);
mMaterialShadersNAT.Push(shc);
FShader *shc1 = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, defaultshaders[i].lightfunc, defaultshaders[i].Defines, false, passType);
mMaterialShadersNAT.Push(shc1);
}
}

View file

@ -325,7 +325,7 @@ class FShaderCollection
void Clean();
void CompileShaders(EPassType passType);
public:
FShaderCollection(EPassType passType);
~FShaderCollection();

View file

@ -1,28 +1,38 @@
//
//---------------------------------------------------------------------------
//
// Copyright(C) 2015 Christopher Bruns
// All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see http://www.gnu.org/licenses/
//
//--------------------------------------------------------------------------
//
/*
** gl_stereo3d.cpp
** gl_stereo.cpp
** Stereoscopic 3D API
**
**---------------------------------------------------------------------------
** Copyright 2015 Christopher Bruns
** Copyright 2016-2021 Christoph Oelckers
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
**
**
*/
#include "gl_system.h"

View file

@ -230,7 +230,7 @@ void gl_PrintStartupLog()
Printf ("Max. texture units: %d\n", v);
glGetIntegerv(GL_MAX_VARYING_FLOATS, &v);
Printf ("Max. varying: %d\n", v);
if (gl.flags & RFL_SHADER_STORAGE_BUFFER)
{
glGetIntegerv(GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS, &v);

View file

@ -9,7 +9,7 @@
static void* AppleGLGetProcAddress (const char *name)
{
static void* image = NULL;
if (NULL == image)
image = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY);
@ -61,9 +61,9 @@ static int TestPointer(const PROC pTest)
ptrdiff_t iTest;
if(!pTest) return 0;
iTest = (ptrdiff_t)pTest;
if(iTest == 1 || iTest == 2 || iTest == 3 || iTest == -1) return 0;
return 1;
}
@ -119,7 +119,7 @@ static PROC WinGetProcAddress(const char *name)
glMod = GetModuleHandleA("OpenGL32.dll");
return (PROC)GetProcAddress(glMod, (LPCSTR)name);
}
#define IntGetProcAddress(name) WinGetProcAddress(name)
#else
#if defined(__APPLE__)
@ -3363,7 +3363,7 @@ static ogl_StrToExtMap *FindExtEntry(const char *extensionName)
if(strcmp(extensionName, currLoc->extensionName) == 0)
return currLoc;
}
return NULL;
}
@ -3465,7 +3465,7 @@ int ogl_LoadFunctions()
{
int numFailed = 0;
ClearExtensionVars();
_ptrc_glGetIntegerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint *))IntGetProcAddress("glGetIntegerv");
if(!_ptrc_glGetIntegerv) return ogl_LOAD_FAILED;
_ptrc_glGetStringi = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glGetStringi");
@ -3479,7 +3479,7 @@ int ogl_LoadFunctions()
}
numFailed = Load_Version_4_5();
if(numFailed == 0)
return ogl_LOAD_SUCCEEDED;
else
@ -3515,7 +3515,7 @@ int ogl_IsVersionGEQ(int majorVersion, int minorVersion)
{
if(g_major_version == 0)
GetGLVersion();
if(majorVersion < g_major_version) return 1;
if(majorVersion > g_major_version) return 0;
if(minorVersion <= g_minor_version) return 1;

View file

@ -7,7 +7,7 @@
APIs: gles2=2.0
Profile: compatibility
Extensions:
Loader: True
Local files: False
Omit khrplatform: False

View file

@ -7,7 +7,7 @@
APIs: egl=1.4
Profile: -
Extensions:
Loader: True
Local files: False
Omit khrplatform: False

View file

@ -7,7 +7,7 @@
APIs: gles2=2.0
Profile: compatibility
Extensions:
Loader: True
Local files: False
Omit khrplatform: False

View file

@ -7,7 +7,7 @@
APIs: egl=1.4
Profile: -
Extensions:
Loader: True
Local files: False
Omit khrplatform: False

View file

@ -79,7 +79,7 @@ GLBuffer::~GLBuffer()
glBindBuffer(mUseType, 0);
glDeleteBuffers(1, &mBufferId);
}
if (memory)
delete[] memory;
}
@ -129,9 +129,9 @@ void GLBuffer::SetData(size_t size, const void* data, BufferUsageType usage)
void GLBuffer::SetSubData(size_t offset, size_t size, const void *data)
{
Bind();
memcpy(memory + offset, data, size);
if (!isData)
{
glBufferSubData(mUseType, offset, size, data);
@ -143,7 +143,7 @@ void GLBuffer::Upload(size_t start, size_t size)
if (!gles.useMappedBuffers)
{
Bind();
if(size)
glBufferSubData(mUseType, start, size, memory + start);
}
@ -278,10 +278,10 @@ void GLVertexBuffer::SetFormat(int numBindingPoints, int numAttributes, size_t s
{
static int VFmtToGLFmt[] = { GL_FLOAT, GL_FLOAT, GL_FLOAT, GL_FLOAT, GL_UNSIGNED_BYTE, GL_FLOAT }; // TODO Fix last entry GL_INT_2_10_10_10_REV, normals for models will be broken
static uint8_t VFmtToSize[] = {4, 3, 2, 1, 4, 4};
mStride = stride;
mNumBindingPoints = numBindingPoints;
for(int i = 0; i < numAttributes; i++)
{
if (attrs[i].location >= 0 && attrs[i].location < VATTR_MAX)

View file

@ -67,8 +67,6 @@ EXTERN_CVAR(Int, gl_pipeline_depth);
EXTERN_CVAR(Bool, gl_sort_textures);
void Draw2D(F2DDrawer *drawer, FRenderState &state);
extern bool vid_hdr_active;
namespace OpenGLESRenderer
@ -136,8 +134,9 @@ void OpenGLFrameBuffer::InitializeState()
glEnable(GL_DITHER);
glDisable(GL_CULL_FACE);
glDisable(GL_POLYGON_OFFSET_FILL);
glEnable(GL_BLEND);
if (gles.depthClampAvailable) glEnable(GL_DEPTH_CLAMP);
glDisable(GL_DEPTH_TEST);
@ -236,7 +235,7 @@ const char* OpenGLFrameBuffer::DeviceName() const
void OpenGLFrameBuffer::Swap()
{
Finish.Reset();
Finish.Clock();
@ -244,7 +243,7 @@ void OpenGLFrameBuffer::Swap()
FPSLimit();
SwapBuffers();
mVertexData->NextPipelineBuffer();
mVertexData->WaitSync();
@ -286,7 +285,6 @@ void OpenGLFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
{
if (mat->Source()->GetUseType() == ETextureType::SWCanvas) return;
int flags = mat->GetScaleFlags();
int numLayers = mat->NumLayers();
MaterialLayerInfo* layer;
auto base = static_cast<FHardwareTexture*>(mat->GetLayer(0, translation, &layer));

View file

@ -61,7 +61,7 @@ public:
bool HWGammaActive = false; // Are we using hardware or software gamma?
std::shared_ptr<FGLDebug> mDebug; // Debug API
FTexture *WipeStartScreen() override;
FTexture *WipeEndScreen() override;

View file

@ -132,14 +132,23 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int
#if USE_GLES2
sourcetype = GL_BGRA;
texformat = GL_BGRA;
if (glTextureBytes == 1)
{
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
sourcetype = GL_ALPHA;
texformat = GL_ALPHA;
}
else
{
sourcetype = GL_BGRA;
texformat = GL_BGRA;
}
#else
if (glTextureBytes == 1)
{
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
sourcetype = GL_RED;
texformat = GL_R8;
texformat = GL_RED;
}
else
{
@ -150,6 +159,16 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int
glTexImage2D(GL_TEXTURE_2D, 0, texformat, rw, rh, 0, sourcetype, GL_UNSIGNED_BYTE, buffer);
#if !(USE_GLES2)
// The shader is using the alpha channel instead of red, this work on GLES but not on GL
// So the texture uses GL_RED and this swizzels the red channel into the alpha channel
if (glTextureBytes == 1)
{
GLint swizzleMask[] = { GL_ZERO, GL_ZERO, GL_ZERO, GL_RED };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
#endif
if (deletebuffer && buffer) free(buffer);
if (mipmap && TexFilter[gl_texture_filter].mipmapping)
@ -157,7 +176,7 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int
glGenerateMipmap(GL_TEXTURE_2D);
mipmapped = true;
}
if (texunit > 0) glActiveTexture(GL_TEXTURE0);
else if (texunit == -1) glBindTexture(GL_TEXTURE_2D, textureBinding);
return glTexID;
@ -166,9 +185,6 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int
void FHardwareTexture::AllocateBuffer(int w, int h, int texelsize)
{
int rw = GetTexDimension(w);
int rh = GetTexDimension(h);
if (texelsize < 1 || texelsize > 4) texelsize = 4;
glTextureBytes = texelsize;
bufferpitch = w;
@ -287,8 +303,6 @@ void FHardwareTexture::BindToFrameBuffer(int width, int height)
bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, int translation, int flags)
{
int usebright = false;
bool needmipmap = (clampmode <= CLAMP_XY) && !forcenofilter;
// Bind it to the system.
@ -303,7 +317,7 @@ bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, i
int w = 0, h = 0;
// Create this texture
FTextureBuffer texbuffer;
if (!tex->isHardwareCanvas())

View file

@ -158,10 +158,9 @@ void FGLRenderer::DrawPresentTexture(const IntRect &box, bool applyGamma)
mPresentShader->Uniforms->Offset = { 0.0f, 0.0f };
mPresentShader->Uniforms.SetData();
for (size_t n = 0; n < mPresentShader->Uniforms.mFields.size(); n++)
{
int index = -1;
UniformFieldDesc desc = mPresentShader->Uniforms.mFields[n];
int loc = mPresentShader->Uniforms.UniformLocation[n];
switch (desc.Type)
@ -179,7 +178,7 @@ void FGLRenderer::DrawPresentTexture(const IntRect &box, bool applyGamma)
break;
}
}
RenderScreenQuad();
}
@ -224,4 +223,4 @@ void FGLRenderer::ClearBorders()
glDisable(GL_SCISSOR_TEST);
}
}
}

View file

@ -44,7 +44,7 @@ namespace OpenGLESRenderer
FGLRenderBuffers::FGLRenderBuffers()
{
}
//==========================================================================
@ -56,7 +56,7 @@ namespace OpenGLESRenderer
FGLRenderBuffers::~FGLRenderBuffers()
{
ClearScene();
DeleteTexture(mDitherTexture);
}
@ -163,7 +163,7 @@ namespace OpenGLESRenderer
mSceneTex = Create2DTexture("PipelineTexture", GL_RGBA, width, height);
}
//==========================================================================
//
@ -178,7 +178,7 @@ namespace OpenGLESRenderer
tex.Height = height;
glGenTextures(1, &tex.handle);
glBindTexture(GL_TEXTURE_2D, tex.handle);
GLenum dataformat = 0, datatype = 0;
/*
switch (format)
@ -224,7 +224,7 @@ namespace OpenGLESRenderer
PPGLRenderBuffer buf;
glGenRenderbuffers(1, &buf.handle);
glBindRenderbuffer(GL_RENDERBUFFER, buf.handle);
glRenderbufferStorage(GL_RENDERBUFFER, format, width, height);
return buf;
}
@ -240,7 +240,7 @@ namespace OpenGLESRenderer
PPGLFrameBuffer fb;
glGenFramebuffers(1, &fb.handle);
glBindFramebuffer(GL_FRAMEBUFFER, fb.handle);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer.handle, 0);
if (CheckFrameBufferCompleteness())
ClearFrameBuffer(false, false);
@ -252,7 +252,7 @@ namespace OpenGLESRenderer
PPGLFrameBuffer fb;
glGenFramebuffers(1, &fb.handle);
glBindFramebuffer(GL_FRAMEBUFFER, fb.handle);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer.handle, 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthstencil.handle);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, gles.depthStencilAvailable ? depthstencil.handle : stencil.handle);
@ -266,7 +266,7 @@ namespace OpenGLESRenderer
PPGLFrameBuffer fb;
glGenFramebuffers(1, &fb.handle);
glBindFramebuffer(GL_FRAMEBUFFER, fb.handle);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuffer.handle);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthstencil.handle);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, gles.depthStencilAvailable ? depthstencil.handle : stencil.handle);
@ -284,7 +284,7 @@ namespace OpenGLESRenderer
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer0.handle, 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthstencil.handle);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, gles.depthStencilAvailable ? depthstencil.handle : stencil.handle);
if (CheckFrameBufferCompleteness())
ClearFrameBuffer(true, true);
return fb;
@ -302,9 +302,6 @@ namespace OpenGLESRenderer
if (result == GL_FRAMEBUFFER_COMPLETE)
return true;
bool FailedCreate = true;
FString error = "glCheckFramebufferStatus failed: ";
switch (result)
{
@ -314,7 +311,7 @@ namespace OpenGLESRenderer
case GL_FRAMEBUFFER_UNSUPPORTED: error << "GL_FRAMEBUFFER_UNSUPPORTED"; break;
}
Printf("%s\n", error.GetChars());
return false;
}
@ -372,7 +369,7 @@ namespace OpenGLESRenderer
mDitherTexture.Bind(1, GL_NEAREST, GL_REPEAT);
}
//==========================================================================
//
// Makes the scene frame buffer active (multisample, depth, stecil, etc.)

View file

@ -113,7 +113,7 @@ public:
private:
void ClearScene();
void CreateScene(int width, int height);
void CreatePipeline(int width, int height);

View file

@ -83,7 +83,7 @@ void FGLRenderer::Initialize(int width, int height)
mScreenBuffers = new FGLRenderBuffers();
mBuffers = mScreenBuffers;
mPresentShader = new FPresentShader();
mFBID = 0;
mOldFBID = 0;
@ -97,7 +97,7 @@ FGLRenderer::~FGLRenderer()
TexMan.FlushAll();
if (mShaderManager != nullptr) delete mShaderManager;
if (mFBID != 0) glDeleteFramebuffers(1, &mFBID);
if (mBuffers) delete mBuffers;
if (mPresentShader) delete mPresentShader;
}
@ -110,7 +110,6 @@ FGLRenderer::~FGLRenderer()
bool FGLRenderer::StartOffscreen()
{
bool firstBind = (mFBID == 0);
if (mFBID == 0)
glGenFramebuffers(1, &mFBID);
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &mOldFBID);

View file

@ -67,12 +67,12 @@ public:
void PresentStereo();
void RenderScreenQuad();
void PostProcessScene(int fixedcm, float flash, const std::function<void()> &afterBloomDrawEndScene2D);
void CopyToBackbuffer(const IntRect *bounds, bool applyGamma);
void DrawPresentTexture(const IntRect &box, bool applyGamma);
void Flush();
void BeginFrame();
bool StartOffscreen();
void EndOffscreen();

View file

@ -94,7 +94,7 @@ void FGLRenderState::Reset()
bool FGLRenderState::ApplyShader()
{
static const float nulvec[] = { 0.f, 0.f, 0.f, 0.f };
ShaderFlavourData flavour;
// Need to calc light data now in order to select correct shader
@ -127,7 +127,7 @@ bool FGLRenderState::ApplyShader()
if (modLights + subLights + addLights > (int)gles.maxlights)
addLights = gles.maxlights - modLights - subLights;
totalLights = modLights + subLights + addLights;
// Skip passed the first 4 floats so the upload below only contains light data
@ -152,12 +152,13 @@ bool FGLRenderState::ApplyShader()
flavour.texFlags = tm >> 16; //Move flags to start of word
if (mTextureClamp && flavour.textureMode == TM_NORMAL) flavour.textureMode = TM_CLAMPY; // fixme. Clamp can now be combined with all modes.
if (flavour.textureMode == -1)
flavour.textureMode = 0;
flavour.blendFlags = (int)(mStreamData.uTextureAddColor.a + 0.01);
flavour.paletteInterpolate = !!(flavour.blendFlags & 0x4000);
flavour.twoDFog = false;
flavour.fogEnabled = false;
@ -165,7 +166,7 @@ bool FGLRenderState::ApplyShader()
flavour.colouredFog = false;
flavour.fogEquationRadial = (gl_fogmode == 2);
flavour.twoDFog = false;
flavour.fogEnabled = false;
flavour.colouredFog = false;
@ -196,7 +197,7 @@ bool FGLRenderState::ApplyShader()
flavour.useObjectColor2 = (mStreamData.uObjectColor2.a > 0);
flavour.useGlowTopColor = mGlowEnabled && (mStreamData.uGlowTopColor[3] > 0);
flavour.useGlowBottomColor = mGlowEnabled && (mStreamData.uGlowBottomColor[3] > 0);
flavour.useColorMap = (mColorMapSpecial >= CM_FIRSTSPECIALCOLORMAP) || (mColorMapFlash != 1);
flavour.buildLighting = (mHwUniforms->mPalLightLevels >> 16) == 5; // Build engine mode
@ -217,7 +218,7 @@ bool FGLRenderState::ApplyShader()
activeShader->Bind(flavour);
}
if (mHwUniforms)
{
activeShader->cur->muProjectionMatrix.Set(&mHwUniforms->mProjectionMatrix);
@ -334,7 +335,7 @@ bool FGLRenderState::ApplyShader()
{
// Calculate the total number of vec4s we need
int totalVectors = totalLights * LIGHT_VEC4_NUM;
if (totalVectors > (int)gles.numlightvectors)
totalVectors = gles.numlightvectors;
@ -347,7 +348,7 @@ bool FGLRenderState::ApplyShader()
activeShader->cur->muLightRange.Set(range);
}
return true;
}
@ -389,19 +390,17 @@ void FGLRenderState::ApplyState()
mMaterial.mChanged = false;
}
if (mBias.mChanged)
if (mBias.mFactor == 0 && mBias.mUnits == 0)
{
if (mBias.mFactor == 0 && mBias.mUnits == 0)
{
glDisable(GL_POLYGON_OFFSET_FILL);
}
else
{
glEnable(GL_POLYGON_OFFSET_FILL);
}
glPolygonOffset(mBias.mFactor, mBias.mUnits);
mBias.mChanged = false;
glDisable(GL_POLYGON_OFFSET_FILL);
}
else
{
glEnable(GL_POLYGON_OFFSET_FILL);
}
glPolygonOffset(mBias.mFactor, mBias.mUnits);
mBias.mChanged = false;
}
void FGLRenderState::ApplyBuffers()
@ -451,14 +450,13 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio
if (tex->isHardwareCanvas()) static_cast<FCanvasTexture*>(tex->GetTexture())->NeedUpdate();
clampmode = tex->GetClampMode(clampmode);
// avoid rebinding the same texture multiple times.
if (mat == lastMaterial && lastClamp == clampmode && translation == lastTranslation) return;
lastMaterial = mat;
lastClamp = clampmode;
lastTranslation = translation;
int usebright = false;
int maxbound = 0;
int numLayers = mat->NumLayers();

View file

@ -60,9 +60,9 @@ FSamplerManager::~FSamplerManager()
void FSamplerManager::UnbindAll()
{
}
uint8_t FSamplerManager::Bind(int texunit, int num, int lastval)
{
@ -157,14 +157,14 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval)
return 255;
}
void FSamplerManager::SetTextureFilterMode()
{
/*
GLRenderer->FlushTextures();
GLint bounds[IHardwareTexture::MAX_TEXTURES];
// Unbind all
for(int i = IHardwareTexture::MAX_TEXTURES-1; i >= 0; i--)
{

View file

@ -266,7 +266,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump_, const char *
// light buffers
uniform vec4 lights[MAXIMUM_LIGHT_VECTORS];
uniform mat4 ProjectionMatrix;
uniform mat4 ViewMatrix;
uniform mat4 NormalViewMatrix;
@ -370,7 +370,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump_, const char *
#define glowtexture texture4
#endif
)";
#ifdef NPOT_EMULATION
i_data += "#define NPOT_EMULATION\nuniform vec2 uNpotEmulation;\n";
#endif
@ -392,7 +392,6 @@ bool FShader::Load(const char * name, const char * vert_prog_lump_, const char *
assert(screen->mLights != NULL);
bool lightbuffertype = screen->mLights->GetBufferType();
unsigned int lightbuffersize = screen->mLights->GetBlockSize();
vp_comb.Format("#version 100\n#define NUM_UBO_LIGHTS %d\n#define NO_CLIPDISTANCE_SUPPORT\n", lightbuffersize);
@ -495,7 +494,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump_, const char *
}
shaderData->hShader = glCreateProgram();
uint32_t binaryFormat = 0;
TArray<uint8_t> binary;
if (IsShaderCacheActive())
@ -687,7 +686,7 @@ bool FShader::Bind(ShaderFlavourData& flavour)
variantConfig.AppendFormat("#define MAXIMUM_LIGHT_VECTORS %d\n", gles.numlightvectors);
variantConfig.AppendFormat("#define DEF_TEXTURE_MODE %d\n", flavour.textureMode);
variantConfig.AppendFormat("#define DEF_TEXTURE_FLAGS %d\n", flavour.texFlags);
variantConfig.AppendFormat("#define DEF_BLEND_FLAGS %d\n", flavour.blendFlags);
variantConfig.AppendFormat("#define DEF_BLEND_FLAGS %d\n", flavour.blendFlags & 0x7);
variantConfig.AppendFormat("#define DEF_FOG_2D %d\n", flavour.twoDFog);
variantConfig.AppendFormat("#define DEF_FOG_ENABLED %d\n", flavour.fogEnabled);
variantConfig.AppendFormat("#define DEF_FOG_RADIAL %d\n", flavour.fogEquationRadial);
@ -695,7 +694,7 @@ bool FShader::Bind(ShaderFlavourData& flavour)
variantConfig.AppendFormat("#define DEF_USE_U_LIGHT_LEVEL %d\n", flavour.useULightLevel);
variantConfig.AppendFormat("#define DEF_DO_DESATURATE %d\n", flavour.doDesaturate);
variantConfig.AppendFormat("#define DEF_DYNAMIC_LIGHTS_MOD %d\n", flavour.dynLightsMod);
variantConfig.AppendFormat("#define DEF_DYNAMIC_LIGHTS_SUB %d\n", flavour.dynLightsSub);
variantConfig.AppendFormat("#define DEF_DYNAMIC_LIGHTS_ADD %d\n", flavour.dynLightsAdd);
@ -703,7 +702,7 @@ bool FShader::Bind(ShaderFlavourData& flavour)
variantConfig.AppendFormat("#define DEF_USE_OBJECT_COLOR_2 %d\n", flavour.useObjectColor2);
variantConfig.AppendFormat("#define DEF_USE_GLOW_TOP_COLOR %d\n", flavour.useGlowTopColor);
variantConfig.AppendFormat("#define DEF_USE_GLOW_BOTTOM_COLOR %d\n", flavour.useGlowBottomColor);
variantConfig.AppendFormat("#define DEF_USE_COLOR_MAP %d\n", flavour.useColorMap);
variantConfig.AppendFormat("#define DEF_BUILD_LIGHTING %d\n", flavour.buildLighting);
variantConfig.AppendFormat("#define DEF_BANDED_SW_LIGHTING %d\n", flavour.bandedSwLight);
@ -715,6 +714,7 @@ bool FShader::Bind(ShaderFlavourData& flavour)
#endif
variantConfig.AppendFormat("#define DEF_HAS_SPOTLIGHT %d\n", flavour.hasSpotLight);
variantConfig.AppendFormat("#define DEF_PALETTE_INTERPOLATE %d\n", flavour.paletteInterpolate);
//Printf("Shader: %s, %08x %s", mFragProg2.GetChars(), tag, variantConfig.GetChars());
@ -851,7 +851,7 @@ void FShaderCollection::CompileShaders(EPassType passType)
mMaterialShaders.Push(shc);
if (i < SHADER_NoTexture)
{
FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, defaultshaders[i].lightfunc, defaultshaders[i].Defines, false, passType);
shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, defaultshaders[i].lightfunc, defaultshaders[i].Defines, false, passType);
mMaterialShadersNAT.Push(shc);
}
}

View file

@ -277,13 +277,14 @@ public:
#endif
bool hasSpotLight;
bool paletteInterpolate;
};
class FShader
{
friend class FShaderCollection;
friend class FGLRenderState;
FName mName;
FString mVertProg;
@ -378,7 +379,7 @@ public:
FShader(const char *name)
: mName(name)
{
}
~FShader();
@ -393,9 +394,9 @@ public:
{
uint32_t tag = 0;
tag |= (flavour.textureMode & 0x7);
tag |= (flavour.texFlags & 7) << 3;
tag |= (flavour.blendFlags & 7) << 6;
tag |= (flavour.twoDFog & 1) << 7;
@ -419,15 +420,15 @@ public:
#ifdef NPOT_EMULATION
tag |= (flavour.npotEmulation & 1) << 22;
#endif
tag |= (flavour.hasSpotLight & 1) << 23;
tag |= (flavour.paletteInterpolate & 1) << 24;
return tag;
}
bool Bind(ShaderFlavourData& flavour);
};
//==========================================================================
@ -461,7 +462,7 @@ class FShaderCollection
void Clean();
void CompileShaders(EPassType passType);
public:
FShaderCollection(EPassType passType);
~FShaderCollection();
@ -480,7 +481,10 @@ public:
{
return mMaterialShaders[eff];
}
return NULL;
else // This can happen if we try and active a user shader which is not loaded, so return default shader so it does not crash
{
return mMaterialShaders[0];
}
}
};

View file

@ -104,7 +104,7 @@ void FShaderProgram::CompileShader(ShaderType type)
const auto &handle = mShaders[type];
const FString &patchedCode = mShaderSources[type];
int lengths[1] = { (int)patchedCode.Len() };
const char *sources[1] = { patchedCode.GetChars() };
@ -290,4 +290,4 @@ void FPresentShader::Bind()
mShader->Bind();
}
}
}

View file

@ -63,7 +63,7 @@ static PROC(WINAPI* getprocaddress)(LPCSTR name);
static void* LoadGLES2Proc(const char* name)
{
HINSTANCE hGetProcIDDLL = LoadLibraryA("libGLESv2.dll");
int error = GetLastError();
void* addr = GetProcAddress(hGetProcIDDLL, name);
@ -169,14 +169,14 @@ namespace OpenGLESRenderer
gles.modelstring = (char*)glGetString(GL_RENDERER);
gles.vendorstring = (char*)glGetString(GL_VENDOR);
gl_customshader = false;
GLint maxTextureSize[1];
glGetIntegerv(GL_MAX_TEXTURE_SIZE, maxTextureSize);
gles.max_texturesize = maxTextureSize[0];
Printf("GL_MAX_TEXTURE_SIZE: %d\n", gles.max_texturesize);
#if USE_GLES2
@ -189,7 +189,7 @@ namespace OpenGLESRenderer
gles.useMappedBuffers = true;
gles.depthClampAvailable = true;
#endif
gles.numlightvectors = (gles.maxlights * LIGHT_VEC4_NUM);
}
}

View file

@ -24,8 +24,7 @@ enum
VATTR_VERTEX2,
VATTR_NORMAL,
VATTR_NORMAL2,
VATTR_LIGHTMAP,
VATTR_LIGHTMAP,
VATTR_MAX
};

View file

@ -150,7 +150,6 @@ std::pair<FFlatVertex *, unsigned int> FFlatVertexBuffer::AllocVertices(unsigned
{
FFlatVertex *p = GetBuffer();
auto index = mCurIndex.fetch_add(count);
auto offset = index;
if (index + count >= BUFFER_SIZE_TO_USE)
{
// If a single scene needs 2'000'000 vertices there must be something very wrong.

View file

@ -67,7 +67,7 @@ public:
IVertexBuffer *mVertexBufferPipeline[HW_MAX_PIPELINE_BUFFERS];
IIndexBuffer *mIndexBuffer;
unsigned int mIndex;
std::atomic<unsigned int> mCurIndex;

View file

@ -167,7 +167,7 @@ void CheckBench()
FString compose;
if (sysCallbacks.GetLocationDescription) compose = sysCallbacks.GetLocationDescription();
AppendRenderStats(compose);
AppendRenderTimes(compose);
AppendLightStats(compose);

View file

@ -44,7 +44,7 @@
#include "printf.h"
CUSTOM_CVAR(Int, gl_fogmode, 1, CVAR_ARCHIVE | CVAR_NOINITCALL)
CUSTOM_CVAR(Int, gl_fogmode, 2, CVAR_ARCHIVE | CVAR_NOINITCALL)
{
if (self > 2) self = 2;
if (self < 0) self = 0;

View file

@ -6,7 +6,7 @@
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
@ -23,6 +23,8 @@
#ifndef __GLC_DYNLIGHT_H
#define __GLC_DYNLIGHT_H
#include "tarray.h"
struct FDynLightData
{
TArray<float> arrays[3];
@ -49,7 +51,7 @@ struct FDynLightData
if (siz[1] > max) siz[1] = max;
if (siz[2] > max) siz[2] = max;
}
};

View file

@ -6,7 +6,7 @@
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
@ -37,10 +37,10 @@ FLightBuffer::FLightBuffer(int pipelineNbr):
mPipelineNbr(pipelineNbr)
{
int maxNumberOfLights = 80000;
mBufferSize = maxNumberOfLights * ELEMENTS_PER_LIGHT;
mByteSize = mBufferSize * ELEMENT_SIZE;
// Hack alert: On Intel's GL driver SSBO's perform quite worse than UBOs.
// We only want to disable using SSBOs for lights but not disable the feature entirely.
// Note that using an uniform buffer here will limit the number of lights per surface so it isn't done for NVidia and AMD.
@ -57,7 +57,7 @@ FLightBuffer::FLightBuffer(int pipelineNbr):
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. REMOVED this...This can try to allocate 100's of MB..
}
@ -96,7 +96,7 @@ int FLightBuffer::UploadLights(FDynLightData &data)
if (totalsize > (int)mMaxUploadSize)
{
int diff = totalsize - (int)mMaxUploadSize;
size2 -= diff;
if (size2 < 0)
{
@ -115,14 +115,14 @@ int FLightBuffer::UploadLights(FDynLightData &data)
assert(mBufferPointer != nullptr);
if (mBufferPointer == nullptr) return -1;
if (totalsize <= 1) return -1; // there are no lights
unsigned thisindex = mIndex.fetch_add(totalsize);
float parmcnt[] = { 0, float(size0), float(size0 + size1), float(size0 + size1 + size2) };
if (thisindex + totalsize <= mBufferSize)
{
float *copyptr = mBufferPointer + thisindex*4;
memcpy(&copyptr[0], parmcnt, ELEMENT_SIZE);
memcpy(&copyptr[4], &data.arrays[0][0], size0 * ELEMENT_SIZE);
memcpy(&copyptr[4 + 4*size0], &data.arrays[1][0], size1 * ELEMENT_SIZE);

View file

@ -23,7 +23,7 @@ class FLightBuffer
unsigned int mBufferSize;
unsigned int mByteSize;
unsigned int mMaxUploadSize;
void CheckSize();
public:

View file

@ -6,7 +6,7 @@
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,

View file

@ -152,7 +152,7 @@ FString RemoveSamplerBindings(FString code, TArray<std::pair<FString, int>> &sam
char *chars = code.LockBuffer();
ptrdiff_t startIndex = 0;
ptrdiff_t startpos, endpos;
ptrdiff_t startpos, endpos = 0;
while (true)
{
ptrdiff_t matchIndex = code.IndexOf("layout(binding", startIndex);
@ -188,10 +188,10 @@ FString RemoveSamplerBindings(FString code, TArray<std::pair<FString, int>> &sam
if (isSamplerUniformName)
{
samplerstobind.Push(std::make_pair(identifier, val));
for (auto pos = startpos; pos < endpos; pos++)
for (auto posi = startpos; posi < endpos; posi++)
{
if (!IsGlslWhitespace(chars[pos]))
chars[pos] = ' ';
if (!IsGlslWhitespace(chars[posi]))
chars[posi] = ' ';
}
}
}
@ -216,7 +216,6 @@ FString RemoveSamplerBindings(FString code, TArray<std::pair<FString, int>> &sam
FString RemoveLayoutLocationDecl(FString code, const char *inoutkeyword)
{
ptrdiff_t len = code.Len();
char *chars = code.LockBuffer();
ptrdiff_t startIndex = 0;
@ -255,8 +254,8 @@ FString RemoveLayoutLocationDecl(FString code, const char *inoutkeyword)
if (keywordFound && IsGlslWhitespace(chars[endIndex + i]))
{
// yes - replace declaration with spaces
for (auto i = matchIndex; i < endIndex; i++)
chars[i] = ' ';
for (auto ii = matchIndex; ii < endIndex; ii++)
chars[ii] = ' ';
}
startIndex = endIndex;

View file

@ -38,13 +38,13 @@
but then only in 2D where this reduces itself to a square. When main.fp samples from the shadow map
it first decides in which direction the fragment is (relative to the light), like cubemap sampling does
for 3D, but once again just for the 2D case.
Texels 0-255 is Y positive, 256-511 is X positive, 512-767 is Y negative and 768-1023 is X negative.
Generating the shadow map itself is done by FShadowMap::Update(). The shadow map texture's FBO is
bound and then a screen quad is drawn to make a fragment shader cover all texels. For each fragment
it shoots a ray and collects the distance to what it hit.
The shadowmap.fp shader knows which light and texel it is processing by mapping gl_FragCoord.y back
to the light index, and it knows which direction to ray trace by looking at gl_FragCoord.x. For
example, if gl_FragCoord.y is 20.5, then it knows its processing light 20, and if gl_FragCoord.x is

View file

@ -4,6 +4,7 @@
#include "hw_aabbtree.h"
#include "stats.h"
#include <memory>
#include <functional>
class IDataBuffer;

View file

@ -6,7 +6,7 @@
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
@ -98,7 +98,7 @@ 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();
for (int n = 0; n < mPipelineNbr; n++)
{
mBufferPipeline[n]->Map();

View file

@ -18,7 +18,7 @@ class HWViewpointBuffer
unsigned int mLastMappedIndex;
unsigned int mByteSize;
TArray<bool> mClipPlaneInfo;
int m2DWidth = -1, m2DHeight = -1;
unsigned int mBlockSize;

View file

@ -1,27 +1,36 @@
//
//---------------------------------------------------------------------------
//
// Copyright(C) 2015 Christopher Bruns
// All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see http://www.gnu.org/licenses/
//
//--------------------------------------------------------------------------
//
/*
** gl_stereo_leftright.cpp
** Offsets for left and right eye views
** hw_vrmodes.cpp
** Matrix handling for stereo 3D rendering
**
**---------------------------------------------------------------------------
** Copyright 2015 Christopher Bruns
** Copyright 2016-2021 Christoph Oelckers
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
**
*/
@ -154,9 +163,9 @@ VSMatrix VREyeInfo::GetProjection(float fov, float aspectRatio, float fovRatio)
double bottom = -fH;
double top = fH;
VSMatrix result(1);
result.frustum((float)left, (float)right, (float)bottom, (float)top, (float)zNear, (float)zFar);
return result;
VSMatrix fmat(1);
fmat.frustum((float)left, (float)right, (float)bottom, (float)top, (float)zNear, (float)zFar);
return fmat;
}
}

View file

@ -89,7 +89,6 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state)
for(auto &cmd : commands)
{
int gltrans = -1;
state.SetRenderStyle(cmd.mRenderStyle);
state.EnableBrightmap(!(cmd.mRenderStyle.Flags & STYLEF_ColorIsFixed));
state.EnableFog(2); // Special 2D mode 'fog'.

View file

@ -679,7 +679,7 @@ int PolyTriangleThreadData::ClipEdge(const ShadedTriVertex *const* verts)
// -v.w <= v.x <= v.w
// -v.w <= v.y <= v.w
// -v.w <= v.z <= v.w
// halfspace clip distances
static const int numclipdistances = 9;
#ifdef NO_SSE
@ -799,7 +799,7 @@ int PolyTriangleThreadData::ClipEdge(const ShadedTriVertex *const* verts)
for (int k = 0; k < 3; k++)
output[outputverts * 3 + k] = input[i * 3 + k] * (1.0f - t1) + input[j * 3 + k] * t1;
outputverts++;
if (t2 != 1.0f && t2 > t1)
{
// add t2 vertex

View file

@ -456,7 +456,7 @@ static void GetLightColor(int x0, int x1, PolyTriangleThreadData* thread)
uint32_t fogG = (int)((thread->mainVertexShader.Data.uFogColor.g) * 255.0f);
uint32_t fogB = (int)((thread->mainVertexShader.Data.uFogColor.b) * 255.0f);
float uFogDensity = thread->PushConstants->uFogDensity;
float* w = thread->scanline.W;
for (int x = x0; x < x1; x++)
{

View file

@ -60,7 +60,7 @@ void DrawerThreads::Execute(DrawerCommandQueuePtr commands)
{
if (!commands || commands->commands.empty())
return;
auto queue = Instance();
queue->StartThreads();

View file

@ -156,17 +156,17 @@ public:
static void WaitForWorkers();
static void ResetDebugDrawPos();
private:
DrawerThreads();
~DrawerThreads();
void StartThreads();
void StopThreads();
void WorkerMain(DrawerThread *thread);
static DrawerThreads *Instance();
std::mutex threads_mutex;
std::vector<DrawerThread> threads;
@ -182,7 +182,7 @@ private:
size_t debug_draw_end = 0;
DrawerThread single_core_thread;
friend class DrawerCommandQueue;
};
@ -192,9 +192,9 @@ class DrawerCommandQueue
{
public:
DrawerCommandQueue(RenderMemory *memoryAllocator);
void Clear() { commands.clear(); }
// Queue command to be executed by drawer worker threads
template<typename T, typename... Types>
void Push(Types &&... args)
@ -212,13 +212,13 @@ public:
command.Execute(&threads->single_core_thread);
}
}
private:
// Allocate memory valid for the duration of a command execution
void *AllocMemory(size_t size);
std::vector<DrawerCommand *> commands;
RenderMemory *FrameMemory;
friend class DrawerThreads;
};

View file

@ -105,7 +105,6 @@ namespace
// minimum set in GZDoom 4.0.0, but only while those fonts are required.
static bool lastspecialUI = false;
bool isInActualMenu = false;
bool specialUI = (!sysCallbacks.IsSpecialUI || sysCallbacks.IsSpecialUI());
@ -126,7 +125,7 @@ namespace
min_height = VID_MIN_UI_HEIGHT;
}
}
// the odd formatting of this struct definition is meant to resemble a table header. set your tab stops to 4 when editing this file.
struct v_ScaleTable
{ bool isValid; uint32_t(*GetScaledWidth)(uint32_t Width, uint32_t Height); uint32_t(*GetScaledHeight)(uint32_t Width, uint32_t Height); float pixelAspect; bool isCustom; };
@ -179,7 +178,7 @@ bool ViewportLinearScale()
aspectmult = 1.f / aspectmult;
if ((ViewportScaledWidth(x,y) > (x * aspectmult)) || (ViewportScaledHeight(x,y) > (y * aspectmult)))
return true;
return vid_scale_linear;
}

View file

@ -121,7 +121,6 @@ CUSTOM_CVAR(Int, vid_preferbackend, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_N
Printf("Changing the video backend requires a restart for " GAMENAME ".\n");
}
CVAR(Int, vid_renderer, 1, 0) // for some stupid mods which threw caution out of the window...
CUSTOM_CVAR(Int, uiscale, 0, CVAR_ARCHIVE | CVAR_NOINITCALL)
{
@ -219,13 +218,13 @@ void DCanvas::Resize(int width, int height, bool optimizepitch)
{
Width = width;
Height = height;
// Making the pitch a power of 2 is very bad for performance
// Try to maximize the number of cache lines that can be filled
// for each column drawing operation by making the pitch slightly
// longer than the width. The values used here are all based on
// empirical evidence.
if (width <= 640 || !optimizepitch)
{
// For low resolutions, just keep the pitch the same as the width.
@ -337,15 +336,15 @@ void V_InitScreenSize ()
{
const char *i;
int width, height, bits;
width = height = bits = 0;
if ( (i = Args->CheckValue ("-width")) )
width = atoi (i);
if ( (i = Args->CheckValue ("-height")) )
height = atoi (i);
if (width == 0)
{
if (height == 0)
@ -374,8 +373,6 @@ void V_InitScreen()
void V_Init2()
{
float gamma = static_cast<DDummyFrameBuffer *>(screen)->Gamma;
{
DFrameBuffer *s = screen;
screen = NULL;

View file

@ -152,7 +152,7 @@ public:
int mPipelineNbr = 1; // Number of HW buffers to pipeline
int mPipelineType = 0;
public:
DFrameBuffer (int width=1, int height=1);
virtual ~DFrameBuffer();
@ -222,7 +222,7 @@ public:
virtual void BlurScene(float amount) {}
virtual void InitLightmap(FLevelLocals *Level) {}
// Interface to hardware rendering resources
virtual IVertexBuffer *CreateVertexBuffer() { return nullptr; }
virtual IIndexBuffer *CreateIndexBuffer() { return nullptr; }

View file

@ -256,12 +256,12 @@ void VkRenderBuffers::CreateShadowmap()
if (!ShadowmapSampler)
{
SamplerBuilder builder;
builder.setMipmapMode(VK_SAMPLER_MIPMAP_MODE_NEAREST);
builder.setMinFilter(VK_FILTER_NEAREST);
builder.setMagFilter(VK_FILTER_NEAREST);
builder.setAddressMode(VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE);
ShadowmapSampler = builder.create(fb->device);
SamplerBuilder samplerBuilder;
samplerBuilder.setMipmapMode(VK_SAMPLER_MIPMAP_MODE_NEAREST);
samplerBuilder.setMinFilter(VK_FILTER_NEAREST);
samplerBuilder.setMagFilter(VK_FILTER_NEAREST);
samplerBuilder.setAddressMode(VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE);
ShadowmapSampler = samplerBuilder.create(fb->device);
ShadowmapSampler->SetDebugName("VkRenderBuffers.ShadowmapSampler");
}
}

View file

@ -150,7 +150,7 @@ static const char *shaderBindings = R"(
int useVertexData;
vec4 uVertexColor;
vec4 uVertexNormal;
vec4 uGlowTopPlane;
vec4 uGlowTopColor;
vec4 uGlowBottomPlane;

View file

@ -325,20 +325,20 @@ void VulkanDevice::CreateInstance()
if (debugLayerFound)
{
VkDebugUtilsMessengerCreateInfoEXT createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
createInfo.messageSeverity =
VkDebugUtilsMessengerCreateInfoEXT dbgCreateInfo = {};
dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
dbgCreateInfo.messageSeverity =
//VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT |
//VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT |
VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT |
VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
createInfo.messageType =
dbgCreateInfo.messageType =
VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT |
VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT |
VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
createInfo.pfnUserCallback = DebugCallback;
createInfo.pUserData = this;
result = vkCreateDebugUtilsMessengerEXT(instance, &createInfo, nullptr, &debugMessenger);
dbgCreateInfo.pfnUserCallback = DebugCallback;
dbgCreateInfo.pUserData = this;
result = vkCreateDebugUtilsMessengerEXT(instance, &dbgCreateInfo, nullptr, &debugMessenger);
CheckVulkanError(result, "vkCreateDebugUtilsMessengerEXT failed");
DebugLayerActive = true;
@ -347,8 +347,6 @@ void VulkanDevice::CreateInstance()
VkBool32 VulkanDevice::DebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT* callbackData, void* userData)
{
VulkanDevice *device = (VulkanDevice*)userData;
static std::mutex mtx;
static std::set<FString> seenMessages;
static int totalMessages;

View file

@ -57,8 +57,6 @@
#include "engineerrors.h"
#include "c_dispatch.h"
void Draw2D(F2DDrawer *drawer, FRenderState &state);
EXTERN_CVAR(Bool, r_drawvoxels)
EXTERN_CVAR(Int, gl_tonemap)
EXTERN_CVAR(Int, screenblocks)
@ -392,8 +390,8 @@ void VulkanFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
int numLayers = mat->NumLayers();
for (int i = 1; i < numLayers; i++)
{
auto systex = static_cast<VkHardwareTexture*>(mat->GetLayer(i, 0, &layer));
systex->GetImage(layer->layerTexture, 0, layer->scaleFlags);
auto syslayer = static_cast<VkHardwareTexture*>(mat->GetLayer(i, 0, &layer));
syslayer->GetImage(layer->layerTexture, 0, layer->scaleFlags);
}
}
@ -421,7 +419,6 @@ IDataBuffer *VulkanFrameBuffer::CreateDataBuffer(int bindingpoint, bool ssbo, bo
{
auto buffer = new VKDataBuffer(bindingpoint, ssbo, needsresize);
auto fb = GetVulkanFrameBuffer();
switch (bindingpoint)
{
case LIGHTBUF_BINDINGPOINT: LightBufferSSO = buffer; break;

View file

@ -407,18 +407,18 @@ VulkanDescriptorSet* VkMaterial::GetDescriptorSet(const FMaterialState& state)
{
for (int i = 1; i < numLayers; i++)
{
auto systex = static_cast<VkHardwareTexture*>(GetLayer(i, 0, &layer));
auto systeximage = systex->GetImage(layer->layerTexture, 0, layer->scaleFlags);
update.addCombinedImageSampler(descriptor.get(), i, systeximage->View.get(), sampler, systeximage->Layout);
auto syslayer = static_cast<VkHardwareTexture*>(GetLayer(i, 0, &layer));
auto syslayerimage = syslayer->GetImage(layer->layerTexture, 0, layer->scaleFlags);
update.addCombinedImageSampler(descriptor.get(), i, syslayerimage->View.get(), sampler, syslayerimage->Layout);
}
}
else
{
for (int i = 1; i < 3; i++)
{
auto systex = static_cast<VkHardwareTexture*>(GetLayer(i, translation, &layer));
auto systeximage = systex->GetImage(layer->layerTexture, 0, layer->scaleFlags);
update.addCombinedImageSampler(descriptor.get(), i, systeximage->View.get(), sampler, systeximage->Layout);
auto syslayer = static_cast<VkHardwareTexture*>(GetLayer(i, translation, &layer));
auto syslayerimage = syslayer->GetImage(layer->layerTexture, 0, layer->scaleFlags);
update.addCombinedImageSampler(descriptor.get(), i, syslayerimage->View.get(), sampler, syslayerimage->Layout);
}
numLayers = 3;
}

View file

@ -82,7 +82,7 @@ void VkSamplerManager::SetTextureFilterMode()
void VkSamplerManager::Create()
{
int filter = sysCallbacks.DisableTextureFilter && sysCallbacks.DisableTextureFilter()? 0 : gl_texture_filter;
for (int i = CLAMP_NONE; i <= CLAMP_XY; i++)
{
SamplerBuilder builder;