d3d12: Remove D3DGSFrame

This commit is contained in:
Vincent Lejeune 2015-10-08 02:44:57 +02:00
parent 0138a95567
commit ceab44b9ab
21 changed files with 244 additions and 408 deletions

View File

@ -33,13 +33,6 @@ static void unloadD3D12FunctionPointers()
FreeLibrary(D3D11Module); FreeLibrary(D3D11Module);
} }
GetGSFrameCb2 GetGSFrame = nullptr;
void SetGetD3DGSFrameCallback(GetGSFrameCb2 value)
{
GetGSFrame = value;
}
void D3D12GSRender::ResourceStorage::Reset() void D3D12GSRender::ResourceStorage::Reset()
{ {
m_constantsBufferIndex = 0; m_constantsBufferIndex = 0;
@ -136,7 +129,7 @@ D3D12DLLManagement::~D3D12DLLManagement()
} }
D3D12GSRender::D3D12GSRender() D3D12GSRender::D3D12GSRender()
: GSRender(), m_D3D12Lib(), m_PSO(nullptr) : GSRender(frame_type::DX12), m_D3D12Lib(), m_PSO(nullptr)
{ {
m_previous_address_a = 0; m_previous_address_a = 0;
m_previous_address_b = 0; m_previous_address_b = 0;
@ -174,13 +167,11 @@ D3D12GSRender::D3D12GSRender()
g_descriptorStrideRTV = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV); g_descriptorStrideRTV = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
g_descriptorStrideSamplers = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); g_descriptorStrideSamplers = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
m_frame = GetGSFrame();
// Create swap chain and put them in a descriptor heap as rendertarget // Create swap chain and put them in a descriptor heap as rendertarget
DXGI_SWAP_CHAIN_DESC swapChain = {}; DXGI_SWAP_CHAIN_DESC swapChain = {};
swapChain.BufferCount = 2; swapChain.BufferCount = 2;
swapChain.Windowed = true; swapChain.Windowed = true;
swapChain.OutputWindow = m_frame->getHandle(); swapChain.OutputWindow = (HWND)m_frame->handle();
swapChain.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; swapChain.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
swapChain.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; swapChain.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChain.SampleDesc.Count = 1; swapChain.SampleDesc.Count = 1;
@ -297,28 +288,6 @@ D3D12GSRender::~D3D12GSRender()
ReleaseD2DStructures(); ReleaseD2DStructures();
} }
void D3D12GSRender::Close()
{
if (joinable())
{
join();
}
if (m_frame->IsShown())
{
m_frame->Hide();
}
}
void D3D12GSRender::OnInit()
{
m_frame->Show();
}
void D3D12GSRender::OnInitThread()
{
}
void D3D12GSRender::OnExitThread() void D3D12GSRender::OnExitThread()
{ {
} }
@ -841,7 +810,7 @@ void D3D12GSRender::Flip()
m_UAVHeap.m_getPos = newStorage.m_getPosUAVHeap; m_UAVHeap.m_getPos = newStorage.m_getPosUAVHeap;
} }
m_frame->Flip(nullptr); m_frame->flip(nullptr);
std::chrono::time_point<std::chrono::system_clock> flipEnd = std::chrono::system_clock::now(); std::chrono::time_point<std::chrono::system_clock> flipEnd = std::chrono::system_clock::now();

View File

