mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-13 09:39:33 +01:00
Merge pull request #23006 from hrydgard/remove-gl-skip-mode
OpenGL: Remove skip mode
This commit is contained in:
8 files changed
+23
-59
No files matched your search
@@ -22,36 +22,25 @@ void GLDeleter::Take(GLDeleter &other) {
|
||||
}
|
||||
|
||||
// Runs on the GPU thread.
|
||||
void GLDeleter::Perform(GLRenderManager *renderManager, bool skipGLCalls) {
|
||||
void GLDeleter::Perform(GLRenderManager *renderManager) {
|
||||
for (auto pushBuffer : pushBuffers) {
|
||||
renderManager->UnregisterPushBuffer(pushBuffer);
|
||||
if (skipGLCalls) {
|
||||
pushBuffer->Destroy(false);
|
||||
}
|
||||
delete pushBuffer;
|
||||
}
|
||||
pushBuffers.clear();
|
||||
for (auto shader : shaders) {
|
||||
if (skipGLCalls && shader)
|
||||
shader->shader = 0; // prevent the glDeleteShader
|
||||
delete shader;
|
||||
}
|
||||
shaders.clear();
|
||||
for (auto program : programs) {
|
||||
if (skipGLCalls && program)
|
||||
program->program = 0; // prevent the glDeleteProgram
|
||||
delete program;
|
||||
}
|
||||
programs.clear();
|
||||
for (auto buffer : buffers) {
|
||||
if (skipGLCalls && buffer)
|
||||
buffer->buffer_ = 0;
|
||||
delete buffer;
|
||||
}
|
||||
buffers.clear();
|
||||
for (auto texture : textures) {
|
||||
if (skipGLCalls && texture)
|
||||
texture->texture = 0;
|
||||
delete texture;
|
||||
}
|
||||
textures.clear();
|
||||
@@ -61,17 +50,9 @@ void GLDeleter::Perform(GLRenderManager *renderManager, bool skipGLCalls) {
|
||||
}
|
||||
inputLayouts.clear();
|
||||
for (auto framebuffer : framebuffers) {
|
||||
if (skipGLCalls) {
|
||||
framebuffer->handle = 0;
|
||||
framebuffer->color_texture.texture = 0;
|
||||
framebuffer->z_stencil_buffer = 0;
|
||||
framebuffer->z_stencil_texture.texture = 0;
|
||||
framebuffer->z_buffer = 0;
|
||||
framebuffer->stencil_buffer = 0;
|
||||
}
|
||||
delete framebuffer;
|
||||
}
|
||||
if (!framebuffers.empty() && !skipGLCalls) {
|
||||
if (!framebuffers.empty()) {
|
||||
// The destructor bound the default framebuffer. Without this, the next readback from the framebuffer
|
||||
// that was bound before could read the default one (zeros for Cars Race-O-Rama's luminance, #15914).
|
||||
renderManager->ForgetBoundFramebuffers();
|
||||
|
||||
@@ -19,7 +19,7 @@ class GLRenderManager;
|
||||
|
||||
class GLDeleter {
|
||||
public:
|
||||
void Perform(GLRenderManager *renderManager, bool skipGLCalls);
|
||||
void Perform(GLRenderManager *renderManager);
|
||||
|
||||
bool IsEmpty() const {
|
||||
return shaders.empty() && programs.empty() && buffers.empty() && textures.empty() && inputLayouts.empty() && framebuffers.empty() && pushBuffers.empty();
|
||||
|
||||
@@ -126,9 +126,9 @@ static std::string GetInfoLog(GLuint name, Getiv getiv, GetLog getLog) {
|
||||
return infoLog;
|
||||
}
|
||||
|
||||
void GLQueueRunner::RunInitSteps(const FastVec<GLRInitStep> &steps, bool skipGLCalls) {
|
||||
if (skipGLCalls) {
|
||||
// Some bookkeeping still needs to be done.
|
||||
void GLQueueRunner::RunInitSteps(const FastVec<GLRInitStep> &steps, bool dryRun) {
|
||||
if (dryRun) {
|
||||
// Steps that will never run (left over at shutdown): only free what they own.
|
||||
for (size_t i = 0; i < steps.size(); i++) {
|
||||
const GLRInitStep &step = steps[i];
|
||||
switch (step.stepType) {
|
||||
@@ -156,14 +156,8 @@ void GLQueueRunner::RunInitSteps(const FastVec<GLRInitStep> &steps, bool skipGLC
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GLRInitStepType::CREATE_PROGRAM:
|
||||
{
|
||||
WARN_LOG(Log::G3D, "CREATE_PROGRAM found with skipGLCalls, not good");
|
||||
break;
|
||||
}
|
||||
case GLRInitStepType::CREATE_SHADER:
|
||||
{
|
||||
WARN_LOG(Log::G3D, "CREATE_SHADER found with skipGLCalls, not good");
|
||||
delete[] step.create_shader.code;
|
||||
break;
|
||||
}
|
||||
@@ -675,8 +669,8 @@ retry_depth:
|
||||
currentReadHandle_ = fbo->handle;
|
||||
}
|
||||
|
||||
void GLQueueRunner::RunSteps(const std::vector<GLRStep *> &steps, GLFrameData &frameData, bool skipGLCalls, bool keepSteps, bool useVR) {
|
||||
if (skipGLCalls) {
|
||||
void GLQueueRunner::RunSteps(const std::vector<GLRStep *> &steps, GLFrameData &frameData, bool dryRun, bool keepSteps, bool useVR) {
|
||||
if (dryRun) {
|
||||
if (keepSteps) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -369,9 +369,10 @@ public:
|
||||
caps_ = caps;
|
||||
}
|
||||
|
||||
void RunInitSteps(const FastVec<GLRInitStep> &steps, bool skipGLCalls);
|
||||
// dryRun: the steps will never run (left over at shutdown), so only free what they own.
|
||||
void RunInitSteps(const FastVec<GLRInitStep> &steps, bool dryRun);
|
||||
|
||||
void RunSteps(const std::vector<GLRStep *> &steps, GLFrameData &frameData, bool skipGLCalls, bool keepSteps, bool useVR);
|
||||
void RunSteps(const std::vector<GLRStep *> &steps, GLFrameData &frameData, bool dryRun, bool keepSteps, bool useVR);
|
||||
|
||||
void CreateDeviceObjects();
|
||||
void DestroyDeviceObjects();
|
||||
|
||||
@@ -44,7 +44,7 @@ GLRenderManager::~GLRenderManager() {
|
||||
_assert_(frameData_[i].deleter_prev.IsEmpty());
|
||||
}
|
||||
// Was anything deleted during shutdown?
|
||||
deleter_.Perform(this, skipGLCalls_);
|
||||
deleter_.Perform(this);
|
||||
_assert_(deleter_.IsEmpty());
|
||||
}
|
||||
|
||||
@@ -55,7 +55,6 @@ void GLRenderManager::ThreadStart(Draw::DrawContext *draw) {
|
||||
|
||||
exitNotified_ = false;
|
||||
hitExit_ = false;
|
||||
skipGLCalls_ = false;
|
||||
|
||||
if (newInflightFrames_ != -1) {
|
||||
INFO_LOG(Log::G3D, "OpenGL: Updating inflight frames to %d", newInflightFrames_);
|
||||
@@ -106,13 +105,12 @@ void GLRenderManager::ThreadEnd() {
|
||||
|
||||
VLOG(" PULL: Quitting");
|
||||
|
||||
// Good time to run all the deleters to get rid of leftover objects.
|
||||
// Good time to run all the deleters to get rid of leftover objects. The context is still current.
|
||||
for (int i = 0; i < MAX_INFLIGHT_FRAMES; i++) {
|
||||
// Since we're in shutdown, we should skip the GL calls on Android.
|
||||
frameData_[i].deleter.Perform(this, skipGLCalls_);
|
||||
frameData_[i].deleter_prev.Perform(this, skipGLCalls_);
|
||||
frameData_[i].deleter.Perform(this);
|
||||
frameData_[i].deleter_prev.Perform(this);
|
||||
}
|
||||
deleter_.Perform(this, skipGLCalls_);
|
||||
deleter_.Perform(this);
|
||||
// Steps that never got submitted. A dry run frees the data they own (texture uploads etc), and the steps.
|
||||
queueRunner_.RunInitSteps(initSteps_, true);
|
||||
initSteps_.clear();
|
||||
@@ -458,15 +456,15 @@ bool GLRenderManager::Run(GLRRenderThreadTask &task) {
|
||||
if (!frameData.hasBegun) {
|
||||
frameData.hasBegun = true;
|
||||
|
||||
frameData.deleter_prev.Perform(this, skipGLCalls_);
|
||||
frameData.deleter_prev.Perform(this);
|
||||
frameData.deleter_prev.Take(frameData.deleter);
|
||||
}
|
||||
|
||||
// queueRunner_.LogSteps(stepsOnThread);
|
||||
queueRunner_.RunInitSteps(task.initSteps, skipGLCalls_);
|
||||
queueRunner_.RunInitSteps(task.initSteps, false);
|
||||
|
||||
// Run this after RunInitSteps so any fresh GLRBuffers for the pushbuffers can get created.
|
||||
if (!skipGLCalls_) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(pushBuffersMutex_);
|
||||
for (auto iter : frameData.activePushBuffers) {
|
||||
iter->Flush();
|
||||
@@ -479,7 +477,7 @@ bool GLRenderManager::Run(GLRRenderThreadTask &task) {
|
||||
}
|
||||
|
||||
#ifdef __LIBRETRO__
|
||||
if (Libretro::VRActive() && !skipGLCalls_) {
|
||||
if (Libretro::VRActive()) {
|
||||
for (int eye = 0; eye < 2; ++eye) {
|
||||
Libretro::BeginVREye(eye);
|
||||
queueRunner_.RunSteps(task.steps, frameData, false, eye == 0, false);
|
||||
@@ -491,18 +489,18 @@ bool GLRenderManager::Run(GLRRenderThreadTask &task) {
|
||||
int passes = GetVRPassesCount();
|
||||
for (int i = 0; i < passes; i++) {
|
||||
PreVRFrameRender(i);
|
||||
queueRunner_.RunSteps(task.steps, frameData, skipGLCalls_, i < passes - 1, true);
|
||||
queueRunner_.RunSteps(task.steps, frameData, false, i < passes - 1, true);
|
||||
PostVRFrameRender();
|
||||
}
|
||||
} else {
|
||||
queueRunner_.RunSteps(task.steps, frameData, skipGLCalls_, false, false);
|
||||
queueRunner_.RunSteps(task.steps, frameData, false, false, false);
|
||||
}
|
||||
|
||||
if (frameData.profile.enabled) {
|
||||
frameData.profile.cpuEndTime = time_now_d();
|
||||
}
|
||||
|
||||
if (!skipGLCalls_) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(pushBuffersMutex_);
|
||||
for (auto iter : frameData.activePushBuffers) {
|
||||
iter->MapDevice(bufferStrategy_);
|
||||
|
||||
@@ -893,12 +893,6 @@ public:
|
||||
return queueRunner_.GetGLString(name);
|
||||
}
|
||||
|
||||
// Used during Android-style ugly shutdown. No need to have a way to set it back because we'll be
|
||||
// destroyed.
|
||||
void SetSkipGLCalls() {
|
||||
skipGLCalls_ = true;
|
||||
}
|
||||
|
||||
int GetNumSteps() const {
|
||||
return (int)steps_.size();
|
||||
}
|
||||
@@ -953,8 +947,6 @@ private:
|
||||
bool syncDone_ = false;
|
||||
|
||||
GLDeleter deleter_;
|
||||
// Set from either thread, read on the render thread.
|
||||
std::atomic<bool> skipGLCalls_{false};
|
||||
|
||||
int curFrame_ = 0;
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ public:
|
||||
|
||||
// Call from emu thread
|
||||
void NotifyEmuThreadExit() override {
|
||||
renderManager_->SetSkipGLCalls();
|
||||
renderManager_->NotifyEmuThreadExit();
|
||||
}
|
||||
|
||||
|
||||
@@ -494,6 +494,5 @@ void WindowsGLContext::ThreadEnd() {
|
||||
}
|
||||
|
||||
void WindowsGLContext::NotifyEmuThreadExit() {
|
||||
// renderManager_->SetSkipGLCalls(); // not necessary on desktop, maybe unadvisable?
|
||||
renderManager_->NotifyEmuThreadExit();
|
||||
}
|
||||
Reference in new issue
Block a user