diff --git a/src/xenia/gpu/d3d11/d3d11_graphics_system.cc b/src/xenia/gpu/d3d11/d3d11_graphics_system.cc index bb79b156c..2e8993429 100644 --- a/src/xenia/gpu/d3d11/d3d11_graphics_system.cc +++ b/src/xenia/gpu/d3d11/d3d11_graphics_system.cc @@ -21,11 +21,16 @@ using namespace xe::gpu::d3d11; namespace { +void __stdcall D3D11GraphicsSystemVsyncCallback(D3D11GraphicsSystem* gs, BOOLEAN) { + gs->DispatchInterruptCallback(); +} + } D3D11GraphicsSystem::D3D11GraphicsSystem(const CreationParams* params) : window_(0), dxgi_factory_(0), device_(0), + timer_queue_(NULL), vsync_timer_(NULL), GraphicsSystem(params) { } @@ -38,6 +43,19 @@ D3D11GraphicsSystem::~D3D11GraphicsSystem() { void D3D11GraphicsSystem::Initialize() { GraphicsSystem::Initialize(); + XEASSERTNULL(timer_queue_); + XEASSERTNULL(vsync_timer_); + + timer_queue_ = CreateTimerQueue(); + CreateTimerQueueTimer( + &vsync_timer_, + timer_queue_, + (WAITORTIMERCALLBACK)D3D11GraphicsSystemVsyncCallback, + this, + 16, + 100, + WT_EXECUTEINTIMERTHREAD); + // Create DXGI factory so we can get a swap chain/etc. HRESULT hr = CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&dxgi_factory_); @@ -127,9 +145,6 @@ void D3D11GraphicsSystem::Pump() { // Swap window. // If we are set to vsync this will block. window_->Swap(); - - // Dispatch interrupt callback to let the game know it can keep drawing. - DispatchInterruptCallback(); } else { // If we have gone too long without an interrupt, fire one. if (xe_pal_now() - last_interrupt_time_ > 16 / 1000.0) { @@ -139,5 +154,14 @@ void D3D11GraphicsSystem::Pump() { } void D3D11GraphicsSystem::Shutdown() { + if (vsync_timer_) { + DeleteTimerQueueTimer(timer_queue_, vsync_timer_, NULL); + } + if (timer_queue_) { + DeleteTimerQueueEx(timer_queue_, NULL); + } + + // TODO(benvanik): release D3D stuff here? + GraphicsSystem::Shutdown(); } diff --git a/src/xenia/gpu/d3d11/d3d11_graphics_system.h b/src/xenia/gpu/d3d11/d3d11_graphics_system.h index 0bb8a50d1..7b0d0bd82 100644 --- a/src/xenia/gpu/d3d11/d3d11_graphics_system.h +++ b/src/xenia/gpu/d3d11/d3d11_graphics_system.h @@ -42,6 +42,9 @@ private: IDXGIFactory1* dxgi_factory_; ID3D11Device* device_; D3D11Window* window_; + + HANDLE timer_queue_; + HANDLE vsync_timer_; }; diff --git a/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_video.cc b/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_video.cc index 78a1e2071..448c56c8a 100644 --- a/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_video.cc +++ b/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_video.cc @@ -391,8 +391,25 @@ SHIM_CALL VdRetrainEDRAM_shim( SHIM_CALL VdSwap_shim( xe_ppc_state_t* ppc_state, KernelState* state) { + uint32_t unk0 = SHIM_GET_ARG_32(0); + uint32_t unk1 = SHIM_GET_ARG_32(1); + uint32_t unk2 = SHIM_GET_ARG_32(2); + uint32_t unk3 = SHIM_GET_ARG_32(3); + uint32_t unk4 = SHIM_GET_ARG_32(4); + uint32_t unk5 = SHIM_GET_ARG_32(5); + uint32_t unk6 = SHIM_GET_ARG_32(6); + uint32_t unk7 = SHIM_GET_ARG_32(7); + XELOGD( - "VdSwap(?)"); + "VdSwap(%.8X, %.8X, %.8X, %.8X, %.8X, %.8X, %.8X, %.8X)", + unk0, + unk1, + unk2, + unk3, + unk4, + unk5, + unk6, + unk7); KernelState* kernel_state = shared_kernel_state_; XEASSERTNOTNULL(kernel_state);