Skip to content

Commit 6ffb11e

Browse files
committed
Fix build warnings in src/Layers
1 parent 83dce7d commit 6ffb11e

21 files changed

+86
-87
lines changed

src/Layers/xrRender/AnimationKeyCalculate.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ IC void Dequantize(CKey& K, const CBlend& BD, const CMotion& M)
178178
}
179179
}
180180

181-
IC void MixInterlerp(CKey& Result, const CKey* R, const CBlend* const BA[MAX_BLENDED], int b_count)
181+
IC void MixInterlerp(CKey& Result, const CKey* R, const CBlend* const BA[MAX_BLENDED], u16 b_count)
182182
{
183183
VERIFY(MAX_BLENDED >= b_count);
184184
switch (b_count)
@@ -394,7 +394,7 @@ IC void MixAdd(CKey& Result, const CKey* R, const float* BA, int b_count)
394394
MixinAdd(Result, R, BA, b_count);
395395
}
396396
IC void process_single_channel(
397-
CKey& Result, const animation::channel_def& /*ch*/, const CKey* R, const CBlend* const BA[MAX_BLENDED], int b_count)
397+
CKey& Result, const animation::channel_def& /*ch*/, const CKey* R, const CBlend* const BA[MAX_BLENDED], u16 b_count)
398398
{
399399
MixInterlerp(Result, R, BA, b_count);
400400
VERIFY(_valid(Result.T));

src/Layers/xrRender/Blender_Recorder.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,16 @@ void CBlender_Compile::PassSET_ablend_mode(BOOL bABlend, u32 abSRC, u32 abDST)
251251
if (bABlend && D3DBLEND_ONE == abSRC && D3DBLEND_ZERO == abDST)
252252
bABlend = FALSE;
253253
RS.SetRS(D3DRS_ALPHABLENDENABLE, BC(bABlend));
254-
RS.SetRS(D3DRS_SRCBLEND, bABlend ? abSRC : D3DBLEND_ONE);
255-
RS.SetRS(D3DRS_DESTBLEND, bABlend ? abDST : D3DBLEND_ZERO);
254+
RS.SetRS(D3DRS_SRCBLEND, bABlend ? abSRC : static_cast<decltype(abSRC)>(D3DBLEND_ONE));
255+
RS.SetRS(D3DRS_DESTBLEND, bABlend ? abDST : static_cast<decltype(abDST)>(D3DBLEND_ZERO));
256256

257257
#if defined(USE_DX11) || defined(USE_OGL)
258258
// Since in our engine D3DRS_SEPARATEALPHABLENDENABLE state is
259259
// always set to false and in DirectX 10 blend functions for
260260
// color and alpha are always independent, assign blend options for
261261
// alpha in DX11 identical to color.
262-
RS.SetRS(D3DRS_SRCBLENDALPHA, bABlend ? abSRC : D3DBLEND_ONE);
263-
RS.SetRS(D3DRS_DESTBLENDALPHA, bABlend ? abDST : D3DBLEND_ZERO);
262+
RS.SetRS(D3DRS_SRCBLENDALPHA, bABlend ? abSRC : static_cast<decltype(abSRC)>(D3DBLEND_ONE));
263+
RS.SetRS(D3DRS_DESTBLENDALPHA, bABlend ? abDST : static_cast<decltype(abDST)>(D3DBLEND_ZERO));
264264
#endif // !USE_DX9
265265
}
266266
void CBlender_Compile::PassSET_ablend_aref(BOOL bATest, u32 aRef)

src/Layers/xrRender/Blender_Recorder_R2.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ u32 CBlender_Compile::i_Sampler(LPCSTR _name) const
8888
fix_texture_name(name);
8989

9090
// Find index
91-
ref_constant C = ctable.get(name, ctable.dx9compatibility ? RC_sampler : u16(-1));
91+
ref_constant C = ctable.get(name, ctable.dx9compatibility ? static_cast<u16>(RC_sampler) : u16(-1));
9292
if (!C)
9393
return u32(-1);
9494

