Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build warnings in src/Layers #1425

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Layers/xrRender/AnimationKeyCalculate.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ IC void Dequantize(CKey& K, const CBlend& BD, const CMotion& M)
}
}

IC void MixInterlerp(CKey& Result, const CKey* R, const CBlend* const BA[MAX_BLENDED], int b_count)
IC void MixInterlerp(CKey& Result, const CKey* R, const CBlend* const BA[MAX_BLENDED], u16 b_count)
{
VERIFY(MAX_BLENDED >= b_count);
switch (b_count)
Expand Down Expand Up @@ -394,7 +394,7 @@ IC void MixAdd(CKey& Result, const CKey* R, const float* BA, int b_count)
MixinAdd(Result, R, BA, b_count);
}
IC void process_single_channel(
CKey& Result, const animation::channel_def& /*ch*/, const CKey* R, const CBlend* const BA[MAX_BLENDED], int b_count)
CKey& Result, const animation::channel_def& /*ch*/, const CKey* R, const CBlend* const BA[MAX_BLENDED], u16 b_count)
{
MixInterlerp(Result, R, BA, b_count);
VERIFY(_valid(Result.T));
Expand Down
8 changes: 4 additions & 4 deletions src/Layers/xrRender/Blender_Recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,16 +251,16 @@ void CBlender_Compile::PassSET_ablend_mode(BOOL bABlend, u32 abSRC, u32 abDST)
if (bABlend && D3DBLEND_ONE == abSRC && D3DBLEND_ZERO == abDST)
bABlend = FALSE;
RS.SetRS(D3DRS_ALPHABLENDENABLE, BC(bABlend));
RS.SetRS(D3DRS_SRCBLEND, bABlend ? abSRC : D3DBLEND_ONE);
RS.SetRS(D3DRS_DESTBLEND, bABlend ? abDST : D3DBLEND_ZERO);
RS.SetRS(D3DRS_SRCBLEND, bABlend ? abSRC : static_cast<decltype(abSRC)>(D3DBLEND_ONE));
RS.SetRS(D3DRS_DESTBLEND, bABlend ? abDST : static_cast<decltype(abDST)>(D3DBLEND_ZERO));

#if defined(USE_DX11) || defined(USE_OGL)
// Since in our engine D3DRS_SEPARATEALPHABLENDENABLE state is
// always set to false and in DirectX 10 blend functions for
// color and alpha are always independent, assign blend options for
// alpha in DX11 identical to color.
RS.SetRS(D3DRS_SRCBLENDALPHA, bABlend ? abSRC : D3DBLEND_ONE);
RS.SetRS(D3DRS_DESTBLENDALPHA, bABlend ? abDST : D3DBLEND_ZERO);
RS.SetRS(D3DRS_SRCBLENDALPHA, bABlend ? abSRC : static_cast<decltype(abSRC)>(D3DBLEND_ONE));
RS.SetRS(D3DRS_DESTBLENDALPHA, bABlend ? abDST : static_cast<decltype(abDST)>(D3DBLEND_ZERO));
#endif // !USE_DX9
}
void CBlender_Compile::PassSET_ablend_aref(BOOL bATest, u32 aRef)
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/Blender_Recorder_R2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ u32 CBlender_Compile::i_Sampler(LPCSTR _name) const
fix_texture_name(name);

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

Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRender/DetailManager_CACHE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ void CDetailManager::cache_Initialize()
CDetailManager::Slot* CDetailManager::cache_Query(int r_x, int r_z)
{
int gx = w2cg_X(r_x + cache_cx);
VERIFY(gx >= 0 && gx < dm_cache_line);
VERIFY(gx >= 0 && gx < static_cast<int>(dm_cache_line));
int gz = w2cg_Z(r_z + cache_cz);
VERIFY(gz >= 0 && gz < dm_cache_line);
VERIFY(gz >= 0 && gz < static_cast<int>(dm_cache_line));
return cache[gz][gx];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/R_Backend_DBG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void CBackend::dbg_Draw(D3DPRIMITIVETYPE T, FVF::L* pVerts, int vcnt, u16* pIdx,
u32 vBase;
{
FVF::L* pv = (FVF::L*)RImplementation.Vertex.Lock(vcnt, vs_L->vb_stride, vBase);
for (size_t i = 0; i < vcnt; i++)
for (int i = 0; i < vcnt; i++)
{
pv[i] = pVerts[i];
}
Expand Down
47 changes: 0 additions & 47 deletions src/Layers/xrRender/ShaderResourceTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,53 +116,6 @@ inline std::pair<char, GLuint> GLUseBinary(pcstr* buffer, size_t size, const GLe

return { 'p', program };
}

static GLuint GLLinkMonolithicProgram(pcstr name, GLuint ps, GLuint vs, GLuint gs)
{
const GLuint program = glCreateProgram();
R_ASSERT(program);
if (GLEW_VERSION_4_3)
CHK_GL(glObjectLabel(GL_PROGRAM, program, -1, name));
// XXX: support caching for monolithic programs
//if (HW.ShaderBinarySupported)
// CHK_GL(glProgramParameteri(program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, (GLint)GL_TRUE));

CHK_GL(glAttachShader(program, ps));
CHK_GL(glAttachShader(program, vs));
if (gs)
CHK_GL(glAttachShader(program, gs));
CHK_GL(glBindFragDataLocation(program, 0, "SV_Target"));
CHK_GL(glBindFragDataLocation(program, 0, "SV_Target0"));
CHK_GL(glBindFragDataLocation(program, 1, "SV_Target1"));
CHK_GL(glBindFragDataLocation(program, 2, "SV_Target2"));
CHK_GL(glLinkProgram(program));
CHK_GL(glDetachShader(program, ps));
CHK_GL(glDetachShader(program, vs));
if (gs)
CHK_GL(glDetachShader(program, gs));

GLint status{};
CHK_GL(glGetProgramiv(program, GL_LINK_STATUS, &status));
if (GLboolean(status) == GL_FALSE)
{
show_compile_errors(name, program, 0);
CHK_GL(glDeleteProgram(program));
return 0; // 0 means error
}
return program;
}

static GLuint GLGeneratePipeline(pcstr name, GLuint ps, GLuint vs, GLuint gs)
{
GLuint pp;
CHK_GL(glGenProgramPipelines(1, &pp));
R_ASSERT(pp);
CHK_GL(glUseProgramStages(pp, GL_FRAGMENT_SHADER_BIT, ps));
CHK_GL(glUseProgramStages(pp, GL_VERTEX_SHADER_BIT, vs));
CHK_GL(glUseProgramStages(pp, GL_GEOMETRY_SHADER_BIT, gs));
CHK_GL(glValidateProgramPipeline(pp));
return pp;
}
#endif

template <typename T>
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRender/light.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ light::light() : SpatialBase(g_SpatialSpace)
vis.query_order = 0;
vis.visible = true;
vis.pending = false;
for (int id = 0; id < R__NUM_CONTEXTS; ++id)
for (auto id = 0u; id < R__NUM_CONTEXTS; ++id)
svis[id].id = id;
#endif // (RENDER==R_R2) || (RENDER==R_R3) || (RENDER==R_R4) || (RENDER==R_GL)
}
Expand Down Expand Up @@ -212,7 +212,7 @@ void light::spatial_move()
#if (RENDER == R_R2) || (RENDER == R_R3) || (RENDER == R_R4) || (RENDER == R_GL)
if (flags.bActive)
gi_generate();
for (int id = 0; id < R__NUM_CONTEXTS; ++id)
for (auto id = 0u; id < R__NUM_CONTEXTS; ++id)
svis[id].invalidate();
#endif // (RENDER==R_R2) || (RENDER==R_R3) || (RENDER==R_R4) || (RENDER == R_GL)
}
Expand Down
1 change: 0 additions & 1 deletion src/Layers/xrRender/occRasterizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ void occRasterizer::on_dbg_render()
{
Fvector quad, left_top, right_bottom, box_center, box_r;
quad.set((float)j - occ_dim_0 / 2.f, -((float)i - occ_dim_0 / 2.f), (float)bufDepth_0[i][j] / occQ_s32);
Device.mProject;

float z = -Device.mProject._43 / (float)(Device.mProject._33 - quad.z);
left_top.set(quad.x * z / Device.mProject._11 / (occ_dim_0 / 2.f),
Expand Down
19 changes: 7 additions & 12 deletions src/Layers/xrRender/r__dsgraph_build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@ ICF float CalcSSA(float& distSQ, Fvector& C, float R)

void R_dsgraph_structure::insert_dynamic(IRenderable* root, dxRender_Visual* pVisual, Fmatrix& xform, Fvector& Center)
{
CRender& RI = RImplementation;
Xottab-DUTY marked this conversation as resolved.
Show resolved Hide resolved

if (pVisual->vis.marker[context_id] == marker)
return;
pVisual->vis.marker[context_id] = marker;

#if RENDER == R_R1
if (RI.o.vis_intersect && (pVisual->vis.accept_frame != Device.dwFrame))
if (RImplementation.o.vis_intersect && (pVisual->vis.accept_frame != Device.dwFrame))
return;
pVisual->vis.accept_frame = Device.dwFrame;
#endif
Expand Down Expand Up @@ -94,7 +92,7 @@ void R_dsgraph_structure::insert_dynamic(IRenderable* root, dxRender_Visual* pVi

// Shadows registering
#if RENDER == R_R1
RI.L_Shadows->add_element(_MatrixItem{ SSA, root, pVisual, xform });
RImplementation.L_Shadows->add_element(_MatrixItem{ SSA, root, pVisual, xform });
#endif
if (root && root->renderable_Invisible())
return;
Expand Down Expand Up @@ -152,14 +150,12 @@ void R_dsgraph_structure::insert_dynamic(IRenderable* root, dxRender_Visual* pVi

void R_dsgraph_structure::insert_static(dxRender_Visual* pVisual)
{
CRender& RI = RImplementation;

if (pVisual->vis.marker[context_id] == marker)
return;
pVisual->vis.marker[context_id] = marker;

#if RENDER == R_R1
if (RI.o.vis_intersect && (pVisual->vis.accept_frame != Device.dwFrame))
if (RImplementation.o.vis_intersect && (pVisual->vis.accept_frame != Device.dwFrame))
return;
pVisual->vis.accept_frame = Device.dwFrame;
#endif
Expand Down Expand Up @@ -663,13 +659,13 @@ void R_dsgraph_structure::load(const xr_vector<CSector::level_sector_data_t>& se
Sectors.resize(sectors_count);
Portals.resize(portals_count);

for (int idx = 0; idx < portals_count; ++idx)
for (auto idx = 0u; idx < portals_count; ++idx)
{
auto* portal = xr_new<CPortal>();
Portals[idx] = portal;
}

for (int idx = 0; idx < sectors_count; ++idx)
for (auto idx = 0u; idx < sectors_count; ++idx)
{
auto* sector = xr_new<CSector>();

Expand All @@ -678,7 +674,7 @@ void R_dsgraph_structure::load(const xr_vector<CSector::level_sector_data_t>& se
Sectors[idx] = sector;
}

for (int idx = 0; idx < portals_count; ++idx)
for (auto idx = 0u; idx < portals_count; ++idx)
{
auto* portal = static_cast<CPortal*>(Portals[idx]);

Expand Down Expand Up @@ -740,11 +736,10 @@ void R_dsgraph_structure::build_subspace()
dxRender_Visual* root = sector->root();
//VERIFY(root->getType() == MT_HIERRARHY);

const auto &children = static_cast<FHierrarhyVisual*>(root)->children;

for (u32 v_it = 0; v_it < sector->r_frustums.size(); v_it++)
{
#if 0
const auto &children = static_cast<FHierrarhyVisual*>(root)->children;
const auto traverse_children = [&, this](const TaskRange<size_t>& range)
{
for (size_t id = range.cbegin(); id != range.cend(); ++id)
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/r__pixel_calculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ r_aabb_ssa r_pixel_calculator::calculate(dxRender_Visual* V)
#if defined(USE_DX9) || defined(USE_DX11)
using namespace DirectX;

r_aabb_ssa result = {0};
r_aabb_ssa result = {};
float area = float(_sqr(rt_dimensions));

auto& dsgraph = RImplementation.get_imm_context();
Expand Down
6 changes: 3 additions & 3 deletions src/Layers/xrRender/r__sector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void CPortal::setup(const level_portal_data_t& data, const xr_vector<CSector*>&
// calc sphere
Fbox BB;
BB.invalidate();
for (int v = 0; v < vcnt; v++)
for (auto v = 0u; v < vcnt; v++)
BB.modify(V[v]);
BB.getsphere(S.P, S.R);

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

FPU::m64r();
u32 _cnt = 0;
for (int i = 2; i < vcnt; i++)
for (auto i = 2u; i < vcnt; i++)
{
T.mknormal_non_normalized(poly[0], poly[i - 1], poly[i]);
float m = T.magnitude();
Expand All @@ -138,7 +138,7 @@ void CSector::setup(const level_sector_data_t& data, const xr_vector<CPortal*> &
// Assign portal polygons
const auto num_portals = data.portals_id.size();
m_portals.resize(num_portals);
for (int idx = 0; idx < num_portals; ++idx)
for (auto idx = 0u; idx < num_portals; ++idx)
{
const auto ID = data.portals_id[idx];
m_portals[idx] = portals[ID];
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderGL/glBufferUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void IterVertexDeclaration(const VertexElement* dxdecl, F&& callback)
if (desc.Stream == 0xFF)
break;

GLuint location = VertexUsageList[desc.Usage];
GLint location = VertexUsageList[desc.Usage];
GLint size = VertexSizeList[desc.Type];
GLenum type = VertexTypeList[desc.Type];
GLboolean normalized = VertexNormalizedList[desc.Type];
Expand Down
47 changes: 47 additions & 0 deletions src/Layers/xrRenderGL/glResourceManager_Resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,53 @@ SPP* CResourceManager::_CreatePP(pcstr vs, pcstr ps, pcstr gs, pcstr hs, pcstr d
return pp;
}

static GLuint GLGeneratePipeline(pcstr name, GLuint ps, GLuint vs, GLuint gs)
{
GLuint pp;
CHK_GL(glGenProgramPipelines(1, &pp));
R_ASSERT(pp);
CHK_GL(glUseProgramStages(pp, GL_FRAGMENT_SHADER_BIT, ps));
CHK_GL(glUseProgramStages(pp, GL_VERTEX_SHADER_BIT, vs));
CHK_GL(glUseProgramStages(pp, GL_GEOMETRY_SHADER_BIT, gs));
CHK_GL(glValidateProgramPipeline(pp));
return pp;
}

static GLuint GLLinkMonolithicProgram(pcstr name, GLuint ps, GLuint vs, GLuint gs)
{
const GLuint program = glCreateProgram();
R_ASSERT(program);
if (GLEW_VERSION_4_3)
CHK_GL(glObjectLabel(GL_PROGRAM, program, -1, name));
// XXX: support caching for monolithic programs
//if (HW.ShaderBinarySupported)
// CHK_GL(glProgramParameteri(program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, (GLint)GL_TRUE));

CHK_GL(glAttachShader(program, ps));
CHK_GL(glAttachShader(program, vs));
if (gs)
CHK_GL(glAttachShader(program, gs));
CHK_GL(glBindFragDataLocation(program, 0, "SV_Target"));
CHK_GL(glBindFragDataLocation(program, 0, "SV_Target0"));
CHK_GL(glBindFragDataLocation(program, 1, "SV_Target1"));
CHK_GL(glBindFragDataLocation(program, 2, "SV_Target2"));
CHK_GL(glLinkProgram(program));
CHK_GL(glDetachShader(program, ps));
CHK_GL(glDetachShader(program, vs));
if (gs)
CHK_GL(glDetachShader(program, gs));

GLint status{};
CHK_GL(glGetProgramiv(program, GL_LINK_STATUS, &status));
if (GLboolean(status) == GL_FALSE)
{
show_compile_errors(name, program, 0);
CHK_GL(glDeleteProgram(program));
return 0; // 0 means error
}
return program;
}

bool CResourceManager::_LinkPP(SPass& pass)
{
auto& pp = *pass.pp;
Expand Down
1 change: 0 additions & 1 deletion src/Layers/xrRenderGL/glTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ GLuint CRender::texture_load(LPCSTR fRName, u32& ret_msize, GLenum& ret_desc)
string_path fn;
size_t img_size = 0;
int img_loaded_lod = 0;
gli::gl::format fmt;
u32 mip_cnt = u32(-1);
// validation
R_ASSERT(fRName);
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderGL/glTextureUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ TextureFormatPairs TextureFormatList[] =
GLenum ConvertTextureFormat(D3DFORMAT dx9FMT)
{
constexpr size_t arrayLength = sizeof(TextureFormatList) / sizeof(TextureFormatList[0]);
for (int i = 0; i < arrayLength; ++i)
for (auto i = 0u; i < arrayLength; ++i)
{
if (TextureFormatList[i].m_dx9FMT == dx9FMT)
return TextureFormatList[i].m_glFMT;
Expand Down
4 changes: 4 additions & 0 deletions src/Layers/xrRenderPC_GL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,10 @@ target_include_directories(${PROJECT_NAME}
${CMAKE_SOURCE_DIR}/src/Layers/xrRender
${CMAKE_SOURCE_DIR}/src/Include/xrRender
${CMAKE_SOURCE_DIR}/src/Layers/xrRender_R2
)

target_include_directories(${PROJECT_NAME}
SYSTEM PRIVATE
${CMAKE_SOURCE_DIR}/sdk/include/DirectXMesh
${CMAKE_SOURCE_DIR}/Externals/luabind
${CMAKE_SOURCE_DIR}/Externals/gli
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_GL/rgl_shaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class shader_sources_manager
// TODO: OGL: make ignore commented includes
void load_includes(IReader* file)
{
cpcstr sourceData = static_cast<cpcstr>(file->pointer());
const auto sourceData = const_cast<pcstr>(static_cast<pstr>(file->pointer()));
const size_t dataLength = file->length();

// Copy source file data into a null-terminated buffer
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender_R2/r2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static bool must_enable_old_cascades()
R_ASSERT3(accumSunNear, "Can't open shader", "accum_sun_near.ps");
do
{
xr_string str(static_cast<cpcstr>(accumSunNear->pointer()), accumSunNear->length());
xr_string str(static_cast<pstr>(accumSunNear->pointer()), accumSunNear->length());

pcstr begin = strstr(str.c_str(), "float4");
if (!begin)
Expand Down
6 changes: 4 additions & 2 deletions src/Layers/xrRender_R2/r2_R_sun_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ using namespace DirectX;
#include "glm/gtc/matrix_transform.hpp"
#include "glm/gtc/matrix_access.hpp"

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

static void XRMatrixOrthoOffCenterLH(Fmatrix* pout, float l, float r, float b, float t, float zn, float zf)
[[maybe_unused]]
inline void XRMatrixOrthoOffCenterLH(Fmatrix* pout, float l, float r, float b, float t, float zn, float zf)
{
pout->identity();
pout->m[0][0] = 2.0f / (r - l);
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender_R2/r2_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ void CRender::LoadSectors(IReader* fs)
rmPortals = nullptr;
}

for (int id = 0; id < R__NUM_PARALLEL_CONTEXTS; ++id)
for (auto id = 0u; id < R__NUM_PARALLEL_CONTEXTS; ++id)
{
auto& dsgraph = contexts_pool[id];
dsgraph.reset();
Expand Down
Loading