aboutsummaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-07-19 09:19:29 +0200
committerSimon Ser <contact@emersion.fr>2023-09-09 23:32:28 +0000
commit65bbbbbf0c3d6844cee3c4e294d0ba07e1f82211 (patch)
treeb97e457c56df26b83a1cb652a337b6d4cf3920f9 /render
parentb18a849fc3659e6eaf9c414564b9f733bfe99194 (diff)
render/vulkan: de-duplicate VkImageUsageFlags
The flags passed to vkCreateImage() must match the flags used when querying formats. Make this clearer by using the same variable.
Diffstat (limited to 'render')
-rw-r--r--render/vulkan/pixel_format.c12
-rw-r--r--render/vulkan/texture.c6
2 files changed, 8 insertions, 10 deletions
diff --git a/render/vulkan/pixel_format.c b/render/vulkan/pixel_format.c
index 98eb4f7b..90fb5f54 100644
--- a/render/vulkan/pixel_format.c
+++ b/render/vulkan/pixel_format.c
@@ -230,13 +230,13 @@ const struct wlr_vk_format *vulkan_get_format_from_drm(uint32_t drm_format) {
return NULL;
}
-static const VkImageUsageFlags render_usage =
+const VkImageUsageFlags vulkan_render_usage =
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
-static const VkImageUsageFlags shm_tex_usage =
+const VkImageUsageFlags vulkan_shm_tex_usage =
VK_IMAGE_USAGE_SAMPLED_BIT |
VK_IMAGE_USAGE_TRANSFER_DST_BIT;
-static const VkImageUsageFlags dma_tex_usage =
+const VkImageUsageFlags vulkan_dma_tex_usage =
VK_IMAGE_USAGE_SAMPLED_BIT;
static const VkFormatFeatureFlags render_features =
@@ -357,7 +357,7 @@ static bool query_modifier_support(struct wlr_vk_device *dev,
if ((m.drmFormatModifierTilingFeatures & render_features) == render_features &&
!props->format.is_ycbcr) {
struct wlr_vk_format_modifier_props p = {0};
- if (query_modifier_usage_support(dev, props->format.vk, render_usage, &m, &p, &errmsg)) {
+ if (query_modifier_usage_support(dev, props->format.vk, vulkan_render_usage, &m, &p, &errmsg)) {
props->dmabuf.render_mods[props->dmabuf.render_mod_count++] = p;
wlr_drm_format_set_add(&dev->dmabuf_render_formats,
props->format.drm, m.drmFormatModifier);
@@ -380,7 +380,7 @@ static bool query_modifier_support(struct wlr_vk_device *dev,
}
if ((m.drmFormatModifierTilingFeatures & features) == features) {
struct wlr_vk_format_modifier_props p = {0};
- if (query_modifier_usage_support(dev, props->format.vk, dma_tex_usage, &m, &p, &errmsg)) {
+ if (query_modifier_usage_support(dev, props->format.vk, vulkan_dma_tex_usage, &m, &p, &errmsg)) {
props->dmabuf.texture_mods[props->dmabuf.texture_mod_count++] = p;
wlr_drm_format_set_add(&dev->dmabuf_texture_formats,
props->format.drm, m.drmFormatModifier);
@@ -445,7 +445,7 @@ void vulkan_format_props_query(struct wlr_vk_device *dev,
.type = VK_IMAGE_TYPE_2D,
.format = format->vk,
.tiling = VK_IMAGE_TILING_OPTIMAL,
- .usage = shm_tex_usage,
+ .usage = vulkan_shm_tex_usage,
};
VkImageFormatProperties2 ifmtp = {
.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2,
diff --git a/render/vulkan/texture.c b/render/vulkan/texture.c
index a72124d2..83a22c81 100644
--- a/render/vulkan/texture.c
+++ b/render/vulkan/texture.c
@@ -402,7 +402,7 @@ static struct wlr_texture *vulkan_texture_from_pixels(
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
.extent = (VkExtent3D) { width, height, 1 },
.tiling = VK_IMAGE_TILING_OPTIMAL,
- .usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT,
+ .usage = vulkan_shm_tex_usage,
};
res = vkCreateImage(dev, &img_info, NULL, &texture->image);
@@ -546,9 +546,7 @@ VkImage vulkan_import_dmabuf(struct wlr_vk_renderer *renderer,
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
.extent = (VkExtent3D) { attribs->width, attribs->height, 1 },
- .usage = for_render ?
- VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT :
- VK_IMAGE_USAGE_SAMPLED_BIT,
+ .usage = for_render ? vulkan_render_usage : vulkan_dma_tex_usage,
};
if (disjoint) {
img_info.flags = VK_IMAGE_CREATE_DISJOINT_BIT;