From: Zebediah Figura zfigura@codeweavers.com
--- dlls/wined3d/utils.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index a46a4c7257d..07e2190db20 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -1929,6 +1929,17 @@ static const struct wined3d_format_srgb_info format_srgb_info[] = {WINED3DFMT_BC7_UNORM_SRGB, WINED3DFMT_BC7_UNORM}, };
+static enum wined3d_format_id wined3d_format_get_srgb_format(enum wined3d_format_id id) +{ + for (unsigned int i = 0; i < ARRAY_SIZE(format_srgb_info); ++i) + { + if (format_srgb_info[i].base_format_id == id) + return format_srgb_info[i].srgb_format_id; + } + + return WINED3DFMT_UNKNOWN; +} + static inline int get_format_idx(enum wined3d_format_id format_id) { unsigned int i; @@ -3186,6 +3197,7 @@ static void query_internal_format(struct wined3d_adapter *adapter, static BOOL init_format_texture_info(struct wined3d_adapter *adapter, struct wined3d_gl_info *gl_info) { struct wined3d_format_gl *format, *srgb_format; + enum wined3d_format_id srgb_format_id; struct fragment_caps fragment_caps; struct shader_caps shader_caps; unsigned int i, j; @@ -3262,18 +3274,11 @@ static BOOL init_format_texture_info(struct wined3d_adapter *adapter, struct win format->f.upload = format_texture_info[i].upload; format->f.download = format_texture_info[i].download;
- srgb_format = NULL; - for (j = 0; j < ARRAY_SIZE(format_srgb_info); ++j) - { - if (format_srgb_info[j].base_format_id == format->f.id) - { - if (!(srgb_format = get_format_gl_internal(adapter, format_srgb_info[j].srgb_format_id))) - return FALSE; - break; - } - } - if (!srgb_format) + srgb_format_id = wined3d_format_get_srgb_format(format->f.id); + if (srgb_format_id == WINED3DFMT_UNKNOWN) continue; + if (!(srgb_format = get_format_gl_internal(adapter, srgb_format_id))) + return FALSE;
copy_format(adapter, &srgb_format->f, &format->f);