@ -41,28 +41,6 @@
* are not currently correctly signaled which leads to deadlock. * are not currently correctly signaled which leads to deadlock.
*/ */
class GSFrameBase2
{
public:
GSFrameBase2() {}
GSFrameBase2(const GSFrameBase2&) = delete;
virtual void Close() = 0;
virtual bool IsShown() = 0;
virtual void Hide() = 0;
virtual void Show() = 0;
virtual void* GetNewContext() = 0;
virtual void SetCurrent(void* ctx) = 0;
virtual void DeleteContext(void* ctx) = 0;
virtual void Flip(void* ctx) = 0;
virtual HWND getHandle() const = 0;
};
typedef GSFrameBase2*(*GetGSFrameCb2)();
void SetGetD3DGSFrameCallback(GetGSFrameCb2 value);
template<typename T> template<typename T>
struct InitHeap struct InitHeap
{ {
@ -470,7 +448,6 @@ private:
u32 m_previous_address_d; u32 m_previous_address_d;
u32 m_previous_address_z; u32 m_previous_address_z;
public: public:
GSFrameBase2 *m_frame;
u32 m_draw_frames; u32 m_draw_frames;
u32 m_skip_frames; u32 m_skip_frames;
@ -491,7 +468,6 @@ private:
void InitD2DStructures(); void InitD2DStructures();
void ReleaseD2DStructures(); void ReleaseD2DStructures();
ID3D12Resource *writeColorBuffer(ID3D12Resource *RTT, ID3D12GraphicsCommandList *cmdlist); ID3D12Resource *writeColorBuffer(ID3D12Resource *RTT, ID3D12GraphicsCommandList *cmdlist);
virtual void Close() override;
bool LoadProgram(); bool LoadProgram();
@ -534,8 +510,6 @@ private:
void renderOverlay(); void renderOverlay();
protected: protected:
virtual void OnInit() override;
virtual void OnInitThread() override;
virtual void OnExitThread() override; virtual void OnExitThread() override;
virtual void OnReset() override; virtual void OnReset() override;
virtual void Clear(u32 cmd) override; virtual void Clear(u32 cmd) override;

View File

@ -777,19 +777,15 @@ void DrawCursorObj::InitializeLocations()
} }
GLGSRender::GLGSRender() GLGSRender::GLGSRender()
: GSRender() : GSRender(frame_type::OpenGL)
, m_frame(nullptr)
, m_fp_buf_num(-1) , m_fp_buf_num(-1)
, m_vp_buf_num(-1) , m_vp_buf_num(-1)
, m_context(nullptr) , m_context(nullptr)
{ {
m_frame = Emu.GetCallbacks().get_gs_frame().release();
} }
GLGSRender::~GLGSRender() GLGSRender::~GLGSRender()
{ {
m_frame->Close();
m_frame->DeleteContext(m_context);
} }
void GLGSRender::Enable(bool enable, const u32 cap) void GLGSRender::Enable(bool enable, const u32 cap)
@ -806,20 +802,6 @@ void GLGSRender::Enable(bool enable, const u32 cap)
extern CellGcmContextData current_context; extern CellGcmContextData current_context;
void GLGSRender::Close()
{
if (joinable())
{
join();
}
if (m_frame->IsShown())
{
m_frame->Hide();
}
m_ctrl = nullptr;
}
void GLGSRender::EnableVertexData(bool indexed_draw) void GLGSRender::EnableVertexData(bool indexed_draw)
{ {
static u32 offset_list[m_vertex_count]; static u32 offset_list[m_vertex_count];
@ -1365,7 +1347,7 @@ void GLGSRender::WriteColorBuffers()
} }
} }
void GLGSRender::OnInit() void GLGSRender::oninit()
{ {
m_draw_frames = 1; m_draw_frames = 1;
m_skip_frames = 0; m_skip_frames = 0;
@ -1378,14 +1360,10 @@ void GLGSRender::OnInit()
last_height = 0; last_height = 0;
last_depth_format = 0; last_depth_format = 0;
m_frame->Show();
} }
void GLGSRender::OnInitThread() void GLGSRender::oninit_thread()
{ {
m_context = m_frame->GetNewContext();
m_frame->SetCurrent(m_context);
InitProcTable(); InitProcTable();
@ -2129,7 +2107,7 @@ void GLGSRender::Flip()
m_post_draw_objs[i].Draw(); m_post_draw_objs[i].Draw();
} }
m_frame->Flip(m_context); // m_frame->Flip(m_context);
// Restore scissor // Restore scissor
if (m_set_scissor_horizontal && m_set_scissor_vertical) if (m_set_scissor_horizontal && m_set_scissor_vertical)

View File

