mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 10:42:36 +01:00
Switch to always using a steady clock (closes #2200)
This commit is contained in:
parent
4203f53b67
commit
11e2965b5c
@ -11,6 +11,7 @@
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <chrono>
|
||||
|
||||
// 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;
|
||||
|
@ -1290,7 +1290,7 @@ s32 cellGcmCallback(vm::ptr<CellGcmContextData> context, u32 count)
|
||||
cellGcmSys.trace("cellGcmCallback(context=*0x%x, count=0x%x)", context, count);
|
||||
|
||||
auto& ctrl = vm::_ref<CellGcmControl>(gcm_info.control_addr);
|
||||
const std::chrono::time_point<std::chrono::system_clock> enterWait = std::chrono::system_clock::now();
|
||||
const std::chrono::time_point<steady_clock> 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<CellGcmContextData> context, u32 count)
|
||||
u32 getPos = ctrl.get.load();
|
||||
if (isInCommandBufferExcept(getPos, newCommandBuffer.first, newCommandBuffer.second))
|
||||
break;
|
||||
std::chrono::time_point<std::chrono::system_clock> waitPoint = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> waitPoint = steady_clock::now();
|
||||
long long elapsedTime = std::chrono::duration_cast<std::chrono::seconds>(waitPoint - enterWait).count();
|
||||
if (elapsedTime > 0)
|
||||
cellGcmSys.error("Has wait for more than a second for command buffer to be released by RSX");
|
||||
|
@ -301,15 +301,15 @@ bool D3D12GSRender::do_method(u32 cmd, u32 arg)
|
||||
|
||||
void D3D12GSRender::end()
|
||||
{
|
||||
std::chrono::time_point<std::chrono::system_clock> start_duration = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> start_duration = steady_clock::now();
|
||||
|
||||
std::chrono::time_point<std::chrono::system_clock> rtt_duration_start = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> rtt_duration_start = steady_clock::now();
|
||||
prepare_render_targets(get_current_resource_storage().command_list.Get());
|
||||
|
||||
std::chrono::time_point<std::chrono::system_clock> rtt_duration_end = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> rtt_duration_end = steady_clock::now();
|
||||
m_timers.prepare_rtt_duration += std::chrono::duration_cast<std::chrono::microseconds>(rtt_duration_end - rtt_duration_start).count();
|
||||
|
||||
std::chrono::time_point<std::chrono::system_clock> vertex_index_duration_start = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> 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<UINT>(vertex_buffer_views.size());
|
||||
|
||||
std::chrono::time_point<std::chrono::system_clock> vertex_index_duration_end = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> vertex_index_duration_end = steady_clock::now();
|
||||
m_timers.vertex_index_duration += std::chrono::duration_cast<std::chrono::microseconds>(vertex_index_duration_end - vertex_index_duration_start).count();
|
||||
|
||||
std::chrono::time_point<std::chrono::system_clock> program_load_start = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> program_load_start = steady_clock::now();
|
||||
load_program();
|
||||
std::chrono::time_point<std::chrono::system_clock> program_load_end = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> program_load_end = steady_clock::now();
|
||||
m_timers.program_load_duration += std::chrono::duration_cast<std::chrono::microseconds>(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<std::chrono::system_clock> constants_duration_start = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> 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<std::chrono::system_clock> constants_duration_end = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> constants_duration_end = steady_clock::now();
|
||||
m_timers.constants_duration += std::chrono::duration_cast<std::chrono::microseconds>(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<std::chrono::system_clock> texture_duration_start = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> 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<std::chrono::system_clock> texture_duration_end = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> texture_duration_end = steady_clock::now();
|
||||
m_timers.texture_duration += std::chrono::duration_cast<std::chrono::microseconds>(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<std::chrono::system_clock> end_duration = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> end_duration = steady_clock::now();
|
||||
m_timers.draw_calls_duration += std::chrono::duration_cast<std::chrono::microseconds>(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<std::chrono::system_clock> flip_start = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> 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<std::chrono::system_clock> flip_end = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> flip_end = steady_clock::now();
|
||||
m_timers.flip_duration += std::chrono::duration_cast<std::chrono::microseconds>(flip_end - flip_start).count();
|
||||
}
|
||||
|
||||
|
@ -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<std::chrono::system_clock> start_duration = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> start_duration = steady_clock::now();
|
||||
|
||||
std::chrono::time_point<std::chrono::system_clock> rtt_duration_start = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> rtt_duration_start = steady_clock::now();
|
||||
prepare_render_targets(get_current_resource_storage().command_list.Get());
|
||||
|
||||
std::chrono::time_point<std::chrono::system_clock> rtt_duration_end = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> rtt_duration_end = steady_clock::now();
|
||||
m_timers.prepare_rtt_duration += std::chrono::duration_cast<std::chrono::microseconds>(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<std::chrono::system_clock> end_duration = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> end_duration = steady_clock::now();
|
||||
m_timers.draw_calls_duration += std::chrono::duration_cast<std::chrono::microseconds>(end_duration - start_duration).count();
|
||||
m_timers.draw_calls_count++;
|
||||
|
||||
|
@ -191,7 +191,7 @@ void GLGSRender::begin()
|
||||
|
||||
init_buffers();
|
||||
|
||||
std::chrono::time_point<std::chrono::system_clock> then = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> 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<std::chrono::system_clock> now = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> now = steady_clock::now();
|
||||
m_begin_time += (u32)std::chrono::duration_cast<std::chrono::microseconds>(now - then).count();
|
||||
m_draw_calls++;
|
||||
}
|
||||
@ -410,7 +410,7 @@ void GLGSRender::end()
|
||||
ds->set_cleared();
|
||||
}
|
||||
|
||||
std::chrono::time_point<std::chrono::system_clock> textures_start = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> 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<std::chrono::system_clock> textures_end = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> textures_end = steady_clock::now();
|
||||
m_textures_upload_time += (u32)std::chrono::duration_cast<std::chrono::microseconds>(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<std::chrono::system_clock> draw_start = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> 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<std::chrono::system_clock> draw_end = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> draw_end = steady_clock::now();
|
||||
m_draw_time += (u32)std::chrono::duration_cast<std::chrono::microseconds>(draw_end - draw_start).count();
|
||||
|
||||
write_buffers();
|
||||
|
@ -460,7 +460,7 @@ namespace
|
||||
|
||||
std::tuple<u32, std::optional<std::tuple<GLenum, u32>>> GLGSRender::set_vertex_buffer()
|
||||
{
|
||||
std::chrono::time_point<std::chrono::system_clock> then = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> 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<u32, std::optional<std::tuple<GLenum, u32>>> GLGSRender::set_vertex_b
|
||||
}),
|
||||
get_draw_command(rsx::method_registers));
|
||||
|
||||
std::chrono::time_point<std::chrono::system_clock> now = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> now = steady_clock::now();
|
||||
m_vertex_upload_time += std::chrono::duration_cast<std::chrono::microseconds>(now - then).count();
|
||||
return result;
|
||||
}
|
||||
|
@ -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<std::chrono::system_clock> submit_start = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> 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<std::chrono::system_clock> submit_end = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> submit_end = steady_clock::now();
|
||||
m_flip_time += std::chrono::duration_cast<std::chrono::microseconds>(submit_end - submit_start).count();
|
||||
}
|
||||
|
||||
std::chrono::time_point<std::chrono::system_clock> start = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> 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<std::chrono::system_clock> stop = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> stop = steady_clock::now();
|
||||
m_setup_time += std::chrono::duration_cast<std::chrono::microseconds>(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<std::chrono::system_clock> textures_start = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> 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<std::chrono::system_clock> textures_end = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> textures_end = steady_clock::now();
|
||||
m_textures_upload_time += std::chrono::duration_cast<std::chrono::microseconds>(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<std::chrono::system_clock> vertex_end = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> vertex_end = steady_clock::now();
|
||||
m_vertex_upload_time += std::chrono::duration_cast<std::chrono::microseconds>(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<std::chrono::system_clock> draw_end = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> draw_end = steady_clock::now();
|
||||
m_draw_time += std::chrono::duration_cast<std::chrono::microseconds>(draw_end - vertex_end).count();
|
||||
|
||||
rsx::thread::end();
|
||||
@ -1364,7 +1364,7 @@ void VKGSRender::flip(int buffer)
|
||||
resize_screen = true;
|
||||
}
|
||||
|
||||
std::chrono::time_point<std::chrono::system_clock> flip_start = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> 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<std::chrono::system_clock> flip_end = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<steady_clock> flip_end = steady_clock::now();
|
||||
m_flip_time = std::chrono::duration_cast<std::chrono::microseconds>(flip_end - flip_start).count();
|
||||
|
||||
m_uniform_buffer_ring_info.m_get_pos = m_uniform_buffer_ring_info.get_current_put_pos_minus_one();
|
||||
|
Loading…
Reference in New Issue
Block a user