mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-31 22:25:21 -04:00
render/vulkan: add some interfaces to allow compositors to integrate
Added wlr_vk_renderer_get_* functions to allow get the VkInstance, VkPhysicalDevice, VkDevice, queue family of a wlr_vk_renderer. Added wlr_vk_renderer_get_current_image_attribs function to allow get the VkImage of current renderer buffer to use on compositors. Added wlr_renderer_is_vk function, it's like the wlr_renderer_is_gles2, returns true if the wlr_renderer is a wlr_vk_renderer. Added wlr_vk_image_get_attribs function to get a VkImage and it's extras information (e.g. a VkImageLayout and VkImageFormat of the VkImage) from a wlr_texture.
This commit is contained in:
parent
9fefeb69d6
commit
270914d379
3 changed files with 66 additions and 4 deletions
|
|
@ -283,8 +283,6 @@ static struct wlr_texture *vulkan_texture_from_pixels(
|
|||
.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT,
|
||||
};
|
||||
|
||||
VkImageLayout layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
|
||||
res = vkCreateImage(dev, &img_info, NULL, &texture->image);
|
||||
if (res != VK_SUCCESS) {
|
||||
wlr_vk_error("vkCreateImage failed", res);
|
||||
|
|
@ -362,7 +360,7 @@ static struct wlr_texture *vulkan_texture_from_pixels(
|
|||
|
||||
VkDescriptorImageInfo ds_img_info = {
|
||||
.imageView = texture->image_view,
|
||||
.imageLayout = layout,
|
||||
.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
};
|
||||
|
||||
VkWriteDescriptorSet ds_write = {
|
||||
|
|
@ -771,3 +769,12 @@ struct wlr_texture *vulkan_texture_from_buffer(struct wlr_renderer *wlr_renderer
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void wlr_vk_texture_get_image_attribs(struct wlr_texture *texture,
|
||||
struct wlr_vk_image_attribs *attribs) {
|
||||
struct wlr_vk_texture *vk_texture = vulkan_get_texture(texture);
|
||||
attribs->image = vk_texture->image;
|
||||
attribs->format = vk_texture->format->vk_format;
|
||||
attribs->layout = vk_texture->transitioned ?
|
||||
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL : VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue