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

Deal with VkSubmitInfo sharing waitSemaphoreCount for pWaitSemaphores and pWaitDstStageMask #851

Closed
voxelias opened this issue Dec 17, 2023 · 3 comments

Comments

@voxelias
Copy link

voxelias commented Dec 17, 2023

When I construct vk::SubmitInfo and pass empty list for wait semaphores but with some wait_dst_stage_mask, the wait_semaphore_count value is being overwriten by length of the mask.

It is in vk::definitions.

    #[inline]
    pub fn wait_dst_stage_mask(mut self, wait_dst_stage_mask: &'a [PipelineStageFlags]) -> Self {
        self.wait_semaphore_count = wait_dst_stage_mask.len() as _;
        self.p_wait_dst_stage_mask = wait_dst_stage_mask.as_ptr();
        self
    }

My code:

           let mut submit_info = vk::SubmitInfo::builder()
            .wait_semaphores(&vk_wait_semaphores) // empty vector
            .wait_dst_stage_mask(&wait_dst_stage_mask)
            .command_buffers(&command_buffers)
            .signal_semaphores(&vk_signal_semaphores)
            .build();
          log::debug!(
            "buffers: {}, wait: {}, signal: {}, deps: {}",
            command_buffers.len(),
            vk_wait_semaphores.len(),
            vk_signal_semaphores.len(),
            wait_dst_stage_mask.len(),
        );

        log::debug!("Submit Info: {:?}", submit_info);

Log Output:

0.0047 ** dotrix::vulkan - buffers: 1, wait: 0, signal: 1, deps: 1
0.0047 ** dotrix::vulkan - Submit Info: SubmitInfo { s_type: SUBMIT_INFO, p_next: 0x0, wait_semaphore_count: 1, p_wait_semaphores: 0x8, p_wait_dst_stage_mask: 0x7f1726dfb96c, command_buffer_count: 1, p_command_buffers: 0x7f1710004090, signal_semaphore_count: 1, p_signal_semaphores: 0x7f1710004880 }

Workaround, otherwise it seg faults on submit:

submit_info.wait_semaphore_count = vk_wait_semaphores.len() as u32;

I would be glad to submit a PR with fix, but at the same time I have a suspicion, that p_wait_dst_stage_mask must not be an array but a pointer to a number, but I am not sure yet. Will check it tomorrow and let you know.

@MarijnS95
Copy link
Collaborator

If we look at the VUIDs for https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkSubmitInfo.html:

VUID-VkSubmitInfo-pWaitSemaphores-parameter
If waitSemaphoreCount is not 0, pWaitSemaphores must be a valid pointer to an array of waitSemaphoreCount valid VkSemaphore handles

VUID-VkSubmitInfo-pWaitDstStageMask-parameter
If waitSemaphoreCount is not 0, pWaitDstStageMask must be a valid pointer to an array of waitSemaphoreCount valid combinations of VkPipelineStageFlagBits values

The list length for .wait_semaphores() and .wait_dst_stage_mask() must be equal, after all:

pWaitDstStageMask is a pointer to an array of pipeline stages at which each corresponding semaphore wait will occur.

And those semahpore waits... Come from pWaitSemaphores. It's a 1:1 mapping.


ash does not currently validate that they are the same, but there have been thoughts of providing a single builder function that requires all slices at once to be able to assert this: #441 (comment).

@MarijnS95 MarijnS95 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 17, 2023
@MarijnS95 MarijnS95 changed the title Critical bug in submit info Deal with VkSubmitInfo sharing waitSemaphoreCount for pWaitSemaphores and pWaitDstStageMask Dec 17, 2023
@voxelias
Copy link
Author

I see now, so both pWaitDstStageMask and pWaitSemaphores should correlate and maintain same number of entries. Thank you!

@MarijnS95
Copy link
Collaborator

Yes, for each wait semaphore you can specify what stage should wait on it 👍

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