From 685d5d3ea3d11c50dd4ca74ff1a3f89333e949e6 Mon Sep 17 00:00:00 2001 From: DHrpcs3 Date: Wed, 20 Jan 2016 15:46:58 +0300 Subject: [PATCH 1/5] Access violation handled by rsx::thread gfxHandler -> rsx::g_access_violation_handler --- Utilities/Thread.cpp | 19 +++++++++---------- rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp | 25 ++++++++++++++++--------- rpcs3/Emu/RSX/D3D12/D3D12GSRender.h | 2 ++ rpcs3/Emu/RSX/RSXThread.cpp | 17 ++++++++++++++++- rpcs3/Emu/RSX/RSXThread.h | 7 +++++-- 5 files changed, 48 insertions(+), 22 deletions(-) diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 86a6701b3a4f..aac60cad6786 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -794,16 +794,18 @@ size_t get_x64_access_size(x64_context* context, x64_op_t op, x64_reg_t reg, siz return d_size; } -/** - * Callback that can be customised by GSRender backends to track memory access. - * Backends can protect memory pages and get this callback called when an access - * violation is met. - * Should return true if the backend handles the access violation. - */ -std::function gfxHandler = [](u32) { return false; }; +namespace rsx +{ + extern std::function g_access_violation_handler; +} bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) { + if (rsx::g_access_violation_handler && rsx::g_access_violation_handler(addr, is_writing)) + { + return true; + } + auto code = (const u8*)RIP(context); x64_op_t op; @@ -811,9 +813,6 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) size_t d_size; size_t i_size; - if (gfxHandler(addr)) - return true; - // decode single x64 instruction that causes memory access decode_x64_reg_op(code, op, reg, d_size, i_size); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp index 9d89cdf53f24..9400dfc91908 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp @@ -67,8 +67,6 @@ void D3D12GSRender::Shader::Release() m_samplerDescriptorHeap->Release(); } -extern std::function gfxHandler; - bool D3D12GSRender::invalidate_address(u32 addr) { bool result = false; @@ -89,12 +87,6 @@ D3D12DLLManagement::~D3D12DLLManagement() D3D12GSRender::D3D12GSRender() : GSRender(frame_type::DX12), m_d3d12_lib(), m_current_pso({}) { - gfxHandler = [this](u32 addr) { - bool result = invalidate_address(addr); - if (result) - LOG_WARNING(RSX, "Reporting Cell writing to 0x%x", addr); - return result; - }; if (rpcs3::config.rsx.d3d12.debug_output.value()) { Microsoft::WRL::ComPtr debugInterface; @@ -204,7 +196,6 @@ D3D12GSRender::~D3D12GSRender() m_texture_cache.unprotect_all(); - gfxHandler = [this](u32) { return false; }; m_dummy_texture->Release(); m_convertPSO->Release(); m_convertRootSignature->Release(); @@ -552,6 +543,22 @@ void D3D12GSRender::flip(int buffer) m_timers.m_flip_duration += std::chrono::duration_cast(flip_end - flip_start).count(); } +bool D3D12GSRender::on_access_violation(u32 address, bool is_writing) +{ + if (!is_writing) + { + return false; + } + + if (invalidate_address(address)) + { + LOG_WARNING(RSX, "Reporting Cell writing to 0x%x", address); + return true; + } + + return false; +} + void D3D12GSRender::reset_timer() { m_timers.m_draw_calls_count = 0; diff --git a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h index a7e34fcffebf..0e8a2dc1b7ca 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h @@ -193,6 +193,8 @@ class D3D12GSRender : public GSRender virtual void end() override; virtual void flip(int buffer) override; + virtual bool on_access_violation(u32 address, bool is_writing) override; + virtual std::array, 4> copy_render_targets_to_memory() override; virtual std::array, 2> copy_depth_stencil_buffer_to_memory() override; virtual std::pair get_programs() const override; diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 37d7ee6b44ad..44d572c55c13 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -19,6 +19,8 @@ frame_capture_data frame_debug; namespace rsx { + std::function g_access_violation_handler; + std::string shaders_cache::path_to_root() { return fs::get_executable_dir() + "data/"; @@ -167,7 +169,7 @@ namespace rsx return 0; } } - + void tiled_region::write(const void *src, u32 width, u32 height, u32 pitch) { if (!tile) @@ -270,6 +272,19 @@ namespace rsx } } + thread::thread() + { + g_access_violation_handler = [this](u32 address, bool is_writing) + { + return on_access_violation(address, is_writing); + }; + } + + thread::~thread() + { + g_access_violation_handler = nullptr; + } + void thread::capture_frame(const std::string &name) { frame_capture_data::draw_state draw_state = {}; diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index aee737cb7c10..2635f9296445 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -257,6 +257,7 @@ namespace rsx bool capture_current_frame = false; void capture_frame(const std::string &name); + public: u32 ioAddress, ioSize; int flip_status; @@ -283,7 +284,6 @@ namespace rsx u32 local_mem_addr, main_mem_addr; bool strict_ordering[0x1000]; - bool draw_inline_vertex_array; std::vector inline_vertex_array; @@ -309,7 +309,8 @@ namespace rsx std::set m_used_gcm_commands; protected: - virtual ~thread() {} + thread(); + virtual ~thread(); virtual void on_task() override; @@ -324,6 +325,7 @@ namespace rsx virtual bool do_method(u32 cmd, u32 value) { return false; } virtual void flip(int buffer) = 0; virtual u64 timestamp() const; + virtual bool on_access_violation(u32 address, bool is_writing) { return false; } /** * Fill buffer with 4x4 scale offset matrix. @@ -362,6 +364,7 @@ namespace rsx }; virtual std::pair get_programs() const { return std::make_pair("", ""); }; + public: void reset(); void init(const u32 ioAddress, const u32 ioSize, const u32 ctrlAddress, const u32 localAddress); From 7972cb5bdc05e73a217d0a4064210cac0e4cbe45 Mon Sep 17 00:00:00 2001 From: DHrpcs3 Date: Wed, 20 Jan 2016 16:23:25 +0300 Subject: [PATCH 2/5] Code style fixes #1 --- rpcs3/Emu/RSX/Common/BufferUtils.cpp | 116 +++++------ rpcs3/Emu/RSX/Common/BufferUtils.h | 12 +- rpcs3/Emu/RSX/Common/surface_store.cpp | 74 +++---- rpcs3/Emu/RSX/Common/surface_store.h | 74 +++---- rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp | 12 +- rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp | 116 +++++------ rpcs3/Emu/RSX/D3D12/D3D12Formats.h | 18 +- rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp | 14 +- rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp | 16 +- rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp | 96 ++++----- rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.h | 16 +- rpcs3/Emu/RSX/GCM.cpp | 194 +++++++++--------- rpcs3/Emu/RSX/GCM.h | 28 +-- rpcs3/Emu/RSX/GL/GLGSRender.cpp | 156 +++++++------- rpcs3/Emu/RSX/GL/gl_helpers.cpp | 48 ++--- rpcs3/Emu/RSX/GL/gl_helpers.h | 30 +-- rpcs3/Emu/RSX/RSXThread.cpp | 22 +- rpcs3/Emu/RSX/RSXThread.h | 30 +-- rpcs3/Emu/RSX/rsx_methods.cpp | 14 +- rpcs3/Emu/SysCalls/Modules/cellResc.cpp | 44 ++-- rpcs3/Gui/RSXDebugger.cpp | 36 ++-- 21 files changed, 584 insertions(+), 582 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.cpp b/rpcs3/Emu/RSX/Common/BufferUtils.cpp index 3528c0383d97..9d5789ae81a8 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 f2bba57cb1c3..cdd14df374a7 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 8361162a0aa3..7b177051d632 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 71cad3cf8949..56a632854a5e 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 d02c941089d9..761cc2888426 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 813864d379e6..60875b5f2c35 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 9400dfc91908..f52938af25bf 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 c8a26cba2a0c..a756db8ca44f 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 3edf99d54845..0616339f4fe5 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 df76dc8a9e15..15c8db05c0ca 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 61af633ec097..145eda216801 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 9a7dfa4980ba..92a55f2c6d02 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 94eb2b9d19af..222248385cd8 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 d8ec50be1210..0fb194e03e46 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 7862e202d68e..04961fa7d051 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_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_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 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 44d572c55c13..72678840701d 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 2635f9296445..ec508ef42ef2 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 95af817e33ad..cd645fe8a677 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 2502985fbc64..328bb3607b2d 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 7f496239c9c4..6c826fe8cdaf 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++) { From 7523d01e0fcd1f4249b5ffd825f6b70a4af8499e Mon Sep 17 00:00:00 2001 From: DHrpcs3 Date: Wed, 20 Jan 2016 16:39:06 +0300 Subject: [PATCH 3/5] Code style fixes #2 --- rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp | 24 ++--- rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp | 88 +++++++++---------- rpcs3/Emu/RSX/D3D12/D3D12GSRender.h | 58 ++++++------ rpcs3/Emu/RSX/D3D12/D3D12Overlay.cpp | 30 +++---- rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp | 26 +++--- rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp | 20 ++--- rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp | 8 +- rpcs3/Emu/RSX/D3D12/D3D12Utils.cpp | 30 +++---- 8 files changed, 143 insertions(+), 141 deletions(-) diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp index 56a632854a5e..98546e1a24db 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp @@ -13,7 +13,7 @@ std::vector D3D12GSRender::upload_vertex_attributes(co { std::vector vertex_buffer_views; - m_IASet.clear(); + m_ia_set.clear(); size_t input_slot = 0; size_t vertex_count = 0; @@ -55,7 +55,7 @@ std::vector D3D12GSRender::upload_vertex_attributes(co }; vertex_buffer_views.push_back(vertex_buffer_view); - m_timers.m_buffer_upload_size += buffer_size; + m_timers.buffer_upload_size += buffer_size; D3D12_INPUT_ELEMENT_DESC IAElement = {}; IAElement.SemanticName = "TEXCOORD"; @@ -65,7 +65,7 @@ std::vector D3D12GSRender::upload_vertex_attributes(co IAElement.AlignedByteOffset = 0; IAElement.InputSlotClass = D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA; IAElement.InstanceDataStepRate = 0; - m_IASet.push_back(IAElement); + m_ia_set.push_back(IAElement); } else if (register_vertex_info[index].size > 0) { @@ -98,7 +98,7 @@ std::vector D3D12GSRender::upload_vertex_attributes(co IAElement.AlignedByteOffset = 0; IAElement.InputSlotClass = D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA; IAElement.InstanceDataStepRate = 1; - m_IASet.push_back(IAElement); + m_ia_set.push_back(IAElement); } } @@ -141,7 +141,7 @@ void D3D12GSRender::upload_and_bind_scale_offset_matrix(size_t descriptorIndex) }; m_device->CreateConstantBufferView(&constant_buffer_view_desc, CD3DX12_CPU_DESCRIPTOR_HANDLE(get_current_resource_storage().descriptors_heap->GetCPUDescriptorHandleForHeapStart()) - .Offset((INT)descriptorIndex, g_descriptor_stride_srv_cbv_uav)); + .Offset((INT)descriptorIndex, m_descriptor_stride_srv_cbv_uav)); } void D3D12GSRender::upload_and_bind_vertex_shader_constants(size_t descriptor_index) @@ -160,13 +160,13 @@ void D3D12GSRender::upload_and_bind_vertex_shader_constants(size_t descriptor_in }; m_device->CreateConstantBufferView(&constant_buffer_view_desc, CD3DX12_CPU_DESCRIPTOR_HANDLE(get_current_resource_storage().descriptors_heap->GetCPUDescriptorHandleForHeapStart()) - .Offset((INT)descriptor_index, g_descriptor_stride_srv_cbv_uav)); + .Offset((INT)descriptor_index, m_descriptor_stride_srv_cbv_uav)); } void D3D12GSRender::upload_and_bind_fragment_shader_constants(size_t descriptor_index) { // Get constant from fragment program - size_t buffer_size = m_pso_cache.get_fragment_constants_buffer_size(fragment_program); + size_t buffer_size = m_pso_cache.get_fragment_constants_buffer_size(m_fragment_program); // Multiple of 256 never 0 buffer_size = (buffer_size + 255) & ~255; @@ -174,7 +174,7 @@ void D3D12GSRender::upload_and_bind_fragment_shader_constants(size_t descriptor_ size_t offset = 0; float *mapped_buffer = m_buffer_data.map(CD3DX12_RANGE(heap_offset, heap_offset + buffer_size)); - m_pso_cache.fill_fragment_constans_buffer({ mapped_buffer, gsl::narrow(buffer_size) }, fragment_program); + m_pso_cache.fill_fragment_constans_buffer({ mapped_buffer, gsl::narrow(buffer_size) }, m_fragment_program); m_buffer_data.unmap(CD3DX12_RANGE(heap_offset, heap_offset + buffer_size)); D3D12_CONSTANT_BUFFER_VIEW_DESC constant_buffer_view_desc = { @@ -183,14 +183,14 @@ void D3D12GSRender::upload_and_bind_fragment_shader_constants(size_t descriptor_ }; m_device->CreateConstantBufferView(&constant_buffer_view_desc, CD3DX12_CPU_DESCRIPTOR_HANDLE(get_current_resource_storage().descriptors_heap->GetCPUDescriptorHandleForHeapStart()) - .Offset((INT)descriptor_index, g_descriptor_stride_srv_cbv_uav)); + .Offset((INT)descriptor_index, m_descriptor_stride_srv_cbv_uav)); } std::tuple D3D12GSRender::upload_inlined_vertex_array() { UINT offset = 0; - m_IASet.clear(); + m_ia_set.clear(); // Bind attributes for (int index = 0; index < rsx::limits::vertex_count; ++index) { @@ -207,7 +207,7 @@ std::tuple D3D12GSRender::upload_inlined_verte IAElement.AlignedByteOffset = offset; IAElement.InputSlotClass = D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA; IAElement.InstanceDataStepRate = 0; - m_IASet.push_back(IAElement); + m_ia_set.push_back(IAElement); offset += rsx::get_vertex_type_size_on_host(info.type, info.size); } @@ -334,7 +334,7 @@ std::tuple D3D12GSRender::upload_and_set_vertex_index_data(ID3D12G (UINT)buffer_size, get_index_type(indexed_type) }; - m_timers.m_buffer_upload_size += buffer_size; + m_timers.buffer_upload_size += buffer_size; command_list->IASetIndexBuffer(&index_buffer_view); const std::vector &vertex_buffer_views = upload_vertex_attributes({ std::make_pair(0, max_index + 1) }); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp index f52938af25bf..5de07cbf379a 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp @@ -58,13 +58,13 @@ void wait_for_command_queue(ID3D12Device *device, ID3D12CommandQueue *command_qu } } -void D3D12GSRender::Shader::Release() +void D3D12GSRender::shader::release() { - m_PSO->Release(); - m_rootSignature->Release(); - m_vertexBuffer->Release(); - m_textureDescriptorHeap->Release(); - m_samplerDescriptorHeap->Release(); + pso->Release(); + root_signature->Release(); + vertex_buffer->Release(); + texture_descriptor_heap->Release(); + sampler_descriptor_heap->Release(); } bool D3D12GSRender::invalidate_address(u32 addr) @@ -105,10 +105,10 @@ D3D12GSRender::D3D12GSRender() D3D12_COMMAND_QUEUE_DESC graphic_queue_desc = { D3D12_COMMAND_LIST_TYPE_DIRECT }; CHECK_HRESULT(m_device->CreateCommandQueue(&graphic_queue_desc, IID_PPV_ARGS(m_command_queue.GetAddressOf()))); - g_descriptor_stride_srv_cbv_uav = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - g_descriptor_stride_dsv = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_DSV); - g_descriptor_stride_rtv = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV); - g_descriptor_stride_samplers = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); + m_descriptor_stride_srv_cbv_uav = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); + m_descriptor_stride_dsv = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_DSV); + m_descriptor_stride_rtv = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV); + m_descriptor_stride_samplers = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); // Create swap chain and put them in a descriptor heap as rendertarget DXGI_SWAP_CHAIN_DESC swap_chain = {}; @@ -169,8 +169,8 @@ D3D12GSRender::D3D12GSRender() m_per_frame_storage[1].init(m_device.Get()); m_per_frame_storage[1].reset(); - initConvertShader(); - m_output_scaling_pass.Init(m_device.Get(), m_command_queue.Get()); + init_convert_shader(); + m_output_scaling_pass.init(m_device.Get(), m_command_queue.Get()); CHECK_HRESULT( m_device->CreateCommittedResource( @@ -197,11 +197,11 @@ D3D12GSRender::~D3D12GSRender() m_texture_cache.unprotect_all(); m_dummy_texture->Release(); - m_convertPSO->Release(); - m_convertRootSignature->Release(); + m_convert_pso->Release(); + m_convert_root_signature->Release(); m_per_frame_storage[0].release(); m_per_frame_storage[1].release(); - m_output_scaling_pass.Release(); + m_output_scaling_pass.release(); release_d2d_structures(); } @@ -237,7 +237,7 @@ void D3D12GSRender::end() prepare_render_targets(get_current_resource_storage().command_list.Get()); std::chrono::time_point rtt_duration_end = std::chrono::system_clock::now(); - m_timers.m_prepare_rtt_duration += std::chrono::duration_cast(rtt_duration_end - rtt_duration_start).count(); + m_timers.prepare_rtt_duration += std::chrono::duration_cast(rtt_duration_end - rtt_duration_start).count(); std::chrono::time_point vertex_index_duration_start = std::chrono::system_clock::now(); @@ -246,12 +246,12 @@ void D3D12GSRender::end() std::tie(indexed_draw, vertex_count) = upload_and_set_vertex_index_data(get_current_resource_storage().command_list.Get()); std::chrono::time_point vertex_index_duration_end = std::chrono::system_clock::now(); - m_timers.m_vertex_index_duration += std::chrono::duration_cast(vertex_index_duration_end - vertex_index_duration_start).count(); + m_timers.vertex_index_duration += std::chrono::duration_cast(vertex_index_duration_end - vertex_index_duration_start).count(); std::chrono::time_point program_load_start = std::chrono::system_clock::now(); load_program(); std::chrono::time_point program_load_end = std::chrono::system_clock::now(); - m_timers.m_program_load_duration += std::chrono::duration_cast(program_load_end - program_load_start).count(); + m_timers.program_load_duration += std::chrono::duration_cast(program_load_end - program_load_start).count(); get_current_resource_storage().command_list->SetGraphicsRootSignature(m_root_signatures[std::get<2>(m_current_pso)].Get()); get_current_resource_storage().command_list->OMSetStencilRef(rsx::method_registers[NV4097_SET_STENCIL_FUNC_REF]); @@ -265,7 +265,7 @@ void D3D12GSRender::end() upload_and_bind_fragment_shader_constants(currentDescriptorIndex + 2); std::chrono::time_point constants_duration_end = std::chrono::system_clock::now(); - m_timers.m_constants_duration += std::chrono::duration_cast(constants_duration_end - constants_duration_start).count(); + m_timers.constants_duration += std::chrono::duration_cast(constants_duration_end - constants_duration_start).count(); get_current_resource_storage().command_list->SetPipelineState(std::get<0>(m_current_pso).Get()); @@ -277,11 +277,11 @@ void D3D12GSRender::end() get_current_resource_storage().command_list->SetGraphicsRootDescriptorTable(0, CD3DX12_GPU_DESCRIPTOR_HANDLE(get_current_resource_storage().descriptors_heap->GetGPUDescriptorHandleForHeapStart()) - .Offset((INT)currentDescriptorIndex, g_descriptor_stride_srv_cbv_uav) + .Offset((INT)currentDescriptorIndex, m_descriptor_stride_srv_cbv_uav) ); get_current_resource_storage().command_list->SetGraphicsRootDescriptorTable(1, CD3DX12_GPU_DESCRIPTOR_HANDLE(get_current_resource_storage().sampler_descriptor_heap[get_current_resource_storage().sampler_descriptors_heap_index]->GetGPUDescriptorHandleForHeapStart()) - .Offset((INT)get_current_resource_storage().current_sampler_index, g_descriptor_stride_samplers) + .Offset((INT)get_current_resource_storage().current_sampler_index, m_descriptor_stride_samplers) ); get_current_resource_storage().current_sampler_index += std::get<2>(m_current_pso); @@ -292,13 +292,13 @@ void D3D12GSRender::end() get_current_resource_storage().command_list->SetDescriptorHeaps(1, get_current_resource_storage().descriptors_heap.GetAddressOf()); get_current_resource_storage().command_list->SetGraphicsRootDescriptorTable(0, CD3DX12_GPU_DESCRIPTOR_HANDLE(get_current_resource_storage().descriptors_heap->GetGPUDescriptorHandleForHeapStart()) - .Offset((INT)currentDescriptorIndex, g_descriptor_stride_srv_cbv_uav) + .Offset((INT)currentDescriptorIndex, m_descriptor_stride_srv_cbv_uav) ); get_current_resource_storage().descriptors_heap_index += 3; } std::chrono::time_point texture_duration_end = std::chrono::system_clock::now(); - m_timers.m_texture_duration += std::chrono::duration_cast(texture_duration_end - texture_duration_start).count(); + m_timers.texture_duration += std::chrono::duration_cast(texture_duration_end - texture_duration_start).count(); set_rtt_and_ds(get_current_resource_storage().command_list.Get()); int clip_w = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL] >> 16; @@ -325,8 +325,8 @@ void D3D12GSRender::end() get_current_resource_storage().command_list->DrawInstanced((UINT)vertex_count, 1, 0, 0); std::chrono::time_point end_duration = std::chrono::system_clock::now(); - m_timers.m_draw_calls_duration += std::chrono::duration_cast(end_duration - start_duration).count(); - m_timers.m_draw_calls_count++; + m_timers.draw_calls_duration += std::chrono::duration_cast(end_duration - start_duration).count(); + m_timers.draw_calls_count++; if (rpcs3::config.rsx.d3d12.debug_output.value()) { @@ -442,8 +442,8 @@ void D3D12GSRender::flip(int buffer) (LONG)m_backbuffer[m_swap_chain->GetCurrentBackBufferIndex()]->GetDesc().Height, }; get_current_resource_storage().command_list->RSSetScissorRects(1, &box); - get_current_resource_storage().command_list->SetGraphicsRootSignature(m_output_scaling_pass.m_rootSignature); - get_current_resource_storage().command_list->SetPipelineState(m_output_scaling_pass.m_PSO); + get_current_resource_storage().command_list->SetGraphicsRootSignature(m_output_scaling_pass.root_signature); + get_current_resource_storage().command_list->SetPipelineState(m_output_scaling_pass.pso); D3D12_SHADER_RESOURCE_VIEW_DESC shader_resource_view_desc = {}; // FIXME: Not always true @@ -460,7 +460,7 @@ void D3D12GSRender::flip(int buffer) D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_0 ); m_device->CreateShaderResourceView(resource_to_flip, &shader_resource_view_desc, - CD3DX12_CPU_DESCRIPTOR_HANDLE(m_output_scaling_pass.m_textureDescriptorHeap->GetCPUDescriptorHandleForHeapStart()).Offset(m_swap_chain->GetCurrentBackBufferIndex(), g_descriptor_stride_srv_cbv_uav)); + CD3DX12_CPU_DESCRIPTOR_HANDLE(m_output_scaling_pass.texture_descriptor_heap->GetCPUDescriptorHandleForHeapStart()).Offset(m_swap_chain->GetCurrentBackBufferIndex(), m_descriptor_stride_srv_cbv_uav)); D3D12_SAMPLER_DESC sampler_desc = {}; sampler_desc.Filter = D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT; @@ -468,24 +468,24 @@ void D3D12GSRender::flip(int buffer) sampler_desc.AddressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP; sampler_desc.AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP; m_device->CreateSampler(&sampler_desc, - CD3DX12_CPU_DESCRIPTOR_HANDLE(m_output_scaling_pass.m_samplerDescriptorHeap->GetCPUDescriptorHandleForHeapStart()).Offset(m_swap_chain->GetCurrentBackBufferIndex(), g_descriptor_stride_samplers)); + CD3DX12_CPU_DESCRIPTOR_HANDLE(m_output_scaling_pass.sampler_descriptor_heap->GetCPUDescriptorHandleForHeapStart()).Offset(m_swap_chain->GetCurrentBackBufferIndex(), m_descriptor_stride_samplers)); ID3D12DescriptorHeap *descriptors_heaps[] = { - m_output_scaling_pass.m_textureDescriptorHeap, - m_output_scaling_pass.m_samplerDescriptorHeap + m_output_scaling_pass.texture_descriptor_heap, + m_output_scaling_pass.sampler_descriptor_heap }; get_current_resource_storage().command_list->SetDescriptorHeaps(2, descriptors_heaps); get_current_resource_storage().command_list->SetGraphicsRootDescriptorTable(0, - CD3DX12_GPU_DESCRIPTOR_HANDLE(m_output_scaling_pass.m_textureDescriptorHeap->GetGPUDescriptorHandleForHeapStart()).Offset(m_swap_chain->GetCurrentBackBufferIndex(), g_descriptor_stride_srv_cbv_uav)); + CD3DX12_GPU_DESCRIPTOR_HANDLE(m_output_scaling_pass.texture_descriptor_heap->GetGPUDescriptorHandleForHeapStart()).Offset(m_swap_chain->GetCurrentBackBufferIndex(), m_descriptor_stride_srv_cbv_uav)); get_current_resource_storage().command_list->SetGraphicsRootDescriptorTable(1, - CD3DX12_GPU_DESCRIPTOR_HANDLE(m_output_scaling_pass.m_samplerDescriptorHeap->GetGPUDescriptorHandleForHeapStart()).Offset(m_swap_chain->GetCurrentBackBufferIndex(), g_descriptor_stride_samplers)); + CD3DX12_GPU_DESCRIPTOR_HANDLE(m_output_scaling_pass.sampler_descriptor_heap->GetGPUDescriptorHandleForHeapStart()).Offset(m_swap_chain->GetCurrentBackBufferIndex(), m_descriptor_stride_samplers)); get_current_resource_storage().command_list->OMSetRenderTargets(1, &CD3DX12_CPU_DESCRIPTOR_HANDLE(m_backbuffer_descriptor_heap[m_swap_chain->GetCurrentBackBufferIndex()]->GetCPUDescriptorHandleForHeapStart()), true, nullptr); D3D12_VERTEX_BUFFER_VIEW vertex_buffer_view = {}; - vertex_buffer_view.BufferLocation = m_output_scaling_pass.m_vertexBuffer->GetGPUVirtualAddress(); + vertex_buffer_view.BufferLocation = m_output_scaling_pass.vertex_buffer->GetGPUVirtualAddress(); vertex_buffer_view.StrideInBytes = 4 * sizeof(float); vertex_buffer_view.SizeInBytes = 16 * sizeof(float); get_current_resource_storage().command_list->IASetVertexBuffers(0, 1, &vertex_buffer_view); @@ -540,7 +540,7 @@ void D3D12GSRender::flip(int buffer) std::chrono::time_point flip_end = std::chrono::system_clock::now(); - m_timers.m_flip_duration += std::chrono::duration_cast(flip_end - flip_start).count(); + m_timers.flip_duration += std::chrono::duration_cast(flip_end - flip_start).count(); } bool D3D12GSRender::on_access_violation(u32 address, bool is_writing) @@ -561,15 +561,15 @@ bool D3D12GSRender::on_access_violation(u32 address, bool is_writing) void D3D12GSRender::reset_timer() { - m_timers.m_draw_calls_count = 0; - m_timers.m_draw_calls_duration = 0; - m_timers.m_prepare_rtt_duration = 0; - m_timers.m_vertex_index_duration = 0; - m_timers.m_buffer_upload_size = 0; - m_timers.m_program_load_duration = 0; - m_timers.m_constants_duration = 0; - m_timers.m_texture_duration = 0; - m_timers.m_flip_duration = 0; + m_timers.draw_calls_count = 0; + m_timers.draw_calls_duration = 0; + m_timers.prepare_rtt_duration = 0; + m_timers.vertex_index_duration = 0; + m_timers.buffer_upload_size = 0; + m_timers.program_load_duration = 0; + m_timers.constants_duration = 0; + m_timers.texture_duration = 0; + m_timers.flip_duration = 0; } resource_storage& D3D12GSRender::get_current_resource_storage() diff --git a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h index 0e8a2dc1b7ca..2edd2d9aa95a 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h @@ -64,49 +64,49 @@ class D3D12GSRender : public GSRender rsx::surface_info m_surface; - RSXVertexProgram vertex_program; - RSXFragmentProgram fragment_program; + RSXVertexProgram m_vertex_program; + RSXFragmentProgram m_fragment_program; PipelineStateObjectCache m_pso_cache; std::tuple, std::vector, size_t> m_current_pso; struct { - size_t m_draw_calls_duration; - size_t m_draw_calls_count; - size_t m_prepare_rtt_duration; - size_t m_vertex_index_duration; - size_t m_buffer_upload_size; - size_t m_program_load_duration; - size_t m_constants_duration; - size_t m_texture_duration; - size_t m_flip_duration; + size_t draw_calls_duration; + size_t draw_calls_count; + size_t prepare_rtt_duration; + size_t vertex_index_duration; + size_t buffer_upload_size; + size_t program_load_duration; + size_t constants_duration; + size_t texture_duration; + size_t flip_duration; } m_timers; void reset_timer(); - struct Shader + struct shader { - ID3D12PipelineState *m_PSO; - ID3D12RootSignature *m_rootSignature; - ID3D12Resource *m_vertexBuffer; - ID3D12DescriptorHeap *m_textureDescriptorHeap; - ID3D12DescriptorHeap *m_samplerDescriptorHeap; - void Init(ID3D12Device *device, ID3D12CommandQueue *gfxcommandqueue); - void Release(); + ID3D12PipelineState *pso; + ID3D12RootSignature *root_signature; + ID3D12Resource *vertex_buffer; + ID3D12DescriptorHeap *texture_descriptor_heap; + ID3D12DescriptorHeap *sampler_descriptor_heap; + void init(ID3D12Device *device, ID3D12CommandQueue *gfx_command_queue); + void release(); }; /** * Stores data related to the scaling pass that turns internal * render targets into presented buffers. */ - Shader m_output_scaling_pass; + shader m_output_scaling_pass; /** * Data used when depth buffer is converted to uchar textures. */ - ID3D12PipelineState *m_convertPSO; - ID3D12RootSignature *m_convertRootSignature; - void initConvertShader(); + ID3D12PipelineState *m_convert_pso; + ID3D12RootSignature *m_convert_root_signature; + void init_convert_shader(); resource_storage m_per_frame_storage[2]; resource_storage &get_current_resource_storage(); @@ -118,18 +118,20 @@ class D3D12GSRender : public GSRender rsx::render_targets m_rtts; - std::vector m_IASet; + std::vector m_ia_set; - INT g_descriptor_stride_srv_cbv_uav; - INT g_descriptor_stride_dsv; - INT g_descriptor_stride_rtv; - INT g_descriptor_stride_samplers; + INT m_descriptor_stride_srv_cbv_uav; + INT m_descriptor_stride_dsv; + INT m_descriptor_stride_rtv; + INT m_descriptor_stride_samplers; // Used to fill unused texture slot ID3D12Resource *m_dummy_texture; + public: D3D12GSRender(); virtual ~D3D12GSRender(); + private: void init_d2d_structures(); void release_d2d_structures(); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Overlay.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Overlay.cpp index 701742639261..d82978e04d9a 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Overlay.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Overlay.cpp @@ -152,21 +152,21 @@ void D3D12GSRender::release_d2d_structures() void D3D12GSRender::render_overlay() { D2D1_SIZE_F rtSize = g_d2d_render_targets[m_swap_chain->GetCurrentBackBufferIndex()]->GetSize(); - std::wstring duration = L"Draw duration : " + std::to_wstring(m_timers.m_draw_calls_duration) + L" us"; - float vtxIdxPercent = (float)m_timers.m_vertex_index_duration / (float)m_timers.m_draw_calls_duration; - std::wstring vertexIndexDuration = L"Vtx/Idx upload : " + std::to_wstring(m_timers.m_vertex_index_duration) + L" us (" + std::to_wstring(100.f * vtxIdxPercent) + L" %)"; - std::wstring size = L"Upload size : " + std::to_wstring(m_timers.m_buffer_upload_size) + L" Bytes"; - float texPercent = (float)m_timers.m_texture_duration / (float)m_timers.m_draw_calls_duration; - std::wstring texDuration = L"Textures : " + std::to_wstring(m_timers.m_texture_duration) + L" us (" + std::to_wstring(100.f * texPercent) + L" %)"; - float programPercent = (float)m_timers.m_program_load_duration / (float)m_timers.m_draw_calls_duration; - std::wstring programDuration = L"Program : " + std::to_wstring(m_timers.m_program_load_duration) + L" us (" + std::to_wstring(100.f * programPercent) + L" %)"; - float constantsPercent = (float)m_timers.m_constants_duration / (float)m_timers.m_draw_calls_duration; - std::wstring constantDuration = L"Constants : " + std::to_wstring(m_timers.m_constants_duration) + L" us (" + std::to_wstring(100.f * constantsPercent) + L" %)"; - float rttPercent = (float)m_timers.m_prepare_rtt_duration / (float)m_timers.m_draw_calls_duration; - std::wstring rttDuration = L"RTT : " + std::to_wstring(m_timers.m_prepare_rtt_duration) + L" us (" + std::to_wstring(100.f * rttPercent) + L" %)"; - std::wstring flipDuration = L"Flip : " + std::to_wstring(m_timers.m_flip_duration) + L" us"; - - std::wstring count = L"Draw count : " + std::to_wstring(m_timers.m_draw_calls_count); + std::wstring duration = L"Draw duration : " + std::to_wstring(m_timers.draw_calls_duration) + L" us"; + float vtxIdxPercent = (float)m_timers.vertex_index_duration / (float)m_timers.draw_calls_duration; + std::wstring vertexIndexDuration = L"Vtx/Idx upload : " + std::to_wstring(m_timers.vertex_index_duration) + L" us (" + std::to_wstring(100.f * vtxIdxPercent) + L" %)"; + std::wstring size = L"Upload size : " + std::to_wstring(m_timers.buffer_upload_size) + L" Bytes"; + float texPercent = (float)m_timers.texture_duration / (float)m_timers.draw_calls_duration; + std::wstring texDuration = L"Textures : " + std::to_wstring(m_timers.texture_duration) + L" us (" + std::to_wstring(100.f * texPercent) + L" %)"; + float programPercent = (float)m_timers.program_load_duration / (float)m_timers.draw_calls_duration; + std::wstring programDuration = L"Program : " + std::to_wstring(m_timers.program_load_duration) + L" us (" + std::to_wstring(100.f * programPercent) + L" %)"; + float constantsPercent = (float)m_timers.constants_duration / (float)m_timers.draw_calls_duration; + std::wstring constantDuration = L"Constants : " + std::to_wstring(m_timers.constants_duration) + L" us (" + std::to_wstring(100.f * constantsPercent) + L" %)"; + float rttPercent = (float)m_timers.prepare_rtt_duration / (float)m_timers.draw_calls_duration; + std::wstring rttDuration = L"RTT : " + std::to_wstring(m_timers.prepare_rtt_duration) + L" us (" + std::to_wstring(100.f * rttPercent) + L" %)"; + std::wstring flipDuration = L"Flip : " + std::to_wstring(m_timers.flip_duration) + L" us"; + + std::wstring count = L"Draw count : " + std::to_wstring(m_timers.draw_calls_count); draw_strings(rtSize, m_swap_chain->GetCurrentBackBufferIndex(), { duration, diff --git a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp index a756db8ca44f..c536e93df07c 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp @@ -39,12 +39,12 @@ void Shader::Compile(const std::string &code, SHADER_TYPE st) void D3D12GSRender::load_program() { u32 transform_program_start = rsx::method_registers[NV4097_SET_TRANSFORM_PROGRAM_START]; - vertex_program.data.reserve((512 - transform_program_start) * 4); + m_vertex_program.data.reserve((512 - transform_program_start) * 4); for (int i = transform_program_start; i < 512; ++i) { - vertex_program.data.resize((i - transform_program_start) * 4 + 4); - memcpy(vertex_program.data.data() + (i - transform_program_start) * 4, transform_program + i * 4, 4 * sizeof(u32)); + m_vertex_program.data.resize((i - transform_program_start) * 4 + 4); + memcpy(m_vertex_program.data.data() + (i - transform_program_start) * 4, transform_program + i * 4, 4 * sizeof(u32)); D3 d3; d3.HEX = transform_program[i * 4 + 3]; @@ -54,19 +54,19 @@ void D3D12GSRender::load_program() } u32 shader_program = rsx::method_registers[NV4097_SET_SHADER_PROGRAM]; - fragment_program.offset = shader_program & ~0x3; - fragment_program.addr = rsx::get_address(fragment_program.offset, (shader_program & 0x3) - 1); - fragment_program.ctrl = rsx::method_registers[NV4097_SET_SHADER_CONTROL]; - fragment_program.texture_dimensions.clear(); + m_fragment_program.offset = shader_program & ~0x3; + m_fragment_program.addr = rsx::get_address(m_fragment_program.offset, (shader_program & 0x3) - 1); + m_fragment_program.ctrl = rsx::method_registers[NV4097_SET_SHADER_CONTROL]; + m_fragment_program.texture_dimensions.clear(); for (u32 i = 0; i < rsx::limits::textures_count; ++i) { if (!textures[i].enabled()) - fragment_program.texture_dimensions.push_back(texture_dimension::texture_dimension_2d); + m_fragment_program.texture_dimensions.push_back(texture_dimension::texture_dimension_2d); else if (textures[i].cubemap()) - fragment_program.texture_dimensions.push_back(texture_dimension::texture_dimension_cubemap); + m_fragment_program.texture_dimensions.push_back(texture_dimension::texture_dimension_cubemap); else - fragment_program.texture_dimensions.push_back(texture_dimension::texture_dimension_2d); + m_fragment_program.texture_dimensions.push_back(texture_dimension::texture_dimension_2d); } D3D12PipelineProperties prop = {}; @@ -251,7 +251,7 @@ void D3D12GSRender::load_program() for (unsigned i = 0; i < prop.numMRT; i++) prop.Blend.RenderTarget[i].RenderTargetWriteMask = mask; - prop.IASet = m_IASet; + prop.IASet = m_ia_set; 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); @@ -265,12 +265,12 @@ void D3D12GSRender::load_program() } } - m_current_pso = m_pso_cache.getGraphicPipelineState(vertex_program, fragment_program, prop, m_device.Get(), m_root_signatures); + m_current_pso = m_pso_cache.getGraphicPipelineState(m_vertex_program, m_fragment_program, prop, m_device.Get(), m_root_signatures); return; } std::pair D3D12GSRender::get_programs() const { - return std::make_pair(m_pso_cache.get_transform_program(vertex_program).content, m_pso_cache.get_shader_program(fragment_program).content); + return std::make_pair(m_pso_cache.get_transform_program(m_vertex_program).content, m_pso_cache.get_shader_program(m_fragment_program).content); } #endif diff --git a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp index 0616339f4fe5..3d3aafd529f6 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp @@ -126,7 +126,7 @@ void D3D12GSRender::clear_surface(u32 arg) prepare_render_targets(get_current_resource_storage().command_list.Get()); std::chrono::time_point rtt_duration_end = std::chrono::system_clock::now(); - m_timers.m_prepare_rtt_duration += std::chrono::duration_cast(rtt_duration_end - rtt_duration_start).count(); + m_timers.prepare_rtt_duration += std::chrono::duration_cast(rtt_duration_end - rtt_duration_start).count(); if (arg & 0x1 || arg & 0x2) { @@ -151,13 +151,13 @@ void D3D12GSRender::clear_surface(u32 arg) size_t rtt_index = get_num_rtt(to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])); get_current_resource_storage().render_targets_descriptors_heap_index += rtt_index; for (unsigned i = 0; i < rtt_index; i++) - get_current_resource_storage().command_list->ClearRenderTargetView(handle.Offset(i, g_descriptor_stride_rtv), get_clear_color(rsx::method_registers[NV4097_SET_COLOR_CLEAR_VALUE]).data(), + get_current_resource_storage().command_list->ClearRenderTargetView(handle.Offset(i, m_descriptor_stride_rtv), get_clear_color(rsx::method_registers[NV4097_SET_COLOR_CLEAR_VALUE]).data(), 1, &get_scissor(rsx::method_registers[NV4097_SET_SCISSOR_HORIZONTAL], rsx::method_registers[NV4097_SET_SCISSOR_VERTICAL])); } std::chrono::time_point end_duration = std::chrono::system_clock::now(); - m_timers.m_draw_calls_duration += std::chrono::duration_cast(end_duration - start_duration).count(); - m_timers.m_draw_calls_count++; + m_timers.draw_calls_duration += std::chrono::duration_cast(end_duration - start_duration).count(); + m_timers.draw_calls_count++; if (rpcs3::config.rsx.d3d12.debug_output.value()) { @@ -196,14 +196,14 @@ void D3D12GSRender::prepare_render_targets(ID3D12GraphicsCommandList *copycmdlis rtt_view_desc.Format = dxgi_format; m_rtts.current_rtts_handle = CD3DX12_CPU_DESCRIPTOR_HANDLE(get_current_resource_storage().render_targets_descriptors_heap->GetCPUDescriptorHandleForHeapStart()) - .Offset((INT)get_current_resource_storage().render_targets_descriptors_heap_index * g_descriptor_stride_rtv); + .Offset((INT)get_current_resource_storage().render_targets_descriptors_heap_index * m_descriptor_stride_rtv); size_t rtt_index = 0; for (u8 i : get_rtt_indexes(to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]))) { if (std::get<1>(m_rtts.m_bound_render_targets[i]) == nullptr) continue; m_device->CreateRenderTargetView(std::get<1>(m_rtts.m_bound_render_targets[i]), &rtt_view_desc, - CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.current_rtts_handle).Offset((INT)rtt_index * g_descriptor_stride_rtv)); + CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.current_rtts_handle).Offset((INT)rtt_index * m_descriptor_stride_rtv)); rtt_index++; } get_current_resource_storage().render_targets_descriptors_heap_index += rtt_index; @@ -211,7 +211,7 @@ void D3D12GSRender::prepare_render_targets(ID3D12GraphicsCommandList *copycmdlis if (std::get<1>(m_rtts.m_bound_depth_stencil) == nullptr) return; m_rtts.current_ds_handle = CD3DX12_CPU_DESCRIPTOR_HANDLE(get_current_resource_storage().depth_stencil_descriptor_heap->GetCPUDescriptorHandleForHeapStart()) - .Offset((INT)get_current_resource_storage().depth_stencil_descriptor_heap_index * g_descriptor_stride_dsv); + .Offset((INT)get_current_resource_storage().depth_stencil_descriptor_heap_index * m_descriptor_stride_dsv); get_current_resource_storage().depth_stencil_descriptor_heap_index += 1; D3D12_DEPTH_STENCIL_VIEW_DESC depth_stencil_view_desc = {}; depth_stencil_view_desc.Format = get_depth_stencil_surface_format(m_surface.depth_format); @@ -362,13 +362,13 @@ void D3D12GSRender::copy_render_target_to_dma_location() uav_desc.Format = DXGI_FORMAT_R8_UNORM; uav_desc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D; m_device->CreateUnorderedAccessView(depth_format_conversion_buffer.Get(), nullptr, &uav_desc, - CD3DX12_CPU_DESCRIPTOR_HANDLE(descriptor_heap->GetCPUDescriptorHandleForHeapStart()).Offset(1, g_descriptor_stride_srv_cbv_uav)); + CD3DX12_CPU_DESCRIPTOR_HANDLE(descriptor_heap->GetCPUDescriptorHandleForHeapStart()).Offset(1, m_descriptor_stride_srv_cbv_uav)); // Convert get_current_resource_storage().command_list->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(std::get<1>(m_rtts.m_bound_depth_stencil), D3D12_RESOURCE_STATE_DEPTH_WRITE, D3D12_RESOURCE_STATE_GENERIC_READ)); - get_current_resource_storage().command_list->SetPipelineState(m_convertPSO); - get_current_resource_storage().command_list->SetComputeRootSignature(m_convertRootSignature); + get_current_resource_storage().command_list->SetPipelineState(m_convert_pso); + get_current_resource_storage().command_list->SetComputeRootSignature(m_convert_root_signature); get_current_resource_storage().command_list->SetDescriptorHeaps(1, descriptor_heap.GetAddressOf()); get_current_resource_storage().command_list->SetComputeRootDescriptorTable(0, descriptor_heap->GetGPUDescriptorHandleForHeapStart()); get_current_resource_storage().command_list->Dispatch(clip_w / 8, clip_h / 8, 1); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp index e34780cd2389..59a96749503d 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp @@ -143,7 +143,7 @@ void D3D12GSRender::upload_and_bind_textures(ID3D12GraphicsCommandList *command_ D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_0); m_device->CreateShaderResourceView(m_dummy_texture, &shader_resource_view_desc, CD3DX12_CPU_DESCRIPTOR_HANDLE(get_current_resource_storage().descriptors_heap->GetCPUDescriptorHandleForHeapStart()) - .Offset((INT)descriptor_index + (INT)used_texture, g_descriptor_stride_srv_cbv_uav) + .Offset((INT)descriptor_index + (INT)used_texture, m_descriptor_stride_srv_cbv_uav) ); D3D12_SAMPLER_DESC sampler_desc = {}; @@ -153,7 +153,7 @@ void D3D12GSRender::upload_and_bind_textures(ID3D12GraphicsCommandList *command_ sampler_desc.AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP; m_device->CreateSampler(&sampler_desc, CD3DX12_CPU_DESCRIPTOR_HANDLE(get_current_resource_storage().sampler_descriptor_heap[get_current_resource_storage().sampler_descriptors_heap_index]->GetCPUDescriptorHandleForHeapStart()) - .Offset((INT)get_current_resource_storage().current_sampler_index + (INT)used_texture, g_descriptor_stride_samplers) + .Offset((INT)get_current_resource_storage().current_sampler_index + (INT)used_texture, m_descriptor_stride_samplers) ); used_texture++; continue; @@ -320,7 +320,7 @@ void D3D12GSRender::upload_and_bind_textures(ID3D12GraphicsCommandList *command_ m_device->CreateShaderResourceView(vram_texture, &shared_resource_view_desc, CD3DX12_CPU_DESCRIPTOR_HANDLE(get_current_resource_storage().descriptors_heap->GetCPUDescriptorHandleForHeapStart()) - .Offset((UINT)descriptor_index + (UINT)used_texture, g_descriptor_stride_srv_cbv_uav)); + .Offset((UINT)descriptor_index + (UINT)used_texture, m_descriptor_stride_srv_cbv_uav)); if (get_current_resource_storage().current_sampler_index + 16 > 2048) { @@ -336,7 +336,7 @@ void D3D12GSRender::upload_and_bind_textures(ID3D12GraphicsCommandList *command_ } m_device->CreateSampler(&get_sampler_desc(textures[i]), CD3DX12_CPU_DESCRIPTOR_HANDLE(get_current_resource_storage().sampler_descriptor_heap[get_current_resource_storage().sampler_descriptors_heap_index]->GetCPUDescriptorHandleForHeapStart()) - .Offset((UINT)get_current_resource_storage().current_sampler_index + (UINT)used_texture, g_descriptor_stride_samplers)); + .Offset((UINT)get_current_resource_storage().current_sampler_index + (UINT)used_texture, m_descriptor_stride_samplers)); used_texture++; } diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Utils.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Utils.cpp index 6401525c0cc3..bc506139ecdd 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Utils.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Utils.cpp @@ -47,7 +47,7 @@ std::pair compileF32toU8CS() } -void D3D12GSRender::Shader::Init(ID3D12Device *device, ID3D12CommandQueue *gfxcommandqueue) +void D3D12GSRender::shader::init(ID3D12Device *device, ID3D12CommandQueue *gfx_command_queue) { const char *fsCode = STRINGIFY( Texture2D InputTexture : register(t0); \n @@ -143,21 +143,21 @@ void D3D12GSRender::Shader::Init(ID3D12Device *device, ID3D12CommandQueue *gfxco Microsoft::WRL::ComPtr rootSignatureBlob; CHECK_HRESULT(wrapD3D12SerializeRootSignature(&rootSignatureDesc, D3D_ROOT_SIGNATURE_VERSION_1, &rootSignatureBlob, &errorBlob)); - CHECK_HRESULT(device->CreateRootSignature(0, rootSignatureBlob->GetBufferPointer(), rootSignatureBlob->GetBufferSize(), IID_PPV_ARGS(&m_rootSignature))); + CHECK_HRESULT(device->CreateRootSignature(0, rootSignatureBlob->GetBufferPointer(), rootSignatureBlob->GetBufferSize(), IID_PPV_ARGS(&root_signature))); - psoDesc.pRootSignature = m_rootSignature; + psoDesc.pRootSignature = root_signature; psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; psoDesc.BlendState.RenderTarget[0].RenderTargetWriteMask = D3D12_COLOR_WRITE_ENABLE_ALL; - CHECK_HRESULT(device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&m_PSO))); + CHECK_HRESULT(device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&pso))); D3D12_DESCRIPTOR_HEAP_DESC textureHeapDesc = { D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV , 2, D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE }; CHECK_HRESULT( - device->CreateDescriptorHeap(&textureHeapDesc, IID_PPV_ARGS(&m_textureDescriptorHeap)) + device->CreateDescriptorHeap(&textureHeapDesc, IID_PPV_ARGS(&texture_descriptor_heap)) ); D3D12_DESCRIPTOR_HEAP_DESC samplerHeapDesc = { D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER , 2, D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE }; CHECK_HRESULT( - device->CreateDescriptorHeap(&samplerHeapDesc, IID_PPV_ARGS(&m_samplerDescriptorHeap)) + device->CreateDescriptorHeap(&samplerHeapDesc, IID_PPV_ARGS(&sampler_descriptor_heap)) ); ComPtr fence; @@ -197,37 +197,37 @@ void D3D12GSRender::Shader::Init(ID3D12Device *device, ID3D12CommandQueue *gfxco &CD3DX12_RESOURCE_DESC::Buffer(16 * sizeof(float)), D3D12_RESOURCE_STATE_COPY_DEST, nullptr, - IID_PPV_ARGS(&m_vertexBuffer) + IID_PPV_ARGS(&vertex_buffer) )); D3D12_SUBRESOURCE_DATA vertexData = { reinterpret_cast(quadVertex), 16 * sizeof(float), 1 }; - UpdateSubresources(cmdList.Get(), m_vertexBuffer, intermediateBuffer.Get(), 0, 0, 1, &vertexData); - cmdList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_vertexBuffer, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER)); + UpdateSubresources(cmdList.Get(), vertex_buffer, intermediateBuffer.Get(), 0, 0, 1, &vertexData); + cmdList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(vertex_buffer, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER)); CHECK_HRESULT(cmdList->Close()); - gfxcommandqueue->ExecuteCommandLists(1, CommandListCast(cmdList.GetAddressOf())); + gfx_command_queue->ExecuteCommandLists(1, CommandListCast(cmdList.GetAddressOf())); // Now wait until upload has completed - gfxcommandqueue->Signal(fence.Get(), 1); + gfx_command_queue->Signal(fence.Get(), 1); WaitForSingleObjectEx(handle, INFINITE, FALSE); CloseHandle(handle); } -void D3D12GSRender::initConvertShader() +void D3D12GSRender::init_convert_shader() { const auto &p = compileF32toU8CS(); CHECK_HRESULT( - m_device->CreateRootSignature(0, p.second->GetBufferPointer(), p.second->GetBufferSize(), IID_PPV_ARGS(&m_convertRootSignature)) + m_device->CreateRootSignature(0, p.second->GetBufferPointer(), p.second->GetBufferSize(), IID_PPV_ARGS(&m_convert_root_signature)) ); D3D12_COMPUTE_PIPELINE_STATE_DESC computePipelineStateDesc = {}; computePipelineStateDesc.CS.BytecodeLength = p.first->GetBufferSize(); computePipelineStateDesc.CS.pShaderBytecode = p.first->GetBufferPointer(); - computePipelineStateDesc.pRootSignature = m_convertRootSignature; + computePipelineStateDesc.pRootSignature = m_convert_root_signature; CHECK_HRESULT( - m_device->CreateComputePipelineState(&computePipelineStateDesc, IID_PPV_ARGS(&m_convertPSO)) + m_device->CreateComputePipelineState(&computePipelineStateDesc, IID_PPV_ARGS(&m_convert_pso)) ); p.first->Release(); From 2e58f312d57865e603290fef6b0b99f5c9c9366c Mon Sep 17 00:00:00 2001 From: DHrpcs3 Date: Wed, 20 Jan 2016 17:12:49 +0300 Subject: [PATCH 4/5] rsx: implemented internal tasks queue (WIP) --- rpcs3/Emu/RSX/RSXThread.cpp | 48 ++++++++++++++++++++++++++++++++++++- rpcs3/Emu/RSX/RSXThread.h | 20 ++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 72678840701d..bdcd893639af 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -366,7 +366,7 @@ namespace rsx if (put == get || !Emu.IsRunning()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack + do_internal_task(); continue; } @@ -519,6 +519,52 @@ namespace rsx return get_system_time() * 1000; } + void thread::do_internal_task() + { + if (m_internal_tasks.empty()) + { + std::this_thread::sleep_for(1ms); + } + else + { + std::lock_guard lock{ m_mtx_task }; + + internal_task_entry &front = m_internal_tasks.front(); + + if (front.callback()) + { + front.promise.set_value(); + m_internal_tasks.pop_front(); + } + } + } + + std::future thread::add_internal_task(std::function callback) + { + std::lock_guard lock{ m_mtx_task }; + m_internal_tasks.emplace_back(callback); + + return m_internal_tasks.back().promise.get_future(); + } + + void thread::invoke(std::function callback) + { + if (get_thread_ctrl() == thread_ctrl::get_current()) + { + while (true) + { + if (callback()) + { + break; + } + } + } + else + { + add_internal_task(callback).wait(); + } + } + std::array thread::get_color_surface_addresses() const { u32 offset_color[] = diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index ec508ef42ef2..48304cefd27a 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -329,6 +329,26 @@ namespace rsx virtual u64 timestamp() const; virtual bool on_access_violation(u32 address, bool is_writing) { return false; } + private: + std::mutex m_mtx_task; + + struct internal_task_entry + { + std::function callback; + std::promise promise; + + internal_task_entry(std::function callback) : callback(callback) + { + } + }; + + std::deque m_internal_tasks; + void do_internal_task(); + + public: + std::future add_internal_task(std::function callback); + void invoke(std::function callback); + /** * Fill buffer with 4x4 scale offset matrix. * Vertex shader's position is to be multiplied by this matrix. From 19ce0cdc0922bc48fd887a79d2644e65e72291cf Mon Sep 17 00:00:00 2001 From: DHrpcs3 Date: Wed, 20 Jan 2016 20:12:48 +0300 Subject: [PATCH 5/5] rsx methods constants moved to rsx namespace minor fix --- rpcs3/Emu/RSX/Common/BufferUtils.cpp | 104 ++++----- rpcs3/Emu/RSX/Common/BufferUtils.h | 12 +- rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp | 6 +- rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp | 116 +++++----- rpcs3/Emu/RSX/D3D12/D3D12Formats.h | 18 +- rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp | 20 +- rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp | 18 +- rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp | 108 ++++----- rpcs3/Emu/RSX/GCM.cpp | 212 +++++++++--------- rpcs3/Emu/RSX/GCM.h | 157 ++++++------- rpcs3/Emu/RSX/GL/GLGSRender.cpp | 148 ++++++------ rpcs3/Emu/RSX/GL/gl_helpers.cpp | 48 ++-- rpcs3/Emu/RSX/GL/gl_helpers.h | 30 +-- rpcs3/Emu/RSX/RSXThread.h | 5 +- rpcs3/Emu/SysCalls/Modules/cellResc.cpp | 14 +- rpcs3/Gui/RSXDebugger.cpp | 34 +-- 16 files changed, 526 insertions(+), 524 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.cpp b/rpcs3/Emu/RSX/Common/BufferUtils.cpp index 9d5789ae81a8..97c93000bd99 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 rsx::vertex_base_type::ub: memcpy(dst, src, vertex_array_desc.size); break; - case vertex_base_type::s1: - case vertex_base_type::sf: + case rsx::vertex_base_type::s1: + case rsx::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 rsx::vertex_base_type::f: + case rsx::vertex_base_type::s32k: + case rsx::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 rsx::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 draw_mode) +bool is_primitive_native(rsx::primitive_type 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 rsx::primitive_type::points: + case rsx::primitive_type::lines: + case rsx::primitive_type::line_loop: + case rsx::primitive_type::line_strip: + case rsx::primitive_type::triangles: + case rsx::primitive_type::triangle_strip: + case rsx::primitive_type::quad_strip: return true; - case primitive_type::polygon: - case primitive_type::triangle_fan: - case primitive_type::quads: + case rsx::primitive_type::polygon: + case rsx::primitive_type::triangle_fan: + case rsx::primitive_type::quads: return false; } throw new EXCEPTION("Wrong primitive type"); @@ -269,7 +269,7 @@ bool is_primitive_native(primitive_type draw_mode) * see http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/polygon-triangulation-r3334 */ -size_t get_index_count(primitive_type draw_mode, unsigned initial_index_count) +size_t get_index_count(rsx::primitive_type draw_mode, unsigned initial_index_count) { // Index count if (is_primitive_native(draw_mode)) @@ -277,33 +277,33 @@ size_t get_index_count(primitive_type draw_mode, unsigned initial_index_count) switch (draw_mode) { - case primitive_type::polygon: - case primitive_type::triangle_fan: + case rsx::primitive_type::polygon: + case rsx::primitive_type::triangle_fan: return (initial_index_count - 2) * 3; - case primitive_type::quads: + case rsx::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(rsx::index_array_type type) { switch (type) { - case index_array_type::unsigned_16b: return 2; - case index_array_type::unsigned_32b: return 4; + case rsx::index_array_type::u16: return sizeof(u16); + case rsx::index_array_type::u32: return sizeof(u32); } 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, rsx::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 rsx::primitive_type::triangle_fan: + case rsx::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 rsx::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 rsx::primitive_type::points: + case rsx::primitive_type::lines: + case rsx::primitive_type::line_loop: + case rsx::primitive_type::line_strip: + case rsx::primitive_type::triangles: + case rsx::primitive_type::triangle_strip: + case rsx::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 draw_mode, const std::vector > &first_count_arguments) +std::tuple write_index_array_data_to_buffer_impl(gsl::span dst, rsx::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); + rsx::index_array_type type = rsx::to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); u32 type_size = gsl::narrow(get_index_type_size(type)); @@ -364,30 +364,30 @@ std::tuple write_index_array_data_to_buffer_impl(gsl::span({ ptr, count }, dst, is_primitive_restart_enabled, primitive_restart_index); - case primitive_type::polygon: - case primitive_type::triangle_fan: + case rsx::primitive_type::polygon: + case rsx::primitive_type::triangle_fan: return expand_indexed_triangle_fan({ ptr, count }, dst, is_primitive_restart_enabled, primitive_restart_index); - case primitive_type::quads: + case rsx::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 draw_mode, const std::vector > &first_count_arguments) +std::tuple write_index_array_data_to_buffer(gsl::span dst, rsx::primitive_type draw_mode, const std::vector > &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 draw_mode, const std::vector > &first_count_arguments) +std::tuple write_index_array_data_to_buffer(gsl::span dst, rsx::primitive_type draw_mode, const std::vector > &first_count_arguments) { return write_index_array_data_to_buffer_impl(dst, draw_mode, first_count_arguments); } @@ -395,7 +395,7 @@ std::tuple write_index_array_data_to_buffer(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); + rsx::index_array_type type = rsx::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); + rsx::index_array_type type = rsx::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 cdd14df374a7..bfe1be21b76d 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(rsx::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(rsx::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(rsx::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 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, rsx::primitive_type draw_mode, const std::vector > &first_count_arguments); +std::tuple write_index_array_data_to_buffer(gsl::span dst, rsx::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 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); + rsx::index_array_type indexed_type = rsx::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 == rsx::index_array_type::u16) { 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 == rsx::index_array_type::u32) { 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 761cc2888426..7e0b392858c7 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(rsx::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 rsx::primitive_type::points: return D3D_PRIMITIVE_TOPOLOGY_POINTLIST; + case rsx::primitive_type::lines: return D3D_PRIMITIVE_TOPOLOGY_LINELIST; + case rsx::primitive_type::line_loop: return D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ; + case rsx::primitive_type::line_strip: return D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; + case rsx::primitive_type::triangles: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; + case rsx::primitive_type::triangle_strip: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; + case rsx::primitive_type::triangle_fan: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; + case rsx::primitive_type::quads: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; + case rsx::primitive_type::quad_strip: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; + case rsx::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(rsx::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 rsx::primitive_type::points: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT; + case rsx::primitive_type::lines: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE; + case rsx::primitive_type::line_strip: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE; + case rsx::primitive_type::triangles: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; + case rsx::primitive_type::triangle_strip: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; + case rsx::primitive_type::triangle_fan: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; + case rsx::primitive_type::quads: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; + case rsx::primitive_type::quad_strip: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; + case rsx::primitive_type::polygon: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; + case rsx::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(rsx::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 rsx::surface_color_format::r5g6b5: return DXGI_FORMAT_B5G6R5_UNORM; + case rsx::surface_color_format::x8r8g8b8_o8r8g8b8: + case rsx::surface_color_format::x8r8g8b8_z8r8g8b8: + case rsx::surface_color_format::x8b8g8r8_o8b8g8r8: + case rsx::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 rsx::surface_color_format::a8b8g8r8: + case rsx::surface_color_format::a8r8g8b8: return DXGI_FORMAT_R8G8B8A8_UNORM; + case rsx::surface_color_format::b8: return DXGI_FORMAT_R8_UNORM; + case rsx::surface_color_format::g8b8: return DXGI_FORMAT_R8G8_UNORM; + case rsx::surface_color_format::w16z16y16x16: return DXGI_FORMAT_R16G16B16A16_FLOAT; + case rsx::surface_color_format::w32z32y32x32: return DXGI_FORMAT_R32G32B32A32_FLOAT; + case rsx::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(rsx::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 rsx::surface_depth_format::z16: return DXGI_FORMAT_D16_UNORM; + case rsx::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(rsx::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 rsx::surface_depth_format::z16: return DXGI_FORMAT_D16_UNORM; + case rsx::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(rsx::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 rsx::surface_depth_format::z16: return DXGI_FORMAT_R16_TYPELESS; + case rsx::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(rsx::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 rsx::surface_depth_format::z16: return DXGI_FORMAT_R16_UNORM; + case rsx::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(rsx::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 rsx::index_array_type::u16: return DXGI_FORMAT_R16_UINT; + case rsx::index_array_type::u32: 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(rsx::vertex_base_type type, u8 size) { switch (type) { - case vertex_base_type::s1: + case rsx::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 rsx::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 rsx::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 rsx::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 rsx::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 rsx::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 rsx::vertex_base_type::ub256: { switch (size) { diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Formats.h b/rpcs3/Emu/RSX/D3D12/D3D12Formats.h index 60875b5f2c35..a5cc001acce6 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(rsx::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(rsx::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(rsx::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(rsx::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(rsx::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(rsx::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(rsx::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(rsx::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(rsx::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 5de07cbf379a..6724b57c4825 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(rsx::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 rsx::surface_target::surface_a: + case rsx::surface_target::surface_b: + case rsx::surface_target::surfaces_a_b: + case rsx::surface_target::surfaces_a_b_c: + case rsx::surface_target::surfaces_a_b_c_d: return true; - case surface_target::none: + case rsx::surface_target::none: return false; } throw EXCEPTION("Wrong color_target"); @@ -361,7 +361,7 @@ void D3D12GSRender::flip(int buffer) ID3D12Resource *resource_to_flip; float viewport_w, viewport_h; - if (!is_flip_surface_in_global_memory(to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]))) + if (!is_flip_surface_in_global_memory(rsx::to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]))) { resource_storage &storage = get_current_resource_storage(); assert(storage.ram_framebuffer == nullptr); @@ -450,7 +450,7 @@ void D3D12GSRender::flip(int buffer) shader_resource_view_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; shader_resource_view_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; shader_resource_view_desc.Texture2D.MipLevels = 1; - if (is_flip_surface_in_global_memory(to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]))) + if (is_flip_surface_in_global_memory(rsx::to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]))) shader_resource_view_desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; else shader_resource_view_desc.Shader4ComponentMapping = D3D12_ENCODE_SHADER_4_COMPONENT_MAPPING( @@ -495,7 +495,7 @@ void D3D12GSRender::flip(int buffer) if (!rpcs3::config.rsx.d3d12.overlay.value()) get_current_resource_storage().command_list->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_backbuffer[m_swap_chain->GetCurrentBackBufferIndex()].Get(), D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT)); - if (is_flip_surface_in_global_memory(to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])) && resource_to_flip != nullptr) + if (is_flip_surface_in_global_memory(rsx::to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])) && resource_to_flip != nullptr) get_current_resource_storage().command_list->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(resource_to_flip, D3D12_RESOURCE_STATE_GENERIC_READ, D3D12_RESOURCE_STATE_RENDER_TARGET)); CHECK_HRESULT(get_current_resource_storage().command_list->Close()); m_command_queue->ExecuteCommandLists(1, (ID3D12CommandList**)get_current_resource_storage().command_list.GetAddressOf()); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp index c536e93df07c..ba79339463e3 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp @@ -162,19 +162,19 @@ void D3D12GSRender::load_program() prop.DepthStencilFormat = get_depth_stencil_surface_format(m_surface.depth_format); prop.RenderTargetsFormat = get_color_surface_format(m_surface.color_format); - switch (to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])) + switch (rsx::to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])) { - case surface_target::surface_a: - case surface_target::surface_b: + case rsx::surface_target::surface_a: + case rsx::surface_target::surface_b: prop.numMRT = 1; break; - case surface_target::surfaces_a_b: + case rsx::surface_target::surfaces_a_b: prop.numMRT = 2; break; - case surface_target::surfaces_a_b_c: + case rsx::surface_target::surfaces_a_b_c: prop.numMRT = 3; break; - case surface_target::surfaces_a_b_c_d: + case rsx::surface_target::surfaces_a_b_c_d: prop.numMRT = 4; break; default: @@ -254,12 +254,12 @@ void D3D12GSRender::load_program() prop.IASet = m_ia_set; 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) + rsx::index_array_type index_type = rsx::to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); + if (index_type == rsx::index_array_type::u32) { prop.CutValue = D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFFFFFF; } - if (index_type == index_array_type::unsigned_16b) + if (index_type == rsx::index_array_type::u16) { 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 3d3aafd529f6..8f1fd989a306 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(rsx::surface_depth_format format) { switch (format) { - case surface_depth_format::z16: return 0xFFFF; - case surface_depth_format::z24s8: return 0xFFFFFF; + case rsx::surface_depth_format::z16: return 0xFFFF; + case rsx::surface_depth_format::z24s8: return 0xFFFFFF; } throw EXCEPTION("Unknow depth format"); } - UINT get_num_rtt(surface_target color_target) + UINT get_num_rtt(rsx::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 rsx::surface_target::none: return 0; + case rsx::surface_target::surface_a: + case rsx::surface_target::surface_b: return 1; + case rsx::surface_target::surfaces_a_b: return 2; + case rsx::surface_target::surfaces_a_b_c: return 3; + case rsx::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(rsx::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 rsx::surface_target::none: return{}; + case rsx::surface_target::surface_a: return{ 0 }; + case rsx::surface_target::surface_b: return{ 1 }; + case rsx::surface_target::surfaces_a_b: return{ 0, 1 }; + case rsx::surface_target::surfaces_a_b_c: return{ 0, 1, 2 }; + case rsx::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(rsx::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 rsx::surface_color_format::b8: return align(width, 256); + case rsx::surface_color_format::g8b8: + case rsx::surface_color_format::x1r5g5b5_o1r5g5b5: + case rsx::surface_color_format::x1r5g5b5_z1r5g5b5: + case rsx::surface_color_format::r5g6b5: return align(width * 2, 256); + case rsx::surface_color_format::a8b8g8r8: + case rsx::surface_color_format::x8b8g8r8_o8b8g8r8: + case rsx::surface_color_format::x8b8g8r8_z8b8g8r8: + case rsx::surface_color_format::x8r8g8b8_o8r8g8b8: + case rsx::surface_color_format::x8r8g8b8_z8r8g8b8: + case rsx::surface_color_format::x32: + case rsx::surface_color_format::a8r8g8b8: return align(width * 4, 256); + case rsx::surface_color_format::w16z16y16x16: return align(width * 8, 256); + case rsx::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(rsx::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 rsx::surface_color_format::b8: return width; + case rsx::surface_color_format::g8b8: + case rsx::surface_color_format::x1r5g5b5_o1r5g5b5: + case rsx::surface_color_format::x1r5g5b5_z1r5g5b5: + case rsx::surface_color_format::r5g6b5: return width * 2; + case rsx::surface_color_format::a8b8g8r8: + case rsx::surface_color_format::x8b8g8r8_o8b8g8r8: + case rsx::surface_color_format::x8b8g8r8_z8b8g8r8: + case rsx::surface_color_format::x8r8g8b8_o8r8g8b8: + case rsx::surface_color_format::x8r8g8b8_z8r8g8b8: + case rsx::surface_color_format::x32: + case rsx::surface_color_format::a8r8g8b8: return width * 4; + case rsx::surface_color_format::w16z16y16x16: return width * 8; + case rsx::surface_color_format::w32z32y32x32: return width * 16; } throw EXCEPTION("Unknow color surface format"); } @@ -148,7 +148,7 @@ void D3D12GSRender::clear_surface(u32 arg) if (arg & 0xF0) { CD3DX12_CPU_DESCRIPTOR_HANDLE handle = CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.current_rtts_handle); - size_t rtt_index = get_num_rtt(to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])); + size_t rtt_index = get_num_rtt(rsx::to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])); get_current_resource_storage().render_targets_descriptors_heap_index += rtt_index; for (unsigned i = 0; i < rtt_index; i++) get_current_resource_storage().command_list->ClearRenderTargetView(handle.Offset(i, m_descriptor_stride_rtv), get_clear_color(rsx::method_registers[NV4097_SET_COLOR_CLEAR_VALUE]).data(), @@ -185,7 +185,7 @@ void D3D12GSRender::prepare_render_targets(ID3D12GraphicsCommandList *copycmdlis m_rtts.prepare_render_target(copycmdlist, rsx::method_registers[NV4097_SET_SURFACE_FORMAT], rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL], rsx::method_registers[NV4097_SET_SURFACE_CLIP_VERTICAL], - to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]), + rsx::to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]), get_color_surface_addresses(), get_zeta_surface_address(), m_device.Get(), clear_color, 1.f, 0); @@ -198,7 +198,7 @@ void D3D12GSRender::prepare_render_targets(ID3D12GraphicsCommandList *copycmdlis m_rtts.current_rtts_handle = CD3DX12_CPU_DESCRIPTOR_HANDLE(get_current_resource_storage().render_targets_descriptors_heap->GetCPUDescriptorHandleForHeapStart()) .Offset((INT)get_current_resource_storage().render_targets_descriptors_heap_index * m_descriptor_stride_rtv); size_t rtt_index = 0; - for (u8 i : get_rtt_indexes(to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]))) + for (u8 i : get_rtt_indexes(rsx::to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]))) { if (std::get<1>(m_rtts.m_bound_render_targets[i]) == nullptr) continue; @@ -221,7 +221,7 @@ void D3D12GSRender::prepare_render_targets(ID3D12GraphicsCommandList *copycmdlis void D3D12GSRender::set_rtt_and_ds(ID3D12GraphicsCommandList *command_list) { - UINT num_rtt = get_num_rtt(to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])); + UINT num_rtt = get_num_rtt(rsx::to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])); D3D12_CPU_DESCRIPTOR_HANDLE* ds_handle = (std::get<1>(m_rtts.m_bound_depth_stencil) != nullptr) ? &m_rtts.current_ds_handle : nullptr; command_list->OMSetRenderTargets((UINT)num_rtt, &m_rtts.current_rtts_handle, true, ds_handle); } @@ -242,7 +242,7 @@ namespace ID3D12GraphicsCommandList * command_list, data_heap &readback_heap, ID3D12Resource * color_surface, - surface_color_format color_surface_format + rsx::surface_color_format color_surface_format ) { int clip_w = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL] >> 16; @@ -391,7 +391,7 @@ void D3D12GSRender::copy_render_target_to_dma_location() size_t color_buffer_offset_in_heap[4]; if (rpcs3::state.config.rsx.opengl.write_color_buffers) { - for (u8 i : get_rtt_indexes(to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]))) + for (u8 i : get_rtt_indexes(rsx::to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]))) { if (!address_color[i]) continue; @@ -443,7 +443,7 @@ void D3D12GSRender::copy_render_target_to_dma_location() vm::base(address_color[3]), }; - for (u8 i : get_rtt_indexes(to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]))) + for (u8 i : get_rtt_indexes(rsx::to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]))) { if (!address_color[i]) continue; diff --git a/rpcs3/Emu/RSX/GCM.cpp b/rpcs3/Emu/RSX/GCM.cpp index 145eda216801..4bef41219c82 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) +rsx::vertex_base_type rsx::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 rsx::vertex_base_type::s1; + case 2: return rsx::vertex_base_type::f; + case 3: return rsx::vertex_base_type::sf; + case 4: return rsx::vertex_base_type::ub; + case 5: return rsx::vertex_base_type::s32k; + case 6: return rsx::vertex_base_type::cmp; + case 7: return rsx::vertex_base_type::ub256; } throw new EXCEPTION("Unknow vertex base type %d", in); } -index_array_type to_index_array_type(u8 in) +rsx::index_array_type rsx::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 rsx::index_array_type::u32; + case 1: return rsx::index_array_type::u16; } throw new EXCEPTION("Unknown index array type %d", in); } -primitive_type to_primitive_type(u8 in) +rsx::primitive_type rsx::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 rsx::primitive_type::points; + case 2: return rsx::primitive_type::lines; + case 3: return rsx::primitive_type::line_loop; + case 4: return rsx::primitive_type::line_strip; + case 5: return rsx::primitive_type::triangles; + case 6: return rsx::primitive_type::triangle_strip; + case 7: return rsx::primitive_type::triangle_fan; + case 8: return rsx::primitive_type::quads; + case 9: return rsx::primitive_type::quad_strip; + case 10: return rsx::primitive_type::polygon; } throw new EXCEPTION("Unknow primitive type %d", in); } @@ -801,26 +801,26 @@ enum }; -surface_target to_surface_target(u8 in) +rsx::surface_target rsx::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 rsx::surface_target::none; + case CELL_GCM_SURFACE_TARGET_0: return rsx::surface_target::surface_a; + case CELL_GCM_SURFACE_TARGET_1: return rsx::surface_target::surface_b; + case CELL_GCM_SURFACE_TARGET_MRT1: return rsx::surface_target::surfaces_a_b; + case CELL_GCM_SURFACE_TARGET_MRT2: return rsx::surface_target::surfaces_a_b_c; + case CELL_GCM_SURFACE_TARGET_MRT3: return rsx::surface_target::surfaces_a_b_c_d; } throw EXCEPTION("Unknow surface target %x", in); } -surface_depth_format to_surface_depth_format(u8 in) +rsx::surface_depth_format rsx::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 rsx::surface_depth_format::z16; + case CELL_GCM_SURFACE_Z24S8: return rsx::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) +rsx::surface_antialiasing rsx::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 rsx::surface_antialiasing::center_1_sample; + case CELL_GCM_SURFACE_DIAGONAL_CENTERED_2: return rsx::surface_antialiasing::diagonal_centered_2_samples; + case CELL_GCM_SURFACE_SQUARE_CENTERED_4: return rsx::surface_antialiasing::square_centered_4_samples; + case CELL_GCM_SURFACE_SQUARE_ROTATED_4: return rsx::surface_antialiasing::square_rotated_4_samples; } throw EXCEPTION("unknow surface antialiasing format %x", in); } -surface_color_format to_surface_color_format(u8 in) +rsx::surface_color_format rsx::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 rsx::surface_color_format::x1r5g5b5_z1r5g5b5; + case CELL_GCM_SURFACE_X1R5G5B5_O1R5G5B5: return rsx::surface_color_format::x1r5g5b5_o1r5g5b5; + case CELL_GCM_SURFACE_R5G6B5: return rsx::surface_color_format::r5g6b5; + case CELL_GCM_SURFACE_X8R8G8B8_Z8R8G8B8: return rsx::surface_color_format::x8r8g8b8_z8r8g8b8; + case CELL_GCM_SURFACE_X8R8G8B8_O8R8G8B8: return rsx::surface_color_format::x8r8g8b8_o8r8g8b8; + case CELL_GCM_SURFACE_A8R8G8B8: return rsx::surface_color_format::a8r8g8b8; + case CELL_GCM_SURFACE_B8: return rsx::surface_color_format::b8; + case CELL_GCM_SURFACE_G8B8: return rsx::surface_color_format::g8b8; + case CELL_GCM_SURFACE_F_W16Z16Y16X16: return rsx::surface_color_format::w16z16y16x16; + case CELL_GCM_SURFACE_F_W32Z32Y32X32: return rsx::surface_color_format::w32z32y32x32; + case CELL_GCM_SURFACE_F_X32: return rsx::surface_color_format::x32; + case CELL_GCM_SURFACE_X8B8G8R8_Z8B8G8R8: return rsx::surface_color_format::x8b8g8r8_z8b8g8r8; + case CELL_GCM_SURFACE_X8B8G8R8_O8B8G8R8: return rsx::surface_color_format::x8b8g8r8_o8b8g8r8; + case CELL_GCM_SURFACE_A8B8G8R8: return rsx::surface_color_format::a8b8g8r8; } throw EXCEPTION("unknow surface color format %x", in); } @@ -953,18 +953,18 @@ namespace std::string get_primitive_mode(u8 draw_mode) { - switch (to_primitive_type(draw_mode)) + switch (rsx::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 rsx::primitive_type::points: return "Points"; + case rsx::primitive_type::lines: return "Lines"; + case rsx::primitive_type::line_loop: return "Line_loop"; + case rsx::primitive_type::line_strip: return "Line_strip"; + case rsx::primitive_type::triangles: return "Triangles"; + case rsx::primitive_type::triangle_strip: return "Triangle_strip"; + case rsx::primitive_type::triangle_fan: return "Triangle_fan"; + case rsx::primitive_type::quads: return "Quads"; + case rsx::primitive_type::quad_strip: return "Quad_strip"; + case rsx::primitive_type::polygon: return "Polygon"; } return "Error"; } @@ -989,58 +989,58 @@ namespace std::string depth_stencil_surface_format(u32 format) { - switch (to_surface_depth_format(format)) + switch (rsx::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 rsx::surface_depth_format::z16: return "CELL_GCM_SURFACE_Z16"; + case rsx::surface_depth_format::z24s8: return "CELL_GCM_SURFACE_Z24S8"; } return "Error"; } std::string surface_antialiasing(u8 format) { - switch (to_surface_antialiasing(format)) + switch (rsx::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 rsx::surface_antialiasing::center_1_sample: return "1 sample centered"; + case rsx::surface_antialiasing::diagonal_centered_2_samples: return "2 samples diagonal centered"; + case rsx::surface_antialiasing::square_centered_4_samples: return "4 samples square centered"; + case rsx::surface_antialiasing::square_rotated_4_samples: return "4 samples diagonal rotated"; } return "Error"; } - std::string color_surface_format(u32 format) + std::string surface_color_format(u32 format) { - switch (to_surface_color_format(format)) + switch (rsx::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 rsx::surface_color_format::x1r5g5b5_z1r5g5b5: return "CELL_GCM_SURFACE_X1R5G5B5_Z1R5G5B5"; + case rsx::surface_color_format::x1r5g5b5_o1r5g5b5: return "CELL_GCM_SURFACE_X1R5G5B5_O1R5G5B5"; + case rsx::surface_color_format::r5g6b5 : return "CELL_GCM_SURFACE_R5G6B5"; + case rsx::surface_color_format::x8r8g8b8_z8r8g8b8: return "CELL_GCM_SURFACE_X8R8G8B8_Z8R8G8B8"; + case rsx::surface_color_format::x8r8g8b8_o8r8g8b8: return "CELL_GCM_SURFACE_X8R8G8B8_O8R8G8B8"; + case rsx::surface_color_format::a8r8g8b8: return "CELL_GCM_SURFACE_A8R8G8B8"; + case rsx::surface_color_format::b8: return "CELL_GCM_SURFACE_B8"; + case rsx::surface_color_format::g8b8: return "CELL_GCM_SURFACE_G8B8"; + case rsx::surface_color_format::w16z16y16x16: return "CELL_GCM_SURFACE_F_W16Z16Y16X16"; + case rsx::surface_color_format::w32z32y32x32: return "CELL_GCM_SURFACE_F_W32Z32Y32X32"; + case rsx::surface_color_format::x32: return "CELL_GCM_SURFACE_F_X32"; + case rsx::surface_color_format::x8b8g8r8_z8b8g8r8: return "CELL_GCM_SURFACE_X8B8G8R8_Z8B8G8R8"; + case rsx::surface_color_format::x8b8g8r8_o8b8g8r8: return "CELL_GCM_SURFACE_X8B8G8R8_O8B8G8R8"; + case rsx::surface_color_format::a8b8g8r8: return "CELL_GCM_SURFACE_A8B8G8R8"; } return "Error"; } std::string surface_target(u32 target) { - switch (to_surface_target(target)) + switch (rsx::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 rsx::surface_target::none: return "none"; + case rsx::surface_target::surface_a: return "surface A"; + case rsx::surface_target::surface_b: return "surface B"; + case rsx::surface_target::surfaces_a_b: return "surfaces A and B"; + case rsx::surface_target::surfaces_a_b_c: return "surfaces A, B and C"; + case rsx::surface_target::surfaces_a_b_c_d: return "surfaces A,B, C and D"; } return "Error"; } @@ -1078,15 +1078,15 @@ namespace std::string get_vertex_attribute_format(u8 type) { - switch (to_vertex_base_type(type)) + switch (rsx::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 rsx::vertex_base_type::s1: return "Short"; + case rsx::vertex_base_type::f: return "Float"; + case rsx::vertex_base_type::sf: return "Half float"; + case rsx::vertex_base_type::ub: return "Unsigned byte"; + case rsx::vertex_base_type::s32k: return "Signed int"; + case rsx::vertex_base_type::cmp: return "CMP"; + case rsx::vertex_base_type::ub256: return "UB256"; } } @@ -1104,10 +1104,10 @@ namespace std::string index_type(u16 arg) { - switch (to_index_array_type(arg)) + switch (rsx::to_index_array_type(arg)) { - case index_array_type::unsigned_16b: return "unsigned short"; - case index_array_type::unsigned_32b: return "unsigned int"; + case rsx::index_array_type::u16: return "unsigned short"; + case rsx::index_array_type::u32: return "unsigned int"; } return "Error"; } @@ -1443,7 +1443,7 @@ namespace { NV4097_SET_SURFACE_PITCH_Z, [](u32 arg) -> std::string { return "Surface Zeta: Pitch = " + std::to_string(arg); } }, { NV4097_SET_SURFACE_ZETA_OFFSET, [](u32 arg) -> std::string { return "Surface Zeta: Offset = " + ptr_to_string(arg); } }, { NV4097_SET_CONTEXT_DMA_ZETA, [](u32 arg) -> std::string { return "Surface Zeta: DMA mode = " + dma_mode(arg);} }, - { NV4097_SET_SURFACE_FORMAT, [](u32 arg) -> std::string { return "Surface: Color format = " + color_surface_format(arg & 0x1F) + " DepthStencil format = " + depth_stencil_surface_format((arg >> 5) & 0x7) + " Anti aliasing =" + surface_antialiasing((arg >> 12) & 0x7); } }, + { NV4097_SET_SURFACE_FORMAT, [](u32 arg) -> std::string { return "Surface: Color format = " + surface_color_format(arg & 0x1F) + " DepthStencil format = " + depth_stencil_surface_format((arg >> 5) & 0x7) + " Anti aliasing =" + surface_antialiasing((arg >> 12) & 0x7); } }, { NV4097_SET_SURFACE_CLIP_HORIZONTAL, [](u32 arg) -> std::string { return "Surface: clip x = " + std::to_string(arg & 0xFFFF) + " width = " + std::to_string(arg >> 16); } }, { NV4097_SET_SURFACE_CLIP_VERTICAL, [](u32 arg) -> std::string { return "Surface: clip y = " + std::to_string(arg & 0xFFFF) + " height = " + std::to_string(arg >> 16); } }, { NV4097_SET_SURFACE_COLOR_TARGET, [](u32 arg) -> std::string { return "Surface: Targets " + surface_target(arg); } }, diff --git a/rpcs3/Emu/RSX/GCM.h b/rpcs3/Emu/RSX/GCM.h index 92a55f2c6d02..a11dc54ae134 100644 --- a/rpcs3/Emu/RSX/GCM.h +++ b/rpcs3/Emu/RSX/GCM.h @@ -23,92 +23,95 @@ enum CELL_GCM_DISPLAY_FREQUENCY_DISABLE = 3, }; -enum class vertex_base_type : u8 -{ - s1, ///< signed byte - f, ///< float - sf, ///< half float - ub, ///< unsigned byte - s32k, ///< signed 32bits int - cmp, ///< compressed aka X11G11Z10 and always 1. W. - ub256, -}; - -vertex_base_type to_vertex_base_type(u8 in); - -enum class index_array_type : u8 -{ - unsigned_32b, - unsigned_16b, -}; - -index_array_type to_index_array_type(u8 in); - -enum class primitive_type : u8 +namespace rsx { - points, - lines, - line_loop, // line strip with last end being joined with first end. - line_strip, - triangles, - triangle_strip, - triangle_fan, // like strip except that every triangle share the first vertex and one instead of 2 from previous triangle. - quads, - quad_strip, - polygon, // convex polygon -}; + enum class vertex_base_type : u8 + { + s1, ///< signed byte + f, ///< float + sf, ///< half float + ub, ///< unsigned byte + s32k, ///< signed 32bits int + cmp, ///< compressed aka X11G11Z10 and always 1. W. + ub256, + }; + + vertex_base_type to_vertex_base_type(u8 in); + + enum class index_array_type : u8 + { + u32, + u16, + }; -primitive_type to_primitive_type(u8 in); + index_array_type to_index_array_type(u8 in); -enum class surface_target : u8 -{ - none, - surface_a, - surface_b, - surfaces_a_b, - surfaces_a_b_c, - surfaces_a_b_c_d, -}; + enum class primitive_type : u8 + { + points, + lines, + line_loop, // line strip with last end being joined with first end. + line_strip, + triangles, + triangle_strip, + triangle_fan, // like strip except that every triangle share the first vertex and one instead of 2 from previous triangle. + quads, + quad_strip, + polygon, // convex polygon + }; + + primitive_type to_primitive_type(u8 in); + + enum class surface_target : u8 + { + none, + surface_a, + surface_b, + surfaces_a_b, + surfaces_a_b_c, + 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 -{ - z16, // unsigned 16 bits depth - z24s8, // unsigned 24 bits depth + 8 bits stencil -}; + 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 -{ - center_1_sample, - diagonal_centered_2_samples, - square_centered_4_samples, - square_rotated_4_samples, -}; - -surface_antialiasing to_surface_antialiasing(u8 in); + enum class surface_antialiasing : u8 + { + center_1_sample, + diagonal_centered_2_samples, + square_centered_4_samples, + square_rotated_4_samples, + }; -enum class surface_color_format : u8 -{ - x1r5g5b5_z1r5g5b5, - x1r5g5b5_o1r5g5b5, - r5g6b5, - x8r8g8b8_z8r8g8b8, - x8r8g8b8_o8r8g8b8, - a8r8g8b8, - b8, - g8b8, - w16z16y16x16, - w32z32y32x32, - x32, - x8b8g8r8_z8b8g8r8, - x8b8g8r8_o8b8g8r8, - a8b8g8r8, -}; + surface_antialiasing to_surface_antialiasing(u8 in); -surface_color_format to_surface_color_format(u8 in); + enum class surface_color_format : u8 + { + x1r5g5b5_z1r5g5b5, + x1r5g5b5_o1r5g5b5, + r5g6b5, + x8r8g8b8_z8r8g8b8, + x8r8g8b8_o8r8g8b8, + a8r8g8b8, + b8, + g8b8, + w16z16y16x16, + w32z32y32x32, + x32, + x8b8g8r8_z8b8g8r8, + x8b8g8r8_o8b8g8r8, + a8b8g8r8, + }; + + 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 222248385cd8..68ff2cee109b 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(rsx::surface_depth_format format) { switch (format) { - case surface_depth_format::z16: return 0xFFFF; - case surface_depth_format::z24s8: return 0xFFFFFF; + case rsx::surface_depth_format::z16: return 0xFFFF; + case rsx::surface_depth_format::z24s8: return 0xFFFFFF; } throw EXCEPTION("Unknow depth format"); } - u8 get_pixel_size(surface_depth_format format) + u8 get_pixel_size(rsx::surface_depth_format format) { switch (format) { - case surface_depth_format::z16: return 2; - case surface_depth_format::z24s8: return 4; + case rsx::surface_depth_format::z16: return 2; + case rsx::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 == rsx::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(rsx::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 rsx::vertex_base_type::s1: return gl::buffer_pointer::type::s16; + case rsx::vertex_base_type::f: return gl::buffer_pointer::type::f32; + case rsx::vertex_base_type::sf: return gl::buffer_pointer::type::f16; + case rsx::vertex_base_type::ub: return gl::buffer_pointer::type::u8; + case rsx::vertex_base_type::s32k: return gl::buffer_pointer::type::s32; + case rsx::vertex_base_type::cmp: return gl::buffer_pointer::type::s16; // Needs conversion + case rsx::vertex_base_type::ub256: gl::buffer_pointer::type::u8; } throw EXCEPTION("unknow vertex type"); } - bool gl_normalized(vertex_base_type type) + bool gl_normalized(rsx::vertex_base_type type) { switch (type) { - case vertex_base_type::s1: - case vertex_base_type::ub: - case vertex_base_type::cmp: + case rsx::vertex_base_type::s1: + case rsx::vertex_base_type::ub: + case rsx::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 rsx::vertex_base_type::f: + case rsx::vertex_base_type::sf: + case rsx::vertex_base_type::ub256: + case rsx::vertex_base_type::s32k: return false; } throw EXCEPTION("unknow vertex type"); @@ -404,7 +404,7 @@ void GLGSRender::end() u32 min_index, max_index; if (draw_command == rsx::draw_command::indexed) { - index_array_type type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); + rsx::index_array_type type = rsx::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,10 +415,10 @@ void GLGSRender::end() switch (type) { - case index_array_type::unsigned_32b: + case rsx::index_array_type::u32: 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 rsx::index_array_type::u16: 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; } @@ -508,7 +508,7 @@ void GLGSRender::end() switch (vertex_info.type) { - case vertex_base_type::f: + case rsx::vertex_base_type::f: switch (register_vertex_info[index].size) { case 1: apply_attrib_array(*m_program, location, vertex_data); break; @@ -531,11 +531,11 @@ void GLGSRender::end() { 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); + rsx::index_array_type indexed_type = rsx::to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); - if (indexed_type == index_array_type::unsigned_32b) + if (indexed_type == rsx::index_array_type::u32) __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 == rsx::index_array_type::u16) __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); + rsx::surface_depth_format surface_depth_format = rsx::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(rsx::surface_color_format color_format) { //color format switch (color_format) { - case surface_color_format::r5g6b5: + case rsx::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 rsx::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 rsx::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 rsx::surface_color_format::w16z16y16x16: return{ gl::texture::type::f16, gl::texture::format::rgba, true, 4, 2 }; - case surface_color_format::w32z32y32x32: + case rsx::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 rsx::surface_color_format::b8: + case rsx::surface_color_format::x1r5g5b5_o1r5g5b5: + case rsx::surface_color_format::x1r5g5b5_z1r5g5b5: + case rsx::surface_color_format::x8r8g8b8_z8r8g8b8: + case rsx::surface_color_format::g8b8: + case rsx::surface_color_format::x32: + case rsx::surface_color_format::x8b8g8r8_o8b8g8r8: + case rsx::surface_color_format::x8b8g8r8_z8b8g8r8: + case rsx::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(rsx::surface_depth_format depth_format) { switch (depth_format) { - case surface_depth_format::z16: + case rsx::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 rsx::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 rsx::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 rsx::surface_depth_format::z24s8: { __glcheck m_draw_tex_depth_stencil.config() .size({ (int)m_surface.width, (int)m_surface.height }) @@ -992,27 +992,27 @@ void GLGSRender::init_buffers(bool skip_reading) set_viewport(); - switch (to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])) + switch (rsx::to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])) { - case surface_target::none: break; + case rsx::surface_target::none: break; - case surface_target::surface_a: + case rsx::surface_target::surface_a: __glcheck draw_fbo.draw_buffer(draw_fbo.color[0]); break; - case surface_target::surface_b: + case rsx::surface_target::surface_b: __glcheck draw_fbo.draw_buffer(draw_fbo.color[1] ); break; - case surface_target::surfaces_a_b: + case rsx::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 rsx::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 rsx::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; @@ -1090,28 +1090,28 @@ void GLGSRender::read_buffers() } }; - switch (to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])) + switch (rsx::to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])) { - case surface_target::none: + case rsx::surface_target::none: break; - case surface_target::surface_a: + case rsx::surface_target::surface_a: read_color_buffers(0, 1); break; - case surface_target::surface_b: + case rsx::surface_target::surface_b: read_color_buffers(1, 1); break; - case surface_target::surfaces_a_b: + case rsx::surface_target::surfaces_a_b: read_color_buffers(0, 2); break; - case surface_target::surfaces_a_b_c: + case rsx::surface_target::surfaces_a_b_c: read_color_buffers(0, 3); break; - case surface_target::surfaces_a_b_c_d: + case rsx::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 == rsx::surface_depth_format::z16) { u16 *dst = (u16*)pixels; const be_t* src = vm::ps3::_ptr(depth_address); @@ -1221,28 +1221,28 @@ void GLGSRender::write_buffers() } }; - switch (to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])) + switch (rsx::to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])) { - case surface_target::none: + case rsx::surface_target::none: break; - case surface_target::surface_a: + case rsx::surface_target::surface_a: write_color_buffers(0, 1); break; - case surface_target::surface_b: + case rsx::surface_target::surface_b: write_color_buffers(1, 1); break; - case surface_target::surfaces_a_b: + case rsx::surface_target::surfaces_a_b: write_color_buffers(0, 2); break; - case surface_target::surfaces_a_b_c: + case rsx::surface_target::surfaces_a_b_c: write_color_buffers(0, 3); break; - case surface_target::surfaces_a_b_c_d: + case rsx::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 == rsx::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 0fb194e03e46..da61fb2d1449 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(rsx::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 rsx::primitive_type::points: return GL_POINTS; + case rsx::primitive_type::lines: return GL_LINES; + case rsx::primitive_type::line_loop: return GL_LINE_LOOP; + case rsx::primitive_type::line_strip: return GL_LINE_STRIP; + case rsx::primitive_type::triangles: return GL_TRIANGLES; + case rsx::primitive_type::triangle_strip: return GL_TRIANGLE_STRIP; + case rsx::primitive_type::triangle_fan: return GL_TRIANGLE_FAN; + case rsx::primitive_type::quads: return GL_QUADS; + case rsx::primitive_type::quad_strip: return GL_QUAD_STRIP; + case rsx::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(rsx::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, rsx::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, rsx::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(rsx::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, rsx::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(rsx::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_, rsx::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(rsx::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, rsx::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(rsx::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, rsx::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(rsx::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, rsx::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 04961fa7d051..568e511ad4bd 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(rsx::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_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_arrays(rsx::primitive_type mode, GLsizei count, GLint first = 0) const; + void draw_arrays(const buffer& buffer, rsx::primitive_type mode, GLsizei count, GLint first = 0) const; + void draw_arrays(const vao& buffer, rsx::primitive_type mode, GLsizei count, GLint first = 0) const; + + void draw_elements(rsx::primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const; + void draw_elements(const buffer& buffer, rsx::primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const; + void draw_elements(rsx::primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset = 0) const; + void draw_elements(const buffer& buffer_, rsx::primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset = 0) const; + void draw_elements(rsx::primitive_type mode, GLsizei count, const GLubyte *indices) const; + void draw_elements(const buffer& buffer, rsx::primitive_type mode, GLsizei count, const GLubyte *indices) const; + void draw_elements(rsx::primitive_type mode, GLsizei count, const GLushort *indices) const; + void draw_elements(const buffer& buffer, rsx::primitive_type mode, GLsizei count, const GLushort *indices) const; + void draw_elements(rsx::primitive_type mode, GLsizei count, const GLuint *indices) const; + void draw_elements(const buffer& buffer, rsx::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.h b/rpcs3/Emu/RSX/RSXThread.h index 48304cefd27a..7537ba32b343 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -15,15 +15,14 @@ extern u64 get_system_time(); struct frame_capture_data { - struct draw_state { std::string name; std::pair programs; size_t width = 0, height = 0; - surface_color_format color_format; + rsx::surface_color_format color_format; std::array, 4> color_buffer; - surface_depth_format depth_format; + rsx::surface_depth_format depth_format; std::array, 2> depth_stencil; }; std::vector > command_queue; diff --git a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp index 328bb3607b2d..da4df9b68e47 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp @@ -267,12 +267,12 @@ u8 GcmSurfaceFormat2GcmTextureFormat(u8 surfaceFormat, u8 surfaceType) { u8 result = 0; - switch (to_surface_color_format(surfaceFormat)) + switch (rsx::to_surface_color_format(surfaceFormat)) { - case surface_color_format::a8r8g8b8: + case rsx::surface_color_format::a8r8g8b8: result = CELL_GCM_TEXTURE_A8R8G8B8; break; - case surface_color_format::w16z16y16x16: + case rsx::surface_color_format::w16z16y16x16: result = CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT; break; default: @@ -933,15 +933,15 @@ s32 cellRescGcmSurface2RescSrc(vm::ptr gcmSurface, vm::ptrcolorFormat, gcmSurface->type); s32 xW = 1, xH = 1; - switch(to_surface_antialiasing(gcmSurface->antialias)) + switch(rsx::to_surface_antialiasing(gcmSurface->antialias)) { - case surface_antialiasing::square_rotated_4_samples: + case rsx::surface_antialiasing::square_rotated_4_samples: xW=xH=2; break; - case surface_antialiasing::square_centered_4_samples: + case rsx::surface_antialiasing::square_centered_4_samples: xW=xH=2; break; - case surface_antialiasing::diagonal_centered_2_samples: + case rsx::surface_antialiasing::diagonal_centered_2_samples: xW=2; break; default: diff --git a/rpcs3/Gui/RSXDebugger.cpp b/rpcs3/Gui/RSXDebugger.cpp index 6c826fe8cdaf..ef2179aa3a3e 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, rsx::surface_color_format format, size_t idx) { switch (format) { - case surface_color_format::b8: + case rsx::surface_color_format::b8: { u8 value = gsl::as_span(orig_buffer)[idx]; return{ value, value, value }; } - case surface_color_format::x32: + case rsx::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 rsx::surface_color_format::a8b8g8r8: + case rsx::surface_color_format::x8b8g8r8_o8b8g8r8: + case rsx::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 rsx::surface_color_format::a8r8g8b8: + case rsx::surface_color_format::x8r8g8b8_o8r8g8b8: + case rsx::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 rsx::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 rsx::surface_color_format::g8b8: + case rsx::surface_color_format::r5g6b5: + case rsx::surface_color_format::x1r5g5b5_o1r5g5b5: + case rsx::surface_color_format::x1r5g5b5_z1r5g5b5: + case rsx::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(rsx::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++) @@ -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.depth_format == surface_depth_format::z24s8) + if (draw_call.depth_format == rsx::surface_depth_format::z24s8) { for (u32 row = 0; row < height; row++) {