mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-09 07:35:41 +12:00
More shader JIT groundwork
This commit is contained in:
parent
bf0436a85b
commit
cf9ed3d460
7 changed files with 46 additions and 7 deletions
|
@ -91,8 +91,10 @@ set(SERVICE_SOURCE_FILES src/core/services/service_manager.cpp src/core/services
|
||||||
src/core/services/act.cpp src/core/services/nfc.cpp src/core/services/dlp_srvr.cpp
|
src/core/services/act.cpp src/core/services/nfc.cpp src/core/services/dlp_srvr.cpp
|
||||||
)
|
)
|
||||||
set(PICA_SOURCE_FILES src/core/PICA/gpu.cpp src/core/PICA/regs.cpp src/core/PICA/shader_unit.cpp
|
set(PICA_SOURCE_FILES src/core/PICA/gpu.cpp src/core/PICA/regs.cpp src/core/PICA/shader_unit.cpp
|
||||||
src/core/PICA/shader_interpreter.cpp
|
src/core/PICA/shader_interpreter.cpp src/core/PICA/dynapica/shader_rec.cpp
|
||||||
|
src/core/PICA/dynapica/shader_rec_instructions_x64.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(RENDERER_GL_SOURCE_FILES src/core/renderer_gl/renderer_gl.cpp src/core/renderer_gl/textures.cpp src/core/renderer_gl/etc1.cpp)
|
set(RENDERER_GL_SOURCE_FILES src/core/renderer_gl/renderer_gl.cpp src/core/renderer_gl/textures.cpp src/core/renderer_gl/etc1.cpp)
|
||||||
|
|
||||||
set(LOADER_SOURCE_FILES src/core/loader/elf.cpp src/core/loader/ncsd.cpp src/core/loader/ncch.cpp src/core/loader/lz77.cpp)
|
set(LOADER_SOURCE_FILES src/core/loader/elf.cpp src/core/loader/ncsd.cpp src/core/loader/ncch.cpp src/core/loader/lz77.cpp)
|
||||||
|
@ -119,7 +121,7 @@ set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/opengl.hpp inc
|
||||||
include/renderer_gl/textures.hpp include/colour.hpp include/services/y2r.hpp include/services/cam.hpp
|
include/renderer_gl/textures.hpp include/colour.hpp include/services/y2r.hpp include/services/cam.hpp
|
||||||
include/services/ldr_ro.hpp include/ipc.hpp include/services/act.hpp include/services/nfc.hpp
|
include/services/ldr_ro.hpp include/ipc.hpp include/services/act.hpp include/services/nfc.hpp
|
||||||
include/system_models.hpp include/services/dlp_srvr.hpp include/PICA/dynapica/pica_recs.hpp
|
include/system_models.hpp include/services/dlp_srvr.hpp include/PICA/dynapica/pica_recs.hpp
|
||||||
include/PICA/dynapica/x64_regs.hpp include/PICA/dynapica/vertex_loader_rec.hpp
|
include/PICA/dynapica/x64_regs.hpp include/PICA/dynapica/vertex_loader_rec.hpp include/PICA/dynapica/shader_rec.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp
|
set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp
|
||||||
|
|
21
include/PICA/dynapica/shader_rec.hpp
Normal file
21
include/PICA/dynapica/shader_rec.hpp
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#pragma once
|
||||||
|
#include "PICA/shader.hpp"
|
||||||
|
|
||||||
|
class ShaderJIT {
|
||||||
|
void compileShader(PICAShader& shaderUnit);
|
||||||
|
|
||||||
|
public:
|
||||||
|
#if defined(PANDA3DS_DYNAPICA_SUPPORTED) && defined(PANDA3DS_X64_HOST)
|
||||||
|
#define PANDA3DS_SHADER_JIT_SUPPORTED
|
||||||
|
|
||||||
|
// Call this before starting to process a batch of vertices
|
||||||
|
// This will read the PICA config (uploaded shader and shader operand descriptors) and search if we've already compiled this shader
|
||||||
|
// If yes, it sets it as the active shader. if not, then it compiles it, adds it to the cache, and sets it as active,
|
||||||
|
void prepare(PICAShader& shaderUnit);
|
||||||
|
#else
|
||||||
|
void prepare(PICAShader& shaderUnit) {
|
||||||
|
Helpers::panic("Vertex Loader JIT: Tried to load vertices with JIT on platform that does not support vertex loader jit");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
|
@ -12,11 +12,15 @@ class VertexLoaderJIT {
|
||||||
Callback compileConfig(PICARegs regs);
|
Callback compileConfig(PICARegs regs);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#ifndef PANDA3DS_DYNAPICA_SUPPORTED
|
#if defined(PANDA3DS_DYNAPICA_SUPPORTED) && defined(PANDA3DS_X64_HOST)
|
||||||
|
void loadVertices(Vertex* output, size_t count, PICARegs regs);
|
||||||
|
static constexpr bool isAvailable() { return true; }
|
||||||
|
|
||||||
|
#else
|
||||||
void loadVertices(Vertex* output, size_t count, PICARegs regs) {
|
void loadVertices(Vertex* output, size_t count, PICARegs regs) {
|
||||||
Helpers::panic("Vertex Loader JIT: Tried to load vertices with JIT on platform that does not support vertex loader jit");
|
Helpers::panic("Vertex Loader JIT: Tried to load vertices with JIT on platform that does not support vertex loader jit");
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
void loadVertices(Vertex* output, size_t count, PICARegs regs);
|
static constexpr bool isAvailable() { return false; }
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
|
@ -6,6 +6,7 @@
|
||||||
#include "PICA/float_types.hpp"
|
#include "PICA/float_types.hpp"
|
||||||
#include "PICA/regs.hpp"
|
#include "PICA/regs.hpp"
|
||||||
#include "PICA/shader_unit.hpp"
|
#include "PICA/shader_unit.hpp"
|
||||||
|
#include "PICA/dynapica/shader_rec.hpp"
|
||||||
#include "renderer_gl/renderer_gl.hpp"
|
#include "renderer_gl/renderer_gl.hpp"
|
||||||
|
|
||||||
class GPU {
|
class GPU {
|
||||||
|
|
|
@ -71,6 +71,8 @@ class PICAShader {
|
||||||
bool f32UniformTransfer = false; // Are we transferring an f32 uniform or an f24 uniform?
|
bool f32UniformTransfer = false; // Are we transferring an f32 uniform or an f24 uniform?
|
||||||
|
|
||||||
std::array<u32, 4> floatUniformBuffer; // Buffer for temporarily caching float uniform data
|
std::array<u32, 4> floatUniformBuffer; // Buffer for temporarily caching float uniform data
|
||||||
|
|
||||||
|
protected:
|
||||||
std::array<u32, 128> operandDescriptors;
|
std::array<u32, 128> operandDescriptors;
|
||||||
std::array<vec4f, 16> tempRegisters; // General purpose registers the shader can use for temp values
|
std::array<vec4f, 16> tempRegisters; // General purpose registers the shader can use for temp values
|
||||||
OpenGL::Vector<s32, 2> addrRegister; // Address register
|
OpenGL::Vector<s32, 2> addrRegister; // Address register
|
||||||
|
@ -85,13 +87,15 @@ class PICAShader {
|
||||||
std::array<Loop, 4> loopInfo;
|
std::array<Loop, 4> loopInfo;
|
||||||
std::array<ConditionalInfo, 8> conditionalInfo;
|
std::array<ConditionalInfo, 8> conditionalInfo;
|
||||||
std::array<CallInfo, 4> callInfo;
|
std::array<CallInfo, 4> callInfo;
|
||||||
|
|
||||||
ShaderType type;
|
ShaderType type;
|
||||||
|
|
||||||
|
friend class ShaderJIT;
|
||||||
|
|
||||||
|
private:
|
||||||
vec4f getSource(u32 source);
|
vec4f getSource(u32 source);
|
||||||
vec4f& getDest(u32 dest);
|
vec4f& getDest(u32 dest);
|
||||||
|
|
||||||
// Shader opcodes
|
// Interpreter functions for the various shader functions
|
||||||
void add(u32 instruction);
|
void add(u32 instruction);
|
||||||
void call(u32 instruction);
|
void call(u32 instruction);
|
||||||
void callc(u32 instruction);
|
void callc(u32 instruction);
|
||||||
|
|
7
src/core/PICA/dynapica/shader_rec.cpp
Normal file
7
src/core/PICA/dynapica/shader_rec.cpp
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#include "PICA/dynapica/shader_rec.hpp"
|
||||||
|
|
||||||
|
#ifdef PANDA3DS_SHADER_JIT_SUPPORTED
|
||||||
|
void ShaderJIT::prepare(PICAShader& shaderUnit) {
|
||||||
|
printf("HAPPY HAPPY HAPPY\n");
|
||||||
|
}
|
||||||
|
#endif // PANDA3DS_SHADER_JIT_SUPPORTED
|
0
src/core/PICA/dynapica/shader_rec_instructions_x64.cpp
Normal file
0
src/core/PICA/dynapica/shader_rec_instructions_x64.cpp
Normal file
Loading…
Add table
Reference in a new issue