mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge some functions
This commit is contained in:
parent
a120cb9468
commit
bfab820947
2 changed files with 41 additions and 81 deletions
|
@ -512,59 +512,12 @@ void GLRenderManager::Finish() {
|
||||||
insideFrame_ = false;
|
insideFrame_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLRenderManager::BeginSubmitFrame(int frame) {
|
// Render thread
|
||||||
|
void GLRenderManager::Run(int frame) {
|
||||||
FrameData &frameData = frameData_[frame];
|
FrameData &frameData = frameData_[frame];
|
||||||
if (!frameData.hasBegun) {
|
if (!frameData.hasBegun) {
|
||||||
frameData.hasBegun = true;
|
frameData.hasBegun = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Render thread
|
|
||||||
void GLRenderManager::Submit(int frame, bool triggerFence) {
|
|
||||||
FrameData &frameData = frameData_[frame];
|
|
||||||
|
|
||||||
// In GL, submission happens automatically in Run().
|
|
||||||
|
|
||||||
// When !triggerFence, we notify after syncing with Vulkan.
|
|
||||||
|
|
||||||
if (triggerFence) {
|
|
||||||
VLOG("PULL: Frame %d.readyForFence = true", frame);
|
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock(frameData.push_mutex);
|
|
||||||
_assert_(frameData.readyForSubmit);
|
|
||||||
frameData.readyForFence = true;
|
|
||||||
frameData.readyForSubmit = false;
|
|
||||||
frameData.push_condVar.notify_all();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render thread
|
|
||||||
void GLRenderManager::EndSubmitFrame(int frame) {
|
|
||||||
FrameData &frameData = frameData_[frame];
|
|
||||||
frameData.hasBegun = false;
|
|
||||||
|
|
||||||
Submit(frame, true);
|
|
||||||
|
|
||||||
if (!frameData.skipSwap) {
|
|
||||||
if (swapIntervalChanged_) {
|
|
||||||
swapIntervalChanged_ = false;
|
|
||||||
if (swapIntervalFunction_) {
|
|
||||||
swapIntervalFunction_(swapInterval_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (swapFunction_) {
|
|
||||||
swapFunction_();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
frameData.skipSwap = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render thread
|
|
||||||
void GLRenderManager::Run(int frame) {
|
|
||||||
BeginSubmitFrame(frame);
|
|
||||||
|
|
||||||
FrameData &frameData = frameData_[frame];
|
|
||||||
|
|
||||||
auto &stepsOnThread = frameData_[frame].steps;
|
auto &stepsOnThread = frameData_[frame].steps;
|
||||||
auto &initStepsOnThread = frameData_[frame].initSteps;
|
auto &initStepsOnThread = frameData_[frame].initSteps;
|
||||||
|
@ -600,11 +553,42 @@ void GLRenderManager::Run(int frame) {
|
||||||
|
|
||||||
switch (frameData.type) {
|
switch (frameData.type) {
|
||||||
case GLRRunType::END:
|
case GLRRunType::END:
|
||||||
EndSubmitFrame(frame);
|
frameData.hasBegun = false;
|
||||||
|
|
||||||
|
VLOG("PULL: Frame %d.readyForFence = true", frame);
|
||||||
|
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> lock(frameData.push_mutex);
|
||||||
|
_assert_(frameData.readyForSubmit);
|
||||||
|
frameData.readyForFence = true;
|
||||||
|
frameData.readyForSubmit = false;
|
||||||
|
frameData.push_condVar.notify_all();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!frameData.skipSwap) {
|
||||||
|
if (swapIntervalChanged_) {
|
||||||
|
swapIntervalChanged_ = false;
|
||||||
|
if (swapIntervalFunction_) {
|
||||||
|
swapIntervalFunction_(swapInterval_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (swapFunction_) {
|
||||||
|
swapFunction_();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
frameData.skipSwap = false;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GLRRunType::SYNC:
|
case GLRRunType::SYNC:
|
||||||
EndSyncFrame(frame);
|
// glFinish is not actually necessary here, and won't be unless we start using
|
||||||
|
// glBufferStorage. Then we need to use fences.
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> lock(frameData.push_mutex);
|
||||||
|
frameData.readyForFence = true;
|
||||||
|
frameData.readyForSubmit = true;
|
||||||
|
frameData.push_condVar.notify_all();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -641,27 +625,6 @@ void GLRenderManager::FlushSync() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render thread
|
|
||||||
void GLRenderManager::EndSyncFrame(int frame) {
|
|
||||||
FrameData &frameData = frameData_[frame];
|
|
||||||
Submit(frame, false);
|
|
||||||
|
|
||||||
// glFinish is not actually necessary here, and won't be until we start using
|
|
||||||
// glBufferStorage. Then we need to use fences.
|
|
||||||
// glFinish();
|
|
||||||
|
|
||||||
// At this point we can resume filling the command buffers for the current frame since
|
|
||||||
// we know the device is idle - and thus all previously enqueued command buffers have been processed.
|
|
||||||
// No need to switch to the next frame number.
|
|
||||||
|
|
||||||
{
|
|
||||||
std::unique_lock<std::mutex> lock(frameData.push_mutex);
|
|
||||||
frameData.readyForFence = true;
|
|
||||||
frameData.readyForSubmit = true;
|
|
||||||
frameData.push_condVar.notify_all();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLRenderManager::Wipe() {
|
void GLRenderManager::Wipe() {
|
||||||
initSteps_.clear();
|
initSteps_.clear();
|
||||||
for (auto step : steps_) {
|
for (auto step : steps_) {
|
||||||
|
|
|
@ -395,9 +395,15 @@ public:
|
||||||
GLRenderManager() {}
|
GLRenderManager() {}
|
||||||
~GLRenderManager();
|
~GLRenderManager();
|
||||||
|
|
||||||
|
|
||||||
void SetInvalidationCallback(InvalidationCallback callback) {
|
void SetInvalidationCallback(InvalidationCallback callback) {
|
||||||
invalidationCallback_ = callback;
|
invalidationCallback_ = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ThreadStart(Draw::DrawContext *draw);
|
||||||
|
void ThreadEnd();
|
||||||
|
bool ThreadFrame(); // Returns false to request exiting the loop.
|
||||||
|
|
||||||
void SetErrorCallback(ErrorCallbackFn callback, void *userdata) {
|
void SetErrorCallback(ErrorCallbackFn callback, void *userdata) {
|
||||||
queueRunner_.SetErrorCallback(callback, userdata);
|
queueRunner_.SetErrorCallback(callback, userdata);
|
||||||
}
|
}
|
||||||
|
@ -406,10 +412,6 @@ public:
|
||||||
caps_ = caps;
|
caps_ = caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadStart(Draw::DrawContext *draw);
|
|
||||||
void ThreadEnd();
|
|
||||||
bool ThreadFrame(); // Returns false to request exiting the loop.
|
|
||||||
|
|
||||||
// Makes sure that the GPU has caught up enough that we can start writing buffers of this frame again.
|
// Makes sure that the GPU has caught up enough that we can start writing buffers of this frame again.
|
||||||
void BeginFrame();
|
void BeginFrame();
|
||||||
// Can run on a different thread!
|
// Can run on a different thread!
|
||||||
|
@ -1014,13 +1016,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void BeginSubmitFrame(int frame);
|
|
||||||
void EndSubmitFrame(int frame);
|
|
||||||
void Submit(int frame, bool triggerFence);
|
|
||||||
|
|
||||||
// Bad for performance but sometimes necessary for synchronous CPU readbacks (screenshots and whatnot).
|
// Bad for performance but sometimes necessary for synchronous CPU readbacks (screenshots and whatnot).
|
||||||
void FlushSync();
|
void FlushSync();
|
||||||
void EndSyncFrame(int frame);
|
|
||||||
|
|
||||||
// When using legacy functionality for push buffers (glBufferData), we need to flush them
|
// When using legacy functionality for push buffers (glBufferData), we need to flush them
|
||||||
// before actually making the glDraw* calls. It's best if the render manager handles that.
|
// before actually making the glDraw* calls. It's best if the render manager handles that.
|
||||||
|
|
Loading…
Add table
Reference in a new issue