Jan Sikorski : wined3d: Introduce wined3d_gl_get_internal_format().

Alexandre Julliard julliard at winehq.org
Wed Mar 31 15:55:14 CDT 2021


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

Author: Jan Sikorski <jsikorski at codeweavers.com>
Date:   Wed Mar 31 12:27:39 2021 +0200

wined3d: Introduce wined3d_gl_get_internal_format().

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

---

 dlls/wined3d/texture.c         | 18 ++----------------
 dlls/wined3d/wined3d_private.h | 11 +++++++++++
 2 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 6f2f408f11e..0736f612f12 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1999,13 +1999,7 @@ void wined3d_texture_gl_prepare_texture(struct wined3d_texture_gl *texture_gl,
 
     wined3d_texture_gl_bind_and_dirtify(texture_gl, context_gl, srgb);
 
-    if (srgb)
-        internal = format_gl->srgb_internal;
-    else if (resource->bind_flags & WINED3D_BIND_RENDER_TARGET && wined3d_resource_is_offscreen(resource))
-        internal = format_gl->rt_internal;
-    else
-        internal = format_gl->internal;
-
+    internal = wined3d_gl_get_internal_format(resource, format_gl, srgb);
     if (!internal)
         FIXME("No GL internal format for format %s.\n", debug_d3dformat(format->id));
 
@@ -2146,16 +2140,8 @@ static void wined3d_texture_gl_upload_bo(const struct wined3d_format *src_format
 
     if (src_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_COMPRESSED)
     {
+        GLenum internal = wined3d_gl_get_internal_format(&dst_texture->resource, format_gl, srgb);
         unsigned int dst_row_pitch, dst_slice_pitch;
-        GLenum internal;
-
-        if (srgb)
-            internal = format_gl->srgb_internal;
-        else if (dst_texture->resource.bind_flags & WINED3D_BIND_RENDER_TARGET
-                && wined3d_resource_is_offscreen(&dst_texture->resource))
-            internal = format_gl->rt_internal;
-        else
-            internal = format_gl->internal;
 
         wined3d_format_calculate_pitch(src_format, 1, update_w, update_h, &dst_row_pitch, &dst_slice_pitch);
 
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 21941afbd82..e9e73da9f25 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -5930,6 +5930,17 @@ static inline GLuint wined3d_texture_gl_get_texture_name(const struct wined3d_te
             ? texture_gl->texture_srgb.name : texture_gl->texture_rgb.name;
 }
 
+static inline GLuint wined3d_gl_get_internal_format(struct wined3d_resource *resource,
+    const struct wined3d_format_gl *format_gl, bool srgb)
+{
+    if (srgb)
+        return format_gl->srgb_internal;
+    else if (resource->bind_flags & WINED3D_BIND_RENDER_TARGET && wined3d_resource_is_offscreen(resource))
+        return format_gl->rt_internal;
+    else
+        return format_gl->internal;
+}
+
 static inline BOOL can_use_texture_swizzle(const struct wined3d_d3d_info *d3d_info, const struct wined3d_format *format)
 {
     return d3d_info->texture_swizzle && !is_complex_fixup(format->color_fixup) && !is_scaling_fixup(format->color_fixup);




More information about the wine-cvs mailing list