@ -111,24 +111,6 @@ public:
void InitializeLocations(); void InitializeLocations();
}; };
class GSFrameBase
{
public:
GSFrameBase() {}
GSFrameBase(const GSFrameBase&) = delete;
virtual void Close() = 0;
virtual bool IsShown() = 0;
virtual void Hide() = 0;
virtual void Show() = 0;
virtual void* GetNewContext() = 0;
virtual void SetCurrent(void* ctx) = 0;
virtual void DeleteContext(void* ctx) = 0;
virtual void Flip(void* ctx) = 0;
};
class GLGSRender final : public GSRender class GLGSRender final : public GSRender
{ {
private: private:
@ -154,7 +136,6 @@ private:
void* m_context; void* m_context;
public: public:
GSFrameBase* m_frame;
u32 m_draw_frames; u32 m_draw_frames;
u32 m_skip_frames; u32 m_skip_frames;
bool is_intel_vendor; bool is_intel_vendor;
@ -169,7 +150,7 @@ private:
void InitFragmentData(); void InitFragmentData();
void Enable(bool enable, const u32 cap); void Enable(bool enable, const u32 cap);
virtual void Close() override;
bool LoadProgram(); bool LoadProgram();
void WriteBuffers(); void WriteBuffers();
void WriteDepthBuffer(); void WriteDepthBuffer();
@ -183,8 +164,8 @@ private:
void InitDrawBuffers(); void InitDrawBuffers();
protected: protected:
virtual void OnInit() override; virtual void oninit() override;
virtual void OnInitThread() override; virtual void oninit_thread() override;
virtual void OnExitThread() override; virtual void OnExitThread() override;
virtual void OnReset() override; virtual void OnReset() override;
virtual void Clear(u32 cmd) override; virtual void Clear(u32 cmd) override;

View File

@ -48,7 +48,7 @@ void GSManager::Close()
{ {
if(m_render) if(m_render)
{ {
m_render->Close(); m_render->close();
delete m_render; delete m_render;
m_render = nullptr; m_render = nullptr;
} }

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
struct GSRender; class GSRender;
struct GSInfo struct GSInfo
{ {

View File

@ -5,6 +5,62 @@
#include "GSManager.h" #include "GSManager.h"
#include "GSRender.h" #include "GSRender.h"
draw_context_t GSFrameBase::new_context()
{
return std::shared_ptr<void>(make_context(), [this](void* ctxt) { delete_context(ctxt); });
}
GSRender::GSRender(frame_type type) : m_frame(Emu.GetCallbacks().get_gs_frame(type).release())
{
}
GSRender::~GSRender()
{
m_context = nullptr;
if (m_frame)
{
m_frame->close();
}
}
void GSRender::oninit()
{
if (m_frame)
{
m_frame->show();
}
}
void GSRender::oninit_thread()
{
if (m_frame)
{
m_context = m_frame->new_context();
m_frame->set_current(m_context);
}
}
void GSRender::close()
{
if (m_frame && m_frame->shown())
{
m_frame->hide();
}
if (joinable())
{
join();
}
}
void GSRender::Flip()
{
if (m_frame)
m_frame->flip(m_context);
}
GSLock::GSLock(GSRender& renderer, GSLockType type) GSLock::GSLock(GSRender& renderer, GSLockType type)
: m_renderer(renderer) : m_renderer(renderer)
, m_type(type) , m_type(type)

View File

@ -1,13 +1,57 @@
#pragma once #pragma once
#include "Emu/RSX/RSXThread.h" #include "Emu/RSX/RSXThread.h"
struct GSRender : public RSXThread using draw_context_t = std::shared_ptr<void>;
{
virtual ~GSRender() override
{
}
virtual void Close()=0; class GSFrameBase
{
protected:
std::wstring m_title_message;
public:
GSFrameBase() = default;
GSFrameBase(const GSFrameBase&) = delete;
virtual void close() = 0;
virtual bool shown() = 0;
virtual void hide() = 0;
virtual void show() = 0;
draw_context_t new_context();
virtual void set_current(draw_context_t ctx) = 0;
virtual void flip(draw_context_t ctx) = 0;
virtual void* handle() const = 0;
void title_message(const std::wstring&);
protected:
virtual void delete_context(void* ctx) = 0;
virtual void* make_context() = 0;
};
enum class frame_type
{
Null,
OpenGL,
DX12
};
class GSRender : public RSXThread
{
protected:
GSFrameBase* m_frame;
draw_context_t m_context;
public:
GSRender(frame_type type);
virtual ~GSRender();
void oninit() override;
void oninit_thread() override;
void close();
void Flip() override;
}; };
enum GSLockType enum GSLockType

View File

@ -5,7 +5,7 @@ class NullGSRender final : public GSRender
{ {
public: public:
NullGSRender() NullGSRender() : GSRender(frame_type::Null)
{ {
} }
@ -14,11 +14,11 @@ public:
} }
private: private:
virtual void OnInit() override virtual void oninit() override
{ {
} }
virtual void OnInitThread() override virtual void oninit_thread() override
{ {
} }
@ -42,14 +42,6 @@ private:
{ {
} }
virtual void Close() override
{
if (joinable())
{
join();
}
}
virtual void semaphorePGRAPHTextureReadRelease(u32 offset, u32 value) override virtual void semaphorePGRAPHTextureReadRelease(u32 offset, u32 value) override
{ {
} }

View File

@ -2493,7 +2493,7 @@ void RSXThread::Task()
u8 inc; u8 inc;
LOG_NOTICE(RSX, "RSX thread started"); LOG_NOTICE(RSX, "RSX thread started");
OnInitThread(); oninit_thread();
m_last_flip_time = get_system_time() - 1000000; m_last_flip_time = get_system_time() - 1000000;
@ -2613,7 +2613,7 @@ void RSXThread::Init(const u32 ioAddress, const u32 ioSize, const u32 ctrlAddres
m_used_gcm_commands.clear(); m_used_gcm_commands.clear();
OnInit(); oninit();
start(WRAP_EXPR("RSXThread"), WRAP_EXPR(Task())); start(WRAP_EXPR("RSXThread"), WRAP_EXPR(Task()));
} }

View File

@ -642,8 +642,8 @@ protected:
u32 OutOfArgsCount(const uint x, const u32 cmd, const u32 count, const u32 args_addr); u32 OutOfArgsCount(const uint x, const u32 cmd, const u32 count, const u32 args_addr);
void DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const u32 count); void DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const u32 count);
virtual void OnInit() = 0; virtual void oninit() = 0;
virtual void OnInitThread() = 0; virtual void oninit_thread() = 0;
virtual void OnExitThread() = 0; virtual void OnExitThread() = 0;
virtual void OnReset() = 0; virtual void OnReset() = 0;

View File

@ -11,7 +11,7 @@ struct EmuCallbacks
std::function<std::unique_ptr<class KeyboardHandlerBase>()> get_kb_handler; std::function<std::unique_ptr<class KeyboardHandlerBase>()> get_kb_handler;
std::function<std::unique_ptr<class MouseHandlerBase>()> get_mouse_handler; std::function<std::unique_ptr<class MouseHandlerBase>()> get_mouse_handler;
std::function<std::unique_ptr<class PadHandlerBase>()> get_pad_handler; std::function<std::unique_ptr<class PadHandlerBase>()> get_pad_handler;
std::function<std::unique_ptr<class GSFrameBase>()> get_gs_frame; std::function<std::unique_ptr<class GSFrameBase>(enum class frame_type)> get_gs_frame;
std::function<std::unique_ptr<class MsgDialogBase>()> get_msg_dialog; std::function<std::unique_ptr<class MsgDialogBase>()> get_msg_dialog;
std::function<std::unique_ptr<class SaveDialogBase>()> get_save_dialog; std::function<std::unique_ptr<class SaveDialogBase>()> get_save_dialog;
}; };

View File

@ -1,103 +0,0 @@
#include "stdafx_gui.h"
#if defined(DX12_SUPPORT)
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "D3DGSFrame.h"
#include "Utilities/Timer.h"
D3DGSFrame::D3DGSFrame()
: GSFrame(nullptr, "GSFrame[DirectX 12]")
, m_frames(0)
{
SetIcon(wxICON(frame_icon));
canvas = new wxWindow(this, wxID_ANY);
canvas->SetSize(GetClientSize());
canvas->Bind(wxEVT_LEFT_DCLICK, &GSFrame::OnLeftDclick, this);
}
D3DGSFrame::~D3DGSFrame()
{
}
void D3DGSFrame::Close()
{
GSFrame::Close();
}
bool D3DGSFrame::IsShown()
{
return GSFrame::IsShown();
}
void D3DGSFrame::Hide()
{
GSFrame::Hide();
}
void D3DGSFrame::Show()
{
GSFrame::Show();
}
void* D3DGSFrame::GetNewContext()
{
return nullptr;//new wxGLContext(GetCanvas());
}
void D3DGSFrame::SetCurrent(void* ctx)
{
// GetCanvas()->SetCurrent(*(wxGLContext*)ctx);
}
void D3DGSFrame::DeleteContext(void* ctx)
{
// delete (wxGLContext*)ctx;
}
void D3DGSFrame::Flip(void* context)
{
if (!canvas) return;
// canvas->SetCurrent(*(wxGLContext*)context);
static Timer fps_t;
// canvas->SwapBuffers();
m_frames++;
const std::string sub_title = Emu.GetTitle() + (Emu.GetTitleID().length() ? " [" + Emu.GetTitleID() + "] | " : " | ") + " | ";
if (fps_t.GetElapsedTimeInSec() >= 0.5)
{
// can freeze on exit
SetTitle(wxString(sub_title.c_str(), wxConvUTF8) + wxString::Format("FPS: %.2f", (double)m_frames / fps_t.GetElapsedTimeInSec()));
m_frames = 0;
fps_t.Start();
}
}
void D3DGSFrame::OnSize(wxSizeEvent& event)
{
if (canvas) canvas->SetSize(GetClientSize());
event.Skip();
}
void D3DGSFrame::SetViewport(int x, int y, u32 w, u32 h)
{
/*
//ConLog.Warning("SetViewport(x=%d, y=%d, w=%d, h=%d)", x, y, w, h);
const wxSize client = GetClientSize();
const wxSize viewport = AspectRatio(client, wxSize(w, h));
const int vx = (client.GetX() - viewport.GetX()) / 2;
const int vy = (client.GetY() - viewport.GetY()) / 2;
glViewport(vx + x, vy + y, viewport.GetWidth(), viewport.GetHeight());
*/
}
HWND D3DGSFrame::getHandle() const
{
return canvas->GetHandle();
}
#endif

View File

@ -1,36 +0,0 @@
#pragma once
#if defined(DX12_SUPPORT)
#include "Emu/RSX/D3D12/D3D12GSRender.h"
#include "Gui/GSFrame.h"
#include "wx/window.h"
struct D3DGSFrame : public GSFrame, public GSFrameBase2
{
wxWindow* canvas;
u32 m_frames;
D3DGSFrame();
~D3DGSFrame();
virtual void Close() override;
virtual bool IsShown() override;
virtual void Hide() override;
virtual void Show() override;
virtual void* GetNewContext() override;
virtual void SetCurrent(void* ctx) override;
virtual void DeleteContext(void* ctx) override;
virtual void Flip(void* context) override;
wxWindow* GetCanvas() const { return canvas; }
virtual void SetViewport(int x, int y, u32 w, u32 h) override;
virtual HWND getHandle() const override;
private:
virtual void OnSize(wxSizeEvent& event);
};
#endif

View File

@ -3,100 +3,51 @@
#include "Emu/Memory/Memory.h" #include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "GLGSFrame.h" #include "GLGSFrame.h"
#include "D3DGSFrame.h"
#include "Utilities/Timer.h" #include "Utilities/Timer.h"
#ifndef _WIN32 #ifndef _WIN32
#include "frame_icon.xpm" #include "frame_icon.xpm"
#endif #endif
GLGSFrame::GLGSFrame() GLGSFrame::GLGSFrame() : GSFrame("OpenGL")
: GSFrame(nullptr, "GSFrame[OpenGL]")
, m_frames(0)
{ {
SetIcon(wxICON(frame_icon)); SetIcon(wxICON(frame_icon));
canvas = new wxGLCanvas(this, wxID_ANY, NULL); m_canvas = new wxGLCanvas(this, wxID_ANY, NULL);
canvas->SetSize(GetClientSize()); m_canvas->SetSize(GetClientSize());
canvas->Bind(wxEVT_LEFT_DCLICK, &GSFrame::OnLeftDclick, this); m_canvas->Bind(wxEVT_LEFT_DCLICK, &GSFrame::OnLeftDclick, this);
} }
GLGSFrame::~GLGSFrame() GLGSFrame::~GLGSFrame()
{ {
} }
void GLGSFrame::Close() void* GLGSFrame::make_context()
{ {
GSFrame::Close(); return new wxGLContext(m_canvas);
} }
bool GLGSFrame::IsShown() void GLGSFrame::set_current(draw_context_t ctx)
{ {
return GSFrame::IsShown(); m_canvas->SetCurrent(*(wxGLContext*)ctx.get());
} }
void GLGSFrame::Hide() void GLGSFrame::delete_context(void* ctx)
{
GSFrame::Hide();
}
void GLGSFrame::Show()
{
GSFrame::Show();
}
void* GLGSFrame::GetNewContext()
{
return new wxGLContext(GetCanvas());
}
void GLGSFrame::SetCurrent(void* ctx)
{
GetCanvas()->SetCurrent(*(wxGLContext*)ctx);
}
void GLGSFrame::DeleteContext(void* ctx)
{ {
delete (wxGLContext*)ctx; delete (wxGLContext*)ctx;
} }
void GLGSFrame::Flip(void* context) void GLGSFrame::flip(draw_context_t context)
{ {
if (!canvas) return; GSFrame::flip(context);
canvas->SetCurrent(*(wxGLContext*)context); if (!m_canvas) return;
m_canvas->SetCurrent(*(wxGLContext*)context.get());
static Timer fps_t; m_canvas->SwapBuffers();
canvas->SwapBuffers();
m_frames++;
const std::string sub_title = Emu.GetTitle() + (Emu.GetTitleID().length() ? " [" + Emu.GetTitleID() + "] | " : " | ");
if (fps_t.GetElapsedTimeInSec() >= 0.5)
{
// can freeze on exit
SetTitle(wxString(sub_title.c_str(), wxConvUTF8) + wxString::Format("FPS: %.2f", (double)m_frames / fps_t.GetElapsedTimeInSec()));
m_frames = 0;
fps_t.Start();
}
} }
void GLGSFrame::OnSize(wxSizeEvent& event) void GLGSFrame::OnSize(wxSizeEvent& event)
{ {
if (canvas) canvas->SetSize(GetClientSize()); if (m_canvas)
m_canvas->SetSize(GetClientSize());
event.Skip(); event.Skip();
}
void GLGSFrame::SetViewport(int x, int y, u32 w, u32 h)
{
/*
//ConLog.Warning("SetViewport(x=%d, y=%d, w=%d, h=%d)", x, y, w, h);
const wxSize client = GetClientSize();
const wxSize viewport = AspectRatio(client, wxSize(w, h));
const int vx = (client.GetX() - viewport.GetX()) / 2;
const int vy = (client.GetY() - viewport.GetY()) / 2;
glViewport(vx + x, vy + y, viewport.GetWidth(), viewport.GetHeight());
*/
} }

View File

@ -3,28 +3,18 @@
#include "Gui/GSFrame.h" #include "Gui/GSFrame.h"
#include "wx/glcanvas.h" #include "wx/glcanvas.h"
struct GLGSFrame : public GSFrame, public GSFrameBase class GLGSFrame : public GSFrame
{ {
wxGLCanvas* canvas; wxGLCanvas* m_canvas;
u32 m_frames; u32 m_frames;
public:
GLGSFrame(); GLGSFrame();
~GLGSFrame(); ~GLGSFrame();
virtual void Close() override; virtual void* make_context() override;
virtual void set_current(draw_context_t context) override;
virtual bool IsShown() override; virtual void delete_context(void* ctx) override;
virtual void Hide() override; virtual void flip(draw_context_t context) override;
virtual void Show() override;
virtual void* GetNewContext() override;
virtual void SetCurrent(void* ctx) override;
virtual void DeleteContext(void* ctx) override;
virtual void Flip(void* context) override;
wxGLCanvas* GetCanvas() const { return canvas; }
virtual void SetViewport(int x, int y, u32 w, u32 h) override;
private: private:
virtual void OnSize(wxSizeEvent& event); virtual void OnSize(wxSizeEvent& event);

View File

@ -9,25 +9,7 @@ BEGIN_EVENT_TABLE(GSFrame, wxFrame)
EVT_SIZE(GSFrame::OnSize) EVT_SIZE(GSFrame::OnSize)
END_EVENT_TABLE() END_EVENT_TABLE()
wxSize AspectRatio(wxSize rs, const wxSize as) GSFrame::GSFrame(const wxString& title) : wxFrame(nullptr, wxID_ANY, title)
{
const double aq = (double)as.x / as.y;
const double rq = (double)rs.x / rs.y;
const double q = aq / rq;
if (q > 1.0)
{
rs.y /= q;
}
else if (q < 1.0)
{
rs.x *= q;
}
return rs;
}
GSFrame::GSFrame(wxWindow* parent, const wxString& title) : wxFrame(parent, wxID_ANY, title)
{ {
CellVideoOutResolution res = ResolutionTable[ResolutionIdToNum(Ini.GSResolution.GetValue())]; CellVideoOutResolution res = ResolutionTable[ResolutionIdToNum(Ini.GSResolution.GetValue())];
SetClientSize(res.width, res.height); SetClientSize(res.width, res.height);
@ -73,13 +55,66 @@ void GSFrame::OnFullScreen()
ShowFullScreen(!IsFullScreen()); ShowFullScreen(!IsFullScreen());
} }
void GSFrame::close()
/*
void GSFrame::SetSize(int width, int height)
{ {
m_size.SetWidth(width); wxFrame::Close();
m_size.SetHeight(height);
//wxFrame::SetSize(width, height);
OnSize(wxSizeEvent());
} }
*/
bool GSFrame::shown()
{
return wxFrame::IsShown();
}
void GSFrame::hide()
{
wxFrame::Hide();
}
void GSFrame::show()
{
wxFrame::Show();
}
void* GSFrame::handle() const
{
return GetHandle();
}
void* GSFrame::make_context()
{
return nullptr;
}
void GSFrame::set_current(draw_context_t ctx)
{
}
void GSFrame::delete_context(void* ctx)
{
}
void GSFrame::flip(draw_context_t)
{
++m_frames;
static Timer fps_t;
if (fps_t.GetElapsedTimeInSec() >= 0.5)
{
std::string title = fmt::format("FPS: %.2f", (double)m_frames / fps_t.GetElapsedTimeInSec());
if (!m_title_message.empty())
title += " | " + m_title_message;
if (!Emu.GetTitle().empty())
title += " | " + Emu.GetTitle();
if (!Emu.GetTitleID().empty())
title += " | [" + Emu.GetTitleID() + "]";
// can freeze on exit
SetTitle(wxString(title.c_str(), wxConvUTF8));
m_frames = 0;
fps_t.Start();
}
}

View File

@ -1,21 +1,33 @@
#pragma once #pragma once
#include "Emu/Memory/vm.h"
#include "Emu/RSX/GSRender.h"
wxSize AspectRatio(wxSize rs, const wxSize as); class GSFrame : public wxFrame, public GSFrameBase
class GSFrame : public wxFrame
{ {
protected: u64 m_frames;
GSFrame(wxWindow* parent, const wxString& title); public:
GSFrame(const wxString& title);
virtual void SetViewport(int x, int y, u32 w, u32 h) {} protected:
virtual void OnPaint(wxPaintEvent& event); virtual void OnPaint(wxPaintEvent& event);
virtual void OnClose(wxCloseEvent& event); virtual void OnClose(wxCloseEvent& event);
//virtual void OnSize(wxSizeEvent&);
void OnKeyDown(wxKeyEvent& event); void OnKeyDown(wxKeyEvent& event);
void OnFullScreen(); void OnFullScreen();
void close() override;
bool shown() override;
void hide() override;
void show() override;
void* handle() const override;
void* make_context() override;
void set_current(draw_context_t context) override;
void delete_context(void* context) override;
void flip(draw_context_t context) override;
public: public:
void OnLeftDclick(wxMouseEvent&) void OnLeftDclick(wxMouseEvent&)
{ {

View File

@ -26,7 +26,6 @@
#include "Gui/SaveDataDialog.h" #include "Gui/SaveDataDialog.h"
#include "Gui/GLGSFrame.h" #include "Gui/GLGSFrame.h"
#include "Gui/D3DGSFrame.h"
#include <wx/stdpaths.h> #include <wx/stdpaths.h>
#ifdef _WIN32 #ifdef _WIN32
@ -112,18 +111,20 @@ bool Rpcs3App::OnInit()
} }
}; };
callbacks.get_gs_frame = []() -> std::unique_ptr<GSFrameBase> callbacks.get_gs_frame = [](frame_type type) -> std::unique_ptr<GSFrameBase>
{ {
return std::make_unique<GLGSFrame>(); switch (type)
}; {
case frame_type::OpenGL:
return std::make_unique<GLGSFrame>();
// TODO: unify with get_gs_frame callback case frame_type::DX12:
#if defined(DX12_SUPPORT) return std::make_unique<GSFrame>("DirectX 12");
SetGetD3DGSFrameCallback([]() ->GSFrameBase2*
{ case frame_type::Null:
return new D3DGSFrame(); return std::make_unique<GSFrame>("Null");
}); }
#endif };
callbacks.get_msg_dialog = []() -> std::unique_ptr<MsgDialogBase> callbacks.get_msg_dialog = []() -> std::unique_ptr<MsgDialogBase>
{ {

View File

@ -511,7 +511,6 @@
<ClCompile Include="Gui\CgDisasm.cpp" /> <ClCompile Include="Gui\CgDisasm.cpp" />
<ClCompile Include="Gui\CompilerELF.cpp" /> <ClCompile Include="Gui\CompilerELF.cpp" />
<ClCompile Include="Gui\ConLogFrame.cpp" /> <ClCompile Include="Gui\ConLogFrame.cpp" />
<ClCompile Include="Gui\D3DGSFrame.cpp" />
<ClCompile Include="Gui\Debugger.cpp" /> <ClCompile Include="Gui\Debugger.cpp" />
<ClCompile Include="Gui\DisAsmFrame.cpp" /> <ClCompile Include="Gui\DisAsmFrame.cpp" />
<ClCompile Include="Gui\GameViewer.cpp" /> <ClCompile Include="Gui\GameViewer.cpp" />
@ -561,7 +560,6 @@
<ClInclude Include="Gui\CgDisasm.h" /> <ClInclude Include="Gui\CgDisasm.h" />
<ClInclude Include="Gui\CompilerELF.h" /> <ClInclude Include="Gui\CompilerELF.h" />
<ClInclude Include="Gui\ConLogFrame.h" /> <ClInclude Include="Gui\ConLogFrame.h" />
<ClInclude Include="Gui\D3DGSFrame.h" />
<ClInclude Include="Gui\Debugger.h" /> <ClInclude Include="Gui\Debugger.h" />
<ClInclude Include="Gui\DisAsmFrame.h" /> <ClInclude Include="Gui\DisAsmFrame.h" />
<ClInclude Include="Gui\FrameBase.h" /> <ClInclude Include="Gui\FrameBase.h" />

View File

@ -102,9 +102,6 @@
<ClCompile Include="Gui\SaveDataDialog.cpp"> <ClCompile Include="Gui\SaveDataDialog.cpp">
<Filter>Gui</Filter> <Filter>Gui</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Gui\D3DGSFrame.cpp">
<Filter>Gui</Filter>
</ClCompile>
<ClCompile Include="Gui\SettingsDialog.cpp"> <ClCompile Include="Gui\SettingsDialog.cpp">
<Filter>Gui</Filter> <Filter>Gui</Filter>
</ClCompile> </ClCompile>
@ -216,9 +213,6 @@
<Filter>Gui</Filter> <Filter>Gui</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="resource.h" /> <ClInclude Include="resource.h" />
<ClInclude Include="Gui\D3DGSFrame.h">
<Filter>Gui</Filter>
</ClInclude>
<ClInclude Include="Gui\SettingsDialog.h"> <ClInclude Include="Gui\SettingsDialog.h">
<Filter>Gui</Filter> <Filter>Gui</Filter>
</ClInclude> </ClInclude>