From: Matteo Bruni mbruni@codeweavers.com
--- dlls/wined3d/cs.c | 18 ++++++++++++++++++ dlls/wined3d/wined3d_private.h | 2 ++ 2 files changed, 20 insertions(+)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 0b7cae2d90b..0d5f5578577 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -23,6 +23,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DECLARE_DEBUG_CHANNEL(d3d_perf); WINE_DECLARE_DEBUG_CHANNEL(d3d_sync); WINE_DECLARE_DEBUG_CHANNEL(fps); +WINE_DECLARE_DEBUG_CHANNEL(frametime);
static NTSTATUS (WINAPI *pNtAlertThreadByThreadId)(HANDLE tid); static NTSTATUS (WINAPI *pNtWaitForAlertByThreadId)(void *addr, const LARGE_INTEGER *timeout); @@ -3363,9 +3364,16 @@ static void wined3d_cs_command_unlock(const struct wined3d_cs *cs)
static inline bool wined3d_cs_execute_next(struct wined3d_cs *cs, struct wined3d_cs_queue *queue) { + static LARGE_INTEGER freq; + struct wined3d_cs_packet *packet; enum wined3d_cs_op opcode; SIZE_T tail; + LARGE_INTEGER time1; + LONGLONG total_time; + + if (!freq.QuadPart) + QueryPerformanceFrequency(&freq);
tail = queue->tail; packet = wined3d_next_cs_packet(queue->data, &tail, WINED3D_CS_QUEUE_MASK); @@ -3386,6 +3394,16 @@ static inline bool wined3d_cs_execute_next(struct wined3d_cs *cs, struct wined3d wined3d_cs_op_handlers[opcode](cs, packet->data); wined3d_cs_command_unlock(cs); TRACE("%s at %p executed.\n", debug_cs_op(opcode), packet); + if (TRACE_ON(frametime) && opcode == WINED3D_CS_OP_PRESENT) + { + QueryPerformanceCounter(&time1); + if (cs->last_present_time.QuadPart) + { + total_time = time1.QuadPart - cs->last_present_time.QuadPart; + TRACE_(frametime)("Frame duration %u μs.\n", (unsigned int)(total_time * 1000000 / freq.QuadPart)); + } + cs->last_present_time = time1; + } }
InterlockedExchange((LONG *)&queue->tail, tail); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 2f74ca17e2d..27c8a09f106 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3619,6 +3619,8 @@ struct wined3d_cs LONG waiting_for_event; LONG waiting_for_present; LONG pending_presents; + + LARGE_INTEGER last_present_time; };
static inline void wined3d_device_context_lock(struct wined3d_device_context *context)