summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2020-03-14 17:45:01 -0400
committerGravatar bunnei2020-03-14 17:45:01 -0400
commitc5afe93dccef4aacb194cd87cbbf3bca875f203b (patch)
treeafa01f43541e28acb68b96326f82201f2527129b /src
parentgl_device: Add option to check GL_EXT_debug_tool. (diff)
downloadyuzu-c5afe93dccef4aacb194cd87cbbf3bca875f203b.tar.gz
yuzu-c5afe93dccef4aacb194cd87cbbf3bca875f203b.tar.xz
yuzu-c5afe93dccef4aacb194cd87cbbf3bca875f203b.zip
renderer_opengl: Keep presentation frames in lock-step when GPU debugging.
- Fixes renderdoc with OpenGL renderer.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index 12333e8c9..c91658cd1 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -56,7 +56,7 @@ public:
56 std::deque<Frame*> present_queue; 56 std::deque<Frame*> present_queue;
57 Frame* previous_frame{}; 57 Frame* previous_frame{};
58 58
59 FrameMailbox() { 59 FrameMailbox() : has_debug_tool{Device().HasDebugTool()} {
60 for (auto& frame : swap_chain) { 60 for (auto& frame : swap_chain) {
61 free_queue.push(&frame); 61 free_queue.push(&frame);
62 } 62 }
@@ -127,9 +127,13 @@ public:
127 std::unique_lock lock{swap_chain_lock}; 127 std::unique_lock lock{swap_chain_lock};
128 present_queue.push_front(frame); 128 present_queue.push_front(frame);
129 present_cv.notify_one(); 129 present_cv.notify_one();
130
131 DebugNotifyNextFrame();
130 } 132 }
131 133
132 Frame* TryGetPresentFrame(int timeout_ms) { 134 Frame* TryGetPresentFrame(int timeout_ms) {
135 DebugWaitForNextFrame();
136
133 std::unique_lock lock{swap_chain_lock}; 137 std::unique_lock lock{swap_chain_lock};
134 // wait for new entries in the present_queue 138 // wait for new entries in the present_queue
135 present_cv.wait_for(lock, std::chrono::milliseconds(timeout_ms), 139 present_cv.wait_for(lock, std::chrono::milliseconds(timeout_ms),
@@ -155,6 +159,33 @@ public:
155 previous_frame = frame; 159 previous_frame = frame;
156 return frame; 160 return frame;
157 } 161 }
162
163private:
164 std::mutex debug_synch_mutex;
165 std::condition_variable debug_synch_condition;
166 std::atomic_int frame_for_debug{};
167 const bool has_debug_tool; // When true, using a GPU debugger, so keep frames in lock-step
168
169 /// Signal that a new frame is available (called from GPU thread)
170 void DebugNotifyNextFrame() {
171 if (!has_debug_tool) {
172 return;
173 }
174 frame_for_debug++;
175 std::lock_guard lock{debug_synch_mutex};
176 debug_synch_condition.notify_one();
177 }
178
179 /// Wait for a new frame to be available (called from presentation thread)
180 void DebugWaitForNextFrame() {
181 if (!has_debug_tool) {
182 return;
183 }
184 const int last_frame = frame_for_debug;
185 std::unique_lock lock{debug_synch_mutex};
186 debug_synch_condition.wait(lock,
187 [this, last_frame] { return frame_for_debug > last_frame; });
188 }
158}; 189};
159 190
160namespace { 191namespace {