[PATCH 07/11] wined3d: Move WINED3DFMT_FLAG_COMPRESSED and HEIGHT_SCALE to the base flags group.

Chip Davis wine at gitlab.winehq.org
Mon May 16 20:26:51 CDT 2022


From: Chip Davis <cdavis5x at gmail.com>

---
 dlls/wined3d/arb_program_shader.c |  4 +--
 dlls/wined3d/glsl_shader.c        |  4 +--
 dlls/wined3d/surface.c            |  2 +-
 dlls/wined3d/texture.c            | 24 ++++++++---------
 dlls/wined3d/utils.c              | 44 +++++++++++++++----------------
 dlls/wined3d/wined3d_private.h    |  6 ++---
 6 files changed, 40 insertions(+), 44 deletions(-)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 12606bbd0b0..7522b566c23 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -7744,8 +7744,8 @@ static BOOL arbfp_blit_supported(enum wined3d_blit_op blit_op, const struct wine
             return FALSE;
     }
 
-    decompress = (src_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_COMPRESSED)
-            && !(dst_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_COMPRESSED);
+    decompress = (src_format->base_flags & WINED3DFMT_FLAG_COMPRESSED)
+            && !(dst_format->base_flags & WINED3DFMT_FLAG_COMPRESSED);
     if (!decompress && !(src_resource->access & dst_resource->access & WINED3D_RESOURCE_ACCESS_GPU))
         return FALSE;
 
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 82c022e4ba7..4fc1307445b 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -13060,8 +13060,8 @@ static BOOL glsl_blitter_supported(enum wined3d_blit_op blit_op, const struct wi
     /* We don't necessarily want to blit from resources without
      * WINED3D_RESOURCE_ACCESS_GPU, but that may be the only way to decompress
      * compressed textures. */
-    decompress = (src_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_COMPRESSED)
-            && !(dst_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_COMPRESSED);
+    decompress = (src_format->base_flags & WINED3DFMT_FLAG_COMPRESSED)
+            && !(dst_format->base_flags & WINED3DFMT_FLAG_COMPRESSED);
     if (!decompress && !(src_resource->access & WINED3D_RESOURCE_ACCESS_GPU))
     {
         TRACE("Source resource does not have GPU access.\n");
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index bb776ad0eed..90d21abd552 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -255,7 +255,7 @@ static struct wined3d_texture *surface_convert_format(struct wined3d_texture *sr
     if (!(conv = find_converter(src_format->id, dst_format->id)) && ((device->wined3d->flags & WINED3D_NO3D)
             || !is_identity_fixup(src_format->color_fixup) || src_format->conv_byte_count
             || !is_identity_fixup(dst_format->color_fixup) || dst_format->conv_byte_count
-            || ((src_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_COMPRESSED)
+            || ((src_format->base_flags & WINED3DFMT_FLAG_COMPRESSED)
             && !src_format->decompress)))
     {
         FIXME("Cannot find a conversion function from format %s to %s.\n",
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 3958958174a..fbe5ac39a08 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -71,7 +71,7 @@ static BOOL wined3d_texture_use_immutable_storage(const struct wined3d_texture *
     /* We don't expect to create texture views for textures with height-scaled formats.
      * Besides, ARB_texture_storage doesn't allow specifying exact sizes for all levels. */
     return gl_info->supported[ARB_TEXTURE_STORAGE]
-            && !(texture->resource.format_flags & WINED3DFMT_FLAG_HEIGHT_SCALE);
+            && !(texture->resource.format_base_flags & WINED3DFMT_FLAG_HEIGHT_SCALE);
 }
 
 /* Front buffer coordinates are always full screen coordinates, but our GL
@@ -978,7 +978,7 @@ static void wined3d_texture_gl_allocate_mutable_storage(struct wined3d_texture_g
         {
             width = wined3d_texture_get_level_pow2_width(&texture_gl->t, level);
             height = wined3d_texture_get_level_pow2_height(&texture_gl->t, level);
-            if (texture_gl->t.resource.format_flags & WINED3DFMT_FLAG_HEIGHT_SCALE)
+            if (texture_gl->t.resource.format_base_flags & WINED3DFMT_FLAG_HEIGHT_SCALE)
             {
                 height *= format->f.height_scale.numerator;
                 height /= format->f.height_scale.denominator;
@@ -2268,7 +2268,7 @@ static void wined3d_texture_gl_upload_bo(const struct wined3d_format *src_format
 {
     const struct wined3d_format_gl *format_gl = wined3d_format_gl(src_format);
 
-    if (src_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_COMPRESSED)
+    if (src_format->base_flags & WINED3DFMT_FLAG_COMPRESSED)
     {
         GLenum internal = wined3d_gl_get_internal_format(&dst_texture->resource, format_gl, srgb);
         unsigned int dst_row_pitch, dst_slice_pitch;
@@ -2411,8 +2411,7 @@ static enum wined3d_format_id wined3d_get_alpha_fixup_format(enum wined3d_format
 {
     unsigned int i;
 
-    if (!(dst_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_COMPRESSED)
-            && !dst_format->alpha_size)
+    if (!(dst_format->base_flags & WINED3DFMT_FLAG_COMPRESSED) && !dst_format->alpha_size)
         return WINED3DFMT_UNKNOWN;
 
     for (i = 0; i < ARRAY_SIZE(formats_src_alpha_fixup); ++i)
@@ -2510,7 +2509,7 @@ static void wined3d_texture_gl_upload_data(struct wined3d_context *context,
         dst_texture->resource.pin_sysmem = 1;
     }
 
-    if (src_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_HEIGHT_SCALE)
+    if (src_format->base_flags & WINED3DFMT_FLAG_HEIGHT_SCALE)
     {
         update_h *= src_format->height_scale.numerator;
         update_h /= src_format->height_scale.denominator;
@@ -2723,7 +2722,7 @@ static void wined3d_texture_gl_download_data_slow_path(struct wined3d_texture_gl
 
         if (bo)
             ERR("NP2 emulated texture uses PBO unexpectedly.\n");
-        if (texture_gl->t.resource.format_flags & WINED3DFMT_FLAG_COMPRESSED)
+        if (texture_gl->t.resource.format_base_flags & WINED3DFMT_FLAG_COMPRESSED)
             ERR("Unexpected compressed format for NP2 emulated texture.\n");
     }
 
@@ -2771,7 +2770,7 @@ static void wined3d_texture_gl_download_data_slow_path(struct wined3d_texture_gl
         mem = data->addr;
     }
 
-    if (texture_gl->t.resource.format_flags & WINED3DFMT_FLAG_COMPRESSED)
+    if (texture_gl->t.resource.format_base_flags & WINED3DFMT_FLAG_COMPRESSED)
     {
         TRACE("Downloading compressed texture %p, %u, level %u, format %#x, type %#x, data %p.\n",
                 texture_gl, sub_resource_idx, level, format_gl->format, format_gl->type, mem);
@@ -2987,7 +2986,7 @@ static void wined3d_texture_gl_download_data(struct wined3d_context *context,
         checkGLcall("glBindBuffer");
     }
 
-    if (src_texture->resource.format_flags & WINED3DFMT_FLAG_COMPRESSED)
+    if (src_texture->resource.format_base_flags & WINED3DFMT_FLAG_COMPRESSED)
     {
         TRACE("Downloading compressed texture %p, %u, level %u, format %#x, type %#x, data %p.\n",
                 src_texture, src_sub_resource_idx, src_level, format_gl->format, format_gl->type, offset);
@@ -3862,8 +3861,7 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
         if (desc->resource_type != WINED3D_RTYPE_TEXTURE_3D && !d3d_info->texture_npot_conditional)
         {
             /* TODO: Add support for non-power-of-two compressed textures. */
-            if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D]
-                    & (WINED3DFMT_FLAG_COMPRESSED | WINED3DFMT_FLAG_HEIGHT_SCALE))
+            if (format->base_flags & (WINED3DFMT_FLAG_COMPRESSED | WINED3DFMT_FLAG_HEIGHT_SCALE))
             {
                 FIXME("Compressed or height scaled non-power-of-two (%ux%u) textures are not supported.\n",
                         desc->width, desc->height);
@@ -5714,8 +5712,8 @@ static bool ffp_blit_supported(enum wined3d_blit_op blit_op, const struct wined3
     if (src_resource->type != WINED3D_RTYPE_TEXTURE_2D)
         return false;
 
-    decompress = (src_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_COMPRESSED)
-            && !(dst_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_COMPRESSED);
+    decompress = (src_format->base_flags & WINED3DFMT_FLAG_COMPRESSED)
+            && !(dst_format->base_flags & WINED3DFMT_FLAG_COMPRESSED);
     if (!decompress && !(src_resource->access & dst_resource->access & WINED3D_RESOURCE_ACCESS_GPU))
     {
         TRACE("Source or destination resource is not GPU accessible.\n");
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 52aff96c36c..b91626b9f81 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -692,28 +692,27 @@ struct wined3d_format_block_info
     UINT block_height;
     UINT block_byte_count;
     unsigned int base_flags;
-    unsigned int flags;
 };
 
 static const struct wined3d_format_block_info format_block_info[] =
 {
-    {WINED3DFMT_DXT1,               4, 4, 8,  0,                                WINED3DFMT_FLAG_COMPRESSED},
-    {WINED3DFMT_DXT2,               4, 4, 16, 0,                                WINED3DFMT_FLAG_COMPRESSED},
-    {WINED3DFMT_DXT3,               4, 4, 16, 0,                                WINED3DFMT_FLAG_COMPRESSED},
-    {WINED3DFMT_DXT4,               4, 4, 16, 0,                                WINED3DFMT_FLAG_COMPRESSED},
-    {WINED3DFMT_DXT5,               4, 4, 16, 0,                                WINED3DFMT_FLAG_COMPRESSED},
-    {WINED3DFMT_BC1_UNORM,          4, 4, 8,  0,                                WINED3DFMT_FLAG_COMPRESSED},
-    {WINED3DFMT_BC2_UNORM,          4, 4, 16, 0,                                WINED3DFMT_FLAG_COMPRESSED},
-    {WINED3DFMT_BC3_UNORM,          4, 4, 16, 0,                                WINED3DFMT_FLAG_COMPRESSED},
-    {WINED3DFMT_BC4_UNORM,          4, 4, 8,  0,                                WINED3DFMT_FLAG_COMPRESSED},
-    {WINED3DFMT_BC4_SNORM,          4, 4, 8,  0,                                WINED3DFMT_FLAG_COMPRESSED},
-    {WINED3DFMT_BC5_UNORM,          4, 4, 16, 0,                                WINED3DFMT_FLAG_COMPRESSED},
-    {WINED3DFMT_BC5_SNORM,          4, 4, 16, 0,                                WINED3DFMT_FLAG_COMPRESSED},
-    {WINED3DFMT_BC6H_UF16,          4, 4, 16, 0,                                WINED3DFMT_FLAG_COMPRESSED},
-    {WINED3DFMT_BC6H_SF16,          4, 4, 16, 0,                                WINED3DFMT_FLAG_COMPRESSED},
-    {WINED3DFMT_BC7_UNORM,          4, 4, 16, 0,                                WINED3DFMT_FLAG_COMPRESSED},
-    {WINED3DFMT_ATI1N,              4, 4, 8,  WINED3DFMT_FLAG_BLOCKS_NO_VERIFY, WINED3DFMT_FLAG_COMPRESSED},
-    {WINED3DFMT_ATI2N,              4, 4, 16, WINED3DFMT_FLAG_BLOCKS_NO_VERIFY, WINED3DFMT_FLAG_COMPRESSED},
+    {WINED3DFMT_DXT1,               4, 4, 8,  WINED3DFMT_FLAG_COMPRESSED},
+    {WINED3DFMT_DXT2,               4, 4, 16, WINED3DFMT_FLAG_COMPRESSED},
+    {WINED3DFMT_DXT3,               4, 4, 16, WINED3DFMT_FLAG_COMPRESSED},
+    {WINED3DFMT_DXT4,               4, 4, 16, WINED3DFMT_FLAG_COMPRESSED},
+    {WINED3DFMT_DXT5,               4, 4, 16, WINED3DFMT_FLAG_COMPRESSED},
+    {WINED3DFMT_BC1_UNORM,          4, 4, 8,  WINED3DFMT_FLAG_COMPRESSED},
+    {WINED3DFMT_BC2_UNORM,          4, 4, 16, WINED3DFMT_FLAG_COMPRESSED},
+    {WINED3DFMT_BC3_UNORM,          4, 4, 16, WINED3DFMT_FLAG_COMPRESSED},
+    {WINED3DFMT_BC4_UNORM,          4, 4, 8,  WINED3DFMT_FLAG_COMPRESSED},
+    {WINED3DFMT_BC4_SNORM,          4, 4, 8,  WINED3DFMT_FLAG_COMPRESSED},
+    {WINED3DFMT_BC5_UNORM,          4, 4, 16, WINED3DFMT_FLAG_COMPRESSED},
+    {WINED3DFMT_BC5_SNORM,          4, 4, 16, WINED3DFMT_FLAG_COMPRESSED},
+    {WINED3DFMT_BC6H_UF16,          4, 4, 16, WINED3DFMT_FLAG_COMPRESSED},
+    {WINED3DFMT_BC6H_SF16,          4, 4, 16, WINED3DFMT_FLAG_COMPRESSED},
+    {WINED3DFMT_BC7_UNORM,          4, 4, 16, WINED3DFMT_FLAG_COMPRESSED},
+    {WINED3DFMT_ATI1N,              4, 4, 8,  WINED3DFMT_FLAG_COMPRESSED | WINED3DFMT_FLAG_BLOCKS_NO_VERIFY},
+    {WINED3DFMT_ATI2N,              4, 4, 16, WINED3DFMT_FLAG_COMPRESSED | WINED3DFMT_FLAG_BLOCKS_NO_VERIFY},
     {WINED3DFMT_YUY2,               2, 1, 4,  WINED3DFMT_FLAG_BLOCKS_NO_VERIFY},
     {WINED3DFMT_UYVY,               2, 1, 4,  WINED3DFMT_FLAG_BLOCKS_NO_VERIFY},
     {WINED3DFMT_R9G9B9E5_SHAREDEXP, 1, 1, 4},
@@ -2314,7 +2313,6 @@ static BOOL init_format_block_info(struct wined3d_adapter *adapter)
         format->block_height = format_block_info[i].block_height;
         format->block_byte_count = format_block_info[i].block_byte_count;
         format->base_flags |= WINED3DFMT_FLAG_BLOCKS | format_block_info[i].base_flags;
-        format_set_flag(format, format_block_info[i].flags);
     }
 
     return TRUE;
@@ -3062,7 +3060,7 @@ static void init_format_fbo_compat_info(const struct wined3d_adapter *adapter,
         if (!format->internal)
             continue;
 
-        if (format->f.flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_COMPRESSED)
+        if (format->f.base_flags & WINED3DFMT_FLAG_COMPRESSED)
         {
             TRACE("Skipping format %s because it's a compressed format.\n",
                     debug_d3dformat(format->f.id));
@@ -3782,13 +3780,13 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
             || (gl_info->supported[ARB_FRAGMENT_SHADER] && gl_info->supported[ARB_VERTEX_SHADER]))
     {
         format = get_format_gl_internal(adapter, WINED3DFMT_YV12);
-        format_set_flag(&format->f, WINED3DFMT_FLAG_HEIGHT_SCALE);
+        format->f.base_flags |= WINED3DFMT_FLAG_HEIGHT_SCALE;
         format->f.height_scale.numerator = 3;
         format->f.height_scale.denominator = 2;
         format->f.color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YV12);
 
         format = get_format_gl_internal(adapter, WINED3DFMT_NV12);
-        format_set_flag(&format->f, WINED3DFMT_FLAG_HEIGHT_SCALE);
+        format->f.base_flags |= WINED3DFMT_FLAG_HEIGHT_SCALE;
         format->f.height_scale.numerator = 3;
         format->f.height_scale.denominator = 2;
         format->f.color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_NV12);
@@ -4684,7 +4682,7 @@ void wined3d_format_calculate_pitch(const struct wined3d_format *format, unsigne
         *slice_pitch = *row_pitch * height;
     }
 
-    if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_HEIGHT_SCALE)
+    if (format->base_flags & WINED3DFMT_FLAG_HEIGHT_SCALE)
     {
         /* The D3D format requirements make sure that the resulting format is an integer again */
         *slice_pitch *= format->height_scale.numerator;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 2cbe78d3bd4..22009db8811 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -6113,7 +6113,9 @@ extern enum wined3d_format_id pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN
 #define WINED3DFMT_FLAG_EXTENSION                   0x00000010
 #define WINED3DFMT_FLAG_BLOCKS                      0x00000020
 #define WINED3DFMT_FLAG_BLOCKS_NO_VERIFY            0x00000040
-#define WINED3DFMT_FLAG_BROKEN_PITCH                0x00000080
+#define WINED3DFMT_FLAG_COMPRESSED                  0x00000080
+#define WINED3DFMT_FLAG_BROKEN_PITCH                0x00000100
+#define WINED3DFMT_FLAG_HEIGHT_SCALE                0x00000200
 
 #define WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING    0x00000001
 #define WINED3DFMT_FLAG_FILTERING                   0x00000002
@@ -6127,8 +6129,6 @@ extern enum wined3d_format_id pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN
 #define WINED3DFMT_FLAG_SRGB_WRITE                  0x00001000
 #define WINED3DFMT_FLAG_VTF                         0x00002000
 #define WINED3DFMT_FLAG_SHADOW                      0x00004000
-#define WINED3DFMT_FLAG_COMPRESSED                  0x00008000
-#define WINED3DFMT_FLAG_HEIGHT_SCALE                0x00040000
 #define WINED3DFMT_FLAG_TEXTURE                     0x00080000
 #define WINED3DFMT_FLAG_GEN_MIPMAP                  0x00400000
 #define WINED3DFMT_FLAG_VERTEX_ATTRIBUTE            0x01000000
-- 
GitLab


https://gitlab.winehq.org/wine/wine/-/merge_requests/79



More information about the wine-devel mailing list