Dispatch interrupt outside of main pump.

This commit is contained in:
Ben Vanik 2013-10-19 00:46:11 -07:00
parent 562c86f76d
commit a63db2b7fd
3 changed files with 48 additions and 4 deletions

View File

@ -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();
}

View File

@ -42,6 +42,9 @@ private:
IDXGIFactory1* dxgi_factory_;
ID3D11Device* device_;
D3D11Window* window_;
HANDLE timer_queue_;
HANDLE vsync_timer_;
};

View File

@ -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);