wined3d: Introduce wined3d_gl_get_internal_format().

Signed-off-by: Jan Sikorski <jsikorski@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jan Sikorski 2021-03-31 12:27:39 +02:00 committed by Alexandre Julliard
parent 99dc5b78a1
commit f42f8925f7
2 changed files with 13 additions and 16 deletions

View File

@ -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);

View File

@ -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);