Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/texture.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 8f499d4ada60..61439d7f03c7 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1706,6 +1706,25 @@ static void wined3d_texture_force_reload(struct wined3d_texture *texture) } }
+static GLenum wined3d_texture_get_gl_internal_format(struct wined3d_texture *texture, BOOL srgb) +{ + const struct wined3d_format *format = texture->resource.format; + GLenum internal; + + if (srgb) + internal = format->glGammaInternal; + else if (texture->resource.usage & WINED3DUSAGE_RENDERTARGET + && wined3d_resource_is_offscreen(&texture->resource)) + internal = format->rtInternal; + else + internal = format->glInternal; + + if (!internal) + FIXME("No GL internal format for format %s.\n", debug_d3dformat(format->id)); + + return internal; +} + /* Context activation is done by the caller. */ void wined3d_texture_prepare_texture(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb) { @@ -1751,16 +1770,7 @@ void wined3d_texture_prepare_texture(struct wined3d_texture *texture, struct win
wined3d_texture_bind_and_dirtify(texture, context, srgb);
- if (srgb) - internal = format->glGammaInternal; - else if (texture->resource.usage & WINED3DUSAGE_RENDERTARGET - && wined3d_resource_is_offscreen(&texture->resource)) - internal = format->rtInternal; - else - internal = format->glInternal; - - if (!internal) - FIXME("No GL internal format for format %s.\n", debug_d3dformat(format->id)); + internal = wined3d_texture_get_gl_internal_format(texture, srgb);
TRACE("internal %#x, format %#x, type %#x.\n", internal, format->glFormat, format->glType);
@@ -2019,13 +2029,7 @@ void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int s const BYTE *addr = bo.addr; GLenum internal;
- if (srgb) - internal = format->glGammaInternal; - else if (texture->resource.usage & WINED3DUSAGE_RENDERTARGET - && wined3d_resource_is_offscreen(&texture->resource)) - internal = format->rtInternal; - else - internal = format->glInternal; + internal = wined3d_texture_get_gl_internal_format(texture, srgb);
wined3d_format_calculate_pitch(format, 1, update_w, update_h, &dst_row_pitch, &dst_slice_pitch);
On 14 September 2018 at 16:30, Józef Kucia jkucia@codeweavers.com wrote:
+static GLenum wined3d_texture_get_gl_internal_format(struct wined3d_texture *texture, BOOL srgb) +{
- const struct wined3d_format *format = texture->resource.format;
...
@@ -2019,13 +2029,7 @@ void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int s
if (srgb)
internal = format->glGammaInternal;
else if (texture->resource.usage & WINED3DUSAGE_RENDERTARGET
&& wined3d_resource_is_offscreen(&texture->resource))
internal = format->rtInternal;
else
internal = format->glInternal;
internal = wined3d_texture_get_gl_internal_format(texture, srgb);
Unfortunately that's not necessarily the same format, and indeed the tests fail with this:
0009:err:d3d:wined3d_debug_callback 0x196440: "GL_INVALID_ENUM in glTexStorage3D(internalformat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)". 0009:err:d3d:wined3d_debug_callback 0x196440: "GL_INVALID_OPERATION in glTexSubImage3D(invalid texture level 0)". visual.c:5100: Test failed: Expected colour 0xffff0000, got 0xff000000, case 0. visual.c:5100: Test failed: Expected colour 0x00000000, got 0xff000000, case 1. visual.c:5100: Test failed: Expected colour 0xff00ff00, got 0xff000000, case 2. visual.c:5100: Test failed: Expected colour 0xff00ff00, got 0xff000000, case 3. visual.c:5100: Test failed: Expected colour 0xff0000ff, got 0xff000000, case 4. visual.c:5100: Test failed: Expected colour 0xff0000ff, got 0xff000000, case 5. visual.c:5100: Test failed: Expected colour 0xffffffff, got 0xff000000, case 6. visual.c:5100: Test failed: Expected colour 0xffffffff, got 0xff000000, case 7.