mirror of https://git.suyu.dev/suyu/suyu
gpu: Change optional<reference_wrapper<T>> to T* for FramebufferConfig
This commit is contained in:
parent
ef584f1a3a
commit
9a76e94b3d
|
@ -37,7 +37,7 @@ void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u3
|
||||||
transform, crop_rect};
|
transform, crop_rect};
|
||||||
|
|
||||||
system.GetPerfStats().EndGameFrame();
|
system.GetPerfStats().EndGameFrame();
|
||||||
system.GPU().SwapBuffers(framebuffer);
|
system.GPU().SwapBuffers(&framebuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Service::Nvidia::Devices
|
} // namespace Service::Nvidia::Devices
|
||||||
|
|
|
@ -247,8 +247,7 @@ public:
|
||||||
virtual void PushGPUEntries(Tegra::CommandList&& entries) = 0;
|
virtual void PushGPUEntries(Tegra::CommandList&& entries) = 0;
|
||||||
|
|
||||||
/// Swap buffers (render frame)
|
/// Swap buffers (render frame)
|
||||||
virtual void SwapBuffers(
|
virtual void SwapBuffers(const Tegra::FramebufferConfig* framebuffer) = 0;
|
||||||
std::optional<std::reference_wrapper<const Tegra::FramebufferConfig>> framebuffer) = 0;
|
|
||||||
|
|
||||||
/// Notify rasterizer that any caches of the specified region should be flushed to Switch memory
|
/// Notify rasterizer that any caches of the specified region should be flushed to Switch memory
|
||||||
virtual void FlushRegion(CacheAddr addr, u64 size) = 0;
|
virtual void FlushRegion(CacheAddr addr, u64 size) = 0;
|
||||||
|
|
|
@ -23,9 +23,8 @@ void GPUAsynch::PushGPUEntries(Tegra::CommandList&& entries) {
|
||||||
gpu_thread.SubmitList(std::move(entries));
|
gpu_thread.SubmitList(std::move(entries));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPUAsynch::SwapBuffers(
|
void GPUAsynch::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) {
|
||||||
std::optional<std::reference_wrapper<const Tegra::FramebufferConfig>> framebuffer) {
|
gpu_thread.SwapBuffers(framebuffer);
|
||||||
gpu_thread.SwapBuffers(std::move(framebuffer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPUAsynch::FlushRegion(CacheAddr addr, u64 size) {
|
void GPUAsynch::FlushRegion(CacheAddr addr, u64 size) {
|
||||||
|
|
|
@ -14,15 +14,14 @@ class RendererBase;
|
||||||
namespace VideoCommon {
|
namespace VideoCommon {
|
||||||
|
|
||||||
/// Implementation of GPU interface that runs the GPU asynchronously
|
/// Implementation of GPU interface that runs the GPU asynchronously
|
||||||
class GPUAsynch : public Tegra::GPU {
|
class GPUAsynch final : public Tegra::GPU {
|
||||||
public:
|
public:
|
||||||
explicit GPUAsynch(Core::System& system, VideoCore::RendererBase& renderer);
|
explicit GPUAsynch(Core::System& system, VideoCore::RendererBase& renderer);
|
||||||
~GPUAsynch() override;
|
~GPUAsynch() override;
|
||||||
|
|
||||||
void Start() override;
|
void Start() override;
|
||||||
void PushGPUEntries(Tegra::CommandList&& entries) override;
|
void PushGPUEntries(Tegra::CommandList&& entries) override;
|
||||||
void SwapBuffers(
|
void SwapBuffers(const Tegra::FramebufferConfig* framebuffer) override;
|
||||||
std::optional<std::reference_wrapper<const Tegra::FramebufferConfig>> framebuffer) override;
|
|
||||||
void FlushRegion(CacheAddr addr, u64 size) override;
|
void FlushRegion(CacheAddr addr, u64 size) override;
|
||||||
void InvalidateRegion(CacheAddr addr, u64 size) override;
|
void InvalidateRegion(CacheAddr addr, u64 size) override;
|
||||||
void FlushAndInvalidateRegion(CacheAddr addr, u64 size) override;
|
void FlushAndInvalidateRegion(CacheAddr addr, u64 size) override;
|
||||||
|
|
|
@ -19,9 +19,8 @@ void GPUSynch::PushGPUEntries(Tegra::CommandList&& entries) {
|
||||||
dma_pusher->DispatchCalls();
|
dma_pusher->DispatchCalls();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPUSynch::SwapBuffers(
|
void GPUSynch::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) {
|
||||||
std::optional<std::reference_wrapper<const Tegra::FramebufferConfig>> framebuffer) {
|
renderer.SwapBuffers(framebuffer);
|
||||||
renderer.SwapBuffers(std::move(framebuffer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPUSynch::FlushRegion(CacheAddr addr, u64 size) {
|
void GPUSynch::FlushRegion(CacheAddr addr, u64 size) {
|
||||||
|
|
|
@ -13,15 +13,14 @@ class RendererBase;
|
||||||
namespace VideoCommon {
|
namespace VideoCommon {
|
||||||
|
|
||||||
/// Implementation of GPU interface that runs the GPU synchronously
|
/// Implementation of GPU interface that runs the GPU synchronously
|
||||||
class GPUSynch : public Tegra::GPU {
|
class GPUSynch final : public Tegra::GPU {
|
||||||
public:
|
public:
|
||||||
explicit GPUSynch(Core::System& system, VideoCore::RendererBase& renderer);
|
explicit GPUSynch(Core::System& system, VideoCore::RendererBase& renderer);
|
||||||
~GPUSynch() override;
|
~GPUSynch() override;
|
||||||
|
|
||||||
void Start() override;
|
void Start() override;
|
||||||
void PushGPUEntries(Tegra::CommandList&& entries) override;
|
void PushGPUEntries(Tegra::CommandList&& entries) override;
|
||||||
void SwapBuffers(
|
void SwapBuffers(const Tegra::FramebufferConfig* framebuffer) override;
|
||||||
std::optional<std::reference_wrapper<const Tegra::FramebufferConfig>> framebuffer) override;
|
|
||||||
void FlushRegion(CacheAddr addr, u64 size) override;
|
void FlushRegion(CacheAddr addr, u64 size) override;
|
||||||
void InvalidateRegion(CacheAddr addr, u64 size) override;
|
void InvalidateRegion(CacheAddr addr, u64 size) override;
|
||||||
void FlushAndInvalidateRegion(CacheAddr addr, u64 size) override;
|
void FlushAndInvalidateRegion(CacheAddr addr, u64 size) override;
|
||||||
|
|
|
@ -39,7 +39,7 @@ static void RunThread(VideoCore::RendererBase& renderer, Tegra::DmaPusher& dma_p
|
||||||
dma_pusher.Push(std::move(submit_list->entries));
|
dma_pusher.Push(std::move(submit_list->entries));
|
||||||
dma_pusher.DispatchCalls();
|
dma_pusher.DispatchCalls();
|
||||||
} else if (const auto data = std::get_if<SwapBuffersCommand>(&next.data)) {
|
} else if (const auto data = std::get_if<SwapBuffersCommand>(&next.data)) {
|
||||||
renderer.SwapBuffers(std::move(data->framebuffer));
|
renderer.SwapBuffers(data->framebuffer ? &*data->framebuffer : nullptr);
|
||||||
} else if (const auto data = std::get_if<FlushRegionCommand>(&next.data)) {
|
} else if (const auto data = std::get_if<FlushRegionCommand>(&next.data)) {
|
||||||
renderer.Rasterizer().FlushRegion(data->addr, data->size);
|
renderer.Rasterizer().FlushRegion(data->addr, data->size);
|
||||||
} else if (const auto data = std::get_if<InvalidateRegionCommand>(&next.data)) {
|
} else if (const auto data = std::get_if<InvalidateRegionCommand>(&next.data)) {
|
||||||
|
@ -78,9 +78,9 @@ void ThreadManager::SubmitList(Tegra::CommandList&& entries) {
|
||||||
system.CoreTiming().ScheduleEvent(synchronization_ticks, synchronization_event, fence);
|
system.CoreTiming().ScheduleEvent(synchronization_ticks, synchronization_event, fence);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadManager::SwapBuffers(
|
void ThreadManager::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) {
|
||||||
std::optional<std::reference_wrapper<const Tegra::FramebufferConfig>> framebuffer) {
|
PushCommand(SwapBuffersCommand(framebuffer ? *framebuffer
|
||||||
PushCommand(SwapBuffersCommand(std::move(framebuffer)));
|
: std::optional<const Tegra::FramebufferConfig>{}));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadManager::FlushRegion(CacheAddr addr, u64 size) {
|
void ThreadManager::FlushRegion(CacheAddr addr, u64 size) {
|
||||||
|
|
|
@ -110,8 +110,7 @@ public:
|
||||||
void SubmitList(Tegra::CommandList&& entries);
|
void SubmitList(Tegra::CommandList&& entries);
|
||||||
|
|
||||||
/// Swap buffers (render frame)
|
/// Swap buffers (render frame)
|
||||||
void SwapBuffers(
|
void SwapBuffers(const Tegra::FramebufferConfig* framebuffer);
|
||||||
std::optional<std::reference_wrapper<const Tegra::FramebufferConfig>> framebuffer);
|
|
||||||
|
|
||||||
/// Notify rasterizer that any caches of the specified region should be flushed to Switch memory
|
/// Notify rasterizer that any caches of the specified region should be flushed to Switch memory
|
||||||
void FlushRegion(CacheAddr addr, u64 size);
|
void FlushRegion(CacheAddr addr, u64 size);
|
||||||
|
|
|
@ -36,8 +36,7 @@ public:
|
||||||
virtual ~RendererBase();
|
virtual ~RendererBase();
|
||||||
|
|
||||||
/// Swap buffers (render frame)
|
/// Swap buffers (render frame)
|
||||||
virtual void SwapBuffers(
|
virtual void SwapBuffers(const Tegra::FramebufferConfig* framebuffer) = 0;
|
||||||
std::optional<std::reference_wrapper<const Tegra::FramebufferConfig>> framebuffer) = 0;
|
|
||||||
|
|
||||||
/// Initialize the renderer
|
/// Initialize the renderer
|
||||||
virtual bool Init() = 0;
|
virtual bool Init() = 0;
|
||||||
|
|
|
@ -101,9 +101,7 @@ RendererOpenGL::RendererOpenGL(Core::Frontend::EmuWindow& emu_window, Core::Syst
|
||||||
|
|
||||||
RendererOpenGL::~RendererOpenGL() = default;
|
RendererOpenGL::~RendererOpenGL() = default;
|
||||||
|
|
||||||
void RendererOpenGL::SwapBuffers(
|
void RendererOpenGL::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) {
|
||||||
std::optional<std::reference_wrapper<const Tegra::FramebufferConfig>> framebuffer) {
|
|
||||||
|
|
||||||
system.GetPerfStats().EndSystemFrame();
|
system.GetPerfStats().EndSystemFrame();
|
||||||
|
|
||||||
// Maintain the rasterizer's state as a priority
|
// Maintain the rasterizer's state as a priority
|
||||||
|
@ -113,9 +111,9 @@ void RendererOpenGL::SwapBuffers(
|
||||||
|
|
||||||
if (framebuffer) {
|
if (framebuffer) {
|
||||||
// If framebuffer is provided, reload it from memory to a texture
|
// If framebuffer is provided, reload it from memory to a texture
|
||||||
if (screen_info.texture.width != (GLsizei)framebuffer->get().width ||
|
if (screen_info.texture.width != static_cast<GLsizei>(framebuffer->width) ||
|
||||||
screen_info.texture.height != (GLsizei)framebuffer->get().height ||
|
screen_info.texture.height != static_cast<GLsizei>(framebuffer->height) ||
|
||||||
screen_info.texture.pixel_format != framebuffer->get().pixel_format) {
|
screen_info.texture.pixel_format != framebuffer->pixel_format) {
|
||||||
// Reallocate texture if the framebuffer size has changed.
|
// Reallocate texture if the framebuffer size has changed.
|
||||||
// This is expected to not happen very often and hence should not be a
|
// This is expected to not happen very often and hence should not be a
|
||||||
// performance problem.
|
// performance problem.
|
||||||
|
|
|
@ -43,14 +43,13 @@ struct ScreenInfo {
|
||||||
TextureInfo texture;
|
TextureInfo texture;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RendererOpenGL : public VideoCore::RendererBase {
|
class RendererOpenGL final : public VideoCore::RendererBase {
|
||||||
public:
|
public:
|
||||||
explicit RendererOpenGL(Core::Frontend::EmuWindow& emu_window, Core::System& system);
|
explicit RendererOpenGL(Core::Frontend::EmuWindow& emu_window, Core::System& system);
|
||||||
~RendererOpenGL() override;
|
~RendererOpenGL() override;
|
||||||
|
|
||||||
/// Swap buffers (render frame)
|
/// Swap buffers (render frame)
|
||||||
void SwapBuffers(
|
void SwapBuffers(const Tegra::FramebufferConfig* framebuffer) override;
|
||||||
std::optional<std::reference_wrapper<const Tegra::FramebufferConfig>> framebuffer) override;
|
|
||||||
|
|
||||||
/// Initialize the renderer
|
/// Initialize the renderer
|
||||||
bool Init() override;
|
bool Init() override;
|
||||||
|
|
Loading…
Reference in New Issue