-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16919 from hrydgard/gl-delayed-readback-prep
Move GLFrameData out of GLRenderManager.
- Loading branch information
Showing
11 changed files
with
171 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#include "Common/GPU/OpenGL/GLCommon.h" | ||
#include "Common/GPU/OpenGL/GLFrameData.h" | ||
#include "Common/GPU/OpenGL/GLRenderManager.h" | ||
#include "Common/Log.h" | ||
|
||
void GLDeleter::Take(GLDeleter &other) { | ||
_assert_msg_(IsEmpty(), "Deleter already has stuff"); | ||
shaders = std::move(other.shaders); | ||
programs = std::move(other.programs); | ||
buffers = std::move(other.buffers); | ||
textures = std::move(other.textures); | ||
inputLayouts = std::move(other.inputLayouts); | ||
framebuffers = std::move(other.framebuffers); | ||
pushBuffers = std::move(other.pushBuffers); | ||
other.shaders.clear(); | ||
other.programs.clear(); | ||
other.buffers.clear(); | ||
other.textures.clear(); | ||
other.inputLayouts.clear(); | ||
other.framebuffers.clear(); | ||
other.pushBuffers.clear(); | ||
} | ||
|
||
// Runs on the GPU thread. | ||
void GLDeleter::Perform(GLRenderManager *renderManager, bool skipGLCalls) { | ||
for (auto pushBuffer : pushBuffers) { | ||
renderManager->UnregisterPushBuffer(pushBuffer); | ||
if (skipGLCalls) { | ||
pushBuffer->Destroy(false); | ||
} | ||
delete pushBuffer; | ||
} | ||
pushBuffers.clear(); | ||
for (auto shader : shaders) { | ||
if (skipGLCalls) | ||
shader->shader = 0; // prevent the glDeleteShader | ||
delete shader; | ||
} | ||
shaders.clear(); | ||
for (auto program : programs) { | ||
if (skipGLCalls) | ||
program->program = 0; // prevent the glDeleteProgram | ||
delete program; | ||
} | ||
programs.clear(); | ||
for (auto buffer : buffers) { | ||
if (skipGLCalls) | ||
buffer->buffer_ = 0; | ||
delete buffer; | ||
} | ||
buffers.clear(); | ||
for (auto texture : textures) { | ||
if (skipGLCalls) | ||
texture->texture = 0; | ||
delete texture; | ||
} | ||
textures.clear(); | ||
for (auto inputLayout : inputLayouts) { | ||
// No GL objects in an inputLayout yet | ||
delete inputLayout; | ||
} | ||
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; | ||
} | ||
framebuffers.clear(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#pragma once | ||
|
||
#include <mutex> | ||
#include <condition_variable> | ||
#include <vector> | ||
#include <set> | ||
|
||
#include "Common/GPU/OpenGL/GLCommon.h" | ||
|
||
class GLRShader; | ||
class GLRBuffer; | ||
class GLRTexture; | ||
class GLRInputLayout; | ||
class GLRFramebuffer; | ||
class GLPushBuffer; | ||
class GLRProgram; | ||
class GLRenderManager; | ||
|
||
class GLDeleter { | ||
public: | ||
void Perform(GLRenderManager *renderManager, bool skipGLCalls); | ||
|
||
bool IsEmpty() const { | ||
return shaders.empty() && programs.empty() && buffers.empty() && textures.empty() && inputLayouts.empty() && framebuffers.empty() && pushBuffers.empty(); | ||
} | ||
|
||
void Take(GLDeleter &other); | ||
|
||
std::vector<GLRShader *> shaders; | ||
std::vector<GLRProgram *> programs; | ||
std::vector<GLRBuffer *> buffers; | ||
std::vector<GLRTexture *> textures; | ||
std::vector<GLRInputLayout *> inputLayouts; | ||
std::vector<GLRFramebuffer *> framebuffers; | ||
std::vector<GLPushBuffer *> pushBuffers; | ||
}; | ||
|
||
// Per-frame data, round-robin so we can overlap submission with execution of the previous frame. | ||
struct GLFrameData { | ||
bool skipSwap = false; | ||
|
||
std::mutex fenceMutex; | ||
std::condition_variable fenceCondVar; | ||
bool readyForFence = true; | ||
|
||
// Swapchain. | ||
bool hasBegun = false; | ||
|
||
GLDeleter deleter; | ||
GLDeleter deleter_prev; | ||
std::set<GLPushBuffer *> activePushBuffers; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.