wined3d: Merge codepaths in surface_download_data().
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
7eac961454
commit
cffe58c75d
|
@ -862,7 +862,10 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
|
|||
{
|
||||
struct wined3d_texture *texture = surface->container;
|
||||
const struct wined3d_format *format = texture->resource.format;
|
||||
unsigned int dst_row_pitch, dst_slice_pitch;
|
||||
unsigned int src_row_pitch, src_slice_pitch;
|
||||
struct wined3d_bo_address data;
|
||||
void *mem;
|
||||
|
||||
/* Only support read back of converted P8 surfaces. */
|
||||
if (texture->flags & WINED3D_TEXTURE_CONVERTED && format->id != WINED3DFMT_P8_UINT)
|
||||
|
@ -873,35 +876,6 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
|
|||
|
||||
wined3d_texture_get_memory(texture, surface_get_sub_resource_idx(surface), &data, dst_location);
|
||||
|
||||
if (texture->resource.format_flags & WINED3DFMT_FLAG_COMPRESSED)
|
||||
{
|
||||
TRACE("(%p) : Calling glGetCompressedTexImage level %d, format %#x, type %#x, data %p.\n",
|
||||
surface, surface->texture_level, format->glFormat, format->glType, data.addr);
|
||||
|
||||
if (data.buffer_object)
|
||||
{
|
||||
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, data.buffer_object));
|
||||
checkGLcall("glBindBuffer");
|
||||
GL_EXTCALL(glGetCompressedTexImage(surface->texture_target, surface->texture_level, NULL));
|
||||
checkGLcall("glGetCompressedTexImage");
|
||||
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));
|
||||
checkGLcall("glBindBuffer");
|
||||
}
|
||||
else
|
||||
{
|
||||
GL_EXTCALL(glGetCompressedTexImage(surface->texture_target,
|
||||
surface->texture_level, data.addr));
|
||||
checkGLcall("glGetCompressedTexImage");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int dst_row_pitch, dst_slice_pitch;
|
||||
unsigned int src_row_pitch, src_slice_pitch;
|
||||
GLenum gl_format = format->glFormat;
|
||||
GLenum gl_type = format->glType;
|
||||
void *mem;
|
||||
|
||||
if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
|
||||
{
|
||||
wined3d_texture_get_pitch(texture, surface->texture_level, &dst_row_pitch, &dst_slice_pitch);
|
||||
|
@ -910,34 +884,47 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
|
|||
wined3d_texture_get_level_pow2_height(texture, surface->texture_level),
|
||||
&src_row_pitch, &src_slice_pitch);
|
||||
mem = HeapAlloc(GetProcessHeap(), 0, src_slice_pitch);
|
||||
|
||||
if (data.buffer_object)
|
||||
ERR("NP2 emulated texture uses PBO unexpectedly.\n");
|
||||
if (texture->resource.format_flags & WINED3DFMT_FLAG_COMPRESSED)
|
||||
ERR("Unexpected compressed format for NP2 emulated texture.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
mem = data.addr;
|
||||
}
|
||||
|
||||
TRACE("(%p) : Calling glGetTexImage level %d, format %#x, type %#x, data %p\n",
|
||||
surface, surface->texture_level, gl_format, gl_type, mem);
|
||||
|
||||
if (data.buffer_object)
|
||||
{
|
||||
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, data.buffer_object));
|
||||
checkGLcall("glBindBuffer");
|
||||
}
|
||||
|
||||
gl_info->gl_ops.gl.p_glGetTexImage(surface->texture_target, surface->texture_level,
|
||||
gl_format, gl_type, NULL);
|
||||
checkGLcall("glGetTexImage");
|
||||
if (texture->resource.format_flags & WINED3DFMT_FLAG_COMPRESSED)
|
||||
{
|
||||
TRACE("Downloading compressed surface %p, level %u, format %#x, type %#x, data %p.\n",
|
||||
surface, surface->texture_level, format->glFormat, format->glType, mem);
|
||||
|
||||
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));
|
||||
checkGLcall("glBindBuffer");
|
||||
GL_EXTCALL(glGetCompressedTexImage(surface->texture_target, surface->texture_level, mem));
|
||||
checkGLcall("glGetCompressedTexImage");
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE("Downloading surface %p, level %u, format %#x, type %#x, data %p.\n",
|
||||
surface, surface->texture_level, format->glFormat, format->glType, mem);
|
||||
|
||||
gl_info->gl_ops.gl.p_glGetTexImage(surface->texture_target, surface->texture_level,
|
||||
gl_format, gl_type, mem);
|
||||
format->glFormat, format->glType, mem);
|
||||
checkGLcall("glGetTexImage");
|
||||
}
|
||||
|
||||
if (data.buffer_object)
|
||||
{
|
||||
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));
|
||||
checkGLcall("glBindBuffer");
|
||||
}
|
||||
|
||||
if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
|
||||
{
|
||||
const BYTE *src_data;
|
||||
|
@ -1002,7 +989,6 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
|
|||
HeapFree(GetProcessHeap(), 0, mem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* This call just uploads data, the caller is responsible for binding the
|
||||
* correct texture. */
|
||||
|
|
Loading…
Reference in New Issue