GPU: Cleanup immediate mode handling

This commit is contained in:
wheremyfoodat 2024-08-25 16:02:54 +03:00
parent f96b609123
commit 33e63f7d7a
5 changed files with 9 additions and 8 deletions

View file

@ -84,7 +84,7 @@ class Renderer {
// It is responsible for things like looking up which vertex/fragment shaders to use, recompiling them if they don't exist, choosing between
// ubershaders and shadergen, and so on.
// Returns whether this draw is eligible for using hardware-accelerated shaders or if shaders should run on the CPU
virtual bool prepareForDraw(ShaderUnit& shaderUnit, PICA::DrawAcceleration* accel, bool isImmediateMode) { return false; }
virtual bool prepareForDraw(ShaderUnit& shaderUnit, PICA::DrawAcceleration* accel) { return false; }
// Functions for initializing the graphics context for the Qt frontend, where we don't have the convenience of SDL_Window
#ifdef PANDA3DS_FRONTEND_QT

View file

@ -160,7 +160,7 @@ class RendererGL final : public Renderer {
virtual bool supportsShaderReload() override { return true; }
virtual std::string getUbershader() override;
virtual void setUbershader(const std::string& shader) override;
virtual bool prepareForDraw(ShaderUnit& shaderUnit, PICA::DrawAcceleration* accel, bool isImmediateMode) override;
virtual bool prepareForDraw(ShaderUnit& shaderUnit, PICA::DrawAcceleration* accel) override;
std::optional<ColourBuffer> getColourBuffer(u32 addr, PICA::ColorFmt format, u32 width, u32 height, bool createIfnotFound = true);

View file

@ -131,7 +131,7 @@ void GPU::drawArrays(bool indexed) {
getAcceleratedDrawInfo(accel, indexed);
}
const bool hwShaders = renderer->prepareForDraw(shaderUnit, &accel, false);
const bool hwShaders = renderer->prepareForDraw(shaderUnit, &accel);
if (hwShaders) {
if (indexed) {

View file

@ -249,7 +249,7 @@ void GPU::writeInternalReg(u32 index, u32 value, u32 mask) {
// If we've reached 3 verts, issue a draw call
// Handle rendering depending on the primitive type
if (immediateModeVertIndex == 3) {
renderer->prepareForDraw(shaderUnit, nullptr, true);
renderer->prepareForDraw(shaderUnit, nullptr);
renderer->drawVertices(PICA::PrimType::TriangleList, immediateModeVertices);
switch (primType) {

View file

@ -950,7 +950,7 @@ OpenGL::Program& RendererGL::getSpecializedShader() {
return program;
}
bool RendererGL::prepareForDraw(ShaderUnit& shaderUnit, PICA::DrawAcceleration* accel, bool isImmediateMode) {
bool RendererGL::prepareForDraw(ShaderUnit& shaderUnit, PICA::DrawAcceleration* accel) {
// First we figure out if we will be using an ubershader
bool usingUbershader = emulatorConfig->useUbershaders;
if (usingUbershader) {
@ -966,7 +966,7 @@ bool RendererGL::prepareForDraw(ShaderUnit& shaderUnit, PICA::DrawAcceleration*
// Then we figure out if we will use hw accelerated shaders, and try to fetch our shader
// TODO: Ubershader support for accelerated shaders
usingAcceleratedShader = emulatorConfig->accelerateShaders && !isImmediateMode && !usingUbershader;
usingAcceleratedShader = emulatorConfig->accelerateShaders && !usingUbershader && accel != nullptr && accel->canBeAccelerated;
if (usingAcceleratedShader) {
PICA::VertConfig vertexConfig(shaderUnit.vs, regs, usingUbershader);
@ -1000,9 +1000,10 @@ bool RendererGL::prepareForDraw(ShaderUnit& shaderUnit, PICA::DrawAcceleration*
shaderUnit.vs.uniformsDirty = false;
glBufferSubData(GL_UNIFORM_BUFFER, 0, PICAShader::totalUniformSize(), shaderUnit.vs.getUniformPointer());
}
}
accelerateVertexUpload(shaderUnit, accel);
// Upload vertex data and index buffer data to our GPU
accelerateVertexUpload(shaderUnit, accel);
}
}
if (usingUbershader) {