Fixing some shutdown code.
This commit is contained in:
@@ -37,9 +37,6 @@ D3D11GraphicsSystem::D3D11GraphicsSystem(Emulator* emulator) :
|
||||
}
|
||||
|
||||
D3D11GraphicsSystem::~D3D11GraphicsSystem() {
|
||||
XESAFERELEASE(device_);
|
||||
XESAFERELEASE(dxgi_factory_);
|
||||
delete window_;
|
||||
}
|
||||
|
||||
void D3D11GraphicsSystem::Initialize() {
|
||||
@@ -50,13 +47,13 @@ void D3D11GraphicsSystem::Initialize() {
|
||||
|
||||
timer_queue_ = CreateTimerQueue();
|
||||
CreateTimerQueueTimer(
|
||||
&vsync_timer_,
|
||||
timer_queue_,
|
||||
(WAITORTIMERCALLBACK)D3D11GraphicsSystemVsyncCallback,
|
||||
this,
|
||||
16,
|
||||
100,
|
||||
WT_EXECUTEINTIMERTHREAD);
|
||||
&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),
|
||||
@@ -158,6 +155,8 @@ void D3D11GraphicsSystem::Pump() {
|
||||
}
|
||||
|
||||
void D3D11GraphicsSystem::Shutdown() {
|
||||
GraphicsSystem::Shutdown();
|
||||
|
||||
if (vsync_timer_) {
|
||||
DeleteTimerQueueTimer(timer_queue_, vsync_timer_, NULL);
|
||||
}
|
||||
@@ -165,7 +164,10 @@ void D3D11GraphicsSystem::Shutdown() {
|
||||
DeleteTimerQueueEx(timer_queue_, NULL);
|
||||
}
|
||||
|
||||
// TODO(benvanik): release D3D stuff here?
|
||||
|
||||
GraphicsSystem::Shutdown();
|
||||
XESAFERELEASE(device_);
|
||||
device_ = 0;
|
||||
XESAFERELEASE(dxgi_factory_);
|
||||
dxgi_factory_ = 0;
|
||||
delete window_;
|
||||
window_ = 0;
|
||||
}
|
||||
|
||||
@@ -33,10 +33,11 @@ public:
|
||||
D3D11GraphicsSystem(Emulator* emulator);
|
||||
virtual ~D3D11GraphicsSystem();
|
||||
|
||||
virtual void Shutdown();
|
||||
|
||||
protected:
|
||||
virtual void Initialize();
|
||||
virtual void Pump();
|
||||
virtual void Shutdown();
|
||||
|
||||
private:
|
||||
IDXGIFactory1* dxgi_factory_;
|
||||
|
||||
@@ -33,14 +33,6 @@ GraphicsSystem::GraphicsSystem(Emulator* emulator) :
|
||||
}
|
||||
|
||||
GraphicsSystem::~GraphicsSystem() {
|
||||
// TODO(benvanik): thread join.
|
||||
running_ = false;
|
||||
xe_thread_release(thread_);
|
||||
|
||||
// TODO(benvanik): worker join/etc.
|
||||
delete worker_;
|
||||
|
||||
xe_run_loop_release(run_loop_);
|
||||
}
|
||||
|
||||
X_STATUS GraphicsSystem::Setup() {
|
||||
@@ -90,13 +82,15 @@ void GraphicsSystem::ThreadStart() {
|
||||
// Pump worker.
|
||||
worker_->Pump();
|
||||
|
||||
if (!running_) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Pump graphics system.
|
||||
Pump();
|
||||
}
|
||||
running_ = false;
|
||||
|
||||
Shutdown();
|
||||
|
||||
xe_run_loop_release(run_loop);
|
||||
|
||||
// TODO(benvanik): call module API to kill?
|
||||
@@ -106,6 +100,13 @@ void GraphicsSystem::Initialize() {
|
||||
}
|
||||
|
||||
void GraphicsSystem::Shutdown() {
|
||||
running_ = false;
|
||||
xe_thread_join(thread_);
|
||||
xe_thread_release(thread_);
|
||||
|
||||
delete worker_;
|
||||
|
||||
xe_run_loop_release(run_loop_);
|
||||
}
|
||||
|
||||
void GraphicsSystem::SetInterruptCallback(uint32_t callback,
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
cpu::Processor* processor() const { return processor_; }
|
||||
|
||||
virtual X_STATUS Setup();
|
||||
virtual void Shutdown();
|
||||
|
||||
void SetInterruptCallback(uint32_t callback, uint32_t user_data);
|
||||
void InitializeRingBuffer(uint32_t ptr, uint32_t page_count);
|
||||
@@ -51,7 +52,6 @@ public:
|
||||
protected:
|
||||
virtual void Initialize();
|
||||
virtual void Pump() = 0;
|
||||
virtual void Shutdown();
|
||||
|
||||
private:
|
||||
static void ThreadStartThunk(GraphicsSystem* this_ptr) {
|
||||
|
||||
@@ -26,10 +26,11 @@ public:
|
||||
NopGraphicsSystem(Emulator* emulator);
|
||||
virtual ~NopGraphicsSystem();
|
||||
|
||||
virtual void Shutdown();
|
||||
|
||||
protected:
|
||||
virtual void Initialize();
|
||||
virtual void Pump();
|
||||
virtual void Shutdown();
|
||||
|
||||
private:
|
||||
HANDLE timer_queue_;
|
||||
|
||||
Reference in New Issue
Block a user