diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.cpp b/rpcs3/Emu/RSX/Common/BufferUtils.cpp index 3528c0383d..9d5789ae81 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.cpp +++ b/rpcs3/Emu/RSX/Common/BufferUtils.cpp @@ -50,12 +50,12 @@ void write_vertex_array_data_to_buffer(void *buffer, u32 first, u32 count, size_ switch (vertex_array_desc.type) { - case Vertex_base_type::ub: + case vertex_base_type::ub: memcpy(dst, src, vertex_array_desc.size); break; - case Vertex_base_type::s1: - case Vertex_base_type::sf: + case vertex_base_type::s1: + case vertex_base_type::sf: { auto* c_src = (const be_t*)src; u16* c_dst = (u16*)dst; @@ -69,9 +69,9 @@ void write_vertex_array_data_to_buffer(void *buffer, u32 first, u32 count, size_ break; } - case Vertex_base_type::f: - case Vertex_base_type::s32k: - case Vertex_base_type::ub256: + case vertex_base_type::f: + case vertex_base_type::s32k: + case vertex_base_type::ub256: { auto* c_src = (const be_t*)src; u32* c_dst = (u32*)dst; @@ -82,7 +82,7 @@ void write_vertex_array_data_to_buffer(void *buffer, u32 first, u32 count, size_ } break; } - case Vertex_base_type::cmp: + case vertex_base_type::cmp: { auto* c_src = (const be_t*)src; const auto& decoded_vector = decode_cmp_vector(*c_src); @@ -244,21 +244,21 @@ std::tuple expand_indexed_quads(gsl::span> src, gsl::span } // Only handle quads and triangle fan now -bool is_primitive_native(Primitive_type m_draw_mode) +bool is_primitive_native(primitive_type draw_mode) { - switch (m_draw_mode) + switch (draw_mode) { - case Primitive_type::points: - case Primitive_type::lines: - case Primitive_type::line_loop: - case Primitive_type::line_strip: - case Primitive_type::triangles: - case Primitive_type::triangle_strip: - case Primitive_type::quad_strip: + case primitive_type::points: + case primitive_type::lines: + case primitive_type::line_loop: + case primitive_type::line_strip: + case primitive_type::triangles: + case primitive_type::triangle_strip: + case primitive_type::quad_strip: return true; - case Primitive_type::polygon: - case Primitive_type::triangle_fan: - case Primitive_type::quads: + case primitive_type::polygon: + case primitive_type::triangle_fan: + case primitive_type::quads: return false; } throw new EXCEPTION("Wrong primitive type"); @@ -269,41 +269,41 @@ bool is_primitive_native(Primitive_type m_draw_mode) * see http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/polygon-triangulation-r3334 */ -size_t get_index_count(Primitive_type m_draw_mode, unsigned initial_index_count) +size_t get_index_count(primitive_type draw_mode, unsigned initial_index_count) { // Index count - if (is_primitive_native(m_draw_mode)) + if (is_primitive_native(draw_mode)) return initial_index_count; - switch (m_draw_mode) + switch (draw_mode) { - case Primitive_type::polygon: - case Primitive_type::triangle_fan: + case primitive_type::polygon: + case primitive_type::triangle_fan: return (initial_index_count - 2) * 3; - case Primitive_type::quads: + case primitive_type::quads: return (6 * initial_index_count) / 4; default: return 0; } } -size_t get_index_type_size(Index_array_type type) +size_t get_index_type_size(index_array_type type) { switch (type) { - case Index_array_type::unsigned_16b: return 2; - case Index_array_type::unsigned_32b: return 4; + case index_array_type::unsigned_16b: return 2; + case index_array_type::unsigned_32b: return 4; } throw new EXCEPTION("Wrong index type"); } -void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, Primitive_type draw_mode, unsigned first, unsigned count) +void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, primitive_type draw_mode, unsigned first, unsigned count) { unsigned short *typedDst = (unsigned short *)(dst); switch (draw_mode) { - case Primitive_type::triangle_fan: - case Primitive_type::polygon: + case primitive_type::triangle_fan: + case primitive_type::polygon: for (unsigned i = 0; i < (count - 2); i++) { typedDst[3 * i] = first; @@ -311,7 +311,7 @@ void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, typedDst[3 * i + 2] = i + 2; } return; - case Primitive_type::quads: + case primitive_type::quads: for (unsigned i = 0; i < count / 4; i++) { // First triangle @@ -324,13 +324,13 @@ void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, typedDst[6 * i + 5] = 4 * i + first; } return; - case Primitive_type::points: - case Primitive_type::lines: - case Primitive_type::line_loop: - case Primitive_type::line_strip: - case Primitive_type::triangles: - case Primitive_type::triangle_strip: - case Primitive_type::quad_strip: + case primitive_type::points: + case primitive_type::lines: + case primitive_type::line_loop: + case primitive_type::line_strip: + case primitive_type::triangles: + case primitive_type::triangle_strip: + case primitive_type::quad_strip: throw new EXCEPTION("Native primitive type doesn't require expansion"); } } @@ -338,10 +338,10 @@ void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, // TODO: Unify indexed and non indexed primitive expansion ? template -std::tuple write_index_array_data_to_buffer_impl(gsl::span dst, Primitive_type m_draw_mode, const std::vector > &first_count_arguments) +std::tuple write_index_array_data_to_buffer_impl(gsl::span dst, primitive_type draw_mode, const std::vector > &first_count_arguments) { u32 address = rsx::get_address(rsx::method_registers[NV4097_SET_INDEX_ARRAY_ADDRESS], rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] & 0xf); - Index_array_type type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); + index_array_type type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); u32 type_size = gsl::narrow(get_index_type_size(type)); @@ -362,40 +362,40 @@ std::tuple write_index_array_data_to_buffer_impl(gsl::span(first_count_arguments.back()) + std::get<1>(first_count_arguments.back()) - first; auto ptr = vm::ps3::_ptr(address + first * type_size); - switch (m_draw_mode) + switch (draw_mode) { - case Primitive_type::points: - case Primitive_type::lines: - case Primitive_type::line_loop: - case Primitive_type::line_strip: - case Primitive_type::triangles: - case Primitive_type::triangle_strip: - case Primitive_type::quad_strip: + case primitive_type::points: + case primitive_type::lines: + case primitive_type::line_loop: + case primitive_type::line_strip: + case primitive_type::triangles: + case primitive_type::triangle_strip: + case primitive_type::quad_strip: return upload_untouched({ ptr, count }, dst, is_primitive_restart_enabled, primitive_restart_index); - case Primitive_type::polygon: - case Primitive_type::triangle_fan: + case primitive_type::polygon: + case primitive_type::triangle_fan: return expand_indexed_triangle_fan({ ptr, count }, dst, is_primitive_restart_enabled, primitive_restart_index); - case Primitive_type::quads: + case primitive_type::quads: return expand_indexed_quads({ ptr, count }, dst, is_primitive_restart_enabled, primitive_restart_index); } throw new EXCEPTION("Unknow draw mode"); } -std::tuple write_index_array_data_to_buffer(gsl::span dst, Primitive_type m_draw_mode, const std::vector > &first_count_arguments) +std::tuple write_index_array_data_to_buffer(gsl::span dst, primitive_type draw_mode, const std::vector > &first_count_arguments) { - return write_index_array_data_to_buffer_impl(dst, m_draw_mode, first_count_arguments); + return write_index_array_data_to_buffer_impl(dst, draw_mode, first_count_arguments); } -std::tuple write_index_array_data_to_buffer(gsl::span dst, Primitive_type m_draw_mode, const std::vector > &first_count_arguments) +std::tuple write_index_array_data_to_buffer(gsl::span dst, primitive_type draw_mode, const std::vector > &first_count_arguments) { - return write_index_array_data_to_buffer_impl(dst, m_draw_mode, first_count_arguments); + return write_index_array_data_to_buffer_impl(dst, draw_mode, first_count_arguments); } std::tuple write_index_array_data_to_buffer_untouched(gsl::span dst, const std::vector > &first_count_arguments) { u32 address = rsx::get_address(rsx::method_registers[NV4097_SET_INDEX_ARRAY_ADDRESS], rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] & 0xf); - Index_array_type type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); + index_array_type type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); u32 type_size = gsl::narrow(get_index_type_size(type)); bool is_primitive_restart_enabled = !!rsx::method_registers[NV4097_SET_RESTART_INDEX_ENABLE]; @@ -418,7 +418,7 @@ std::tuple write_index_array_data_to_buffer_untouched(gsl::span write_index_array_data_to_buffer_untouched(gsl::span dst, const std::vector > &first_count_arguments) { u32 address = rsx::get_address(rsx::method_registers[NV4097_SET_INDEX_ARRAY_ADDRESS], rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] & 0xf); - Index_array_type type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); + index_array_type type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); u32 type_size = gsl::narrow(get_index_type_size(type)); bool is_primitive_restart_enabled = !!rsx::method_registers[NV4097_SET_RESTART_INDEX_ENABLE]; diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.h b/rpcs3/Emu/RSX/Common/BufferUtils.h index f2bba57cb1..cdd14df374 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.h +++ b/rpcs3/Emu/RSX/Common/BufferUtils.h @@ -11,25 +11,25 @@ void write_vertex_array_data_to_buffer(void *buffer, u32 first, u32 count, size_ /* * If primitive mode is not supported and need to be emulated (using an index buffer) returns false. */ -bool is_primitive_native(Primitive_type m_draw_mode); +bool is_primitive_native(primitive_type m_draw_mode); /** * Returns a fixed index count for emulated primitive, otherwise returns initial_index_count */ -size_t get_index_count(Primitive_type m_draw_mode, unsigned initial_index_count); +size_t get_index_count(primitive_type m_draw_mode, unsigned initial_index_count); /** * Returns index type size in byte */ -size_t get_index_type_size(Index_array_type type); +size_t get_index_type_size(index_array_type type); /** * Write count indexes using (first, first + count) ranges. * Returns min/max index found during the process. * The function expands index buffer for non native primitive type. */ -std::tuple write_index_array_data_to_buffer(gsl::span dst, Primitive_type m_draw_mode, const std::vector > &first_count_arguments); -std::tuple write_index_array_data_to_buffer(gsl::span dst, Primitive_type m_draw_mode, const std::vector > &first_count_arguments); +std::tuple write_index_array_data_to_buffer(gsl::span dst, primitive_type draw_mode, const std::vector > &first_count_arguments); +std::tuple write_index_array_data_to_buffer(gsl::span dst, primitive_type draw_mode, const std::vector > &first_count_arguments); /** * Doesn't expand index @@ -40,7 +40,7 @@ std::tuple write_index_array_data_to_buffer_untouched(gsl::span get_rtt_indexes(Surface_target color_target) + std::vector get_rtt_indexes(surface_target color_target) { switch (color_target) { - case Surface_target::none: return{}; - case Surface_target::surface_a: return{ 0 }; - case Surface_target::surface_b: return{ 1 }; - case Surface_target::surfaces_a_b: return{ 0, 1 }; - case Surface_target::surfaces_a_b_c: return{ 0, 1, 2 }; - case Surface_target::surfaces_a_b_c_d: return{ 0, 1, 2, 3 }; + case surface_target::none: return{}; + case surface_target::surface_a: return{ 0 }; + case surface_target::surface_b: return{ 1 }; + case surface_target::surfaces_a_b: return{ 0, 1 }; + case surface_target::surfaces_a_b_c: return{ 0, 1, 2 }; + case surface_target::surfaces_a_b_c_d: return{ 0, 1, 2, 3 }; } throw EXCEPTION("Wrong color_target"); } - size_t get_aligned_pitch(Surface_color_format format, u32 width) + size_t get_aligned_pitch(surface_color_format format, u32 width) { switch (format) { - case Surface_color_format::b8: return align(width, 256); - case Surface_color_format::g8b8: - case Surface_color_format::x1r5g5b5_o1r5g5b5: - case Surface_color_format::x1r5g5b5_z1r5g5b5: - case Surface_color_format::r5g6b5: return align(width * 2, 256); - case Surface_color_format::a8b8g8r8: - case Surface_color_format::x8b8g8r8_o8b8g8r8: - case Surface_color_format::x8b8g8r8_z8b8g8r8: - case Surface_color_format::x8r8g8b8_o8r8g8b8: - case Surface_color_format::x8r8g8b8_z8r8g8b8: - case Surface_color_format::x32: - case Surface_color_format::a8r8g8b8: return align(width * 4, 256); - case Surface_color_format::w16z16y16x16: return align(width * 8, 256); - case Surface_color_format::w32z32y32x32: return align(width * 16, 256); + case surface_color_format::b8: return align(width, 256); + case surface_color_format::g8b8: + case surface_color_format::x1r5g5b5_o1r5g5b5: + case surface_color_format::x1r5g5b5_z1r5g5b5: + case surface_color_format::r5g6b5: return align(width * 2, 256); + case surface_color_format::a8b8g8r8: + case surface_color_format::x8b8g8r8_o8b8g8r8: + case surface_color_format::x8b8g8r8_z8b8g8r8: + case surface_color_format::x8r8g8b8_o8r8g8b8: + case surface_color_format::x8r8g8b8_z8r8g8b8: + case surface_color_format::x32: + case surface_color_format::a8r8g8b8: return align(width * 4, 256); + case surface_color_format::w16z16y16x16: return align(width * 8, 256); + case surface_color_format::w32z32y32x32: return align(width * 16, 256); } throw EXCEPTION("Unknow color surface format"); } - size_t get_packed_pitch(Surface_color_format format, u32 width) + size_t get_packed_pitch(surface_color_format format, u32 width) { switch (format) { - case Surface_color_format::b8: return width; - case Surface_color_format::g8b8: - case Surface_color_format::x1r5g5b5_o1r5g5b5: - case Surface_color_format::x1r5g5b5_z1r5g5b5: - case Surface_color_format::r5g6b5: return width * 2; - case Surface_color_format::a8b8g8r8: - case Surface_color_format::x8b8g8r8_o8b8g8r8: - case Surface_color_format::x8b8g8r8_z8b8g8r8: - case Surface_color_format::x8r8g8b8_o8r8g8b8: - case Surface_color_format::x8r8g8b8_z8r8g8b8: - case Surface_color_format::x32: - case Surface_color_format::a8r8g8b8: return width * 4; - case Surface_color_format::w16z16y16x16: return width * 8; - case Surface_color_format::w32z32y32x32: return width * 16; + case surface_color_format::b8: return width; + case surface_color_format::g8b8: + case surface_color_format::x1r5g5b5_o1r5g5b5: + case surface_color_format::x1r5g5b5_z1r5g5b5: + case surface_color_format::r5g6b5: return width * 2; + case surface_color_format::a8b8g8r8: + case surface_color_format::x8b8g8r8_o8b8g8r8: + case surface_color_format::x8b8g8r8_z8b8g8r8: + case surface_color_format::x8r8g8b8_o8r8g8b8: + case surface_color_format::x8r8g8b8_z8r8g8b8: + case surface_color_format::x32: + case surface_color_format::a8r8g8b8: return width * 4; + case surface_color_format::w16z16y16x16: return width * 8; + case surface_color_format::w32z32y32x32: return width * 16; } throw EXCEPTION("Unknow color surface format"); } diff --git a/rpcs3/Emu/RSX/Common/surface_store.h b/rpcs3/Emu/RSX/Common/surface_store.h index 8361162a0a..7b177051d6 100644 --- a/rpcs3/Emu/RSX/Common/surface_store.h +++ b/rpcs3/Emu/RSX/Common/surface_store.h @@ -7,9 +7,9 @@ namespace rsx { namespace utility { - std::vector get_rtt_indexes(Surface_target color_target); - size_t get_aligned_pitch(Surface_color_format format, u32 width); - size_t get_packed_pitch(Surface_color_format format, u32 width); + std::vector get_rtt_indexes(surface_target color_target); + size_t get_aligned_pitch(surface_color_format format, u32 width); + size_t get_packed_pitch(surface_color_format format, u32 width); } /** @@ -86,7 +86,7 @@ namespace rsx gsl::not_null bind_address_as_render_targets( command_list_type command_list, u32 address, - Surface_color_format surface_color_format, size_t width, size_t height, + surface_color_format color_format, size_t width, size_t height, Args&&... extra_params) { auto It = m_render_targets_storage.find(address); @@ -96,7 +96,7 @@ namespace rsx if (It != m_render_targets_storage.end()) { surface_storage_type &rtt = It->second; - if (Traits::rtt_has_format_width_height(rtt, surface_color_format, width, height)) + if (Traits::rtt_has_format_width_height(rtt, color_format, width, height)) { Traits::prepare_rtt_for_drawing(command_list, Traits::get(rtt)); return Traits::get(rtt); @@ -105,7 +105,7 @@ namespace rsx m_render_targets_storage.erase(address); } - m_render_targets_storage[address] = Traits::create_new_surface(address, surface_color_format, width, height, std::forward(extra_params)...); + m_render_targets_storage[address] = Traits::create_new_surface(address, color_format, width, height, std::forward(extra_params)...); return Traits::get(m_render_targets_storage[address]); } @@ -113,14 +113,14 @@ namespace rsx gsl::not_null bind_address_as_depth_stencil( command_list_type command_list, u32 address, - Surface_depth_format surface_depth_format, size_t width, size_t height, + surface_depth_format depth_format, size_t width, size_t height, Args&&... extra_params) { auto It = m_depth_stencil_storage.find(address); if (It != m_depth_stencil_storage.end()) { surface_storage_type &ds = It->second; - if (Traits::ds_has_format_width_height(ds, surface_depth_format, width, height)) + if (Traits::ds_has_format_width_height(ds, depth_format, width, height)) { Traits::prepare_ds_for_drawing(command_list, Traits::get(ds)); return Traits::get(ds); @@ -129,7 +129,7 @@ namespace rsx m_depth_stencil_storage.erase(address); } - m_depth_stencil_storage[address] = Traits::create_new_surface(address, surface_depth_format, width, height, std::forward(extra_params)...); + m_depth_stencil_storage[address] = Traits::create_new_surface(address, depth_format, width, height, std::forward(extra_params)...); return Traits::get(m_depth_stencil_storage[address]); } public: @@ -142,7 +142,7 @@ namespace rsx command_list_type command_list, u32 set_surface_format_reg, u32 clip_horizontal_reg, u32 clip_vertical_reg, - Surface_target set_surface_target, + surface_target set_surface_target, const std::array &surface_addresses, u32 address_z, Args&&... extra_params) { @@ -151,8 +151,8 @@ namespace rsx u32 clip_x = clip_horizontal_reg; u32 clip_y = clip_vertical_reg; - Surface_color_format color_format = to_surface_color_format(set_surface_format_reg & 0x1f); - Surface_depth_format depth_format = to_surface_depth_format((set_surface_format_reg >> 5) & 0x7); + surface_color_format color_format = to_surface_color_format(set_surface_format_reg & 0x1f); + surface_depth_format depth_format = to_surface_depth_format((set_surface_format_reg >> 5) & 0x7); // Make previous RTTs sampleable for (std::tuple &rtt : m_bound_render_targets) @@ -216,7 +216,7 @@ namespace rsx */ template std::array, 4> get_render_targets_data( - Surface_color_format surface_color_format, size_t width, size_t height, + surface_color_format color_format, size_t width, size_t height, Args&& ...args ) { @@ -230,7 +230,7 @@ namespace rsx surface_type surface_resource = std::get<1>(m_bound_render_targets[i]); download_data[i] = std::move( - Traits::issue_download_command(surface_resource, surface_color_format, width, height, std::forward(args)...) + Traits::issue_download_command(surface_resource, color_format, width, height, std::forward(args)...) ); } @@ -244,50 +244,50 @@ namespace rsx gsl::span raw_src = Traits::map_downloaded_buffer(download_data[i], std::forward(args)...); - size_t src_pitch = utility::get_aligned_pitch(surface_color_format, gsl::narrow(width)); - size_t dst_pitch = utility::get_packed_pitch(surface_color_format, gsl::narrow(width)); + size_t src_pitch = utility::get_aligned_pitch(color_format, gsl::narrow(width)); + size_t dst_pitch = utility::get_packed_pitch(color_format, gsl::narrow(width)); result[i].resize(dst_pitch * height); // Note: MSVC + GSL doesn't support span -> span for non const span atm // thus manual conversion - switch (surface_color_format) + switch (color_format) { - case Surface_color_format::a8b8g8r8: - case Surface_color_format::x8b8g8r8_o8b8g8r8: - case Surface_color_format::x8b8g8r8_z8b8g8r8: - case Surface_color_format::a8r8g8b8: - case Surface_color_format::x8r8g8b8_o8r8g8b8: - case Surface_color_format::x8r8g8b8_z8r8g8b8: - case Surface_color_format::x32: + case surface_color_format::a8b8g8r8: + case surface_color_format::x8b8g8r8_o8b8g8r8: + case surface_color_format::x8b8g8r8_z8b8g8r8: + case surface_color_format::a8r8g8b8: + case surface_color_format::x8r8g8b8_o8r8g8b8: + case surface_color_format::x8r8g8b8_z8r8g8b8: + case surface_color_format::x32: { gsl::span> dst_span{ (be_t*)result[i].data(), gsl::narrow(dst_pitch * width / sizeof(be_t)) }; copy_pitched_src_to_dst(dst_span, gsl::as_span(raw_src), src_pitch, width, height); break; } - case Surface_color_format::b8: + case surface_color_format::b8: { gsl::span dst_span{ (u8*)result[i].data(), gsl::narrow(dst_pitch * width / sizeof(u8)) }; copy_pitched_src_to_dst(dst_span, gsl::as_span(raw_src), src_pitch, width, height); break; } - case Surface_color_format::g8b8: - case Surface_color_format::r5g6b5: - case Surface_color_format::x1r5g5b5_o1r5g5b5: - case Surface_color_format::x1r5g5b5_z1r5g5b5: + case surface_color_format::g8b8: + case surface_color_format::r5g6b5: + case surface_color_format::x1r5g5b5_o1r5g5b5: + case surface_color_format::x1r5g5b5_z1r5g5b5: { gsl::span> dst_span{ (be_t*)result[i].data(), gsl::narrow(dst_pitch * width / sizeof(be_t)) }; copy_pitched_src_to_dst(dst_span, gsl::as_span(raw_src), src_pitch, width, height); break; } // Note : may require some big endian swap - case Surface_color_format::w32z32y32x32: + case surface_color_format::w32z32y32x32: { gsl::span dst_span{ (u128*)result[i].data(), gsl::narrow(dst_pitch * width / sizeof(u128)) }; copy_pitched_src_to_dst(dst_span, gsl::as_span(raw_src), src_pitch, width, height); break; } - case Surface_color_format::w16z16y16x16: + case surface_color_format::w16z16y16x16: { gsl::span dst_span{ (u64*)result[i].data(), gsl::narrow(dst_pitch * width / sizeof(u64)) }; copy_pitched_src_to_dst(dst_span, gsl::as_span(raw_src), src_pitch, width, height); @@ -305,7 +305,7 @@ namespace rsx */ template std::array, 2> get_depth_stencil_data( - Surface_depth_format surface_depth_format, size_t width, size_t height, + surface_depth_format depth_format, size_t width, size_t height, Args&& ...args ) { @@ -315,18 +315,18 @@ namespace rsx size_t row_pitch = align(width * 4, 256); download_buffer_object stencil_data = {}; - download_buffer_object depth_data = Traits::issue_depth_download_command(std::get<1>(m_bound_depth_stencil), surface_depth_format, width, height, std::forward(args)...); - if (surface_depth_format == Surface_depth_format::z24s8) + download_buffer_object depth_data = Traits::issue_depth_download_command(std::get<1>(m_bound_depth_stencil), depth_format, width, height, std::forward(args)...); + if (depth_format == surface_depth_format::z24s8) stencil_data = std::move(Traits::issue_stencil_download_command(std::get<1>(m_bound_depth_stencil), width, height, std::forward(args)...)); gsl::span depth_buffer_raw_src = Traits::map_downloaded_buffer(depth_data, std::forward(args)...); - if (surface_depth_format == Surface_depth_format::z16) + if (depth_format == surface_depth_format::z16) { result[0].resize(width * height * 2); gsl::span dest{ (u16*)result[0].data(), gsl::narrow(width * height) }; copy_pitched_src_to_dst(dest, gsl::as_span(depth_buffer_raw_src), row_pitch, width, height); } - if (surface_depth_format == Surface_depth_format::z24s8) + if (depth_format == surface_depth_format::z24s8) { result[0].resize(width * height * 4); gsl::span dest{ (u32*)result[0].data(), gsl::narrow(width * height) }; @@ -334,7 +334,7 @@ namespace rsx } Traits::unmap_downloaded_buffer(depth_data, std::forward(args)...); - if (surface_depth_format == Surface_depth_format::z16) + if (depth_format == surface_depth_format::z16) return result; gsl::span stencil_buffer_raw_src = Traits::map_downloaded_buffer(stencil_data, std::forward(args)...); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp index 71cad3cf89..56a632854a 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp @@ -260,7 +260,7 @@ std::tuple D3D12GSRender::generate_index_buffer std::tuple D3D12GSRender::upload_and_set_vertex_index_data(ID3D12GraphicsCommandList *command_list) { - if (draw_command == Draw_command::draw_command_inlined_array) + if (draw_command == rsx::draw_command::inlined_array) { size_t vertex_count; D3D12_VERTEX_BUFFER_VIEW vertex_buffer_view; @@ -277,7 +277,7 @@ std::tuple D3D12GSRender::upload_and_set_vertex_index_data(ID3D12G return std::make_tuple(true, index_count); } - if (draw_command == Draw_command::draw_command_array) + if (draw_command == rsx::draw_command::array) { const std::vector &vertex_buffer_views = upload_vertex_attributes(first_count_commands); command_list->IASetVertexBuffers(0, (UINT)vertex_buffer_views.size(), vertex_buffer_views.data()); @@ -298,7 +298,7 @@ std::tuple D3D12GSRender::upload_and_set_vertex_index_data(ID3D12G return std::make_tuple(true, index_count); } - assert(draw_command == Draw_command::draw_command_indexed); + assert(draw_command == rsx::draw_command::indexed); // Index count size_t index_count = 0; @@ -306,7 +306,7 @@ std::tuple D3D12GSRender::upload_and_set_vertex_index_data(ID3D12G index_count += pair.second; index_count = get_index_count(draw_mode, gsl::narrow(index_count)); - Index_array_type indexed_type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); + index_array_type indexed_type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); size_t index_size = get_index_type_size(indexed_type); // Alloc @@ -316,13 +316,13 @@ std::tuple D3D12GSRender::upload_and_set_vertex_index_data(ID3D12G void *mapped_buffer = m_buffer_data.map(CD3DX12_RANGE(heap_offset, heap_offset + buffer_size)); u32 min_index, max_index; - if (indexed_type == Index_array_type::unsigned_16b) + if (indexed_type == index_array_type::unsigned_16b) { gsl::span dst = { (u16*)mapped_buffer, gsl::narrow(buffer_size / index_size) }; std::tie(min_index, max_index) = write_index_array_data_to_buffer(dst, draw_mode, first_count_commands); } - if (indexed_type == Index_array_type::unsigned_32b) + if (indexed_type == index_array_type::unsigned_32b) { gsl::span dst = { (u32*)mapped_buffer, gsl::narrow(buffer_size / index_size) }; std::tie(min_index, max_index) = write_index_array_data_to_buffer(dst, draw_mode, first_count_commands); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp index d02c941089..761cc28884 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp @@ -262,99 +262,99 @@ D3D12_FILTER get_texture_filter(u8 min_filter, u8 mag_filter) return D3D12_ENCODE_BASIC_FILTER(min, mag, mip, D3D12_FILTER_REDUCTION_TYPE_STANDARD); } -D3D12_PRIMITIVE_TOPOLOGY get_primitive_topology(Primitive_type draw_mode) +D3D12_PRIMITIVE_TOPOLOGY get_primitive_topology(primitive_type draw_mode) { switch (draw_mode) { - case Primitive_type::points: return D3D_PRIMITIVE_TOPOLOGY_POINTLIST; - case Primitive_type::lines: return D3D_PRIMITIVE_TOPOLOGY_LINELIST; - case Primitive_type::line_loop: return D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ; - case Primitive_type::line_strip: return D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; - case Primitive_type::triangles: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; - case Primitive_type::triangle_strip: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; - case Primitive_type::triangle_fan: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; - case Primitive_type::quads: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; - case Primitive_type::quad_strip: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; - case Primitive_type::polygon: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; + case primitive_type::points: return D3D_PRIMITIVE_TOPOLOGY_POINTLIST; + case primitive_type::lines: return D3D_PRIMITIVE_TOPOLOGY_LINELIST; + case primitive_type::line_loop: return D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ; + case primitive_type::line_strip: return D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; + case primitive_type::triangles: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; + case primitive_type::triangle_strip: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; + case primitive_type::triangle_fan: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; + case primitive_type::quads: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; + case primitive_type::quad_strip: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; + case primitive_type::polygon: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; } throw EXCEPTION("Invalid draw mode (0x%x)", draw_mode); } -D3D12_PRIMITIVE_TOPOLOGY_TYPE get_primitive_topology_type(Primitive_type draw_mode) +D3D12_PRIMITIVE_TOPOLOGY_TYPE get_primitive_topology_type(primitive_type draw_mode) { switch (draw_mode) { - case Primitive_type::points: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT; - case Primitive_type::lines: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE; - case Primitive_type::line_strip: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE; - case Primitive_type::triangles: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; - case Primitive_type::triangle_strip: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; - case Primitive_type::triangle_fan: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; - case Primitive_type::quads: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; - case Primitive_type::quad_strip: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; - case Primitive_type::polygon: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; - case Primitive_type::line_loop: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE; + case primitive_type::points: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT; + case primitive_type::lines: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE; + case primitive_type::line_strip: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE; + case primitive_type::triangles: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; + case primitive_type::triangle_strip: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; + case primitive_type::triangle_fan: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; + case primitive_type::quads: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; + case primitive_type::quad_strip: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; + case primitive_type::polygon: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; + case primitive_type::line_loop: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE; } throw EXCEPTION("Invalid or unsupported draw mode (0x%x)", draw_mode); } -DXGI_FORMAT get_color_surface_format(Surface_color_format format) +DXGI_FORMAT get_color_surface_format(surface_color_format format) { switch (format) { - case Surface_color_format::r5g6b5: return DXGI_FORMAT_B5G6R5_UNORM; - case Surface_color_format::x8r8g8b8_o8r8g8b8: - case Surface_color_format::x8r8g8b8_z8r8g8b8: - case Surface_color_format::x8b8g8r8_o8b8g8r8: - case Surface_color_format::x8b8g8r8_z8b8g8r8: + case surface_color_format::r5g6b5: return DXGI_FORMAT_B5G6R5_UNORM; + case surface_color_format::x8r8g8b8_o8r8g8b8: + case surface_color_format::x8r8g8b8_z8r8g8b8: + case surface_color_format::x8b8g8r8_o8b8g8r8: + case surface_color_format::x8b8g8r8_z8b8g8r8: return DXGI_FORMAT_B8G8R8X8_UNORM; //BIT.TRIP Runner2 use this - case Surface_color_format::a8b8g8r8: - case Surface_color_format::a8r8g8b8: return DXGI_FORMAT_R8G8B8A8_UNORM; - case Surface_color_format::b8: return DXGI_FORMAT_R8_UNORM; - case Surface_color_format::g8b8: return DXGI_FORMAT_R8G8_UNORM; - case Surface_color_format::w16z16y16x16: return DXGI_FORMAT_R16G16B16A16_FLOAT; - case Surface_color_format::w32z32y32x32: return DXGI_FORMAT_R32G32B32A32_FLOAT; - case Surface_color_format::x32: return DXGI_FORMAT_R32_FLOAT; + case surface_color_format::a8b8g8r8: + case surface_color_format::a8r8g8b8: return DXGI_FORMAT_R8G8B8A8_UNORM; + case surface_color_format::b8: return DXGI_FORMAT_R8_UNORM; + case surface_color_format::g8b8: return DXGI_FORMAT_R8G8_UNORM; + case surface_color_format::w16z16y16x16: return DXGI_FORMAT_R16G16B16A16_FLOAT; + case surface_color_format::w32z32y32x32: return DXGI_FORMAT_R32G32B32A32_FLOAT; + case surface_color_format::x32: return DXGI_FORMAT_R32_FLOAT; } throw EXCEPTION("Invalid format (0x%x)", format); } -DXGI_FORMAT get_depth_stencil_surface_format(Surface_depth_format format) +DXGI_FORMAT get_depth_stencil_surface_format(surface_depth_format format) { switch (format) { - case Surface_depth_format::z16: return DXGI_FORMAT_D16_UNORM; - case Surface_depth_format::z24s8: return DXGI_FORMAT_D24_UNORM_S8_UINT; + case surface_depth_format::z16: return DXGI_FORMAT_D16_UNORM; + case surface_depth_format::z24s8: return DXGI_FORMAT_D24_UNORM_S8_UINT; } throw EXCEPTION("Invalid format (0x%x)", format); } -DXGI_FORMAT get_depth_stencil_surface_clear_format(Surface_depth_format format) +DXGI_FORMAT get_depth_stencil_surface_clear_format(surface_depth_format format) { switch (format) { - case Surface_depth_format::z16: return DXGI_FORMAT_D16_UNORM; - case Surface_depth_format::z24s8: return DXGI_FORMAT_D24_UNORM_S8_UINT; + case surface_depth_format::z16: return DXGI_FORMAT_D16_UNORM; + case surface_depth_format::z24s8: return DXGI_FORMAT_D24_UNORM_S8_UINT; } throw EXCEPTION("Invalid format (0x%x)", format); } -DXGI_FORMAT get_depth_stencil_typeless_surface_format(Surface_depth_format format) +DXGI_FORMAT get_depth_stencil_typeless_surface_format(surface_depth_format format) { switch (format) { - case Surface_depth_format::z16: return DXGI_FORMAT_R16_TYPELESS; - case Surface_depth_format::z24s8: return DXGI_FORMAT_R24G8_TYPELESS; + case surface_depth_format::z16: return DXGI_FORMAT_R16_TYPELESS; + case surface_depth_format::z24s8: return DXGI_FORMAT_R24G8_TYPELESS; } throw EXCEPTION("Invalid format (0x%x)", format); } -DXGI_FORMAT get_depth_samplable_surface_format(Surface_depth_format format) +DXGI_FORMAT get_depth_samplable_surface_format(surface_depth_format format) { switch (format) { - case Surface_depth_format::z16: return DXGI_FORMAT_R16_UNORM; - case Surface_depth_format::z24s8: return DXGI_FORMAT_R24_UNORM_X8_TYPELESS; + case surface_depth_format::z16: return DXGI_FORMAT_R16_UNORM; + case surface_depth_format::z24s8: return DXGI_FORMAT_R24_UNORM_X8_TYPELESS; } throw EXCEPTION("Invalid format (0x%x)", format); } @@ -370,21 +370,21 @@ BOOL get_front_face_ccw(u32 ffv) throw EXCEPTION("Invalid front face value (0x%x)", ffv); } -DXGI_FORMAT get_index_type(Index_array_type index_type) +DXGI_FORMAT get_index_type(index_array_type index_type) { switch (index_type) { - case Index_array_type::unsigned_16b: return DXGI_FORMAT_R16_UINT; - case Index_array_type::unsigned_32b: return DXGI_FORMAT_R32_UINT; + case index_array_type::unsigned_16b: return DXGI_FORMAT_R16_UINT; + case index_array_type::unsigned_32b: return DXGI_FORMAT_R32_UINT; } throw EXCEPTION("Invalid index_type (0x%x)", index_type); } -DXGI_FORMAT get_vertex_attribute_format(Vertex_base_type type, u8 size) +DXGI_FORMAT get_vertex_attribute_format(vertex_base_type type, u8 size) { switch (type) { - case Vertex_base_type::s1: + case vertex_base_type::s1: { switch (size) { @@ -395,7 +395,7 @@ DXGI_FORMAT get_vertex_attribute_format(Vertex_base_type type, u8 size) } break; } - case Vertex_base_type::f: + case vertex_base_type::f: { switch (size) { @@ -406,7 +406,7 @@ DXGI_FORMAT get_vertex_attribute_format(Vertex_base_type type, u8 size) } break; } - case Vertex_base_type::sf: + case vertex_base_type::sf: { switch (size) { @@ -417,7 +417,7 @@ DXGI_FORMAT get_vertex_attribute_format(Vertex_base_type type, u8 size) } break; } - case Vertex_base_type::ub: + case vertex_base_type::ub: { switch (size) { @@ -428,7 +428,7 @@ DXGI_FORMAT get_vertex_attribute_format(Vertex_base_type type, u8 size) } break; } - case Vertex_base_type::s32k: + case vertex_base_type::s32k: { switch (size) { @@ -439,7 +439,7 @@ DXGI_FORMAT get_vertex_attribute_format(Vertex_base_type type, u8 size) } break; } - case Vertex_base_type::cmp: + case vertex_base_type::cmp: { switch (size) { @@ -450,7 +450,7 @@ DXGI_FORMAT get_vertex_attribute_format(Vertex_base_type type, u8 size) } break; } - case Vertex_base_type::ub256: + case vertex_base_type::ub256: { switch (size) { diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Formats.h b/rpcs3/Emu/RSX/D3D12/D3D12Formats.h index 813864d379..60875b5f2c 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Formats.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12Formats.h @@ -56,37 +56,37 @@ D3D12_FILTER get_texture_filter(u8 min_filter, u8 mag_filter); /** * Convert draw mode to D3D12_PRIMITIVE_TOPOLOGY */ -D3D12_PRIMITIVE_TOPOLOGY get_primitive_topology(Primitive_type draw_mode); +D3D12_PRIMITIVE_TOPOLOGY get_primitive_topology(primitive_type draw_mode); /** * Convert draw mode to D3D12_PRIMITIVE_TOPOLOGY_TYPE */ -D3D12_PRIMITIVE_TOPOLOGY_TYPE get_primitive_topology_type(Primitive_type draw_mode); +D3D12_PRIMITIVE_TOPOLOGY_TYPE get_primitive_topology_type(primitive_type draw_mode); /** * Convert color surface format to DXGI_FORMAT */ -DXGI_FORMAT get_color_surface_format(Surface_color_format format); +DXGI_FORMAT get_color_surface_format(surface_color_format format); /** * Convert depth stencil surface format to DXGI_FORMAT */ -DXGI_FORMAT get_depth_stencil_surface_format(Surface_depth_format format); +DXGI_FORMAT get_depth_stencil_surface_format(surface_depth_format format); /** *Convert depth stencil surface format to DXGI_FORMAT suited for clear value */ -DXGI_FORMAT get_depth_stencil_surface_clear_format(Surface_depth_format format); +DXGI_FORMAT get_depth_stencil_surface_clear_format(surface_depth_format format); /** * Convert depth surface format to a typeless DXGI_FORMAT */ -DXGI_FORMAT get_depth_stencil_typeless_surface_format(Surface_depth_format format); +DXGI_FORMAT get_depth_stencil_typeless_surface_format(surface_depth_format format); /** * Convert depth surface format to a DXGI_FORMAT that can be depth sampled */ -DXGI_FORMAT get_depth_samplable_surface_format(Surface_depth_format format); +DXGI_FORMAT get_depth_samplable_surface_format(surface_depth_format format); /** * Convert front face value to bool value telling wheter front face is counterclockwise or not @@ -96,12 +96,12 @@ BOOL get_front_face_ccw(u32 set_front_face_value); /** * Convert index type to DXGI_FORMAT */ -DXGI_FORMAT get_index_type(Index_array_type index_type); +DXGI_FORMAT get_index_type(index_array_type index_type); /** * Convert vertex attribute format and size to DXGI_FORMAT */ -DXGI_FORMAT get_vertex_attribute_format(Vertex_base_type type, u8 size); +DXGI_FORMAT get_vertex_attribute_format(vertex_base_type type, u8 size); /** * Convert scissor register value to D3D12_RECT diff --git a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp index 9400dfc919..f52938af25 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp @@ -339,17 +339,17 @@ void D3D12GSRender::end() namespace { -bool is_flip_surface_in_global_memory(Surface_target color_target) +bool is_flip_surface_in_global_memory(surface_target color_target) { switch (color_target) { - case Surface_target::surface_a: - case Surface_target::surface_b: - case Surface_target::surfaces_a_b: - case Surface_target::surfaces_a_b_c: - case Surface_target::surfaces_a_b_c_d: + case surface_target::surface_a: + case surface_target::surface_b: + case surface_target::surfaces_a_b: + case surface_target::surfaces_a_b_c: + case surface_target::surfaces_a_b_c_d: return true; - case Surface_target::none: + case surface_target::none: return false; } throw EXCEPTION("Wrong color_target"); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp index c8a26cba2a..a756db8ca4 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp @@ -164,17 +164,17 @@ void D3D12GSRender::load_program() switch (to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])) { - case Surface_target::surface_a: - case Surface_target::surface_b: + case surface_target::surface_a: + case surface_target::surface_b: prop.numMRT = 1; break; - case Surface_target::surfaces_a_b: + case surface_target::surfaces_a_b: prop.numMRT = 2; break; - case Surface_target::surfaces_a_b_c: + case surface_target::surfaces_a_b_c: prop.numMRT = 3; break; - case Surface_target::surfaces_a_b_c_d: + case surface_target::surfaces_a_b_c_d: prop.numMRT = 4; break; default: @@ -254,12 +254,12 @@ void D3D12GSRender::load_program() prop.IASet = m_IASet; if (!!rsx::method_registers[NV4097_SET_RESTART_INDEX_ENABLE]) { - Index_array_type index_type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); - if (index_type == Index_array_type::unsigned_32b) + index_array_type index_type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); + if (index_type == index_array_type::unsigned_32b) { prop.CutValue = D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFFFFFF; } - if (index_type == Index_array_type::unsigned_16b) + if (index_type == index_array_type::unsigned_16b) { prop.CutValue = D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFF; } diff --git a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp index 3edf99d548..0616339f4f 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp @@ -15,40 +15,40 @@ namespace { - u32 get_max_depth_value(Surface_depth_format format) + u32 get_max_depth_value(surface_depth_format format) { switch (format) { - case Surface_depth_format::z16: return 0xFFFF; - case Surface_depth_format::z24s8: return 0xFFFFFF; + case surface_depth_format::z16: return 0xFFFF; + case surface_depth_format::z24s8: return 0xFFFFFF; } throw EXCEPTION("Unknow depth format"); } - UINT get_num_rtt(Surface_target color_target) + UINT get_num_rtt(surface_target color_target) { switch (color_target) { - case Surface_target::none: return 0; - case Surface_target::surface_a: - case Surface_target::surface_b: return 1; - case Surface_target::surfaces_a_b: return 2; - case Surface_target::surfaces_a_b_c: return 3; - case Surface_target::surfaces_a_b_c_d: return 4; + case surface_target::none: return 0; + case surface_target::surface_a: + case surface_target::surface_b: return 1; + case surface_target::surfaces_a_b: return 2; + case surface_target::surfaces_a_b_c: return 3; + case surface_target::surfaces_a_b_c_d: return 4; } throw EXCEPTION("Wrong color_target (%d)", color_target); } - std::vector get_rtt_indexes(Surface_target color_target) + std::vector get_rtt_indexes(surface_target color_target) { switch (color_target) { - case Surface_target::none: return{}; - case Surface_target::surface_a: return{ 0 }; - case Surface_target::surface_b: return{ 1 }; - case Surface_target::surfaces_a_b: return{ 0, 1 }; - case Surface_target::surfaces_a_b_c: return{ 0, 1, 2 }; - case Surface_target::surfaces_a_b_c_d: return{ 0, 1, 2, 3 }; + case surface_target::none: return{}; + case surface_target::surface_a: return{ 0 }; + case surface_target::surface_b: return{ 1 }; + case surface_target::surfaces_a_b: return{ 0, 1 }; + case surface_target::surfaces_a_b_c: return{ 0, 1, 2 }; + case surface_target::surfaces_a_b_c_d: return{ 0, 1, 2, 3 }; } throw EXCEPTION("Wrong color_target (%d)", color_target); } @@ -73,46 +73,46 @@ namespace return register_value & 0xff; } - size_t get_aligned_pitch(Surface_color_format format, u32 width) + size_t get_aligned_pitch(surface_color_format format, u32 width) { switch (format) { - case Surface_color_format::b8: return align(width, 256); - case Surface_color_format::g8b8: - case Surface_color_format::x1r5g5b5_o1r5g5b5: - case Surface_color_format::x1r5g5b5_z1r5g5b5: - case Surface_color_format::r5g6b5: return align(width * 2, 256); - case Surface_color_format::a8b8g8r8: - case Surface_color_format::x8b8g8r8_o8b8g8r8: - case Surface_color_format::x8b8g8r8_z8b8g8r8: - case Surface_color_format::x8r8g8b8_o8r8g8b8: - case Surface_color_format::x8r8g8b8_z8r8g8b8: - case Surface_color_format::x32: - case Surface_color_format::a8r8g8b8: return align(width * 4, 256); - case Surface_color_format::w16z16y16x16: return align(width * 8, 256); - case Surface_color_format::w32z32y32x32: return align(width * 16, 256); + case surface_color_format::b8: return align(width, 256); + case surface_color_format::g8b8: + case surface_color_format::x1r5g5b5_o1r5g5b5: + case surface_color_format::x1r5g5b5_z1r5g5b5: + case surface_color_format::r5g6b5: return align(width * 2, 256); + case surface_color_format::a8b8g8r8: + case surface_color_format::x8b8g8r8_o8b8g8r8: + case surface_color_format::x8b8g8r8_z8b8g8r8: + case surface_color_format::x8r8g8b8_o8r8g8b8: + case surface_color_format::x8r8g8b8_z8r8g8b8: + case surface_color_format::x32: + case surface_color_format::a8r8g8b8: return align(width * 4, 256); + case surface_color_format::w16z16y16x16: return align(width * 8, 256); + case surface_color_format::w32z32y32x32: return align(width * 16, 256); } throw EXCEPTION("Unknow color surface format"); } - size_t get_packed_pitch(Surface_color_format format, u32 width) + size_t get_packed_pitch(surface_color_format format, u32 width) { switch (format) { - case Surface_color_format::b8: return width; - case Surface_color_format::g8b8: - case Surface_color_format::x1r5g5b5_o1r5g5b5: - case Surface_color_format::x1r5g5b5_z1r5g5b5: - case Surface_color_format::r5g6b5: return width * 2; - case Surface_color_format::a8b8g8r8: - case Surface_color_format::x8b8g8r8_o8b8g8r8: - case Surface_color_format::x8b8g8r8_z8b8g8r8: - case Surface_color_format::x8r8g8b8_o8r8g8b8: - case Surface_color_format::x8r8g8b8_z8r8g8b8: - case Surface_color_format::x32: - case Surface_color_format::a8r8g8b8: return width * 4; - case Surface_color_format::w16z16y16x16: return width * 8; - case Surface_color_format::w32z32y32x32: return width * 16; + case surface_color_format::b8: return width; + case surface_color_format::g8b8: + case surface_color_format::x1r5g5b5_o1r5g5b5: + case surface_color_format::x1r5g5b5_z1r5g5b5: + case surface_color_format::r5g6b5: return width * 2; + case surface_color_format::a8b8g8r8: + case surface_color_format::x8b8g8r8_o8b8g8r8: + case surface_color_format::x8b8g8r8_z8b8g8r8: + case surface_color_format::x8r8g8b8_o8r8g8b8: + case surface_color_format::x8r8g8b8_z8r8g8b8: + case surface_color_format::x32: + case surface_color_format::a8r8g8b8: return width * 4; + case surface_color_format::w16z16y16x16: return width * 8; + case surface_color_format::w32z32y32x32: return width * 16; } throw EXCEPTION("Unknow color surface format"); } @@ -242,7 +242,7 @@ namespace ID3D12GraphicsCommandList * command_list, data_heap &readback_heap, ID3D12Resource * color_surface, - Surface_color_format color_surface_format + surface_color_format color_surface_format ) { int clip_w = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL] >> 16; diff --git a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.h b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.h index df76dc8a9e..15c8db05c0 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.h @@ -21,10 +21,10 @@ struct render_target_traits static ComPtr create_new_surface( u32 address, - Surface_color_format surface_color_format, size_t width, size_t height, + surface_color_format color_format, size_t width, size_t height, gsl::not_null device, const std::array &clear_color, float, u8) { - DXGI_FORMAT dxgi_format = get_color_surface_format(surface_color_format); + DXGI_FORMAT dxgi_format = get_color_surface_format(color_format); ComPtr rtt; LOG_WARNING(RSX, "Creating RTT"); @@ -69,7 +69,7 @@ struct render_target_traits static ComPtr create_new_surface( u32 address, - Surface_depth_format surfaceDepthFormat, size_t width, size_t height, + surface_depth_format surfaceDepthFormat, size_t width, size_t height, gsl::not_null device, const std::array& , float clear_depth, u8 clear_stencil) { D3D12_CLEAR_VALUE clear_depth_value = {}; @@ -113,14 +113,14 @@ struct render_target_traits static - bool rtt_has_format_width_height(const ComPtr &rtt, Surface_color_format surface_color_format, size_t width, size_t height) + bool rtt_has_format_width_height(const ComPtr &rtt, surface_color_format surface_color_format, size_t width, size_t height) { DXGI_FORMAT dxgi_format = get_color_surface_format(surface_color_format); return rtt->GetDesc().Format == dxgi_format && rtt->GetDesc().Width == width && rtt->GetDesc().Height == height; } static - bool ds_has_format_width_height(const ComPtr &rtt, Surface_depth_format surface_depth_stencil_format, size_t width, size_t height) + bool ds_has_format_width_height(const ComPtr &rtt, surface_depth_format surface_depth_stencil_format, size_t width, size_t height) { //TODO: Check format return rtt->GetDesc().Width == width && rtt->GetDesc().Height == height; @@ -129,7 +129,7 @@ struct render_target_traits static std::tuple, HANDLE> issue_download_command( gsl::not_null rtt, - Surface_color_format color_format, size_t width, size_t height, + surface_color_format color_format, size_t width, size_t height, gsl::not_null device, gsl::not_null command_queue, data_heap &readback_heap, resource_storage &res_store ) { @@ -162,12 +162,12 @@ struct render_target_traits static std::tuple, HANDLE> issue_depth_download_command( gsl::not_null ds, - Surface_depth_format depth_format, size_t width, size_t height, + surface_depth_format depth_format, size_t width, size_t height, gsl::not_null device, gsl::not_null command_queue, data_heap &readback_heap, resource_storage &res_store ) { ID3D12GraphicsCommandList* command_list = res_store.command_list.Get(); - DXGI_FORMAT dxgi_format = (depth_format == Surface_depth_format::z24s8) ? DXGI_FORMAT_R32_TYPELESS : DXGI_FORMAT_R16_TYPELESS; + DXGI_FORMAT dxgi_format = (depth_format == surface_depth_format::z24s8) ? DXGI_FORMAT_R32_TYPELESS : DXGI_FORMAT_R16_TYPELESS; size_t row_pitch = align(width * 4, 256); size_t buffer_size = row_pitch * height; diff --git a/rpcs3/Emu/RSX/GCM.cpp b/rpcs3/Emu/RSX/GCM.cpp index 61af633ec0..145eda2168 100644 --- a/rpcs3/Emu/RSX/GCM.cpp +++ b/rpcs3/Emu/RSX/GCM.cpp @@ -719,45 +719,45 @@ namespace }; } -Vertex_base_type to_vertex_base_type(u8 in) +vertex_base_type to_vertex_base_type(u8 in) { switch (in) { - case 1: return Vertex_base_type::s1; - case 2: return Vertex_base_type::f; - case 3: return Vertex_base_type::sf; - case 4: return Vertex_base_type::ub; - case 5: return Vertex_base_type::s32k; - case 6: return Vertex_base_type::cmp; - case 7: return Vertex_base_type::ub256; + case 1: return vertex_base_type::s1; + case 2: return vertex_base_type::f; + case 3: return vertex_base_type::sf; + case 4: return vertex_base_type::ub; + case 5: return vertex_base_type::s32k; + case 6: return vertex_base_type::cmp; + case 7: return vertex_base_type::ub256; } throw new EXCEPTION("Unknow vertex base type %d", in); } -Index_array_type to_index_array_type(u8 in) +index_array_type to_index_array_type(u8 in) { switch (in) { - case 0: return Index_array_type::unsigned_32b; - case 1: return Index_array_type::unsigned_16b; + case 0: return index_array_type::unsigned_32b; + case 1: return index_array_type::unsigned_16b; } throw new EXCEPTION("Unknown index array type %d", in); } -Primitive_type to_primitive_type(u8 in) +primitive_type to_primitive_type(u8 in) { switch (in) { - case 1: return Primitive_type::points; - case 2: return Primitive_type::lines; - case 3: return Primitive_type::line_loop; - case 4: return Primitive_type::line_strip; - case 5: return Primitive_type::triangles; - case 6: return Primitive_type::triangle_strip; - case 7: return Primitive_type::triangle_fan; - case 8: return Primitive_type::quads; - case 9: return Primitive_type::quad_strip; - case 10: return Primitive_type::polygon; + case 1: return primitive_type::points; + case 2: return primitive_type::lines; + case 3: return primitive_type::line_loop; + case 4: return primitive_type::line_strip; + case 5: return primitive_type::triangles; + case 6: return primitive_type::triangle_strip; + case 7: return primitive_type::triangle_fan; + case 8: return primitive_type::quads; + case 9: return primitive_type::quad_strip; + case 10: return primitive_type::polygon; } throw new EXCEPTION("Unknow primitive type %d", in); } @@ -801,26 +801,26 @@ enum }; -Surface_target to_surface_target(u8 in) +surface_target to_surface_target(u8 in) { switch (in) { - case CELL_GCM_SURFACE_TARGET_NONE: return Surface_target::none; - case CELL_GCM_SURFACE_TARGET_0: return Surface_target::surface_a; - case CELL_GCM_SURFACE_TARGET_1: return Surface_target::surface_b; - case CELL_GCM_SURFACE_TARGET_MRT1: return Surface_target::surfaces_a_b; - case CELL_GCM_SURFACE_TARGET_MRT2: return Surface_target::surfaces_a_b_c; - case CELL_GCM_SURFACE_TARGET_MRT3: return Surface_target::surfaces_a_b_c_d; + case CELL_GCM_SURFACE_TARGET_NONE: return surface_target::none; + case CELL_GCM_SURFACE_TARGET_0: return surface_target::surface_a; + case CELL_GCM_SURFACE_TARGET_1: return surface_target::surface_b; + case CELL_GCM_SURFACE_TARGET_MRT1: return surface_target::surfaces_a_b; + case CELL_GCM_SURFACE_TARGET_MRT2: return surface_target::surfaces_a_b_c; + case CELL_GCM_SURFACE_TARGET_MRT3: return surface_target::surfaces_a_b_c_d; } throw EXCEPTION("Unknow surface target %x", in); } -Surface_depth_format to_surface_depth_format(u8 in) +surface_depth_format to_surface_depth_format(u8 in) { switch (in) { - case CELL_GCM_SURFACE_Z16: return Surface_depth_format::z16; - case CELL_GCM_SURFACE_Z24S8: return Surface_depth_format::z24s8; + case CELL_GCM_SURFACE_Z16: return surface_depth_format::z16; + case CELL_GCM_SURFACE_Z24S8: return surface_depth_format::z24s8; } throw EXCEPTION("Unknow surface depth format %x", in); } @@ -836,36 +836,36 @@ std::string rsx::get_method_name(const u32 id) return fmt::format("unknown/illegal method [0x%08x]", id); } -Surface_antialiasing to_surface_antialiasing(u8 in) +surface_antialiasing to_surface_antialiasing(u8 in) { switch (in) { - case CELL_GCM_SURFACE_CENTER_1: return Surface_antialiasing::center_1_sample; - case CELL_GCM_SURFACE_DIAGONAL_CENTERED_2: return Surface_antialiasing::diagonal_centered_2_samples; - case CELL_GCM_SURFACE_SQUARE_CENTERED_4: return Surface_antialiasing::square_centered_4_samples; - case CELL_GCM_SURFACE_SQUARE_ROTATED_4: return Surface_antialiasing::square_rotated_4_samples; + case CELL_GCM_SURFACE_CENTER_1: return surface_antialiasing::center_1_sample; + case CELL_GCM_SURFACE_DIAGONAL_CENTERED_2: return surface_antialiasing::diagonal_centered_2_samples; + case CELL_GCM_SURFACE_SQUARE_CENTERED_4: return surface_antialiasing::square_centered_4_samples; + case CELL_GCM_SURFACE_SQUARE_ROTATED_4: return surface_antialiasing::square_rotated_4_samples; } throw EXCEPTION("unknow surface antialiasing format %x", in); } -Surface_color_format to_surface_color_format(u8 in) +surface_color_format to_surface_color_format(u8 in) { switch (in) { - case CELL_GCM_SURFACE_X1R5G5B5_Z1R5G5B5: return Surface_color_format::x1r5g5b5_z1r5g5b5; - case CELL_GCM_SURFACE_X1R5G5B5_O1R5G5B5: return Surface_color_format::x1r5g5b5_o1r5g5b5; - case CELL_GCM_SURFACE_R5G6B5: return Surface_color_format::r5g6b5; - case CELL_GCM_SURFACE_X8R8G8B8_Z8R8G8B8: return Surface_color_format::x8r8g8b8_z8r8g8b8; - case CELL_GCM_SURFACE_X8R8G8B8_O8R8G8B8: return Surface_color_format::x8r8g8b8_o8r8g8b8; - case CELL_GCM_SURFACE_A8R8G8B8: return Surface_color_format::a8r8g8b8; - case CELL_GCM_SURFACE_B8: return Surface_color_format::b8; - case CELL_GCM_SURFACE_G8B8: return Surface_color_format::g8b8; - case CELL_GCM_SURFACE_F_W16Z16Y16X16: return Surface_color_format::w16z16y16x16; - case CELL_GCM_SURFACE_F_W32Z32Y32X32: return Surface_color_format::w32z32y32x32; - case CELL_GCM_SURFACE_F_X32: return Surface_color_format::x32; - case CELL_GCM_SURFACE_X8B8G8R8_Z8B8G8R8: return Surface_color_format::x8b8g8r8_z8b8g8r8; - case CELL_GCM_SURFACE_X8B8G8R8_O8B8G8R8: return Surface_color_format::x8b8g8r8_o8b8g8r8; - case CELL_GCM_SURFACE_A8B8G8R8: return Surface_color_format::a8b8g8r8; + case CELL_GCM_SURFACE_X1R5G5B5_Z1R5G5B5: return surface_color_format::x1r5g5b5_z1r5g5b5; + case CELL_GCM_SURFACE_X1R5G5B5_O1R5G5B5: return surface_color_format::x1r5g5b5_o1r5g5b5; + case CELL_GCM_SURFACE_R5G6B5: return surface_color_format::r5g6b5; + case CELL_GCM_SURFACE_X8R8G8B8_Z8R8G8B8: return surface_color_format::x8r8g8b8_z8r8g8b8; + case CELL_GCM_SURFACE_X8R8G8B8_O8R8G8B8: return surface_color_format::x8r8g8b8_o8r8g8b8; + case CELL_GCM_SURFACE_A8R8G8B8: return surface_color_format::a8r8g8b8; + case CELL_GCM_SURFACE_B8: return surface_color_format::b8; + case CELL_GCM_SURFACE_G8B8: return surface_color_format::g8b8; + case CELL_GCM_SURFACE_F_W16Z16Y16X16: return surface_color_format::w16z16y16x16; + case CELL_GCM_SURFACE_F_W32Z32Y32X32: return surface_color_format::w32z32y32x32; + case CELL_GCM_SURFACE_F_X32: return surface_color_format::x32; + case CELL_GCM_SURFACE_X8B8G8R8_Z8B8G8R8: return surface_color_format::x8b8g8r8_z8b8g8r8; + case CELL_GCM_SURFACE_X8B8G8R8_O8B8G8R8: return surface_color_format::x8b8g8r8_o8b8g8r8; + case CELL_GCM_SURFACE_A8B8G8R8: return surface_color_format::a8b8g8r8; } throw EXCEPTION("unknow surface color format %x", in); } @@ -955,16 +955,16 @@ namespace { switch (to_primitive_type(draw_mode)) { - case Primitive_type::points: return "Points"; - case Primitive_type::lines: return "Lines"; - case Primitive_type::line_loop: return "Line_loop"; - case Primitive_type::line_strip: return "Line_strip"; - case Primitive_type::triangles: return "Triangles"; - case Primitive_type::triangle_strip: return "Triangle_strip"; - case Primitive_type::triangle_fan: return "Triangle_fan"; - case Primitive_type::quads: return "Quads"; - case Primitive_type::quad_strip: return "Quad_strip"; - case Primitive_type::polygon: return "Polygon"; + case primitive_type::points: return "Points"; + case primitive_type::lines: return "Lines"; + case primitive_type::line_loop: return "Line_loop"; + case primitive_type::line_strip: return "Line_strip"; + case primitive_type::triangles: return "Triangles"; + case primitive_type::triangle_strip: return "Triangle_strip"; + case primitive_type::triangle_fan: return "Triangle_fan"; + case primitive_type::quads: return "Quads"; + case primitive_type::quad_strip: return "Quad_strip"; + case primitive_type::polygon: return "Polygon"; } return "Error"; } @@ -991,8 +991,8 @@ namespace { switch (to_surface_depth_format(format)) { - case Surface_depth_format::z16: return "CELL_GCM_SURFACE_Z16"; - case Surface_depth_format::z24s8: return "CELL_GCM_SURFACE_Z24S8"; + case surface_depth_format::z16: return "CELL_GCM_SURFACE_Z16"; + case surface_depth_format::z24s8: return "CELL_GCM_SURFACE_Z24S8"; } return "Error"; } @@ -1001,10 +1001,10 @@ namespace { switch (to_surface_antialiasing(format)) { - case Surface_antialiasing::center_1_sample: "1 sample centered"; - case Surface_antialiasing::diagonal_centered_2_samples: return "2 samples diagonal centered"; - case Surface_antialiasing::square_centered_4_samples: return "4 samples square centered"; - case Surface_antialiasing::square_rotated_4_samples: return "4 samples diagonal rotated"; + case surface_antialiasing::center_1_sample: "1 sample centered"; + case surface_antialiasing::diagonal_centered_2_samples: return "2 samples diagonal centered"; + case surface_antialiasing::square_centered_4_samples: return "4 samples square centered"; + case surface_antialiasing::square_rotated_4_samples: return "4 samples diagonal rotated"; } return "Error"; } @@ -1013,20 +1013,20 @@ namespace { switch (to_surface_color_format(format)) { - case Surface_color_format::x1r5g5b5_z1r5g5b5: return "CELL_GCM_SURFACE_X1R5G5B5_Z1R5G5B5"; - case Surface_color_format::x1r5g5b5_o1r5g5b5: return "CELL_GCM_SURFACE_X1R5G5B5_O1R5G5B5"; - case Surface_color_format::r5g6b5 : return "CELL_GCM_SURFACE_R5G6B5"; - case Surface_color_format::x8r8g8b8_z8r8g8b8: return "CELL_GCM_SURFACE_X8R8G8B8_Z8R8G8B8"; - case Surface_color_format::x8r8g8b8_o8r8g8b8: return "CELL_GCM_SURFACE_X8R8G8B8_O8R8G8B8"; - case Surface_color_format::a8r8g8b8: return "CELL_GCM_SURFACE_A8R8G8B8"; - case Surface_color_format::b8: return "CELL_GCM_SURFACE_B8"; - case Surface_color_format::g8b8: return "CELL_GCM_SURFACE_G8B8"; - case Surface_color_format::w16z16y16x16: return "CELL_GCM_SURFACE_F_W16Z16Y16X16"; - case Surface_color_format::w32z32y32x32: return "CELL_GCM_SURFACE_F_W32Z32Y32X32"; - case Surface_color_format::x32: return "CELL_GCM_SURFACE_F_X32"; - case Surface_color_format::x8b8g8r8_z8b8g8r8: return "CELL_GCM_SURFACE_X8B8G8R8_Z8B8G8R8"; - case Surface_color_format::x8b8g8r8_o8b8g8r8: return "CELL_GCM_SURFACE_X8B8G8R8_O8B8G8R8"; - case Surface_color_format::a8b8g8r8: return "CELL_GCM_SURFACE_A8B8G8R8"; + case surface_color_format::x1r5g5b5_z1r5g5b5: return "CELL_GCM_SURFACE_X1R5G5B5_Z1R5G5B5"; + case surface_color_format::x1r5g5b5_o1r5g5b5: return "CELL_GCM_SURFACE_X1R5G5B5_O1R5G5B5"; + case surface_color_format::r5g6b5 : return "CELL_GCM_SURFACE_R5G6B5"; + case surface_color_format::x8r8g8b8_z8r8g8b8: return "CELL_GCM_SURFACE_X8R8G8B8_Z8R8G8B8"; + case surface_color_format::x8r8g8b8_o8r8g8b8: return "CELL_GCM_SURFACE_X8R8G8B8_O8R8G8B8"; + case surface_color_format::a8r8g8b8: return "CELL_GCM_SURFACE_A8R8G8B8"; + case surface_color_format::b8: return "CELL_GCM_SURFACE_B8"; + case surface_color_format::g8b8: return "CELL_GCM_SURFACE_G8B8"; + case surface_color_format::w16z16y16x16: return "CELL_GCM_SURFACE_F_W16Z16Y16X16"; + case surface_color_format::w32z32y32x32: return "CELL_GCM_SURFACE_F_W32Z32Y32X32"; + case surface_color_format::x32: return "CELL_GCM_SURFACE_F_X32"; + case surface_color_format::x8b8g8r8_z8b8g8r8: return "CELL_GCM_SURFACE_X8B8G8R8_Z8B8G8R8"; + case surface_color_format::x8b8g8r8_o8b8g8r8: return "CELL_GCM_SURFACE_X8B8G8R8_O8B8G8R8"; + case surface_color_format::a8b8g8r8: return "CELL_GCM_SURFACE_A8B8G8R8"; } return "Error"; } @@ -1035,12 +1035,12 @@ namespace { switch (to_surface_target(target)) { - case Surface_target::none: return "none"; - case Surface_target::surface_a: return "surface A"; - case Surface_target::surface_b: return "surface B"; - case Surface_target::surfaces_a_b: return "surfaces A and B"; - case Surface_target::surfaces_a_b_c: return "surfaces A, B and C"; - case Surface_target::surfaces_a_b_c_d: return "surfaces A,B, C and D"; + case surface_target::none: return "none"; + case surface_target::surface_a: return "surface A"; + case surface_target::surface_b: return "surface B"; + case surface_target::surfaces_a_b: return "surfaces A and B"; + case surface_target::surfaces_a_b_c: return "surfaces A, B and C"; + case surface_target::surfaces_a_b_c_d: return "surfaces A,B, C and D"; } return "Error"; } @@ -1080,13 +1080,13 @@ namespace { switch (to_vertex_base_type(type)) { - case Vertex_base_type::s1: return "Short"; - case Vertex_base_type::f: return "Float"; - case Vertex_base_type::sf: return "Half float"; - case Vertex_base_type::ub: return "Unsigned byte"; - case Vertex_base_type::s32k: return "Signed int"; - case Vertex_base_type::cmp: return "CMP"; - case Vertex_base_type::ub256: return "UB256"; + case vertex_base_type::s1: return "Short"; + case vertex_base_type::f: return "Float"; + case vertex_base_type::sf: return "Half float"; + case vertex_base_type::ub: return "Unsigned byte"; + case vertex_base_type::s32k: return "Signed int"; + case vertex_base_type::cmp: return "CMP"; + case vertex_base_type::ub256: return "UB256"; } } @@ -1106,8 +1106,8 @@ namespace { switch (to_index_array_type(arg)) { - case Index_array_type::unsigned_16b: return "unsigned short"; - case Index_array_type::unsigned_32b: return "unsigned int"; + case index_array_type::unsigned_16b: return "unsigned short"; + case index_array_type::unsigned_32b: return "unsigned int"; } return "Error"; } diff --git a/rpcs3/Emu/RSX/GCM.h b/rpcs3/Emu/RSX/GCM.h index 9a7dfa4980..92a55f2c6d 100644 --- a/rpcs3/Emu/RSX/GCM.h +++ b/rpcs3/Emu/RSX/GCM.h @@ -23,7 +23,7 @@ enum CELL_GCM_DISPLAY_FREQUENCY_DISABLE = 3, }; -enum class Vertex_base_type : u8 +enum class vertex_base_type : u8 { s1, ///< signed byte f, ///< float @@ -34,17 +34,17 @@ enum class Vertex_base_type : u8 ub256, }; -Vertex_base_type to_vertex_base_type(u8 in); +vertex_base_type to_vertex_base_type(u8 in); -enum class Index_array_type : u8 +enum class index_array_type : u8 { unsigned_32b, unsigned_16b, }; -Index_array_type to_index_array_type(u8 in); +index_array_type to_index_array_type(u8 in); -enum class Primitive_type : u8 +enum class primitive_type : u8 { points, lines, @@ -58,9 +58,9 @@ enum class Primitive_type : u8 polygon, // convex polygon }; -Primitive_type to_primitive_type(u8 in); +primitive_type to_primitive_type(u8 in); -enum class Surface_target : u8 +enum class surface_target : u8 { none, surface_a, @@ -70,17 +70,17 @@ enum class Surface_target : u8 surfaces_a_b_c_d, }; -Surface_target to_surface_target(u8 in); +surface_target to_surface_target(u8 in); -enum class Surface_depth_format : u8 +enum class surface_depth_format : u8 { z16, // unsigned 16 bits depth z24s8, // unsigned 24 bits depth + 8 bits stencil }; -Surface_depth_format to_surface_depth_format(u8 in); +surface_depth_format to_surface_depth_format(u8 in); -enum class Surface_antialiasing : u8 +enum class surface_antialiasing : u8 { center_1_sample, diagonal_centered_2_samples, @@ -88,9 +88,9 @@ enum class Surface_antialiasing : u8 square_rotated_4_samples, }; -Surface_antialiasing to_surface_antialiasing(u8 in); +surface_antialiasing to_surface_antialiasing(u8 in); -enum class Surface_color_format : u8 +enum class surface_color_format : u8 { x1r5g5b5_z1r5g5b5, x1r5g5b5_o1r5g5b5, @@ -108,7 +108,7 @@ enum class Surface_color_format : u8 a8b8g8r8, }; -Surface_color_format to_surface_color_format(u8 in); +surface_color_format to_surface_color_format(u8 in); enum { diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index 94eb2b9d19..222248385c 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -11,22 +11,22 @@ namespace { - u32 get_max_depth_value(Surface_depth_format format) + u32 get_max_depth_value(surface_depth_format format) { switch (format) { - case Surface_depth_format::z16: return 0xFFFF; - case Surface_depth_format::z24s8: return 0xFFFFFF; + case surface_depth_format::z16: return 0xFFFF; + case surface_depth_format::z24s8: return 0xFFFFFF; } throw EXCEPTION("Unknow depth format"); } - u8 get_pixel_size(Surface_depth_format format) + u8 get_pixel_size(surface_depth_format format) { switch (format) { - case Surface_depth_format::z16: return 2; - case Surface_depth_format::z24s8: return 4; + case surface_depth_format::z16: return 2; + case surface_depth_format::z24s8: return 4; } throw EXCEPTION("Unknow depth format"); } @@ -120,7 +120,7 @@ void GLGSRender::begin() __glcheck glBlendFuncSeparate(sfactor_rgb, dfactor_rgb, sfactor_a, dfactor_a); - if (m_surface.color_format == Surface_color_format::w16z16y16x16) //TODO: check another color formats + if (m_surface.color_format == surface_color_format::w16z16y16x16) //TODO: check another color formats { u32 blend_color = rsx::method_registers[NV4097_SET_BLEND_COLOR]; u32 blend_color2 = rsx::method_registers[NV4097_SET_BLEND_COLOR2]; @@ -318,33 +318,33 @@ void apply_attrib_array(gl::glsl::program& program, int location, const std::vec namespace { - gl::buffer_pointer::type gl_types(Vertex_base_type type) + gl::buffer_pointer::type gl_types(vertex_base_type type) { switch (type) { - case Vertex_base_type::s1: return gl::buffer_pointer::type::s16; - case Vertex_base_type::f: return gl::buffer_pointer::type::f32; - case Vertex_base_type::sf: return gl::buffer_pointer::type::f16; - case Vertex_base_type::ub: return gl::buffer_pointer::type::u8; - case Vertex_base_type::s32k: return gl::buffer_pointer::type::s32; - case Vertex_base_type::cmp: return gl::buffer_pointer::type::s16; // Needs conversion - case Vertex_base_type::ub256: gl::buffer_pointer::type::u8; + case vertex_base_type::s1: return gl::buffer_pointer::type::s16; + case vertex_base_type::f: return gl::buffer_pointer::type::f32; + case vertex_base_type::sf: return gl::buffer_pointer::type::f16; + case vertex_base_type::ub: return gl::buffer_pointer::type::u8; + case vertex_base_type::s32k: return gl::buffer_pointer::type::s32; + case vertex_base_type::cmp: return gl::buffer_pointer::type::s16; // Needs conversion + case vertex_base_type::ub256: gl::buffer_pointer::type::u8; } throw EXCEPTION("unknow vertex type"); } - bool gl_normalized(Vertex_base_type type) + bool gl_normalized(vertex_base_type type) { switch (type) { - case Vertex_base_type::s1: - case Vertex_base_type::ub: - case Vertex_base_type::cmp: + case vertex_base_type::s1: + case vertex_base_type::ub: + case vertex_base_type::cmp: return true; - case Vertex_base_type::f: - case Vertex_base_type::sf: - case Vertex_base_type::ub256: - case Vertex_base_type::s32k: + case vertex_base_type::f: + case vertex_base_type::sf: + case vertex_base_type::ub256: + case vertex_base_type::s32k: return false; } throw EXCEPTION("unknow vertex type"); @@ -402,9 +402,9 @@ void GLGSRender::end() std::vector vertex_index_array; vertex_draw_count = 0; u32 min_index, max_index; - if (draw_command == Draw_command::draw_command_indexed) + if (draw_command == rsx::draw_command::indexed) { - Index_array_type type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); + index_array_type type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); u32 type_size = gsl::narrow(get_index_type_size(type)); for (const auto& first_count : first_count_commands) { @@ -415,16 +415,16 @@ void GLGSRender::end() switch (type) { - case Index_array_type::unsigned_32b: + case index_array_type::unsigned_32b: std::tie(min_index, max_index) = write_index_array_data_to_buffer_untouched(gsl::span((u32*)vertex_index_array.data(), vertex_draw_count), first_count_commands); break; - case Index_array_type::unsigned_16b: + case index_array_type::unsigned_16b: std::tie(min_index, max_index) = write_index_array_data_to_buffer_untouched(gsl::span((u16*)vertex_index_array.data(), vertex_draw_count), first_count_commands); break; } } - if (draw_command == Draw_command::draw_command_inlined_array) + if (draw_command == rsx::draw_command::inlined_array) { write_inline_array_to_buffer(vertex_arrays_data.data()); u32 offset = 0; @@ -446,7 +446,7 @@ void GLGSRender::end() } } - if (draw_command == Draw_command::draw_command_array) + if (draw_command == rsx::draw_command::array) { for (const auto &first_count : first_count_commands) { @@ -454,7 +454,7 @@ void GLGSRender::end() } } - if (draw_command == Draw_command::draw_command_array || draw_command == Draw_command::draw_command_indexed) + if (draw_command == rsx::draw_command::array || draw_command == rsx::draw_command::indexed) { for (int index = 0; index < rsx::limits::vertex_count; ++index) { @@ -475,7 +475,7 @@ void GLGSRender::end() // Fill vertex_array u32 element_size = rsx::get_vertex_type_size_on_host(vertex_info.type, vertex_info.size); vertex_array.resize(vertex_draw_count * element_size); - if (draw_command == Draw_command::draw_command_array) + if (draw_command == rsx::draw_command::array) { size_t offset = 0; for (const auto &first_count : first_count_commands) @@ -484,7 +484,7 @@ void GLGSRender::end() offset += first_count.second * element_size; } } - if (draw_command == Draw_command::draw_command_indexed) + if (draw_command == rsx::draw_command::indexed) { vertex_array.resize((max_index + 1) * element_size); write_vertex_array_data_to_buffer(vertex_array.data(), 0, max_index + 1, index, vertex_info); @@ -508,7 +508,7 @@ void GLGSRender::end() switch (vertex_info.type) { - case Vertex_base_type::f: + case vertex_base_type::f: switch (register_vertex_info[index].size) { case 1: apply_attrib_array(*m_program, location, vertex_data); break; @@ -527,15 +527,15 @@ void GLGSRender::end() } m_vbo.data(vertex_arrays_data.size(), vertex_arrays_data.data()); - if (draw_command == Draw_command::draw_command_indexed) + if (draw_command == rsx::draw_command::indexed) { m_ebo.data(vertex_index_array.size(), vertex_index_array.data()); - Index_array_type indexed_type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); + index_array_type indexed_type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); - if (indexed_type == Index_array_type::unsigned_32b) + if (indexed_type == index_array_type::unsigned_32b) __glcheck glDrawElements(gl::draw_mode(draw_mode), vertex_draw_count, GL_UNSIGNED_INT, nullptr); - if (indexed_type == Index_array_type::unsigned_16b) + if (indexed_type == index_array_type::unsigned_16b) __glcheck glDrawElements(gl::draw_mode(draw_mode), vertex_draw_count, GL_UNSIGNED_SHORT, nullptr); } else @@ -677,7 +677,7 @@ void nv4097_clear_surface(u32 arg, GLGSRender* renderer) if (arg & 0x1) { - Surface_depth_format surface_depth_format = to_surface_depth_format((rsx::method_registers[NV4097_SET_SURFACE_FORMAT] >> 5) & 0x7); + surface_depth_format surface_depth_format = to_surface_depth_format((rsx::method_registers[NV4097_SET_SURFACE_FORMAT] >> 5) & 0x7); u32 max_depth_value = get_max_depth_value(surface_depth_format); u32 clear_depth = rsx::method_registers[NV4097_SET_ZSTENCIL_CLEAR_VALUE] >> 8; @@ -855,52 +855,52 @@ struct color_format color_swizzle swizzle; }; -color_format surface_color_format_to_gl(Surface_color_format color_format) +color_format surface_color_format_to_gl(surface_color_format color_format) { //color format switch (color_format) { - case Surface_color_format::r5g6b5: + case surface_color_format::r5g6b5: return{ gl::texture::type::ushort_5_6_5, gl::texture::format::bgr, false, 3, 2 }; - case Surface_color_format::a8r8g8b8: + case surface_color_format::a8r8g8b8: return{ gl::texture::type::uint_8_8_8_8, gl::texture::format::bgra, false, 4, 1 }; - case Surface_color_format::x8r8g8b8_o8r8g8b8: + case surface_color_format::x8r8g8b8_o8r8g8b8: return{ gl::texture::type::uint_8_8_8_8, gl::texture::format::bgra, false, 4, 1, { gl::texture::channel::one, gl::texture::channel::r, gl::texture::channel::g, gl::texture::channel::b } }; - case Surface_color_format::w16z16y16x16: + case surface_color_format::w16z16y16x16: return{ gl::texture::type::f16, gl::texture::format::rgba, true, 4, 2 }; - case Surface_color_format::w32z32y32x32: + case surface_color_format::w32z32y32x32: return{ gl::texture::type::f32, gl::texture::format::rgba, true, 4, 4 }; - case Surface_color_format::b8: - case Surface_color_format::x1r5g5b5_o1r5g5b5: - case Surface_color_format::x1r5g5b5_z1r5g5b5: - case Surface_color_format::x8r8g8b8_z8r8g8b8: - case Surface_color_format::g8b8: - case Surface_color_format::x32: - case Surface_color_format::x8b8g8r8_o8b8g8r8: - case Surface_color_format::x8b8g8r8_z8b8g8r8: - case Surface_color_format::a8b8g8r8: + case surface_color_format::b8: + case surface_color_format::x1r5g5b5_o1r5g5b5: + case surface_color_format::x1r5g5b5_z1r5g5b5: + case surface_color_format::x8r8g8b8_z8r8g8b8: + case surface_color_format::g8b8: + case surface_color_format::x32: + case surface_color_format::x8b8g8r8_o8b8g8r8: + case surface_color_format::x8b8g8r8_z8b8g8r8: + case surface_color_format::a8b8g8r8: default: LOG_ERROR(RSX, "Surface color buffer: Unsupported surface color format (0x%x)", color_format); return{ gl::texture::type::uint_8_8_8_8, gl::texture::format::bgra, false, 4, 1 }; } } -std::pair surface_depth_format_to_gl(Surface_depth_format depth_format) +std::pair surface_depth_format_to_gl(surface_depth_format depth_format) { switch (depth_format) { - case Surface_depth_format::z16: + case surface_depth_format::z16: return std::make_pair(gl::texture::type::ushort, gl::texture::format::depth); default: LOG_ERROR(RSX, "Surface depth buffer: Unsupported surface depth format (0x%x)", depth_format); - case Surface_depth_format::z24s8: + case surface_depth_format::z24s8: return std::make_pair(gl::texture::type::uint_24_8, gl::texture::format::depth_stencil); //return std::make_pair(gl::texture::type::f32, gl::texture::format::depth); } @@ -949,7 +949,7 @@ void GLGSRender::init_buffers(bool skip_reading) switch (m_surface.depth_format) { - case Surface_depth_format::z16: + case surface_depth_format::z16: { __glcheck m_draw_tex_depth_stencil.config() .size({ (int)m_surface.width, (int)m_surface.height }) @@ -961,7 +961,7 @@ void GLGSRender::init_buffers(bool skip_reading) break; } - case Surface_depth_format::z24s8: + case surface_depth_format::z24s8: { __glcheck m_draw_tex_depth_stencil.config() .size({ (int)m_surface.width, (int)m_surface.height }) @@ -994,25 +994,25 @@ void GLGSRender::init_buffers(bool skip_reading) switch (to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])) { - case Surface_target::none: break; + case surface_target::none: break; - case Surface_target::surface_a: + case surface_target::surface_a: __glcheck draw_fbo.draw_buffer(draw_fbo.color[0]); break; - case Surface_target::surface_b: + case surface_target::surface_b: __glcheck draw_fbo.draw_buffer(draw_fbo.color[1] ); break; - case Surface_target::surfaces_a_b: + case surface_target::surfaces_a_b: __glcheck draw_fbo.draw_buffers({ draw_fbo.color[0], draw_fbo.color[1] }); break; - case Surface_target::surfaces_a_b_c: + case surface_target::surfaces_a_b_c: __glcheck draw_fbo.draw_buffers({ draw_fbo.color[0], draw_fbo.color[1], draw_fbo.color[2] }); break; - case Surface_target::surfaces_a_b_c_d: + case surface_target::surfaces_a_b_c_d: __glcheck draw_fbo.draw_buffers({ draw_fbo.color[0], draw_fbo.color[1], draw_fbo.color[2], draw_fbo.color[3] }); break; @@ -1092,26 +1092,26 @@ void GLGSRender::read_buffers() switch (to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])) { - case Surface_target::none: + case surface_target::none: break; - case Surface_target::surface_a: + case surface_target::surface_a: read_color_buffers(0, 1); break; - case Surface_target::surface_b: + case surface_target::surface_b: read_color_buffers(1, 1); break; - case Surface_target::surfaces_a_b: + case surface_target::surfaces_a_b: read_color_buffers(0, 2); break; - case Surface_target::surfaces_a_b_c: + case surface_target::surfaces_a_b_c: read_color_buffers(0, 3); break; - case Surface_target::surfaces_a_b_c_d: + case surface_target::surfaces_a_b_c_d: read_color_buffers(0, 4); break; } @@ -1135,7 +1135,7 @@ void GLGSRender::read_buffers() { u32 depth_address = rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_ZETA_OFFSET], rsx::method_registers[NV4097_SET_CONTEXT_DMA_ZETA]); - if (m_surface.depth_format == Surface_depth_format::z16) + if (m_surface.depth_format == surface_depth_format::z16) { u16 *dst = (u16*)pixels; const be_t* src = vm::ps3::_ptr(depth_address); @@ -1223,26 +1223,26 @@ void GLGSRender::write_buffers() switch (to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])) { - case Surface_target::none: + case surface_target::none: break; - case Surface_target::surface_a: + case surface_target::surface_a: write_color_buffers(0, 1); break; - case Surface_target::surface_b: + case surface_target::surface_b: write_color_buffers(1, 1); break; - case Surface_target::surfaces_a_b: + case surface_target::surfaces_a_b: write_color_buffers(0, 2); break; - case Surface_target::surfaces_a_b_c: + case surface_target::surfaces_a_b_c: write_color_buffers(0, 3); break; - case Surface_target::surfaces_a_b_c_d: + case surface_target::surfaces_a_b_c_d: write_color_buffers(0, 4); break; } @@ -1269,7 +1269,7 @@ void GLGSRender::write_buffers() { u32 depth_address = rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_ZETA_OFFSET], rsx::method_registers[NV4097_SET_CONTEXT_DMA_ZETA]); - if (m_surface.depth_format == Surface_depth_format::z16) + if (m_surface.depth_format == surface_depth_format::z16) { const u16 *src = (const u16*)pixels; be_t* dst = vm::ps3::_ptr(depth_address); diff --git a/rpcs3/Emu/RSX/GL/gl_helpers.cpp b/rpcs3/Emu/RSX/GL/gl_helpers.cpp index d8ec50be12..0fb194e03e 100644 --- a/rpcs3/Emu/RSX/GL/gl_helpers.cpp +++ b/rpcs3/Emu/RSX/GL/gl_helpers.cpp @@ -5,20 +5,20 @@ namespace gl { const fbo screen{}; - GLenum draw_mode(Primitive_type in) + GLenum draw_mode(primitive_type in) { switch (in) { - case Primitive_type::points: return GL_POINTS; - case Primitive_type::lines: return GL_LINES; - case Primitive_type::line_loop: return GL_LINE_LOOP; - case Primitive_type::line_strip: return GL_LINE_STRIP; - case Primitive_type::triangles: return GL_TRIANGLES; - case Primitive_type::triangle_strip: return GL_TRIANGLE_STRIP; - case Primitive_type::triangle_fan: return GL_TRIANGLE_FAN; - case Primitive_type::quads: return GL_QUADS; - case Primitive_type::quad_strip: return GL_QUAD_STRIP; - case Primitive_type::polygon: return GL_POLYGON; + case primitive_type::points: return GL_POINTS; + case primitive_type::lines: return GL_LINES; + case primitive_type::line_loop: return GL_LINE_LOOP; + case primitive_type::line_strip: return GL_LINE_STRIP; + case primitive_type::triangles: return GL_TRIANGLES; + case primitive_type::triangle_strip: return GL_TRIANGLE_STRIP; + case primitive_type::triangle_fan: return GL_TRIANGLE_FAN; + case primitive_type::quads: return GL_QUADS; + case primitive_type::quad_strip: return GL_QUAD_STRIP; + case primitive_type::polygon: return GL_POLYGON; } throw new EXCEPTION("unknow primitive type"); } @@ -97,74 +97,74 @@ namespace gl __glcheck glDrawBuffers((GLsizei)ids.size(), ids.data()); } - void fbo::draw_arrays(Primitive_type mode, GLsizei count, GLint first) const + void fbo::draw_arrays(primitive_type mode, GLsizei count, GLint first) const { save_binding_state save(*this); __glcheck glDrawArrays(draw_mode(mode), first, count); } - void fbo::draw_arrays(const buffer& buffer, Primitive_type mode, GLsizei count, GLint first) const + void fbo::draw_arrays(const buffer& buffer, primitive_type mode, GLsizei count, GLint first) const { buffer.bind(buffer::target::array); draw_arrays(mode, count, first); } - void fbo::draw_arrays(const vao& buffer, Primitive_type mode, GLsizei count, GLint first) const + void fbo::draw_arrays(const vao& buffer, primitive_type mode, GLsizei count, GLint first) const { buffer.bind(); draw_arrays(mode, count, first); } - void fbo::draw_elements(Primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const + void fbo::draw_elements(primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const { save_binding_state save(*this); __glcheck glDrawElements(draw_mode(mode), count, (GLenum)type, indices); } - void fbo::draw_elements(const buffer& buffer, Primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const + void fbo::draw_elements(const buffer& buffer, primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const { buffer.bind(buffer::target::array); __glcheck glDrawElements(draw_mode(mode), count, (GLenum)type, indices); } - void fbo::draw_elements(Primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset) const + void fbo::draw_elements(primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset) const { indices.bind(buffer::target::element_array); __glcheck glDrawElements(draw_mode(mode), count, (GLenum)type, (GLvoid*)indices_buffer_offset); } - void fbo::draw_elements(const buffer& buffer_, Primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset) const + void fbo::draw_elements(const buffer& buffer_, primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset) const { buffer_.bind(buffer::target::array); draw_elements(mode, count, type, indices, indices_buffer_offset); } - void fbo::draw_elements(Primitive_type mode, GLsizei count, const GLubyte *indices) const + void fbo::draw_elements(primitive_type mode, GLsizei count, const GLubyte *indices) const { draw_elements(mode, count, indices_type::ubyte, indices); } - void fbo::draw_elements(const buffer& buffer, Primitive_type mode, GLsizei count, const GLubyte *indices) const + void fbo::draw_elements(const buffer& buffer, primitive_type mode, GLsizei count, const GLubyte *indices) const { draw_elements(buffer, mode, count, indices_type::ubyte, indices); } - void fbo::draw_elements(Primitive_type mode, GLsizei count, const GLushort *indices) const + void fbo::draw_elements(primitive_type mode, GLsizei count, const GLushort *indices) const { draw_elements(mode, count, indices_type::ushort, indices); } - void fbo::draw_elements(const buffer& buffer, Primitive_type mode, GLsizei count, const GLushort *indices) const + void fbo::draw_elements(const buffer& buffer, primitive_type mode, GLsizei count, const GLushort *indices) const { draw_elements(buffer, mode, count, indices_type::ushort, indices); } - void fbo::draw_elements(Primitive_type mode, GLsizei count, const GLuint *indices) const + void fbo::draw_elements(primitive_type mode, GLsizei count, const GLuint *indices) const { draw_elements(mode, count, indices_type::uint, indices); } - void fbo::draw_elements(const buffer& buffer, Primitive_type mode, GLsizei count, const GLuint *indices) const + void fbo::draw_elements(const buffer& buffer, primitive_type mode, GLsizei count, const GLuint *indices) const { draw_elements(buffer, mode, count, indices_type::uint, indices); } diff --git a/rpcs3/Emu/RSX/GL/gl_helpers.h b/rpcs3/Emu/RSX/GL/gl_helpers.h index 7862e202d6..04961fa7d0 100644 --- a/rpcs3/Emu/RSX/GL/gl_helpers.h +++ b/rpcs3/Emu/RSX/GL/gl_helpers.h @@ -1380,7 +1380,7 @@ namespace gl settings& border_color(color4f value); }; - GLenum draw_mode(Primitive_type in); + GLenum draw_mode(primitive_type in); enum class indices_type { @@ -1523,20 +1523,20 @@ namespace gl void draw_buffer(const attachment& buffer) const; void draw_buffers(const std::initializer_list& indexes) const; - void draw_arrays(Primitive_type mode, GLsizei count, GLint first = 0) const; - void draw_arrays(const buffer& buffer, Primitive_type mode, GLsizei count, GLint first = 0) const; - void draw_arrays(const vao& buffer, Primitive_type mode, GLsizei count, GLint first = 0) const; + void draw_arrays(primitive_type mode, GLsizei count, GLint first = 0) const; + void draw_arrays(const buffer& buffer, primitive_type mode, GLsizei count, GLint first = 0) const; + void draw_arrays(const vao& buffer, primitive_type mode, GLsizei count, GLint first = 0) const; - void draw_elements(Primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const; - void draw_elements(const buffer& buffer, Primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const; - void draw_elements(Primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset = 0) const; - void draw_elements(const buffer& buffer_, Primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset = 0) const; - void draw_elements(Primitive_type mode, GLsizei count, const GLubyte *indices) const; - void draw_elements(const buffer& buffer, Primitive_type mode, GLsizei count, const GLubyte *indices) const; - void draw_elements(Primitive_type mode, GLsizei count, const GLushort *indices) const; - void draw_elements(const buffer& buffer, Primitive_type mode, GLsizei count, const GLushort *indices) const; - void draw_elements(Primitive_type mode, GLsizei count, const GLuint *indices) const; - void draw_elements(const buffer& buffer, Primitive_type mode, GLsizei count, const GLuint *indices) const; + void draw_elements(primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const; + void draw_elements(const buffer& buffer, primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const; + void draw_elements(primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset = 0) const; + void draw_elements(const buffer& buffer_, primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset = 0) const; + void draw_elements(primitive_type mode, GLsizei count, const GLubyte *indices) const; + void draw_elements(const buffer& buffer, primitive_type mode, GLsizei count, const GLubyte *indices) const; + void draw_elements(primitive_type mode, GLsizei count, const GLushort *indices) const; + void draw_elements(const buffer& buffer, primitive_type mode, GLsizei count, const GLushort *indices) const; + void draw_elements(primitive_type mode, GLsizei count, const GLuint *indices) const; + void draw_elements(const buffer& buffer, primitive_type mode, GLsizei count, const GLuint *indices) const; void clear(buffers buffers_) const; void clear(buffers buffers_, color4f color_value, double depth_value, u8 stencil_value) const; diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 44d572c55c..7267884070 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -122,11 +122,11 @@ namespace rsx return res; } - u32 get_vertex_type_size_on_host(Vertex_base_type type, u32 size) + u32 get_vertex_type_size_on_host(vertex_base_type type, u32 size) { switch (type) { - case Vertex_base_type::s1: + case vertex_base_type::s1: switch (size) { case 1: @@ -137,8 +137,8 @@ namespace rsx return sizeof(u16) * 4; } throw new EXCEPTION("Wrong vector size"); - case Vertex_base_type::f: return sizeof(f32) * size; - case Vertex_base_type::sf: + case vertex_base_type::f: return sizeof(f32) * size; + case vertex_base_type::sf: switch (size) { case 1: @@ -149,7 +149,7 @@ namespace rsx return sizeof(f16) * 4; } throw new EXCEPTION("Wrong vector size"); - case Vertex_base_type::ub: + case vertex_base_type::ub: switch (size) { case 1: @@ -160,9 +160,9 @@ namespace rsx return sizeof(u8) * 4; } throw new EXCEPTION("Wrong vector size"); - case Vertex_base_type::s32k: return sizeof(u32) * size; - case Vertex_base_type::cmp: return sizeof(u16) * 4; - case Vertex_base_type::ub256: return sizeof(u8) * 4; + case vertex_base_type::s32k: return sizeof(u32) * size; + case vertex_base_type::cmp: return sizeof(u16) * 4; + case vertex_base_type::ub256: return sizeof(u8) * 4; default: throw new EXCEPTION("RSXVertexData::GetTypeSize: Bad vertex data type (%d)!", type); @@ -295,9 +295,9 @@ namespace rsx surface.unpack(rsx::method_registers[NV4097_SET_SURFACE_FORMAT]); draw_state.width = clip_w; draw_state.height = clip_h; - draw_state.surface_color_format = surface.color_format; + draw_state.color_format = surface.color_format; draw_state.color_buffer = std::move(copy_render_targets_to_memory()); - draw_state.surface_depth_format = surface.depth_format; + draw_state.depth_format = surface.depth_format; draw_state.depth_stencil = std::move(copy_depth_stencil_buffer_to_memory()); draw_state.programs = get_programs(); draw_state.name = name; @@ -495,7 +495,7 @@ namespace rsx u32 element_size = rsx::get_vertex_type_size_on_host(info.type, info.size); - if (info.type == Vertex_base_type::ub && info.size == 4) + if (info.type == vertex_base_type::ub && info.size == 4) { dst[0] = src[3]; dst[1] = src[2]; diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index 2635f92964..ec508ef42e 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -21,9 +21,9 @@ struct frame_capture_data std::string name; std::pair programs; size_t width = 0, height = 0; - Surface_color_format surface_color_format; + surface_color_format color_format; std::array, 4> color_buffer; - Surface_depth_format surface_depth_format; + surface_depth_format depth_format; std::array, 2> depth_stencil; }; std::vector > command_queue; @@ -145,7 +145,7 @@ namespace rsx static std::string path_to_root(); }; - u32 get_vertex_type_size_on_host(Vertex_base_type type, u32 size); + u32 get_vertex_type_size_on_host(vertex_base_type type, u32 size); u32 get_address(u32 offset, u32 location); @@ -164,9 +164,9 @@ namespace rsx { u8 log2height; u8 log2width; - Surface_antialiasing antialias; - Surface_depth_format depth_format; - Surface_color_format color_format; + surface_antialiasing antialias; + surface_depth_format depth_format; + surface_color_format color_format; u32 width; u32 height; @@ -192,7 +192,7 @@ namespace rsx u16 frequency = 0; u8 stride = 0; u8 size = 0; - Vertex_base_type type = Vertex_base_type::f; + vertex_base_type type = vertex_base_type::f; void unpack_array(u32 data_array_format) { @@ -203,6 +203,13 @@ namespace rsx } }; + enum class draw_command + { + array, + inlined_array, + indexed, + }; + class thread : public named_thread_t { protected: @@ -273,13 +280,8 @@ namespace rsx u32 ctxt_addr; u32 report_main_addr; u32 label_addr; - enum class Draw_command - { - draw_command_array, - draw_command_inlined_array, - draw_command_indexed, - } draw_command; - Primitive_type draw_mode; + rsx::draw_command draw_command; + primitive_type draw_mode; u32 local_mem_addr, main_mem_addr; bool strict_ordering[0x1000]; diff --git a/rpcs3/Emu/RSX/rsx_methods.cpp b/rpcs3/Emu/RSX/rsx_methods.cpp index 95af817e33..cd645fe8a6 100644 --- a/rpcs3/Emu/RSX/rsx_methods.cpp +++ b/rpcs3/Emu/RSX/rsx_methods.cpp @@ -14,10 +14,10 @@ namespace rsx rsx_method_t methods[0x10000 >> 2]{}; template struct vertex_data_type_from_element_type; - template<> struct vertex_data_type_from_element_type { static const Vertex_base_type type = Vertex_base_type::f; }; - template<> struct vertex_data_type_from_element_type { static const Vertex_base_type type = Vertex_base_type::sf; }; - template<> struct vertex_data_type_from_element_type { static const Vertex_base_type type = Vertex_base_type::ub; }; - template<> struct vertex_data_type_from_element_type { static const Vertex_base_type type = Vertex_base_type::s1; }; + template<> struct vertex_data_type_from_element_type { static const vertex_base_type type = vertex_base_type::f; }; + template<> struct vertex_data_type_from_element_type { static const vertex_base_type type = vertex_base_type::sf; }; + template<> struct vertex_data_type_from_element_type { static const vertex_base_type type = vertex_base_type::ub; }; + template<> struct vertex_data_type_from_element_type { static const vertex_base_type type = vertex_base_type::s1; }; namespace nv406e { @@ -160,7 +160,7 @@ namespace rsx force_inline void draw_arrays(thread* rsx, u32 arg) { - rsx->draw_command = thread::Draw_command::draw_command_array; + rsx->draw_command = rsx::draw_command::array; u32 first = arg & 0xffffff; u32 count = (arg >> 24) + 1; @@ -169,7 +169,7 @@ namespace rsx force_inline void draw_index_array(thread* rsx, u32 arg) { - rsx->draw_command = thread::Draw_command::draw_command_indexed; + rsx->draw_command = rsx::draw_command::indexed; u32 first = arg & 0xffffff; u32 count = (arg >> 24) + 1; @@ -178,7 +178,7 @@ namespace rsx force_inline void draw_inline_array(thread* rsx, u32 arg) { - rsx->draw_command = thread::Draw_command::draw_command_inlined_array; + rsx->draw_command = rsx::draw_command::inlined_array; rsx->draw_inline_vertex_array = true; rsx->inline_vertex_array.push_back(arg); } diff --git a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp index 2502985fbc..328bb3607b 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp @@ -258,7 +258,7 @@ u8 RescDstFormat2SysutilFormat(u32 dstFormat) { case CELL_RESC_SURFACE_F_W16Z16Y16X16: return CELL_VIDEO_OUT_BUFFER_COLOR_FORMAT_R16G16B16X16_FLOAT; - default: + default: return CELL_VIDEO_OUT_BUFFER_COLOR_FORMAT_X8R8G8B8; } } @@ -269,22 +269,22 @@ u8 GcmSurfaceFormat2GcmTextureFormat(u8 surfaceFormat, u8 surfaceType) switch (to_surface_color_format(surfaceFormat)) { - case Surface_color_format::a8r8g8b8: - result = CELL_GCM_TEXTURE_A8R8G8B8; + case surface_color_format::a8r8g8b8: + result = CELL_GCM_TEXTURE_A8R8G8B8; break; - case Surface_color_format::w16z16y16x16: - result = CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT; + case surface_color_format::w16z16y16x16: + result = CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT; break; - default: + default: return 0xFF; //Error } switch (surfaceType) { - case CELL_GCM_SURFACE_PITCH: + case CELL_GCM_SURFACE_PITCH: result |= CELL_GCM_TEXTURE_LN; break; - case CELL_GCM_SURFACE_SWIZZLE: + case CELL_GCM_SURFACE_SWIZZLE: result |= CELL_GCM_TEXTURE_SZ; break; default: @@ -300,13 +300,13 @@ s32 GetRescDestsIndex(u32 dstMode) { switch(dstMode) { - case CELL_RESC_720x480: + case CELL_RESC_720x480: return 0; - case CELL_RESC_720x576: + case CELL_RESC_720x576: return 1; - case CELL_RESC_1280x720: + case CELL_RESC_1280x720: return 2; - case CELL_RESC_1920x1080: + case CELL_RESC_1920x1080: return 3; default: return -1; @@ -317,14 +317,14 @@ void GetScreenSize(u32 mode, s32 *width, s32 *height) { switch (mode) { - case CELL_RESC_720x480: - *width = 720; *height = 480; + case CELL_RESC_720x480: + *width = 720; *height = 480; break; - case CELL_RESC_720x576: - *width = 720; *height = 576; + case CELL_RESC_720x576: + *width = 720; *height = 576; break; - case CELL_RESC_1280x720: - *width = 1280; *height = 720; + case CELL_RESC_1280x720: + *width = 1280; *height = 720; break; case CELL_RESC_1920x1080: *width = 1920; *height = 1080; @@ -935,16 +935,16 @@ s32 cellRescGcmSurface2RescSrc(vm::ptr gcmSurface, vm::ptrantialias)) { - case Surface_antialiasing::square_rotated_4_samples: + case surface_antialiasing::square_rotated_4_samples: xW=xH=2; break; - case Surface_antialiasing::square_centered_4_samples: + case surface_antialiasing::square_centered_4_samples: xW=xH=2; break; - case Surface_antialiasing::diagonal_centered_2_samples: + case surface_antialiasing::diagonal_centered_2_samples: xW=2; break; - default: + default: break; } diff --git a/rpcs3/Gui/RSXDebugger.cpp b/rpcs3/Gui/RSXDebugger.cpp index 7f496239c9..6c826fe8cd 100644 --- a/rpcs3/Gui/RSXDebugger.cpp +++ b/rpcs3/Gui/RSXDebugger.cpp @@ -382,16 +382,16 @@ void RSXDebugger::OnClickBuffer(wxMouseEvent& event) namespace { - std::array get_value(gsl::span orig_buffer, Surface_color_format format, size_t idx) + std::array get_value(gsl::span orig_buffer, surface_color_format format, size_t idx) { switch (format) { - case Surface_color_format::b8: + case surface_color_format::b8: { u8 value = gsl::as_span(orig_buffer)[idx]; return{ value, value, value }; } - case Surface_color_format::x32: + case surface_color_format::x32: { be_t stored_val = gsl::as_span>(orig_buffer)[idx]; u32 swapped_val = stored_val; @@ -399,21 +399,21 @@ namespace u8 val = float_val * 255.f; return{ val, val, val }; } - case Surface_color_format::a8b8g8r8: - case Surface_color_format::x8b8g8r8_o8b8g8r8: - case Surface_color_format::x8b8g8r8_z8b8g8r8: + case surface_color_format::a8b8g8r8: + case surface_color_format::x8b8g8r8_o8b8g8r8: + case surface_color_format::x8b8g8r8_z8b8g8r8: { auto ptr = gsl::as_span(orig_buffer); return{ ptr[1 + idx * 4], ptr[2 + idx * 4], ptr[3 + idx * 4] }; } - case Surface_color_format::a8r8g8b8: - case Surface_color_format::x8r8g8b8_o8r8g8b8: - case Surface_color_format::x8r8g8b8_z8r8g8b8: + case surface_color_format::a8r8g8b8: + case surface_color_format::x8r8g8b8_o8r8g8b8: + case surface_color_format::x8r8g8b8_z8r8g8b8: { auto ptr = gsl::as_span(orig_buffer); return{ ptr[3 + idx * 4], ptr[2 + idx * 4], ptr[1 + idx * 4] }; } - case Surface_color_format::w16z16y16x16: + case surface_color_format::w16z16y16x16: { auto ptr = gsl::as_span(orig_buffer); f16 h0 = f16(ptr[4 * idx]); @@ -428,11 +428,11 @@ namespace u8 val2 = f2 * 255.; return{ val0, val1, val2 }; } - case Surface_color_format::g8b8: - case Surface_color_format::r5g6b5: - case Surface_color_format::x1r5g5b5_o1r5g5b5: - case Surface_color_format::x1r5g5b5_z1r5g5b5: - case Surface_color_format::w32z32y32x32: + case surface_color_format::g8b8: + case surface_color_format::r5g6b5: + case surface_color_format::x1r5g5b5_o1r5g5b5: + case surface_color_format::x1r5g5b5_z1r5g5b5: + case surface_color_format::w32z32y32x32: throw EXCEPTION("Unsupported format for display"); } } @@ -441,7 +441,7 @@ namespace * Return a new buffer that can be passed to wxImage ctor. * The pointer seems to be freed by wxImage. */ - u8* convert_to_wximage_buffer(Surface_color_format format, gsl::span orig_buffer, size_t width, size_t height) noexcept + u8* convert_to_wximage_buffer(surface_color_format format, gsl::span orig_buffer, size_t width, size_t height) noexcept { unsigned char* buffer = (unsigned char*)malloc(width * height * 3); for (u32 i = 0; i < width * height; i++) @@ -476,7 +476,7 @@ void RSXDebugger::OnClickDrawCalls(wxMouseEvent& event) { if (width && height && !draw_call.color_buffer[i].empty()) { - buffer_img[i] = wxImage(width, height, convert_to_wximage_buffer(draw_call.surface_color_format, draw_call.color_buffer[i], width, height)); + buffer_img[i] = wxImage(width, height, convert_to_wximage_buffer(draw_call.color_format, draw_call.color_buffer[i], width, height)); wxClientDC dc_canvas(p_buffers[i]); if (buffer_img[i].IsOk()) @@ -491,7 +491,7 @@ void RSXDebugger::OnClickDrawCalls(wxMouseEvent& event) gsl::span orig_buffer = draw_call.depth_stencil[0]; unsigned char *buffer = (unsigned char *)malloc(width * height * 3); - if (draw_call.surface_depth_format == Surface_depth_format::z24s8) + if (draw_call.depth_format == surface_depth_format::z24s8) { for (u32 row = 0; row < height; row++) {