Skip to content

vulkan renderer - #2165

Open
Drakulix wants to merge 3 commits into
masterfrom
feat/vulkan-renderer
Open

vulkan renderer#2165
Drakulix wants to merge 3 commits into
masterfrom
feat/vulkan-renderer

Conversation

@Drakulix

@Drakulix Drakulix commented Sep 9, 2026

Copy link
Copy Markdown
Member

Description

Very early draft of a vulkan renderer.

  1. This moves around a lot of logic from backend/allocator/vulkan into
    backend/vulkan to generalize for use in the renderer.
  2. It also expands the modules in backend/vulkan significantly to
    provide more useful abstractions around vulkan objects and their
    initialization logic.
  3. The vulkan renderer then itself deals mostly with specialized drawing
    related functionality as well as implementating the various
    renderer-trait semantics by creating the right vulkan objects with
    the right set of flags.
  4. Most testing so far has been done with examples/vulkan.rs. The render
    itself still lacks a lot of functionality needed to run a full
    compositor.

Checklist

1. This moves around a lot of logic from backend/allocator/vulkan into
   backend/vulkan to generalize for use in the renderer.
2. It also expands the modules in backend/vulkan significantly to
   provide more useful abstractions around vulkan objects and their
   initialization logic.
3. The vulkan renderer then itself deals mostly with specialized drawing
   related functionality as well as implementating the various
   renderer-trait semantics by creating the right vulkan objects with
   the right set of flags.
4. Most testing so far has been done with examples/vulkan.rs. The render
   itself still lacks a lot of functionality needed to run a full
   compositor.
@Pheoxy

Pheoxy commented Sep 9, 2026

Copy link
Copy Markdown

https://github.com/Pheoxy/smithay/tree/add-vulkan-renderer-support-cosmic-e3d461a

This is my fork branch where I'm working on figuring out Vulkan myself.

It's a bit dirty but it was never intended to be a PR branch.

Comment on lines +197 to +199
pub fn queue(&self) -> &Queue {
&self.0.queue
}

@ids1024 ids1024 Sep 9, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.vulkan.org/refpages/latest/refpages/source/vkQueueSubmit.html

Host access to queue must be externally synchronized if it was not created with VK_DEVICE_QUEUE_CREATE_INTERNALLY_SYNCHRONIZED_BIT_KHR

Maybe this should return a &Mutex<vk::Queue>, which would enforce the necessary synchronization.

Comment on lines +1063 to +1080
unsafe {
self.renderer
.device
.vk()
.queue_submit(
*self.renderer.device.queue(),
&[SubmitInfo::default()
.command_buffers(&[buf])
.signal_semaphores(&[self.renderer.timeline.vk])
.push_next(&mut timeline_info)],
Fence::null(),
)
.map_err(Error::SubmitError)?;
}

self.renderer
.cmd_pool
.store_pending_buffer(buf, next_seq_no[0], descriptor);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the best practice is generally to call vkQueueSubmit only once per frame. For instance in https://gpuopen.com/learn/rdna-performance-guide:

Ideally, submissions would only happen when syncing queues or at the end of a frame.

So we probably want to store a vk::CommandBufer in VulkanFrame and submit in VulkanFrame::finish?

{
return Err(Error::MismatchedDrmDevice);
}
Some(node)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed a typo here:
current

let node = DrmNode::from_file(fd).map_err(|_| Error::MismatchedDrmDevice)?;
if !(phd.render_node().ok().flatten().is_some_and(|node| node == node)
                || phd.primary_node().ok().flatten().is_some_and(|node| node == node))

it should be

let node = DrmNode::from_file(fd).map_err(|_| Error::MismatchedDrmDevice)?;
if !(phd.render_node().ok().flatten().is_some_and(|n| n == node)
                || phd.primary_node().ok().flatten().is_some_and(|n| n == node))

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

Successfully merging this pull request may close these issues.

4 participants