video_core: Refactor GPU interface (#7272)

* video_core: Refactor GPU interface

* citra_qt: Better debug widget lifetime
This commit is contained in:
GPUCode 2023-12-28 12:46:57 +02:00 committed by GitHub
parent 602f4f60d8
commit 2bb7f89c30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
167 changed files with 4172 additions and 4866 deletions

View file

@ -6,9 +6,9 @@
#include "common/hash.h"
#include "common/math_util.h"
#include "video_core/pica/regs_rasterizer.h"
#include "video_core/rasterizer_cache/slot_id.h"
#include "video_core/rasterizer_cache/surface_params.h"
#include "video_core/regs_rasterizer.h"
namespace VideoCore {

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "video_core/pica/regs_external.h"
#include "video_core/rasterizer_cache/pixel_format.h"
namespace VideoCore {
@ -134,17 +135,17 @@ PixelFormat PixelFormatFromDepthFormat(Pica::FramebufferRegs::DepthFormat format
}
}
PixelFormat PixelFormatFromGPUPixelFormat(GPU::Regs::PixelFormat format) {
PixelFormat PixelFormatFromGPUPixelFormat(Pica::PixelFormat format) {
switch (format) {
case GPU::Regs::PixelFormat::RGBA8:
case Pica::PixelFormat::RGBA8:
return PixelFormat::RGBA8;
case GPU::Regs::PixelFormat::RGB8:
case Pica::PixelFormat::RGB8:
return PixelFormat::RGB8;
case GPU::Regs::PixelFormat::RGB565:
case Pica::PixelFormat::RGB565:
return PixelFormat::RGB565;
case GPU::Regs::PixelFormat::RGB5A1:
case Pica::PixelFormat::RGB5A1:
return PixelFormat::RGB5A1;
case GPU::Regs::PixelFormat::RGBA4:
case Pica::PixelFormat::RGBA4:
return PixelFormat::RGBA4;
default:
return PixelFormat::Invalid;

View file

@ -6,9 +6,12 @@
#include <limits>
#include <string_view>
#include "core/hw/gpu.h"
#include "video_core/regs_framebuffer.h"
#include "video_core/regs_texturing.h"
#include "video_core/pica/regs_framebuffer.h"
#include "video_core/pica/regs_texturing.h"
namespace Pica {
enum class PixelFormat : u32;
}
namespace VideoCore {
@ -109,6 +112,6 @@ PixelFormat PixelFormatFromColorFormat(Pica::FramebufferRegs::ColorFormat format
PixelFormat PixelFormatFromDepthFormat(Pica::FramebufferRegs::DepthFormat format);
PixelFormat PixelFormatFromGPUPixelFormat(GPU::Regs::PixelFormat format);
PixelFormat PixelFormatFromGPUPixelFormat(Pica::PixelFormat format);
} // namespace VideoCore

View file

@ -14,9 +14,10 @@
#include "common/settings.h"
#include "core/memory.h"
#include "video_core/custom_textures/custom_tex_manager.h"
#include "video_core/pica/regs_external.h"
#include "video_core/pica/regs_internal.h"
#include "video_core/rasterizer_cache/rasterizer_cache_base.h"
#include "video_core/rasterizer_cache/surface_base.h"
#include "video_core/regs.h"
#include "video_core/renderer_base.h"
#include "video_core/texture/texture_decode.h"
@ -34,7 +35,7 @@ constexpr auto RangeFromInterval(const auto& map, const auto& interval) {
template <class T>
RasterizerCache<T>::RasterizerCache(Memory::MemorySystem& memory_,
CustomTexManager& custom_tex_manager_, Runtime& runtime_,
Pica::Regs& regs_, RendererBase& renderer_)
Pica::RegsInternal& regs_, RendererBase& renderer_)
: memory{memory_}, custom_tex_manager{custom_tex_manager_}, runtime{runtime_}, regs{regs_},
renderer{renderer_}, resolution_scale_factor{renderer.GetResolutionScaleFactor()},
filter{Settings::values.texture_filter.GetValue()},
@ -151,7 +152,7 @@ void RasterizerCache<T>::RemoveTextureCubeFace(SurfaceId surface_id) {
}
template <class T>
bool RasterizerCache<T>::AccelerateTextureCopy(const GPU::Regs::DisplayTransferConfig& config) {
bool RasterizerCache<T>::AccelerateTextureCopy(const Pica::DisplayTransferConfig& config) {
const DebugScope scope{runtime, Common::Vec4f{0.f, 0.f, 1.f, 1.f},
"RasterizerCache::AccelerateTextureCopy ({})", config.DebugName()};
@ -249,7 +250,7 @@ bool RasterizerCache<T>::AccelerateTextureCopy(const GPU::Regs::DisplayTransferC
}
template <class T>
bool RasterizerCache<T>::AccelerateDisplayTransfer(const GPU::Regs::DisplayTransferConfig& config) {
bool RasterizerCache<T>::AccelerateDisplayTransfer(const Pica::DisplayTransferConfig& config) {
const DebugScope scope{runtime, Common::Vec4f{0.f, 0.f, 1.f, 1.f},
"RasterizerCache::AccelerateDisplayTransfer ({})", config.DebugName()};
@ -274,10 +275,9 @@ bool RasterizerCache<T>::AccelerateDisplayTransfer(const GPU::Regs::DisplayTrans
// Using flip_vertically alongside crop_input_lines produces skewed output on hardware.
// We have to emulate this because some games rely on this behaviour to render correctly.
if (config.flip_vertically && config.crop_input_lines &&
config.input_width > config.output_width) {
if (config.flip_vertically && config.crop_input_lines) {
dst_params.addr += (config.input_width - config.output_width) * (config.output_height - 1) *
GPU::Regs::BytesPerPixel(config.output_format);
Pica::BytesPerPixel(config.output_format);
}
auto [src_surface_id, src_rect] = GetSurfaceSubRect(src_params, ScaleMatch::Ignore, true);
@ -320,7 +320,7 @@ bool RasterizerCache<T>::AccelerateDisplayTransfer(const GPU::Regs::DisplayTrans
}
template <class T>
bool RasterizerCache<T>::AccelerateFill(const GPU::Regs::MemoryFillConfig& config) {
bool RasterizerCache<T>::AccelerateFill(const Pica::MemoryFillConfig& config) {
const DebugScope scope{runtime, Common::Vec4f{1.f, 0.f, 1.f, 1.f},
"RasterizerCache::AccelerateFill ({})", config.DebugName()};

View file

@ -12,6 +12,7 @@
#include <vector>
#include <boost/icl/interval_map.hpp>
#include <tsl/robin_map.h>
#include "video_core/rasterizer_cache/framebuffer_base.h"
#include "video_core/rasterizer_cache/sampler_params.h"
#include "video_core/rasterizer_cache/surface_params.h"
@ -22,8 +23,10 @@ class MemorySystem;
}
namespace Pica {
struct Regs;
}
struct RegsInternal;
struct DisplayTransferConfig;
struct MemoryFillConfig;
} // namespace Pica
namespace Pica::Texture {
struct TextureInfo;
@ -74,20 +77,20 @@ class RasterizerCache {
public:
explicit RasterizerCache(Memory::MemorySystem& memory, CustomTexManager& custom_tex_manager,
Runtime& runtime, Pica::Regs& regs, RendererBase& renderer);
Runtime& runtime, Pica::RegsInternal& regs, RendererBase& renderer);
~RasterizerCache();
/// Notify the cache that a new frame has been queued
void TickFrame();
/// Perform hardware accelerated texture copy according to the provided configuration
bool AccelerateTextureCopy(const GPU::Regs::DisplayTransferConfig& config);
bool AccelerateTextureCopy(const Pica::DisplayTransferConfig& config);
/// Perform hardware accelerated display transfer according to the provided configuration
bool AccelerateDisplayTransfer(const GPU::Regs::DisplayTransferConfig& config);
bool AccelerateDisplayTransfer(const Pica::DisplayTransferConfig& config);
/// Perform hardware accelerated memory fill according to the provided configuration
bool AccelerateFill(const GPU::Regs::MemoryFillConfig& config);
bool AccelerateFill(const Pica::MemoryFillConfig& config);
/// Returns a reference to the surface object assigned to surface_id
Surface& GetSurface(SurfaceId surface_id);
@ -212,7 +215,7 @@ private:
Memory::MemorySystem& memory;
CustomTexManager& custom_tex_manager;
Runtime& runtime;
Pica::Regs& regs;
Pica::RegsInternal& regs;
RendererBase& renderer;
std::unordered_map<TextureCubeConfig, TextureCube> texture_cube_cache;
tsl::robin_pg_map<u64, std::vector<SurfaceId>, Common::IdentityHash<u64>> page_table;

View file

@ -6,7 +6,7 @@
#include <compare>
#include "common/hash.h"
#include "video_core/regs_texturing.h"
#include "video_core/pica/regs_texturing.h"
namespace VideoCore {

View file

@ -5,8 +5,8 @@
#pragma once
#include "common/hash.h"
#include "video_core/pica/regs_texturing.h"
#include "video_core/rasterizer_cache/slot_id.h"
#include "video_core/regs_texturing.h"
namespace VideoCore {