diff options
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/service/nvflinger/buffer_queue.h | 1 | ||||
-rw-r--r-- | src/core/settings.cpp | 6 | ||||
-rw-r--r-- | src/video_core/command_processor.h | 3 | ||||
-rw-r--r-- | src/video_core/engines/shader_bytecode.h | 3 | ||||
-rw-r--r-- | src/video_core/gpu.cpp | 42 | ||||
-rw-r--r-- | src/video_core/gpu.h | 17 | ||||
-rw-r--r-- | src/video_core/renderer_base.cpp | 19 | ||||
-rw-r--r-- | src/video_core/renderer_base.h | 24 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 21 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 51 | ||||
-rw-r--r-- | src/video_core/video_core.cpp | 2 | ||||
-rw-r--r-- | src/video_core/video_core.h | 7 |
12 files changed, 138 insertions, 58 deletions
diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h index f86e1056c..db2e17c0c 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.h +++ b/src/core/hle/service/nvflinger/buffer_queue.h @@ -6,6 +6,7 @@ #include <vector> #include <boost/optional.hpp> +#include "common/common_funcs.h" #include "common/math_util.h" #include "common/swap.h" #include "core/hle/kernel/event.h" diff --git a/src/core/settings.cpp b/src/core/settings.cpp index a4623223d..0da159559 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -7,22 +7,18 @@ #include "core/hle/service/hid/hid.h" #include "core/settings.h" #include "video_core/renderer_base.h" -#include "video_core/video_core.h" namespace Settings { Values values = {}; void Apply() { - GDBStub::SetServerPort(values.gdbstub_port); GDBStub::ToggleServer(values.use_gdbstub); - VideoCore::g_toggle_framelimit_enabled = values.toggle_framelimit; - auto& system_instance = Core::System::GetInstance(); if (system_instance.IsPoweredOn()) { - system_instance.Renderer().UpdateCurrentFramebufferLayout(); + system_instance.Renderer().RefreshBaseSettings(); } Service::HID::ReloadInputDevices(); diff --git a/src/video_core/command_processor.h b/src/video_core/command_processor.h index f7214ffec..a01153e0b 100644 --- a/src/video_core/command_processor.h +++ b/src/video_core/command_processor.h @@ -30,8 +30,7 @@ union CommandHeader { BitField<29, 3, SubmissionMode> mode; }; -static_assert(std::is_standard_layout<CommandHeader>::value == true, - "CommandHeader does not use standard layout"); +static_assert(std::is_standard_layout_v<CommandHeader>, "CommandHeader is not standard layout"); static_assert(sizeof(CommandHeader) == sizeof(u32), "CommandHeader has incorrect size!"); } // namespace Tegra diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h index 42c6ea5fd..6cb7bea1c 100644 --- a/src/video_core/engines/shader_bytecode.h +++ b/src/video_core/engines/shader_bytecode.h @@ -477,8 +477,7 @@ union Instruction { u64 value; }; static_assert(sizeof(Instruction) == 0x8, "Incorrect structure size"); -static_assert(std::is_standard_layout<Instruction>::value, - "Structure does not have standard layout"); +static_assert(std::is_standard_layout_v<Instruction>, "Instruction is not standard layout"); class OpCode { public: diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 4ff4d71c5..ceaf86654 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/assert.h" #include "video_core/engines/fermi_2d.h" #include "video_core/engines/maxwell_3d.h" #include "video_core/engines/maxwell_compute.h" @@ -11,6 +12,15 @@ namespace Tegra { +u32 FramebufferConfig::BytesPerPixel(PixelFormat format) { + switch (format) { + case PixelFormat::ABGR8: + return 4; + } + + UNREACHABLE(); +} + GPU::GPU(VideoCore::RasterizerInterface& rasterizer) { memory_manager = std::make_unique<MemoryManager>(); maxwell_3d = std::make_unique<Engines::Maxwell3D>(rasterizer, *memory_manager); @@ -34,19 +44,51 @@ u32 RenderTargetBytesPerPixel(RenderTargetFormat format) { switch (format) { case RenderTargetFormat::RGBA32_FLOAT: + case RenderTargetFormat::RGBA32_UINT: return 16; case RenderTargetFormat::RGBA16_FLOAT: case RenderTargetFormat::RG32_FLOAT: return 8; case RenderTargetFormat::RGBA8_UNORM: + case RenderTargetFormat::RGBA8_SRGB: case RenderTargetFormat::RGB10_A2_UNORM: case RenderTargetFormat::BGRA8_UNORM: + case RenderTargetFormat::RG16_UNORM: + case RenderTargetFormat::RG16_SNORM: + case RenderTargetFormat::RG16_UINT: + case RenderTargetFormat::RG16_SINT: + case RenderTargetFormat::RG16_FLOAT: case RenderTargetFormat::R32_FLOAT: case RenderTargetFormat::R11G11B10_FLOAT: return 4; + case RenderTargetFormat::R16_UNORM: + case RenderTargetFormat::R16_SNORM: + case RenderTargetFormat::R16_UINT: + case RenderTargetFormat::R16_SINT: + case RenderTargetFormat::R16_FLOAT: + return 2; + case RenderTargetFormat::R8_UNORM: + return 1; default: UNIMPLEMENTED_MSG("Unimplemented render target format {}", static_cast<u32>(format)); } } +u32 DepthFormatBytesPerPixel(DepthFormat format) { + switch (format) { + case DepthFormat::Z32_S8_X24_FLOAT: + return 8; + case DepthFormat::Z32_FLOAT: + case DepthFormat::S8_Z24_UNORM: + case DepthFormat::Z24_X8_UNORM: + case DepthFormat::Z24_S8_UNORM: + case DepthFormat::Z24_C8_UNORM: + return 4; + case DepthFormat::Z16_UNORM: + return 2; + default: + UNIMPLEMENTED_MSG("Unimplemented Depth format {}", static_cast<u32>(format)); + } +} + } // namespace Tegra diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index 874eddd78..b57312b3b 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h @@ -6,7 +6,6 @@ #include <memory> #include <unordered_map> -#include <vector> #include "common/common_types.h" #include "core/hle/service/nvflinger/buffer_queue.h" #include "video_core/memory_manager.h" @@ -35,6 +34,10 @@ enum class RenderTargetFormat : u32 { R11G11B10_FLOAT = 0xE0, R32_FLOAT = 0xE5, B5G6R5_UNORM = 0xE8, + R16_UNORM = 0xEE, + R16_SNORM = 0xEF, + R16_SINT = 0xF0, + R16_UINT = 0xF1, R16_FLOAT = 0xF2, R8_UNORM = 0xF3, }; @@ -52,6 +55,9 @@ enum class DepthFormat : u32 { /// Returns the number of bytes per pixel of each rendertarget format. u32 RenderTargetBytesPerPixel(RenderTargetFormat format); +/// Returns the number of bytes per pixel of each depth format. +u32 DepthFormatBytesPerPixel(DepthFormat format); + class DebugContext; /** @@ -65,14 +71,7 @@ struct FramebufferConfig { /** * Returns the number of bytes per pixel. */ - static u32 BytesPerPixel(PixelFormat format) { - switch (format) { - case PixelFormat::ABGR8: - return 4; - } - - UNREACHABLE(); - } + static u32 BytesPerPixel(PixelFormat format); VAddr address; u32 offset; diff --git a/src/video_core/renderer_base.cpp b/src/video_core/renderer_base.cpp index 3ca350243..e87016429 100644 --- a/src/video_core/renderer_base.cpp +++ b/src/video_core/renderer_base.cpp @@ -4,18 +4,23 @@ #include <memory> #include "core/frontend/emu_window.h" +#include "core/settings.h" #include "video_core/renderer_base.h" #include "video_core/renderer_opengl/gl_rasterizer.h" namespace VideoCore { -RendererBase::RendererBase(EmuWindow& window) : render_window{window} {} +RendererBase::RendererBase(EmuWindow& window) : render_window{window} { + RefreshBaseSettings(); +} + RendererBase::~RendererBase() = default; -void RendererBase::UpdateCurrentFramebufferLayout() { - const Layout::FramebufferLayout& layout = render_window.GetFramebufferLayout(); +void RendererBase::RefreshBaseSettings() { + RefreshRasterizerSetting(); + UpdateCurrentFramebufferLayout(); - render_window.UpdateCurrentFramebufferLayout(layout.width, layout.height); + renderer_settings.use_framelimiter = Settings::values.toggle_framelimit; } void RendererBase::RefreshRasterizerSetting() { @@ -24,4 +29,10 @@ void RendererBase::RefreshRasterizerSetting() { } } +void RendererBase::UpdateCurrentFramebufferLayout() { + const Layout::FramebufferLayout& layout = render_window.GetFramebufferLayout(); + + render_window.UpdateCurrentFramebufferLayout(layout.width, layout.height); +} + } // namespace VideoCore diff --git a/src/video_core/renderer_base.h b/src/video_core/renderer_base.h index 235de23a1..fd8c47592 100644 --- a/src/video_core/renderer_base.h +++ b/src/video_core/renderer_base.h @@ -4,9 +4,9 @@ #pragma once +#include <atomic> #include <memory> #include <boost/optional.hpp> -#include "common/assert.h" #include "common/common_types.h" #include "video_core/gpu.h" #include "video_core/rasterizer_interface.h" @@ -15,11 +15,12 @@ class EmuWindow; namespace VideoCore { +struct RendererSettings { + std::atomic_bool use_framelimiter{false}; +}; + class RendererBase : NonCopyable { public: - /// Used to reference a framebuffer - enum kFramebuffer { kFramebuffer_VirtualXFB = 0, kFramebuffer_EFB, kFramebuffer_Texture }; - explicit RendererBase(EmuWindow& window); virtual ~RendererBase(); @@ -32,9 +33,6 @@ public: /// Shutdown the renderer virtual void ShutDown() = 0; - /// Updates the framebuffer layout of the contained render window handle. - void UpdateCurrentFramebufferLayout(); - // Getter/setter functions: // ------------------------ @@ -54,13 +52,23 @@ public: return *rasterizer; } - void RefreshRasterizerSetting(); + /// Refreshes the settings common to all renderers + void RefreshBaseSettings(); protected: + /// Refreshes settings specific to the rasterizer. + void RefreshRasterizerSetting(); + EmuWindow& render_window; ///< Reference to the render window handle. std::unique_ptr<RasterizerInterface> rasterizer; f32 m_current_fps = 0.0f; ///< Current framerate, should be set by the renderer int m_current_frame = 0; ///< Current frame, should be set by the renderer + + RendererSettings renderer_settings; + +private: + /// Updates the framebuffer layout of the contained render window handle. + void UpdateCurrentFramebufferLayout(); }; } // namespace VideoCore diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 9fb734b77..15a33ed9b 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -122,6 +122,9 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form {GL_R32F, GL_RED, GL_FLOAT, ComponentType::Float, false}, // R32F {GL_R16F, GL_RED, GL_HALF_FLOAT, ComponentType::Float, false}, // R16F {GL_R16, GL_RED, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // R16UNORM + {GL_R16_SNORM, GL_RED, GL_SHORT, ComponentType::SNorm, false}, // R16S + {GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT, ComponentType::UInt, false}, // R16UI + {GL_R16I, GL_RED_INTEGER, GL_SHORT, ComponentType::SInt, false}, // R16I {GL_RG16, GL_RG, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // RG16 {GL_RG16F, GL_RG, GL_HALF_FLOAT, ComponentType::Float, false}, // RG16F {GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT, ComponentType::UInt, false}, // RG16UI @@ -239,13 +242,14 @@ static constexpr std::array<void (*)(u32, u32, u32, std::vector<u8>&, Tegra::GPU MortonCopy<true, PixelFormat::G8R8>, MortonCopy<true, PixelFormat::BGRA8>, MortonCopy<true, PixelFormat::RGBA32F>, MortonCopy<true, PixelFormat::RG32F>, MortonCopy<true, PixelFormat::R32F>, MortonCopy<true, PixelFormat::R16F>, - MortonCopy<true, PixelFormat::R16UNORM>, MortonCopy<true, PixelFormat::RG16>, - MortonCopy<true, PixelFormat::RG16F>, MortonCopy<true, PixelFormat::RG16UI>, - MortonCopy<true, PixelFormat::RG16I>, MortonCopy<true, PixelFormat::RG16S>, - MortonCopy<true, PixelFormat::RGB32F>, MortonCopy<true, PixelFormat::SRGBA8>, - MortonCopy<true, PixelFormat::Z24S8>, MortonCopy<true, PixelFormat::S8Z24>, - MortonCopy<true, PixelFormat::Z32F>, MortonCopy<true, PixelFormat::Z16>, - MortonCopy<true, PixelFormat::Z32FS8>, + MortonCopy<true, PixelFormat::R16UNORM>, MortonCopy<true, PixelFormat::R16S>, + MortonCopy<true, PixelFormat::R16UI>, MortonCopy<true, PixelFormat::R16I>, + MortonCopy<true, PixelFormat::RG16>, MortonCopy<true, PixelFormat::RG16F>, + MortonCopy<true, PixelFormat::RG16UI>, MortonCopy<true, PixelFormat::RG16I>, + MortonCopy<true, PixelFormat::RG16S>, MortonCopy<true, PixelFormat::RGB32F>, + MortonCopy<true, PixelFormat::SRGBA8>, MortonCopy<true, PixelFormat::Z24S8>, + MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::Z32F>, + MortonCopy<true, PixelFormat::Z16>, MortonCopy<true, PixelFormat::Z32FS8>, }; static constexpr std::array<void (*)(u32, u32, u32, std::vector<u8>&, Tegra::GPUVAddr), @@ -276,6 +280,9 @@ static constexpr std::array<void (*)(u32, u32, u32, std::vector<u8>&, Tegra::GPU MortonCopy<false, PixelFormat::R32F>, MortonCopy<false, PixelFormat::R16F>, MortonCopy<false, PixelFormat::R16UNORM>, + MortonCopy<false, PixelFormat::R16S>, + MortonCopy<false, PixelFormat::R16UI>, + MortonCopy<false, PixelFormat::R16I>, MortonCopy<false, PixelFormat::RG16>, MortonCopy<false, PixelFormat::RG16F>, MortonCopy<false, PixelFormat::RG16UI>, diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 829a76dfe..e24ba8cfe 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h @@ -46,22 +46,25 @@ struct SurfaceParams { R32F = 20, R16F = 21, R16UNORM = 22, - RG16 = 23, - RG16F = 24, - RG16UI = 25, - RG16I = 26, - RG16S = 27, - RGB32F = 28, - SRGBA8 = 29, + R16S = 23, + R16UI = 24, + R16I = 25, + RG16 = 26, + RG16F = 27, + RG16UI = 28, + RG16I = 29, + RG16S = 30, + RGB32F = 31, + SRGBA8 = 32, MaxColorFormat, // DepthStencil formats - Z24S8 = 30, - S8Z24 = 31, - Z32F = 32, - Z16 = 33, - Z32FS8 = 34, + Z24S8 = 33, + S8Z24 = 34, + Z32F = 35, + Z16 = 36, + Z32FS8 = 37, MaxDepthStencilFormat, @@ -122,6 +125,9 @@ struct SurfaceParams { 1, // R32F 1, // R16F 1, // R16UNORM + 1, // R16S + 1, // R16UI + 1, // R16I 1, // RG16 1, // RG16F 1, // RG16UI @@ -168,6 +174,9 @@ struct SurfaceParams { 32, // R32F 16, // R16F 16, // R16UNORM + 16, // R16S + 16, // R16UI + 16, // R16I 32, // RG16 32, // RG16F 32, // RG16UI @@ -245,6 +254,14 @@ struct SurfaceParams { return PixelFormat::RG16S; case Tegra::RenderTargetFormat::R16_FLOAT: return PixelFormat::R16F; + case Tegra::RenderTargetFormat::R16_UNORM: + return PixelFormat::R16UNORM; + case Tegra::RenderTargetFormat::R16_SNORM: + return PixelFormat::R16S; + case Tegra::RenderTargetFormat::R16_UINT: + return PixelFormat::R16UI; + case Tegra::RenderTargetFormat::R16_SINT: + return PixelFormat::R16I; case Tegra::RenderTargetFormat::R32_FLOAT: return PixelFormat::R32F; default: @@ -293,6 +310,12 @@ struct SurfaceParams { return PixelFormat::R16F; case Tegra::Texture::ComponentType::UNORM: return PixelFormat::R16UNORM; + case Tegra::Texture::ComponentType::SNORM: + return PixelFormat::R16S; + case Tegra::Texture::ComponentType::UINT: + return PixelFormat::R16UI; + case Tegra::Texture::ComponentType::SINT: + return PixelFormat::R16I; } LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type)); @@ -376,9 +399,11 @@ struct SurfaceParams { case Tegra::RenderTargetFormat::RGB10_A2_UNORM: case Tegra::RenderTargetFormat::R8_UNORM: case Tegra::RenderTargetFormat::RG16_UNORM: + case Tegra::RenderTargetFormat::R16_UNORM: case Tegra::RenderTargetFormat::B5G6R5_UNORM: return ComponentType::UNorm; case Tegra::RenderTargetFormat::RG16_SNORM: + case Tegra::RenderTargetFormat::R16_SNORM: return ComponentType::SNorm; case Tegra::RenderTargetFormat::RGBA16_FLOAT: case Tegra::RenderTargetFormat::R11G11B10_FLOAT: @@ -390,8 +415,10 @@ struct SurfaceParams { return ComponentType::Float; case Tegra::RenderTargetFormat::RGBA32_UINT: case Tegra::RenderTargetFormat::RG16_UINT: + case Tegra::RenderTargetFormat::R16_UINT: return ComponentType::UInt; case Tegra::RenderTargetFormat::RG16_SINT: + case Tegra::RenderTargetFormat::R16_SINT: return ComponentType::SInt; default: LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp index 5085ef96b..1e686b89e 100644 --- a/src/video_core/video_core.cpp +++ b/src/video_core/video_core.cpp @@ -9,8 +9,6 @@ namespace VideoCore { -std::atomic<bool> g_toggle_framelimit_enabled; - std::unique_ptr<RendererBase> CreateRenderer(EmuWindow& emu_window) { return std::make_unique<RendererOpenGL>(emu_window); } diff --git a/src/video_core/video_core.h b/src/video_core/video_core.h index 7c01c0b8d..2dc07540f 100644 --- a/src/video_core/video_core.h +++ b/src/video_core/video_core.h @@ -4,7 +4,6 @@ #pragma once -#include <atomic> #include <memory> class EmuWindow; @@ -13,12 +12,6 @@ namespace VideoCore { class RendererBase; -enum class Renderer { Software, OpenGL }; - -// TODO: Wrap these in a user settings struct along with any other graphics settings (often set from -// qt ui) -extern std::atomic<bool> g_toggle_framelimit_enabled; - /** * Creates a renderer instance. * |