Skip to content

Commit 25a1e6a

Browse files
committed
Some renaming, add a bunch of sanity debug-asserts
1 parent ea180e5 commit 25a1e6a

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

Common/GPU/Vulkan/VulkanFrameData.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ VkCommandBuffer FrameData::GetInitCmd(VulkanContext *vulkan) {
169169
return initCmd;
170170
}
171171

172-
void FrameData::SubmitPending(VulkanContext *vulkan, FrameSubmitType type, FrameDataShared &sharedData) {
172+
void FrameData::Submit(VulkanContext *vulkan, FrameSubmitType type, FrameDataShared &sharedData) {
173173
VkCommandBuffer cmdBufs[3];
174174
int numCmdBufs = 0;
175175

@@ -200,14 +200,16 @@ void FrameData::SubmitPending(VulkanContext *vulkan, FrameSubmitType type, Frame
200200
hasMainCommands = false;
201201
}
202202

203-
if (hasPresentCommands && type != FrameSubmitType::Pending) {
203+
if (hasPresentCommands) {
204+
_dbg_assert_(type == FrameSubmitType::FinishFrame);
204205
VkResult res = vkEndCommandBuffer(presentCmd);
206+
205207
_assert_msg_(res == VK_SUCCESS, "vkEndCommandBuffer failed (present)! result=%s", VulkanResultToString(res));
206208

207209
cmdBufs[numCmdBufs++] = presentCmd;
208210
hasPresentCommands = false;
209211

210-
if (type == FrameSubmitType::Present) {
212+
if (type == FrameSubmitType::FinishFrame) {
211213
fenceToTrigger = fence;
212214
}
213215
}
@@ -219,15 +221,15 @@ void FrameData::SubmitPending(VulkanContext *vulkan, FrameSubmitType type, Frame
219221

220222
VkSubmitInfo submit_info{ VK_STRUCTURE_TYPE_SUBMIT_INFO };
221223
VkPipelineStageFlags waitStage[1]{ VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT };
222-
if (type == FrameSubmitType::Present && !skipSwap) {
224+
if (type == FrameSubmitType::FinishFrame && !skipSwap) {
223225
_dbg_assert_(hasAcquired);
224226
submit_info.waitSemaphoreCount = 1;
225227
submit_info.pWaitSemaphores = &acquireSemaphore;
226228
submit_info.pWaitDstStageMask = waitStage;
227229
}
228230
submit_info.commandBufferCount = (uint32_t)numCmdBufs;
229231
submit_info.pCommandBuffers = cmdBufs;
230-
if (type == FrameSubmitType::Present && !skipSwap) {
232+
if (type == FrameSubmitType::FinishFrame && !skipSwap) {
231233
submit_info.signalSemaphoreCount = 1;
232234
submit_info.pSignalSemaphores = &renderingCompleteSemaphore;
233235
}

Common/GPU/Vulkan/VulkanFrameData.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct FrameDataShared {
6565
enum class FrameSubmitType {
6666
Pending,
6767
Sync,
68-
Present,
68+
FinishFrame,
6969
};
7070

7171
// Per-frame data, round-robin so we can overlap submission with execution of the previous frame.
@@ -121,8 +121,8 @@ struct FrameData {
121121
// Generally called from the main thread, unlike most of the rest.
122122
VkCommandBuffer GetInitCmd(VulkanContext *vulkan);
123123

124-
// This will only submit if we are actually recording init commands.
125-
void SubmitPending(VulkanContext *vulkan, FrameSubmitType type, FrameDataShared &shared);
124+
// Submits pending command buffers.
125+
void Submit(VulkanContext *vulkan, FrameSubmitType type, FrameDataShared &shared);
126126

127127
private:
128128
// Metadata for logging etc

Common/GPU/Vulkan/VulkanQueueRunner.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ void VulkanQueueRunner::RunSteps(std::vector<VKRStep *> &steps, int curFrame, Fr
369369
if (emitLabels) {
370370
vkCmdEndDebugUtilsLabelEXT(cmd);
371371
}
372-
frameData.SubmitPending(vulkan_, FrameSubmitType::Pending, frameDataShared);
372+
frameData.Submit(vulkan_, FrameSubmitType::Pending, frameDataShared);
373373

374374
// When stepping in the GE debugger, we can end up here multiple times in a "frame".
375375
// So only acquire once.

Common/GPU/Vulkan/VulkanRenderManager.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,11 @@ void VulkanRenderManager::BindFramebufferAsRenderTarget(VKRFramebuffer *fb, VKRR
952952
EndCurRenderStep();
953953
}
954954

955+
// Sanity check that we don't have binds to the backbuffer before binds to other buffers. It must always be bound last.
956+
if (steps_.size() >= 1 && steps_.back()->stepType == VKRStepType::RENDER && steps_.back()->render.framebuffer == nullptr && fb != nullptr) {
957+
_dbg_assert_(false);
958+
}
959+
955960
// Older Mali drivers have issues with depth and stencil don't match load/clear/etc.
956961
// TODO: Determine which versions and do this only where necessary.
957962
u32 lateClearMask = 0;
@@ -1470,7 +1475,7 @@ void VulkanRenderManager::Run(VKRRenderThreadTask &task) {
14701475
if (!frameTimeHistory_[frameData.frameId].firstSubmit) {
14711476
frameTimeHistory_[frameData.frameId].firstSubmit = time_now_d();
14721477
}
1473-
frameData.SubmitPending(vulkan_, FrameSubmitType::Pending, frameDataShared_);
1478+
frameData.Submit(vulkan_, FrameSubmitType::Pending, frameDataShared_);
14741479

14751480
// Flush descriptors.
14761481
double descStart = time_now_d();
@@ -1507,12 +1512,12 @@ void VulkanRenderManager::Run(VKRRenderThreadTask &task) {
15071512

15081513
switch (task.runType) {
15091514
case VKRRunType::SUBMIT:
1510-
frameData.SubmitPending(vulkan_, FrameSubmitType::Present, frameDataShared_);
1515+
frameData.Submit(vulkan_, FrameSubmitType::FinishFrame, frameDataShared_);
15111516
break;
15121517

15131518
case VKRRunType::SYNC:
15141519
// The submit will trigger the readbackFence, and also do the wait for it.
1515-
frameData.SubmitPending(vulkan_, FrameSubmitType::Sync, frameDataShared_);
1520+
frameData.Submit(vulkan_, FrameSubmitType::Sync, frameDataShared_);
15161521

15171522
if (useRenderThread_) {
15181523
std::unique_lock<std::mutex> lock(syncMutex_);

0 commit comments

Comments
 (0)