aboutsummaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
Diffstat (limited to 'render')
-rw-r--r--render/vulkan/renderer.c10
-rw-r--r--render/vulkan/texture.c20
2 files changed, 17 insertions, 13 deletions
diff --git a/render/vulkan/renderer.c b/render/vulkan/renderer.c
index 33601732..d15ccc2d 100644
--- a/render/vulkan/renderer.c
+++ b/render/vulkan/renderer.c
@@ -730,8 +730,9 @@ static struct wlr_vk_render_buffer *create_render_buffer(
wlr_log(WLR_DEBUG, "vulkan create_render_buffer: %.4s, %dx%d",
(const char*) &dmabuf.format, dmabuf.width, dmabuf.height);
+ bool using_mutable_srgb = false;
buffer->image = vulkan_import_dmabuf(renderer, &dmabuf,
- buffer->memories, &buffer->mem_count, true);
+ buffer->memories, &buffer->mem_count, true, &using_mutable_srgb);
if (!buffer->image) {
goto error;
}
@@ -748,7 +749,7 @@ static struct wlr_vk_render_buffer *create_render_buffer(
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
.image = buffer->image,
.viewType = VK_IMAGE_VIEW_TYPE_2D,
- .format = fmt->format.vk,
+ .format = using_mutable_srgb ? fmt->format.vk_srgb : fmt->format.vk,
.components.r = VK_COMPONENT_SWIZZLE_IDENTITY,
.components.g = VK_COMPONENT_SWIZZLE_IDENTITY,
.components.b = VK_COMPONENT_SWIZZLE_IDENTITY,
@@ -768,7 +769,7 @@ static struct wlr_vk_render_buffer *create_render_buffer(
goto error;
}
- bool has_blending_buffer = !fmt->format.vk_srgb || true /* temporary */;
+ bool has_blending_buffer = !using_mutable_srgb;
buffer->render_setup = find_or_create_render_setup(
renderer, &fmt->format, has_blending_buffer);
@@ -2028,8 +2029,9 @@ static struct wlr_vk_render_format_setup *find_or_create_render_setup(
goto error;
}
} else {
+ assert(format->vk_srgb);
VkAttachmentDescription attachment = {
- .format = format->vk,
+ .format = format->vk_srgb,
.samples = VK_SAMPLE_COUNT_1_BIT,
.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
diff --git a/render/vulkan/texture.c b/render/vulkan/texture.c
index a4e53760..4b9674cf 100644
--- a/render/vulkan/texture.c
+++ b/render/vulkan/texture.c
@@ -311,7 +311,8 @@ struct wlr_vk_texture_view *vulkan_texture_get_or_create_view(struct wlr_vk_text
VkImageViewCreateInfo view_info = {
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
.viewType = VK_IMAGE_VIEW_TYPE_2D,
- .format = texture->format->vk,
+ .format = texture->using_mutable_srgb ? texture->format->vk_srgb
+ : texture->format->vk,
.components.r = VK_COMPONENT_SWIZZLE_IDENTITY,
.components.g = VK_COMPONENT_SWIZZLE_IDENTITY,
.components.b = VK_COMPONENT_SWIZZLE_IDENTITY,
@@ -372,10 +373,10 @@ struct wlr_vk_texture_view *vulkan_texture_get_or_create_view(struct wlr_vk_text
}
static void texture_set_format(struct wlr_vk_texture *texture,
- const struct wlr_vk_format *format) {
+ const struct wlr_vk_format *format, bool has_mutable_srgb) {
texture->format = format;
- texture->transform = !format->is_ycbcr &&
- (format->vk_srgb && false /* temporary */) ?
+ texture->using_mutable_srgb = has_mutable_srgb;
+ texture->transform = !format->is_ycbcr && has_mutable_srgb ?
WLR_VK_TEXTURE_TRANSFORM_IDENTITY : WLR_VK_TEXTURE_TRANSFORM_SRGB;
const struct wlr_pixel_format_info *format_info =
@@ -409,7 +410,7 @@ static struct wlr_texture *vulkan_texture_from_pixels(
return NULL;
}
- texture_set_format(texture, &fmt->format);
+ texture_set_format(texture, &fmt->format, fmt->shm.has_mutable_srgb);
VkFormat view_formats[2] = {
fmt->format.vk,
@@ -516,7 +517,7 @@ static bool is_dmabuf_disjoint(const struct wlr_dmabuf_attributes *attribs) {
VkImage vulkan_import_dmabuf(struct wlr_vk_renderer *renderer,
const struct wlr_dmabuf_attributes *attribs,
VkDeviceMemory mems[static WLR_DMABUF_MAX_PLANES], uint32_t *n_mems,
- bool for_render) {
+ bool for_render, bool *using_mutable_srgb) {
VkResult res;
VkDevice dev = renderer->dev->dev;
*n_mems = 0u;
@@ -729,6 +730,7 @@ VkImage vulkan_import_dmabuf(struct wlr_vk_renderer *renderer,
goto error_image;
}
+ *using_mutable_srgb = mod->has_mutable_srgb;
return image;
error_image:
@@ -760,13 +762,13 @@ static struct wlr_vk_texture *vulkan_texture_from_dmabuf(
return NULL;
}
- texture_set_format(texture, &fmt->format);
-
+ bool using_mutable_srgb = false;
texture->image = vulkan_import_dmabuf(renderer, attribs,
- texture->memories, &texture->mem_count, false);
+ texture->memories, &texture->mem_count, false, &using_mutable_srgb);
if (!texture->image) {
goto error;
}
+ texture_set_format(texture, &fmt->format, using_mutable_srgb);
texture->dmabuf_imported = true;