mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 23:25:40 +12:00
Add SDL_Window
to initGraphicsContext
prototype
This value is needed for vulkan to properly allocate a surface, and would benefit OpenGL to move more of its initialization code into here rather than in `emulator.cpp`.
This commit is contained in:
parent
870b6a21bf
commit
b048d4dd6e
9 changed files with 16 additions and 13 deletions
|
@ -83,7 +83,7 @@ class GPU {
|
||||||
bool lightingLUTDirty = false;
|
bool lightingLUTDirty = false;
|
||||||
|
|
||||||
GPU(Memory& mem, EmulatorConfig& config);
|
GPU(Memory& mem, EmulatorConfig& config);
|
||||||
void initGraphicsContext() { renderer->initGraphicsContext(); }
|
void initGraphicsContext(SDL_Window* window) { renderer->initGraphicsContext(window); }
|
||||||
void display() { renderer->display(); }
|
void display() { renderer->display(); }
|
||||||
void screenshot(const std::string& name) { renderer->screenshot(name); }
|
void screenshot(const std::string& name) { renderer->screenshot(name); }
|
||||||
|
|
||||||
|
@ -103,9 +103,7 @@ class GPU {
|
||||||
|
|
||||||
// TODO: Emulate the transfer engine & its registers
|
// TODO: Emulate the transfer engine & its registers
|
||||||
// Then this can be emulated by just writing the appropriate values there
|
// Then this can be emulated by just writing the appropriate values there
|
||||||
void clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) {
|
void clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) { renderer->clearBuffer(startAddress, endAddress, value, control); }
|
||||||
renderer->clearBuffer(startAddress, endAddress, value, control);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Emulate the transfer engine & its registers
|
// TODO: Emulate the transfer engine & its registers
|
||||||
// Then this can be emulated by just writing the appropriate values there
|
// Then this can be emulated by just writing the appropriate values there
|
||||||
|
|
|
@ -16,6 +16,7 @@ enum class RendererType : s8 {
|
||||||
};
|
};
|
||||||
|
|
||||||
class GPU;
|
class GPU;
|
||||||
|
class SDL_Window;
|
||||||
|
|
||||||
class Renderer {
|
class Renderer {
|
||||||
protected:
|
protected:
|
||||||
|
@ -42,7 +43,7 @@ class Renderer {
|
||||||
|
|
||||||
virtual void reset() = 0;
|
virtual void reset() = 0;
|
||||||
virtual void display() = 0; // Display the 3DS screen contents to the window
|
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 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 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
|
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 reset() override;
|
||||||
void display() override; // Display the 3DS screen contents to the window
|
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 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 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
|
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 reset() override;
|
||||||
void display() 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 clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) override;
|
||||||
void displayTransfer(u32 inputAddr, u32 outputAddr, u32 inputSize, u32 outputSize, u32 flags) 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 drawVertices(PICA::PrimType primType, std::span<const PICA::Vertex> vertices) override;
|
||||||
|
|
|
@ -16,7 +16,7 @@ class RendererVK final : public Renderer {
|
||||||
|
|
||||||
void reset() override;
|
void reset() override;
|
||||||
void display() 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 clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) override;
|
||||||
void displayTransfer(u32 inputAddr, u32 outputAddr, u32 inputSize, u32 outputSize, u32 flags) 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 drawVertices(PICA::PrimType primType, std::span<const PICA::Vertex> vertices) override;
|
||||||
|
|
|
@ -45,7 +45,7 @@ void RendererGL::reset() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererGL::initGraphicsContext() {
|
void RendererGL::initGraphicsContext(SDL_Window* window) {
|
||||||
gl.reset();
|
gl.reset();
|
||||||
|
|
||||||
auto gl_resources = cmrc::RendererGL::get_filesystem();
|
auto gl_resources = cmrc::RendererGL::get_filesystem();
|
||||||
|
|
|
@ -5,7 +5,7 @@ RendererNull::~RendererNull() {}
|
||||||
|
|
||||||
void RendererNull::reset() {}
|
void RendererNull::reset() {}
|
||||||
void RendererNull::display() {}
|
void RendererNull::display() {}
|
||||||
void RendererNull::initGraphicsContext() {}
|
void RendererNull::initGraphicsContext(SDL_Window* window) {}
|
||||||
void RendererNull::clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) {}
|
void RendererNull::clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) {}
|
||||||
void RendererNull::displayTransfer(u32 inputAddr, u32 outputAddr, u32 inputSize, u32 outputSize, u32 flags) {}
|
void RendererNull::displayTransfer(u32 inputAddr, u32 outputAddr, u32 inputSize, u32 outputSize, u32 flags) {}
|
||||||
void RendererNull::drawVertices(PICA::PrimType primType, std::span<const PICA::Vertex> vertices) {}
|
void RendererNull::drawVertices(PICA::PrimType primType, std::span<const PICA::Vertex> vertices) {}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "renderer_vk/renderer_vk.hpp"
|
#include "renderer_vk/renderer_vk.hpp"
|
||||||
|
|
||||||
|
#include "SDL_vulkan.h"
|
||||||
#include "helpers.hpp"
|
#include "helpers.hpp"
|
||||||
#include "renderer_vk/vk_debug.hpp"
|
#include "renderer_vk/vk_debug.hpp"
|
||||||
|
|
||||||
|
@ -11,7 +12,7 @@ void RendererVK::reset() {}
|
||||||
|
|
||||||
void RendererVK::display() {}
|
void RendererVK::display() {}
|
||||||
|
|
||||||
void RendererVK::initGraphicsContext() {
|
void RendererVK::initGraphicsContext(SDL_Window* window) {
|
||||||
// Resolve all function pointers
|
// Resolve all function pointers
|
||||||
static vk::DynamicLoader dl;
|
static vk::DynamicLoader dl;
|
||||||
VULKAN_HPP_DEFAULT_DISPATCHER.init(dl.getProcAddress<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr"));
|
VULKAN_HPP_DEFAULT_DISPATCHER.init(dl.getProcAddress<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr"));
|
||||||
|
@ -129,6 +130,9 @@ void RendererVK::initGraphicsContext() {
|
||||||
|
|
||||||
// Initialize device-specific function pointers
|
// Initialize device-specific function pointers
|
||||||
VULKAN_HPP_DEFAULT_DISPATCHER.init(device.get());
|
VULKAN_HPP_DEFAULT_DISPATCHER.init(device.get());
|
||||||
|
|
||||||
|
VkSurfaceKHR surface;
|
||||||
|
SDL_Vulkan_CreateSurface(window, instance.get(), &surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererVK::clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) {}
|
void RendererVK::clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) {}
|
||||||
|
|
|
@ -54,7 +54,7 @@ Emulator::Emulator()
|
||||||
|
|
||||||
#ifdef PANDA3DS_ENABLE_VULKAN
|
#ifdef PANDA3DS_ENABLE_VULKAN
|
||||||
if (config.rendererType == RendererType::Vulkan) {
|
if (config.rendererType == RendererType::Vulkan) {
|
||||||
// window = SDL_CreateWindow("Alber", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_VULKAN);
|
window = SDL_CreateWindow("Alber", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_VULKAN);
|
||||||
|
|
||||||
if (window == nullptr) {
|
if (window == nullptr) {
|
||||||
// Helpers::panic("Window creation failed: %s", SDL_GetError());
|
// Helpers::panic("Window creation failed: %s", SDL_GetError());
|
||||||
|
@ -457,7 +457,7 @@ bool Emulator::loadELF(std::ifstream& file) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset our graphics context and initialize the GPU's graphics context
|
// Reset our graphics context and initialize the GPU's graphics context
|
||||||
void Emulator::initGraphicsContext() { gpu.initGraphicsContext(); }
|
void Emulator::initGraphicsContext() { gpu.initGraphicsContext(window); }
|
||||||
|
|
||||||
#ifdef PANDA3DS_ENABLE_HTTP_SERVER
|
#ifdef PANDA3DS_ENABLE_HTTP_SERVER
|
||||||
void Emulator::pollHttpServer() {
|
void Emulator::pollHttpServer() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue