1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-06-25 22:09:35 +00:00

Code cleanup: fix compilation warnings.

This commit is contained in:
Sergey Lipskiy 2017-11-15 14:42:04 +07:00
parent 5f088c70ce
commit 5a037474a2
19 changed files with 69 additions and 63 deletions

View File

@ -451,7 +451,7 @@ void Debugger::_drawTextureCache()
const f32 Z = 0.0f;
const f32 W = 1.0f;
if (m_clickY >= wnd.getHeight() * 5 / 8) {
if (m_clickY >= (long)(wnd.getHeight() * 5 / 8)) {
long y = m_clickY - wnd.getHeight() * 5 / 8;
m_selectedTexPos[m_tmu].row = y * m_cacheViewerRows/ areaHeight;
m_selectedTexPos[m_tmu].col = m_clickX * m_cacheViewerCols/ wnd.getWidth();
@ -1090,7 +1090,7 @@ void Debugger::_drawMouseCursor()
const u32 winWidth = wnd.getWidth();
const u32 winHeight = wnd.getHeight();
if (x < 0 || x > winWidth || y < 0 || y > winHeight)
if (x < 0 || x > (long)winWidth || y < 0 || y > (long)winHeight)
return;
const f32 scaleX = 1.0f / winWidth;
@ -1134,8 +1134,8 @@ void Debugger::_findSelected()
const long x = m_clickX;
const long y = m_clickY;
DisplayWindow & wnd = dwnd();
const u32 winWidth = wnd.getWidth();
const u32 winHeight = wnd.getHeight();
const long winWidth = (long)wnd.getWidth();
const long winHeight = (long)wnd.getHeight();
if (x < 0 || x > winWidth || y < 0 || y > winHeight)
return;

View File

@ -95,7 +95,7 @@ int ClipPolygon(vertexclip *** final, vertexclip * vbp, int numVertices)
} else if ((src2->visible & RIGHT) != VISIBLE)
continue;
float a = (RightClip - src1->x) / (src2->x - src1->x);
float ima = 1.0 - a;
float ima = 1.0f - a;
dst[dsti] = vbp++; // create new vertex
dst[dsti]->y = src1->y*ima + src2->y*a;
dst[dsti]->x = RightClip;
@ -120,7 +120,7 @@ int ClipPolygon(vertexclip *** final, vertexclip * vbp, int numVertices)
} else if((src2->visible & LEFT) != VISIBLE)
continue;
float a = (LeftClip - src1->x) / (src2->x - src1->x);
float ima = 1.0-a;
float ima = 1.0f - a;
dst[dsti] = vbp++; // create new vertex
dst[dsti]->y = src1->y*ima + src2->y*a;
dst[dsti]->x = LeftClip;
@ -145,7 +145,7 @@ int ClipPolygon(vertexclip *** final, vertexclip * vbp, int numVertices)
} else if((src2->visible & TOP) != VISIBLE)
continue;
float a = (TopClip - src1->y) / (src2->y - src1->y);
float ima = 1.0-a;
float ima = 1.0f - a;
dst[dsti] = vbp++; // create new vertex
dst[dsti]->x = src1->x*ima + src2->x*a;
dst[dsti]->y = TopClip;
@ -170,7 +170,7 @@ int ClipPolygon(vertexclip *** final, vertexclip * vbp, int numVertices)
} else if((src2->visible & BOT) != VISIBLE)
continue;
float a = (BotClip - src1->y) / (src2->y - src1->y);
float ima = 1.0-a;
float ima = 1.0f - a;
dst[dsti] = vbp++; // create new vertex
dst[dsti]->x = src1->x*ima + src2->x*a;
dst[dsti]->y = BotClip;

View File

@ -202,10 +202,10 @@ void Rasterize(vertexi * vtx, int vertices, int dzdx)
for (;;) {
int x1 = iceil(left_x);
if (x1 < (int)gDP.scissor.ulx)
x1 = gDP.scissor.ulx;
x1 = (int)gDP.scissor.ulx;
int width = iceil(right_x) - x1;
if (x1 + width >= (int)gDP.scissor.lrx)
width = gDP.scissor.lrx - x1 - 1;
width = (int)(gDP.scissor.lrx - x1 - 1);
if (width > 0 && y1 >= (int)gDP.scissor.uly) {

View File

@ -256,7 +256,7 @@ bool FrameBuffer::isValid(bool _forceCheck) const
if (m_cleared) {
const u32 testColor = m_clearParams.fillcolor & 0xFFFEFFFE;
const u32 stride = m_width << m_size >> 1;
const u32 lry = _cutHeight(m_startAddress, m_clearParams.lry, stride);
const s32 lry = (s32)_cutHeight(m_startAddress, m_clearParams.lry, stride);
if (lry == 0)
return false;
@ -264,8 +264,8 @@ bool FrameBuffer::isValid(bool _forceCheck) const
const u32 start = (m_startAddress >> 2) + m_clearParams.uly * ci_width_in_dwords;
const u32 * dst = pData + start;
u32 wrongPixels = 0;
for (u32 y = m_clearParams.uly; y < lry; ++y) {
for (u32 x = m_clearParams.ulx; x < m_clearParams.lrx; ++x) {
for (s32 y = m_clearParams.uly; y < lry; ++y) {
for (s32 x = m_clearParams.ulx; x < m_clearParams.lrx; ++x) {
if ((dst[x] & 0xFFFEFFFE) != testColor)
++wrongPixels;
}
@ -1221,10 +1221,10 @@ void FrameBufferList::fillRDRAM(s32 ulx, s32 uly, s32 lrx, s32 lry)
if (m_pCurrent == nullptr)
return;
ulx = min(max((float)ulx, gDP.scissor.ulx), gDP.scissor.lrx);
lrx = min(max((float)lrx, gDP.scissor.ulx), gDP.scissor.lrx);
uly = min(max((float)uly, gDP.scissor.uly), gDP.scissor.lry);
lry = min(max((float)lry, gDP.scissor.uly), gDP.scissor.lry);
ulx = (s32)min(max((float)ulx, gDP.scissor.ulx), gDP.scissor.lrx);
lrx = (s32)min(max((float)lrx, gDP.scissor.ulx), gDP.scissor.lrx);
uly = (s32)min(max((float)uly, gDP.scissor.uly), gDP.scissor.lry);
lry = (s32)min(max((float)lry, gDP.scissor.uly), gDP.scissor.lry);
const u32 stride = gDP.colorImage.width << gDP.colorImage.size >> 1;
const u32 lowerBound = gDP.colorImage.address + lry*stride;
@ -1235,8 +1235,8 @@ void FrameBufferList::fillRDRAM(s32 ulx, s32 uly, s32 lrx, s32 lry)
lrx >>= (3 - gDP.colorImage.size);
u32 * dst = (u32*)(RDRAM + gDP.colorImage.address);
dst += uly * ci_width_in_dwords;
for (u32 y = uly; y < lry; ++y) {
for (u32 x = ulx; x < lrx; ++x) {
for (s32 y = uly; y < lry; ++y) {
for (s32 x = ulx; x < lrx; ++x) {
dst[x] = gDP.fillColor.color;
}
dst += ci_width_in_dwords;

View File

@ -75,7 +75,7 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET(GCC_CPP11_COMPILE_FLAGS "-std=c++0x")
SET(GCC_CPP11_COMPILE_FLAGS "-std=c++0x -Wno-unused-result")
if( NOT GHQCHK )
if ( NOT MINGW )
SET ( PIC_FLAGS "-fPIC" )

View File

@ -822,7 +822,7 @@ public:
void update(bool _force) override
{
for (s32 i = 0; i <= gSP.numLights; ++i) {
for (u32 i = 0; i <= gSP.numLights; ++i) {
uLightDirection[i].set(gSP.lights.xyz[i], _force);
uLightColor[i].set(gSP.lights.rgb[i], _force);
}

View File

@ -235,7 +235,7 @@ bool ShaderStorage::_loadFromCombinerKeys(graphics::Combiners & _combiners)
u32 hwlSupport;
fin >> std::hex >> hwlSupport;
GBI.setHWLSupported(static_cast<bool>(hwlSupport));
GBI.setHWLSupported(hwlSupport != 0);
displayLoadProgress(L"LOAD COMBINER SHADERS %.1f%%", 0.0f);

View File

@ -60,8 +60,8 @@ void Utils::logErrorShader(GLenum _shaderType, const std::string & _strShader)
{
LOG(LOG_ERROR, "Error in %s shader", _shaderType == GL_VERTEX_SHADER ? "vertex" : "fragment");
const int max = 800;
int pos = 0;
const u32 max = 800;
u32 pos = 0;
while (pos < _strShader.length()) {

View File

@ -202,9 +202,9 @@ void DisplayWindowMupen64plus::_readScreen2(void * _dest, int * _width, int * _h
#endif
//Convert RGBA to RGB
for (u32 y = 0; y < *_height; ++y) {
for (s32 y = 0; y < *_height; ++y) {
u8 *ptr = pBufferData + ((*_width) * 4 * y);
for (u32 x = 0; x < *_width; ++x) {
for (s32 x = 0; x < *_width; ++x) {
pDest[x * 3] = ptr[0]; // red
pDest[x * 3 + 1] = ptr[1]; // green
pDest[x * 3 + 2] = ptr[2]; // blue

View File

@ -212,7 +212,7 @@ void BufferedDrawer::drawTriangles(const graphics::Context::DrawTriangleParamete
// Draw polygons one by one
const GLint eboStartPos = m_trisBuffers.ebo.pos - _params.elementsCount;
const GLint vboStartPos = m_trisBuffers.vbo.pos - _params.verticesCount;
for (GLint i = 0; i < _params.elementsCount; i += 3) {
for (GLuint i = 0; i < _params.elementsCount; i += 3) {
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
glDrawElementsBaseVertex(GLenum(_params.mode), 3, GL_UNSIGNED_BYTE,
(char*)nullptr + eboStartPos + i, vboStartPos);

View File

@ -56,7 +56,7 @@ const u8 * ColorBufferReaderWithBufferStorage::_readPixels(const ReadColorBuffer
m_curIndex = (m_curIndex + 1) % _numPBO;
//Wait for glReadPixels to complete for the currently selected PBO
if (m_fence[m_curIndex] != 0) {
glClientWaitSync(m_fence[m_curIndex], 0, 1e8);
glClientWaitSync(m_fence[m_curIndex], 0, 100000000);
glDeleteSync(m_fence[m_curIndex]);
}
} else {

View File

@ -87,7 +87,7 @@ void UnbufferedDrawer::drawTriangles(const graphics::Context::DrawTriangleParame
}
// Draw polygons one by one
for (GLint i = 0; i < _params.elementsCount; i += 3) {
for (GLuint i = 0; i < _params.elementsCount; i += 3) {
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
glDrawElements(GLenum(_params.mode), 3, GL_UNSIGNED_BYTE, (u8*)_params.elements + i);
}

View File

@ -916,16 +916,16 @@ void GraphicsDrawer::drawRect(int _ulx, int _uly, int _lrx, int _lry)
calcCoordsScales(frameBufferList().getCurrent(), scaleX, scaleY);
const float Z = (gDP.otherMode.depthSource == G_ZS_PRIM) ? gDP.primDepth.z : 0.0f;
const float W = 1.0f;
m_rect[0].x = (float)_ulx * (2.0f * scaleX) - 1.0;
m_rect[0].y = (float)_uly * (-2.0f * scaleY) + 1.0;
m_rect[0].x = (float)_ulx * (2.0f * scaleX) - 1.0f;
m_rect[0].y = (float)_uly * (-2.0f * scaleY) + 1.0f;
m_rect[0].z = Z;
m_rect[0].w = W;
m_rect[1].x = (float)_lrx * (2.0f * scaleX) - 1.0;
m_rect[1].x = (float)_lrx * (2.0f * scaleX) - 1.0f;
m_rect[1].y = m_rect[0].y;
m_rect[1].z = Z;
m_rect[1].w = W;
m_rect[2].x = m_rect[0].x;
m_rect[2].y = (float)_lry * (-2.0f * scaleY) + 1.0;
m_rect[2].y = (float)_lry * (-2.0f * scaleY) + 1.0f;
m_rect[2].z = Z;
m_rect[2].w = W;
m_rect[3].x = m_rect[1].x;
@ -934,7 +934,7 @@ void GraphicsDrawer::drawRect(int _ulx, int _uly, int _lrx, int _lry)
m_rect[3].w = W;
DisplayWindow & wnd = dwnd();
if (wnd.isAdjustScreen() && (gDP.colorImage.width > VI.width * 98 / 100) && (_lrx - _ulx < VI.width * 9 / 10)) {
if (wnd.isAdjustScreen() && (gDP.colorImage.width > VI.width * 98 / 100) && ((u32)(_lrx - _ulx) < VI.width * 9 / 10)) {
const float scale = wnd.getAdjustScale();
for (u32 i = 0; i < 4; ++i)
m_rect[i].x *= scale;
@ -1031,7 +1031,7 @@ bool texturedRectBGCopy(const GraphicsDrawer::TexturedRectParams & _params)
const u32 width = (u32)(_params.lrx - _params.ulx);
const u32 tex_width = gSP.textureTile[0]->line << 3;
const u32 uly = (u32)_params.uly;
const u32 lry = flry;
const u32 lry = (u32)flry;
u8 * texaddr = RDRAM + gDP.loadInfo[gSP.textureTile[0]->tmem].texAddress + tex_width*(u32)_params.ult + (u32)_params.uls;
u8 * fbaddr = RDRAM + gDP.colorImage.address + (u32)_params.ulx;
@ -1374,8 +1374,8 @@ void GraphicsDrawer::drawOSD()
const bool bottom = (config.posBottom & config.onScreenDisplay.pos) != 0;
const bool left = (config.onScreenDisplay.pos == Config::posTopLeft) || (config.onScreenDisplay.pos == Config::posBottomLeft);
const float hp = left ? -1 : 1;
const float vp = bottom ? -1 : 1;
const float hp = left ? -1.0f : 1.0f;
const float vp = bottom ? -1.0f : 1.0f;
float hShift, vShift;
g_textDrawer.getTextSize("0", hShift, vShift);
@ -1585,7 +1585,7 @@ void GraphicsDrawer::_initStates()
gfxContext.clearColorBuffer(0.0f, 0.0f, 0.0f, 0.0f);
srand(time(nullptr));
srand((unsigned int)time(nullptr));
wnd.swapBuffers();
}

View File

@ -49,8 +49,8 @@ void Performance::increaseVICount()
const double elapsed = double(time_span.count()) * std::chrono::steady_clock::period::num / std::chrono::steady_clock::period::den;
if (elapsed < 0.5)
return;
m_vis = m_vi / elapsed;
m_fps = m_frames / elapsed;
m_vis = (f32)(m_vi / elapsed);
m_fps = (f32)(m_frames / elapsed);
m_vi = 0;
m_frames = 0;
m_startTime = curTime;

View File

@ -22,7 +22,7 @@ void clipTest(vertexclip & _vtx)
}
static
bool calcScreenCoordinates(SPVertex * _vsrc, vertexclip * _vclip, int _numVertex)
bool calcScreenCoordinates(SPVertex * _vsrc, vertexclip * _vclip, u32 _numVertex)
{
for (u32 i = 0; i < _numVertex; ++i) {
SPVertex & v = _vsrc[i];
@ -139,9 +139,9 @@ void copyVertex(SPVertex & _dst, const SPVertex * _src)
}
static
int clipW(const SPVertex ** _vsrc, SPVertex * _vdst)
u32 clipW(const SPVertex ** _vsrc, SPVertex * _vdst)
{
int dsti = 0;
u32 dsti = 0;
for (int n = 0; n < 3; ++n) {
const SPVertex * src1 = _vsrc[n]; // current vertex
const SPVertex * src2 = _vsrc[n + 1]; // next vertex
@ -186,7 +186,7 @@ f32 renderTriangles(const SPVertex * _pVertices, const u8 * _pElements, u32 _num
}
vsrc[3] = vsrc[0];
int numVertex = clipW(vsrc, vdata);
u32 numVertex = clipW(vsrc, vdata);
if (!calcScreenCoordinates(vdata, vclip, numVertex))
continue;
@ -218,7 +218,7 @@ f32 renderTriangles(const SPVertex * _pVertices, const u8 * _pElements, u32 _num
continue;
if ((gSP.geometryMode & G_CULL_FRONT) != 0) {
for (int k = 0; k < numVertex; ++k) {
for (u32 k = 0; k < numVertex; ++k) {
const u32 idx = numVertex - k - 1;
maxY = std::max(maxY, vtx[idx]->y);
vdraw[k].x = floatToFixed16(vtx[idx]->x);
@ -226,7 +226,7 @@ f32 renderTriangles(const SPVertex * _pVertices, const u8 * _pElements, u32 _num
vdraw[k].z = floatToFixed16(vtx[idx]->z);
}
} else {
for (int k = 0; k < numVertex; ++k) {
for (u32 k = 0; k < numVertex; ++k) {
maxY = std::max(maxY, vtx[k]->y);
vdraw[k].x = floatToFixed16(vtx[k]->x);
vdraw[k].y = floatToFixed16(vtx[k]->y);

View File

@ -110,7 +110,7 @@ void UnswapCopyWrap(const u8 *src, u32 srcIdx, u8 *dest, u32 destIdx, u32 destMa
numBytes -= leadingBytes;
srcIdx ^= 3;
for (int i = 0; i < leadingBytes; i++) {
for (u32 i = 0; i < leadingBytes; i++) {
dest[destIdx&destMask] = src[srcIdx];
++destIdx;
--srcIdx;

View File

@ -239,7 +239,7 @@ void gDPGetFillColor(f32 _fillColor[4])
void gDPSetPrimColor( u32 m, u32 l, u32 r, u32 g, u32 b, u32 a )
{
gDP.primColor.m = m * 0.0312500000;
gDP.primColor.m = m * 0.0312500000f;
gDP.primColor.l = l * 0.0039215689f;
gDP.primColor.r = r * 0.0039215689f;
gDP.primColor.g = g * 0.0039215689f;
@ -458,7 +458,7 @@ void gDPLoadTile(u32 tile, u32 uls, u32 ult, u32 lrs, u32 lrt)
bpl2 = (gDP.textureImage.width - gDP.loadTile->uls);
u32 height2 = height;
if (gDP.loadTile->lrt > gDP.scissor.lry)
height2 = gDP.scissor.lry - gDP.loadTile->ult;
height2 = (u32)gDP.scissor.lry - gDP.loadTile->ult;
if (CheckForFrameBufferTexture(address, bpl2*height2))
return;
@ -678,8 +678,8 @@ void gDPSetScissor( u32 mode, f32 ulx, f32 uly, f32 lrx, f32 lry )
if (ulx > 0 && ulx < maxCropH &&
uly > 0 && uly < maxCropV &&
(VI.width - lrx) < maxCropH && (VI.height - lry) < maxCropV) {
config.video.cropWidth = ulx;
config.video.cropHeight = uly;
config.video.cropWidth = (u32)ulx;
config.video.cropHeight = (u32)uly;
}
}
@ -758,7 +758,7 @@ void gDPFillRectangle( s32 ulx, s32 uly, s32 lrx, s32 lry )
}
}
frameBufferList().setBufferChanged(lry);
frameBufferList().setBufferChanged(f32(lry));
DebugMsg( DEBUG_NORMAL, "gDPFillRectangle( %i, %i, %i, %i );\n", ulx, uly, lrx, lry );
}

View File

@ -485,7 +485,7 @@ void gSPLightVertexStandard(u32 v, SPVertex * spVtx)
vtx.b = gSP.lights.rgb[gSP.numLights][B];
vtx.HWLight = 0;
for (int i = 0; i < gSP.numLights; ++i) {
for (u32 i = 0; i < gSP.numLights; ++i) {
const f32 intensity = DotProduct( &vtx.nx, gSP.lights.i_xyz[i] );
if (intensity > 0.0f) {
vtx.r += gSP.lights.rgb[i][R] * intensity;
@ -1575,10 +1575,10 @@ void gSPInsertMatrix( u32 where, u32 num )
if (where < 0x20) {
fraction = modff( gSP.matrix.combined[0][where >> 1], &integer );
gSP.matrix.combined[0][where >> 1] = (s16)_SHIFTR( num, 16, 16 ) + abs( (int)fraction );
gSP.matrix.combined[0][where >> 1] = (f32)((s16)_SHIFTR( num, 16, 16 ) + abs( (int)fraction ));
fraction = modff( gSP.matrix.combined[0][(where >> 1) + 1], &integer );
gSP.matrix.combined[0][(where >> 1) + 1] = (s16)_SHIFTR( num, 0, 16 ) + abs( (int)fraction );
gSP.matrix.combined[0][(where >> 1) + 1] = (f32)((s16)_SHIFTR( num, 0, 16 ) + abs( (int)fraction ));
} else {
f32 newValue;
@ -1720,7 +1720,7 @@ void gSPCoordMod(u32 _w0, u32 _w1)
}
}
void gSPTexture( f32 sc, f32 tc, s32 level, s32 tile, s32 on )
void gSPTexture( f32 sc, f32 tc, u32 level, u32 tile, u32 on )
{
gSP.texture.on = on;
if (on == 0) {
@ -2020,8 +2020,8 @@ struct ObjCoordinates
}
uls = ult = 0;
lrs = data.imageW - 1;
lrt = data.imageH - 1;
lrs = (f32)(data.imageW - 1);
lrt = (f32)(data.imageH - 1);
if (data.flipS) {
uls = lrs;
lrs = 0;
@ -2158,7 +2158,7 @@ void _drawYUVImageToFrameBuffer(const ObjCoordinates & _objCoords)
const u32 lrx = (u32)_objCoords.lrx;
const u32 lry = (u32)_objCoords.lry;
const u32 ci_width = gDP.colorImage.width;
const u32 ci_height = gDP.scissor.lry;
const u32 ci_height = (u32)gDP.scissor.lry;
if (ulx >= ci_width)
return;
if (uly >= ci_height)
@ -2375,15 +2375,21 @@ void gSPObjSprite(u32 _sp)
const f32 lrx = data.X1;
const f32 lry = data.Y1;
float uls = 0, lrs = data.imageW - 1, ult = 0, lrt = data.imageH - 1;
f32 uls = 0;
f32 lrs = (f32)(data.imageW - 1);
f32 ult = 0;
f32 lrt = (f32)(data.imageH - 1);
if (objSprite->imageFlags & 0x01) { // flipS
uls = lrs;
lrs = 0;
}
if (objSprite->imageFlags & 0x10) { // flipT
ult = lrt;
lrt = 0;
}
const float z = (gDP.otherMode.depthSource == G_ZS_PRIM) ? gDP.primDepth.z : gSP.viewport.nearz;
GraphicsDrawer & drawer = dwnd().getDrawer();

View File

@ -88,13 +88,13 @@ struct gSPInfo
f32 ca[2], la[2], qa[2];
} lookat;
s32 numLights;
u32 numLights;
bool lookatEnable;
struct
{
f32 scales, scalet;
s32 level, on, tile;
u32 level, on, tile;
} texture;
gDPTile *textureTile[2];
@ -182,7 +182,7 @@ void gSPNumLights( s32 n );
void gSPLightColor( u32 lightNum, u32 packedColor );
void gSPFogFactor( s16 fm, s16 fo );
void gSPPerspNormalize( u16 scale );
void gSPTexture( f32 sc, f32 tc, s32 level, s32 tile, s32 on );
void gSPTexture( f32 sc, f32 tc, u32 level, u32 tile, u32 on );
void gSPEndDisplayList();
void gSPGeometryMode( u32 clear, u32 set );
void gSPSetGeometryMode( u32 mode );