diff options
Diffstat (limited to 'render/vulkan')
-rw-r--r-- | render/vulkan/renderer.c | 20 | ||||
-rw-r--r-- | render/vulkan/texture.c | 14 |
2 files changed, 28 insertions, 6 deletions
diff --git a/render/vulkan/renderer.c b/render/vulkan/renderer.c index 8d7fdb78..00b8d0e2 100644 --- a/render/vulkan/renderer.c +++ b/render/vulkan/renderer.c @@ -17,6 +17,7 @@ #include <wlr/render/vulkan.h> #include <wlr/backend/interface.h> #include <wlr/types/wlr_linux_dmabuf_v1.h> +#include <xf86drm.h> #include "render/dmabuf.h" #include "render/pixel_format.h" @@ -1405,11 +1406,11 @@ static bool vulkan_render_subtexture_with_matrix(struct wlr_renderer *wlr_render wl_list_insert(&renderer->foreign_textures, &texture->foreign_link); } - VkPipelineLayout pipe_layout = renderer->default_pipeline_layout.vk; + VkPipelineLayout pipe_layout = texture->pipeline_layout->vk; + VkPipeline pipe; // SRGB formats already have the transfer function applied if (texture->format->drm == DRM_FORMAT_NV12) { - pipe_layout = renderer->nv12_pipeline_layout.vk; pipe = renderer->current_render_buffer->render_setup->tex_nv12_pipe; } else if (texture->format->is_srgb) { pipe = renderer->current_render_buffer->render_setup->tex_identity_pipe; @@ -2841,6 +2842,21 @@ struct wlr_renderer *wlr_vk_renderer_create_with_drm_fd(int drm_fd) { return vulkan_renderer_create_for_device(dev); } +struct wlr_vk_pipeline_layout *vulkan_get_pipeline_layout(struct wlr_vk_renderer *renderer, + const struct wlr_vk_format *format) { + if (!format->is_ycbcr) { + return &renderer->default_pipeline_layout; + } + if (format->drm == DRM_FORMAT_NV12 && renderer->dev->sampler_ycbcr_conversion) { + return &renderer->nv12_pipeline_layout; + } + char *name = drmGetFormatName(format->drm); + wlr_log(WLR_ERROR, "No pipeline layout found for format %s (0x%08"PRIX32")", + name, format->drm); + free(name); + return NULL; +} + VkInstance wlr_vk_renderer_get_instance(struct wlr_renderer *renderer) { struct wlr_vk_renderer *vk_renderer = vulkan_get_renderer(renderer); return vk_renderer->dev->instance->instance; diff --git a/render/vulkan/texture.c b/render/vulkan/texture.c index 59a41d35..6a895a42 100644 --- a/render/vulkan/texture.c +++ b/render/vulkan/texture.c @@ -282,6 +282,7 @@ static struct wlr_texture *vulkan_texture_from_pixels( } texture->format = &fmt->format; + texture->pipeline_layout = &renderer->default_pipeline_layout; VkImageCreateInfo img_info = { .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, @@ -662,6 +663,12 @@ static struct wlr_vk_texture *vulkan_texture_from_dmabuf( } texture->format = &fmt->format; + + texture->pipeline_layout = vulkan_get_pipeline_layout(renderer, texture->format); + if (texture->pipeline_layout == NULL) { + goto error; + } + texture->image = vulkan_import_dmabuf(renderer, attribs, texture->memories, &texture->mem_count, false); if (!texture->image) { @@ -695,13 +702,12 @@ static struct wlr_vk_texture *vulkan_texture_from_dmabuf( .image = texture->image, }; - VkDescriptorSetLayout ds_layout = renderer->default_pipeline_layout.ds; VkSamplerYcbcrConversionInfo ycbcr_conversion_info; if (fmt->format.is_ycbcr) { - ds_layout = renderer->nv12_pipeline_layout.ds; + assert(texture->pipeline_layout->ycbcr.conversion != VK_NULL_HANDLE); ycbcr_conversion_info = (VkSamplerYcbcrConversionInfo){ .sType = VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO, - .conversion = renderer->nv12_pipeline_layout.ycbcr.conversion, + .conversion = texture->pipeline_layout->ycbcr.conversion, }; view_info.pNext = &ycbcr_conversion_info; } @@ -712,7 +718,7 @@ static struct wlr_vk_texture *vulkan_texture_from_dmabuf( goto error; } - texture->ds_pool = vulkan_alloc_texture_ds(renderer, ds_layout, &texture->ds); + texture->ds_pool = vulkan_alloc_texture_ds(renderer, texture->pipeline_layout->ds, &texture->ds); if (!texture->ds_pool) { wlr_log(WLR_ERROR, "failed to allocate descriptor"); goto error; |