Commit 0eae42dd authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Use GL_UNPACK_ROW_LENGTH for partial updates of regular surfaces in…

wined3d: Use GL_UNPACK_ROW_LENGTH for partial updates of regular surfaces in IWineD3DDeviceImpl_UpdateSurface().
parent 25338601
...@@ -5261,14 +5261,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface, ...@@ -5261,14 +5261,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
ENTER_GL(); ENTER_GL();
/* TODO: Cube and volume support */ if (dst_format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED)
if (rowoffset) /* Not a whole row so we have to do it a line at a time. */
{ {
if (dst_format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED) const unsigned char *data = ((const unsigned char *)IWineD3DSurface_GetData(pSourceSurface));
if (rowoffset)
{ {
const unsigned char *data = ((const unsigned char *)IWineD3DSurface_GetData(pSourceSurface));
UINT row_length = (srcWidth / src_format_desc->block_width) * src_format_desc->block_byte_count; UINT row_length = (srcWidth / src_format_desc->block_width) * src_format_desc->block_byte_count;
UINT row_count = srcHeight / src_format_desc->block_height; UINT row_count = srcHeight / src_format_desc->block_height;
UINT src_pitch = IWineD3DSurface_GetPitch(pSourceSurface); UINT src_pitch = IWineD3DSurface_GetPitch(pSourceSurface);
UINT y = destTop; UINT y = destTop;
UINT row; UINT row;
...@@ -5279,32 +5279,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface, ...@@ -5279,32 +5279,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
for (row = 0; row < row_count; ++row) for (row = 0; row < row_count; ++row)
{ {
GL_EXTCALL(glCompressedTexSubImage2DARB(dst_impl->texture_target, dst_impl->texture_level, GL_EXTCALL(glCompressedTexSubImage2DARB(dst_impl->texture_target, dst_impl->texture_level,
destLeft, y, srcWidth, src_format_desc->block_height, destLeft, y, srcWidth, src_format_desc->block_height,
dst_format_desc->glInternal, row_length, data)); dst_format_desc->glInternal, row_length, data));
y += src_format_desc->block_height; y += src_format_desc->block_height;
data += src_pitch; data += src_pitch;
} }
checkGLcall("glCompressedTexSubImage2DARB");
} }
else else
{ {
const unsigned char *data = ((const unsigned char *)IWineD3DSurface_GetData(pSourceSurface)) + offset;
unsigned int j;
for (j = destTop; j < (srcHeight + destTop); ++j)
{
glTexSubImage2D(dst_impl->texture_target, dst_impl->texture_level, destLeft, j,
srcWidth, 1, dst_format_desc->glFormat, dst_format_desc->glType,data);
data += rowoffset;
}
}
}
else /* Full width, so just write out the whole texture. */
{
const unsigned char* data = ((const unsigned char *)IWineD3DSurface_GetData(pSourceSurface)) + offset;
if (dst_format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED)
{
if (destSurfaceHeight != srcHeight || destSurfaceWidth != srcWidth) if (destSurfaceHeight != srcHeight || destSurfaceWidth != srcWidth)
{ {
/* FIXME: The easy way to do this is to lock the destination, and copy the bits across. */ /* FIXME: The easy way to do this is to lock the destination, and copy the bits across. */
...@@ -5320,13 +5302,18 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface, ...@@ -5320,13 +5302,18 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
dst_format_desc->glInternal, srcWidth, srcHeight, 0, destSize, data)); dst_format_desc->glInternal, srcWidth, srcHeight, 0, destSize, data));
} }
} }
else checkGLcall("glCompressedTexSubImage2DARB");
{ }
glTexSubImage2D(dst_impl->texture_target, dst_impl->texture_level, destLeft, destTop, else
srcWidth, srcHeight, dst_format_desc->glFormat, dst_format_desc->glType, data); {
} const unsigned char *data = ((const unsigned char *)IWineD3DSurface_GetData(pSourceSurface)) + offset;
}
checkGLcall("glTexSubImage2D"); glPixelStorei(GL_UNPACK_ROW_LENGTH, srcSurfaceWidth);
glTexSubImage2D(dst_impl->texture_target, dst_impl->texture_level, destLeft, destTop,
srcWidth, srcHeight, dst_format_desc->glFormat, dst_format_desc->glType, data);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
checkGLcall("glTexSubImage2D");
}
LEAVE_GL(); LEAVE_GL();
context_release(context); context_release(context);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment