Henri Verbeet : wined3d: Add a swizzle to the Vulkan format information for WINED3DFMT_A8_UNORM.

Alexandre Julliard julliard at winehq.org
Fri May 1 16:17:50 CDT 2020


Module: wine
Branch: master
Commit: a3874561cd68c8fec22c05a024ed23cbc17ddcb1
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=a3874561cd68c8fec22c05a024ed23cbc17ddcb1

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Fri May  1 15:24:21 2020 +0430

wined3d: Add a swizzle to the Vulkan format information for WINED3DFMT_A8_UNORM.

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/texture.c | 17 +++++++++++++----
 dlls/wined3d/utils.c   | 10 ++++++++--
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index b8b90c95c5..49373eb58a 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -4509,6 +4509,7 @@ const VkDescriptorImageInfo *wined3d_texture_vk_get_default_image_info(struct wi
     const struct wined3d_vk_info *vk_info;
     struct wined3d_device_vk *device_vk;
     VkImageViewCreateInfo create_info;
+    struct color_fixup_desc fixup;
     uint32_t flags = 0;
     VkResult vr;
 
@@ -4529,10 +4530,18 @@ const VkDescriptorImageInfo *wined3d_texture_vk_get_default_image_info(struct wi
     create_info.image = texture_vk->vk_image;
     create_info.viewType = vk_image_view_type_from_wined3d(texture_vk->t.resource.type, flags);
     create_info.format = format_vk->vk_format;
-    create_info.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
-    create_info.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
-    create_info.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
-    create_info.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
+    fixup = format_vk->f.color_fixup;
+    if (is_identity_fixup(fixup) || !can_use_texture_swizzle(context_vk->c.d3d_info, &format_vk->f))
+    {
+        create_info.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
+        create_info.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
+        create_info.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
+        create_info.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
+    }
+    else
+    {
+        wined3d_vk_swizzle_from_color_fixup(&create_info.components, fixup);
+    }
     create_info.subresourceRange.aspectMask = vk_aspect_mask_from_format(&format_vk->f);
     create_info.subresourceRange.baseMipLevel = 0;
     create_info.subresourceRange.levelCount = texture_vk->t.level_count;
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 2108eb65ba..04e9300ee6 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -4135,6 +4135,7 @@ static void init_vulkan_format_info(struct wined3d_format_vk *format,
     {
         enum wined3d_format_id id;
         VkFormat vk_format;
+        const char *fixup;
     }
     vulkan_formats[] =
     {
@@ -4182,7 +4183,7 @@ static void init_vulkan_format_info(struct wined3d_format_vk *format,
         {WINED3DFMT_R8_UINT,                    VK_FORMAT_R8_UINT,                 },
         {WINED3DFMT_R8_SNORM,                   VK_FORMAT_R8_SNORM,                },
         {WINED3DFMT_R8_SINT,                    VK_FORMAT_R8_SINT,                 },
-        {WINED3DFMT_A8_UNORM,                   VK_FORMAT_R8_UNORM,                },
+        {WINED3DFMT_A8_UNORM,                   VK_FORMAT_R8_UNORM,                "000X"},
         {WINED3DFMT_B8G8R8A8_UNORM,             VK_FORMAT_B8G8R8A8_UNORM,          },
         {WINED3DFMT_B8G8R8A8_UNORM_SRGB,        VK_FORMAT_B8G8R8A8_SRGB,           },
         {WINED3DFMT_BC1_UNORM,                  VK_FORMAT_BC1_RGBA_UNORM_BLOCK,    },
@@ -4211,6 +4212,7 @@ static void init_vulkan_format_info(struct wined3d_format_vk *format,
     VkFormatProperties properties;
     VkImageUsageFlags vk_usage;
     unsigned int flags;
+    const char *fixup;
     unsigned int i;
     VkResult vr;
 
@@ -4219,6 +4221,7 @@ static void init_vulkan_format_info(struct wined3d_format_vk *format,
         if (vulkan_formats[i].id == format->f.id)
         {
             vk_format = vulkan_formats[i].vk_format;
+            fixup = vulkan_formats[i].fixup;
             break;
         }
     }
@@ -4229,7 +4232,10 @@ static void init_vulkan_format_info(struct wined3d_format_vk *format,
     }
 
     format->vk_format = vk_format;
-    format->f.color_fixup = COLOR_FIXUP_IDENTITY;
+    if (fixup)
+        format->f.color_fixup = create_color_fixup_desc_from_string(fixup);
+    else
+        format->f.color_fixup = COLOR_FIXUP_IDENTITY;
 
     VK_CALL(vkGetPhysicalDeviceFormatProperties(vk_physical_device, vk_format, &properties));
 




More information about the wine-cvs mailing list