mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-26 12:42:41 +01:00
d3d12: Remove D3DGSFrame
This commit is contained in:
parent
0138a95567
commit
ceab44b9ab
@ -33,13 +33,6 @@ static void unloadD3D12FunctionPointers()
|
||||
FreeLibrary(D3D11Module);
|
||||
}
|
||||
|
||||
GetGSFrameCb2 GetGSFrame = nullptr;
|
||||
|
||||
void SetGetD3DGSFrameCallback(GetGSFrameCb2 value)
|
||||
{
|
||||
GetGSFrame = value;
|
||||
}
|
||||
|
||||
void D3D12GSRender::ResourceStorage::Reset()
|
||||
{
|
||||
m_constantsBufferIndex = 0;
|
||||
@ -136,7 +129,7 @@ D3D12DLLManagement::~D3D12DLLManagement()
|
||||
}
|
||||
|
||||
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_b = 0;
|
||||
@ -174,13 +167,11 @@ D3D12GSRender::D3D12GSRender()
|
||||
g_descriptorStrideRTV = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
|
||||
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
|
||||
DXGI_SWAP_CHAIN_DESC swapChain = {};
|
||||
swapChain.BufferCount = 2;
|
||||
swapChain.Windowed = true;
|
||||
swapChain.OutputWindow = m_frame->getHandle();
|
||||
swapChain.OutputWindow = (HWND)m_frame->handle();
|
||||
swapChain.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
swapChain.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
swapChain.SampleDesc.Count = 1;
|
||||
@ -297,28 +288,6 @@ D3D12GSRender::~D3D12GSRender()
|
||||
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()
|
||||
{
|
||||
}
|
||||
@ -841,7 +810,7 @@ void D3D12GSRender::Flip()
|
||||
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();
|
||||
|
@ -41,28 +41,6 @@
|
||||
* 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>
|
||||
struct InitHeap
|
||||
{
|
||||
@ -470,7 +448,6 @@ private:
|
||||
u32 m_previous_address_d;
|
||||
u32 m_previous_address_z;
|
||||
public:
|
||||
GSFrameBase2 *m_frame;
|
||||
u32 m_draw_frames;
|
||||
u32 m_skip_frames;
|
||||
|
||||
@ -491,7 +468,6 @@ private:
|
||||
void InitD2DStructures();
|
||||
void ReleaseD2DStructures();
|
||||
ID3D12Resource *writeColorBuffer(ID3D12Resource *RTT, ID3D12GraphicsCommandList *cmdlist);
|
||||
virtual void Close() override;
|
||||
|
||||
bool LoadProgram();
|
||||
|
||||
@ -534,8 +510,6 @@ private:
|
||||
void renderOverlay();
|
||||
|
||||
protected:
|
||||
virtual void OnInit() override;
|
||||
virtual void OnInitThread() override;
|
||||
virtual void OnExitThread() override;
|
||||
virtual void OnReset() override;
|
||||
virtual void Clear(u32 cmd) override;
|
||||
|
@ -777,19 +777,15 @@ void DrawCursorObj::InitializeLocations()
|
||||
}
|
||||
|
||||
GLGSRender::GLGSRender()
|
||||
: GSRender()
|
||||
, m_frame(nullptr)
|
||||
: GSRender(frame_type::OpenGL)
|
||||
, m_fp_buf_num(-1)
|
||||
, m_vp_buf_num(-1)
|
||||
, m_context(nullptr)
|
||||
{
|
||||
m_frame = Emu.GetCallbacks().get_gs_frame().release();
|
||||
}
|
||||
|
||||
GLGSRender::~GLGSRender()
|
||||
{
|
||||
m_frame->Close();
|
||||
m_frame->DeleteContext(m_context);
|
||||
}
|
||||
|
||||
void GLGSRender::Enable(bool enable, const u32 cap)
|
||||
@ -806,20 +802,6 @@ void GLGSRender::Enable(bool enable, const u32 cap)
|
||||
|
||||
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)
|
||||
{
|
||||
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_skip_frames = 0;
|
||||
@ -1378,14 +1360,10 @@ void GLGSRender::OnInit()
|
||||
last_height = 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();
|
||||
|
||||
@ -2129,7 +2107,7 @@ void GLGSRender::Flip()
|
||||
m_post_draw_objs[i].Draw();
|
||||
}
|
||||
|
||||
m_frame->Flip(m_context);
|
||||
// m_frame->Flip(m_context);
|
||||
|
||||
// Restore scissor
|
||||
if (m_set_scissor_horizontal && m_set_scissor_vertical)
|
||||
|
@ -111,24 +111,6 @@ public:
|
||||
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
|
||||
{
|
||||
private:
|
||||
@ -154,7 +136,6 @@ private:
|
||||
void* m_context;
|
||||
|
||||
public:
|
||||
GSFrameBase* m_frame;
|
||||
u32 m_draw_frames;
|
||||
u32 m_skip_frames;
|
||||
bool is_intel_vendor;
|
||||
@ -169,7 +150,7 @@ private:
|
||||
void InitFragmentData();
|
||||
|
||||
void Enable(bool enable, const u32 cap);
|
||||
virtual void Close() override;
|
||||
|
||||
bool LoadProgram();
|
||||
void WriteBuffers();
|
||||
void WriteDepthBuffer();
|
||||
@ -183,8 +164,8 @@ private:
|
||||
void InitDrawBuffers();
|
||||
|
||||
protected:
|
||||
virtual void OnInit() override;
|
||||
virtual void OnInitThread() override;
|
||||
virtual void oninit() override;
|
||||
virtual void oninit_thread() override;
|
||||
virtual void OnExitThread() override;
|
||||
virtual void OnReset() override;
|
||||
virtual void Clear(u32 cmd) override;
|
||||
|
@ -48,7 +48,7 @@ void GSManager::Close()
|
||||
{
|
||||
if(m_render)
|
||||
{
|
||||
m_render->Close();
|
||||
m_render->close();
|
||||
delete m_render;
|
||||
m_render = nullptr;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
struct GSRender;
|
||||
class GSRender;
|
||||
|
||||
struct GSInfo
|
||||
{
|
||||
|
@ -5,6 +5,62 @@
|
||||
#include "GSManager.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)
|
||||
: m_renderer(renderer)
|
||||
, m_type(type)
|
||||
|
@ -1,13 +1,57 @@
|
||||
#pragma once
|
||||
#include "Emu/RSX/RSXThread.h"
|
||||
|
||||
struct GSRender : public RSXThread
|
||||
{
|
||||
virtual ~GSRender() override
|
||||
{
|
||||
}
|
||||
using draw_context_t = std::shared_ptr<void>;
|
||||
|
||||
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
|
||||
|
@ -5,7 +5,7 @@ class NullGSRender final : public GSRender
|
||||
{
|
||||
public:
|
||||
|
||||
NullGSRender()
|
||||
NullGSRender() : GSRender(frame_type::Null)
|
||||
{
|
||||
}
|
||||
|
||||
@ -14,11 +14,11 @@ public:
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
}
|
||||
|
@ -2493,7 +2493,7 @@ void RSXThread::Task()
|
||||
u8 inc;
|
||||
LOG_NOTICE(RSX, "RSX thread started");
|
||||
|
||||
OnInitThread();
|
||||
oninit_thread();
|
||||
|
||||
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();
|
||||
|
||||
OnInit();
|
||||
oninit();
|
||||
|
||||
start(WRAP_EXPR("RSXThread"), WRAP_EXPR(Task()));
|
||||
}
|
||||
|
@ -642,8 +642,8 @@ protected:
|
||||
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);
|
||||
|
||||
virtual void OnInit() = 0;
|
||||
virtual void OnInitThread() = 0;
|
||||
virtual void oninit() = 0;
|
||||
virtual void oninit_thread() = 0;
|
||||
virtual void OnExitThread() = 0;
|
||||
virtual void OnReset() = 0;
|
||||
|
||||
|
@ -11,7 +11,7 @@ struct EmuCallbacks
|
||||
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 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 SaveDialogBase>()> get_save_dialog;
|
||||
};
|
||||
|
@ -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
|
@ -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
|
@ -3,100 +3,51 @@
|
||||
#include "Emu/Memory/Memory.h"
|
||||
#include "Emu/System.h"
|
||||
#include "GLGSFrame.h"
|
||||
#include "D3DGSFrame.h"
|
||||
#include "Utilities/Timer.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#include "frame_icon.xpm"
|
||||
#endif
|
||||
|
||||
GLGSFrame::GLGSFrame()
|
||||
: GSFrame(nullptr, "GSFrame[OpenGL]")
|
||||
, m_frames(0)
|
||||
GLGSFrame::GLGSFrame() : GSFrame("OpenGL")
|
||||
{
|
||||
SetIcon(wxICON(frame_icon));
|
||||
canvas = new wxGLCanvas(this, wxID_ANY, NULL);
|
||||
canvas->SetSize(GetClientSize());
|
||||
m_canvas = new wxGLCanvas(this, wxID_ANY, NULL);
|
||||
m_canvas->SetSize(GetClientSize());
|
||||
|
||||
canvas->Bind(wxEVT_LEFT_DCLICK, &GSFrame::OnLeftDclick, this);
|
||||
m_canvas->Bind(wxEVT_LEFT_DCLICK, &GSFrame::OnLeftDclick, this);
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
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)
|
||||
void GLGSFrame::delete_context(void* ctx)
|
||||
{
|
||||
delete (wxGLContext*)ctx;
|
||||
}
|
||||
|
||||
void GLGSFrame::Flip(void* context)
|
||||
void GLGSFrame::flip(draw_context_t 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();
|
||||
}
|
||||
GSFrame::flip(context);
|
||||
if (!m_canvas) return;
|
||||
m_canvas->SetCurrent(*(wxGLContext*)context.get());
|
||||
m_canvas->SwapBuffers();
|
||||
}
|
||||
|
||||
void GLGSFrame::OnSize(wxSizeEvent& event)
|
||||
{
|
||||
if (canvas) canvas->SetSize(GetClientSize());
|
||||
if (m_canvas)
|
||||
m_canvas->SetSize(GetClientSize());
|
||||
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());
|
||||
*/
|
||||
}
|
@ -3,28 +3,18 @@
|
||||
#include "Gui/GSFrame.h"
|
||||
#include "wx/glcanvas.h"
|
||||
|
||||
struct GLGSFrame : public GSFrame, public GSFrameBase
|
||||
class GLGSFrame : public GSFrame
|
||||
{
|
||||
wxGLCanvas* canvas;
|
||||
wxGLCanvas* m_canvas;
|
||||
u32 m_frames;
|
||||
|
||||
public:
|
||||
GLGSFrame();
|
||||
~GLGSFrame();
|
||||
|
||||
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;
|
||||
|
||||
wxGLCanvas* GetCanvas() const { return canvas; }
|
||||
|
||||
virtual void SetViewport(int x, int y, u32 w, u32 h) override;
|
||||
virtual void* make_context() override;
|
||||
virtual void set_current(draw_context_t context) override;
|
||||
virtual void delete_context(void* ctx) override;
|
||||
virtual void flip(draw_context_t context) override;
|
||||
|
||||
private:
|
||||
virtual void OnSize(wxSizeEvent& event);
|
||||
|
@ -9,25 +9,7 @@ BEGIN_EVENT_TABLE(GSFrame, wxFrame)
|
||||
EVT_SIZE(GSFrame::OnSize)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
wxSize AspectRatio(wxSize rs, const wxSize as)
|
||||
{
|
||||
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)
|
||||
GSFrame::GSFrame(const wxString& title) : wxFrame(nullptr, wxID_ANY, title)
|
||||
{
|
||||
CellVideoOutResolution res = ResolutionTable[ResolutionIdToNum(Ini.GSResolution.GetValue())];
|
||||
SetClientSize(res.width, res.height);
|
||||
@ -73,13 +55,66 @@ void GSFrame::OnFullScreen()
|
||||
ShowFullScreen(!IsFullScreen());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void GSFrame::SetSize(int width, int height)
|
||||
void GSFrame::close()
|
||||
{
|
||||
m_size.SetWidth(width);
|
||||
m_size.SetHeight(height);
|
||||
//wxFrame::SetSize(width, height);
|
||||
OnSize(wxSizeEvent());
|
||||
wxFrame::Close();
|
||||
}
|
||||
*/
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
@ -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
|
||||
class GSFrame : public wxFrame, public GSFrameBase
|
||||
{
|
||||
protected:
|
||||
GSFrame(wxWindow* parent, const wxString& title);
|
||||
u64 m_frames;
|
||||
public:
|
||||
GSFrame(const wxString& title);
|
||||
|
||||
virtual void SetViewport(int x, int y, u32 w, u32 h) {}
|
||||
protected:
|
||||
virtual void OnPaint(wxPaintEvent& event);
|
||||
virtual void OnClose(wxCloseEvent& event);
|
||||
|
||||
//virtual void OnSize(wxSizeEvent&);
|
||||
|
||||
void OnKeyDown(wxKeyEvent& event);
|
||||
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:
|
||||
void OnLeftDclick(wxMouseEvent&)
|
||||
{
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "Gui/SaveDataDialog.h"
|
||||
|
||||
#include "Gui/GLGSFrame.h"
|
||||
#include "Gui/D3DGSFrame.h"
|
||||
#include <wx/stdpaths.h>
|
||||
|
||||
#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
|
||||
#if defined(DX12_SUPPORT)
|
||||
SetGetD3DGSFrameCallback([]() ->GSFrameBase2*
|
||||
{
|
||||
return new D3DGSFrame();
|
||||
});
|
||||
#endif
|
||||
case frame_type::DX12:
|
||||
return std::make_unique<GSFrame>("DirectX 12");
|
||||
|
||||
case frame_type::Null:
|
||||
return std::make_unique<GSFrame>("Null");
|
||||
}
|
||||
};
|
||||
|
||||
callbacks.get_msg_dialog = []() -> std::unique_ptr<MsgDialogBase>
|
||||
{
|
||||
|
@ -511,7 +511,6 @@
|
||||
<ClCompile Include="Gui\CgDisasm.cpp" />
|
||||
<ClCompile Include="Gui\CompilerELF.cpp" />
|
||||
<ClCompile Include="Gui\ConLogFrame.cpp" />
|
||||
<ClCompile Include="Gui\D3DGSFrame.cpp" />
|
||||
<ClCompile Include="Gui\Debugger.cpp" />
|
||||
<ClCompile Include="Gui\DisAsmFrame.cpp" />
|
||||
<ClCompile Include="Gui\GameViewer.cpp" />
|
||||
@ -561,7 +560,6 @@
|
||||
<ClInclude Include="Gui\CgDisasm.h" />
|
||||
<ClInclude Include="Gui\CompilerELF.h" />
|
||||
<ClInclude Include="Gui\ConLogFrame.h" />
|
||||
<ClInclude Include="Gui\D3DGSFrame.h" />
|
||||
<ClInclude Include="Gui\Debugger.h" />
|
||||
<ClInclude Include="Gui\DisAsmFrame.h" />
|
||||
<ClInclude Include="Gui\FrameBase.h" />
|
||||
|
@ -102,9 +102,6 @@
|
||||
<ClCompile Include="Gui\SaveDataDialog.cpp">
|
||||
<Filter>Gui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Gui\D3DGSFrame.cpp">
|
||||
<Filter>Gui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Gui\SettingsDialog.cpp">
|
||||
<Filter>Gui</Filter>
|
||||
</ClCompile>
|
||||
@ -216,9 +213,6 @@
|
||||
<Filter>Gui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="Gui\D3DGSFrame.h">
|
||||
<Filter>Gui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Gui\SettingsDialog.h">
|
||||
<Filter>Gui</Filter>
|
||||
</ClInclude>
|
||||
|
Loading…
Reference in New Issue
Block a user