src/Layers/xrRender/DetailManager_CACHE.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ void CDetailManager::cache_Initialize()
3737
CDetailManager::Slot* CDetailManager::cache_Query(int r_x, int r_z)
3838
{
3939
int gx = w2cg_X(r_x + cache_cx);
40-
VERIFY(gx >= 0 && gx < dm_cache_line);
40+
VERIFY(gx >= 0 && gx < static_cast<int>(dm_cache_line));
4141
int gz = w2cg_Z(r_z + cache_cz);
42-
VERIFY(gz >= 0 && gz < dm_cache_line);
42+
VERIFY(gz >= 0 && gz < static_cast<int>(dm_cache_line));
4343
return cache[gz][gx];
4444
}
4545

src/Layers/xrRender/R_Backend_DBG.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void CBackend::dbg_Draw(D3DPRIMITIVETYPE T, FVF::L* pVerts, int vcnt, u16* pIdx,
4141
u32 vBase;
4242
{
4343
FVF::L* pv = (FVF::L*)RImplementation.Vertex.Lock(vcnt, vs_L->vb_stride, vBase);
44-
for (size_t i = 0; i < vcnt; i++)
44+
for (int i = 0; i < vcnt; i++)
4545
{
4646
pv[i] = pVerts[i];
4747
}

src/Layers/xrRender/ShaderResourceTraits.h

-47
Original file line numberDiff line numberDiff line change
@@ -113,53 +113,6 @@ inline std::pair<char, GLuint> GLUseBinary(pcstr* buffer, size_t size, const GLe
113113

114114
return { 'p', program };
115115
}
116-
117-
static GLuint GLLinkMonolithicProgram(pcstr name, GLuint ps, GLuint vs, GLuint gs)
118-
{
119-
const GLuint program = glCreateProgram();
120-
R_ASSERT(program);
121-
if (GLEW_VERSION_4_3)
122-
CHK_GL(glObjectLabel(GL_PROGRAM, program, -1, name));
123-
// XXX: support caching for monolithic programs
124-
//if (HW.ShaderBinarySupported)
125-
// CHK_GL(glProgramParameteri(program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, (GLint)GL_TRUE));
126-
127-
CHK_GL(glAttachShader(program, ps));
128-
CHK_GL(glAttachShader(program, vs));
129-
if (gs)
130-
CHK_GL(glAttachShader(program, gs));
131-
CHK_GL(glBindFragDataLocation(program, 0, "SV_Target"));
132-
CHK_GL(glBindFragDataLocation(program, 0, "SV_Target0"));
133-
CHK_GL(glBindFragDataLocation(program, 1, "SV_Target1"));
134-
CHK_GL(glBindFragDataLocation(program, 2, "SV_Target2"));
135-
CHK_GL(glLinkProgram(program));
136-
CHK_GL(glDetachShader(program, ps));
137-
CHK_GL(glDetachShader(program, vs));
138-
if (gs)
139-
CHK_GL(glDetachShader(program, gs));
140-
141-
GLint status{};
142-
CHK_GL(glGetProgramiv(program, GL_LINK_STATUS, &status));
143-
if (GLboolean(status) == GL_FALSE)
144-
{
145-
show_compile_errors(name, program, 0);
146-
CHK_GL(glDeleteProgram(program));
147-
return 0; // 0 means error
148-
}
149-
return program;
150-
}
151-
152-
static GLuint GLGeneratePipeline(pcstr name, GLuint ps, GLuint vs, GLuint gs)
153-
{
154-
GLuint pp;
155-
CHK_GL(glGenProgramPipelines(1, &pp));
156-
R_ASSERT(pp);
157-
CHK_GL(glUseProgramStages(pp, GL_FRAGMENT_SHADER_BIT, ps));
158-
CHK_GL(glUseProgramStages(pp, GL_VERTEX_SHADER_BIT, vs));
159-
CHK_GL(glUseProgramStages(pp, GL_GEOMETRY_SHADER_BIT, gs));
160-
CHK_GL(glValidateProgramPipeline(pp));
161-
return pp;
162-
}
163116
#endif
164117

165118
template <typename T>

src/Layers/xrRender/light.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ light::light() : SpatialBase(g_SpatialSpace)
3636
vis.query_order = 0;
3737
vis.visible = true;
3838
vis.pending = false;
39-
for (int id = 0; id < R__NUM_CONTEXTS; ++id)
39+
for (auto id = 0u; id < R__NUM_CONTEXTS; ++id)
4040
svis[id].id = id;
4141
#endif // (RENDER==R_R2) || (RENDER==R_R3) || (RENDER==R_R4) || (RENDER==R_GL)
4242
}
@@ -212,7 +212,7 @@ void light::spatial_move()
212212
#if (RENDER == R_R2) || (RENDER == R_R3) || (RENDER == R_R4) || (RENDER == R_GL)
213213
if (flags.bActive)
214214
gi_generate();
215-
for (int id = 0; id < R__NUM_CONTEXTS; ++id)
215+
for (auto id = 0u; id < R__NUM_CONTEXTS; ++id)
216216
svis[id].invalidate();
217217
#endif // (RENDER==R_R2) || (RENDER==R_R3) || (RENDER==R_R4) || (RENDER == R_GL)
218218
}

