mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-07-20 14:01:44 +12:00
Merge remote-tracking branch 'upstream/master' into http-server-improvements
This commit is contained in:
commit
a0a821a1ac
26 changed files with 942 additions and 20 deletions
|
@ -83,7 +83,7 @@ class GPU {
|
|||
bool lightingLUTDirty = false;
|
||||
|
||||
GPU(Memory& mem, EmulatorConfig& config);
|
||||
void initGraphicsContext() { renderer->initGraphicsContext(); }
|
||||
void initGraphicsContext(SDL_Window* window) { renderer->initGraphicsContext(window); }
|
||||
void display() { renderer->display(); }
|
||||
void screenshot(const std::string& name) { renderer->screenshot(name); }
|
||||
|
||||
|
@ -103,9 +103,7 @@ class GPU {
|
|||
|
||||
// TODO: Emulate the transfer engine & its registers
|
||||
// Then this can be emulated by just writing the appropriate values there
|
||||
void clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) {
|
||||
renderer->clearBuffer(startAddress, endAddress, value, control);
|
||||
}
|
||||
void clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) { renderer->clearBuffer(startAddress, endAddress, value, control); }
|
||||
|
||||
// TODO: Emulate the transfer engine & its registers
|
||||
// Then this can be emulated by just writing the appropriate values there
|
||||
|
|
|
@ -16,6 +16,7 @@ enum class RendererType : s8 {
|
|||
};
|
||||
|
||||
class GPU;
|
||||
struct SDL_Window;
|
||||
|
||||
class Renderer {
|
||||
protected:
|
||||
|
@ -42,7 +43,7 @@ class Renderer {
|
|||
|
||||
virtual void reset() = 0;
|
||||
virtual void display() = 0; // Display the 3DS screen contents to the window
|
||||
virtual void initGraphicsContext() = 0; // Initialize graphics context
|
||||
virtual void initGraphicsContext(SDL_Window* window) = 0; // Initialize graphics context
|
||||
virtual void clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) = 0; // Clear a GPU buffer in VRAM
|
||||
virtual void displayTransfer(u32 inputAddr, u32 outputAddr, u32 inputSize, u32 outputSize, u32 flags) = 0; // Perform display transfer
|
||||
virtual void drawVertices(PICA::PrimType primType, std::span<const PICA::Vertex> vertices) = 0; // Draw the given vertices
|
||||
|
|
|
@ -72,7 +72,7 @@ class RendererGL final : public Renderer {
|
|||
|
||||
void reset() override;
|
||||
void display() override; // Display the 3DS screen contents to the window
|
||||
void initGraphicsContext() override; // Initialize graphics context
|
||||
void initGraphicsContext(SDL_Window* window) override; // Initialize graphics context
|
||||
void clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) override; // Clear a GPU buffer in VRAM
|
||||
void displayTransfer(u32 inputAddr, u32 outputAddr, u32 inputSize, u32 outputSize, u32 flags) override; // Perform display transfer
|
||||
void drawVertices(PICA::PrimType primType, std::span<const PICA::Vertex> vertices) override; // Draw the given vertices
|
||||
|
|
|
@ -9,7 +9,7 @@ class RendererNull final : public Renderer {
|
|||
|
||||
void reset() override;
|
||||
void display() override;
|
||||
void initGraphicsContext() override;
|
||||
void initGraphicsContext(SDL_Window* window) override;
|
||||
void clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) override;
|
||||
void displayTransfer(u32 inputAddr, u32 outputAddr, u32 inputSize, u32 outputSize, u32 flags) override;
|
||||
void drawVertices(PICA::PrimType primType, std::span<const PICA::Vertex> vertices) override;
|
||||
|
|
|
@ -9,7 +9,7 @@ class RendererSw final : public Renderer {
|
|||
|
||||
void reset() override;
|
||||
void display() override;
|
||||
void initGraphicsContext() override;
|
||||
void initGraphicsContext(SDL_Window* window) override;
|
||||
void clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) override;
|
||||
void displayTransfer(u32 inputAddr, u32 outputAddr, u32 inputSize, u32 outputSize, u32 flags) override;
|
||||
void drawVertices(PICA::PrimType primType, std::span<const PICA::Vertex> vertices) override;
|
||||
|
|
57
include/renderer_vk/renderer_vk.hpp
Normal file
57
include/renderer_vk/renderer_vk.hpp
Normal file
|
@ -0,0 +1,57 @@
|
|||
#include "renderer.hpp"
|
||||
#include "vulkan_api.hpp"
|
||||
|
||||
class GPU;
|
||||
|
||||
class RendererVK final : public Renderer {
|
||||
SDL_Window* targetWindow;
|
||||
|
||||
// The order of these `Unique*` members is important, they will be destroyed in RAII order
|
||||
vk::UniqueInstance instance = {};
|
||||
vk::UniqueDebugUtilsMessengerEXT debugMessenger = {};
|
||||
|
||||
vk::UniqueSurfaceKHR surface = {};
|
||||
|
||||
vk::PhysicalDevice physicalDevice = {};
|
||||
|
||||
vk::UniqueDevice device = {};
|
||||
|
||||
vk::Queue presentQueue = {};
|
||||
u32 presentQueueFamily = ~0u;
|
||||
vk::Queue graphicsQueue = {};
|
||||
u32 graphicsQueueFamily = ~0u;
|
||||
vk::Queue computeQueue = {};
|
||||
u32 computeQueueFamily = ~0u;
|
||||
vk::Queue transferQueue = {};
|
||||
u32 transferQueueFamily = ~0u;
|
||||
|
||||
vk::UniqueCommandPool commandPool = {};
|
||||
|
||||
vk::UniqueSwapchainKHR swapchain = {};
|
||||
u32 swapchainImageCount = ~0u;
|
||||
std::vector<vk::Image> swapchainImages = {};
|
||||
std::vector<vk::UniqueImageView> swapchainImageViews = {};
|
||||
|
||||
// Per-swapchain-image data
|
||||
// Each vector is `swapchainImageCount` in size
|
||||
std::vector<vk::UniqueCommandBuffer> presentCommandBuffers = {};
|
||||
std::vector<vk::UniqueSemaphore> swapImageFreeSemaphore = {};
|
||||
std::vector<vk::UniqueSemaphore> renderFinishedSemaphore = {};
|
||||
std::vector<vk::UniqueFence> frameFinishedFences = {};
|
||||
|
||||
// Recreate the swapchain, possibly re-using the old one in the case of a resize
|
||||
vk::Result recreateSwapchain(vk::SurfaceKHR surface, vk::Extent2D swapchainExtent);
|
||||
|
||||
u64 currentFrame = 0;
|
||||
public:
|
||||
RendererVK(GPU& gpu, const std::array<u32, regNum>& internalRegs);
|
||||
~RendererVK() override;
|
||||
|
||||
void reset() override;
|
||||
void display() override;
|
||||
void initGraphicsContext(SDL_Window* window) override;
|
||||
void clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) override;
|
||||
void displayTransfer(u32 inputAddr, u32 outputAddr, u32 inputSize, u32 outputSize, u32 flags) override;
|
||||
void drawVertices(PICA::PrimType primType, std::span<const PICA::Vertex> vertices) override;
|
||||
void screenshot(const std::string& name) override;
|
||||
};
|
48
include/renderer_vk/vk_debug.hpp
Normal file
48
include/renderer_vk/vk_debug.hpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
#pragma once
|
||||
|
||||
#include <span>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "vulkan_api.hpp"
|
||||
|
||||
namespace Vulkan {
|
||||
|
||||
VKAPI_ATTR VkBool32 VKAPI_CALL debugMessageCallback(
|
||||
VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType,
|
||||
const VkDebugUtilsMessengerCallbackDataEXT* callbackData, void* userData
|
||||
);
|
||||
|
||||
void setObjectName(vk::Device device, vk::ObjectType objectType, const void* objectHandle, const char* format, ...);
|
||||
|
||||
template <typename T, typename = std::enable_if_t<vk::isVulkanHandleType<T>::value == true>, typename... ArgsT>
|
||||
inline void setObjectName(vk::Device device, const T objectHandle, const char* format, ArgsT&&... args) {
|
||||
setObjectName(device, T::objectType, objectHandle, format, std::forward<ArgsT>(args)...);
|
||||
}
|
||||
|
||||
void beginDebugLabel(vk::CommandBuffer commandBuffer, std::span<const float, 4> color, const char* format, ...);
|
||||
|
||||
void insertDebugLabel(vk::CommandBuffer commandBuffer, std::span<const float, 4> color, const char* format, ...);
|
||||
|
||||
void endDebugLabel(vk::CommandBuffer commandBuffer);
|
||||
|
||||
class DebugLabelScope {
|
||||
private:
|
||||
const vk::CommandBuffer commandBuffer;
|
||||
|
||||
public:
|
||||
template <typename... ArgsT>
|
||||
DebugLabelScope(vk::CommandBuffer targetCommandBuffer, std::span<const float, 4> color, const char* format, ArgsT&&... args)
|
||||
: commandBuffer(targetCommandBuffer) {
|
||||
beginDebugLabel(commandBuffer, color, format, std::forward<ArgsT>(args)...);
|
||||
}
|
||||
|
||||
template <typename... ArgsT>
|
||||
void operator()(std::span<const float, 4> color, const char* format, ArgsT&&... args) const {
|
||||
insertDebugLabel(commandBuffer, color, format, std::forward<ArgsT>(args)...);
|
||||
}
|
||||
|
||||
~DebugLabelScope() { endDebugLabel(commandBuffer); }
|
||||
};
|
||||
|
||||
} // namespace Vulkan
|
12
include/renderer_vk/vulkan_api.hpp
Normal file
12
include/renderer_vk/vulkan_api.hpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#define VK_NO_PROTOTYPES
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1
|
||||
#define VULKAN_HPP_NO_EXCEPTIONS
|
||||
// Disable asserts on result-codes
|
||||
#define VULKAN_HPP_ASSERT_ON_RESULT
|
||||
#include <vulkan/vulkan.hpp>
|
||||
#include <vulkan/vulkan_format_traits.hpp>
|
||||
#include <vulkan/vulkan_hash.hpp>
|
|
@ -11,6 +11,7 @@ class ACService {
|
|||
MAKE_LOG_FUNCTION(log, acLogger)
|
||||
|
||||
// Service commands
|
||||
void getLastErrorCode(u32 messagePointer);
|
||||
void setClientVersion(u32 messagePointer);
|
||||
|
||||
public:
|
||||
|
|
|
@ -15,6 +15,7 @@ class MICService {
|
|||
void mapSharedMem(u32 messagePointer);
|
||||
void setClamp(u32 messagePointer);
|
||||
void setGain(u32 messagePointer);
|
||||
void setIirFilter(u32 messagePointer);
|
||||
void setPower(u32 messagePointer);
|
||||
void startSampling(u32 messagePointer);
|
||||
void theCaptainToadFunction(u32 messagePointer);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue