mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 04:45:58 +01:00
render/vulkan: drop "_format" in wlr_vk_format fields
"format" is already in the name, no need to repeat ourselves. `format->vk_format` sounds a bit redundant.
This commit is contained in:
parent
c8eb24d30e
commit
8b9a48c984
4 changed files with 32 additions and 36 deletions
|
@ -79,8 +79,8 @@ int vulkan_find_mem_type(struct wlr_vk_device *device,
|
|||
VkMemoryPropertyFlags flags, uint32_t req_bits);
|
||||
|
||||
struct wlr_vk_format {
|
||||
uint32_t drm_format;
|
||||
VkFormat vk_format;
|
||||
uint32_t drm;
|
||||
VkFormat vk;
|
||||
bool is_srgb;
|
||||
};
|
||||
|
||||
|
|
|
@ -8,29 +8,29 @@
|
|||
// Reversed endianess of shm and vulkan format names
|
||||
static const struct wlr_vk_format formats[] = {
|
||||
{
|
||||
.drm_format = DRM_FORMAT_ARGB8888,
|
||||
.vk_format = VK_FORMAT_B8G8R8A8_SRGB,
|
||||
.drm = DRM_FORMAT_ARGB8888,
|
||||
.vk = VK_FORMAT_B8G8R8A8_SRGB,
|
||||
.is_srgb = true,
|
||||
},
|
||||
{
|
||||
.drm_format = DRM_FORMAT_XRGB8888,
|
||||
.vk_format = VK_FORMAT_B8G8R8A8_SRGB,
|
||||
.drm = DRM_FORMAT_XRGB8888,
|
||||
.vk = VK_FORMAT_B8G8R8A8_SRGB,
|
||||
.is_srgb = true,
|
||||
},
|
||||
{
|
||||
.drm_format = DRM_FORMAT_XBGR8888,
|
||||
.vk_format = VK_FORMAT_R8G8B8A8_SRGB,
|
||||
.drm = DRM_FORMAT_XBGR8888,
|
||||
.vk = VK_FORMAT_R8G8B8A8_SRGB,
|
||||
.is_srgb = true,
|
||||
},
|
||||
{
|
||||
.drm_format = DRM_FORMAT_ABGR8888,
|
||||
.vk_format = VK_FORMAT_R8G8B8A8_SRGB,
|
||||
.drm = DRM_FORMAT_ABGR8888,
|
||||
.vk = VK_FORMAT_R8G8B8A8_SRGB,
|
||||
.is_srgb = true,
|
||||
},
|
||||
#if WLR_LITTLE_ENDIAN
|
||||
{
|
||||
.drm_format = DRM_FORMAT_RGB565,
|
||||
.vk_format = VK_FORMAT_R5G6B5_UNORM_PACK16,
|
||||
.drm = DRM_FORMAT_RGB565,
|
||||
.vk = VK_FORMAT_R5G6B5_UNORM_PACK16,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
@ -42,7 +42,7 @@ const struct wlr_vk_format *vulkan_get_format_list(size_t *len) {
|
|||
|
||||
const struct wlr_vk_format *vulkan_get_format_from_drm(uint32_t drm_format) {
|
||||
for (unsigned i = 0; i < sizeof(formats) / sizeof(formats[0]); ++i) {
|
||||
if (formats[i].drm_format == drm_format) {
|
||||
if (formats[i].drm == drm_format) {
|
||||
return &formats[i];
|
||||
}
|
||||
}
|
||||
|
@ -97,8 +97,7 @@ static bool query_modifier_support(struct wlr_vk_device *dev,
|
|||
return false;
|
||||
}
|
||||
|
||||
vkGetPhysicalDeviceFormatProperties2(dev->phdev,
|
||||
props->format.vk_format, &fmtp);
|
||||
vkGetPhysicalDeviceFormatProperties2(dev->phdev, props->format.vk, &fmtp);
|
||||
|
||||
props->render_mods = calloc(modp.drmFormatModifierCount,
|
||||
sizeof(*props->render_mods));
|
||||
|
@ -175,7 +174,7 @@ static bool query_modifier_support(struct wlr_vk_device *dev,
|
|||
|
||||
found = true;
|
||||
wlr_drm_format_set_add(&dev->dmabuf_render_formats,
|
||||
props->format.drm_format, m.drmFormatModifier);
|
||||
props->format.drm, m.drmFormatModifier);
|
||||
|
||||
render_status = "✓ render";
|
||||
} else {
|
||||
|
@ -210,7 +209,7 @@ static bool query_modifier_support(struct wlr_vk_device *dev,
|
|||
|
||||
found = true;
|
||||
wlr_drm_format_set_add(&dev->dmabuf_texture_formats,
|
||||
props->format.drm_format, m.drmFormatModifier);
|
||||
props->format.drm, m.drmFormatModifier);
|
||||
|
||||
texture_status = "✓ texture";
|
||||
} else {
|
||||
|
@ -236,9 +235,9 @@ void vulkan_format_props_query(struct wlr_vk_device *dev,
|
|||
const struct wlr_vk_format *format) {
|
||||
VkResult res;
|
||||
|
||||
char *format_name = drmGetFormatName(format->drm_format);
|
||||
char *format_name = drmGetFormatName(format->drm);
|
||||
wlr_log(WLR_DEBUG, " %s (0x%08"PRIX32")",
|
||||
format_name ? format_name : "<unknown>", format->drm_format);
|
||||
format_name ? format_name : "<unknown>", format->drm);
|
||||
free(format_name);
|
||||
|
||||
// get general features and modifiers
|
||||
|
@ -249,14 +248,13 @@ void vulkan_format_props_query(struct wlr_vk_device *dev,
|
|||
modp.sType = VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT;
|
||||
fmtp.pNext = &modp;
|
||||
|
||||
vkGetPhysicalDeviceFormatProperties2(dev->phdev,
|
||||
format->vk_format, &fmtp);
|
||||
vkGetPhysicalDeviceFormatProperties2(dev->phdev, format->vk, &fmtp);
|
||||
|
||||
// detailed check
|
||||
VkPhysicalDeviceImageFormatInfo2 fmti = {0};
|
||||
fmti.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2;
|
||||
fmti.type = VK_IMAGE_TYPE_2D;
|
||||
fmti.format = format->vk_format;
|
||||
fmti.format = format->vk;
|
||||
|
||||
VkImageFormatProperties2 ifmtp = {0};
|
||||
ifmtp.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2;
|
||||
|
@ -290,7 +288,7 @@ void vulkan_format_props_query(struct wlr_vk_device *dev,
|
|||
|
||||
shm_texture_status = "✓ texture";
|
||||
|
||||
dev->shm_formats[dev->shm_format_count] = format->drm_format;
|
||||
dev->shm_formats[dev->shm_format_count] = format->drm;
|
||||
++dev->shm_format_count;
|
||||
|
||||
add_fmt_props = true;
|
||||
|
|
|
@ -392,7 +392,7 @@ bool vulkan_submit_stage_wait(struct wlr_vk_renderer *renderer) {
|
|||
struct wlr_vk_format_props *vulkan_format_props_from_drm(
|
||||
struct wlr_vk_device *dev, uint32_t drm_fmt) {
|
||||
for (size_t i = 0u; i < dev->format_prop_count; ++i) {
|
||||
if (dev->format_props[i].format.drm_format == drm_fmt) {
|
||||
if (dev->format_props[i].format.drm == drm_fmt) {
|
||||
return &dev->format_props[i];
|
||||
}
|
||||
}
|
||||
|
@ -618,7 +618,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,
|
||||
.format = fmt->format.vk,
|
||||
.components.r = VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
.components.g = VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
.components.b = VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
|
@ -638,8 +638,7 @@ static struct wlr_vk_render_buffer *create_render_buffer(
|
|||
goto error_view;
|
||||
}
|
||||
|
||||
buffer->render_setup = find_or_create_render_setup(
|
||||
renderer, fmt->format.vk_format);
|
||||
buffer->render_setup = find_or_create_render_setup(renderer, fmt->format.vk);
|
||||
if (!buffer->render_setup) {
|
||||
goto error_view;
|
||||
}
|
||||
|
@ -1315,7 +1314,7 @@ static bool vulkan_read_pixels(struct wlr_renderer *wlr_renderer,
|
|||
"matching drm format 0x%08x available", drm_format);
|
||||
return false;
|
||||
}
|
||||
VkFormat dst_format = wlr_vk_format->vk_format;
|
||||
VkFormat dst_format = wlr_vk_format->vk;
|
||||
VkFormat src_format = vk_renderer->current_render_buffer->render_setup->render_format;
|
||||
VkFormatProperties dst_format_props = {0}, src_format_props = {0};
|
||||
vkGetPhysicalDeviceFormatProperties(vk_renderer->dev->phdev, dst_format, &dst_format_props);
|
||||
|
|
|
@ -43,8 +43,7 @@ static bool write_pixels(struct wlr_vk_texture *texture,
|
|||
struct wlr_vk_renderer *renderer = texture->renderer;
|
||||
VkDevice dev = texture->renderer->dev->dev;
|
||||
|
||||
const struct wlr_pixel_format_info *format_info = drm_get_pixel_format_info(
|
||||
texture->format->drm_format);
|
||||
const struct wlr_pixel_format_info *format_info = drm_get_pixel_format_info(texture->format->drm);
|
||||
assert(format_info);
|
||||
|
||||
uint32_t bsize = 0;
|
||||
|
@ -177,7 +176,7 @@ static bool vulkan_texture_update_from_buffer(struct wlr_texture *wlr_texture,
|
|||
|
||||
bool ok = true;
|
||||
|
||||
if (format != texture->format->drm_format) {
|
||||
if (format != texture->format->drm) {
|
||||
ok = false;
|
||||
goto out;
|
||||
}
|
||||
|
@ -287,7 +286,7 @@ static struct wlr_texture *vulkan_texture_from_pixels(
|
|||
VkImageCreateInfo img_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
||||
.imageType = VK_IMAGE_TYPE_2D,
|
||||
.format = texture->format->vk_format,
|
||||
.format = texture->format->vk,
|
||||
.mipLevels = 1,
|
||||
.arrayLayers = 1,
|
||||
.samples = VK_SAMPLE_COUNT_1_BIT,
|
||||
|
@ -342,7 +341,7 @@ static struct wlr_texture *vulkan_texture_from_pixels(
|
|||
VkImageViewCreateInfo view_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
||||
.viewType = VK_IMAGE_VIEW_TYPE_2D,
|
||||
.format = texture->format->vk_format,
|
||||
.format = texture->format->vk,
|
||||
.components.r = VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
.components.g = VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
.components.b = VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
|
@ -488,7 +487,7 @@ VkImage vulkan_import_dmabuf(struct wlr_vk_renderer *renderer,
|
|||
VkImageCreateInfo img_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
||||
.imageType = VK_IMAGE_TYPE_2D,
|
||||
.format = fmt->format.vk_format,
|
||||
.format = fmt->format.vk,
|
||||
.mipLevels = 1,
|
||||
.arrayLayers = 1,
|
||||
.samples = VK_SAMPLE_COUNT_1_BIT,
|
||||
|
@ -678,7 +677,7 @@ static struct wlr_vk_texture *vulkan_texture_from_dmabuf(
|
|||
VkImageViewCreateInfo view_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
||||
.viewType = VK_IMAGE_VIEW_TYPE_2D,
|
||||
.format = texture->format->vk_format,
|
||||
.format = texture->format->vk,
|
||||
.components.r = VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
.components.g = VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
.components.b = VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
|
@ -796,7 +795,7 @@ 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->format = vk_texture->format->vk;
|
||||
attribs->layout = vk_texture->transitioned ?
|
||||
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL : VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue