From cbe119b457eb2d2b3a5f518ca7147ff54416f172 Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Sat, 2 Apr 2016 00:02:05 +0200 Subject: [PATCH] rsx/common: Remove MIN2/MAX2 macro. --- rpcs3/Emu/RSX/Common/BufferUtils.cpp | 35 ++++++++++++--------------- rpcs3/Emu/RSX/Common/TextureUtils.cpp | 12 ++++----- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.cpp b/rpcs3/Emu/RSX/Common/BufferUtils.cpp index 56d6461d9b..cce0c90075 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.cpp +++ b/rpcs3/Emu/RSX/Common/BufferUtils.cpp @@ -2,9 +2,6 @@ #include "BufferUtils.h" #include "../rsx_methods.h" -#define MIN2(x, y) ((x) < (y)) ? (x) : (y) -#define MAX2(x, y) ((x) > (y)) ? (x) : (y) - namespace { // FIXME: GSL as_span break build if template parameter is non const with current revision. @@ -114,8 +111,8 @@ std::tuple upload_untouched(gsl::span> src, gsl::span } else { - max_index = MAX2(max_index, index); - min_index = MIN2(min_index, index); + max_index = std::max(max_index, index); + min_index = std::min(min_index, index); } dst[dst_idx++] = index; } @@ -134,8 +131,8 @@ std::tuple expand_indexed_triangle_fan(gsl::span> src, gs const T index0 = src[0]; if (!is_primitive_restart_enabled || index0 != -1) // Cut { - min_index = MIN2(min_index, index0); - max_index = MAX2(max_index, index0); + min_index = std::min(min_index, index0); + max_index = std::max(max_index, index0); } size_t dst_idx = 0; @@ -149,8 +146,8 @@ std::tuple expand_indexed_triangle_fan(gsl::span> src, gs } else { - min_index = MIN2(min_index, index1); - max_index = MAX2(max_index, index1); + min_index = std::min(min_index, index1); + max_index = std::max(max_index, index1); } T index2 = tri_indexes[1]; if (is_primitive_restart_enabled && index2 == primitive_restart_index) @@ -159,8 +156,8 @@ std::tuple expand_indexed_triangle_fan(gsl::span> src, gs } else { - min_index = MIN2(min_index, index2); - max_index = MAX2(max_index, index2); + min_index = std::min(min_index, index2); + max_index = std::max(max_index, index2); } dst[dst_idx++] = index0; @@ -192,8 +189,8 @@ std::tuple expand_indexed_quads(gsl::span> src, gsl::span } else { - min_index = MIN2(min_index, index0); - max_index = MAX2(max_index, index0); + min_index = std::min(min_index, index0); + max_index = std::max(max_index, index0); } T index1 = quad_indexes[1]; if (is_primitive_restart_enabled && index1 == primitive_restart_index) @@ -202,8 +199,8 @@ std::tuple expand_indexed_quads(gsl::span> src, gsl::span } else { - min_index = MIN2(min_index, index1); - max_index = MAX2(max_index, index1); + min_index = std::min(min_index, index1); + max_index = std::max(max_index, index1); } T index2 = quad_indexes[2]; if (is_primitive_restart_enabled && index2 == primitive_restart_index) @@ -212,8 +209,8 @@ std::tuple expand_indexed_quads(gsl::span> src, gsl::span } else { - min_index = MIN2(min_index, index2); - max_index = MAX2(max_index, index2); + min_index = std::min(min_index, index2); + max_index = std::max(max_index, index2); } T index3 = quad_indexes[3]; if (is_primitive_restart_enabled &&index3 == primitive_restart_index) @@ -222,8 +219,8 @@ std::tuple expand_indexed_quads(gsl::span> src, gsl::span } else { - min_index = MIN2(min_index, index3); - max_index = MAX2(max_index, index3); + min_index = std::min(min_index, index3); + max_index = std::max(max_index, index3); } // First triangle diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.cpp b/rpcs3/Emu/RSX/Common/TextureUtils.cpp index 7d0f478f65..f39c06601b 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.cpp +++ b/rpcs3/Emu/RSX/Common/TextureUtils.cpp @@ -5,7 +5,6 @@ #include "../rsx_utils.h" -#define MAX2(a, b) ((a) > (b)) ? (a) : (b) namespace { // FIXME: GSL as_span break build if template parameter is non const with current revision. @@ -101,8 +100,8 @@ namespace result.push_back(current_subresource_layout); offset_in_src += miplevel_height_in_block * src_pitch_in_block * block_size_in_bytes * depth; - miplevel_height_in_block = MAX2(miplevel_height_in_block / 2, 1); - miplevel_width_in_block = MAX2(miplevel_width_in_block / 2, 1); + miplevel_height_in_block = std::max(miplevel_height_in_block / 2, 1); + miplevel_width_in_block = std::max(miplevel_width_in_block / 2, 1); } offset_in_src = align(offset_in_src, 128); } @@ -343,7 +342,7 @@ u8 get_format_block_size_in_texel(int format) size_t get_placed_texture_storage_size(const rsx::texture &texture, size_t rowPitchAlignement, size_t mipmapAlignment) { - size_t w = texture.width(), h = texture.height(), d = MAX2(texture.depth(), 1); + size_t w = texture.width(), h = texture.height(), d = std::max(texture.depth(), 1); int format = texture.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); size_t blockEdge = get_format_block_size_in_texel(format); @@ -352,14 +351,13 @@ size_t get_placed_texture_storage_size(const rsx::texture &texture, size_t rowPi size_t heightInBlocks = (h + blockEdge - 1) / blockEdge; size_t widthInBlocks = (w + blockEdge - 1) / blockEdge; - size_t result = 0; for (unsigned mipmap = 0; mipmap < texture.mipmap(); ++mipmap) { size_t rowPitch = align(blockSizeInByte * widthInBlocks, rowPitchAlignement); result += align(rowPitch * heightInBlocks * d, mipmapAlignment); - heightInBlocks = MAX2(heightInBlocks / 2, 1); - widthInBlocks = MAX2(widthInBlocks / 2, 1); + heightInBlocks = std::max(heightInBlocks / 2, 1); + widthInBlocks = std::max(widthInBlocks / 2, 1); } return result * (texture.cubemap() ? 6 : 1);