diff --git a/rpcs3/Emu/CPU/CPUTranslator.cpp b/rpcs3/Emu/CPU/CPUTranslator.cpp index df09467a22..d0b7741270 100644 --- a/rpcs3/Emu/CPU/CPUTranslator.cpp +++ b/rpcs3/Emu/CPU/CPUTranslator.cpp @@ -149,27 +149,27 @@ llvm::Constant* cpu_translator::make_const_vector(v128 v, llvm::Type* t) if (sct->isIntegerTy(8)) { - return llvm::ConstantDataVector::get(m_context, llvm::makeArrayRef((const u8*)v._bytes, 16)); + return llvm::ConstantDataVector::get(m_context, llvm::makeArrayRef(reinterpret_cast(v._bytes), 16)); } else if (sct->isIntegerTy(16)) { - return llvm::ConstantDataVector::get(m_context, llvm::makeArrayRef((const u16*)v._bytes, 8)); + return llvm::ConstantDataVector::get(m_context, llvm::makeArrayRef(reinterpret_cast(v._bytes), 8)); } else if (sct->isIntegerTy(32)) { - return llvm::ConstantDataVector::get(m_context, llvm::makeArrayRef((const u32*)v._bytes, 4)); + return llvm::ConstantDataVector::get(m_context, llvm::makeArrayRef(reinterpret_cast(v._bytes), 4)); } else if (sct->isIntegerTy(64)) { - return llvm::ConstantDataVector::get(m_context, llvm::makeArrayRef((const u64*)v._bytes, 2)); + return llvm::ConstantDataVector::get(m_context, llvm::makeArrayRef(reinterpret_cast(v._bytes), 2)); } else if (sct->isFloatTy()) { - return llvm::ConstantDataVector::get(m_context, llvm::makeArrayRef((const f32*)v._bytes, 4)); + return llvm::ConstantDataVector::get(m_context, llvm::makeArrayRef(reinterpret_cast(v._bytes), 4)); } else if (sct->isDoubleTy()) { - return llvm::ConstantDataVector::get(m_context, llvm::makeArrayRef((const f64*)v._bytes, 2)); + return llvm::ConstantDataVector::get(m_context, llvm::makeArrayRef(reinterpret_cast(v._bytes), 2)); } fmt::raw_error("No supported constant type" HERE); diff --git a/rpcs3/Emu/RSX/Capture/rsx_capture.cpp b/rpcs3/Emu/RSX/Capture/rsx_capture.cpp index 46f4b4f7a9..7c4eb69a73 100644 --- a/rpcs3/Emu/RSX/Capture/rsx_capture.cpp +++ b/rpcs3/Emu/RSX/Capture/rsx_capture.cpp @@ -207,11 +207,11 @@ namespace rsx for (u32 i = 0; i < idxCount; ++i) { u16 index = fifo[i]; - if (is_primitive_restart_enabled && (u32)index == primitive_restart_index) + if (is_primitive_restart_enabled && u32{index} == primitive_restart_index) continue; - index = (u16)get_index_from_base(index, method_registers.vertex_data_base_index()); - min_index = (u16)std::min(index, (u16)min_index); - max_index = (u16)std::max(index, (u16)max_index); + index = static_cast(get_index_from_base(index, method_registers.vertex_data_base_index())); + min_index = std::min(index, static_cast(min_index)); + max_index = std::max(index, static_cast(max_index)); } break; } @@ -304,7 +304,7 @@ namespace rsx block.location = src_dma & 0xf; const auto src_address = rsx::get_address(block.offset, block.location); - u8* pixels_src = (u8*)vm::base(src_address); + u8* pixels_src = vm::_ptr(src_address); const u32 src_size = in_pitch * (in_h - 1) + (in_w * in_bpp); rsx->read_barrier(src_address, src_size, true); diff --git a/rpcs3/Emu/RSX/Capture/rsx_replay.cpp b/rpcs3/Emu/RSX/Capture/rsx_replay.cpp index f002d23d76..a1b4a7d836 100644 --- a/rpcs3/Emu/RSX/Capture/rsx_replay.cpp +++ b/rpcs3/Emu/RSX/Capture/rsx_replay.cpp @@ -134,7 +134,7 @@ namespace rsx cs.buffer_state.buffers[i] = buf; sys_rsx_context_attribute(context_id, 0x104, i, - (u64)dbstate.buffers[i].width << 32 | dbstate.buffers[i].height, (u64)dbstate.buffers[i].pitch << 32 | dbstate.buffers[i].offset, 0); + u64{dbstate.buffers[i].width} << 32 | dbstate.buffers[i].height, u64{dbstate.buffers[i].pitch} << 32 | dbstate.buffers[i].offset, 0); } cs.display_buffer_hash = replay_cmd.display_buffer_state; } @@ -153,7 +153,7 @@ namespace rsx continue; cs.tile_state.tiles[i] = ti; - sys_rsx_context_attribute(context_id, 0x300, i, (u64)ti.tile << 32 | ti.limit, (u64)ti.pitch << 32 | ti.format, 0); + sys_rsx_context_attribute(context_id, 0x300, i, u64{ti.tile} << 32 | ti.limit, u64{ti.pitch} << 32 | ti.format, 0); } for (u32 i = 0; i < limits::zculls_count; ++i) @@ -163,7 +163,7 @@ namespace rsx continue; cs.tile_state.zculls[i] = zci; - sys_rsx_context_attribute(context_id, 0x301, i, (u64)zci.region << 32 | zci.size, (u64)zci.start << 32 | zci.offset, (u64)zci.status0 << 32 | zci.status1); + sys_rsx_context_attribute(context_id, 0x301, i, u64{zci.region} << 32 | zci.size, u64{zci.start} << 32 | zci.offset, u64{zci.status0} << 32 | zci.status1); } cs.tile_hash = replay_cmd.tile_state; diff --git a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp index fb8323834d..2fb357e951 100644 --- a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp @@ -213,7 +213,7 @@ std::string FragmentProgramDecompiler::AddConst() return name; } - auto data = (be_t*) ((char*)m_prog.addr + m_size + 4 * u32{sizeof(u32)}); + auto data = reinterpret_cast*>(static_cast(m_prog.addr) + m_size + 4 * sizeof(u32)); m_offset = 2 * 4 * sizeof(u32); u32 x = GetData(data[0]); u32 y = GetData(data[1]); @@ -1072,7 +1072,7 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode) std::string FragmentProgramDecompiler::Decompile() { - auto data = (be_t*) m_prog.addr; + auto data = static_cast*>(m_prog.addr); m_size = 0; m_location = 0; m_loop_count = 0; diff --git a/rpcs3/Emu/RSX/Common/TextGlyphs.h b/rpcs3/Emu/RSX/Common/TextGlyphs.h index 6ef6341021..f0ce18316d 100644 --- a/rpcs3/Emu/RSX/Common/TextGlyphs.h +++ b/rpcs3/Emu/RSX/Common/TextGlyphs.h @@ -213,7 +213,7 @@ public: for (auto &entry : glyph_map) { - entry.glyph_point_offset = (u32)result.size(); + entry.glyph_point_offset = ::size32(result); for (std::size_t j = 0; j < entry.plot.size(); ++j) { @@ -226,14 +226,14 @@ public: if (line & (1 << i)) { // Font is inverted, so we correct it for conventional renderers - const auto x = (float)(7 - i); - const auto y = (float)(15 - j); + const auto x = static_cast(7 - i); + const auto y = static_cast(15 - j); result.emplace_back(x, y); } } } - entry.points_count = (u32)result.size() - entry.glyph_point_offset; + entry.points_count = ::size32(result) - entry.glyph_point_offset; } return result; diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.cpp b/rpcs3/Emu/RSX/Common/TextureUtils.cpp index daeed5b856..d74236a6ba 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.cpp +++ b/rpcs3/Emu/RSX/Common/TextureUtils.cpp @@ -29,13 +29,13 @@ namespace template gsl::span as_span_workaround(gsl::span unformated_span) { - return{ (T*)unformated_span.data(), unformated_span.size_bytes() / sizeof(T) }; + return{ reinterpret_cast(unformated_span.data()), unformated_span.size_bytes() / sizeof(T) }; } template gsl::span as_const_span(gsl::span unformated_span) { - return{ (T*)unformated_span.data(), unformated_span.size_bytes() / sizeof(T) }; + return{ reinterpret_cast(unformated_span.data()), unformated_span.size_bytes() / sizeof(T) }; } // TODO: Make this function part of GSL @@ -106,7 +106,7 @@ struct copy_unmodified_block_swizzled { if (std::is_same::value && dst_pitch_in_block == width_in_block && words_per_block == 1 && !border) { - rsx::convert_linear_swizzle_3d((void*)src.data(), (void*)dst.data(), width_in_block, row_count, depth); + rsx::convert_linear_swizzle_3d(src.data(), dst.data(), width_in_block, row_count, depth); } else { @@ -127,20 +127,20 @@ struct copy_unmodified_block_swizzled if (LIKELY(words_per_block == 1)) { - rsx::convert_linear_swizzle_3d((void*)src.data(), tmp.data(), padded_width, padded_height, depth); + rsx::convert_linear_swizzle_3d(src.data(), tmp.data(), padded_width, padded_height, depth); } else { switch (words_per_block * sizeof(T)) { case 4: - rsx::convert_linear_swizzle_3d((void*)src.data(), tmp.data(), padded_width, padded_height, depth); + rsx::convert_linear_swizzle_3d(src.data(), tmp.data(), padded_width, padded_height, depth); break; case 8: - rsx::convert_linear_swizzle_3d((void*)src.data(), tmp.data(), padded_width, padded_height, depth); + rsx::convert_linear_swizzle_3d(src.data(), tmp.data(), padded_width, padded_height, depth); break; case 16: - rsx::convert_linear_swizzle_3d((void*)src.data(), tmp.data(), padded_width, padded_height, depth); + rsx::convert_linear_swizzle_3d(src.data(), tmp.data(), padded_width, padded_height, depth); break; default: fmt::throw_exception("Failed to decode swizzled format, words_per_block=%d, src_type_size=%d", words_per_block, sizeof(T)); @@ -303,7 +303,7 @@ struct copy_rgb655_block_swizzled u32 size = padded_width * padded_height * depth * 2; std::vector tmp(size); - rsx::convert_linear_swizzle_3d((void*)src.data(), tmp.data(), padded_width, padded_height, depth); + rsx::convert_linear_swizzle_3d(src.data(), tmp.data(), padded_width, padded_height, depth); gsl::span src_span = tmp; copy_rgb655_block::copy_mipmap_level(dst, src_span, width_in_block, row_count, depth, border, dst_pitch_in_block, padded_width); @@ -687,7 +687,7 @@ texture_memory_info upload_texture_subresource(gsl::span dst_buffer, else if (word_size == 4) { result.require_deswizzle = (is_swizzled && caps.supports_hw_deswizzle); - + if (is_swizzled && !caps.supports_hw_deswizzle) copy_unmodified_block_swizzled::copy_mipmap_level(as_span_workaround(dst_buffer), as_const_span(src_layout.data), words_per_block, w, h, depth, src_layout.border, dst_pitch_in_block); else @@ -818,7 +818,7 @@ u8 get_format_block_size_in_bytes(rsx::surface_color_format format) case rsx::surface_color_format::w32z32y32x32: return 16; default: - fmt::throw_exception("Invalid color format 0x%x" HERE, (u32)format); + fmt::throw_exception("Invalid color format 0x%x" HERE, static_cast(format)); } } @@ -890,7 +890,7 @@ size_t get_placed_texture_storage_size(u16 width, u16 height, u32 depth, u8 form } // Mipmap, height and width aren't allowed to be zero - return verify("Texture params" HERE, result) * (cubemap ? 6 : 1); + return verify("Texture params" HERE, result) * (cubemap ? 6 : 1); } size_t get_placed_texture_storage_size(const rsx::fragment_texture &texture, size_t row_pitch_alignment, size_t mipmap_alignment) @@ -1026,7 +1026,7 @@ std::pair get_compatible_gcm_format(rsx::surface_color_format format) case rsx::surface_color_format::x32: return{ CELL_GCM_TEXTURE_X32_FLOAT, true }; //verified default: - fmt::throw_exception("Unhandled surface format 0x%x", (u32)format); + fmt::throw_exception("Unhandled surface format 0x%x", static_cast(format)); } } diff --git a/rpcs3/Emu/RSX/Common/surface_store.h b/rpcs3/Emu/RSX/Common/surface_store.h index 8803d63b3f..6e212ecd57 100644 --- a/rpcs3/Emu/RSX/Common/surface_store.h +++ b/rpcs3/Emu/RSX/Common/surface_store.h @@ -496,7 +496,7 @@ namespace rsx if (Traits::surface_is_pitch_compatible(aliased_surface->second, pitch)) { auto surface = Traits::get(aliased_surface->second); - split_surface_region(command_list, address, surface, (u16)width, (u16)height, bpp, antialias); + split_surface_region(command_list, address, surface, static_cast(width), static_cast(height), bpp, antialias); if (!old_surface || old_surface->last_use_tag < surface->last_use_tag) { diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index 6d125a4416..745cdaea54 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -938,7 +938,7 @@ namespace rsx { auto &tex = *It; - if (!tex.is_dirty() && (context_mask & (u32)tex.get_context())) + if (!tex.is_dirty() && (context_mask & static_cast(tex.get_context()))) { if constexpr (check_unlocked) { @@ -1362,7 +1362,7 @@ namespace rsx desc.external_handle, surface_transform::coordinate_transform, 0, - 0, (u16)(desc.slice_h * n), + 0, static_cast(desc.slice_h * n), 0, 0, n, desc.width, desc.height, desc.width, desc.height @@ -1388,7 +1388,7 @@ namespace rsx desc.external_handle, surface_transform::coordinate_transform, 0, - 0, (u16)(desc.slice_h * n), + 0, static_cast(desc.slice_h * n), 0, 0, n, desc.width, desc.height, desc.width, desc.height @@ -1417,7 +1417,7 @@ namespace rsx default: { //Throw - fmt::throw_exception("Invalid deferred command op 0x%X" HERE, (u32)desc.op); + fmt::throw_exception("Invalid deferred command op 0x%X" HERE, static_cast(desc.op)); } } @@ -1730,14 +1730,14 @@ namespace rsx case rsx::texture_dimension_extended::texture_dimension_cubemap: attributes.depth = 6; subsurface_count = 1; - tex_size = (u32)get_texture_size(tex); + tex_size = static_cast(get_texture_size(tex)); required_surface_height = tex_size / attributes.pitch; attributes.slice_h = required_surface_height / attributes.depth; break; case rsx::texture_dimension_extended::texture_dimension_3d: attributes.depth = tex.depth(); subsurface_count = 1; - tex_size = (u32)get_texture_size(tex); + tex_size = static_cast(get_texture_size(tex)); required_surface_height = tex_size / attributes.pitch; attributes.slice_h = required_surface_height / attributes.depth; break; @@ -1752,7 +1752,7 @@ namespace rsx } else { - LOG_ERROR(RSX, "Unimplemented unnormalized sampling for texture type %d", (u32)extended_dimension); + LOG_ERROR(RSX, "Unimplemented unnormalized sampling for texture type %d", static_cast(extended_dimension)); } } @@ -1872,7 +1872,7 @@ namespace rsx if (!tex_size) { - tex_size = (u32)get_texture_size(tex); + tex_size = static_cast(get_texture_size(tex)); } lock.upgrade(); @@ -1916,8 +1916,8 @@ namespace rsx // Offset in x and y for src is 0 (it is already accounted for when getting pixels_src) // Reproject final clip onto source... - u16 src_w = (u16)((f32)dst.clip_width / scale_x); - u16 src_h = (u16)((f32)dst.clip_height / scale_y); + u16 src_w = static_cast(dst.clip_width / scale_x); + u16 src_h = static_cast(dst.clip_height / scale_y); u16 dst_w = dst.clip_width; u16 dst_h = dst.clip_height; @@ -2100,7 +2100,7 @@ namespace rsx { // Enable type scaling in src typeless_info.src_is_typeless = true; - typeless_info.src_scaling_hint = (f32)bpp / src_bpp; + typeless_info.src_scaling_hint = static_cast(bpp) / src_bpp; typeless_info.src_gcm_format = helpers::get_sized_blit_format(src_is_argb8, false); } @@ -2126,7 +2126,7 @@ namespace rsx { // Enable type scaling in dst typeless_info.dst_is_typeless = true; - typeless_info.dst_scaling_hint = (f32)bpp / dst_bpp; + typeless_info.dst_scaling_hint = static_cast(bpp) / dst_bpp; typeless_info.dst_gcm_format = helpers::get_sized_blit_format(dst_is_argb8, false); } } @@ -2232,8 +2232,8 @@ namespace rsx } // Validate clipping region - if ((unsigned)dst_area.x2 <= surface->get_width() && - (unsigned)dst_area.y2 <= surface->get_height()) + if (static_cast(dst_area.x2) <= surface->get_width() && + static_cast(dst_area.y2) <= surface->get_height()) { cached_dest = surface; dest_texture = cached_dest->get_raw_texture(); @@ -2291,7 +2291,7 @@ namespace rsx typeless_info.dst_context = texture_upload_context::framebuffer_storage; dst_is_depth_surface = typeless_info.dst_is_typeless ? false : dst_subres.is_depth; - max_dst_width = (u16)(dst_subres.surface->get_surface_width(rsx::surface_metrics::samples) * typeless_info.dst_scaling_hint); + max_dst_width = static_cast(dst_subres.surface->get_surface_width(rsx::surface_metrics::samples) * typeless_info.dst_scaling_hint); max_dst_height = dst_subres.surface->get_surface_height(rsx::surface_metrics::samples); } @@ -2458,8 +2458,8 @@ namespace rsx // Reproject clip offsets onto source to simplify blit if (dst.clip_x || dst.clip_y) { - const u16 scaled_clip_offset_x = (const u16)((f32)dst.clip_x / (scale_x * typeless_info.src_scaling_hint)); - const u16 scaled_clip_offset_y = (const u16)((f32)dst.clip_y / scale_y); + const u16 scaled_clip_offset_x = static_cast(dst.clip_x / (scale_x * typeless_info.src_scaling_hint)); + const u16 scaled_clip_offset_y = static_cast(dst.clip_y / scale_y); src_area.x1 += scaled_clip_offset_x; src_area.x2 += scaled_clip_offset_x; @@ -2625,14 +2625,14 @@ namespace rsx { if (src_subres.surface->get_surface_width(rsx::surface_metrics::pixels) > g_cfg.video.min_scalable_dimension) { - src_area.x1 = (u16)(src_area.x1 * resolution_scale); - src_area.x2 = (u16)(src_area.x2 * resolution_scale); + src_area.x1 = static_cast(src_area.x1 * resolution_scale); + src_area.x2 = static_cast(src_area.x2 * resolution_scale); } if (src_subres.surface->get_surface_height(rsx::surface_metrics::pixels) > g_cfg.video.min_scalable_dimension) { - src_area.y1 = (u16)(src_area.y1 * resolution_scale); - src_area.y2 = (u16)(src_area.y2 * resolution_scale); + src_area.y1 = static_cast(src_area.y1 * resolution_scale); + src_area.y2 = static_cast(src_area.y2 * resolution_scale); } } @@ -2640,14 +2640,14 @@ namespace rsx { if (dst_subres.surface->get_surface_width(rsx::surface_metrics::pixels) > g_cfg.video.min_scalable_dimension) { - dst_area.x1 = (u16)(dst_area.x1 * resolution_scale); - dst_area.x2 = (u16)(dst_area.x2 * resolution_scale); + dst_area.x1 = static_cast(dst_area.x1 * resolution_scale); + dst_area.x2 = static_cast(dst_area.x2 * resolution_scale); } if (dst_subres.surface->get_surface_height(rsx::surface_metrics::pixels) > g_cfg.video.min_scalable_dimension) { - dst_area.y1 = (u16)(dst_area.y1 * resolution_scale); - dst_area.y2 = (u16)(dst_area.y2 * resolution_scale); + dst_area.y1 = static_cast(dst_area.y1 * resolution_scale); + dst_area.y2 = static_cast(dst_area.y2 * resolution_scale); } } } @@ -2819,7 +2819,7 @@ namespace rsx f32 get_cache_miss_ratio() const { const auto num_flushes = m_flushes_this_frame.load(); - return (num_flushes == 0u) ? 0.f : (f32)m_misses_this_frame.load() / num_flushes; + return (num_flushes == 0u) ? 0.f : static_cast(m_misses_this_frame.load()) / num_flushes; } }; } diff --git a/rpcs3/Emu/RSX/Common/texture_cache_helpers.h b/rpcs3/Emu/RSX/Common/texture_cache_helpers.h index f1bf23ace9..b979ddb846 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache_helpers.h +++ b/rpcs3/Emu/RSX/Common/texture_cache_helpers.h @@ -289,8 +289,8 @@ namespace rsx return; } - const auto slice_begin = u32(slice * attr.slice_h); - const auto slice_end = u32(slice_begin + attr.height); + const u32 slice_begin = slice * attr.slice_h; + const u32 slice_end = slice_begin + attr.height; const auto dst_y = std::get<1>(clipped).y; const auto dst_h = std::get<2>(clipped).height; @@ -302,9 +302,9 @@ namespace rsx return; } - const u16 dst_w = (u16)std::get<2>(clipped).width; - const u16 src_w = u16(dst_w * attr.bpp) / section_bpp; - const u16 height = (u16)std::get<2>(clipped).height; + const u16 dst_w = static_cast(std::get<2>(clipped).width); + const u16 src_w = static_cast(dst_w * attr.bpp) / section_bpp; + const u16 height = static_cast(std::get<2>(clipped).height); if (scaling) { @@ -314,10 +314,10 @@ namespace rsx section->get_raw_texture(), surface_transform::identity, 0, - (u16)std::get<0>(clipped).x, - (u16)std::get<0>(clipped).y, - rsx::apply_resolution_scale((u16)std::get<1>(clipped).x, true), - rsx::apply_resolution_scale((u16)std::get<1>(clipped).y, true), + static_cast(std::get<0>(clipped).x), + static_cast(std::get<0>(clipped).y), + rsx::apply_resolution_scale(static_cast(std::get<1>(clipped).x), true), + rsx::apply_resolution_scale(static_cast(std::get<1>(clipped).y), true), slice, src_w, height, @@ -332,10 +332,10 @@ namespace rsx section->get_raw_texture(), surface_transform::identity, 0, - (u16)std::get<0>(clipped).x, - (u16)std::get<0>(clipped).y, - (u16)std::get<1>(clipped).x, - (u16)std::get<1>(clipped).y, + static_cast(std::get<0>(clipped).x), + static_cast(std::get<0>(clipped).y), + static_cast(std::get<1>(clipped).x), + static_cast(std::get<1>(clipped).y), 0, src_w, height, diff --git a/rpcs3/Emu/RSX/GL/GLCompute.h b/rpcs3/Emu/RSX/GL/GLCompute.h index 147632d21b..85ae084a76 100644 --- a/rpcs3/Emu/RSX/GL/GLCompute.h +++ b/rpcs3/Emu/RSX/GL/GLCompute.h @@ -37,7 +37,7 @@ namespace gl optimal_group_size = 128; } - glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 0, (GLint*)&max_invocations_x); + glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 0, reinterpret_cast(&max_invocations_x)); } void create() @@ -79,7 +79,7 @@ namespace gl m_program.use(); glDispatchCompute(invocations_x, invocations_y, 1); - glUseProgram((GLuint)old_program); + glUseProgram(old_program); } void run(u32 num_invocations) @@ -93,7 +93,7 @@ namespace gl else { // Since all the invocations will run, the optimal distribution is sqrt(count) - const auto optimal_length = (u32)floor(std::sqrt(num_invocations)); + const u32 optimal_length = static_cast(floor(std::sqrt(num_invocations))); invocations_x = optimal_length; invocations_y = invocations_x; diff --git a/rpcs3/Emu/RSX/GL/GLExecutionState.h b/rpcs3/Emu/RSX/GL/GLExecutionState.h index 483fded64e..25475a5b98 100644 --- a/rpcs3/Emu/RSX/GL/GLExecutionState.h +++ b/rpcs3/Emu/RSX/GL/GLExecutionState.h @@ -146,7 +146,7 @@ namespace gl void clear_color(u8 r, u8 g, u8 b, u8 a) { - u32 value = (u32)r | (u32)g << 8 | (u32)b << 16 | (u32)a << 24; + u32 value = u32{r} | u32{g} << 8 | u32{b} << 16 | u32{a} << 24; if (!test_property(GL_COLOR_CLEAR_VALUE, value)) { glClearColor(r / 255.f, g / 255.f, b / 255.f, a / 255.f); @@ -156,7 +156,7 @@ namespace gl void clear_color(const color4f& color) { - clear_color(u8(color.r * 255), u8(color.g * 255), u8(color.b * 255), u8(color.a * 255)); + clear_color(static_cast(color.r * 255), static_cast(color.g * 255), static_cast(color.b * 255), static_cast(color.a * 255)); } void depth_bounds(float min, float max) diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index 363fd75a0a..516a96f4bd 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -59,7 +59,7 @@ namespace case rsx::comparison_function::greater_or_equal: return GL_GEQUAL; case rsx::comparison_function::always: return GL_ALWAYS; } - fmt::throw_exception("Unsupported comparison op 0x%X" HERE, (u32)op); + fmt::throw_exception("Unsupported comparison op 0x%X" HERE, static_cast(op)); } GLenum stencil_op(rsx::stencil_op op) @@ -75,7 +75,7 @@ namespace case rsx::stencil_op::incr_wrap: return GL_INCR_WRAP; case rsx::stencil_op::decr_wrap: return GL_DECR_WRAP; } - fmt::throw_exception("Unsupported stencil op 0x%X" HERE, (u32)op); + fmt::throw_exception("Unsupported stencil op 0x%X" HERE, static_cast(op)); } GLenum blend_equation(rsx::blend_equation op) @@ -94,7 +94,7 @@ namespace case rsx::blend_equation::reverse_substract: return GL_FUNC_REVERSE_SUBTRACT; case rsx::blend_equation::reverse_add_signed: default: - LOG_ERROR(RSX, "Blend equation 0x%X is unimplemented!", (u32)op); + LOG_ERROR(RSX, "Blend equation 0x%X is unimplemented!", static_cast(op)); return GL_FUNC_ADD; } } @@ -119,7 +119,7 @@ namespace case rsx::blend_factor::constant_alpha: return GL_CONSTANT_ALPHA; case rsx::blend_factor::one_minus_constant_alpha: return GL_ONE_MINUS_CONSTANT_ALPHA; } - fmt::throw_exception("Unsupported blend factor 0x%X" HERE, (u32)op); + fmt::throw_exception("Unsupported blend factor 0x%X" HERE, static_cast(op)); } GLenum logic_op(rsx::logic_op op) @@ -143,7 +143,7 @@ namespace case rsx::logic_op::logic_nand: return GL_NAND; case rsx::logic_op::logic_set: return GL_SET; } - fmt::throw_exception("Unsupported logic op 0x%X" HERE, (u32)op); + fmt::throw_exception("Unsupported logic op 0x%X" HERE, static_cast(op)); } GLenum front_face(rsx::front_face op) @@ -157,7 +157,7 @@ namespace case rsx::front_face::cw: return GL_CCW; case rsx::front_face::ccw: return GL_CW; } - fmt::throw_exception("Unsupported front face 0x%X" HERE, (u32)op); + fmt::throw_exception("Unsupported front face 0x%X" HERE, static_cast(op)); } GLenum cull_face(rsx::cull_face op) @@ -168,7 +168,7 @@ namespace case rsx::cull_face::back: return GL_BACK; case rsx::cull_face::front_and_back: return GL_FRONT_AND_BACK; } - fmt::throw_exception("Unsupported cull face 0x%X" HERE, (u32)op); + fmt::throw_exception("Unsupported cull face 0x%X" HERE, static_cast(op)); } } @@ -543,9 +543,9 @@ void GLGSRender::end() bool use_draw_arrays_fallback = false; m_scratch_buffer.resize(draw_count * 24); - GLint* firsts = (GLint*)m_scratch_buffer.data(); - GLsizei* counts = (GLsizei*)(firsts + draw_count); - const GLvoid** offsets = (const GLvoid**)(counts + draw_count); + GLint* firsts = reinterpret_cast(m_scratch_buffer.data()); + GLsizei* counts = (firsts + draw_count); + const GLvoid** offsets = reinterpret_cast(counts + draw_count); u32 first = 0; u32 dst_index = 0; @@ -553,7 +553,7 @@ void GLGSRender::end() { firsts[dst_index] = first; counts[dst_index] = range.count; - offsets[dst_index++] = (const GLvoid*)(u64(first << 2)); + offsets[dst_index++] = reinterpret_cast(u64{first << 2}); if (driver_caps.vendor_AMD && (first + range.count) > (0x100000 >> 2)) { @@ -577,12 +577,12 @@ void GLGSRender::end() { //Use identity index buffer to fix broken vertexID on AMD m_identity_index_buffer->bind(); - glMultiDrawElements(draw_mode, counts, GL_UNSIGNED_INT, offsets, (GLsizei)draw_count); + glMultiDrawElements(draw_mode, counts, GL_UNSIGNED_INT, offsets, static_cast(draw_count)); } else { //Normal render - glMultiDrawArrays(draw_mode, firsts, counts, (GLsizei)draw_count); + glMultiDrawArrays(draw_mode, firsts, counts, static_cast(draw_count)); } } } @@ -601,7 +601,7 @@ void GLGSRender::end() if (rsx::method_registers.current_draw_clause.is_single_draw()) { - glDrawElements(draw_mode, upload_info.vertex_draw_count, index_type, (GLvoid *)(uintptr_t)index_offset); + glDrawElements(draw_mode, upload_info.vertex_draw_count, index_type, reinterpret_cast(u64{index_offset})); } else { @@ -611,20 +611,20 @@ void GLGSRender::end() uintptr_t index_ptr = index_offset; m_scratch_buffer.resize(draw_count * 16); - GLsizei *counts = (GLsizei*)m_scratch_buffer.data(); - const GLvoid** offsets = (const GLvoid**)(counts + draw_count); + GLsizei *counts = reinterpret_cast(m_scratch_buffer.data()); + const GLvoid** offsets = reinterpret_cast(counts + draw_count); int dst_index = 0; for (const auto &range : subranges) { const auto index_size = get_index_count(rsx::method_registers.current_draw_clause.primitive, range.count); counts[dst_index] = index_size; - offsets[dst_index++] = (const GLvoid*)index_ptr; + offsets[dst_index++] = reinterpret_cast(index_ptr); index_ptr += (index_size << type_scale); } - glMultiDrawElements(draw_mode, counts, index_type, offsets, (GLsizei)draw_count); + glMultiDrawElements(draw_mode, counts, index_type, offsets, static_cast(draw_count)); } } } while (rsx::method_registers.current_draw_clause.next()); @@ -691,9 +691,9 @@ void GLGSRender::on_init_thread() if (g_cfg.video.debug_output) gl::enable_debugging(); - LOG_NOTICE(RSX, "GL RENDERER: %s (%s)", (const char*)glGetString(GL_RENDERER), (const char*)glGetString(GL_VENDOR)); - LOG_NOTICE(RSX, "GL VERSION: %s", (const char*)glGetString(GL_VERSION)); - LOG_NOTICE(RSX, "GLSL VERSION: %s", (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION)); + LOG_NOTICE(RSX, "GL RENDERER: %s (%s)", reinterpret_cast(glGetString(GL_RENDERER)), reinterpret_cast(glGetString(GL_VENDOR))); + LOG_NOTICE(RSX, "GL VERSION: %s", reinterpret_cast(glGetString(GL_VERSION))); + LOG_NOTICE(RSX, "GLSL VERSION: %s", reinterpret_cast(glGetString(GL_SHADING_LANGUAGE_VERSION))); auto& gl_caps = gl::get_driver_caps(); @@ -827,7 +827,7 @@ void GLGSRender::on_init_thread() m_identity_index_buffer->create(gl::buffer::target::element_array, 1 * 0x100000, nullptr, gl::buffer::memory_type::host_visible); // Initialize with 256k identity entries - auto* dst = (u32*)m_identity_index_buffer->map(gl::buffer::access::write); + auto* dst = reinterpret_cast(m_identity_index_buffer->map(gl::buffer::access::write)); for (u32 n = 0; n < (0x100000 >> 2); ++n) { dst[n] = n; @@ -842,8 +842,8 @@ void GLGSRender::on_init_thread() backend_config.supports_hw_renormalization = true; } - m_persistent_stream_view.update(m_attrib_ring_buffer.get(), 0, std::min((u32)m_attrib_ring_buffer->size(), m_max_texbuffer_size)); - m_volatile_stream_view.update(m_attrib_ring_buffer.get(), 0, std::min((u32)m_attrib_ring_buffer->size(), m_max_texbuffer_size)); + m_persistent_stream_view.update(m_attrib_ring_buffer.get(), 0, std::min(static_cast(m_attrib_ring_buffer->size()), m_max_texbuffer_size)); + m_volatile_stream_view.update(m_attrib_ring_buffer.get(), 0, std::min(static_cast(m_attrib_ring_buffer->size()), m_max_texbuffer_size)); m_gl_persistent_stream_buffer->copy_from(m_persistent_stream_view); m_gl_volatile_stream_buffer->copy_from(m_volatile_stream_view); @@ -885,7 +885,7 @@ void GLGSRender::on_init_thread() auto &query = m_occlusion_query_data[i]; glGenQueries(1, &handle); - query.driver_handle = (u64)handle; + query.driver_handle = handle; query.pending = false; query.active = false; query.result = 0; @@ -927,7 +927,7 @@ void GLGSRender::on_init_thread() type.disable_cancel = true; type.progress_bar_count = 2; - dlg = g_fxo->get()->create((bool)g_cfg.video.shader_preloading_dialog.use_custom_background); + dlg = g_fxo->get()->create(!!g_cfg.video.shader_preloading_dialog.use_custom_background); dlg->progress_bar_set_taskbar_index(-1); dlg->show("Loading precompiled shaders from disk...", type, [](s32 status) { @@ -945,7 +945,7 @@ void GLGSRender::on_init_thread() void inc_value(u32 index, u32 value) override { - dlg->progress_bar_increment(index, (f32)value); + dlg->progress_bar_increment(index, static_cast(value)); owner->flip({}); } @@ -1087,7 +1087,7 @@ void GLGSRender::on_exit() query.active = false; query.pending = false; - GLuint handle = (GLuint)query.driver_handle; + GLuint handle = query.driver_handle; glDeleteQueries(1, &handle); query.driver_handle = 0; } @@ -1236,7 +1236,7 @@ bool GLGSRender::do_method(u32 cmd, u32 arg) if (arg & 0xF0) ctx |= rsx::framebuffer_creation_context::context_clear_color; if (arg & 0x3) ctx |= rsx::framebuffer_creation_context::context_clear_depth; - init_buffers((rsx::framebuffer_creation_context)ctx, true); + init_buffers(rsx::framebuffer_creation_context{ctx}, true); clear_surface(arg); } @@ -1426,7 +1426,7 @@ void GLGSRender::update_vertex_env(const gl::vertex_upload_info& upload_info) buf[1] = upload_info.vertex_index_offset; buf += 4; - fill_vertex_layout_state(m_vertex_layout, upload_info.first_vertex, upload_info.allocated_vertex_count, (s32*)buf, upload_info.persistent_mapping_offset, upload_info.volatile_mapping_offset); + fill_vertex_layout_state(m_vertex_layout, upload_info.first_vertex, upload_info.allocated_vertex_count, reinterpret_cast(buf), upload_info.persistent_mapping_offset, upload_info.volatile_mapping_offset); m_vertex_layout_buffer->bind_range(GL_VERTEX_LAYOUT_BIND_SLOT, mapping.second, 128 + 16); @@ -1615,25 +1615,25 @@ void GLGSRender::flip(const rsx::display_flip_info_t& info) if (!g_cfg.video.stretch_to_display_area) { - const double aq = (double)buffer_width / buffer_height; - const double rq = (double)new_size.width / new_size.height; + const double aq = 1. * buffer_width / buffer_height; + const double rq = 1. * new_size.width / new_size.height; const double q = aq / rq; if (q > 1.0) { - new_size.height = int(new_size.height / q); + new_size.height = static_cast(new_size.height / q); aspect_ratio.y = (csize.height - new_size.height) / 2; } else if (q < 1.0) { - new_size.width = int(new_size.width * q); + new_size.width = static_cast(new_size.width * q); aspect_ratio.x = (csize.width - new_size.width) / 2; } } aspect_ratio.size = new_size; - if ((u32)info.buffer < display_buffers_count && buffer_width && buffer_height) + if (info.buffer < display_buffers_count && buffer_width && buffer_height) { // Find the source image const u32 absolute_address = rsx::get_address(display_buffers[info.buffer].offset, CELL_GCM_LOCATION_LOCAL); @@ -1690,7 +1690,7 @@ void GLGSRender::flip(const rsx::display_flip_info_t& info) gl::pixel_unpack_settings unpack_settings; unpack_settings.alignment(1).row_length(buffer_pitch / 4); - if (!m_flip_tex_color || m_flip_tex_color->size2D() != sizei{ (int)buffer_width, (int)buffer_height }) + if (!m_flip_tex_color || m_flip_tex_color->size2D() != sizei{ static_cast(buffer_width), static_cast(buffer_height) }) { m_flip_tex_color = std::make_unique(GL_TEXTURE_2D, buffer_width, buffer_height, 1, 1, GL_RGBA8); } @@ -1723,7 +1723,7 @@ void GLGSRender::flip(const rsx::display_flip_info_t& info) m_frame->take_screenshot(std::move(sshot_frame), buffer_width, buffer_height); } - areai screen_area = coordi({}, { (int)buffer_width, (int)buffer_height }); + areai screen_area = coordi({}, { static_cast(buffer_width), static_cast(buffer_height) }); if (g_cfg.video.full_rgb_range_output && rsx::fcmp(avconfig->gamma, 1.f)) { @@ -1797,7 +1797,7 @@ void GLGSRender::flip(const rsx::display_flip_info_t& info) const auto num_speculate = m_gl_texture_cache.get_num_cache_speculative_writes(); const auto num_misses = m_gl_texture_cache.get_num_cache_misses(); const auto num_unavoidable = m_gl_texture_cache.get_num_unavoidable_hard_faults(); - const auto cache_miss_ratio = (u32)ceil(m_gl_texture_cache.get_cache_miss_ratio() * 100); + const auto cache_miss_ratio = static_cast(ceil(m_gl_texture_cache.get_cache_miss_ratio() * 100)); m_text_printer.print_text(0, 126, m_frame->client_width(), m_frame->client_height(), fmt::format("Unreleased textures: %7d", num_dirty_textures)); m_text_printer.print_text(0, 144, m_frame->client_width(), m_frame->client_height(), fmt::format("Texture memory: %12dM", texture_memory_size)); m_text_printer.print_text(0, 162, m_frame->client_width(), m_frame->client_height(), fmt::format("Flush requests: %12d = %2d (%3d%%) hard faults, %2d unavoidable, %2d misprediction(s), %2d speculation(s)", num_flushes, num_misses, cache_miss_ratio, num_unavoidable, num_mispredict, num_speculate)); @@ -1967,7 +1967,7 @@ void GLGSRender::notify_tile_unbound(u32 tile) void GLGSRender::begin_occlusion_query(rsx::reports::occlusion_query_info* query) { query->result = 0; - glBeginQuery(GL_ANY_SAMPLES_PASSED, (GLuint)query->driver_handle); + glBeginQuery(GL_ANY_SAMPLES_PASSED, query->driver_handle); } void GLGSRender::end_occlusion_query(rsx::reports::occlusion_query_info* query) @@ -1982,7 +1982,7 @@ bool GLGSRender::check_occlusion_query_status(rsx::reports::occlusion_query_info return true; GLint status = GL_TRUE; - glGetQueryObjectiv((GLuint)query->driver_handle, GL_QUERY_RESULT_AVAILABLE, &status); + glGetQueryObjectiv(query->driver_handle, GL_QUERY_RESULT_AVAILABLE, &status); return status != GL_FALSE; } @@ -1992,7 +1992,7 @@ void GLGSRender::get_occlusion_query_result(rsx::reports::occlusion_query_info* if (query->num_draws) { GLint result = 0; - glGetQueryObjectiv((GLuint)query->driver_handle, GL_QUERY_RESULT, &result); + glGetQueryObjectiv(query->driver_handle, GL_QUERY_RESULT, &result); query->result += result; } diff --git a/rpcs3/Emu/RSX/GL/GLHelpers.cpp b/rpcs3/Emu/RSX/GL/GLHelpers.cpp index 03e87fb55c..6dc8bbebb6 100644 --- a/rpcs3/Emu/RSX/GL/GLHelpers.cpp +++ b/rpcs3/Emu/RSX/GL/GLHelpers.cpp @@ -94,12 +94,12 @@ namespace gl glBlitFramebuffer( src_area.x1, src_area.y1, src_area.x2, src_area.y2, dst_area.x1, dst_area.y1, dst_area.x2, dst_area.y2, - (GLbitfield)buffers_, (GLenum)filter_); + static_cast(buffers_), static_cast(filter_)); } void fbo::bind_as(target target_) const { - glBindFramebuffer((int)target_, id()); + glBindFramebuffer(static_cast(target_), id()); } void fbo::remove() @@ -151,7 +151,7 @@ namespace gl for (auto &index : indexes) ids.push_back(index.id()); - glDrawBuffers((GLsizei)ids.size(), ids.data()); + glDrawBuffers(::narrow(ids.size()), ids.data()); } void fbo::read_buffer(const attachment& buffer) const @@ -183,19 +183,19 @@ namespace gl void fbo::draw_elements(rsx::primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const { save_binding_state save(*this); - glDrawElements(draw_mode(mode), count, (GLenum)type, indices); + glDrawElements(draw_mode(mode), count, static_cast(type), indices); } void fbo::draw_elements(const buffer& buffer, rsx::primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const { buffer.bind(buffer::target::array); - glDrawElements(draw_mode(mode), count, (GLenum)type, indices); + glDrawElements(draw_mode(mode), count, static_cast(type), indices); } void fbo::draw_elements(rsx::primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset) const { indices.bind(buffer::target::element_array); - glDrawElements(draw_mode(mode), count, (GLenum)type, (GLvoid*)indices_buffer_offset); + glDrawElements(draw_mode(mode), count, static_cast(type), reinterpret_cast(indices_buffer_offset)); } void fbo::draw_elements(const buffer& buffer_, rsx::primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset) const @@ -237,7 +237,7 @@ namespace gl void fbo::clear(buffers buffers_) const { save_binding_state save(*this); - glClear((GLbitfield)buffers_); + glClear(static_cast(buffers_)); } void fbo::clear(buffers buffers_, color4f color_value, double depth_value, u8 stencil_value) const @@ -253,7 +253,7 @@ namespace gl { save_binding_state save(*this); pixel_settings.apply(); - glDrawPixels(size.width, size.height, (GLenum)format_, (GLenum)type_, pixels); + glDrawPixels(size.width, size.height, static_cast(format_), static_cast(type_), pixels); } void fbo::copy_from(const buffer& buf, const sizei& size, gl::texture::format format_, gl::texture::type type_, class pixel_unpack_settings pixel_settings) const @@ -261,14 +261,14 @@ namespace gl save_binding_state save(*this); buffer::save_binding_state save_buffer(buffer::target::pixel_unpack, buf); pixel_settings.apply(); - glDrawPixels(size.width, size.height, (GLenum)format_, (GLenum)type_, nullptr); + glDrawPixels(size.width, size.height, static_cast(format_), static_cast(type_), nullptr); } void fbo::copy_to(void* pixels, coordi coord, gl::texture::format format_, gl::texture::type type_, class pixel_pack_settings pixel_settings) const { save_binding_state save(*this); pixel_settings.apply(); - glReadPixels(coord.x, coord.y, coord.width, coord.height, (GLenum)format_, (GLenum)type_, pixels); + glReadPixels(coord.x, coord.y, coord.width, coord.height, static_cast(format_), static_cast(type_), pixels); } void fbo::copy_to(const buffer& buf, coordi coord, gl::texture::format format_, gl::texture::type type_, class pixel_pack_settings pixel_settings) const @@ -276,7 +276,7 @@ namespace gl save_binding_state save(*this); buffer::save_binding_state save_buffer(buffer::target::pixel_pack, buf); pixel_settings.apply(); - glReadPixels(coord.x, coord.y, coord.width, coord.height, (GLenum)format_, (GLenum)type_, nullptr); + glReadPixels(coord.x, coord.y, coord.width, coord.height, static_cast(format_), static_cast(type_), nullptr); } fbo fbo::get_binded_draw_buffer() @@ -284,7 +284,7 @@ namespace gl GLint value; glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &value); - return{ (GLuint)value }; + return{ static_cast(value) }; } fbo fbo::get_binded_read_buffer() @@ -292,7 +292,7 @@ namespace gl GLint value; glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &value); - return{ (GLuint)value }; + return{ static_cast(value) }; } fbo fbo::get_binded_buffer() @@ -300,7 +300,7 @@ namespace gl GLint value; glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); - return{ (GLuint)value }; + return{ static_cast(value) }; } GLuint fbo::id() const @@ -390,13 +390,13 @@ namespace gl if (static_cast(internal_fmt) != src->get_internal_format()) { - const auto internal_width = (u16)(src->width() * xfer_info.src_scaling_hint); + const u16 internal_width = static_cast(src->width() * xfer_info.src_scaling_hint); typeless_src = std::make_unique(GL_TEXTURE_2D, internal_width, src->height(), 1, 1, internal_fmt); copy_typeless(typeless_src.get(), src); real_src = typeless_src.get(); - src_rect.x1 = (u16)(src_rect.x1 * xfer_info.src_scaling_hint); - src_rect.x2 = (u16)(src_rect.x2 * xfer_info.src_scaling_hint); + src_rect.x1 = static_cast(src_rect.x1 * xfer_info.src_scaling_hint); + src_rect.x2 = static_cast(src_rect.x2 * xfer_info.src_scaling_hint); } } @@ -408,13 +408,13 @@ namespace gl if (static_cast(internal_fmt) != dst->get_internal_format()) { - const auto internal_width = (u16)(dst->width() * xfer_info.dst_scaling_hint); + const auto internal_width = static_cast(dst->width() * xfer_info.dst_scaling_hint); typeless_dst = std::make_unique(GL_TEXTURE_2D, internal_width, dst->height(), 1, 1, internal_fmt); copy_typeless(typeless_dst.get(), dst); real_dst = typeless_dst.get(); - dst_rect.x1 = (u16)(dst_rect.x1 * xfer_info.dst_scaling_hint); - dst_rect.x2 = (u16)(dst_rect.x2 * xfer_info.dst_scaling_hint); + dst_rect.x1 = static_cast(dst_rect.x1 * xfer_info.dst_scaling_hint); + dst_rect.x2 = static_cast(dst_rect.x2 * xfer_info.dst_scaling_hint); } } @@ -466,7 +466,7 @@ namespace gl glBlitFramebuffer(src_rect.x1, src_rect.y1, src_rect.x2, src_rect.y2, dst_rect.x1, dst_rect.y1, dst_rect.x2, dst_rect.y2, - (GLbitfield)target, (GLenum)interp); + static_cast(target), static_cast(interp)); if (xfer_info.dst_is_typeless) { @@ -513,7 +513,7 @@ namespace gl attachment = GL_DEPTH_STENCIL_ATTACHMENT; break; default: - fmt::throw_exception("Invalid texture passed to clear depth function, format=0x%x", (u32)fmt); + fmt::throw_exception("Invalid texture passed to clear depth function, format=0x%x", static_cast(fmt)); } save_binding_state saved; diff --git a/rpcs3/Emu/RSX/GL/GLHelpers.h b/rpcs3/Emu/RSX/GL/GLHelpers.h index 5ec956a59d..3b3c6d3a46 100644 --- a/rpcs3/Emu/RSX/GL/GLHelpers.h +++ b/rpcs3/Emu/RSX/GL/GLHelpers.h @@ -746,7 +746,7 @@ namespace gl } glGetIntegerv(pname, &m_last_binding); - m_target = (GLenum)target_; + m_target = static_cast(target_); } @@ -800,7 +800,7 @@ namespace gl flags |= GL_CLIENT_STORAGE_BIT; } - glBufferStorage((GLenum)target_, size, data_, flags); + glBufferStorage(static_cast(target_), size, data_, flags); m_size = size; } else @@ -866,7 +866,7 @@ namespace gl void bind(target target_) const { - glBindBuffer((GLenum)target_, m_id); + glBindBuffer(static_cast(target_), m_id); } void bind() const @@ -916,7 +916,7 @@ namespace gl target target_ = current_target(); save_binding_state save(target_, *this); - glBufferData((GLenum)target_, size, data_, usage); + glBufferData(static_cast(target_), size, data_, usage); m_size = size; } @@ -925,23 +925,23 @@ namespace gl verify(HERE), m_memory_type == memory_type::host_visible; bind(current_target()); - return (GLubyte*)glMapBuffer((GLenum)current_target(), (GLenum)access_); + return reinterpret_cast(glMapBuffer(static_cast(current_target()), static_cast(access_))); } void unmap() { verify(HERE), m_memory_type == memory_type::host_visible; - glUnmapBuffer((GLenum)current_target()); + glUnmapBuffer(static_cast(current_target())); } void bind_range(u32 index, u32 offset, u32 size) const { - glBindBufferRange((GLenum)current_target(), index, id(), offset, size); + glBindBufferRange(static_cast(current_target()), index, id(), offset, size); } void bind_range(target target_, u32 index, u32 offset, u32 size) const { - glBindBufferRange((GLenum)target_, index, id(), offset, size); + glBindBufferRange(static_cast(target_), index, id(), offset, size); } }; @@ -969,9 +969,9 @@ namespace gl GLbitfield buffer_storage_flags = GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT; if (gl::get_driver_caps().vendor_MESA) buffer_storage_flags |= GL_CLIENT_STORAGE_BIT; - glBindBuffer((GLenum)m_target, m_id); - glBufferStorage((GLenum)m_target, size, data, buffer_storage_flags); - m_memory_mapping = glMapBufferRange((GLenum)m_target, 0, size, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + glBindBuffer(static_cast(m_target), m_id); + glBufferStorage(static_cast(m_target), size, data, buffer_storage_flags); + m_memory_mapping = glMapBufferRange(static_cast(m_target), 0, size, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); verify(HERE), m_memory_mapping != nullptr; m_data_loc = 0; @@ -1007,15 +1007,15 @@ namespace gl //Align data loc to 256; allows some "guard" region so we dont trample our own data inadvertently m_data_loc = align(offset + alloc_size, 256); - return std::make_pair(((char*)m_memory_mapping) + offset, offset); + return std::make_pair(static_cast(m_memory_mapping) + offset, offset); } virtual void remove() { if (m_memory_mapping) { - glBindBuffer((GLenum)m_target, m_id); - glUnmapBuffer((GLenum)m_target); + glBindBuffer(static_cast(m_target), m_id); + glUnmapBuffer(static_cast(m_target)); m_memory_mapping = nullptr; m_data_loc = 0; @@ -1082,14 +1082,14 @@ namespace gl m_data_loc = 0; } - glBindBuffer((GLenum)m_target, m_id); - m_memory_mapping = glMapBufferRange((GLenum)m_target, m_data_loc, block_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_UNSYNCHRONIZED_BIT); + glBindBuffer(static_cast(m_target), m_id); + m_memory_mapping = glMapBufferRange(static_cast(m_target), m_data_loc, block_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_UNSYNCHRONIZED_BIT); m_mapped_bytes = block_size; m_mapping_offset = m_data_loc; m_alignment_offset = 0; //When using debugging tools, the mapped base might not be aligned as expected - const u64 mapped_address_base = (u64)m_memory_mapping; + const u64 mapped_address_base = reinterpret_cast(m_memory_mapping); if (mapped_address_base & 0xF) { //Unaligned result was returned. We have to modify the base address a bit @@ -1097,7 +1097,7 @@ namespace gl const u64 new_base = (mapped_address_base & ~0xF) + 16; const u64 diff_bytes = new_base - mapped_address_base; - m_memory_mapping = (void *)new_base; + m_memory_mapping = reinterpret_cast(new_base); m_mapped_bytes -= ::narrow(diff_bytes); m_alignment_offset = ::narrow(diff_bytes); } @@ -1131,7 +1131,7 @@ namespace gl m_mapped_bytes -= real_size; u32 local_offset = (offset - m_mapping_offset); - return std::make_pair(((char*)m_memory_mapping) + local_offset, offset + m_alignment_offset); + return std::make_pair(static_cast(m_memory_mapping) + local_offset, offset + m_alignment_offset); } void remove() override @@ -1224,7 +1224,7 @@ namespace gl vao& m_parent; public: - using save_binding_state = save_binding_state_base; + using save_binding_state = save_binding_state_base(BindId)), GetStateId>; entry(vao* parent) noexcept : m_parent(*parent) { @@ -1248,7 +1248,7 @@ namespace gl entry element_array_buffer{ this }; vao() = default; - vao(vao&) = delete; + vao(const vao&) = delete; vao(vao&& vao_) noexcept { @@ -1341,19 +1341,19 @@ namespace gl disable_for_attributes({ index }); } - buffer_pointer operator + (u32 offset) const noexcept + buffer_pointer operator + (u32 offset) noexcept { - return{ (vao*)this, offset }; + return{ this, offset }; } - buffer_pointer operator >> (u32 stride) const noexcept + buffer_pointer operator >> (u32 stride) noexcept { - return{ (vao*)this, {}, stride }; + return{ this, {}, stride }; } - operator buffer_pointer() const noexcept + operator buffer_pointer() noexcept { - return{ (vao*)this }; + return{ this }; } attrib_t operator [] (u32 index) const noexcept; @@ -1389,8 +1389,8 @@ namespace gl void operator = (buffer_pointer& pointer) const { pointer.get_vao().enable_for_attribute(m_location); - glVertexAttribPointer(location(), pointer.size(), (GLenum)pointer.get_type(), pointer.normalize(), - pointer.stride(), (const void*)(size_t)pointer.offset()); + glVertexAttribPointer(location(), pointer.size(), static_cast(pointer.get_type()), pointer.normalize(), + pointer.stride(), reinterpret_cast(u64{pointer.offset()})); } }; @@ -1582,19 +1582,19 @@ namespace gl switch (target) { case GL_TEXTURE_1D: - glGetIntegerv(GL_TEXTURE_BINDING_1D, (GLint*)&old_binding); + glGetIntegerv(GL_TEXTURE_BINDING_1D, reinterpret_cast(&old_binding)); break; case GL_TEXTURE_2D: - glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&old_binding); + glGetIntegerv(GL_TEXTURE_BINDING_2D, reinterpret_cast(&old_binding)); break; case GL_TEXTURE_3D: - glGetIntegerv(GL_TEXTURE_BINDING_3D, (GLint*)&old_binding); + glGetIntegerv(GL_TEXTURE_BINDING_3D, reinterpret_cast(&old_binding)); break; case GL_TEXTURE_CUBE_MAP: - glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP, (GLint*)&old_binding); + glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP, reinterpret_cast(&old_binding)); break; case GL_TEXTURE_BUFFER: - glGetIntegerv(GL_TEXTURE_BINDING_BUFFER, (GLint*)&old_binding); + glGetIntegerv(GL_TEXTURE_BINDING_BUFFER, reinterpret_cast(&old_binding)); break; } } @@ -1807,37 +1807,37 @@ namespace gl { pixel_settings.apply(); - switch ((GLenum)m_target) + switch (static_cast(m_target)) { case GL_TEXTURE_1D: { - DSA_CALL(TextureSubImage1D, m_id, GL_TEXTURE_1D, 0, region.x, region.width, (GLenum)format, (GLenum)type, src); + DSA_CALL(TextureSubImage1D, m_id, GL_TEXTURE_1D, 0, region.x, region.width, static_cast(format), static_cast(type), src); break; } case GL_TEXTURE_2D: { - DSA_CALL(TextureSubImage2D, m_id, GL_TEXTURE_2D, 0, region.x, region.y, region.width, region.height, (GLenum)format, (GLenum)type, src); + DSA_CALL(TextureSubImage2D, m_id, GL_TEXTURE_2D, 0, region.x, region.y, region.width, region.height, static_cast(format), static_cast(type), src); break; } case GL_TEXTURE_3D: { - DSA_CALL(TextureSubImage3D, m_id, GL_TEXTURE_3D, 0, region.x, region.y, region.z, region.width, region.height, region.depth, (GLenum)format, (GLenum)type, src); + DSA_CALL(TextureSubImage3D, m_id, GL_TEXTURE_3D, 0, region.x, region.y, region.z, region.width, region.height, region.depth, static_cast(format), static_cast(type), src); break; } case GL_TEXTURE_CUBE_MAP: { if (get_driver_caps().ARB_dsa_supported) { - glTextureSubImage3D(m_id, 0, region.x, region.y, region.z, region.width, region.height, region.depth, (GLenum)format, (GLenum)type, src); + glTextureSubImage3D(m_id, 0, region.x, region.y, region.z, region.width, region.height, region.depth, static_cast(format), static_cast(type), src); } else { LOG_WARNING(RSX, "Cubemap upload via texture::copy_from is halfplemented!"); - u8* ptr = (u8*)src; + auto ptr = static_cast(src); const auto end = std::min(6u, region.z + region.depth); for (unsigned face = region.z; face < end; ++face) { - glTextureSubImage2DEXT(m_id, GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, region.x, region.y, region.width, region.height, (GLenum)format, (GLenum)type, ptr); + glTextureSubImage2DEXT(m_id, GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, region.x, region.y, region.width, region.height, static_cast(format), static_cast(type), ptr); ptr += (region.width * region.height * 4); //TODO } } @@ -1874,20 +1874,20 @@ namespace gl region.width == m_width && region.height == m_height && region.depth == m_depth) { if (caps.ARB_dsa_supported) - glGetTextureImage(m_id, 0, (GLenum)format, (GLenum)type, INT32_MAX, dst); + glGetTextureImage(m_id, 0, static_cast(format), static_cast(type), INT32_MAX, dst); else - glGetTextureImageEXT(m_id, (GLenum)m_target, 0, (GLenum)format, (GLenum)type, dst); + glGetTextureImageEXT(m_id, static_cast(m_target), 0, static_cast(format), static_cast(type), dst); } else if (caps.ARB_dsa_supported) { glGetTextureSubImage(m_id, 0, region.x, region.y, region.z, region.width, region.height, region.depth, - (GLenum)format, (GLenum)type, INT32_MAX, dst); + static_cast(format), static_cast(type), INT32_MAX, dst); } else { // Worst case scenario. For some reason, EXT_dsa does not have glGetTextureSubImage const auto target_ = static_cast(m_target); - texture tmp{ target_, region.width, region.height, region.depth, 1, (GLenum)m_internal_format }; + texture tmp{ target_, region.width, region.height, region.depth, 1, static_cast(m_internal_format) }; glCopyImageSubData(m_id, target_, 0, region.x, region.y, region.z, tmp.id(), target_, 0, 0, 0, 0, region.width, region.height, region.depth); @@ -1934,7 +1934,7 @@ namespace gl component_swizzle[3] = argb_swizzle[0]; glBindTexture(m_target, m_id); - glTexParameteriv(m_target, GL_TEXTURE_SWIZZLE_RGBA, (GLint*)component_swizzle); + glTexParameteriv(m_target, GL_TEXTURE_SWIZZLE_RGBA, reinterpret_cast(component_swizzle)); } else { @@ -1968,8 +1968,8 @@ namespace gl texture_view(texture* data, const GLenum* argb_swizzle = nullptr, GLenum aspect_flags = image_aspect::color | image_aspect::depth) { - GLenum target = (GLenum)data->get_target(); - GLenum sized_format = (GLenum)data->get_internal_format(); + GLenum target = static_cast(data->get_target()); + GLenum sized_format = static_cast(data->get_internal_format()); create(data, target, sized_format, aspect_flags, argb_swizzle); } @@ -2137,7 +2137,7 @@ public: void storage(texture::format format, u32 width, u32 height) { save_binding_state save(*this); - glRenderbufferStorage(GL_RENDERBUFFER, (GLenum)format, width, height); + glRenderbufferStorage(GL_RENDERBUFFER, static_cast(format), width, height); } void remove() @@ -2236,7 +2236,7 @@ public: public: attachment(fbo& parent, type type) - : m_id((int)type) + : m_id(static_cast(type)) , m_parent(parent) { } @@ -2470,14 +2470,14 @@ public: void create(type type_) { - m_id = glCreateShader((GLenum)type_); + m_id = glCreateShader(static_cast(type_)); shader_type = type_; } void source(const std::string& src) const { const char* str = src.c_str(); - const GLint length = (GLint)src.length(); + const GLint length = ::narrow(src.length()); if (g_cfg.video.log_programs) { std::string base_name; @@ -2708,7 +2708,7 @@ public: { GLint id; glGetIntegerv(GL_CURRENT_PROGRAM, &id); - return{ (GLuint)id }; + return{ static_cast(id) }; } void use() @@ -2899,7 +2899,7 @@ public: save_binding_state() { - glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*)&old_fbo); + glGetIntegerv(GL_FRAMEBUFFER_BINDING, reinterpret_cast(&old_fbo)); } ~save_binding_state() diff --git a/rpcs3/Emu/RSX/GL/GLOverlays.h b/rpcs3/Emu/RSX/GL/GLOverlays.h index e1da632fe6..e8fd19217b 100644 --- a/rpcs3/Emu/RSX/GL/GLOverlays.h +++ b/rpcs3/Emu/RSX/GL/GLOverlays.h @@ -37,7 +37,7 @@ namespace gl saved_sampler_state(GLuint _unit, const gl::sampler_state& sampler) { glActiveTexture(GL_TEXTURE0 + _unit); - glGetIntegerv(GL_SAMPLER_BINDING, (GLint*)&saved); + glGetIntegerv(GL_SAMPLER_BINDING, reinterpret_cast(&saved)); unit = _unit; sampler.bind(_unit); @@ -240,7 +240,7 @@ namespace gl glBindFramebuffer(GL_FRAMEBUFFER, old_fbo); } - glUseProgram((GLuint)program); + glUseProgram(program); glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); glColorMask(color_writes[0], color_writes[1], color_writes[2], color_writes[3]); @@ -493,8 +493,8 @@ namespace gl } else { - u64 key = (u64)desc; - temp_image_cache[key] = std::move(std::make_pair(owner_uid, std::move(tex))); + u64 key = reinterpret_cast(desc); + temp_image_cache[key] = std::make_pair(owner_uid, std::move(tex)); temp_view_cache[key] = std::move(view); } @@ -544,13 +544,13 @@ namespace gl gl::texture_view* find_font(rsx::overlays::font *font) { - u64 key = (u64)font; + u64 key = reinterpret_cast(font); auto found = view_cache.find(key); if (found != view_cache.end()) return found->second.get(); //Create font file - auto tex = std::make_unique(GL_TEXTURE_2D, (int)font->width, (int)font->height, 1, 1, GL_R8); + auto tex = std::make_unique(GL_TEXTURE_2D, font->width, font->height, 1, 1, GL_R8); tex->copy_from(font->glyph_data.data(), gl::texture::format::r, gl::texture::type::ubyte, {}); GLenum remap[] = { GL_RED, GL_RED, GL_RED, GL_RED }; @@ -565,7 +565,7 @@ namespace gl gl::texture_view* find_temp_image(rsx::overlays::image_info *desc, u32 owner_uid) { - auto key = (u64)desc; + auto key = reinterpret_cast(desc); auto cached = temp_view_cache.find(key); if (cached != temp_view_cache.end()) { @@ -632,17 +632,17 @@ namespace gl void run(const areau& viewport, GLuint target, rsx::overlays::overlay& ui) { - program_handle.uniforms["viewport"] = color2f((f32)viewport.width(), (f32)viewport.height()); - program_handle.uniforms["ui_scale"] = color4f((f32)ui.virtual_width, (f32)ui.virtual_height, 1.f, 1.f); - program_handle.uniforms["time"] = (f32)(get_system_time() / 1000) * 0.005f; + program_handle.uniforms["viewport"] = color2f(static_cast(viewport.width()), static_cast(viewport.height())); + program_handle.uniforms["ui_scale"] = color4f(static_cast(ui.virtual_width), static_cast(ui.virtual_height), 1.f, 1.f); + program_handle.uniforms["time"] = static_cast(get_system_time() / 1000) * 0.005f; saved_sampler_state saved(31, m_sampler); for (auto &cmd : ui.get_compiled().draw_commands) { set_primitive_type(cmd.config.primitives); - upload_vertex_data((f32*)cmd.verts.data(), (u32)cmd.verts.size() * 4u); - num_drawable_elements = (u32)cmd.verts.size(); + upload_vertex_data(reinterpret_cast(cmd.verts.data()), ::size32(cmd.verts) * 4u); + num_drawable_elements = ::size32(cmd.verts); GLint texture_exists = GL_TRUE; switch (cmd.config.texture_ref) @@ -658,7 +658,7 @@ namespace gl } case rsx::overlays::image_resource_id::raw_image: { - glBindTexture(GL_TEXTURE_2D, find_temp_image((rsx::overlays::image_info*)cmd.config.external_data_ref, ui.uid)->id()); + glBindTexture(GL_TEXTURE_2D, find_temp_image(static_cast(cmd.config.external_data_ref), ui.uid)->id()); break; } case rsx::overlays::image_resource_id::font_file: @@ -675,9 +675,9 @@ namespace gl program_handle.uniforms["color"] = cmd.config.color; program_handle.uniforms["read_texture"] = texture_exists; - program_handle.uniforms["pulse_glow"] = (s32)cmd.config.pulse_glow; - program_handle.uniforms["blur_strength"] = (s32)cmd.config.blur_strength; - program_handle.uniforms["clip_region"] = (s32)cmd.config.clip_region; + program_handle.uniforms["pulse_glow"] = static_cast(cmd.config.pulse_glow); + program_handle.uniforms["blur_strength"] = static_cast(cmd.config.blur_strength); + program_handle.uniforms["clip_region"] = static_cast(cmd.config.clip_region); program_handle.uniforms["clip_bounds"] = cmd.config.clip_rect; overlay_pass::run(viewport, target, false, true); } @@ -728,7 +728,7 @@ namespace gl void run(const areau& viewport, GLuint source, f32 gamma, bool limited_rgb) { program_handle.uniforms["gamma"] = gamma; - program_handle.uniforms["limit_range"] = (int)limited_rgb; + program_handle.uniforms["limit_range"] = limited_rgb + 0; saved_sampler_state saved(31, m_sampler); glBindTexture(GL_TEXTURE_2D, source); diff --git a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp index 2dadf4d382..ad01a0b2ef 100644 --- a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp +++ b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp @@ -62,7 +62,7 @@ color_format rsx::internals::surface_color_format_to_gl(rsx::surface_color_forma { ::gl::texture::channel::a, ::gl::texture::channel::b, ::gl::texture::channel::g, ::gl::texture::channel::r } }; default: - fmt::throw_exception("Unsupported surface color format 0x%x" HERE, (u32)color_format); + fmt::throw_exception("Unsupported surface color format 0x%x" HERE, static_cast(color_format)); } } @@ -78,9 +78,9 @@ depth_format rsx::internals::surface_depth_format_to_gl(rsx::surface_depth_forma return{ ::gl::texture::type::uint_24_8, ::gl::texture::format::depth_stencil, ::gl::texture::internal_format::depth32f_stencil8 }; else return{ ::gl::texture::type::uint_24_8, ::gl::texture::format::depth_stencil, ::gl::texture::internal_format::depth24_stencil8 }; - + default: - fmt::throw_exception("Unsupported depth format 0x%x" HERE, (u32)depth_format); + fmt::throw_exception("Unsupported depth format 0x%x" HERE, static_cast(depth_format)); } } @@ -252,7 +252,7 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk m_draw_fbo = &fbo; m_draw_fbo->bind(); - m_draw_fbo->set_extents({ (int)m_framebuffer_layout.width, (int)m_framebuffer_layout.height }); + m_draw_fbo->set_extents({ m_framebuffer_layout.width, m_framebuffer_layout.height }); framebuffer_status_valid = true; break; @@ -267,7 +267,7 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk m_draw_fbo = &m_framebuffer_cache.back(); m_draw_fbo->create(); m_draw_fbo->bind(); - m_draw_fbo->set_extents({ (int)m_framebuffer_layout.width, (int)m_framebuffer_layout.height }); + m_draw_fbo->set_extents({ m_framebuffer_layout.width, m_framebuffer_layout.height }); for (int i = 0; i < 4; ++i) { @@ -479,13 +479,13 @@ void gl::render_target::memory_barrier(gl::command_context& cmd, bool force_init else { // Mem cast, generate typeless xfer info - if (!formats_are_bitcast_compatible((GLenum)get_internal_format(), (GLenum)src_texture->get_internal_format()) || + if (!formats_are_bitcast_compatible(static_cast(get_internal_format()), static_cast(src_texture->get_internal_format())) || aspect() != src_texture->aspect()) { typeless_info.src_is_typeless = true; typeless_info.src_context = rsx::texture_upload_context::framebuffer_storage; - typeless_info.src_native_format_override = (u32)get_internal_format(); - typeless_info.src_scaling_hint = f32(src_bpp) / dst_bpp; + typeless_info.src_native_format_override = static_cast(get_internal_format()); + typeless_info.src_scaling_hint = static_cast(src_bpp) / dst_bpp; } } diff --git a/rpcs3/Emu/RSX/GL/GLRenderTargets.h b/rpcs3/Emu/RSX/GL/GLRenderTargets.h index cfbe4b6017..30a02abf97 100644 --- a/rpcs3/Emu/RSX/GL/GLRenderTargets.h +++ b/rpcs3/Emu/RSX/GL/GLRenderTargets.h @@ -93,7 +93,7 @@ namespace gl texture* get_surface(rsx::surface_access /*access_type*/) override { // TODO - return (gl::texture*)this; + return static_cast(this); } u32 raw_handle() const @@ -141,15 +141,15 @@ struct gl_render_target_traits { auto format = rsx::internals::surface_color_format_to_gl(surface_color_format); - std::unique_ptr result(new gl::render_target(rsx::apply_resolution_scale((u16)width, true), - rsx::apply_resolution_scale((u16)height, true), (GLenum)format.internal_format)); + std::unique_ptr result(new gl::render_target(rsx::apply_resolution_scale(static_cast(width), true), + rsx::apply_resolution_scale(static_cast(height), true), static_cast(format.internal_format))); result->set_aa_mode(antialias); - result->set_native_pitch((u16)width * get_format_block_size_in_bytes(surface_color_format) * result->samples_x); - result->set_surface_dimensions((u16)width, (u16)height, (u16)pitch); + result->set_native_pitch(static_cast(width) * get_format_block_size_in_bytes(surface_color_format) * result->samples_x); + result->set_surface_dimensions(static_cast(width), static_cast(height), static_cast(pitch)); result->set_format(surface_color_format); - std::array native_layout = { (GLenum)format.swizzle.a, (GLenum)format.swizzle.r, (GLenum)format.swizzle.g, (GLenum)format.swizzle.b }; + std::array native_layout = { static_cast(format.swizzle.a), static_cast(format.swizzle.r), static_cast(format.swizzle.g), static_cast(format.swizzle.b) }; result->set_native_component_layout(native_layout); result->memory_usage_flags = rsx::surface_usage_flags::attachment; @@ -168,14 +168,14 @@ struct gl_render_target_traits ) { auto format = rsx::internals::surface_depth_format_to_gl(surface_depth_format); - std::unique_ptr result(new gl::render_target(rsx::apply_resolution_scale((u16)width, true), - rsx::apply_resolution_scale((u16)height, true), (GLenum)format.internal_format)); + std::unique_ptr result(new gl::render_target(rsx::apply_resolution_scale(static_cast(width), true), + rsx::apply_resolution_scale(static_cast(height), true), static_cast(format.internal_format))); result->set_aa_mode(antialias); - result->set_surface_dimensions((u16)width, (u16)height, (u16)pitch); + result->set_surface_dimensions(static_cast(width), static_cast(height), static_cast(pitch)); result->set_format(surface_depth_format); - u16 native_pitch = (u16)width * 2 * result->samples_x; + u16 native_pitch = static_cast(width) * 2 * result->samples_x; if (surface_depth_format == rsx::surface_depth_format::z24s8) native_pitch *= 2; @@ -199,7 +199,7 @@ struct gl_render_target_traits { if (!sink) { - auto internal_format = (GLenum)ref->get_internal_format(); + auto internal_format = static_cast(ref->get_internal_format()); const auto new_w = rsx::apply_resolution_scale(prev.width, true, ref->get_surface_width(rsx::surface_metrics::pixels)); const auto new_h = rsx::apply_resolution_scale(prev.height, true, ref->get_surface_height(rsx::surface_metrics::pixels)); @@ -266,7 +266,7 @@ struct gl_render_target_traits static void invalidate_surface_contents(gl::command_context&, gl::render_target *surface, u32 address, size_t pitch) { - surface->set_rsx_pitch((u16)pitch); + surface->set_rsx_pitch(static_cast(pitch)); surface->queue_tag(address); surface->last_use_tag = 0; surface->stencil_init_flags = 0; @@ -309,7 +309,7 @@ struct gl_render_target_traits return surface->get_internal_format() == format && surface->get_spp() == get_format_sample_count(antialias) && - surface->matches_dimensions((u16)width, (u16)height); + surface->matches_dimensions(static_cast(width), static_cast(height)); } static diff --git a/rpcs3/Emu/RSX/GL/GLTextOut.h b/rpcs3/Emu/RSX/GL/GLTextOut.h index c79b0d9ae2..ee20d323ab 100644 --- a/rpcs3/Emu/RSX/GL/GLTextOut.h +++ b/rpcs3/Emu/RSX/GL/GLTextOut.h @@ -73,7 +73,7 @@ namespace gl m_program.use(); m_program.uniforms["draw_color"] = color; - glProgramUniform2fv(m_program.id(), m_program.uniforms["offsets"].location(), (GLsizei)nb_offsets, offsets); + glProgramUniform2fv(m_program.id(), m_program.uniforms["offsets"].location(), static_cast(nb_offsets), offsets); glProgramUniform2fv(m_program.id(), m_program.uniforms["scale"].location(), 1, scale); } @@ -141,9 +141,8 @@ namespace gl float base_offset = 0.f; shader_offsets.reserve(text.length() * 2); - while (*s) + while (u8 offset = static_cast(*s)) { - u8 offset = (u8)*s; bool to_draw = false; //Can be false for space or unsupported characters auto o = m_offsets.find(offset); @@ -183,7 +182,7 @@ namespace gl m_vao.bind(); - glMultiDrawArrays(GL_POINTS, (const GLint*)offsets.data(), (const GLsizei*)counts.data(), (GLsizei)counts.size()); + glMultiDrawArrays(GL_POINTS, offsets.data(), counts.data(), static_cast(counts.size())); glBindVertexArray(old_vao); } diff --git a/rpcs3/Emu/RSX/GL/GLTexture.cpp b/rpcs3/Emu/RSX/GL/GLTexture.cpp index fd743fb1bf..ce3a179f84 100644 --- a/rpcs3/Emu/RSX/GL/GLTexture.cpp +++ b/rpcs3/Emu/RSX/GL/GLTexture.cpp @@ -129,7 +129,7 @@ namespace gl case texture::internal_format::depth32f_stencil8: return { GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 4, true }; default: - fmt::throw_exception("Unexpected internal format 0x%X" HERE, (u32)format); + fmt::throw_exception("Unexpected internal format 0x%X" HERE, static_cast(format)); } } @@ -165,7 +165,7 @@ namespace gl case rsx::texture_wrap_mode::mirror_once_clamp: return GL_MIRROR_CLAMP_EXT; } - LOG_ERROR(RSX, "Texture wrap error: bad wrap (%d)", (u32)wrap); + LOG_ERROR(RSX, "Texture wrap error: bad wrap (%d)", static_cast(wrap)); return GL_REPEAT; } @@ -183,7 +183,7 @@ namespace gl case rsx::texture_max_anisotropy::x16: return 16.0f; } - LOG_ERROR(RSX, "Texture anisotropy error: bad max aniso (%d)", (u32)aniso); + LOG_ERROR(RSX, "Texture anisotropy error: bad max aniso (%d)", static_cast(aniso)); return 1.0f; } @@ -245,7 +245,7 @@ namespace gl case GL_LINEAR_MIPMAP_LINEAR: min_filter = GL_LINEAR; break; default: - LOG_ERROR(RSX, "No mipmap fallback defined for rsx_min_filter = 0x%X", (u32)tex.min_filter()); + LOG_ERROR(RSX, "No mipmap fallback defined for rsx_min_filter = 0x%X", static_cast(tex.min_filter())); min_filter = GL_NEAREST; } } @@ -273,7 +273,7 @@ namespace gl texture_format == CELL_GCM_TEXTURE_DEPTH16_FLOAT || texture_format == CELL_GCM_TEXTURE_DEPTH24_D8_FLOAT) { //NOTE: The stored texture function is reversed wrt the textureProj compare function - GLenum compare_mode = (GLenum)tex.zfunc() | GL_NEVER; + GLenum compare_mode = static_cast(tex.zfunc()) | GL_NEVER; switch (compare_mode) { @@ -672,7 +672,7 @@ namespace gl case GL_DEPTH32F_STENCIL8: return 4; default: - fmt::throw_exception("Unexpected internal format 0x%X" HERE, (u32)format); + fmt::throw_exception("Unexpected internal format 0x%X" HERE, static_cast(format)); } } @@ -703,7 +703,7 @@ namespace gl case GL_DEPTH32F_STENCIL8: return { true, 4 }; default: - fmt::throw_exception("Unexpected internal format 0x%X" HERE, (u32)format); + fmt::throw_exception("Unexpected internal format 0x%X" HERE, static_cast(format)); } } @@ -794,13 +794,13 @@ namespace gl if (LIKELY(caps.ARB_compute_shader_supported)) { // Raw copy - src->copy_to(nullptr, (texture::format)pack_info.format, (texture::type)pack_info.type, src_region, {}); + src->copy_to(nullptr, static_cast(pack_info.format), static_cast(pack_info.type), src_region, {}); } else { pixel_pack_settings pack_settings{}; pack_settings.swap_bytes(pack_info.swap_bytes); - src->copy_to(nullptr, (texture::format)pack_info.format, (texture::type)pack_info.type, src_region, pack_settings); + src->copy_to(nullptr, static_cast(pack_info.format), static_cast(pack_info.type), src_region, pack_settings); } glBindBuffer(GL_PIXEL_PACK_BUFFER, GL_NONE); @@ -847,7 +847,7 @@ namespace gl } g_typeless_transfer_buffer.bind(buffer::target::pixel_unpack); - dst->copy_from(nullptr, (texture::format)unpack_info.format, (texture::type)unpack_info.type, dst_region, unpack_settings); + dst->copy_from(nullptr, static_cast(pack_info.format), static_cast(pack_info.type), dst_region, unpack_settings); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, GL_NONE); } diff --git a/rpcs3/Emu/RSX/GL/GLTextureCache.h b/rpcs3/Emu/RSX/GL/GLTextureCache.h index 67899b6949..c8a9685280 100644 --- a/rpcs3/Emu/RSX/GL/GLTextureCache.h +++ b/rpcs3/Emu/RSX/GL/GLTextureCache.h @@ -184,11 +184,11 @@ namespace gl // AMD driver bug // Pixel transfer fails with GL_OUT_OF_MEMORY. Usually happens with float textures or operations attempting to swap endianness. // Failed operations also leak a large amount of memory - LOG_ERROR(RSX, "Memory transfer failure (AMD bug). Please update your driver to Adrenalin 19.4.3 or newer. Format=0x%x, Type=0x%x, Swap=%d", (u32)format, (u32)type, pack_unpack_swap_bytes); + LOG_ERROR(RSX, "Memory transfer failure (AMD bug). Please update your driver to Adrenalin 19.4.3 or newer. Format=0x%x, Type=0x%x, Swap=%d", static_cast(format), static_cast(type), pack_unpack_swap_bytes); } else { - LOG_ERROR(RSX, "Memory transfer failed with error 0x%x. Format=0x%x, Type=0x%x", error, (u32)format, (u32)type); + LOG_ERROR(RSX, "Memory transfer failed with error 0x%x. Format=0x%x, Type=0x%x", error, static_cast(format), static_cast(type)); } } @@ -233,7 +233,7 @@ namespace gl } areai src_area = { 0, 0, 0, 0 }; - const areai dst_area = { 0, 0, (s32)real_width, (s32)real_height }; + const areai dst_area = { 0, 0, static_cast(real_width), static_cast(real_height) }; auto ifmt = vram_texture->get_internal_format(); src_area.x2 = vram_texture->width(); @@ -255,7 +255,7 @@ namespace gl if (!scaled_texture) { - scaled_texture = std::make_unique(GL_TEXTURE_2D, real_width, real_height, 1, 1, (GLenum)ifmt); + scaled_texture = std::make_unique(GL_TEXTURE_2D, real_width, real_height, 1, 1, static_cast(ifmt)); } const bool linear_interp = is_depth_texture() ? false : true; @@ -510,7 +510,7 @@ namespace gl } std::array swizzle; - if (!src || (GLenum)src->get_internal_format() != sized_internal_fmt) + if (!src || static_cast(src->get_internal_format()) != sized_internal_fmt) { // Apply base component map onto the new texture if a data cast has been done swizzle = get_component_mapping(gcm_format, rsx::texture_create_flags::default_component_order); @@ -575,7 +575,7 @@ namespace gl continue; const bool typeless = dst_aspect != slice.src->aspect() || - !formats_are_bitcast_compatible((GLenum)slice.src->get_internal_format(), (GLenum)dst_image->get_internal_format()); + !formats_are_bitcast_compatible(static_cast(slice.src->get_internal_format()), static_cast(dst_image->get_internal_format())); std::unique_ptr tmp; auto src_image = slice.src; @@ -601,7 +601,7 @@ namespace gl { const auto src_bpp = slice.src->pitch() / slice.src->width(); const u16 convert_w = u16(slice.src->width() * src_bpp) / dst_bpp; - tmp = std::make_unique(GL_TEXTURE_2D, convert_w, slice.src->height(), 1, 1, (GLenum)dst_image->get_internal_format()); + tmp = std::make_unique(GL_TEXTURE_2D, convert_w, slice.src->height(), 1, 1, static_cast(dst_image->get_internal_format())); src_image = tmp.get(); @@ -620,7 +620,7 @@ namespace gl if (src_w == slice.dst_w && src_h == slice.dst_h) { glCopyImageSubData(src_image->id(), GL_TEXTURE_2D, 0, src_x, src_y, 0, - dst_image->id(), (GLenum)dst_image->get_target(), slice.level, slice.dst_x, slice.dst_y, slice.dst_z, src_w, src_h, 1); + dst_image->id(), static_cast(dst_image->get_target()), slice.level, slice.dst_x, slice.dst_y, slice.dst_z, src_w, src_h, 1); } else { @@ -637,7 +637,7 @@ namespace gl } else { - tmp = std::make_unique(GL_TEXTURE_2D, dst_rect.x2, dst_rect.y2, 1, 1, (GLenum)slice.src->get_internal_format()); + tmp = std::make_unique(GL_TEXTURE_2D, dst_rect.x2, dst_rect.y2, 1, 1, static_cast(slice.src->get_internal_format())); _dst = tmp.get(); } @@ -648,7 +648,7 @@ namespace gl { // Data cast comes after scaling glCopyImageSubData(tmp->id(), GL_TEXTURE_2D, 0, slice.dst_x, slice.dst_y, 0, - dst_image->id(), (GLenum)dst_image->get_target(), slice.level, slice.dst_x, slice.dst_y, slice.dst_z, slice.dst_w, slice.dst_h, 1); + dst_image->id(), static_cast(dst_image->get_target()), slice.level, slice.dst_x, slice.dst_y, slice.dst_z, slice.dst_w, slice.dst_h, 1); } } } @@ -702,7 +702,7 @@ namespace gl gl::texture_view* create_temporary_subresource_view(gl::command_context &cmd, gl::texture* src, u32 gcm_format, u16 x, u16 y, u16 w, u16 h, const rsx::texture_channel_remap_t& remap_vector) override { - return create_temporary_subresource_impl(cmd, src, (GLenum)src->get_internal_format(), + return create_temporary_subresource_impl(cmd, src, static_cast(src->get_internal_format()), GL_TEXTURE_2D, gcm_format, x, y, w, h, remap_vector, true); } @@ -764,8 +764,8 @@ namespace gl const rsx::texture_channel_remap_t& remap_vector) override { const auto _template = sections_to_copy.front().src; - const GLenum ifmt = (GLenum)_template->get_internal_format(); - const u8 mipmaps = (u8)sections_to_copy.size(); + const GLenum ifmt = static_cast(_template->get_internal_format()); + const u8 mipmaps = ::narrow(sections_to_copy.size()); const auto swizzle = _template->get_native_component_layout(); auto image_ptr = new gl::viewable_image(GL_TEXTURE_2D, width, height, 1, mipmaps, ifmt); @@ -932,7 +932,7 @@ namespace gl { default: //TODO - warn_once("Format incompatibility detected, reporting failure to force data copy (GL_INTERNAL_FORMAT=0x%X, GCM_FORMAT=0x%X)", (u32)ifmt, gcm_format); + warn_once("Format incompatibility detected, reporting failure to force data copy (GL_INTERNAL_FORMAT=0x%X, GCM_FORMAT=0x%X)", static_cast(ifmt), gcm_format); return false; case CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT: return (ifmt == gl::texture::internal_format::rgba16f); diff --git a/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp b/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp index 057c9dc505..016f7151e6 100644 --- a/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp +++ b/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp @@ -26,7 +26,7 @@ namespace verify(HERE), !gl::is_primitive_native(primitive_mode); auto mapping = dst.alloc_from_heap(element_count * sizeof(u16), 256); - char *mapped_buffer = (char *)mapping.first; + auto mapped_buffer = static_cast(mapping.first); write_index_array_for_non_indexed_non_native_primitive_to_buffer(mapped_buffer, primitive_mode, vertex_count); return std::make_tuple(element_count, mapping.second); @@ -92,14 +92,14 @@ namespace rsx::index_array_type type = rsx::method_registers.current_draw_clause.is_immediate_draw? rsx::index_array_type::u32: rsx::method_registers.index_type(); - + u32 type_size = get_index_type_size(type); const u32 vertex_count = rsx::method_registers.current_draw_clause.get_elements_count(); u32 index_count = vertex_count; - + if (!gl::is_primitive_native(rsx::method_registers.current_draw_clause.primitive)) - index_count = (u32)get_index_count(rsx::method_registers.current_draw_clause.primitive, vertex_count); + index_count = static_cast(get_index_count(rsx::method_registers.current_draw_clause.primitive, vertex_count)); u32 max_size = index_count * type_size; auto mapping = m_index_ring_buffer.alloc_from_heap(max_size, 256); @@ -228,7 +228,7 @@ gl::vertex_upload_info GLGSRender::set_vertex_buffer() const size_t view_size = ((upload_info.persistent_mapping_offset + m_max_texbuffer_size) > m_attrib_ring_buffer->size()) ? (m_attrib_ring_buffer->size() - upload_info.persistent_mapping_offset) : m_max_texbuffer_size; - m_persistent_stream_view.update(m_attrib_ring_buffer.get(), upload_info.persistent_mapping_offset, (u32)view_size); + m_persistent_stream_view.update(m_attrib_ring_buffer.get(), upload_info.persistent_mapping_offset, static_cast(view_size)); m_gl_persistent_stream_buffer->copy_from(m_persistent_stream_view); upload_info.persistent_mapping_offset = 0; } @@ -245,7 +245,7 @@ gl::vertex_upload_info GLGSRender::set_vertex_buffer() const size_t view_size = ((upload_info.volatile_mapping_offset + m_max_texbuffer_size) > m_attrib_ring_buffer->size()) ? (m_attrib_ring_buffer->size() - upload_info.volatile_mapping_offset) : m_max_texbuffer_size; - m_volatile_stream_view.update(m_attrib_ring_buffer.get(), upload_info.volatile_mapping_offset, (u32)view_size); + m_volatile_stream_view.update(m_attrib_ring_buffer.get(), upload_info.volatile_mapping_offset, static_cast(view_size)); m_gl_volatile_stream_buffer->copy_from(m_volatile_stream_view); upload_info.volatile_mapping_offset = 0; } diff --git a/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp b/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp index 19f64893d0..c077ddd070 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp @@ -63,7 +63,7 @@ namespace rsx background_poster.set_size(1280, 720); background_poster.set_raw_image(background_image.get()); - background_poster.set_blur_strength((u8)g_cfg.video.shader_preloading_dialog.blur_strength); + background_poster.set_blur_strength(static_cast(g_cfg.video.shader_preloading_dialog.blur_strength)); } } } @@ -248,7 +248,7 @@ namespace rsx progress_2.inc(value); if (index == taskbar_index || taskbar_index == -1) - Emu.GetCallbacks().handle_taskbar_progress(1, (s32)value); + Emu.GetCallbacks().handle_taskbar_progress(1, static_cast(value)); return CELL_OK; } @@ -274,9 +274,9 @@ namespace rsx return CELL_MSGDIALOG_ERROR_PARAM; if (index == 0) - progress_1.set_limit((float)limit); + progress_1.set_limit(static_cast(limit)); else - progress_2.set_limit((float)limit); + progress_2.set_limit(static_cast(limit)); if (index == taskbar_index) { diff --git a/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp b/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp index d3e954f253..33fa4ed8e4 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp @@ -239,7 +239,7 @@ namespace rsx auto on_accept = [&]() { const u32 current_index = (selected_y * num_columns) + selected_x; - const u32 output_count = (u32)m_grid[current_index].outputs.size(); + const u32 output_count = ::size32(m_grid[current_index].outputs); if (output_count) { diff --git a/rpcs3/Emu/RSX/Overlays/overlay_progress_bar.cpp b/rpcs3/Emu/RSX/Overlays/overlay_progress_bar.cpp index 8c90858b16..7b099501d5 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_progress_bar.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_progress_bar.cpp @@ -31,7 +31,7 @@ namespace rsx m_value = std::clamp(value, 0.f, m_limit); f32 indicator_width = (w * m_value) / m_limit; - indicator.set_size((u16)indicator_width, h); + indicator.set_size(static_cast(indicator_width), h); is_compiled = false; } diff --git a/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp b/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp index 561737d108..bb727a6c2c 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp @@ -136,7 +136,7 @@ namespace rsx m_list->select_next(10); break; default: - LOG_TRACE(RSX, "[ui] Button %d pressed", (u8)button_press); + LOG_TRACE(RSX, "[ui] Button %d pressed", static_cast(button_press)); } } diff --git a/rpcs3/Emu/RSX/Overlays/overlays.cpp b/rpcs3/Emu/RSX/Overlays/overlays.cpp index 0ed7006e2e..9f8182cb61 100644 --- a/rpcs3/Emu/RSX/Overlays/overlays.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlays.cpp @@ -58,13 +58,19 @@ static auto s_ascii_lowering_map = []() std::string utf8_to_ascii8(const std::string& utf8_string) { - std::vector out; - out.reserve(utf8_string.length() + 1); + std::string out; + out.reserve(utf8_string.length()); const auto end = utf8_string.length(); for (u32 index = 0; index < end; ++index) { - const auto code = (u8)utf8_string[index]; + const u8 code = static_cast(utf8_string[index]); + + if (code == 0) + { + break; + } + if (code <= 0x7F) { out.push_back(code); @@ -103,7 +109,7 @@ std::string utf8_to_ascii8(const std::string& utf8_string) if (u_code <= 0xFF) { // Latin-1 supplement block - out.push_back(u8(u_code)); + out.push_back(static_cast(u_code)); continue; } @@ -117,37 +123,40 @@ std::string utf8_to_ascii8(const std::string& utf8_string) out.push_back(replace->second); } - out.push_back(0); - return { reinterpret_cast(out.data()) }; + return out; } std::string utf16_to_ascii8(const std::u16string& utf16_string) { // Strip extended codes, map to '#' instead (placeholder) - std::vector out; - out.reserve(utf16_string.length() + 1); + std::string out; + out.reserve(utf16_string.length()); for (const auto& code : utf16_string) { - out.push_back(code > 0xFF ? '#': (u8)code); + if (!code) + break; + + out.push_back(code > 0xFF ? '#': static_cast(code)); } - out.push_back(0); - return { reinterpret_cast(out.data()) }; + return out; } std::u16string ascii8_to_utf16(const std::string& ascii_string) { - std::vector out; - out.reserve(ascii_string.length() + 1); + std::u16string out; + out.reserve(ascii_string.length()); for (const auto& code : ascii_string) { - out.push_back((char16_t)code); + if (!code) + break; + + out.push_back(static_cast(code)); } - out.push_back(0); - return { out.data() }; + return out; } namespace rsx diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 2f40238fe3..53a49914da 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -154,7 +154,7 @@ namespace rsx default: break; } - fmt::throw_exception("RSXVertexData::GetTypeSize: Bad vertex data type (%d)!" HERE, (u8)type); + fmt::throw_exception("RSXVertexData::GetTypeSize: Bad vertex data type (%d)!" HERE, static_cast(type)); } void tiled_region::write(const void *src, u32 width, u32 height, u32 pitch) @@ -174,7 +174,7 @@ namespace rsx case CELL_GCM_COMPMODE_DISABLED: for (u32 y = 0; y < height; ++y) { - memcpy(ptr + (offset_y + y) * tile->pitch + offset_x, (u8*)src + pitch * y, pitch); + memcpy(ptr + (offset_y + y) * tile->pitch + offset_x, static_cast(src) + pitch * y, pitch); } break; /* @@ -196,12 +196,12 @@ namespace rsx { for (u32 x = 0; x < width; ++x) { - u32 value = *(u32*)((u8*)src + pitch * y + x * sizeof(u32)); + u32 value = *reinterpret_cast(static_cast(src) + pitch * y + x * sizeof(u32)); - *(u32*)(ptr + (offset_y + y * 2 + 0) * tile->pitch + offset_x + (x * 2 + 0) * sizeof(u32)) = value; - *(u32*)(ptr + (offset_y + y * 2 + 0) * tile->pitch + offset_x + (x * 2 + 1) * sizeof(u32)) = value; - *(u32*)(ptr + (offset_y + y * 2 + 1) * tile->pitch + offset_x + (x * 2 + 0) * sizeof(u32)) = value; - *(u32*)(ptr + (offset_y + y * 2 + 1) * tile->pitch + offset_x + (x * 2 + 1) * sizeof(u32)) = value; + *reinterpret_cast(ptr + (offset_y + y * 2 + 0) * tile->pitch + offset_x + (x * 2 + 0) * sizeof(u32)) = value; + *reinterpret_cast(ptr + (offset_y + y * 2 + 0) * tile->pitch + offset_x + (x * 2 + 1) * sizeof(u32)) = value; + *reinterpret_cast(ptr + (offset_y + y * 2 + 1) * tile->pitch + offset_x + (x * 2 + 0) * sizeof(u32)) = value; + *reinterpret_cast(ptr + (offset_y + y * 2 + 1) * tile->pitch + offset_x + (x * 2 + 1) * sizeof(u32)) = value; } } break; @@ -227,7 +227,7 @@ namespace rsx case CELL_GCM_COMPMODE_DISABLED: for (u32 y = 0; y < height; ++y) { - memcpy((u8*)dst + pitch * y, ptr + (offset_y + y) * tile->pitch + offset_x, pitch); + memcpy(static_cast(dst) + pitch * y, ptr + (offset_y + y) * tile->pitch + offset_x, pitch); } break; /* @@ -248,9 +248,9 @@ namespace rsx { for (u32 x = 0; x < width; ++x) { - u32 value = *(u32*)(ptr + (offset_y + y * 2 + 0) * tile->pitch + offset_x + (x * 2 + 0) * sizeof(u32)); + u32 value = *reinterpret_cast(ptr + (offset_y + y * 2 + 0) * tile->pitch + offset_x + (x * 2 + 0) * sizeof(u32)); - *(u32*)((u8*)dst + pitch * y + x * sizeof(u32)) = value; + *reinterpret_cast(static_cast(dst) + pitch * y + x * sizeof(u32)) = value; } } break; @@ -342,7 +342,7 @@ namespace rsx u32 thread::get_push_buffer_index_count() const { - return (u32)element_push_buffer.size(); + return ::size32(element_push_buffer); } void thread::end() @@ -497,7 +497,7 @@ namespace rsx { // Save the difference before pause start_time = get_system_time() - start_time; - + while (Emu.IsPaused() && !m_rsx_thread_exiting) { thread_ctrl::wait_for(wait_sleep); @@ -631,9 +631,9 @@ namespace rsx float one = 1.f; stream_vector(buffer, std::bit_cast(scale_x), 0, 0, std::bit_cast(offset_x)); - stream_vector((char*)buffer + 16, 0, std::bit_cast(scale_y), 0, std::bit_cast(offset_y)); - stream_vector((char*)buffer + 32, 0, 0, std::bit_cast(scale_z), std::bit_cast(offset_z)); - stream_vector((char*)buffer + 48, 0, 0, 0, std::bit_cast(one)); + stream_vector(static_cast(buffer) + 16, 0, std::bit_cast(scale_y), 0, std::bit_cast(offset_y)); + stream_vector(static_cast(buffer) + 32, 0, 0, std::bit_cast(scale_z), std::bit_cast(offset_z)); + stream_vector(static_cast(buffer) + 48, 0, 0, 0, std::bit_cast(one)); } void thread::fill_user_clip_data(void *buffer) const @@ -657,7 +657,7 @@ namespace rsx switch (clip_plane_control[index]) { default: - LOG_ERROR(RSX, "bad clip plane control (0x%x)", (u8)clip_plane_control[index]); + LOG_ERROR(RSX, "bad clip plane control (0x%x)", static_cast(clip_plane_control[index])); case rsx::user_clip_plane_op::disable: clip_enabled_flags[index] = 0; @@ -749,7 +749,7 @@ namespace rsx const auto window_origin = rsx::method_registers.shader_window_origin(); const u32 window_height = rsx::method_registers.shader_window_height(); - const f32 resolution_scale = (window_height <= (u32)g_cfg.video.min_scalable_dimension)? 1.f : rsx::get_resolution_scale(); + const f32 resolution_scale = (window_height <= static_cast(g_cfg.video.min_scalable_dimension)) ? 1.f : rsx::get_resolution_scale(); const f32 wpos_scale = (window_origin == rsx::window_origin::top) ? (1.f / resolution_scale) : (-1.f / resolution_scale); const f32 wpos_bias = (window_origin == rsx::window_origin::top) ? 0.f : window_height; @@ -783,7 +783,7 @@ namespace rsx if (!element_push_buffer.empty()) { //Indices provided via immediate mode - return{(const std::byte*)element_push_buffer.data(), ::narrow(element_push_buffer.size() * sizeof(u32))}; + return{reinterpret_cast(element_push_buffer.data()), ::narrow(element_push_buffer.size() * sizeof(u32))}; } const rsx::index_array_type type = rsx::method_registers.index_type(); @@ -1019,7 +1019,7 @@ namespace rsx m_framebuffer_state_contested = color_buffer_unused || depth_buffer_unused; break; default: - fmt::throw_exception("Unknown framebuffer context 0x%x" HERE, (u32)context); + fmt::throw_exception("Unknown framebuffer context 0x%x" HERE, static_cast(context)); } // Swizzled render does tight packing of bytes @@ -1030,7 +1030,7 @@ namespace rsx switch (const auto mode = rsx::method_registers.surface_type()) { default: - LOG_ERROR(RSX, "Unknown raster mode 0x%x", (u32)mode); + LOG_ERROR(RSX, "Unknown raster mode 0x%x", static_cast(mode)); [[fallthrough]]; case rsx::surface_raster_type::linear: break; @@ -1085,7 +1085,7 @@ namespace rsx // Unlike the depth buffer, when given a color target we know it is intended to be rendered to LOG_ERROR(RSX, "Framebuffer setup error: Color target failed pitch check, Pitch=[%d, %d, %d, %d] + %d, target=%d, context=%d", layout.color_pitch[0], layout.color_pitch[1], layout.color_pitch[2], layout.color_pitch[3], - layout.zeta_pitch, (u32)layout.target, (u32)context); + layout.zeta_pitch, static_cast(layout.target), static_cast(context)); // Do not remove this buffer for now as it implies something went horribly wrong anyway break; @@ -1094,7 +1094,7 @@ namespace rsx if (layout.color_addresses[index] == layout.zeta_address) { LOG_WARNING(RSX, "Framebuffer at 0x%X has aliasing color/depth targets, color_index=%d, zeta_pitch = %d, color_pitch=%d, context=%d", - layout.zeta_address, index, layout.zeta_pitch, layout.color_pitch[index], (u32)context); + layout.zeta_address, index, layout.zeta_pitch, layout.color_pitch[index], static_cast(context)); m_framebuffer_state_contested = true; @@ -1316,7 +1316,7 @@ namespace rsx const auto &tex = rsx::method_registers.vertex_textures[i]; if (tex.enabled() && (current_vp_metadata.referenced_textures_mask & (1 << i))) { - current_vertex_program.texture_dimensions |= ((u32)sampler_descriptors[i]->image_type << (i << 1)); + current_vertex_program.texture_dimensions |= (static_cast(sampler_descriptors[i]->image_type) << (i << 1)); } } } @@ -1548,7 +1548,7 @@ namespace rsx result.addr = vm::base(rsx::get_address(program_offset, program_location)); current_fp_metadata = program_hash_util::fragment_program_utils::analyse_fragment_program(result.addr); - result.addr = ((u8*)result.addr + current_fp_metadata.program_start_offset); + result.addr = (static_cast(result.addr) + current_fp_metadata.program_start_offset); result.offset = program_offset + current_fp_metadata.program_start_offset; result.ucode_length = current_fp_metadata.program_ucode_length; result.valid = true; @@ -1578,7 +1578,7 @@ namespace rsx if (tex.enabled() && (current_fp_metadata.referenced_textures_mask & (1 << i))) { u32 texture_control = 0; - result.texture_dimensions |= ((u32)sampler_descriptors[i]->image_type << (i << 1)); + result.texture_dimensions |= (static_cast(sampler_descriptors[i]->image_type) << (i << 1)); if (tex.alpha_kill_enabled()) { @@ -1747,7 +1747,7 @@ namespace rsx u32 persistent_memory_size = 0; u32 volatile_memory_size = 0; - volatile_memory_size += (u32)layout.referenced_registers.size() * 16u; + volatile_memory_size += ::size32(layout.referenced_registers) * 16u; if (rsx::method_registers.current_draw_clause.command == rsx::draw_command::inlined_array) { @@ -1847,7 +1847,7 @@ namespace rsx { if (layout.attribute_placement[index] == attribute_buffer_placement::none) { - ((u64*)buffer)[index] = 0ull; + reinterpret_cast(buffer)[index] = 0; continue; } @@ -1988,8 +1988,8 @@ namespace rsx void thread::write_vertex_data_to_memory(const vertex_input_layout& layout, u32 first_vertex, u32 vertex_count, void *persistent_data, void *volatile_data) { - char *transient = (char *)volatile_data; - char *persistent = (char *)persistent_data; + auto transient = static_cast(volatile_data); + auto persistent = static_cast(persistent_data); auto &draw_call = rsx::method_registers.current_draw_clause; @@ -2035,7 +2035,7 @@ namespace rsx const u32 data_size = range.second * block.attribute_stride; const u32 vertex_base = range.first * block.attribute_stride; - g_dma_manager.copy(persistent, (char*)vm::base(block.real_offset_address) + vertex_base, data_size); + g_dma_manager.copy(persistent, vm::_ptr(block.real_offset_address) + vertex_base, data_size); persistent += data_size; } } @@ -2312,7 +2312,7 @@ namespace rsx const auto elapsed = timestamp - performance_counters.last_update_timestamp; if (elapsed > idle) - performance_counters.approximate_load = (u32)((elapsed - idle) * 100 / elapsed); + performance_counters.approximate_load = static_cast((elapsed - idle) * 100 / elapsed); else performance_counters.approximate_load = 0u; diff --git a/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp b/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp index e6a67e6418..2a88c73223 100644 --- a/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp +++ b/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp @@ -1,8 +1,22 @@ #include "stdafx.h" #include "VKCommonDecompiler.h" + +#ifdef _MSC_VER +#pragma warning(push, 0) +#else +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wall" +#pragma GCC diagnostic ignored "-Wextra" +#pragma GCC diagnostic ignored "-Wold-style-cast" +#endif #include "restore_new.h" #include "SPIRV/GlslangToSpv.h" #include "define_new_memleakdetect.h" +#ifdef _MSC_VER +#pragma warning(pop) +#else +#pragma GCC diagnostic pop +#endif namespace vk { @@ -155,7 +169,7 @@ namespace vk shader_object.setStrings(&shader_text, 1); - EShMessages msg = (EShMessages)(EShMsgVulkanRules | EShMsgSpvRules); + EShMessages msg = static_cast(EShMsgVulkanRules | EShMsgSpvRules); if (shader_object.parse(&g_default_config, 400, EProfile::ECoreProfile, false, true, msg)) { program.addShader(&shader_object); diff --git a/rpcs3/Emu/RSX/VK/VKCompute.h b/rpcs3/Emu/RSX/VK/VKCompute.h index 6aa5aef963..25b2a6d611 100644 --- a/rpcs3/Emu/RSX/VK/VKCompute.h +++ b/rpcs3/Emu/RSX/VK/VKCompute.h @@ -59,12 +59,12 @@ namespace vk } // Reserve descriptor pools - m_descriptor_pool.create(*get_current_renderer(), descriptor_pool_sizes.data(), (u32)descriptor_pool_sizes.size(), VK_MAX_COMPUTE_TASKS, 2); + m_descriptor_pool.create(*get_current_renderer(), descriptor_pool_sizes.data(), ::size32(descriptor_pool_sizes), VK_MAX_COMPUTE_TASKS, 2); VkDescriptorSetLayoutCreateInfo infos = {}; infos.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; infos.pBindings = bindings.data(); - infos.bindingCount = (u32)bindings.size(); + infos.bindingCount = ::size32(bindings); CHECK_RESULT(vkCreateDescriptorSetLayout(*get_current_renderer(), &infos, nullptr, &m_descriptor_layout)); @@ -212,7 +212,7 @@ namespace vk { // AMD hw reports an annoyingly small maximum number of invocations in the X dimension // Split the 1D job into 2 dimensions to accomodate this - invocations_x = (u32)floor(std::sqrt(num_invocations)); + invocations_x = static_cast(floor(std::sqrt(num_invocations))); invocations_y = invocations_x; if (num_invocations % invocations_x) invocations_y++; @@ -584,7 +584,7 @@ namespace vk u32 in_offset = 0; u32 out_offset = 0; u32 block_length = 0; - + cs_deswizzle_3d() { verify("Unsupported block type" HERE), (sizeof(_BlockType) & 3) == 0; diff --git a/rpcs3/Emu/RSX/VK/VKFormats.cpp b/rpcs3/Emu/RSX/VK/VKFormats.cpp index 850234f225..956bcaf0ec 100644 --- a/rpcs3/Emu/RSX/VK/VKFormats.cpp +++ b/rpcs3/Emu/RSX/VK/VKFormats.cpp @@ -45,7 +45,7 @@ namespace vk default: break; } - fmt::throw_exception("Invalid format (0x%x)" HERE, (u32)format); + fmt::throw_exception("Invalid format (0x%x)" HERE, static_cast(format)); } minification_filter get_min_filter(rsx::texture_minify_filter min_filter) @@ -77,7 +77,7 @@ namespace vk ASSUME(0); break; } - fmt::throw_exception("Invalid mag filter (0x%x)" HERE, (u32)mag_filter); + fmt::throw_exception("Invalid mag filter (0x%x)" HERE, static_cast(mag_filter)); } VkBorderColor get_border_color(u32 color) @@ -151,7 +151,7 @@ namespace vk break; } - fmt::throw_exception("Texture anisotropy error: bad max aniso (%d)" HERE, (u32)gcm_aniso); + fmt::throw_exception("Texture anisotropy error: bad max aniso (%d)" HERE, static_cast(gcm_aniso)); } @@ -325,7 +325,7 @@ namespace vk break; } - fmt::throw_exception("Unexpected vkFormat 0x%X", (u32)format); + fmt::throw_exception("Unexpected vkFormat 0x%X", static_cast(format)); } std::pair get_format_element_size(VkFormat format) @@ -386,7 +386,7 @@ namespace vk break; } - fmt::throw_exception("Unexpected vkFormat 0x%X", (u32)format); + fmt::throw_exception("Unexpected vkFormat 0x%X", static_cast(format)); } std::pair get_format_convert_flags(VkFormat format) @@ -438,7 +438,7 @@ namespace vk break; } - fmt::throw_exception("Unknown vkFormat 0x%x" HERE, (u32)format); + fmt::throw_exception("Unknown vkFormat 0x%x" HERE, static_cast(format)); } bool formats_are_bitcast_compatible(VkFormat format1, VkFormat format2) diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index 9b7bcfda1c..d3ff600d90 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -54,7 +54,7 @@ namespace vk case rsx::comparison_function::not_equal: return VK_COMPARE_OP_NOT_EQUAL; case rsx::comparison_function::always: return VK_COMPARE_OP_ALWAYS; default: - fmt::throw_exception("Unknown compare op: 0x%x" HERE, (u32)op); + fmt::throw_exception("Unknown compare op: 0x%x" HERE, static_cast(op)); } } @@ -117,7 +117,7 @@ namespace vk return std::make_pair(VK_FORMAT_R32_SFLOAT, vk::default_component_map()); default: - LOG_ERROR(RSX, "Surface color buffer: Unsupported surface color format (0x%x)", (u32)color_format); + LOG_ERROR(RSX, "Surface color buffer: Unsupported surface color format (0x%x)", static_cast(color_format)); return std::make_pair(VK_FORMAT_B8G8R8A8_UNORM, vk::default_component_map()); } } @@ -143,7 +143,7 @@ namespace vk case rsx::logic_op::logic_nand: return VK_LOGIC_OP_NAND; case rsx::logic_op::logic_set: return VK_LOGIC_OP_SET; default: - fmt::throw_exception("Unknown logic op 0x%x" HERE, (u32)op); + fmt::throw_exception("Unknown logic op 0x%x" HERE, static_cast(op)); } } @@ -167,7 +167,7 @@ namespace vk case rsx::blend_factor::one_minus_constant_color: return VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR; case rsx::blend_factor::src_alpha_saturate: return VK_BLEND_FACTOR_SRC_ALPHA_SATURATE; default: - fmt::throw_exception("Unknown blend factor 0x%x" HERE, (u32)factor); + fmt::throw_exception("Unknown blend factor 0x%x" HERE, static_cast(factor)); } } @@ -186,7 +186,7 @@ namespace vk case rsx::blend_equation::min: return VK_BLEND_OP_MIN; case rsx::blend_equation::max: return VK_BLEND_OP_MAX; default: - fmt::throw_exception("Unknown blend op: 0x%x" HERE, (u32)op); + fmt::throw_exception("Unknown blend op: 0x%x" HERE, static_cast(op)); } } @@ -204,7 +204,7 @@ namespace vk case rsx::stencil_op::incr_wrap: return VK_STENCIL_OP_INCREMENT_AND_WRAP; case rsx::stencil_op::decr_wrap: return VK_STENCIL_OP_DECREMENT_AND_WRAP; default: - fmt::throw_exception("Unknown stencil op: 0x%x" HERE, (u32)op); + fmt::throw_exception("Unknown stencil op: 0x%x" HERE, static_cast(op)); } } @@ -215,7 +215,7 @@ namespace vk case rsx::front_face::cw: return VK_FRONT_FACE_CLOCKWISE; case rsx::front_face::ccw: return VK_FRONT_FACE_COUNTER_CLOCKWISE; default: - fmt::throw_exception("Unknown front face value: 0x%x" HERE, (u32)ffv); + fmt::throw_exception("Unknown front face value: 0x%x" HERE, static_cast(ffv)); } } @@ -227,7 +227,7 @@ namespace vk case rsx::cull_face::front: return VK_CULL_MODE_FRONT_BIT; case rsx::cull_face::front_and_back: return VK_CULL_MODE_FRONT_AND_BACK; default: - fmt::throw_exception("Unknown cull face value: 0x%x" HERE, (u32)cfv); + fmt::throw_exception("Unknown cull face value: 0x%x" HERE, static_cast(cfv)); } } } @@ -398,7 +398,7 @@ VKGSRender::VKGSRender() : GSRender() return; } - m_device = (vk::render_device*)(&m_swapchain->get_device()); + m_device = const_cast(&m_swapchain->get_device()); vk::set_current_thread_ctx(m_thread_context); vk::set_current_renderer(m_swapchain->get_device()); @@ -1381,12 +1381,12 @@ void VKGSRender::end() f32 actual_mipmaps; if (sampler_state->upload_context == rsx::texture_upload_context::shader_read) { - actual_mipmaps = (f32)mipmap_count; + actual_mipmaps = static_cast(mipmap_count); } else if (sampler_state->external_subresource_desc.op == rsx::deferred_request_command::mipmap_gather) { // Clamp min and max lod - actual_mipmaps = (f32)sampler_state->external_subresource_desc.sections_to_copy.size(); + actual_mipmaps = static_cast(sampler_state->external_subresource_desc.sections_to_copy.size()); } else { @@ -1856,7 +1856,7 @@ void VKGSRender::on_init_thread() type.disable_cancel = true; type.progress_bar_count = 2; - dlg = g_fxo->get()->create((bool)g_cfg.video.shader_preloading_dialog.use_custom_background); + dlg = g_fxo->get()->create(!!g_cfg.video.shader_preloading_dialog.use_custom_background); dlg->progress_bar_set_taskbar_index(-1); dlg->show("Loading precompiled shaders from disk...", type, [](s32 status) { @@ -1874,7 +1874,7 @@ void VKGSRender::on_init_thread() void inc_value(u32 index, u32 value) override { - dlg->progress_bar_increment(index, (f32)value); + dlg->progress_bar_increment(index, static_cast(value)); owner->flip({}); } @@ -1921,7 +1921,7 @@ void VKGSRender::clear_surface(u32 mask) u8 ctx = rsx::framebuffer_creation_context::context_draw; if (mask & 0xF0) ctx |= rsx::framebuffer_creation_context::context_clear_color; if (mask & 0x3) ctx |= rsx::framebuffer_creation_context::context_clear_depth; - init_buffers((rsx::framebuffer_creation_context)ctx); + init_buffers(rsx::framebuffer_creation_context{ctx}); if (!framebuffer_status_valid) return; @@ -1932,10 +1932,10 @@ void VKGSRender::clear_surface(u32 mask) std::vector clear_descriptors; VkClearValue depth_stencil_clear_values = {}, color_clear_values = {}; - u16 scissor_x = (u16)m_scissor.offset.x; - u16 scissor_w = (u16)m_scissor.extent.width; - u16 scissor_y = (u16)m_scissor.offset.y; - u16 scissor_h = (u16)m_scissor.extent.height; + u16 scissor_x = static_cast(m_scissor.offset.x); + u16 scissor_w = static_cast(m_scissor.extent.width); + u16 scissor_y = static_cast(m_scissor.offset.y); + u16 scissor_h = static_cast(m_scissor.extent.height); const u16 fb_width = m_draw_fbo->width(); const u16 fb_height = m_draw_fbo->height(); @@ -1955,7 +1955,7 @@ void VKGSRender::clear_surface(u32 mask) u32 max_depth_value = get_max_depth_value(surface_depth_format); u32 clear_depth = rsx::method_registers.z_clear_value(surface_depth_format == rsx::surface_depth_format::z24s8); - float depth_clear = (float)clear_depth / max_depth_value; + float depth_clear = static_cast(clear_depth) / max_depth_value; depth_stencil_clear_values.depthStencil.depth = depth_clear; depth_stencil_clear_values.depthStencil.stencil = stencil_clear; @@ -2039,10 +2039,10 @@ void VKGSRender::clear_surface(u32 mask) u8 clear_g = rsx::method_registers.clear_color_g(); u8 clear_b = rsx::method_registers.clear_color_b(); - color_clear_values.color.float32[0] = (float)clear_r / 255; - color_clear_values.color.float32[1] = (float)clear_g / 255; - color_clear_values.color.float32[2] = (float)clear_b / 255; - color_clear_values.color.float32[3] = (float)clear_a / 255; + color_clear_values.color.float32[0] = static_cast(clear_r) / 255; + color_clear_values.color.float32[1] = static_cast(clear_g) / 255; + color_clear_values.color.float32[2] = static_cast(clear_b) / 255; + color_clear_values.color.float32[3] = static_cast(clear_a) / 255; if (use_fast_clear) { @@ -2109,7 +2109,7 @@ void VKGSRender::clear_surface(u32 mask) { if (require_mem_load) m_rtts.m_bound_depth_stencil.second->write_barrier(*m_current_command_buffer); - clear_descriptors.push_back({ (VkImageAspectFlags)depth_stencil_mask, 0, depth_stencil_clear_values }); + clear_descriptors.push_back({ static_cast(depth_stencil_mask), 0, depth_stencil_clear_values }); update_z = true; } } @@ -2123,7 +2123,7 @@ void VKGSRender::clear_surface(u32 mask) if (!clear_descriptors.empty()) { begin_render_pass(); - vkCmdClearAttachments(*m_current_command_buffer, (u32)clear_descriptors.size(), clear_descriptors.data(), 1, ®ion); + vkCmdClearAttachments(*m_current_command_buffer, ::size32(clear_descriptors), clear_descriptors.data(), 1, ®ion); close_render_pass(); } } @@ -2530,7 +2530,7 @@ bool VKGSRender::load_program() properties.state.enable_primitive_restart(); // Rasterizer state - properties.state.set_attachment_count((u32)m_draw_buffers.size()); + properties.state.set_attachment_count(::size32(m_draw_buffers)); properties.state.set_front_face(vk::get_front_face(rsx::method_registers.front_face_mode())); properties.state.enable_depth_clamp(rsx::method_registers.depth_clamp_enabled() || !rsx::method_registers.depth_clip_enabled()); properties.state.enable_depth_bias(true); @@ -2711,7 +2711,7 @@ void VKGSRender::load_program_env() // Vertex state const auto mem = m_vertex_env_ring_info.alloc<256>(256); - auto buf = (u8*)m_vertex_env_ring_info.map(mem, 144); + auto buf = static_cast(m_vertex_env_ring_info.map(mem, 144)); fill_scale_offset_data(buf, false); fill_user_clip_data(buf + 64); @@ -2827,7 +2827,7 @@ void VKGSRender::update_vertex_env(u32 id, const vk::vertex_upload_info& vertex_ const size_t data_offset = (id * 128) + m_vertex_layout_stream_info.offset; auto dst = m_vertex_layout_ring_info.map(data_offset, 128); - fill_vertex_layout_state(m_vertex_layout, vertex_info.first_vertex, vertex_info.allocated_vertex_count, (s32*)dst, + fill_vertex_layout_state(m_vertex_layout, vertex_info.first_vertex, vertex_info.allocated_vertex_count, static_cast(dst), vertex_info.persistent_window_offset, vertex_info.volatile_window_offset); m_vertex_layout_ring_info.unmap(); @@ -3279,18 +3279,18 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info) if (!g_cfg.video.stretch_to_display_area) { - const double aq = (double)buffer_width / buffer_height; - const double rq = (double)new_size.width / new_size.height; + const double aq = 1. * buffer_width / buffer_height; + const double rq = 1. * new_size.width / new_size.height; const double q = aq / rq; if (q > 1.0) { - new_size.height = int(new_size.height / q); + new_size.height = static_cast(new_size.height / q); aspect_ratio.y = (csize.height - new_size.height) / 2; } else if (q < 1.0) { - new_size.width = int(new_size.width * q); + new_size.width = static_cast(new_size.width * q); aspect_ratio.x = (csize.width - new_size.width) / 2; } } @@ -3340,7 +3340,7 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info) //Blit contents to screen.. vk::image* image_to_flip = nullptr; - if ((u32)info.buffer < display_buffers_count && buffer_width && buffer_height) + if (info.buffer < display_buffers_count && buffer_width && buffer_height) { const u32 absolute_address = rsx::get_address(display_buffers[info.buffer].offset, CELL_GCM_LOCATION_LOCAL); @@ -3442,7 +3442,7 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info) if (LIKELY(!calibration_src)) { vk::copy_scaled_image(*m_current_command_buffer, image_to_flip->value, target_image, image_to_flip->current_layout, target_layout, - { 0, 0, (s32)buffer_width, (s32)buffer_height }, aspect_ratio, 1, VK_IMAGE_ASPECT_COLOR_BIT, false); + { 0, 0, static_cast(buffer_width), static_cast(buffer_height) }, aspect_ratio, 1, VK_IMAGE_ASPECT_COLOR_BIT, false); } else { @@ -3572,7 +3572,7 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info) const auto num_speculate = m_texture_cache.get_num_cache_speculative_writes(); const auto num_misses = m_texture_cache.get_num_cache_misses(); const auto num_unavoidable = m_texture_cache.get_num_unavoidable_hard_faults(); - const auto cache_miss_ratio = (u32)ceil(m_texture_cache.get_cache_miss_ratio() * 100); + const auto cache_miss_ratio = static_cast(ceil(m_texture_cache.get_cache_miss_ratio() * 100)); m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 0, 144, direct_fbo->width(), direct_fbo->height(), fmt::format("Unreleased textures: %8d", num_dirty_textures)); m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 0, 162, direct_fbo->width(), direct_fbo->height(), fmt::format("Texture cache memory: %7dM", texture_memory_size)); m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 0, 180, direct_fbo->width(), direct_fbo->height(), fmt::format("Temporary texture memory: %3dM", tmp_texture_memory_size)); diff --git a/rpcs3/Emu/RSX/VK/VKHelpers.cpp b/rpcs3/Emu/RSX/VK/VKHelpers.cpp index 279e4a2306..1708c895db 100644 --- a/rpcs3/Emu/RSX/VK/VKHelpers.cpp +++ b/rpcs3/Emu/RSX/VK/VKHelpers.cpp @@ -311,7 +311,7 @@ namespace vk VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, 0); }; - auto &ptr = g_typeless_textures[(u32)format]; + auto& ptr = g_typeless_textures[+format]; if (!ptr || ptr->width() < requested_width || ptr->height() < requested_height) { if (ptr) diff --git a/rpcs3/Emu/RSX/VK/VKHelpers.h b/rpcs3/Emu/RSX/VK/VKHelpers.h index 134b3baeca..0f08d554c8 100644 --- a/rpcs3/Emu/RSX/VK/VKHelpers.h +++ b/rpcs3/Emu/RSX/VK/VKHelpers.h @@ -410,24 +410,24 @@ namespace vk void free(mem_handle_t mem_handle) override { vmm_notify_memory_freed(mem_handle); - vkFreeMemory(m_device, (VkDeviceMemory)mem_handle, nullptr); + vkFreeMemory(m_device, static_cast(mem_handle), nullptr); } void *map(mem_handle_t mem_handle, u64 offset, u64 size) override { void *data = nullptr; - CHECK_RESULT(vkMapMemory(m_device, (VkDeviceMemory)mem_handle, offset, std::max(size, 1u), 0, &data)); + CHECK_RESULT(vkMapMemory(m_device, static_cast(mem_handle), offset, std::max(size, 1u), 0, &data)); return data; } void unmap(mem_handle_t mem_handle) override { - vkUnmapMemory(m_device, (VkDeviceMemory)mem_handle); + vkUnmapMemory(m_device, static_cast(mem_handle)); } VkDeviceMemory get_vk_device_memory(mem_handle_t mem_handle) override { - return (VkDeviceMemory)mem_handle; + return static_cast(mem_handle); } u64 get_vk_device_memory_offset(mem_handle_t /*mem_handle*/) override @@ -577,7 +577,7 @@ private: features2.pNext = &driver_properties; } - auto getPhysicalDeviceFeatures2KHR = (PFN_vkGetPhysicalDeviceFeatures2KHR)vkGetInstanceProcAddr(parent, "vkGetPhysicalDeviceFeatures2KHR"); + auto getPhysicalDeviceFeatures2KHR = reinterpret_cast(vkGetInstanceProcAddr(parent, "vkGetPhysicalDeviceFeatures2KHR")); verify("vkGetInstanceProcAddress failed to find entry point!" HERE), getPhysicalDeviceFeatures2KHR; getPhysicalDeviceFeatures2KHR(dev, &features2); @@ -705,7 +705,7 @@ private: uint32_t get_queue_count() const { if (!queue_props.empty()) - return (u32)queue_props.size(); + return ::size32(queue_props); uint32_t count = 0; vkGetPhysicalDeviceQueueFamilyProperties(dev, &count, nullptr); @@ -852,7 +852,7 @@ private: device.pQueueCreateInfos = &queue; device.enabledLayerCount = 0; device.ppEnabledLayerNames = nullptr; // Deprecated - device.enabledExtensionCount = (u32)requested_extensions.size(); + device.enabledExtensionCount = ::size32(requested_extensions); device.ppEnabledExtensionNames = requested_extensions.data(); device.pEnabledFeatures = &enabled_features; @@ -1060,7 +1060,7 @@ private: VkCommandBufferAllocateInfo infos = {}; infos.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; infos.commandBufferCount = 1; - infos.commandPool = (VkCommandPool)cmd_pool; + infos.commandPool = +cmd_pool; infos.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; CHECK_RESULT(vkAllocateCommandBuffers(cmd_pool.get_owner(), &infos, &commands)); @@ -1547,7 +1547,7 @@ private: u32 size() const { - return (u32)info.size; + return static_cast(info.size); } buffer(const buffer&) = delete; @@ -1586,7 +1586,7 @@ private: if (address < info.offset) return false; - const u32 _offset = address - (u32)info.offset; + const u32 _offset = address - static_cast(info.offset); if (info.range < _offset) return false; @@ -1937,7 +1937,7 @@ public: u32 get_swap_image_count() const override { - return (u32)swapchain_images.size(); + return ::size32(swapchain_images); } using swapchain_base::init; @@ -2167,7 +2167,7 @@ public: auto& src = swapchain_images[index]; if (pixmap) { - pixmap->data = (char*)src.second->get_pixels(); + pixmap->data = static_cast(src.second->get_pixels()); XPutImage(display, window, gc, pixmap, 0, 0, 0, 0, m_width, m_height); XFlush(display); @@ -2206,7 +2206,7 @@ public: VkImage& get_image(u32 index) override { - return (VkImage&)(*swapchain_images[index].second); + return swapchain_images[index].second->value; } VkImageLayout get_optimal_present_layout() override @@ -2263,11 +2263,11 @@ public: swapchain_WSI(vk::physical_device &gpu, uint32_t _present_queue, uint32_t _graphics_queue, VkFormat format, VkSurfaceKHR surface, VkColorSpaceKHR color_space, bool force_wm_reporting_off) : WSI_swapchain_base(gpu, _present_queue, _graphics_queue, format) { - createSwapchainKHR = (PFN_vkCreateSwapchainKHR)vkGetDeviceProcAddr(dev, "vkCreateSwapchainKHR"); - destroySwapchainKHR = (PFN_vkDestroySwapchainKHR)vkGetDeviceProcAddr(dev, "vkDestroySwapchainKHR"); - getSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR)vkGetDeviceProcAddr(dev, "vkGetSwapchainImagesKHR"); - acquireNextImageKHR = (PFN_vkAcquireNextImageKHR)vkGetDeviceProcAddr(dev, "vkAcquireNextImageKHR"); - queuePresentKHR = (PFN_vkQueuePresentKHR)vkGetDeviceProcAddr(dev, "vkQueuePresentKHR"); + createSwapchainKHR = reinterpret_cast(vkGetDeviceProcAddr(dev, "vkCreateSwapchainKHR")); + destroySwapchainKHR = reinterpret_cast(vkGetDeviceProcAddr(dev, "vkDestroySwapchainKHR")); + getSwapchainImagesKHR = reinterpret_cast(vkGetDeviceProcAddr(dev, "vkGetSwapchainImagesKHR")); + acquireNextImageKHR = reinterpret_cast(vkGetDeviceProcAddr(dev, "vkAcquireNextImageKHR")); + queuePresentKHR = reinterpret_cast(vkGetDeviceProcAddr(dev, "vkQueuePresentKHR")); m_surface = surface; m_color_space = color_space; @@ -2297,9 +2297,9 @@ public: void create(display_handle_t&) override {} - void destroy(bool=true) override + void destroy(bool = true) override { - if (VkDevice pdev = (VkDevice)dev) + if (VkDevice pdev = dev) { if (m_vk_swapchain) { @@ -2338,7 +2338,7 @@ public: } VkExtent2D swapchainExtent; - if (surface_descriptors.currentExtent.width == (uint32_t)-1) + if (surface_descriptors.currentExtent.width == UINT32_MAX) { swapchainExtent.width = m_width; swapchainExtent.height = m_height; @@ -2481,7 +2481,7 @@ public: VkImage& get_image(u32 index) override { - return (VkImage&)swapchain_images[index]; + return static_cast(swapchain_images[index]); } VkImageLayout get_optimal_present_layout() override @@ -2539,8 +2539,8 @@ public: PFN_vkDebugReportCallbackEXT callback = vk::dbgFunc; - createDebugReportCallback = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(m_instance, "vkCreateDebugReportCallbackEXT"); - destroyDebugReportCallback = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(m_instance, "vkDestroyDebugReportCallbackEXT"); + createDebugReportCallback = reinterpret_cast(vkGetInstanceProcAddr(m_instance, "vkCreateDebugReportCallbackEXT")); + destroyDebugReportCallback = reinterpret_cast(vkGetInstanceProcAddr(m_instance, "vkDestroyDebugReportCallbackEXT")); VkDebugReportCallbackCreateInfoEXT dbgCreateInfo = {}; dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; @@ -2940,7 +2940,7 @@ public: void initialize(vk::command_buffer &cmd) { - const u32 count = (u32)query_active_status.size(); + const u32 count = ::size32(query_active_status); vkCmdResetQueryPool(cmd, query_pool, 0, count); std::fill(query_active_status.begin(), query_active_status.end(), false); @@ -3334,10 +3334,10 @@ public: vs_info.codeSize = m_compiled.size() * sizeof(u32); vs_info.pNext = nullptr; vs_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; - vs_info.pCode = (uint32_t*)m_compiled.data(); + vs_info.pCode = m_compiled.data(); vs_info.flags = 0; - VkDevice dev = (VkDevice)*vk::get_current_renderer(); + VkDevice dev = *vk::get_current_renderer(); vkCreateShaderModule(dev, &vs_info, nullptr, &m_handle); return m_handle; @@ -3350,7 +3350,7 @@ public: if (m_handle) { - VkDevice dev = (VkDevice)*vk::get_current_renderer(); + VkDevice dev = *vk::get_current_renderer(); vkDestroyShaderModule(dev, m_handle, nullptr); m_handle = nullptr; } @@ -3445,7 +3445,7 @@ public: if (!(get_heap_compatible_buffer_types() & usage)) { - LOG_WARNING(RSX, "Buffer usage %u is not heap-compatible using this driver, explicit staging buffer in use", (u32)usage); + LOG_WARNING(RSX, "Buffer usage %u is not heap-compatible using this driver, explicit staging buffer in use", usage); shadow = std::make_unique(*device, size, memory_index, memory_flags, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, 0); usage |= VK_BUFFER_USAGE_TRANSFER_DST_BIT; @@ -3488,7 +3488,7 @@ public: raise_status_interrupt(runtime_state::heap_dirty); } - return (u8*)_ptr + offset; + return static_cast(_ptr) + offset; } void unmap(bool force = false) @@ -3515,7 +3515,7 @@ public: if (!dirty_ranges.empty()) { verify (HERE), shadow, heap; - vkCmdCopyBuffer(cmd, shadow->value, heap->value, (u32)dirty_ranges.size(), dirty_ranges.data()); + vkCmdCopyBuffer(cmd, shadow->value, heap->value, ::size32(dirty_ranges), dirty_ranges.data()); dirty_ranges.clear(); insert_buffer_memory_barrier(cmd, heap->value, 0, heap->size(), diff --git a/rpcs3/Emu/RSX/VK/VKMemAlloc.cpp b/rpcs3/Emu/RSX/VK/VKMemAlloc.cpp index 1bffa57a85..78369868dc 100644 --- a/rpcs3/Emu/RSX/VK/VKMemAlloc.cpp +++ b/rpcs3/Emu/RSX/VK/VKMemAlloc.cpp @@ -1,2 +1,16 @@ #define VMA_IMPLEMENTATION + +#ifdef _MSC_VER +#pragma warning(push, 0) +#else +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wall" +#pragma GCC diagnostic ignored "-Wextra" +#pragma GCC diagnostic ignored "-Wold-style-cast" +#endif #include "3rdparty/GPUOpen/include/vk_mem_alloc.h" +#ifdef _MSC_VER +#pragma warning(pop) +#else +#pragma GCC diagnostic pop +#endif diff --git a/rpcs3/Emu/RSX/VK/VKRenderPass.cpp b/rpcs3/Emu/RSX/VK/VKRenderPass.cpp index 68956f64ae..07bf8779ed 100644 --- a/rpcs3/Emu/RSX/VK/VKRenderPass.cpp +++ b/rpcs3/Emu/RSX/VK/VKRenderPass.cpp @@ -41,7 +41,7 @@ namespace vk layout_offset += 3; break; default: - fmt::throw_exception("Unsupported image layout 0x%x", (u32)layout); + fmt::throw_exception("Unsupported image layout 0x%x", static_cast(layout)); } } @@ -68,7 +68,7 @@ namespace vk layout_offset += 3; break; default: - fmt::throw_exception("Unsupported image layout 0x%x", (u32)layout); + fmt::throw_exception("Unsupported image layout 0x%x", static_cast(layout)); } } diff --git a/rpcs3/Emu/RSX/VK/VKRenderTargets.h b/rpcs3/Emu/RSX/VK/VKRenderTargets.h index 80365f4ea3..6f14697c6c 100644 --- a/rpcs3/Emu/RSX/VK/VKRenderTargets.h +++ b/rpcs3/Emu/RSX/VK/VKRenderTargets.h @@ -245,7 +245,7 @@ namespace vk subres.height_in_block = subres.height_in_texel = surface_height * samples_y; subres.pitch_in_block = rsx_pitch / get_bpp(); subres.depth = 1; - subres.data = { (const std::byte*)vm::get_super_ptr(base_addr), static_cast::index_type>(rsx_pitch * surface_height * samples_y) }; + subres.data = { vm::get_super_ptr(base_addr), static_cast::index_type>(rsx_pitch * surface_height * samples_y) }; if (LIKELY(g_cfg.video.resolution_scale_percent == 100 && samples() == 1)) { @@ -276,7 +276,7 @@ namespace vk if (content != final_dst) { vk::copy_scaled_image(cmd, content->value, final_dst->value, content->current_layout, final_dst->current_layout, - { 0, 0, subres.width_in_block, subres.height_in_block }, { 0, 0, (s32)final_dst->width(), (s32)final_dst->height() }, + { 0, 0, subres.width_in_block, subres.height_in_block }, { 0, 0, static_cast(final_dst->width()), static_cast(final_dst->height()) }, 1, aspect(), true, aspect() == VK_IMAGE_ASPECT_COLOR_BIT ? VK_FILTER_LINEAR : VK_FILTER_NEAREST, format(), format()); } @@ -456,7 +456,7 @@ namespace vk { typeless_info.src_is_typeless = true; typeless_info.src_context = rsx::texture_upload_context::framebuffer_storage; - typeless_info.src_native_format_override = (u32)info.format; + typeless_info.src_native_format_override = static_cast(info.format); typeless_info.src_scaling_hint = f32(src_bpp) / dst_bpp; } } @@ -592,7 +592,7 @@ namespace rsx VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, VK_IMAGE_TYPE_2D, requested_format, - static_cast(rsx::apply_resolution_scale((u16)width, true)), static_cast(rsx::apply_resolution_scale((u16)height, true)), 1, 1, 1, + static_cast(rsx::apply_resolution_scale(static_cast(width), true)), static_cast(rsx::apply_resolution_scale(static_cast(height), true)), 1, 1, 1, static_cast(samples), VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_TILING_OPTIMAL, @@ -607,10 +607,10 @@ namespace rsx rtt->memory_usage_flags = rsx::surface_usage_flags::attachment; rtt->state_flags = rsx::surface_state_flags::erase_bkgnd; rtt->native_component_map = fmt.second; - rtt->rsx_pitch = (u16)pitch; - rtt->native_pitch = (u16)width * get_format_block_size_in_bytes(format) * rtt->samples_x; - rtt->surface_width = (u16)width; - rtt->surface_height = (u16)height; + rtt->rsx_pitch = static_cast(pitch); + rtt->native_pitch = static_cast(width) * get_format_block_size_in_bytes(format) * rtt->samples_x; + rtt->surface_width = static_cast(width); + rtt->surface_height = static_cast(height); rtt->queue_tag(address); rtt->add_ref(); @@ -650,7 +650,7 @@ namespace rsx VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, VK_IMAGE_TYPE_2D, requested_format, - static_cast(rsx::apply_resolution_scale((u16)width, true)), static_cast(rsx::apply_resolution_scale((u16)height, true)), 1, 1, 1, + static_cast(rsx::apply_resolution_scale(static_cast(width), true)), static_cast(rsx::apply_resolution_scale(static_cast(height), true)), 1, 1, 1, static_cast(samples), VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_TILING_OPTIMAL, @@ -666,13 +666,13 @@ namespace rsx ds->state_flags = rsx::surface_state_flags::erase_bkgnd; ds->native_component_map = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_R }; - ds->native_pitch = (u16)width * 2 * ds->samples_x; + ds->native_pitch = static_cast(width) * 2 * ds->samples_x; if (format == rsx::surface_depth_format::z24s8) ds->native_pitch *= 2; - ds->rsx_pitch = (u16)pitch; - ds->surface_width = (u16)width; - ds->surface_height = (u16)height; + ds->rsx_pitch = static_cast(pitch); + ds->surface_width = static_cast(width); + ds->surface_height = static_cast(height); ds->queue_tag(address); ds->add_ref(); @@ -775,7 +775,7 @@ namespace rsx static void invalidate_surface_contents(vk::command_buffer& /*cmd*/, vk::render_target *surface, u32 address, size_t pitch) { - surface->rsx_pitch = (u16)pitch; + surface->rsx_pitch = static_cast(pitch); surface->queue_tag(address); surface->last_use_tag = 0; surface->stencil_init_flags = 0; @@ -820,7 +820,7 @@ namespace rsx return (surface->info.format == format && surface->get_spp() == get_format_sample_count(antialias) && - surface->matches_dimensions((u16)width, (u16)height)); + surface->matches_dimensions(static_cast(width), static_cast(height))); } static bool surface_matches_properties( diff --git a/rpcs3/Emu/RSX/VK/VKTexture.cpp b/rpcs3/Emu/RSX/VK/VKTexture.cpp index ae3a45fe8a..b2b8c736e9 100644 --- a/rpcs3/Emu/RSX/VK/VKTexture.cpp +++ b/rpcs3/Emu/RSX/VK/VKTexture.cpp @@ -372,9 +372,9 @@ namespace vk VkImageCopy copy_rgn; copy_rgn.srcOffset = { src_rect.x1, src_rect.y1, 0 }; copy_rgn.dstOffset = { dst_rect.x1, dst_rect.y1, 0 }; - copy_rgn.dstSubresource = { (VkImageAspectFlags)aspect, 0, 0, 1 }; - copy_rgn.srcSubresource = { (VkImageAspectFlags)aspect, 0, 0, 1 }; - copy_rgn.extent = { (u32)src_rect.width(), (u32)src_rect.height(), 1 }; + copy_rgn.dstSubresource = { static_cast(aspect), 0, 0, 1 }; + copy_rgn.srcSubresource = { static_cast(aspect), 0, 0, 1 }; + copy_rgn.extent = { static_cast(src_rect.width()), static_cast(src_rect.height()), 1 }; vkCmdCopyImage(cmd, src, preferred_src_format, dst, preferred_dst_format, 1, ©_rgn); } @@ -383,7 +383,7 @@ namespace vk //Most depth/stencil formats cannot be scaled using hw blit if (src_format == VK_FORMAT_UNDEFINED) { - LOG_ERROR(RSX, "Could not blit depth/stencil image. src_fmt=0x%x", (u32)src_format); + LOG_ERROR(RSX, "Could not blit depth/stencil image. src_fmt=0x%x", static_cast(src_format)); } else { @@ -427,7 +427,7 @@ namespace vk //1. Copy unscaled to typeless surface VkBufferImageCopy info{}; info.imageOffset = { std::min(src_rect.x1, src_rect.x2), std::min(src_rect.y1, src_rect.y2), 0 }; - info.imageExtent = { (u32)src_w, (u32)src_h, 1 }; + info.imageExtent = { static_cast(src_w), static_cast(src_h), 1 }; info.imageSubresource = { aspect & transfer_flags, 0, 0, 1 }; vkCmdCopyImageToBuffer(cmd, src, preferred_src_format, scratch_buf->value, 1, &info); @@ -446,7 +446,7 @@ namespace vk src_rect2, { 0, src_h, dst_w, (src_h + dst_h) }, 1, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_ASPECT_COLOR_BIT, filter); //3. Copy back the aspect bits - info.imageExtent = { (u32)dst_w, (u32)dst_h, 1 }; + info.imageExtent = { static_cast(dst_w), static_cast(dst_h), 1 }; info.imageOffset = { 0, src_h, 0 }; vkCmdCopyImageToBuffer(cmd, typeless, VK_IMAGE_LAYOUT_GENERAL, scratch_buf->value, 1, &info); @@ -712,7 +712,7 @@ namespace vk // Map with extra padding bytes in case of realignment size_t offset_in_buffer = upload_heap.alloc<512>(image_linear_size + 8); - void *mapped_buffer = upload_heap.map(offset_in_buffer, image_linear_size + 8); + void* mapped_buffer = upload_heap.map(offset_in_buffer, image_linear_size + 8); // Only do GPU-side conversion if occupancy is good if (check_caps) @@ -722,7 +722,7 @@ namespace vk check_caps = false; } - gsl::span mapped{ (std::byte*)mapped_buffer, image_linear_size }; + gsl::span mapped{ static_cast(mapped_buffer), image_linear_size }; opt = upload_texture_subresource(mapped, layout, format, is_swizzled, caps); upload_heap.unmap(); @@ -770,7 +770,7 @@ namespace vk if (opt.require_swap || opt.require_deswizzle || dst_image->aspect() & VK_IMAGE_ASPECT_STENCIL_BIT) { verify(HERE), scratch_buf; - vkCmdCopyBuffer(cmd, upload_heap.heap->value, scratch_buf->value, (u32)buffer_copies.size(), buffer_copies.data()); + vkCmdCopyBuffer(cmd, upload_heap.heap->value, scratch_buf->value, static_cast(buffer_copies.size()), buffer_copies.data()); insert_buffer_memory_barrier(cmd, scratch_buf->value, 0, scratch_offset, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT); @@ -814,11 +814,11 @@ namespace vk insert_buffer_memory_barrier(cmd, scratch_buf->value, block_start, scratch_offset, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT); - vkCmdCopyBufferToImage(cmd, scratch_buf->value, dst_image->value, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, (u32)copy_regions.size(), copy_regions.data()); + vkCmdCopyBufferToImage(cmd, scratch_buf->value, dst_image->value, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, static_cast(copy_regions.size()), copy_regions.data()); } else { - vkCmdCopyBufferToImage(cmd, upload_heap.heap->value, dst_image->value, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, (u32)copy_regions.size(), copy_regions.data()); + vkCmdCopyBufferToImage(cmd, upload_heap.heap->value, dst_image->value, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, static_cast(copy_regions.size()), copy_regions.data()); } } @@ -864,14 +864,14 @@ namespace vk const auto aspect = vk::get_aspect_flags(format); // Transfer bits from src to typeless src - real_src = vk::get_typeless_helper(format, (u32)internal_width, src->height()); + real_src = vk::get_typeless_helper(format, static_cast(internal_width), src->height()); vk::change_image_layout(cmd, real_src, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, { aspect, 0, 1, 0, 1 }); - vk::copy_image_typeless(cmd, src, real_src, { 0, 0, (s32)src->width(), (s32)src->height() }, { 0, 0, (s32)internal_width, (s32)src->height() }, 1, + vk::copy_image_typeless(cmd, src, real_src, { 0, 0, static_cast(src->width()), static_cast(src->height()) }, { 0, 0, static_cast(internal_width), static_cast(src->height()) }, 1, vk::get_aspect_flags(src->info.format), aspect); - src_area.x1 = (u16)(src_area.x1 * xfer_info.src_scaling_hint); - src_area.x2 = (u16)(src_area.x2 * xfer_info.src_scaling_hint); + src_area.x1 = static_cast(src_area.x1 * xfer_info.src_scaling_hint); + src_area.x2 = static_cast(src_area.x2 * xfer_info.src_scaling_hint); } } @@ -887,14 +887,14 @@ namespace vk const auto aspect = vk::get_aspect_flags(format); // Transfer bits from dst to typeless dst - real_dst = vk::get_typeless_helper(format, (u32)internal_width, dst->height()); + real_dst = vk::get_typeless_helper(format, static_cast(internal_width), dst->height()); vk::change_image_layout(cmd, real_dst, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, { aspect, 0, 1, 0, 1 }); - vk::copy_image_typeless(cmd, dst, real_dst, { 0, 0, (s32)dst->width(), (s32)dst->height() }, { 0, 0, (s32)internal_width, (s32)dst->height() }, 1, + vk::copy_image_typeless(cmd, dst, real_dst, { 0, 0, static_cast(dst->width()), static_cast(dst->height()) }, { 0, 0, static_cast(internal_width), static_cast(dst->height()) }, 1, vk::get_aspect_flags(dst->info.format), aspect); - dst_area.x1 = (u16)(dst_area.x1 * xfer_info.dst_scaling_hint); - dst_area.x2 = (u16)(dst_area.x2 * xfer_info.dst_scaling_hint); + dst_area.x1 = static_cast(dst_area.x1 * xfer_info.dst_scaling_hint); + dst_area.x2 = static_cast(dst_area.x2 * xfer_info.dst_scaling_hint); } } @@ -905,13 +905,13 @@ namespace vk return; } - if (src_area.x1 < 0 || src_area.x2 >(s32)real_src->width() || src_area.y1 < 0 || src_area.y2 >(s32)real_src->height()) + if (src_area.x1 < 0 || src_area.x2 > static_cast(real_src->width()) || src_area.y1 < 0 || src_area.y2 > static_cast(real_src->height())) { LOG_ERROR(RSX, "Blit request denied because the source region does not fit!"); return; } - if (dst_area.x1 < 0 || dst_area.x2 >(s32)real_dst->width() || dst_area.y1 < 0 || dst_area.y2 >(s32)real_dst->height()) + if (dst_area.x1 < 0 || dst_area.x2 > static_cast(real_dst->width()) || dst_area.y1 < 0 || dst_area.y2 > static_cast(real_dst->height())) { LOG_ERROR(RSX, "Blit request denied because the destination region does not fit!"); return; @@ -936,7 +936,7 @@ namespace vk if (real_dst != dst) { auto internal_width = dst->width() * xfer_info.dst_scaling_hint; - vk::copy_image_typeless(cmd, real_dst, dst, { 0, 0, (s32)internal_width, (s32)dst->height() }, { 0, 0, (s32)dst->width(), (s32)dst->height() }, 1, + vk::copy_image_typeless(cmd, real_dst, dst, { 0, 0, static_cast(internal_width), static_cast(dst->height()) }, { 0, 0, static_cast(dst->width()), static_cast(dst->height()) }, 1, vk::get_aspect_flags(real_dst->info.format), vk::get_aspect_flags(dst->info.format)); } } diff --git a/rpcs3/Emu/RSX/VK/VKTextureCache.h b/rpcs3/Emu/RSX/VK/VKTextureCache.h index e66c884898..54d432ad12 100644 --- a/rpcs3/Emu/RSX/VK/VKTextureCache.h +++ b/rpcs3/Emu/RSX/VK/VKTextureCache.h @@ -185,8 +185,8 @@ namespace vk src->push_layout(cmd, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); const auto internal_bpp = vk::get_format_texel_width(src->format()); - const auto transfer_width = (u32)src_area.width(); - const auto transfer_height = (u32)src_area.height(); + const auto transfer_width = static_cast(src_area.width()); + const auto transfer_height = static_cast(src_area.height()); real_pitch = internal_bpp * transfer_width; rsx_pitch = pitch; @@ -343,7 +343,7 @@ namespace vk const auto filter = (target->aspect() == VK_IMAGE_ASPECT_COLOR_BIT) ? VK_FILTER_LINEAR : VK_FILTER_NEAREST; vk::copy_scaled_image(cmd, locked_resource->value, target->value, locked_resource->current_layout, target->current_layout, - { 0, 0, (s32)locked_resource->width(), (s32)locked_resource->height() }, { 0, 0, (s32)transfer_width, (s32)transfer_height }, + { 0, 0, static_cast(locked_resource->width()), static_cast(locked_resource->height()) }, { 0, 0, static_cast(transfer_width), static_cast(transfer_height) }, 1, target->aspect(), true, filter, vram_texture->format(), target->format()); target->change_layout(cmd, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); @@ -374,8 +374,8 @@ namespace vk } areai src_area; - src_area.x1 = (s32)transfer_x; - src_area.y1 = (s32)transfer_y; + src_area.x1 = static_cast(transfer_x); + src_area.y1 = static_cast(transfer_y); src_area.x2 = s32(transfer_x + transfer_width); src_area.y2 = s32(transfer_y + transfer_height); dma_transfer(cmd, target, src_area, valid_range, rsx_pitch); @@ -709,7 +709,7 @@ namespace vk } vk::copy_scaled_image(cmd, tmp->value, _dst->value, tmp->current_layout, _dst->current_layout, - areai{ 0, 0, src_w, (s32)src_h }, + areai{ 0, 0, src_w, static_cast(src_h) }, coordi{ { dst_x, dst_y }, { section.dst_w, section.dst_h } }, 1, new_src_aspect, tmp->info.format == _dst->info.format, VK_FILTER_NEAREST, tmp->info.format, _dst->info.format); @@ -1029,7 +1029,7 @@ namespace vk const std::vector& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) override { const auto _template = sections_to_copy.front().src; - const auto mipmaps = (u8)sections_to_copy.size(); + const auto mipmaps = ::narrow(sections_to_copy.size()); std::unique_ptr image; if (image = find_temporary_image(_template->format(), width, height, 1, mipmaps); !image) @@ -1287,7 +1287,7 @@ namespace vk { default: //TODO - warn_once("Format incompatibility detected, reporting failure to force data copy (VK_FORMAT=0x%X, GCM_FORMAT=0x%X)", (u32)vk_format, gcm_format); + warn_once("Format incompatibility detected, reporting failure to force data copy (VK_FORMAT=0x%X, GCM_FORMAT=0x%X)", static_cast(vk_format), gcm_format); return false; case CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT: return (vk_format == VK_FORMAT_R16G16B16A16_SFLOAT); @@ -1465,14 +1465,14 @@ namespace vk void* mem = image->memory->map(0, layout.rowPitch * height); u32 row_pitch = width * 4; - char *src = (char *)vm::base(address); - char *dst = (char *)mem; + auto src = vm::_ptr(address); + auto dst = static_cast(mem); //TODO: SSE optimization for (u32 row = 0; row < height; ++row) { - be_t* casted_src = (be_t*)src; - u32* casted_dst = (u32*)dst; + auto casted_src = reinterpret_cast*>(src); + auto casted_dst = reinterpret_cast(dst); for (u32 col = 0; col < width; ++col) casted_dst[col] = casted_src[col]; @@ -1514,7 +1514,7 @@ namespace vk const u32 get_unreleased_textures_count() const override { - return baseclass::get_unreleased_textures_count() + (u32)m_temporary_storage.size(); + return baseclass::get_unreleased_textures_count() + ::size32(m_temporary_storage); } const u32 get_temporary_memory_in_use() diff --git a/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp b/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp index 316b1325fd..9cba6765b9 100644 --- a/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp +++ b/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp @@ -34,7 +34,7 @@ namespace vk requires_modification = true; return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; default: - fmt::throw_exception("Unsupported primitive topology 0x%x", (u8)mode); + fmt::throw_exception("Unsupported primitive topology 0x%x", static_cast(mode)); } } @@ -179,11 +179,11 @@ namespace { if (index_type == rsx::index_array_type::u16) { - index_count = rsx::remove_restart_index((u16*)buf, (u16*)tmp.data(), index_count, (u16)UINT16_MAX); + index_count = rsx::remove_restart_index(static_cast(buf), reinterpret_cast(tmp.data()), index_count, u16{UINT16_MAX}); } else { - index_count = rsx::remove_restart_index((u32*)buf, (u32*)tmp.data(), index_count, (u32)UINT32_MAX); + index_count = rsx::remove_restart_index(static_cast(buf), reinterpret_cast(tmp.data()), index_count, u32{UINT32_MAX}); } } @@ -272,21 +272,21 @@ vk::vertex_upload_info VKGSRender::upload_vertex_data() if (!in_cache) { - persistent_offset = (u32)m_attrib_ring_info.alloc<256>(required.first); - persistent_range_base = (u32)persistent_offset; + persistent_offset = static_cast(m_attrib_ring_info.alloc<256>(required.first)); + persistent_range_base = static_cast(persistent_offset); if (to_store) { //store ref in vertex cache - m_vertex_cache->store_range(storage_address, VK_FORMAT_R8_UINT, required.first, (u32)persistent_offset); + m_vertex_cache->store_range(storage_address, VK_FORMAT_R8_UINT, required.first, static_cast(persistent_offset)); } } } if (required.second > 0) { - volatile_offset = (u32)m_attrib_ring_info.alloc<256>(required.second); - volatile_range_base = (u32)volatile_offset; + volatile_offset = static_cast(m_attrib_ring_info.alloc<256>(required.second)); + volatile_range_base = static_cast(volatile_offset); } //Write all the data once if possible @@ -298,7 +298,7 @@ vk::vertex_upload_info VKGSRender::upload_vertex_data() const size_t volatile_offset_in_block = volatile_offset - persistent_offset; void *block_mapping = m_attrib_ring_info.map(persistent_offset, block_size); - write_vertex_data_to_memory(m_vertex_layout, vertex_base, vertex_count, block_mapping, (char*)block_mapping + volatile_offset_in_block); + write_vertex_data_to_memory(m_vertex_layout, vertex_base, vertex_count, block_mapping, static_cast(block_mapping) + volatile_offset_in_block); m_attrib_ring_info.unmap(); } else diff --git a/rpcs3/Emu/RSX/rsx_methods.cpp b/rpcs3/Emu/RSX/rsx_methods.cpp index 65375580f7..50567624b3 100644 --- a/rpcs3/Emu/RSX/rsx_methods.cpp +++ b/rpcs3/Emu/RSX/rsx_methods.cpp @@ -42,7 +42,7 @@ namespace rsx //Don't throw, gather information and ignore broken/garbage commands //TODO: Investigate why these commands are executed at all. (Heap corruption? Alignment padding?) const u32 cmd = rsx->get_fifo_cmd(); - LOG_ERROR(RSX, "Invalid RSX method 0x%x (arg=0x%x, start=0x%x, count=0x%x, non-inc=%s)", _reg << 2, arg, + LOG_ERROR(RSX, "Invalid RSX method 0x%x (arg=0x%x, start=0x%x, count=0x%x, non-inc=%s)", _reg << 2, arg, cmd & 0xfffc, (cmd >> 18) & 0x7ff, !!(cmd & RSX_METHOD_NON_INCREMENT_CMD)); rsx->invalid_command_interrupt_raised = true; } @@ -86,7 +86,7 @@ namespace rsx if (Emu.IsStopped()) return; - if (const auto tdr = (u64)g_cfg.video.driver_recovery_timeout) + if (const auto tdr = static_cast(g_cfg.video.driver_recovery_timeout)) { if (Emu.IsPaused()) { @@ -834,7 +834,7 @@ namespace rsx vm::write32(address, color); break; case 2: - vm::write16(address, (u16)(color)); + vm::write16(address, static_cast(color)); break; default: fmt::throw_exception("Unreachable" HERE); @@ -868,8 +868,8 @@ namespace rsx // NOTE: Do not round these value up! // Sub-pixel offsets are used to signify pixel centers and do not mean to read from the next block (fill convention) - auto in_x = (u16)std::floor(method_registers.blit_engine_in_x()); - auto in_y = (u16)std::floor(method_registers.blit_engine_in_y()); + auto in_x = static_cast(std::floor(method_registers.blit_engine_in_x())); + auto in_y = static_cast(std::floor(method_registers.blit_engine_in_y())); // Clipping // Validate that clipping rect will fit onto both src and dst regions @@ -904,12 +904,12 @@ namespace rsx case blit_engine::transfer_origin::center: break; default: - LOG_WARNING(RSX, "NV3089_IMAGE_IN_SIZE: unknown origin (%d)", (u8)in_origin); + LOG_WARNING(RSX, "NV3089_IMAGE_IN_SIZE: unknown origin (%d)", static_cast(in_origin)); } if (operation != rsx::blit_engine::transfer_operation::srccopy) { - fmt::throw_exception("NV3089_IMAGE_IN_SIZE: unknown operation (%d)" HERE, (u8)operation); + fmt::throw_exception("NV3089_IMAGE_IN_SIZE: unknown operation (%d)" HERE, static_cast(operation)); } const u32 src_offset = method_registers.blit_engine_input_offset(); @@ -942,7 +942,7 @@ namespace rsx break; } default: - LOG_ERROR(RSX, "NV3089_IMAGE_IN_SIZE: unknown m_context_surface (0x%x)", (u8)method_registers.blit_engine_context_surface()); + LOG_ERROR(RSX, "NV3089_IMAGE_IN_SIZE: unknown m_context_surface (0x%x)", static_cast(method_registers.blit_engine_context_surface())); return; } @@ -1008,7 +1008,7 @@ namespace rsx if (dst_color_format != rsx::blit_engine::transfer_destination_format::r5g6b5 && dst_color_format != rsx::blit_engine::transfer_destination_format::a8r8g8b8) { - fmt::throw_exception("NV3089_IMAGE_IN_SIZE: unknown dst_color_format (%d)" HERE, (u8)dst_color_format); + fmt::throw_exception("NV3089_IMAGE_IN_SIZE: unknown dst_color_format (%d)" HERE, static_cast(dst_color_format)); } if (src_color_format != rsx::blit_engine::transfer_source_format::r5g6b5 && @@ -1022,12 +1022,12 @@ namespace rsx else { // TODO: Support more formats - fmt::throw_exception("NV3089_IMAGE_IN_SIZE: unknown src_color_format (%d)" HERE, (u8)src_color_format); + fmt::throw_exception("NV3089_IMAGE_IN_SIZE: unknown src_color_format (%d)" HERE, static_cast(src_color_format)); } } - u32 convert_w = (u32)(std::abs(scale_x) * in_w); - u32 convert_h = (u32)(std::abs(scale_y) * in_h); + u32 convert_w = static_cast(std::abs(scale_x) * in_w); + u32 convert_h = static_cast(std::abs(scale_y) * in_h); if (convert_w == 0 || convert_h == 0) { @@ -1078,12 +1078,12 @@ namespace rsx const u32 packed_pitch = in_w * in_bpp; temp1.resize(packed_pitch * in_h); - const s32 stride_y = (scale_y < 0 ? -1 : 1) * (s32)in_pitch; + const s32 stride_y = (scale_y < 0 ? -1 : 1) * s32{in_pitch}; for (u32 y = 0; y < in_h; ++y) { u8 *dst = temp1.data() + (packed_pitch * y); - u8 *src = pixels_src + ((s32)y * stride_y); + u8 *src = pixels_src + (static_cast(y) * stride_y); if (scale_x < 0) { @@ -1194,7 +1194,7 @@ namespace rsx { if (need_clip) { - temp2.resize(out_pitch * std::max(convert_h, (u32)clip_h)); + temp2.resize(out_pitch * std::max(convert_h, clip_h)); convert_scale_image(temp2.data(), out_format, convert_w, convert_h, out_pitch, pixels_src, in_format, in_w, in_h, in_pitch, slice_h, in_inter == blit_engine::transfer_interpolator::foh); @@ -1218,7 +1218,7 @@ namespace rsx if (need_convert) { - temp2.resize(out_pitch * std::max(convert_h, (u32)clip_h)); + temp2.resize(out_pitch * std::max(convert_h, clip_h)); convert_scale_image(temp2.data(), out_format, convert_w, convert_h, out_pitch, pixels_src, in_format, in_w, in_h, in_pitch, slice_h, in_inter == blit_engine::transfer_interpolator::foh); diff --git a/rpcs3/Emu/RSX/rsx_utils.h b/rpcs3/Emu/RSX/rsx_utils.h index 39bea5d103..f4d635b971 100644 --- a/rpcs3/Emu/RSX/rsx_utils.h +++ b/rpcs3/Emu/RSX/rsx_utils.h @@ -337,8 +337,8 @@ namespace rsx * Restriction: It has mixed results if the height or width is not a power of 2 * Restriction: Only works with 2D surfaces */ - template - void convert_linear_swizzle(void* input_pixels, void* output_pixels, u16 width, u16 height, u32 pitch) + template + void convert_linear_swizzle(const void* input_pixels, void* output_pixels, u16 width, u16 height, u32 pitch) { u32 log2width = ceil_log2(width); u32 log2height = ceil_log2(height); @@ -368,8 +368,8 @@ namespace rsx { for (int y = 0; y < height; ++y) { - T* src = static_cast(input_pixels) + y * adv; - T *dst = static_cast(output_pixels) + offs_y; + auto src = static_cast(input_pixels) + y * adv; + auto dst = static_cast(output_pixels) + offs_y; offs_x = offs_x0; for (int x = 0; x < width; ++x) @@ -390,8 +390,8 @@ namespace rsx { for (int y = 0; y < height; ++y) { - T *src = static_cast(input_pixels) + offs_y; - T* dst = static_cast(output_pixels) + y * adv; + auto src = static_cast(input_pixels) + offs_y; + auto dst = static_cast(output_pixels) + y * adv; offs_x = offs_x0; for (int x = 0; x < width; ++x) @@ -417,7 +417,7 @@ namespace rsx * i.e 32 texels per "unit" */ template - void convert_linear_swizzle_3d(void *input_pixels, void *output_pixels, u16 width, u16 height, u16 depth) + void convert_linear_swizzle_3d(const void* input_pixels, void* output_pixels, u16 width, u16 height, u16 depth) { if (depth == 1) { @@ -425,8 +425,8 @@ namespace rsx return; } - T *src = static_cast(input_pixels); - T *dst = static_cast(output_pixels); + auto src = static_cast(input_pixels); + auto dst = static_cast(output_pixels); const u32 log2_w = ceil_log2(width); const u32 log2_h = ceil_log2(height);