- Backend update from Raze.

Mostly warning fixes reported by Clang, plus GLES update.
This commit is contained in:
Christoph Oelckers 2021-10-30 09:29:21 +02:00
parent 8e59ed754e
commit cc617d9085
9 changed files with 46 additions and 15 deletions

View file

@ -266,7 +266,7 @@ bool FZipFile::Open(bool quiet, LumpFilterInfo* filter)
// at least one of the more common definition lumps must be present.
for (auto &p : filter->requiredPrefixes)
{
if (name.IndexOf(name0 + p) == 0 || name.LastIndexOf(p) == name.Len() - strlen(p))
if (name.IndexOf(name0 + p) == 0 || name.LastIndexOf(p) == ptrdiff_t(name.Len() - strlen(p)))
{
foundspeciallump = true;
break;

View file

@ -686,7 +686,7 @@ int FFont::GetColorTranslation (EColorRange range, PalEntry *color) const
{
// Single pic fonts do not set up their translation table and must always return 0.
if (Translations.Size() == 0) return 0;
assert(Translations.Size() == NumTextColors);
assert(Translations.Size() == (unsigned)NumTextColors);
if (noTranslate)
{

View file

@ -210,8 +210,8 @@ void FVoxelModel::AddFace(int x1, int y1, int z1, int x2, int y2, int z2, int x3
unsigned int indx[4];
vert.packedNormal = 0; // currently this is not being used for voxels.
vert.u = (((col & 15) * 255 / 16) + 7) / 255.f;
vert.v = (((col / 16) * 255 / 16) + 7) / 255.f;
vert.u = (((col & 15) + 0.5f) / 16.f);
vert.v = (((col / 16) + 0.5f) / 16.f);
vert.x = x1 - PivotX;
vert.z = -y1 + PivotY;

View file

@ -159,7 +159,7 @@ void FGLRenderer::DrawPresentTexture(const IntRect &box, bool applyGamma)
mPresentShader->Uniforms.SetData();
for (int n = 0; n < mPresentShader->Uniforms.mFields.size(); n++)
for (size_t n = 0; n < mPresentShader->Uniforms.mFields.size(); n++)
{
int index = -1;
UniformFieldDesc desc = mPresentShader->Uniforms.mFields[n];
@ -175,6 +175,8 @@ void FGLRenderer::DrawPresentTexture(const IntRect &box, bool applyGamma)
case UniformType::Vec2:
glUniform2fv(loc,1 , ((GLfloat*)(((char*)(&mPresentShader->Uniforms)) + desc.Offset)));
break;
default:
break;
}
}

View file

@ -35,6 +35,9 @@
#include "gles_renderbuffers.h"
#include "gles_hwtexture.h"
#include "gles_buffers.h"
#include "gles_renderer.h"
#include "gles_samplers.h"
#include "hw_clock.h"
#include "printf.h"
@ -116,13 +119,13 @@ bool FGLRenderState::ApplyShader()
addLights = (int(lightPtr[3]) - int(lightPtr[2])) / LIGHT_VEC4_NUM;
// Here we limit the number of lights, but dont' change the light data so priority has to be mod, sub then add
if (modLights > gles.maxlights)
if (modLights > (int)gles.maxlights)
modLights = gles.maxlights;
if (modLights + subLights > gles.maxlights)
if (modLights + subLights > (int)gles.maxlights)
subLights = gles.maxlights - modLights;
if (modLights + subLights + addLights > gles.maxlights)
if (modLights + subLights + addLights > (int)gles.maxlights)
addLights = gles.maxlights - modLights - subLights;
totalLights = modLights + subLights + addLights;
@ -332,7 +335,7 @@ bool FGLRenderState::ApplyShader()
// Calculate the total number of vec4s we need
int totalVectors = totalLights * LIGHT_VEC4_NUM;
if (totalVectors > gles.numlightvectors)
if (totalVectors > (int)gles.numlightvectors)
totalVectors = gles.numlightvectors;
glUniform4fv(activeShader->cur->lights_index, totalVectors, lightPtr);
@ -479,6 +482,7 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio
for (int i = 1; i < 3; i++)
{
auto systex = static_cast<FHardwareTexture*>(mat->GetLayer(i, translation, &layer));
GLRenderer->mSamplerManager->Bind(i, CLAMP_NONE, 255);
systex->Bind(i, false);
maxbound = i;
}
@ -720,10 +724,13 @@ void FGLRenderState::ClearScreen()
bool FGLRenderState::SetDepthClamp(bool on)
{
bool res = mLastDepthClamp;
/*
if (!on) glDisable(GL_DEPTH_CLAMP);
else glEnable(GL_DEPTH_CLAMP);
*/
if (gles.depthClampAvailable)
{
if (!on) glDisable(GL_DEPTH_CLAMP);
else glEnable(GL_DEPTH_CLAMP);
}
mLastDepthClamp = on;
return res;
}

View file

@ -119,8 +119,26 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval)
break;
case CLAMP_NOFILTER:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
break;
case CLAMP_NOFILTER_X:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
break;
case CLAMP_NOFILTER_Y:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
break;
case CLAMP_NOFILTER_XY:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

View file

@ -272,7 +272,7 @@ void FPresentShaderBase::Init(const char * vtx_shader_name, const char * program
Uniforms.UniformLocation.resize(Uniforms.mFields.size());
for (int n = 0; n < Uniforms.mFields.size(); n++)
for (size_t n = 0; n < Uniforms.mFields.size(); n++)
{
int index = -1;
UniformFieldDesc desc = Uniforms.mFields[n];

View file

@ -62,7 +62,6 @@ static PROC(WINAPI* getprocaddress)(LPCSTR name);
static void* LoadGLES2Proc(const char* name)
{
HINSTANCE hGetProcIDDLL = LoadLibraryA("libGLESv2.dll");
int error = GetLastError();
@ -71,6 +70,7 @@ static void* LoadGLES2Proc(const char* name)
if (!addr)
{
//exit(1);
return nullptr;
}
else
{
@ -182,10 +182,12 @@ namespace OpenGLESRenderer
#if USE_GLES2
gles.depthStencilAvailable = CheckExtension("GL_OES_packed_depth_stencil");
gles.npotAvailable = CheckExtension("GL_OES_texture_npot");
gles.depthClampAvailable = CheckExtension("GL_EXT_depth_clamp");
#else
gles.depthStencilAvailable = true;
gles.npotAvailable = true;
gles.useMappedBuffers = true;
gles.depthClampAvailable = true;
#endif
gles.numlightvectors = (gles.maxlights * LIGHT_VEC4_NUM);

View file

@ -42,6 +42,7 @@ GLAPI PFNGLUNMAPBUFFEROESPROC glUnmapBuffer;
#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020
#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
#define GL_BGRA 0x80E1
#define GL_DEPTH_CLAMP 0x864F
#else
#include "gl_load/gl_load.h"
@ -69,6 +70,7 @@ namespace OpenGLESRenderer
bool depthStencilAvailable;
bool npotAvailable;
bool forceGLSLv100;
bool depthClampAvailable;
int max_texturesize;
char* vendorstring;
char* modelstring;