mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-21 12:05:23 +00:00
d3d12: Create window
This commit is contained in:
parent
976d707596
commit
0b5816d6d6
8 changed files with 181 additions and 6 deletions
|
@ -3,6 +3,13 @@
|
|||
#include <wrl/client.h>
|
||||
#include <dxgi1_4.h>
|
||||
|
||||
GetGSFrameCb2 GetGSFrame = nullptr;
|
||||
|
||||
void SetGetD3DGSFrameCallback(GetGSFrameCb2 value)
|
||||
{
|
||||
GetGSFrame = value;
|
||||
}
|
||||
|
||||
static void check(HRESULT hr)
|
||||
{
|
||||
if (hr != 0)
|
||||
|
@ -30,6 +37,9 @@ D3D12GSRender::D3D12GSRender()
|
|||
graphicQueueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
|
||||
check(m_device->CreateCommandQueue(©QueueDesc, IID_PPV_ARGS(&m_commandQueueCopy)));
|
||||
check(m_device->CreateCommandQueue(&graphicQueueDesc, IID_PPV_ARGS(&m_commandQueueGraphic)));
|
||||
|
||||
GSFrameBase2 *tmp = GetGSFrame();
|
||||
tmp->Show();
|
||||
}
|
||||
|
||||
D3D12GSRender::~D3D12GSRender()
|
||||
|
@ -47,15 +57,15 @@ void D3D12GSRender::Close()
|
|||
|
||||
void D3D12GSRender::InitDrawBuffers()
|
||||
{
|
||||
// if (!m_fbo.IsCreated() || RSXThread::m_width != last_width || RSXThread::m_height != last_height || last_depth_format != m_surface_depth_format)
|
||||
if (!m_fbo.IsCreated() || RSXThread::m_width != m_lastWidth || RSXThread::m_height != m_lastHeight || m_lastDepth != m_surface_depth_format)
|
||||
{
|
||||
/*
|
||||
|
||||
LOG_WARNING(RSX, "New FBO (%dx%d)", RSXThread::m_width, RSXThread::m_height);
|
||||
last_width = RSXThread::m_width;
|
||||
last_height = RSXThread::m_height;
|
||||
last_depth_format = m_surface_depth_format;
|
||||
m_lastWidth = RSXThread::m_width;
|
||||
m_lastHeight = RSXThread::m_height;
|
||||
m_lastDepth = m_surface_depth_format;
|
||||
|
||||
m_fbo.Create();
|
||||
/* m_fbo.Create();
|
||||
checkForGlError("m_fbo.Create");
|
||||
m_fbo.Bind();
|
||||
|
||||
|
|
|
@ -16,6 +16,28 @@
|
|||
#pragma comment (lib, "dxgi.lib")
|
||||
#pragma comment (lib, "d3dcompiler.lib")
|
||||
|
||||
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;
|
||||
|
||||
};
|
||||
|
||||
typedef GSFrameBase2*(*GetGSFrameCb2)();
|
||||
|
||||
void SetGetD3DGSFrameCallback(GetGSFrameCb2 value);
|
||||
|
||||
|
||||
class D3D12GSRender //TODO: find out why this used to inherit from wxWindow
|
||||
: //public wxWindow
|
||||
|
@ -44,6 +66,8 @@ private:
|
|||
ID3D12CommandQueue *m_commandQueueCopy;
|
||||
ID3D12CommandQueue *m_commandQueueGraphic;
|
||||
|
||||
size_t m_lastWidth, m_lastHeight, m_lastDepth;
|
||||
|
||||
void* m_context;
|
||||
|
||||
public:
|
||||
|
|
95
rpcs3/Gui/D3DGSFrame.cpp
Normal file
95
rpcs3/Gui/D3DGSFrame.cpp
Normal file
|
@ -0,0 +1,95 @@
|
|||
#include "stdafx_gui.h"
|
||||
#include "Emu/Memory/Memory.h"
|
||||
#include "Emu/System.h"
|
||||
#include "D3DGSFrame.h"
|
||||
#include "Utilities/Timer.h"
|
||||
|
||||
D3DGSFrame::D3DGSFrame()
|
||||
: GSFrame(nullptr, "GSFrame[OpenGL]")
|
||||
, m_frames(0)
|
||||
{
|
||||
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());
|
||||
*/
|
||||
}
|
31
rpcs3/Gui/D3DGSFrame.h
Normal file
31
rpcs3/Gui/D3DGSFrame.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
#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);
|
||||
|
||||
private:
|
||||
virtual void OnSize(wxSizeEvent& event);
|
||||
};
|
|
@ -3,6 +3,7 @@
|
|||
#include "Emu/Memory/Memory.h"
|
||||
#include "Emu/System.h"
|
||||
#include "GLGSFrame.h"
|
||||
#include "D3DGSFrame.h"
|
||||
#include "Utilities/Timer.h"
|
||||
|
||||
GLGSFrame::GLGSFrame()
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "Gui/SaveDataDialog.h"
|
||||
|
||||
#include "Gui/GLGSFrame.h"
|
||||
#include "Gui/D3DGSFrame.h"
|
||||
#include <wx/stdpaths.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -137,6 +138,11 @@ bool Rpcs3App::OnInit()
|
|||
return new GLGSFrame();
|
||||
});
|
||||
|
||||
SetGetD3DGSFrameCallback([]() ->GSFrameBase2*
|
||||
{
|
||||
return new D3DGSFrame();
|
||||
});
|
||||
|
||||
g_msg_dialog.reset(new MsgDialogFrame);
|
||||
g_savedata_dialog.reset(new SaveDataDialogFrame);
|
||||
|
||||
|
|
|
@ -177,6 +177,7 @@
|
|||
<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" />
|
||||
|
@ -218,6 +219,7 @@
|
|||
<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,6 +102,9 @@
|
|||
<ClCompile Include="Gui\SaveDataDialog.cpp">
|
||||
<Filter>Gui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Gui\D3DGSFrame.cpp">
|
||||
<Filter>Gui</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="rpcs3.rc" />
|
||||
|
@ -207,6 +210,9 @@
|
|||
<Filter>Gui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="Gui\D3DGSFrame.h">
|
||||
<Filter>Gui</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="rpcs3.ico" />
|
||||
|
|
Loading…
Add table
Reference in a new issue