No need to render black when paused
This commit is contained in:
52
external/parallel-rdp/ParallelRDPWrapper.cpp
vendored
52
external/parallel-rdp/ParallelRDPWrapper.cpp
vendored
@@ -1,14 +1,12 @@
|
|||||||
|
#include <File.hpp>
|
||||||
#include <ParallelRDPWrapper.hpp>
|
#include <ParallelRDPWrapper.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <rdp_device.hpp>
|
#include <rdp_device.hpp>
|
||||||
#include <File.hpp>
|
|
||||||
|
|
||||||
using namespace Vulkan;
|
using namespace Vulkan;
|
||||||
using namespace RDP;
|
using namespace RDP;
|
||||||
|
|
||||||
bool ParallelRDP::IsFramerateUnlocked() {
|
bool ParallelRDP::IsFramerateUnlocked() { return wsi->get_present_mode() != PresentMode::SyncToVBlank; }
|
||||||
return wsi->get_present_mode() != PresentMode::SyncToVBlank;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParallelRDP::SetFramerateUnlocked(bool unlocked) {
|
void ParallelRDP::SetFramerateUnlocked(bool unlocked) {
|
||||||
if (unlocked) {
|
if (unlocked) {
|
||||||
@@ -20,7 +18,9 @@ void ParallelRDP::SetFramerateUnlocked(bool unlocked) {
|
|||||||
|
|
||||||
Program *fullscreen_quad_program;
|
Program *fullscreen_quad_program;
|
||||||
|
|
||||||
void ParallelRDP::LoadWSIPlatform(const std::shared_ptr<Vulkan::InstanceFactory>& instanceFactory, const std::shared_ptr<Vulkan::WSIPlatform>& wsi_platform, const std::shared_ptr<ParallelRDP::WindowInfo>& newWindowInfo) {
|
void ParallelRDP::LoadWSIPlatform(const std::shared_ptr<Vulkan::InstanceFactory> &instanceFactory,
|
||||||
|
const std::shared_ptr<Vulkan::WSIPlatform> &wsi_platform,
|
||||||
|
const std::shared_ptr<ParallelRDP::WindowInfo> &newWindowInfo) {
|
||||||
wsi = std::make_shared<WSI>();
|
wsi = std::make_shared<WSI>();
|
||||||
wsi->set_backbuffer_srgb(false);
|
wsi->set_backbuffer_srgb(false);
|
||||||
wsi->set_platform(wsi_platform.get());
|
wsi->set_platform(wsi_platform.get());
|
||||||
@@ -33,7 +33,9 @@ void ParallelRDP::LoadWSIPlatform(const std::shared_ptr<Vulkan::InstanceFactory>
|
|||||||
windowInfo = newWindowInfo;
|
windowInfo = newWindowInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParallelRDP::Init(const std::shared_ptr<Vulkan::InstanceFactory>& factory, const std::shared_ptr<Vulkan::WSIPlatform>& wsiPlatform, const std::shared_ptr<WindowInfo>& newWindowInfo, const u8* rdram) {
|
void ParallelRDP::Init(const std::shared_ptr<Vulkan::InstanceFactory> &factory,
|
||||||
|
const std::shared_ptr<Vulkan::WSIPlatform> &wsiPlatform,
|
||||||
|
const std::shared_ptr<WindowInfo> &newWindowInfo, const u8 *rdram) {
|
||||||
LoadWSIPlatform(factory, wsiPlatform, newWindowInfo);
|
LoadWSIPlatform(factory, wsiPlatform, newWindowInfo);
|
||||||
|
|
||||||
ResourceLayout vertLayout;
|
ResourceLayout vertLayout;
|
||||||
@@ -56,9 +58,9 @@ void ParallelRDP::Init(const std::shared_ptr<Vulkan::InstanceFactory>& factory,
|
|||||||
auto sizeVert = fullscreenQuadVert.size();
|
auto sizeVert = fullscreenQuadVert.size();
|
||||||
auto sizeFrag = fullscreenQuadFrag.size();
|
auto sizeFrag = fullscreenQuadFrag.size();
|
||||||
|
|
||||||
fullscreen_quad_program = wsi->get_device().request_program(reinterpret_cast<u32*>(fullscreenQuadVert.data()), sizeVert,
|
fullscreen_quad_program = wsi->get_device().request_program(
|
||||||
reinterpret_cast<u32*>(fullscreenQuadFrag.data()), sizeFrag,
|
reinterpret_cast<u32 *>(fullscreenQuadVert.data()), sizeVert, reinterpret_cast<u32 *>(fullscreenQuadFrag.data()),
|
||||||
&vertLayout, &fragLayout);
|
sizeFrag, &vertLayout, &fragLayout);
|
||||||
|
|
||||||
auto aligned_rdram = reinterpret_cast<uintptr_t>(rdram);
|
auto aligned_rdram = reinterpret_cast<uintptr_t>(rdram);
|
||||||
uintptr_t offset = 0;
|
uintptr_t offset = 0;
|
||||||
@@ -99,12 +101,10 @@ void ParallelRDP::DrawFullscreenTexturedQuad(Util::IntrusivePtr<Image> image, Ut
|
|||||||
float width = (wsi->get_platform().get_surface_width() / windowSize.x) * zoom;
|
float width = (wsi->get_platform().get_surface_width() / windowSize.x) * zoom;
|
||||||
float height = (wsi->get_platform().get_surface_height() / windowSize.y) * zoom;
|
float height = (wsi->get_platform().get_surface_height() / windowSize.y) * zoom;
|
||||||
|
|
||||||
float uniform_data[] = {
|
float uniform_data[] = {// Size
|
||||||
// Size
|
|
||||||
width, height,
|
width, height,
|
||||||
// Offset
|
// Offset
|
||||||
(1.0f - width) * 0.5f,
|
(1.0f - width) * 0.5f, (1.0f - height) * 0.5f};
|
||||||
(1.0f - height) * 0.5f};
|
|
||||||
|
|
||||||
cmd->push_constants(uniform_data, 0, sizeof(uniform_data));
|
cmd->push_constants(uniform_data, 0, sizeof(uniform_data));
|
||||||
|
|
||||||
@@ -120,21 +120,18 @@ void ParallelRDP::UpdateScreen(Util::IntrusivePtr<Image> image) {
|
|||||||
|
|
||||||
if (!image) {
|
if (!image) {
|
||||||
auto info = Vulkan::ImageCreateInfo::immutable_2d_image(800, 600, VK_FORMAT_R8G8B8A8_UNORM);
|
auto info = Vulkan::ImageCreateInfo::immutable_2d_image(800, 600, VK_FORMAT_R8G8B8A8_UNORM);
|
||||||
info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
|
info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||||
VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
|
||||||
info.misc = IMAGE_MISC_MUTABLE_SRGB_BIT;
|
info.misc = IMAGE_MISC_MUTABLE_SRGB_BIT;
|
||||||
info.initial_layout = VK_IMAGE_LAYOUT_UNDEFINED;
|
info.initial_layout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||||
image = wsi->get_device().create_image(info);
|
image = wsi->get_device().create_image(info);
|
||||||
|
|
||||||
auto cmd = wsi->get_device().request_command_buffer();
|
auto cmd = wsi->get_device().request_command_buffer();
|
||||||
|
|
||||||
cmd->image_barrier(*image,
|
cmd->image_barrier(*image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||||
VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0,
|
VK_ACCESS_TRANSFER_WRITE_BIT);
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT);
|
|
||||||
cmd->clear_image(*image, {});
|
cmd->clear_image(*image, {});
|
||||||
cmd->image_barrier(*image,
|
cmd->image_barrier(*image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
|
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT);
|
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT);
|
||||||
wsi->get_device().submit(cmd);
|
wsi->get_device().submit(cmd);
|
||||||
@@ -150,7 +147,7 @@ void ParallelRDP::UpdateScreen(Util::IntrusivePtr<Image> image) {
|
|||||||
wsi->end_frame();
|
wsi->end_frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParallelRDP::UpdateScreen(n64::VI& vi, bool noGame) {
|
void ParallelRDP::UpdateScreen(n64::VI &vi) {
|
||||||
command_processor->set_vi_register(VIRegister::Control, vi.status.raw);
|
command_processor->set_vi_register(VIRegister::Control, vi.status.raw);
|
||||||
command_processor->set_vi_register(VIRegister::Origin, vi.origin);
|
command_processor->set_vi_register(VIRegister::Origin, vi.origin);
|
||||||
command_processor->set_vi_register(VIRegister::Width, vi.width);
|
command_processor->set_vi_register(VIRegister::Width, vi.width);
|
||||||
@@ -165,8 +162,7 @@ void ParallelRDP::UpdateScreen(n64::VI& vi, bool noGame) {
|
|||||||
command_processor->set_vi_register(VIRegister::VBurst, vi.vburst);
|
command_processor->set_vi_register(VIRegister::VBurst, vi.vburst);
|
||||||
command_processor->set_vi_register(VIRegister::XScale, vi.xscale.raw);
|
command_processor->set_vi_register(VIRegister::XScale, vi.xscale.raw);
|
||||||
command_processor->set_vi_register(VIRegister::YScale, vi.yscale.raw);
|
command_processor->set_vi_register(VIRegister::YScale, vi.yscale.raw);
|
||||||
if (!noGame) {
|
ScanoutOptions opts;
|
||||||
RDP::ScanoutOptions opts;
|
|
||||||
opts.persist_frame_on_invalid_input = true;
|
opts.persist_frame_on_invalid_input = true;
|
||||||
opts.vi.aa = true;
|
opts.vi.aa = true;
|
||||||
opts.vi.scale = true;
|
opts.vi.scale = true;
|
||||||
@@ -178,16 +174,10 @@ void ParallelRDP::UpdateScreen(n64::VI& vi, bool noGame) {
|
|||||||
Util::IntrusivePtr<Image> image = command_processor->scanout(opts);
|
Util::IntrusivePtr<Image> image = command_processor->scanout(opts);
|
||||||
UpdateScreen(image);
|
UpdateScreen(image);
|
||||||
command_processor->begin_frame_context();
|
command_processor->begin_frame_context();
|
||||||
} else {
|
|
||||||
UpdateScreen(static_cast<Util::IntrusivePtr<Image>>(nullptr));
|
|
||||||
command_processor->begin_frame_context();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParallelRDP::EnqueueCommand(int command_length, u32 *buffer) {
|
void ParallelRDP::EnqueueCommand(int command_length, u32 *buffer) {
|
||||||
command_processor->enqueue_command(command_length, buffer);
|
command_processor->enqueue_command(command_length, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParallelRDP::OnFullSync() {
|
void ParallelRDP::OnFullSync() { command_processor->wait_for_timeline(command_processor->signal_timeline()); }
|
||||||
command_processor->wait_for_timeline(command_processor->signal_timeline());
|
|
||||||
}
|
|
||||||
|
|||||||
11
external/parallel-rdp/ParallelRDPWrapper.hpp
vendored
11
external/parallel-rdp/ParallelRDPWrapper.hpp
vendored
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <backend/Core.hpp>
|
#include <backend/Core.hpp>
|
||||||
#include <wsi.hpp>
|
|
||||||
#include <rdp_device.hpp>
|
#include <rdp_device.hpp>
|
||||||
|
#include <wsi.hpp>
|
||||||
|
|
||||||
class ParallelRDP {
|
class ParallelRDP {
|
||||||
public:
|
public:
|
||||||
@@ -15,16 +15,19 @@ public:
|
|||||||
virtual ~WindowInfo() = default;
|
virtual ~WindowInfo() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Init(const std::shared_ptr<Vulkan::InstanceFactory>&, const std::shared_ptr<Vulkan::WSIPlatform>&, const std::shared_ptr<WindowInfo>&, const u8*);
|
void Init(const std::shared_ptr<Vulkan::InstanceFactory> &, const std::shared_ptr<Vulkan::WSIPlatform> &,
|
||||||
|
const std::shared_ptr<WindowInfo> &, const u8 *);
|
||||||
ParallelRDP() = default;
|
ParallelRDP() = default;
|
||||||
|
|
||||||
void UpdateScreen(n64::VI&, bool = false);
|
void UpdateScreen(n64::VI &);
|
||||||
void EnqueueCommand(int, u32 *);
|
void EnqueueCommand(int, u32 *);
|
||||||
void OnFullSync();
|
void OnFullSync();
|
||||||
bool IsFramerateUnlocked();
|
bool IsFramerateUnlocked();
|
||||||
void SetFramerateUnlocked(bool);
|
void SetFramerateUnlocked(bool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void LoadWSIPlatform(const std::shared_ptr<Vulkan::InstanceFactory>&, const std::shared_ptr<Vulkan::WSIPlatform>&, const std::shared_ptr<WindowInfo>&);
|
void LoadWSIPlatform(const std::shared_ptr<Vulkan::InstanceFactory> &, const std::shared_ptr<Vulkan::WSIPlatform> &,
|
||||||
|
const std::shared_ptr<WindowInfo> &);
|
||||||
void DrawFullscreenTexturedQuad(Util::IntrusivePtr<Vulkan::Image>, Util::IntrusivePtr<Vulkan::CommandBuffer>);
|
void DrawFullscreenTexturedQuad(Util::IntrusivePtr<Vulkan::Image>, Util::IntrusivePtr<Vulkan::CommandBuffer>);
|
||||||
void UpdateScreen(Util::IntrusivePtr<Vulkan::Image>);
|
void UpdateScreen(Util::IntrusivePtr<Vulkan::Image>);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user