Skip to content

Commit

Permalink
Merge pull request #17219 from hrydgard/vulkan-fix-debug-validation-e…
Browse files Browse the repository at this point in the history
…rror

Vulkan: Fix a couple of validation errors
  • Loading branch information
hrydgard authored Apr 2, 2023
2 parents d1e21ab + 9ae1e10 commit 30b0f83
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
12 changes: 9 additions & 3 deletions Common/GPU/Vulkan/VulkanImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,18 @@ bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, int w, int h, int depth, i
if (initialLayout != VK_IMAGE_LAYOUT_UNDEFINED && initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED) {
switch (initialLayout) {
case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
case VK_IMAGE_LAYOUT_GENERAL:
TransitionImageLayout2(cmd, image_, 0, numMips, 1, VK_IMAGE_ASPECT_COLOR_BIT,
VK_IMAGE_LAYOUT_UNDEFINED, initialLayout,
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
0, VK_ACCESS_TRANSFER_WRITE_BIT);
break;
case VK_IMAGE_LAYOUT_GENERAL:
// We use this initial layout when we're about to write to the image using a compute shader, only.
TransitionImageLayout2(cmd, image_, 0, numMips, 1, VK_IMAGE_ASPECT_COLOR_BIT,
VK_IMAGE_LAYOUT_UNDEFINED, initialLayout,
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
0, VK_ACCESS_SHADER_WRITE_BIT);
break;
default:
// If you planned to use UploadMip, you want VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL. After the
// upload, you can transition using EndCreate.
Expand Down Expand Up @@ -203,7 +209,7 @@ void VulkanTexture::GenerateMips(VkCommandBuffer cmd, int firstMipToGenerate, bo
fromCompute ? VK_ACCESS_SHADER_WRITE_BIT : VK_ACCESS_TRANSFER_WRITE_BIT,
VK_ACCESS_TRANSFER_READ_BIT);

// Do the same with the uninitialized levels.
// Do the same with the uninitialized levels, transition from UNDEFINED.
TransitionImageLayout2(cmd, image_, firstMipToGenerate, numMips_ - firstMipToGenerate, 1,
VK_IMAGE_ASPECT_COLOR_BIT,
VK_IMAGE_LAYOUT_UNDEFINED,
Expand Down
10 changes: 9 additions & 1 deletion Common/GPU/Vulkan/VulkanQueueRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,15 @@ void VulkanQueueRunner::RunSteps(std::vector<VKRStep *> &steps, FrameData &frame
} else {
labelInfo.pLabelName = step.tag;
}
vkCmdBeginDebugUtilsLabelEXT(frameData.mainCmd, &labelInfo);
vkCmdBeginDebugUtilsLabelEXT(cmd, &labelInfo);
}

switch (step.stepType) {
case VKRStepType::RENDER:
if (!step.render.framebuffer) {
if (emitLabels) {
vkCmdEndDebugUtilsLabelEXT(cmd);
}
frameData.SubmitPending(vulkan_, FrameSubmitType::Pending, frameDataShared);

// When stepping in the GE debugger, we can end up here multiple times in a "frame".
Expand All @@ -410,6 +413,11 @@ void VulkanQueueRunner::RunSteps(std::vector<VKRStep *> &steps, FrameData &frame
frameData.hasPresentCommands = true;
}
cmd = frameData.presentCmd;
if (emitLabels) {
VkDebugUtilsLabelEXT labelInfo{ VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT };
labelInfo.pLabelName = "present";
vkCmdBeginDebugUtilsLabelEXT(cmd, &labelInfo);
}
}
PerformRenderPass(step, cmd);
break;
Expand Down

0 comments on commit 30b0f83

Please sign in to comment.