diff --git a/include/PICA/dynapica/shader_rec.hpp b/include/PICA/dynapica/shader_rec.hpp index 9a17e905..48104364 100644 --- a/include/PICA/dynapica/shader_rec.hpp +++ b/include/PICA/dynapica/shader_rec.hpp @@ -12,10 +12,12 @@ public: // 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); + 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"); } + static constexpr bool isAvailable() { return false; } #endif }; \ No newline at end of file diff --git a/include/PICA/dynapica/vertex_loader_rec.hpp b/include/PICA/dynapica/vertex_loader_rec.hpp index 71be1ca9..b515a4f7 100644 --- a/include/PICA/dynapica/vertex_loader_rec.hpp +++ b/include/PICA/dynapica/vertex_loader_rec.hpp @@ -13,6 +13,8 @@ class VertexLoaderJIT { public: #if defined(PANDA3DS_DYNAPICA_SUPPORTED) && defined(PANDA3DS_X64_HOST) + #define PANDA3DS_VERTEX_LOADER_JIT_SUPPORTED + void loadVertices(Vertex* output, size_t count, PICARegs regs); static constexpr bool isAvailable() { return true; } diff --git a/include/PICA/gpu.hpp b/include/PICA/gpu.hpp index 284e5a28..347dd946 100644 --- a/include/PICA/gpu.hpp +++ b/include/PICA/gpu.hpp @@ -29,7 +29,7 @@ class GPU { uint immediateModeVertIndex; uint immediateModeAttrIndex; // Index of the immediate mode attribute we're uploading - template + template void drawArrays(); // Silly method of avoiding linking problems. TODO: Change to something less silly diff --git a/src/core/PICA/gpu.cpp b/src/core/PICA/gpu.cpp index 7e9ddfea..e11b07a2 100644 --- a/src/core/PICA/gpu.cpp +++ b/src/core/PICA/gpu.cpp @@ -33,16 +33,25 @@ void GPU::reset() { renderer.reset(); } +// Call the correct version of drawArrays based on whether this is an indexed draw (first template parameter) +// And whether we are going to use the shader JIT (second template parameter) void GPU::drawArrays(bool indexed) { - if (indexed) - drawArrays(); - else - drawArrays(); + if (indexed) { + if constexpr (ShaderJIT::isAvailable()) + drawArrays(); + else + drawArrays(); + } else { + if constexpr (ShaderJIT::isAvailable()) + drawArrays(); + else + drawArrays(); + } } Vertex* vertices = new Vertex[Renderer::vertexBufferSize]; -template +template void GPU::drawArrays() { // Base address for vertex attributes // The vertex base is always on a quadword boundary because the PICA does weird alignment shit any time possible