Remove the min/max functions in CommonFuncs.

The algorithm header has the same functions.
This commit is contained in:
Lioncash
2014-05-02 22:47:04 -04:00
parent 3097345929
commit 49b0eef393
29 changed files with 104 additions and 99 deletions

View File

@ -2,8 +2,9 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include "Common/Common.h"
#include <algorithm>
#include "Common/Common.h"
#include "VideoBackends/Software/BPMemLoader.h"
#include "VideoBackends/Software/EfbInterface.h"
#include "VideoBackends/Software/HwRasterizer.h"
@ -231,12 +232,12 @@ inline void CalculateLOD(s32 &lod, bool &linear, u32 texmap, u32 texcoord)
float *uv1 = rasterBlock.Pixel[1][0].Uv[texcoord];
float *uv2 = rasterBlock.Pixel[0][1].Uv[texcoord];
sDelta = max(fabsf(uv0[0] - uv1[0]), fabsf(uv0[0] - uv2[0]));
tDelta = max(fabsf(uv0[1] - uv1[1]), fabsf(uv0[1] - uv2[1]));
sDelta = std::max(fabsf(uv0[0] - uv1[0]), fabsf(uv0[0] - uv2[0]));
tDelta = std::max(fabsf(uv0[1] - uv1[1]), fabsf(uv0[1] - uv2[1]));
}
// get LOD in s28.4
lod = FixedLog2(max(sDelta, tDelta));
lod = FixedLog2(std::max(sDelta, tDelta));
// bias is s2.5
int bias = tm0.lod_bias;
@ -349,16 +350,16 @@ void DrawTriangleFrontFace(OutputVertexData *v0, OutputVertexData *v1, OutputVer
const s32 FDY31 = DY31 << 4;
// Bounding rectangle
s32 minx = (min(min(X1, X2), X3) + 0xF) >> 4;
s32 maxx = (max(max(X1, X2), X3) + 0xF) >> 4;
s32 miny = (min(min(Y1, Y2), Y3) + 0xF) >> 4;
s32 maxy = (max(max(Y1, Y2), Y3) + 0xF) >> 4;
s32 minx = (std::min(std::min(X1, X2), X3) + 0xF) >> 4;
s32 maxx = (std::max(std::max(X1, X2), X3) + 0xF) >> 4;
s32 miny = (std::min(std::min(Y1, Y2), Y3) + 0xF) >> 4;
s32 maxy = (std::max(std::max(Y1, Y2), Y3) + 0xF) >> 4;
// scissor
minx = max(minx, scissorLeft);
maxx = min(maxx, scissorRight);
miny = max(miny, scissorTop);
maxy = min(maxy, scissorBottom);
minx = std::max(minx, scissorLeft);
maxx = std::min(maxx, scissorRight);
miny = std::max(miny, scissorTop);
maxy = std::min(maxy, scissorBottom);
if (minx >= maxx || miny >= maxy)
return;

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <algorithm>
#include "Common/Common.h"
#include "Core/Core.h"
#include "VideoBackends/OGL/GLUtil.h"
@ -180,14 +182,14 @@ void SWRenderer::UpdateColorTexture(EfbInterface::yuv422_packed *xfb, u32 fbWidt
// We do the inverse BT.601 conversion for YCbCr to RGB
// http://www.equasys.de/colorconversion.html#YCbCr-RGBColorFormatConversion
TexturePointer[offset++] = (u8)min(255.0f, max(0.0f, 1.164f * Y1 + 1.596f * V));
TexturePointer[offset++] = (u8)min(255.0f, max(0.0f, 1.164f * Y1 - 0.392f * U - 0.813f * V));
TexturePointer[offset++] = (u8)min(255.0f, max(0.0f, 1.164f * Y1 + 2.017f * U ));
TexturePointer[offset++] = std::min<u8>(255.0f, std::max(0.0f, 1.164f * Y1 + 1.596f * V));
TexturePointer[offset++] = std::min<u8>(255.0f, std::max(0.0f, 1.164f * Y1 - 0.392f * U - 0.813f * V));
TexturePointer[offset++] = std::min<u8>(255.0f, std::max(0.0f, 1.164f * Y1 + 2.017f * U ));
TexturePointer[offset++] = 255;
TexturePointer[offset++] = (u8)min(255.0f, max(0.0f, 1.164f * Y2 + 1.596f * V));
TexturePointer[offset++] = (u8)min(255.0f, max(0.0f, 1.164f * Y2 - 0.392f * U - 0.813f * V));
TexturePointer[offset++] = (u8)min(255.0f, max(0.0f, 1.164f * Y2 + 2.017f * U ));
TexturePointer[offset++] = std::min<u8>(255.0f, std::max(0.0f, 1.164f * Y2 + 1.596f * V));
TexturePointer[offset++] = std::min<u8>(255.0f, std::max(0.0f, 1.164f * Y2 - 0.392f * U - 0.813f * V));
TexturePointer[offset++] = std::min<u8>(255.0f, std::max(0.0f, 1.164f * Y2 + 2.017f * U ));
TexturePointer[offset++] = 255;
}
xfb += fbWidth;

View File

@ -2,6 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <algorithm>
#include <cmath>
#include "Core/HW/Memmap.h"
@ -142,8 +143,8 @@ void SampleMip(s32 s, s32 t, s32 mip, bool linear, u8 texmap, u8 *sample)
while (mip)
{
mipWidth = max(mipWidth, fmtWidth);
mipHeight = max(mipHeight, fmtHeight);
mipWidth = std::max(mipWidth, fmtWidth);
mipHeight = std::max(mipHeight, fmtHeight);
u32 size = (mipWidth * mipHeight * fmtDepth) >> 1;
imageSrc += size;

View File

@ -2,6 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <algorithm>
#include <cmath>
#include "Common/Common.h"
@ -229,7 +230,7 @@ void LightColor(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChann
case LIGHTDIF_CLAMP:
{
Vec3 ldir = (light->pos - pos).normalized();
float diffuse = max(0.0f, ldir * normal);
float diffuse = std::max(0.0f, ldir * normal);
AddScaledIntegerColor(light->color, diffuse, lightCol);
}
break;
@ -247,21 +248,21 @@ void LightColor(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChann
float dist2 = ldir.length2();
float dist = sqrtf(dist2);
ldir = ldir / dist;
attn = max(0.0f, ldir * light->dir);
attn = std::max(0.0f, ldir * light->dir);
float cosAtt = light->cosatt.x + (light->cosatt.y * attn) + (light->cosatt.z * attn * attn);
float distAtt = light->distatt.x + (light->distatt.y * dist) + (light->distatt.z * dist2);
attn = SafeDivide(max(0.0f, cosAtt), distAtt);
attn = SafeDivide(std::max(0.0f, cosAtt), distAtt);
}
else if (chan.attnfunc == 1) // specular
{
// donko - what is going on here? 655.36 is a guess but seems about right.
attn = (light->pos * normal) > -655.36 ? max(0.0f, (light->dir * normal)) : 0;
attn = (light->pos * normal) > -655.36 ? std::max(0.0f, (light->dir * normal)) : 0;
ldir.set(1.0f, attn, attn * attn);
float cosAtt = max(0.0f, light->cosatt * ldir);
float cosAtt = std::max(0.0f, light->cosatt * ldir);
float distAtt = light->distatt * ldir;
attn = SafeDivide(max(0.0f, cosAtt), distAtt);
attn = SafeDivide(std::max(0.0f, cosAtt), distAtt);
}
else
{
@ -283,7 +284,7 @@ void LightColor(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChann
case LIGHTDIF_CLAMP:
{
float difAttn = max(0.0f, ldir * normal);
float difAttn = std::max(0.0f, ldir * normal);
AddScaledIntegerColor(light->color, attn * difAttn, lightCol);
}
break;
@ -314,7 +315,7 @@ void LightAlpha(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChann
case LIGHTDIF_CLAMP:
{
Vec3 ldir = (light->pos - pos).normalized();
float diffuse = max(0.0f, ldir * normal);
float diffuse = std::max(0.0f, ldir * normal);
lightCol += light->color[0] * diffuse;
}
break;
@ -331,21 +332,21 @@ void LightAlpha(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChann
float dist2 = ldir.length2();
float dist = sqrtf(dist2);
ldir = ldir / dist;
attn = max(0.0f, ldir * light->dir);
attn = std::max(0.0f, ldir * light->dir);
float cosAtt = light->cosatt.x + (light->cosatt.y * attn) + (light->cosatt.z * attn * attn);
float distAtt = light->distatt.x + (light->distatt.y * dist) + (light->distatt.z * dist2);
attn = SafeDivide(max(0.0f, cosAtt), distAtt);
attn = SafeDivide(std::max(0.0f, cosAtt), distAtt);
}
else /* if (chan.attnfunc == 1) */ // specular
{
// donko - what is going on here? 655.36 is a guess but seems about right.
attn = (light->pos * normal) > -655.36 ? max(0.0f, (light->dir * normal)) : 0;
attn = (light->pos * normal) > -655.36 ? std::max(0.0f, (light->dir * normal)) : 0;
ldir.set(1.0f, attn, attn * attn);
float cosAtt = light->cosatt * ldir;
float distAtt = light->distatt * ldir;
attn = SafeDivide(max(0.0f, cosAtt), distAtt);
attn = SafeDivide(std::max(0.0f, cosAtt), distAtt);
}
switch (chan.diffusefunc)
@ -362,7 +363,7 @@ void LightAlpha(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChann
case LIGHTDIF_CLAMP:
{
float difAttn = max(0.0f, ldir * normal);
float difAttn = std::max(0.0f, ldir * normal);
lightCol += light->color[0] * attn * difAttn;
}
break;

View File

@ -5,9 +5,11 @@
#pragma once
#define _WIN32_WINNT 0x501
#ifndef _WIN32_IE
#define _WIN32_IE 0x0500 // Default value is 0x0400
#define _WIN32_IE 0x0500 // Default value is 0x0400
#endif
#define NOMINMAX // Don't include windows min/max definitions
#include <tchar.h>
#include <windows.h>