- Backend update from Raze.
This is mainly code cleanup from setting the compiler to a stricter warning level.
This commit is contained in:
parent
6aea7694bc
commit
1c517d19fa
102 changed files with 493 additions and 590 deletions
|
|
@ -326,7 +326,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));
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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: ";
|
||||
|
|
|
|||
|
|
@ -318,7 +318,6 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio
|
|||
lastClamp = clampmode;
|
||||
lastTranslation = translation;
|
||||
|
||||
int usebright = false;
|
||||
int maxbound = 0;
|
||||
|
||||
int numLayers = mat->NumLayers();
|
||||
|
|
|
|||
|
|
@ -620,7 +620,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 > 0) glUniform1i(tempindex, i - 1);
|
||||
}
|
||||
|
||||
|
|
@ -783,8 +783,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ void OpenGLFrameBuffer::InitializeState()
|
|||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
if (gles.depthClampAvailable) glEnable(GL_DEPTH_CLAMP);
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
|
|
@ -286,7 +287,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));
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -161,7 +161,6 @@ void FGLRenderer::DrawPresentTexture(const IntRect &box, bool applyGamma)
|
|||
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -302,9 +302,6 @@ namespace OpenGLESRenderer
|
|||
if (result == GL_FRAMEBUFFER_COMPLETE)
|
||||
return true;
|
||||
|
||||
bool FailedCreate = true;
|
||||
|
||||
|
||||
FString error = "glCheckFramebufferStatus failed: ";
|
||||
switch (result)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -110,7 +110,6 @@ FGLRenderer::~FGLRenderer()
|
|||
|
||||
bool FGLRenderer::StartOffscreen()
|
||||
{
|
||||
bool firstBind = (mFBID == 0);
|
||||
if (mFBID == 0)
|
||||
glGenFramebuffers(1, &mFBID);
|
||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &mOldFBID);
|
||||
|
|
|
|||
|
|
@ -389,19 +389,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()
|
||||
|
|
@ -458,7 +456,6 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio
|
|||
lastClamp = clampmode;
|
||||
lastTranslation = translation;
|
||||
|
||||
int usebright = false;
|
||||
int maxbound = 0;
|
||||
|
||||
int numLayers = mat->NumLayers();
|
||||
|
|
|
|||
|
|
@ -149,7 +149,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.
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
#ifndef __GLC_DYNLIGHT_H
|
||||
#define __GLC_DYNLIGHT_H
|
||||
|
||||
#include "tarray.h"
|
||||
|
||||
struct FDynLightData
|
||||
{
|
||||
TArray<float> arrays[3];
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "hw_aabbtree.h"
|
||||
#include "stats.h"
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
|
||||
class IDataBuffer;
|
||||
|
||||
|
|
|
|||
|
|
@ -154,9 +154,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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'.
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
||||
|
|
|
|||
|
|
@ -374,8 +374,6 @@ void V_InitScreen()
|
|||
|
||||
void V_Init2()
|
||||
{
|
||||
float gamma = static_cast<DDummyFrameBuffer *>(screen)->Gamma;
|
||||
|
||||
{
|
||||
DFrameBuffer *s = screen;
|
||||
screen = NULL;
|
||||
|
|
|
|||
|
|
@ -255,12 +255,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");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -392,8 +392,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 +421,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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue