Merge pull request #334 from lioncash/use-std-minmax
Remove the min/max functions in CommonFuncs.
This commit is contained in:
commit
8fc83d8ffc
|
@ -12,6 +12,7 @@
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
|
#define NOMINMAX // Don't include windows min/max definitions
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
|
@ -158,15 +158,6 @@ extern "C" {
|
||||||
#endif // M_IX86
|
#endif // M_IX86
|
||||||
#endif // WIN32 ndef
|
#endif // WIN32 ndef
|
||||||
|
|
||||||
// Dolphin's min and max functions
|
|
||||||
#undef min
|
|
||||||
#undef max
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline T min(const T& a, const T& b) {return a > b ? b : a;}
|
|
||||||
template<class T>
|
|
||||||
inline T max(const T& a, const T& b) {return a > b ? a : b;}
|
|
||||||
|
|
||||||
// Generic function to get last error message.
|
// Generic function to get last error message.
|
||||||
// Call directly after the command or use the error num.
|
// Call directly after the command or use the error num.
|
||||||
// This function might change the error code.
|
// This function might change the error code.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// Licensed under GPLv2
|
// Licensed under GPLv2
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include "Common/Hash.h"
|
#include "Common/Hash.h"
|
||||||
#if _M_SSE >= 0x402
|
#if _M_SSE >= 0x402
|
||||||
#include "Common/CPUDetect.h"
|
#include "Common/CPUDetect.h"
|
||||||
|
@ -155,7 +155,7 @@ u64 GetMurmurHash3(const u8 *src, int len, u32 samples)
|
||||||
const u8 * data = (const u8*)src;
|
const u8 * data = (const u8*)src;
|
||||||
const int nblocks = len / 16;
|
const int nblocks = len / 16;
|
||||||
u32 Step = (len / 8);
|
u32 Step = (len / 8);
|
||||||
if (samples == 0) samples = max(Step, 1u);
|
if (samples == 0) samples = std::max(Step, 1u);
|
||||||
Step = Step / samples;
|
Step = Step / samples;
|
||||||
if (Step < 1) Step = 1;
|
if (Step < 1) Step = 1;
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ u64 GetCRC32(const u8 *src, int len, u32 samples)
|
||||||
u32 Step = (len / 8);
|
u32 Step = (len / 8);
|
||||||
const u64 *data = (const u64 *)src;
|
const u64 *data = (const u64 *)src;
|
||||||
const u64 *end = data + Step;
|
const u64 *end = data + Step;
|
||||||
if (samples == 0) samples = max(Step, 1u);
|
if (samples == 0) samples = std::max(Step, 1u);
|
||||||
Step = Step / samples;
|
Step = Step / samples;
|
||||||
if (Step < 1) Step = 1;
|
if (Step < 1) Step = 1;
|
||||||
while (data < end)
|
while (data < end)
|
||||||
|
@ -265,7 +265,7 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples)
|
||||||
u32 Step = (len / 8);
|
u32 Step = (len / 8);
|
||||||
const u64 *data = (const u64 *)src;
|
const u64 *data = (const u64 *)src;
|
||||||
const u64 *end = data + Step;
|
const u64 *end = data + Step;
|
||||||
if (samples == 0) samples = max(Step, 1u);
|
if (samples == 0) samples = std::max(Step, 1u);
|
||||||
Step = Step / samples;
|
Step = Step / samples;
|
||||||
if (Step < 1) Step = 1;
|
if (Step < 1) Step = 1;
|
||||||
while (data < end)
|
while (data < end)
|
||||||
|
@ -308,7 +308,7 @@ u64 GetCRC32(const u8 *src, int len, u32 samples)
|
||||||
u32 Step = (len/4);
|
u32 Step = (len/4);
|
||||||
const u32 *data = (const u32 *)src;
|
const u32 *data = (const u32 *)src;
|
||||||
const u32 *end = data + Step;
|
const u32 *end = data + Step;
|
||||||
if (samples == 0) samples = max(Step, 1u);
|
if (samples == 0) samples = std::max(Step, 1u);
|
||||||
Step = Step / samples;
|
Step = Step / samples;
|
||||||
if (Step < 1) Step = 1;
|
if (Step < 1) Step = 1;
|
||||||
while (data < end)
|
while (data < end)
|
||||||
|
@ -380,7 +380,7 @@ u64 GetMurmurHash3(const u8* src, int len, u32 samples)
|
||||||
u32 out[2];
|
u32 out[2];
|
||||||
const int nblocks = len / 8;
|
const int nblocks = len / 8;
|
||||||
u32 Step = (len / 4);
|
u32 Step = (len / 4);
|
||||||
if (samples == 0) samples = max(Step, 1u);
|
if (samples == 0) samples = std::max(Step, 1u);
|
||||||
Step = Step / samples;
|
Step = Step / samples;
|
||||||
if (Step < 1) Step = 1;
|
if (Step < 1) Step = 1;
|
||||||
|
|
||||||
|
@ -456,7 +456,7 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples)
|
||||||
u32 Step = (len / 8);
|
u32 Step = (len / 8);
|
||||||
const u64 *data = (const u64 *)src;
|
const u64 *data = (const u64 *)src;
|
||||||
const u64 *end = data + Step;
|
const u64 *end = data + Step;
|
||||||
if (samples == 0) samples = max(Step, 1u);
|
if (samples == 0) samples = std::max(Step, 1u);
|
||||||
Step = Step / samples;
|
Step = Step / samples;
|
||||||
if (Step < 1) Step = 1;
|
if (Step < 1) Step = 1;
|
||||||
while (data < end)
|
while (data < end)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -58,7 +59,7 @@ struct SSysConfEntry
|
||||||
{
|
{
|
||||||
if (buffer)
|
if (buffer)
|
||||||
{
|
{
|
||||||
memcpy(data, buffer, min<u16>(bufferSize, dataLength));
|
memcpy(data, buffer, std::min<u16>(bufferSize, dataLength));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -9,11 +9,13 @@
|
||||||
#define _WIN32_WINNT 0x501
|
#define _WIN32_WINNT 0x501
|
||||||
#endif
|
#endif
|
||||||
#ifndef _WIN32_IE
|
#ifndef _WIN32_IE
|
||||||
#define _WIN32_IE 0x0500 // Default value is 0x0400
|
#define _WIN32_IE 0x0500 // Default value is 0x0400
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
|
#define NOMINMAX // Don't include windows min/max definitions
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||||
#define _CRT_NONSTDC_NO_DEPRECATE 1
|
#define _CRT_NONSTDC_NO_DEPRECATE 1
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
// Licensed under GPLv2
|
// Licensed under GPLv2
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
#include "Core/FifoPlayer/FifoAnalyzer.h"
|
#include "Core/FifoPlayer/FifoAnalyzer.h"
|
||||||
#include "Core/FifoPlayer/FifoRecordAnalyzer.h"
|
#include "Core/FifoPlayer/FifoRecordAnalyzer.h"
|
||||||
|
@ -289,8 +291,8 @@ void FifoRecordAnalyzer::WriteTexMapMemory(int texMap, u32 &writtenTexMaps)
|
||||||
width >>= 1;
|
width >>= 1;
|
||||||
height >>= 1;
|
height >>= 1;
|
||||||
|
|
||||||
width = max(width, fmtWidth);
|
width = std::max(width, fmtWidth);
|
||||||
height = max(height, fmtHeight);
|
height = std::max(height, fmtHeight);
|
||||||
u32 size = (width * height * fmtDepth) >> 1;
|
u32 size = (width * height * fmtDepth) >> 1;
|
||||||
|
|
||||||
textureSize += size;
|
textureSize += size;
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
// Licensed under GPLv2
|
// Licensed under GPLv2
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "Common/ChunkFile.h"
|
#include "Common/ChunkFile.h"
|
||||||
#include "Common/Common.h"
|
#include "Common/Common.h"
|
||||||
|
|
||||||
|
@ -544,7 +546,7 @@ int GetTicksToNextSIPoll()
|
||||||
else if (!g_Poll.Y)
|
else if (!g_Poll.Y)
|
||||||
return SystemTimers::GetTicksPerSecond() / 60;
|
return SystemTimers::GetTicksPerSecond() / 60;
|
||||||
|
|
||||||
return min(VideoInterface::GetTicksPerFrame() / g_Poll.Y, VideoInterface::GetTicksPerLine() * g_Poll.X);
|
return std::min(VideoInterface::GetTicksPerFrame() / g_Poll.Y, VideoInterface::GetTicksPerLine() * g_Poll.X);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of namespace SerialInterface
|
} // end of namespace SerialInterface
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
// Licensed under GPLv2
|
// Licensed under GPLv2
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
#include "Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h"
|
#include "Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h"
|
||||||
#include "Core/IPC_HLE/WII_Socket.h"
|
#include "Core/IPC_HLE/WII_Socket.h"
|
||||||
|
@ -174,7 +176,7 @@ bool CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
|
||||||
ssl_set_authmode(&ssl->ctx, SSL_VERIFY_NONE);
|
ssl_set_authmode(&ssl->ctx, SSL_VERIFY_NONE);
|
||||||
ssl_set_renegotiation(&ssl->ctx, SSL_RENEGOTIATION_ENABLED);
|
ssl_set_renegotiation(&ssl->ctx, SSL_RENEGOTIATION_ENABLED);
|
||||||
|
|
||||||
memcpy(ssl->hostname, hostname, min((int)BufferOutSize2, NET_SSL_MAX_HOSTNAME_LEN));
|
memcpy(ssl->hostname, hostname, std::min((int)BufferOutSize2, NET_SSL_MAX_HOSTNAME_LEN));
|
||||||
ssl->hostname[NET_SSL_MAX_HOSTNAME_LEN-1] = '\0';
|
ssl->hostname[NET_SSL_MAX_HOSTNAME_LEN-1] = '\0';
|
||||||
ssl_set_hostname(&ssl->ctx, ssl->hostname);
|
ssl_set_hostname(&ssl->ctx, ssl->hostname);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
// Licensed under GPLv2
|
// Licensed under GPLv2
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "Core/Movie.h"
|
#include "Core/Movie.h"
|
||||||
#include "Core/NetPlayProto.h"
|
#include "Core/NetPlayProto.h"
|
||||||
#include "Core/IPC_HLE/WII_IPC_HLE.h"
|
#include "Core/IPC_HLE/WII_IPC_HLE.h"
|
||||||
|
@ -589,7 +591,7 @@ void WiiSockMan::Update()
|
||||||
FD_SET(sock.fd, &read_fds);
|
FD_SET(sock.fd, &read_fds);
|
||||||
FD_SET(sock.fd, &write_fds);
|
FD_SET(sock.fd, &write_fds);
|
||||||
FD_SET(sock.fd, &except_fds);
|
FD_SET(sock.fd, &except_fds);
|
||||||
nfds = max(nfds, sock.fd+1);
|
nfds = std::max(nfds, sock.fd+1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,6 +24,8 @@ The register allocation is linear scan allocation.
|
||||||
#pragma warning(disable:4146) // unary minus operator applied to unsigned type, result still unsigned
|
#pragma warning(disable:4146) // unary minus operator applied to unsigned type, result still unsigned
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "Common/CPUDetect.h"
|
#include "Common/CPUDetect.h"
|
||||||
#include "Common/MathUtil.h"
|
#include "Common/MathUtil.h"
|
||||||
#include "Core/HW/ProcessorInterface.h"
|
#include "Core/HW/ProcessorInterface.h"
|
||||||
|
@ -76,7 +78,7 @@ static void regMarkUse(RegInfo& R, InstLoc I, InstLoc Op, unsigned OpNum) {
|
||||||
unsigned& info = R.IInfo[Op - R.FirstI];
|
unsigned& info = R.IInfo[Op - R.FirstI];
|
||||||
if (info == 0) R.IInfo[I - R.FirstI] |= 1 << (OpNum + 1);
|
if (info == 0) R.IInfo[I - R.FirstI] |= 1 << (OpNum + 1);
|
||||||
if (info < 2) info++;
|
if (info < 2) info++;
|
||||||
R.lastUsed[Op - R.FirstI] = max(R.lastUsed[Op - R.FirstI], I);
|
R.lastUsed[Op - R.FirstI] = std::max(R.lastUsed[Op - R.FirstI], I);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned regReadUse(RegInfo& R, InstLoc I) {
|
static unsigned regReadUse(RegInfo& R, InstLoc I) {
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
// Licensed under GPLv2
|
// Licensed under GPLv2
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "Common/ArmEmitter.h"
|
#include "Common/ArmEmitter.h"
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
#include "Core/CoreTiming.h"
|
#include "Core/CoreTiming.h"
|
||||||
|
@ -50,7 +52,7 @@ static void regMarkUse(RegInfo& R, InstLoc I, InstLoc Op, unsigned OpNum) {
|
||||||
unsigned& info = R.IInfo[Op - R.FirstI];
|
unsigned& info = R.IInfo[Op - R.FirstI];
|
||||||
if (info == 0) R.IInfo[I - R.FirstI] |= 1 << (OpNum + 1);
|
if (info == 0) R.IInfo[I - R.FirstI] |= 1 << (OpNum + 1);
|
||||||
if (info < 2) info++;
|
if (info < 2) info++;
|
||||||
R.lastUsed[Op - R.FirstI] = max(R.lastUsed[Op - R.FirstI], I);
|
R.lastUsed[Op - R.FirstI] = std::max(R.lastUsed[Op - R.FirstI], I);
|
||||||
}
|
}
|
||||||
static void regClearInst(RegInfo& RI, InstLoc I) {
|
static void regClearInst(RegInfo& RI, InstLoc I) {
|
||||||
for (int i = 0; i < RegAllocSize; i++)
|
for (int i = 0; i < RegAllocSize; i++)
|
||||||
|
|
|
@ -6,9 +6,10 @@
|
||||||
|
|
||||||
#define _WIN32_WINNT 0x501
|
#define _WIN32_WINNT 0x501
|
||||||
#ifndef _WIN32_IE
|
#ifndef _WIN32_IE
|
||||||
#define _WIN32_IE 0x0500 // Default value is 0x0400
|
#define _WIN32_IE 0x0500 // Default value is 0x0400
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
|
#define NOMINMAX // Don't include windows min/max definitions
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
|
@ -193,7 +193,7 @@ bool CompressFileToBlob(const std::string& infile, const std::string& outfile, u
|
||||||
u64 position = 0;
|
u64 position = 0;
|
||||||
int num_compressed = 0;
|
int num_compressed = 0;
|
||||||
int num_stored = 0;
|
int num_stored = 0;
|
||||||
int progress_monitor = max<int>(1, header.num_blocks / 1000);
|
int progress_monitor = std::max<int>(1, header.num_blocks / 1000);
|
||||||
|
|
||||||
for (u32 i = 0; i < header.num_blocks; i++)
|
for (u32 i = 0; i < header.num_blocks; i++)
|
||||||
{
|
{
|
||||||
|
@ -299,7 +299,7 @@ bool DecompressBlobToFile(const std::string& infile, const std::string& outfile,
|
||||||
|
|
||||||
const CompressedBlobHeader &header = reader->GetHeader();
|
const CompressedBlobHeader &header = reader->GetHeader();
|
||||||
u8* buffer = new u8[header.block_size];
|
u8* buffer = new u8[header.block_size];
|
||||||
int progress_monitor = max<int>(1, header.num_blocks / 100);
|
int progress_monitor = std::max<int>(1, header.num_blocks / 100);
|
||||||
|
|
||||||
for (u64 i = 0; i < header.num_blocks; i++)
|
for (u64 i = 0; i < header.num_blocks; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -104,7 +104,7 @@ bool CFileSystemGCWii::ExportFile(const std::string& _rFullPath, const std::stri
|
||||||
while (remainingSize)
|
while (remainingSize)
|
||||||
{
|
{
|
||||||
// Limit read size to 128 MB
|
// Limit read size to 128 MB
|
||||||
size_t readSize = (size_t)min(remainingSize, (u64)0x08000000);
|
size_t readSize = std::min<size_t>(remainingSize, (u64)0x08000000);
|
||||||
|
|
||||||
std::vector<u8> buffer(readSize);
|
std::vector<u8> buffer(readSize);
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
|
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
|
#define NOMINMAX // Don't include windows min/max definitions
|
||||||
|
|
||||||
#ifndef _CRT_SECURE_NO_DEPRECATE
|
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||||
#define _CRT_SECURE_NO_DEPRECATE
|
#define _CRT_SECURE_NO_DEPRECATE
|
||||||
|
|
|
@ -12,8 +12,9 @@
|
||||||
#define _WIN32_IE 0x0500
|
#define _WIN32_IE 0x0500
|
||||||
#define _RICHEDIT_VER 0x0100
|
#define _RICHEDIT_VER 0x0100
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
#include <wx/wx.h> // wxWidgets
|
#define NOMINMAX // Don't include windows min/max definitions
|
||||||
|
#include <wx/wx.h> // wxWidgets
|
||||||
|
|
||||||
#if _M_X86_32
|
#if _M_X86_32
|
||||||
|
|
||||||
|
|
|
@ -10,5 +10,6 @@
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
|
#define NOMINMAX // Don't include windows min/max definitions
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
|
@ -5,8 +5,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#define _WIN32_WINNT 0x501
|
#define _WIN32_WINNT 0x501
|
||||||
#ifndef _WIN32_IE
|
#ifndef _WIN32_IE
|
||||||
#define _WIN32_IE 0x0500 // Default value is 0x0400
|
#define _WIN32_IE 0x0500 // Default value is 0x0400
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define NOMINMAX // Don't include windows min/max definitions
|
||||||
|
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
|
@ -5,8 +5,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#define _WIN32_WINNT 0x501
|
#define _WIN32_WINNT 0x501
|
||||||
#ifndef _WIN32_IE
|
#ifndef _WIN32_IE
|
||||||
#define _WIN32_IE 0x0500 // Default value is 0x0400
|
#define _WIN32_IE 0x0500 // Default value is 0x0400
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define NOMINMAX // Don't include windows min/max definitions
|
||||||
|
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
// Licensed under GPLv2
|
// Licensed under GPLv2
|
||||||
// Refer to the license.txt file included.
|
// 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/BPMemLoader.h"
|
||||||
#include "VideoBackends/Software/EfbInterface.h"
|
#include "VideoBackends/Software/EfbInterface.h"
|
||||||
#include "VideoBackends/Software/HwRasterizer.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 *uv1 = rasterBlock.Pixel[1][0].Uv[texcoord];
|
||||||
float *uv2 = rasterBlock.Pixel[0][1].Uv[texcoord];
|
float *uv2 = rasterBlock.Pixel[0][1].Uv[texcoord];
|
||||||
|
|
||||||
sDelta = max(fabsf(uv0[0] - uv1[0]), fabsf(uv0[0] - uv2[0]));
|
sDelta = std::max(fabsf(uv0[0] - uv1[0]), fabsf(uv0[0] - uv2[0]));
|
||||||
tDelta = max(fabsf(uv0[1] - uv1[1]), fabsf(uv0[1] - uv2[1]));
|
tDelta = std::max(fabsf(uv0[1] - uv1[1]), fabsf(uv0[1] - uv2[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// get LOD in s28.4
|
// get LOD in s28.4
|
||||||
lod = FixedLog2(max(sDelta, tDelta));
|
lod = FixedLog2(std::max(sDelta, tDelta));
|
||||||
|
|
||||||
// bias is s2.5
|
// bias is s2.5
|
||||||
int bias = tm0.lod_bias;
|
int bias = tm0.lod_bias;
|
||||||
|
@ -349,16 +350,16 @@ void DrawTriangleFrontFace(OutputVertexData *v0, OutputVertexData *v1, OutputVer
|
||||||
const s32 FDY31 = DY31 << 4;
|
const s32 FDY31 = DY31 << 4;
|
||||||
|
|
||||||
// Bounding rectangle
|
// Bounding rectangle
|
||||||
s32 minx = (min(min(X1, X2), X3) + 0xF) >> 4;
|
s32 minx = (std::min(std::min(X1, X2), X3) + 0xF) >> 4;
|
||||||
s32 maxx = (max(max(X1, X2), X3) + 0xF) >> 4;
|
s32 maxx = (std::max(std::max(X1, X2), X3) + 0xF) >> 4;
|
||||||
s32 miny = (min(min(Y1, Y2), Y3) + 0xF) >> 4;
|
s32 miny = (std::min(std::min(Y1, Y2), Y3) + 0xF) >> 4;
|
||||||
s32 maxy = (max(max(Y1, Y2), Y3) + 0xF) >> 4;
|
s32 maxy = (std::max(std::max(Y1, Y2), Y3) + 0xF) >> 4;
|
||||||
|
|
||||||
// scissor
|
// scissor
|
||||||
minx = max(minx, scissorLeft);
|
minx = std::max(minx, scissorLeft);
|
||||||
maxx = min(maxx, scissorRight);
|
maxx = std::min(maxx, scissorRight);
|
||||||
miny = max(miny, scissorTop);
|
miny = std::max(miny, scissorTop);
|
||||||
maxy = min(maxy, scissorBottom);
|
maxy = std::min(maxy, scissorBottom);
|
||||||
|
|
||||||
if (minx >= maxx || miny >= maxy)
|
if (minx >= maxx || miny >= maxy)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
// Licensed under GPLv2
|
// Licensed under GPLv2
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "Common/Common.h"
|
#include "Common/Common.h"
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
#include "VideoBackends/OGL/GLUtil.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
|
// We do the inverse BT.601 conversion for YCbCr to RGB
|
||||||
// http://www.equasys.de/colorconversion.html#YCbCr-RGBColorFormatConversion
|
// 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++] = std::min<u8>(255.0f, std::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++] = std::min<u8>(255.0f, std::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 + 2.017f * U ));
|
||||||
TexturePointer[offset++] = 255;
|
TexturePointer[offset++] = 255;
|
||||||
|
|
||||||
TexturePointer[offset++] = (u8)min(255.0f, max(0.0f, 1.164f * Y2 + 1.596f * V));
|
TexturePointer[offset++] = std::min<u8>(255.0f, std::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++] = std::min<u8>(255.0f, std::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 + 2.017f * U ));
|
||||||
TexturePointer[offset++] = 255;
|
TexturePointer[offset++] = 255;
|
||||||
}
|
}
|
||||||
xfb += fbWidth;
|
xfb += fbWidth;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under GPLv2
|
// Licensed under GPLv2
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "Core/HW/Memmap.h"
|
#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)
|
while (mip)
|
||||||
{
|
{
|
||||||
mipWidth = max(mipWidth, fmtWidth);
|
mipWidth = std::max(mipWidth, fmtWidth);
|
||||||
mipHeight = max(mipHeight, fmtHeight);
|
mipHeight = std::max(mipHeight, fmtHeight);
|
||||||
u32 size = (mipWidth * mipHeight * fmtDepth) >> 1;
|
u32 size = (mipWidth * mipHeight * fmtDepth) >> 1;
|
||||||
|
|
||||||
imageSrc += size;
|
imageSrc += size;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under GPLv2
|
// Licensed under GPLv2
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "Common/Common.h"
|
#include "Common/Common.h"
|
||||||
|
@ -229,7 +230,7 @@ void LightColor(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChann
|
||||||
case LIGHTDIF_CLAMP:
|
case LIGHTDIF_CLAMP:
|
||||||
{
|
{
|
||||||
Vec3 ldir = (light->pos - pos).normalized();
|
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);
|
AddScaledIntegerColor(light->color, diffuse, lightCol);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -247,21 +248,21 @@ void LightColor(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChann
|
||||||
float dist2 = ldir.length2();
|
float dist2 = ldir.length2();
|
||||||
float dist = sqrtf(dist2);
|
float dist = sqrtf(dist2);
|
||||||
ldir = ldir / dist;
|
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 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);
|
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
|
else if (chan.attnfunc == 1) // specular
|
||||||
{
|
{
|
||||||
// donko - what is going on here? 655.36 is a guess but seems about right.
|
// 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);
|
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;
|
float distAtt = light->distatt * ldir;
|
||||||
attn = SafeDivide(max(0.0f, cosAtt), distAtt);
|
attn = SafeDivide(std::max(0.0f, cosAtt), distAtt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -283,7 +284,7 @@ void LightColor(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChann
|
||||||
|
|
||||||
case LIGHTDIF_CLAMP:
|
case LIGHTDIF_CLAMP:
|
||||||
{
|
{
|
||||||
float difAttn = max(0.0f, ldir * normal);
|
float difAttn = std::max(0.0f, ldir * normal);
|
||||||
AddScaledIntegerColor(light->color, attn * difAttn, lightCol);
|
AddScaledIntegerColor(light->color, attn * difAttn, lightCol);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -314,7 +315,7 @@ void LightAlpha(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChann
|
||||||
case LIGHTDIF_CLAMP:
|
case LIGHTDIF_CLAMP:
|
||||||
{
|
{
|
||||||
Vec3 ldir = (light->pos - pos).normalized();
|
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;
|
lightCol += light->color[0] * diffuse;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -331,21 +332,21 @@ void LightAlpha(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChann
|
||||||
float dist2 = ldir.length2();
|
float dist2 = ldir.length2();
|
||||||
float dist = sqrtf(dist2);
|
float dist = sqrtf(dist2);
|
||||||
ldir = ldir / dist;
|
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 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);
|
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
|
else /* if (chan.attnfunc == 1) */ // specular
|
||||||
{
|
{
|
||||||
// donko - what is going on here? 655.36 is a guess but seems about right.
|
// 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);
|
ldir.set(1.0f, attn, attn * attn);
|
||||||
|
|
||||||
float cosAtt = light->cosatt * ldir;
|
float cosAtt = light->cosatt * ldir;
|
||||||
float distAtt = light->distatt * ldir;
|
float distAtt = light->distatt * ldir;
|
||||||
attn = SafeDivide(max(0.0f, cosAtt), distAtt);
|
attn = SafeDivide(std::max(0.0f, cosAtt), distAtt);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (chan.diffusefunc)
|
switch (chan.diffusefunc)
|
||||||
|
@ -362,7 +363,7 @@ void LightAlpha(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChann
|
||||||
|
|
||||||
case LIGHTDIF_CLAMP:
|
case LIGHTDIF_CLAMP:
|
||||||
{
|
{
|
||||||
float difAttn = max(0.0f, ldir * normal);
|
float difAttn = std::max(0.0f, ldir * normal);
|
||||||
lightCol += light->color[0] * attn * difAttn;
|
lightCol += light->color[0] * attn * difAttn;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -5,9 +5,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#define _WIN32_WINNT 0x501
|
#define _WIN32_WINNT 0x501
|
||||||
#ifndef _WIN32_IE
|
#ifndef _WIN32_IE
|
||||||
#define _WIN32_IE 0x0500 // Default value is 0x0400
|
#define _WIN32_IE 0x0500 // Default value is 0x0400
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define NOMINMAX // Don't include windows min/max definitions
|
||||||
|
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
// Licensed under GPLv2
|
// Licensed under GPLv2
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
#include "Common/MemoryUtil.h"
|
#include "Common/MemoryUtil.h"
|
||||||
|
|
||||||
|
@ -386,7 +388,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int const stage,
|
||||||
|
|
||||||
// D3D doesn't like when the specified mipmap count would require more than one 1x1-sized LOD in the mipmap chain
|
// D3D doesn't like when the specified mipmap count would require more than one 1x1-sized LOD in the mipmap chain
|
||||||
// e.g. 64x64 with 7 LODs would have the mipmap chain 64x64,32x32,16x16,8x8,4x4,2x2,1x1,1x1, so we limit the mipmap count to 6 there
|
// e.g. 64x64 with 7 LODs would have the mipmap chain 64x64,32x32,16x16,8x8,4x4,2x2,1x1,1x1, so we limit the mipmap count to 6 there
|
||||||
while (g_ActiveConfig.backend_info.bUseMinimalMipCount && max(expandedWidth, expandedHeight) >> maxlevel == 0)
|
while (g_ActiveConfig.backend_info.bUseMinimalMipCount && std::max(expandedWidth, expandedHeight) >> maxlevel == 0)
|
||||||
--maxlevel;
|
--maxlevel;
|
||||||
|
|
||||||
TCacheEntryBase *entry = textures[texID];
|
TCacheEntryBase *entry = textures[texID];
|
||||||
|
|
|
@ -1,20 +1,8 @@
|
||||||
// Copyright (C) 2003 Dolphin Project.
|
// Copyright 2014 Dolphin Emulator Project
|
||||||
|
// Licensed under GPLv2
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// Refer to the license.txt file included.
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, version 2.0.
|
|
||||||
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License 2.0 for more details.
|
|
||||||
|
|
||||||
// A copy of the GPL 2.0 should have been included with the program.
|
|
||||||
// If not, see http://www.gnu.org/licenses/
|
|
||||||
|
|
||||||
// Official SVN repository and contact information can be found at
|
|
||||||
// http://code.google.com/p/dolphin-emu/
|
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "Common/Common.h"
|
#include "Common/Common.h"
|
||||||
|
@ -1055,8 +1043,8 @@ PC_TexFormat TexDecoder_Decode(u8 *dst, const u8 *src, int width, int height, in
|
||||||
if ((!TexFmt_Overlay_Enable) || (retval == PC_TEX_FMT_NONE))
|
if ((!TexFmt_Overlay_Enable) || (retval == PC_TEX_FMT_NONE))
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
int w = min(width, 40);
|
int w = std::min(width, 40);
|
||||||
int h = min(height, 10);
|
int h = std::min(height, 10);
|
||||||
|
|
||||||
int xoff = (width - w) >> 1;
|
int xoff = (width - w) >> 1;
|
||||||
int yoff = (height - h) >> 1;
|
int yoff = (height - h) >> 1;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under GPLv2
|
// Licensed under GPLv2
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "Common/Common.h"
|
#include "Common/Common.h"
|
||||||
|
@ -2037,8 +2038,8 @@ PC_TexFormat TexDecoder_Decode(u8 *dst, const u8 *src, int width, int height, in
|
||||||
if ((!TexFmt_Overlay_Enable) || (retval == PC_TEX_FMT_NONE))
|
if ((!TexFmt_Overlay_Enable) || (retval == PC_TEX_FMT_NONE))
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
int w = min(width, 40);
|
int w = std::min(width, 40);
|
||||||
int h = min(height, 10);
|
int h = std::min(height, 10);
|
||||||
|
|
||||||
int xoff = (width - w) >> 1;
|
int xoff = (width - w) >> 1;
|
||||||
int yoff = (height - h) >> 1;
|
int yoff = (height - h) >> 1;
|
||||||
|
|
|
@ -6,9 +6,10 @@
|
||||||
|
|
||||||
#define _WIN32_WINNT 0x501
|
#define _WIN32_WINNT 0x501
|
||||||
#ifndef _WIN32_IE
|
#ifndef _WIN32_IE
|
||||||
#define _WIN32_IE 0x0500 // Default value is 0x0400
|
#define _WIN32_IE 0x0500 // Default value is 0x0400
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
|
#define NOMINMAX // Don't include windows min/max definitions
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
|
@ -28,15 +28,6 @@ TEST(CommonFuncs, CrashMacro)
|
||||||
EXPECT_DEATH({ Crash(); }, "");
|
EXPECT_DEATH({ Crash(); }, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CommonFuncs, MinMax)
|
|
||||||
{
|
|
||||||
EXPECT_EQ(4, min(4, 5));
|
|
||||||
EXPECT_EQ(-1, min(-1, 1));
|
|
||||||
|
|
||||||
EXPECT_EQ(5, max(4, 5));
|
|
||||||
EXPECT_EQ(1, max(-1, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(CommonFuncs, Swap)
|
TEST(CommonFuncs, Swap)
|
||||||
{
|
{
|
||||||
EXPECT_EQ(0xf0, Common::swap8(0xf0));
|
EXPECT_EQ(0xf0, Common::swap8(0xf0));
|
||||||
|
|
Loading…
Reference in New Issue