[PATCH 3/9] wined3d: Add support for sysmem-clearing float32 formats.

Stefan Dösinger stefan at codeweavers.com
Sun May 1 13:39:05 CDT 2022


Signed-off-by: Stefan Dösinger <stefan at codeweavers.com>
---
 dlls/wined3d/resource.c |  6 ++++++
 dlls/wined3d/utils.c    | 29 +++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index cfbb60c3606..8c3ca59bedc 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -682,6 +682,12 @@ void wined3d_resource_memory_colour_fill(struct wined3d_resource *resource,
                 ((DWORD *)dst)[x] = c[0];
             }
             break;
+        case 8:
+        case 12:
+        case 16:
+            for (x = 0; x < w; ++x)
+                memcpy(((uint8_t *)map->data) + x * bpp, c, bpp);
+            break;
 
         default:
             FIXME("Not implemented for bpp %u.\n", bpp);
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 23d5a0e30a7..0820184ce05 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -6046,6 +6046,14 @@ void wined3d_format_convert_from_float(const struct wined3d_format *format, cons
         {WINED3DFMT_X8D24_UNORM,       {  16777215.0, 0.0, 0.0, 0.0}, {0, 0, 0, 0}},
         {WINED3DFMT_D32_UNORM,         {4294967295.0, 0.0, 0.0, 0.0}, {0, 0, 0, 0}},
     };
+    enum wined3d_format_id float32_copy[] =
+    {
+        WINED3DFMT_D32_FLOAT,
+        WINED3DFMT_R32_FLOAT,
+        WINED3DFMT_R32G32_FLOAT,
+        WINED3DFMT_R32G32B32_FLOAT,
+        WINED3DFMT_R32G32B32A32_FLOAT,
+    };
     enum wined3d_format_id format_id = format->id;
     struct wined3d_color colour_srgb;
     struct wined3d_uvec4 idx, shift;
@@ -6113,6 +6121,27 @@ void wined3d_format_convert_from_float(const struct wined3d_format *format, cons
         return;
     }
 
+    for (i = 0; i < ARRAY_SIZE(float32_copy); ++i)
+    {
+        if (format_id != float32_copy[i])
+            continue;
+
+        switch(format->byte_count)
+        {
+            case 16: ((float *)ret)[3] = color->a;
+            case 12: ((float *)ret)[2] = color->b;
+            case  8: ((float *)ret)[1] = color->g;
+            case  4: ((float *)ret)[0] = color->r;
+                break;
+
+            default:
+                ERR("Unexpected byte count %u: Format %s\n", format->byte_count, debug_d3dformat(format_id));
+                break;
+        }
+
+        return;
+    }
+
     FIXME("Conversion for format %s not implemented.\n", debug_d3dformat(format_id));
 }
 
-- 
2.35.1




More information about the wine-devel mailing list