src/Layers/xrRender/occRasterizer.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ void occRasterizer::on_dbg_render()
139139
{
140140
Fvector quad, left_top, right_bottom, box_center, box_r;
141141
quad.set((float)j - occ_dim_0 / 2.f, -((float)i - occ_dim_0 / 2.f), (float)bufDepth_0[i][j] / occQ_s32);
142-
Device.mProject;
143142

144143
float z = -Device.mProject._43 / (float)(Device.mProject._33 - quad.z);
145144
left_top.set(quad.x * z / Device.mProject._11 / (occ_dim_0 / 2.f),

src/Layers/xrRender/r__dsgraph_build.cpp

+7-12
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,12 @@ ICF float CalcSSA(float& distSQ, Fvector& C, float R)
3737

3838
void R_dsgraph_structure::insert_dynamic(IRenderable* root, dxRender_Visual* pVisual, Fmatrix& xform, Fvector& Center)
3939
{
40-
CRender& RI = RImplementation;
41-
4240
if (pVisual->vis.marker[context_id] == marker)
4341
return;
4442
pVisual->vis.marker[context_id] = marker;
4543

4644
#if RENDER == R_R1
47-
if (RI.o.vis_intersect && (pVisual->vis.accept_frame != Device.dwFrame))
45+
if (RImplementation.o.vis_intersect && (pVisual->vis.accept_frame != Device.dwFrame))
4846
return;
4947
pVisual->vis.accept_frame = Device.dwFrame;
5048
#endif
@@ -90,7 +88,7 @@ void R_dsgraph_structure::insert_dynamic(IRenderable* root, dxRender_Visual* pVi
9088

9189
// Shadows registering
9290
#if RENDER == R_R1
93-
RI.L_Shadows->add_element(_MatrixItem{ SSA, root, pVisual, xform });
91+
RImplementation.L_Shadows->add_element(_MatrixItem{ SSA, root, pVisual, xform });
9492
#endif
9593
if (root && root->renderable_Invisible())
9694
return;
@@ -148,14 +146,12 @@ void R_dsgraph_structure::insert_dynamic(IRenderable* root, dxRender_Visual* pVi
148146

149147
void R_dsgraph_structure::insert_static(dxRender_Visual* pVisual)
150148
{
151-
CRender& RI = RImplementation;
152-
153149
if (pVisual->vis.marker[context_id] == marker)
154150
return;
155151
pVisual->vis.marker[context_id] = marker;
156152

157153
#if RENDER == R_R1
158-
if (RI.o.vis_intersect && (pVisual->vis.accept_frame != Device.dwFrame))
154+
if (RImplementation.o.vis_intersect && (pVisual->vis.accept_frame != Device.dwFrame))
159155
return;
160156
pVisual->vis.accept_frame = Device.dwFrame;
161157
#endif
@@ -655,13 +651,13 @@ void R_dsgraph_structure::load(const xr_vector<CSector::level_sector_data_t>& se
655651
Sectors.resize(sectors_count);
656652
Portals.resize(portals_count);
657653

658-
for (int idx = 0; idx < portals_count; ++idx)
654+
for (auto idx = 0u; idx < portals_count; ++idx)
659655
{
660656
auto* portal = xr_new<CPortal>();
661657
Portals[idx] = portal;
662658
}
663659

664-
for (int idx = 0; idx < sectors_count; ++idx)
660+
for (auto idx = 0u; idx < sectors_count; ++idx)
665661
{
666662
auto* sector = xr_new<CSector>();
667663

@@ -670,7 +666,7 @@ void R_dsgraph_structure::load(const xr_vector<CSector::level_sector_data_t>& se
670666
Sectors[idx] = sector;
671667
}
672668

673-
for (int idx = 0; idx < portals_count; ++idx)
669+
for (auto idx = 0u; idx < portals_count; ++idx)
674670
{
675671
auto* portal = static_cast<CPortal*>(Portals[idx]);
676672

@@ -732,11 +728,10 @@ void R_dsgraph_structure::build_subspace()
732728
dxRender_Visual* root = sector->root();
733729
//VERIFY(root->getType() == MT_HIERRARHY);
734730

735-
const auto &children = static_cast<FHierrarhyVisual*>(root)->children;
736-
737731
for (u32 v_it = 0; v_it < sector->r_frustums.size(); v_it++)
738732
{
739733
#if 0
734+
const auto &children = static_cast<FHierrarhyVisual*>(root)->children;
740735
const auto traverse_children = [&, this](const TaskRange<size_t>& range)
741736
{
742737
for (size_t id = range.cbegin(); id != range.cend(); ++id)

src/Layers/xrRender/r__pixel_calculator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ r_aabb_ssa r_pixel_calculator::calculate(dxRender_Visual* V)
4646
#if defined(USE_DX9) || defined(USE_DX11)
4747
using namespace DirectX;
4848

49-
r_aabb_ssa result = {0};
49+
r_aabb_ssa result = {};
5050
float area = float(_sqr(rt_dimensions));
5151

5252
auto& dsgraph = RImplementation.get_imm_context();

src/Layers/xrRender/r__sector.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void CPortal::setup(const level_portal_data_t& data, const xr_vector<CSector*>&
9797
// calc sphere
9898
Fbox BB;
9999
BB.invalidate();
100-
for (int v = 0; v < vcnt; v++)
100+
for (auto v = 0u; v < vcnt; v++)
101101
BB.modify(V[v]);
102102
BB.getsphere(S.P, S.R);
103103

@@ -112,7 +112,7 @@ void CPortal::setup(const level_portal_data_t& data, const xr_vector<CSector*>&
112112

113113
FPU::m64r();
114114
u32 _cnt = 0;
115-
for (int i = 2; i < vcnt; i++)
115+
for (auto i = 2u; i < vcnt; i++)
116116
{
117117
T.mknormal_non_normalized(poly[0], poly[i - 1], poly[i]);
118118
float m = T.magnitude();
@@ -138,7 +138,7 @@ void CSector::setup(const level_sector_data_t& data, const xr_vector<CPortal*> &
138138
// Assign portal polygons
139139
const auto num_portals = data.portals_id.size();
140140
m_portals.resize(num_portals);
141-
for (int idx = 0; idx < num_portals; ++idx)
141+
for (auto idx = 0u; idx < num_portals; ++idx)
142142
{
143143
const auto ID = data.portals_id[idx];
144144
m_portals[idx] = portals[ID];

src/Layers/xrRenderGL/glBufferUtils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ void IterVertexDeclaration(const VertexElement* dxdecl, F&& callback)
157157
if (desc.Stream == 0xFF)
158158
break;
159159

160-
GLuint location = VertexUsageList[desc.Usage];
160+
GLint location = VertexUsageList[desc.Usage];
161161
GLint size = VertexSizeList[desc.Type];
162162
GLenum type = VertexTypeList[desc.Type];
163163
GLboolean normalized = VertexNormalizedList[desc.Type];

src/Layers/xrRenderGL/glResourceManager_Resources.cpp

+47
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,53 @@ SPP* CResourceManager::_CreatePP(pcstr vs, pcstr ps, pcstr gs, pcstr hs, pcstr d
119119
return pp;
120120
}
121121

122+
static GLuint GLGeneratePipeline(pcstr name, GLuint ps, GLuint vs, GLuint gs)
123+
{
124+
GLuint pp;
125+
CHK_GL(glGenProgramPipelines(1, &pp));
126+
R_ASSERT(pp);
127+
CHK_GL(glUseProgramStages(pp, GL_FRAGMENT_SHADER_BIT, ps));
128+
CHK_GL(glUseProgramStages(pp, GL_VERTEX_SHADER_BIT, vs));
129+
CHK_GL(glUseProgramStages(pp, GL_GEOMETRY_SHADER_BIT, gs));
130+
CHK_GL(glValidateProgramPipeline(pp));
131+
return pp;
132+
}
133+
134+
static GLuint GLLinkMonolithicProgram(pcstr name, GLuint ps, GLuint vs, GLuint gs)
135+
{
136+
const GLuint program = glCreateProgram();
137+
R_ASSERT(program);
138+
if (GLEW_VERSION_4_3)
139+
CHK_GL(glObjectLabel(GL_PROGRAM, program, -1, name));
140+
// XXX: support caching for monolithic programs
141+
//if (HW.ShaderBinarySupported)
142+
// CHK_GL(glProgramParameteri(program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, (GLint)GL_TRUE));
143+
144+
CHK_GL(glAttachShader(program, ps));
145+
CHK_GL(glAttachShader(program, vs));
146+
if (gs)
147+
CHK_GL(glAttachShader(program, gs));
148+
CHK_GL(glBindFragDataLocation(program, 0, "SV_Target"));
149+
CHK_GL(glBindFragDataLocation(program, 0, "SV_Target0"));
150+
CHK_GL(glBindFragDataLocation(program, 1, "SV_Target1"));
151+
CHK_GL(glBindFragDataLocation(program, 2, "SV_Target2"));
152+
CHK_GL(glLinkProgram(program));
153+
CHK_GL(glDetachShader(program, ps));
154+
CHK_GL(glDetachShader(program, vs));
155+
if (gs)
156+
CHK_GL(glDetachShader(program, gs));
157+
158+
GLint status{};
159+
CHK_GL(glGetProgramiv(program, GL_LINK_STATUS, &status));
160+
if (GLboolean(status) == GL_FALSE)
161+
{
162+
show_compile_errors(name, program, 0);
163+
CHK_GL(glDeleteProgram(program));
164+
return 0; // 0 means error
165+
}
166+
return program;
167+
}
168+
122169
bool CResourceManager::_LinkPP(SPass& pass)
123170
{
124171
auto& pp = *pass.pp;

src/Layers/xrRenderGL/glTexture.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ GLuint CRender::texture_load(LPCSTR fRName, u32& ret_msize, GLenum& ret_desc)
6464
string_path fn;
6565
size_t img_size = 0;
6666
int img_loaded_lod = 0;
67-
gli::gl::format fmt;
6867
u32 mip_cnt = u32(-1);
6968
// validation
7069
R_ASSERT(fRName);

src/Layers/xrRenderGL/glTextureUtils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ TextureFormatPairs TextureFormatList[] =
100100
GLenum ConvertTextureFormat(D3DFORMAT dx9FMT)
101101
{
102102
constexpr size_t arrayLength = sizeof(TextureFormatList) / sizeof(TextureFormatList[0]);
103-
for (int i = 0; i < arrayLength; ++i)
103+
for (auto i = 0u; i < arrayLength; ++i)
104104
{
105105
if (TextureFormatList[i].m_dx9FMT == dx9FMT)
106106
return TextureFormatList[i].m_glFMT;

src/Layers/xrRenderPC_GL/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,10 @@ target_include_directories(${PROJECT_NAME}
395395
${CMAKE_SOURCE_DIR}/src/Layers/xrRender
396396
${CMAKE_SOURCE_DIR}/src/Include/xrRender
397397
${CMAKE_SOURCE_DIR}/src/Layers/xrRender_R2
398+
)
399+
400+
target_include_directories(${PROJECT_NAME}
401+
SYSTEM PRIVATE
398402
${CMAKE_SOURCE_DIR}/Externals/luabind
399403
${CMAKE_SOURCE_DIR}/Externals/gli
400404
${CMAKE_SOURCE_DIR}/Externals/gli/external

src/Layers/xrRenderPC_GL/rgl_shaders.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class shader_sources_manager
148148
// TODO: OGL: make ignore commented includes
149149
void load_includes(IReader* file)
150150
{
151-
cpcstr sourceData = static_cast<cpcstr>(file->pointer());
151+
const auto sourceData = const_cast<pcstr>(static_cast<pstr>(file->pointer()));
152152
const size_t dataLength = file->length();
153153

154154
// Copy source file data into a null-terminated buffer

src/Layers/xrRender_R2/r2.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static bool must_enable_old_cascades()
161161
R_ASSERT3(accumSunNear, "Can't open shader", "accum_sun_near.ps");
162162
do
163163
{
164-
xr_string str(static_cast<cpcstr>(accumSunNear->pointer()), accumSunNear->length());
164+
xr_string str(static_cast<pstr>(accumSunNear->pointer()), accumSunNear->length());
165165

166166
pcstr begin = strstr(str.c_str(), "float4");
167167
if (!begin)

src/Layers/xrRender_R2/r2_R_sun_support.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ using namespace DirectX;
2020
#include "glm/gtc/matrix_transform.hpp"
2121
#include "glm/gtc/matrix_access.hpp"
2222

23-
static void XRVec3TransformCoordArray(glm::vec3* out, const glm::vec3* in, const glm::mat4& matrix, unsigned int elements)
23+
[[maybe_unused]]
24+
inline void XRVec3TransformCoordArray(glm::vec3* out, const glm::vec3* in, const glm::mat4& matrix, unsigned int elements)
2425
{
2526
for (unsigned int i = 0; i < elements; ++i)
2627
out[i] = glm::vec3(glm::translate(matrix, in[i]) * glm::vec4(1.f,1.f,1.f,1.f));
2728
}
2829

29-
static void XRMatrixOrthoOffCenterLH(Fmatrix* pout, float l, float r, float b, float t, float zn, float zf)
30+
[[maybe_unused]]
31+
inline void XRMatrixOrthoOffCenterLH(Fmatrix* pout, float l, float r, float b, float t, float zn, float zf)
3032
{
3133
pout->identity();
3234
pout->m[0][0] = 2.0f / (r - l);

src/Layers/xrRender_R2/r2_loader.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ void CRender::LoadSectors(IReader* fs)
411411
rmPortals = nullptr;
412412
}
413413

414-
for (int id = 0; id < R__NUM_PARALLEL_CONTEXTS; ++id)
414+
for (auto id = 0u; id < R__NUM_PARALLEL_CONTEXTS; ++id)
415415
{
416416
auto& dsgraph = contexts_pool[id];
417417
dsgraph.reset();

0 commit comments

Comments
 (0)