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

create_render_pass causes validation errors, eventual crash #7

Closed
timoore opened this issue Apr 15, 2021 · 4 comments
Closed

create_render_pass causes validation errors, eventual crash #7

timoore opened this issue Apr 15, 2021 · 4 comments

Comments

@timoore
Copy link

timoore commented Apr 15, 2021

Hi,
Experienced graphics engineer, Julia newbie here.

My code that calls create_render_pass doesn't work and eventually causes a segfault. With the validation layer enabled, I get a ton of messages like:
VUID-VkSubpassDescription-flags-parameter(ERROR / SPEC): msgNum: 1258039040 - Validation Error: [ VUID-VkSubpassDescription-flags-parameter ] Object 0: handle = 0x255c658, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x4afc2700 | vkCreateRenderPass: value of pCreateInfo->pSubpasses[0].flags contains flag bits that are not recognized members of VkSubpassDescriptionFlagBits The Vulkan spec states: flags must be a valid combination of VkSubpassDescriptionFlagBits values (https://vulkan.lunarg.com/doc/view/1.2.170.0/linux/1.2-extensions/vkspec.html#VUID-VkSubpassDescription-flags-parameter)
Objects: 1
[0] 0x255c658, type: 3, name: NULL
VUID-VkSubpassDescription-pipelineBindPoint-parameter(ERROR / SPEC): msgNum: -93556066 - Validation Error: [ VUID-VkSubpassDescription-pipelineBindPoint-parameter ] Object 0: handle = 0x255c658, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xfa6c729e | vkCreateRenderPass: value of pCreateInfo->pSubpasses[0].pipelineBindPoint (32557) does not fall within the begin..end range of the core VkPipelineBindPoint enumeration tokens and is not an extension added token. The Vulkan spec states: pipelineBindPoint must be a valid VkPipelineBindPoint value (https://vulkan.lunarg.com/doc/view/1.2.170.0/linux/1.2-extensions/vkspec.html#VUID-VkSubpassDescription-pipelineBindPoint-parameter)

This leads me to believe that the proper C struct isn't being passed to Vulkan. This is my function: am I doing something wrong?
function createSimpleRenderpass(vDevice::VulkanDevice, colorFormat, depthFormat, colorFinalLayout) colorAttachmentDesc = VK.AttachmentDescription( colorFormat, VK.SAMPLE_COUNT_1_BIT, VK.VK_ATTACHMENT_LOAD_OP_CLEAR, VK.VK_ATTACHMENT_STORE_OP_STORE, VK.VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK.VK_ATTACHMENT_STORE_OP_DONT_CARE, VK.VK_IMAGE_LAYOUT_UNDEFINED, colorFinalLayout) depthAttachmentDesc = VK.AttachmentDescription( depthFormat, VK.SAMPLE_COUNT_1_BIT, VK.VK_ATTACHMENT_LOAD_OP_CLEAR, VK.VK_ATTACHMENT_STORE_OP_STORE, VK.VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK.VK_ATTACHMENT_STORE_OP_DONT_CARE, VK.VK_IMAGE_LAYOUT_UNDEFINED, VK.VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL) colorReference = VK.AttachmentReference(0, VK.VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL) depthReference = VK.AttachmentReference(1, VK.VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL) println("colorReference: $colorReference") println("depthReference: $depthReference") subpassDescription = VK.SubpassDescription( VK.VK_PIPELINE_BIND_POINT_GRAPHICS, [], [colorReference],[], resolve_attachments = [], depth_stencil_attachment = depthReference) println("SubpassDescription: $SubpassDescription") subpassDependencies = [ VK.SubpassDependency( VK.VK_SUBPASS_EXTERNAL, 0, VK.PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK.PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, src_access_mask = VK.VK_ACCESS_MEMORY_READ_BIT, dst_access_mask = VK.VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK.VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, dependency_flags = VK.VK_DEPENDENCY_BY_REGION_BIT), VK.SubpassDependency( 0, VK.VK_SUBPASS_EXTERNAL, VK.PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK.PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, src_access_mask = VK.VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK.VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, dst_access_mask = VK.VK_ACCESS_MEMORY_READ_BIT, dependency_flags = VK.VK_DEPENDENCY_BY_REGION_BIT)] println("subpassDependencies: $subpassDependencies") unwrap(VK.create_render_pass( vDevice.device, VK.RenderPassCreateInfo([colorAttachmentDesc, depthAttachmentDesc], [SubpassDescription], subpassDependencies))) end

@timoore
Copy link
Author

timoore commented Apr 15, 2021

Sorry about the code formatting! Another go:

function createSimpleRenderpass(vDevice::VulkanDevice, colorFormat, depthFormat, colorFinalLayout)
    colorAttachmentDesc = VK.AttachmentDescription(
        colorFormat, VK.SAMPLE_COUNT_1_BIT,
        VK.VK_ATTACHMENT_LOAD_OP_CLEAR, VK.VK_ATTACHMENT_STORE_OP_STORE,
        VK.VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK.VK_ATTACHMENT_STORE_OP_DONT_CARE,
        VK.VK_IMAGE_LAYOUT_UNDEFINED, colorFinalLayout)
    depthAttachmentDesc = VK.AttachmentDescription(
        depthFormat, VK.SAMPLE_COUNT_1_BIT,
        VK.VK_ATTACHMENT_LOAD_OP_CLEAR, VK.VK_ATTACHMENT_STORE_OP_STORE,
        VK.VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK.VK_ATTACHMENT_STORE_OP_DONT_CARE,
        VK.VK_IMAGE_LAYOUT_UNDEFINED, VK.VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)
    colorReference = VK.AttachmentReference(0, VK.VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)
    depthReference = VK.AttachmentReference(1, VK.VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)
    println("colorReference: $colorReference")
    println("depthReference: $depthReference")
    subpassDescription = VK.SubpassDescription(
        VK.VK_PIPELINE_BIND_POINT_GRAPHICS, [], [colorReference],[],
        resolve_attachments = [],
        depth_stencil_attachment = depthReference)
    println("SubpassDescription: $SubpassDescription")
    subpassDependencies = [
        VK.SubpassDependency(
            VK.VK_SUBPASS_EXTERNAL,
            0,
            VK.PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
	    VK.PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
	    src_access_mask = VK.VK_ACCESS_MEMORY_READ_BIT,
	    dst_access_mask = VK.VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK.VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
	    dependency_flags = VK.VK_DEPENDENCY_BY_REGION_BIT),
        VK.SubpassDependency(
            0,
            VK.VK_SUBPASS_EXTERNAL,
	    VK.PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
            VK.PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
	    src_access_mask = VK.VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
            VK.VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
            dst_access_mask = VK.VK_ACCESS_MEMORY_READ_BIT,
	    dependency_flags = VK.VK_DEPENDENCY_BY_REGION_BIT)]
    println("subpassDependencies: $subpassDependencies")
    unwrap(VK.create_render_pass(
        vDevice.device,
        VK.RenderPassCreateInfo([colorAttachmentDesc, depthAttachmentDesc],
                                [SubpassDescription],
                                subpassDependencies)))
end

@serenity4
Copy link
Member

serenity4 commented Apr 15, 2021

At the last line, you use SubpassDescription (the type) and not the variable subpassDescription that you defined.
The fact that it errors hints me that you use Vulkan with using Vulkan, while you prefix all symbols with VK. You may want to import Vulkan instead if you prefer not to have all the exported symbols into your module scope.
You can quickly see it from the validation layers; it is complaining that the subpass description does not contain valid fields, which hints that the array of subpass descriptions is not correct.

@timoore
Copy link
Author

timoore commented Apr 15, 2021 via email

@serenity4
Copy link
Member

Ah, that is a bug in the wrapper. Thanks for reporting it, I'll open a new issue to track it.
Yes, you may look at VulkanExamples, examples should work fine. However it depends on VulkanShader which is not released yet and abstracts away some interfacing with shaders. I might remove these abstractions for these examples in the future, in the mean time you'd need to add VulkanShaders manually if you want to run them.

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

2 participants