Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchronization Errors in Hello Triangle Tutorial #366

Open
john01dav opened this issue Nov 18, 2023 · 1 comment
Open

Synchronization Errors in Hello Triangle Tutorial #366

john01dav opened this issue Nov 18, 2023 · 1 comment

Comments

@john01dav
Copy link

I originally encountered this problem due to actual symptoms of incorrect synchronization in a more realistic program than the hello triangle example, but when downloading the hello triangle app I am able to show synchronization errors due to the synchronization validation failing.

I added this code to the 15_hello_triangle.cpp file:

VkValidationFeatureEnableEXT enabled[] = {
    VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT,
    VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT,
    VK_VALIDATION_FEATURE_ENABLE_BEST_PRACTICES_EXT,
    VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT,
    VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT,
};
VkValidationFeaturesEXT validationFeatures;
VkDebugUtilsMessengerCreateInfoEXT debugCreateInfo{};
if (enableValidationLayers) {
    createInfo.enabledLayerCount = static_cast<uint32_t>(validationLayers.size());
    createInfo.ppEnabledLayerNames = validationLayers.data();

    populateDebugMessengerCreateInfo(debugCreateInfo);
    createInfo.pNext = (VkDebugUtilsMessengerCreateInfoEXT*) &debugCreateInfo;

    validationFeatures.sType = VK_STRUCTURE_TYPE_VALIDATION_FEATURES_EXT;
    validationFeatures.pNext = nullptr;
    validationFeatures.pEnabledValidationFeatures = enabled;
    validationFeatures.enabledValidationFeatureCount = 5;
    validationFeatures.disabledValidationFeatureCount = 0;
    debugCreateInfo.pNext = &validationFeatures;
} else {
    createInfo.enabledLayerCount = 0;

    createInfo.pNext = nullptr;
}

Then, when running, there are validation errors:

validation layer: Validation Error: [ SYNC-HAZARD-WRITE-AFTER-WRITE ] Object 0: handle = 0xd000000000d, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0x5c0ec5d6 | vkCmdBeginRenderPass: Hazard WRITE_AFTER_WRITE vs. layout transition in subpass 0 for attachment 0 aspect color during load with loadOp VK_ATTACHMENT_LOAD_OP_CLEAR.
validation layer: Validation Error: [ SYNC-HAZARD-WRITE-AFTER-WRITE ] Object 0: handle = 0xd000000000d, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0x5c0ec5d6 | vkCmdEndRenderPass: Hazard WRITE_AFTER_WRITE vs. store/resolve operations in subpass 0 for attachment 0 final image layout transition (old_layout: VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, new_layout: VK_IMAGE_LAYOUT_PRESENT_SRC_KHR).

Actual issues occur on Nvidia + Wayland when you make the GPU very busy:
flickering.webm

There seems to be something wrong with the synchronization in the tutorial that propagated into my program, but I don't understand synchronization well enough to say what. Also, it may be a good idea to enable synchronization and other extended validation in the tutorial, or at least show users how. I had no idea that this feature existed until recently.

@john01dav
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant