mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-22 05:15:51 +12:00
[Shader JIT] Add caching
This commit is contained in:
parent
364443d66f
commit
4064abfdeb
9 changed files with 77 additions and 5 deletions
|
@ -1,22 +1,35 @@
|
|||
#pragma once
|
||||
#include "PICA/shader.hpp"
|
||||
|
||||
#if defined(PANDA3DS_DYNAPICA_SUPPORTED) && defined(PANDA3DS_X64_HOST)
|
||||
#define PANDA3DS_SHADER_JIT_SUPPORTED
|
||||
#include <unordered_map>
|
||||
#endif
|
||||
|
||||
class ShaderJIT {
|
||||
#ifdef PANDA3DS_SHADER_JIT_SUPPORTED
|
||||
using Hash = PICAShader::Hash;
|
||||
using ShaderCache = std::unordered_map<Hash, int>;
|
||||
|
||||
ShaderCache cache;
|
||||
void compileShader(PICAShader& shaderUnit);
|
||||
#endif
|
||||
|
||||
public:
|
||||
#if defined(PANDA3DS_DYNAPICA_SUPPORTED) && defined(PANDA3DS_X64_HOST)
|
||||
#define PANDA3DS_SHADER_JIT_SUPPORTED
|
||||
|
||||
#ifdef 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);
|
||||
void reset();
|
||||
|
||||
static constexpr bool isAvailable() { return true; }
|
||||
#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");
|
||||
}
|
||||
|
||||
void reset() {}
|
||||
static constexpr bool isAvailable() { return false; }
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue