diff --git a/Utilities/types.h b/Utilities/types.h index b783ca2f62..0a397d36d9 100644 --- a/Utilities/types.h +++ b/Utilities/types.h @@ -11,6 +11,7 @@ #include #include #include +#include // Assume little-endian #define IS_LE_MACHINE 1 @@ -80,6 +81,10 @@ using s16 = std::int16_t; using s32 = std::int32_t; using s64 = std::int64_t; +using steady_clock = std::conditional< + std::chrono::high_resolution_clock::is_steady, + std::chrono::high_resolution_clock, std::chrono::steady_clock>::type; + namespace gsl { enum class byte : u8; diff --git a/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp b/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp index caa8ddf312..2ba525b44d 100644 --- a/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp @@ -1290,7 +1290,7 @@ s32 cellGcmCallback(vm::ptr context, u32 count) cellGcmSys.trace("cellGcmCallback(context=*0x%x, count=0x%x)", context, count); auto& ctrl = vm::_ref(gcm_info.control_addr); - const std::chrono::time_point enterWait = std::chrono::system_clock::now(); + const std::chrono::time_point enterWait = steady_clock::now(); // Flush command buffer (ie allow RSX to read up to context->current) ctrl.put.exchange(getOffsetFromAddress(context->current.addr())); @@ -1309,7 +1309,7 @@ s32 cellGcmCallback(vm::ptr context, u32 count) u32 getPos = ctrl.get.load(); if (isInCommandBufferExcept(getPos, newCommandBuffer.first, newCommandBuffer.second)) break; - std::chrono::time_point waitPoint = std::chrono::system_clock::now(); + std::chrono::time_point waitPoint = steady_clock::now(); long long elapsedTime = std::chrono::duration_cast(waitPoint - enterWait).count(); if (elapsedTime > 0) cellGcmSys.error("Has wait for more than a second for command buffer to be released by RSX"); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp index b35b98adc0..59e86dd8b2 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp @@ -301,15 +301,15 @@ bool D3D12GSRender::do_method(u32 cmd, u32 arg) void D3D12GSRender::end() { - std::chrono::time_point start_duration = std::chrono::system_clock::now(); + std::chrono::time_point start_duration = steady_clock::now(); - std::chrono::time_point rtt_duration_start = std::chrono::system_clock::now(); + std::chrono::time_point rtt_duration_start = steady_clock::now(); prepare_render_targets(get_current_resource_storage().command_list.Get()); - std::chrono::time_point rtt_duration_end = std::chrono::system_clock::now(); + std::chrono::time_point rtt_duration_end = steady_clock::now(); 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(); + std::chrono::time_point vertex_index_duration_start = steady_clock::now(); size_t currentDescriptorIndex = get_current_resource_storage().descriptors_heap_index; @@ -320,18 +320,18 @@ void D3D12GSRender::end() UINT vertex_buffer_count = static_cast(vertex_buffer_views.size()); - std::chrono::time_point vertex_index_duration_end = std::chrono::system_clock::now(); + std::chrono::time_point vertex_index_duration_end = steady_clock::now(); 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(); + std::chrono::time_point program_load_start = steady_clock::now(); load_program(); - std::chrono::time_point program_load_end = std::chrono::system_clock::now(); + std::chrono::time_point program_load_end = steady_clock::now(); m_timers.program_load_duration += std::chrono::duration_cast(program_load_end - program_load_start).count(); get_current_resource_storage().command_list->SetGraphicsRootSignature(m_shared_root_signature.Get()); get_current_resource_storage().command_list->OMSetStencilRef(rsx::method_registers.stencil_func_ref()); - std::chrono::time_point constants_duration_start = std::chrono::system_clock::now(); + std::chrono::time_point constants_duration_start = steady_clock::now(); INT offset = 0; for (const auto view : vertex_buffer_views) @@ -368,12 +368,12 @@ void D3D12GSRender::end() } - std::chrono::time_point constants_duration_end = std::chrono::system_clock::now(); + std::chrono::time_point constants_duration_end = steady_clock::now(); 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()); - std::chrono::time_point texture_duration_start = std::chrono::system_clock::now(); + std::chrono::time_point texture_duration_start = steady_clock::now(); get_current_resource_storage().descriptors_heap_index += 2 + vertex_buffer_count; size_t texture_count = std::get<2>(m_current_pso); @@ -421,7 +421,7 @@ void D3D12GSRender::end() get_current_resource_storage().descriptors_heap_index += texture_count; } - std::chrono::time_point texture_duration_end = std::chrono::system_clock::now(); + std::chrono::time_point texture_duration_end = steady_clock::now(); 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()); @@ -449,7 +449,7 @@ void D3D12GSRender::end() else get_current_resource_storage().command_list->DrawInstanced((UINT)vertex_count, 1, 0, 0); - std::chrono::time_point end_duration = std::chrono::system_clock::now(); + std::chrono::time_point end_duration = steady_clock::now(); m_timers.draw_calls_duration += std::chrono::duration_cast(end_duration - start_duration).count(); m_timers.draw_calls_count++; @@ -633,7 +633,7 @@ void D3D12GSRender::flip(int buffer) reset_timer(); - std::chrono::time_point flip_start = std::chrono::system_clock::now(); + std::chrono::time_point flip_start = steady_clock::now(); CHECK_HRESULT(m_swap_chain->Present(g_cfg_rsx_vsync ? 1 : 0, 0)); // Add an event signaling queue completion @@ -667,7 +667,7 @@ void D3D12GSRender::flip(int buffer) m_frame->flip(nullptr); - std::chrono::time_point flip_end = std::chrono::system_clock::now(); + std::chrono::time_point flip_end = steady_clock::now(); m_timers.flip_duration += std::chrono::duration_cast(flip_end - flip_start).count(); } diff --git a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp index 0c3f1b0b40..f5793bf35d 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp @@ -111,12 +111,12 @@ void D3D12GSRender::clear_surface(u32 arg) // Ignore clear if surface target is set to CELL_GCM_SURFACE_TARGET_NONE if (rsx::method_registers.surface_color_target() == rsx::surface_target::none) return; - std::chrono::time_point start_duration = std::chrono::system_clock::now(); + std::chrono::time_point start_duration = steady_clock::now(); - std::chrono::time_point rtt_duration_start = std::chrono::system_clock::now(); + std::chrono::time_point rtt_duration_start = steady_clock::now(); prepare_render_targets(get_current_resource_storage().command_list.Get()); - std::chrono::time_point rtt_duration_end = std::chrono::system_clock::now(); + std::chrono::time_point rtt_duration_end = steady_clock::now(); m_timers.prepare_rtt_duration += std::chrono::duration_cast(rtt_duration_end - rtt_duration_start).count(); if (arg & 0x1 || arg & 0x2) @@ -153,7 +153,7 @@ void D3D12GSRender::clear_surface(u32 arg) 1, &get_scissor(rsx::method_registers.scissor_origin_x(), rsx::method_registers.scissor_origin_y(), rsx::method_registers.scissor_width(), rsx::method_registers.scissor_height())); } - std::chrono::time_point end_duration = std::chrono::system_clock::now(); + std::chrono::time_point end_duration = steady_clock::now(); m_timers.draw_calls_duration += std::chrono::duration_cast(end_duration - start_duration).count(); m_timers.draw_calls_count++; diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index 8252ab0e7b..652463473a 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -191,7 +191,7 @@ void GLGSRender::begin() init_buffers(); - std::chrono::time_point then = std::chrono::system_clock::now(); + std::chrono::time_point then = steady_clock::now(); bool color_mask_b = rsx::method_registers.color_mask_b(); bool color_mask_g = rsx::method_registers.color_mask_g(); @@ -343,7 +343,7 @@ void GLGSRender::begin() //NV4097_SET_ANTI_ALIASING_CONTROL //NV4097_SET_CLIP_ID_TEST_ENABLE - std::chrono::time_point now = std::chrono::system_clock::now(); + std::chrono::time_point now = steady_clock::now(); m_begin_time += (u32)std::chrono::duration_cast(now - then).count(); m_draw_calls++; } @@ -410,7 +410,7 @@ void GLGSRender::end() ds->set_cleared(); } - std::chrono::time_point textures_start = std::chrono::system_clock::now(); + std::chrono::time_point textures_start = steady_clock::now(); //Setup textures for (int i = 0; i < rsx::limits::fragment_textures_count; ++i) @@ -450,7 +450,7 @@ void GLGSRender::end() } } - std::chrono::time_point textures_end = std::chrono::system_clock::now(); + std::chrono::time_point textures_end = steady_clock::now(); m_textures_upload_time += (u32)std::chrono::duration_cast(textures_end - textures_start).count(); u32 vertex_draw_count; @@ -458,7 +458,7 @@ void GLGSRender::end() std::tie(vertex_draw_count, indexed_draw_info) = set_vertex_buffer(); m_vao.bind(); - std::chrono::time_point draw_start = std::chrono::system_clock::now(); + std::chrono::time_point draw_start = steady_clock::now(); if (g_cfg_rsx_debug_output) { @@ -486,7 +486,7 @@ void GLGSRender::end() draw_fbo.draw_arrays(rsx::method_registers.current_draw_clause.primitive, vertex_draw_count); } - std::chrono::time_point draw_end = std::chrono::system_clock::now(); + std::chrono::time_point draw_end = steady_clock::now(); m_draw_time += (u32)std::chrono::duration_cast(draw_end - draw_start).count(); write_buffers(); diff --git a/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp b/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp index 0feb5f55ff..daa275d6c9 100644 --- a/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp +++ b/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp @@ -460,7 +460,7 @@ namespace std::tuple>> GLGSRender::set_vertex_buffer() { - std::chrono::time_point then = std::chrono::system_clock::now(); + std::chrono::time_point then = steady_clock::now(); auto result = std::apply_visitor(draw_command_visitor(*m_index_ring_buffer, *m_attrib_ring_buffer, m_gl_attrib_buffers, m_program, m_min_texbuffer_alignment, [this](const auto& state, const auto& list) { @@ -468,7 +468,7 @@ std::tuple>> GLGSRender::set_vertex_b }), get_draw_command(rsx::method_registers)); - std::chrono::time_point now = std::chrono::system_clock::now(); + std::chrono::time_point now = steady_clock::now(); m_vertex_upload_time += std::chrono::duration_cast(now - then).count(); return result; } diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index 744073b1f4..ba6ebe0afe 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -622,7 +622,7 @@ void VKGSRender::begin() //Ease resource pressure if the number of draw calls becomes too high if (m_used_descriptors >= DESCRIPTOR_MAX_DRAW_CALLS) { - std::chrono::time_point submit_start = std::chrono::system_clock::now(); + std::chrono::time_point submit_start = steady_clock::now(); close_and_submit_command_buffer({}, m_submit_fence); CHECK_RESULT(vkWaitForFences((*m_device), 1, &m_submit_fence, VK_TRUE, ~0ULL)); @@ -638,11 +638,11 @@ void VKGSRender::begin() m_attrib_ring_info.m_get_pos = m_attrib_ring_info.get_current_put_pos_minus_one(); m_texture_upload_buffer_ring_info.m_get_pos = m_texture_upload_buffer_ring_info.get_current_put_pos_minus_one(); - std::chrono::time_point submit_end = std::chrono::system_clock::now(); + std::chrono::time_point submit_end = steady_clock::now(); m_flip_time += std::chrono::duration_cast(submit_end - submit_start).count(); } - std::chrono::time_point start = std::chrono::system_clock::now(); + std::chrono::time_point start = steady_clock::now(); VkDescriptorSetAllocateInfo alloc_info = {}; alloc_info.descriptorPool = descriptor_pool; @@ -666,7 +666,7 @@ void VKGSRender::begin() //TODO: Set up other render-state parameters into the program pipeline - std::chrono::time_point stop = std::chrono::system_clock::now(); + std::chrono::time_point stop = steady_clock::now(); m_setup_time += std::chrono::duration_cast(stop - start).count(); m_draw_calls++; @@ -681,7 +681,7 @@ void VKGSRender::end() (u8)vk::get_draw_buffers(rsx::method_registers.surface_color_target()).size()); VkRenderPass current_render_pass = m_render_passes[idx]; - std::chrono::time_point textures_start = std::chrono::system_clock::now(); + std::chrono::time_point textures_start = steady_clock::now(); for (int i = 0; i < rsx::limits::fragment_textures_count; ++i) { @@ -763,7 +763,7 @@ void VKGSRender::end() } } - std::chrono::time_point textures_end = std::chrono::system_clock::now(); + std::chrono::time_point textures_end = steady_clock::now(); m_textures_upload_time += std::chrono::duration_cast(textures_end - textures_start).count(); VkRenderPassBeginInfo rp_begin = {}; @@ -779,7 +779,7 @@ void VKGSRender::end() auto upload_info = upload_vertex_data(); - std::chrono::time_point vertex_end = std::chrono::system_clock::now(); + std::chrono::time_point vertex_end = steady_clock::now(); m_vertex_upload_time += std::chrono::duration_cast(vertex_end - textures_end).count(); vkCmdBindPipeline(m_command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_program->pipeline); @@ -803,7 +803,7 @@ void VKGSRender::end() vkCmdEndRenderPass(m_command_buffer); - std::chrono::time_point draw_end = std::chrono::system_clock::now(); + std::chrono::time_point draw_end = steady_clock::now(); m_draw_time += std::chrono::duration_cast(draw_end - vertex_end).count(); rsx::thread::end(); @@ -1364,7 +1364,7 @@ void VKGSRender::flip(int buffer) resize_screen = true; } - std::chrono::time_point flip_start = std::chrono::system_clock::now(); + std::chrono::time_point flip_start = steady_clock::now(); if (!resize_screen) { @@ -1538,7 +1538,7 @@ void VKGSRender::flip(int buffer) vkDestroyFence((*m_device), resize_fence, nullptr); } - std::chrono::time_point flip_end = std::chrono::system_clock::now(); + std::chrono::time_point flip_end = steady_clock::now(); m_flip_time = std::chrono::duration_cast(flip_end - flip_start).count(); m_uniform_buffer_ring_info.m_get_pos = m_uniform_buffer_ring_info.get_current_put_pos_minus_one();