mirror of
https://github.com/reactos/wine.git
synced 2025-02-21 13:23:25 +00:00
wined3d: Introduce surface_calculate_size().
This commit is contained in:
parent
5f581975dc
commit
fede35d1c5
@ -94,6 +94,31 @@ static void surface_cleanup(IWineD3DSurfaceImpl *This)
|
||||
resource_cleanup((IWineD3DResource *)This);
|
||||
}
|
||||
|
||||
UINT surface_calculate_size(const struct GlPixelFormatDesc *format_desc, UINT alignment, UINT width, UINT height)
|
||||
{
|
||||
UINT size;
|
||||
|
||||
if (format_desc->format == WINED3DFMT_UNKNOWN)
|
||||
{
|
||||
size = 0;
|
||||
}
|
||||
else if (format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED)
|
||||
{
|
||||
UINT row_block_count = (width + format_desc->block_width - 1) / format_desc->block_width;
|
||||
UINT row_count = (height + format_desc->block_height - 1) / format_desc->block_height;
|
||||
size = row_count * row_block_count * format_desc->block_byte_count;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The pitch is a multiple of 4 bytes. */
|
||||
size = height * (((width * format_desc->byte_count) + alignment - 1) & ~(alignment - 1));
|
||||
}
|
||||
|
||||
if (format_desc->heightscale != 0.0) size *= format_desc->heightscale;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
HRESULT surface_init(IWineD3DSurfaceImpl *surface, WINED3DSURFTYPE surface_type, UINT alignment,
|
||||
UINT width, UINT height, UINT level, BOOL lockable, BOOL discard, WINED3DMULTISAMPLE_TYPE multisample_type,
|
||||
UINT multisample_quality, IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format,
|
||||
@ -113,24 +138,7 @@ HRESULT surface_init(IWineD3DSurfaceImpl *surface, WINED3DSURFTYPE surface_type,
|
||||
|
||||
/* FIXME: Check that the format is supported by the device. */
|
||||
|
||||
if (format == WINED3DFMT_UNKNOWN)
|
||||
{
|
||||
resource_size = 0;
|
||||
}
|
||||
else if (format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED)
|
||||
{
|
||||
UINT row_block_count = (width + format_desc->block_width - 1) / format_desc->block_width;
|
||||
UINT row_count = (height + format_desc->block_height - 1) / format_desc->block_height;
|
||||
resource_size = row_count * row_block_count * format_desc->block_byte_count;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The pitch is a multiple of 4 bytes. */
|
||||
resource_size = ((width * format_desc->byte_count) + alignment - 1) & ~(alignment - 1);
|
||||
resource_size *= height;
|
||||
}
|
||||
|
||||
if (format_desc->heightscale != 0.0) resource_size *= format_desc->heightscale;
|
||||
resource_size = surface_calculate_size(format_desc, alignment, width, height);
|
||||
|
||||
/* Look at the implementation and set the correct Vtable. */
|
||||
switch (surface_type)
|
||||
|
@ -519,21 +519,9 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3D
|
||||
}
|
||||
|
||||
TRACE("(%p) : Setting texture format to (%d,%s)\n", This, format, debug_d3dformat(format));
|
||||
if (format == WINED3DFMT_UNKNOWN) {
|
||||
This->resource.size = 0;
|
||||
}
|
||||
else if (format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED)
|
||||
{
|
||||
UINT row_block_count = (This->pow2Width + format_desc->block_width - 1) / format_desc->block_width;
|
||||
UINT row_count = (This->pow2Height + format_desc->block_height - 1) / format_desc->block_height;
|
||||
This->resource.size = row_count * row_block_count * format_desc->block_byte_count;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char alignment = This->resource.wineD3DDevice->surface_alignment;
|
||||
This->resource.size = ((This->pow2Width * format_desc->byte_count) + alignment - 1) & ~(alignment - 1);
|
||||
This->resource.size *= This->pow2Height;
|
||||
}
|
||||
|
||||
This->resource.size = surface_calculate_size(format_desc, This->resource.wineD3DDevice->surface_alignment,
|
||||
This->pow2Width, This->pow2Height);
|
||||
|
||||
This->Flags |= (WINED3DFMT_D16_LOCKABLE == format) ? SFLAG_LOCKABLE : 0;
|
||||
|
||||
|
@ -1920,6 +1920,7 @@ struct IWineD3DSurfaceImpl
|
||||
extern const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl;
|
||||
extern const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl;
|
||||
|
||||
UINT surface_calculate_size(const struct GlPixelFormatDesc *format_desc, UINT alignment, UINT width, UINT height);
|
||||
void surface_gdi_cleanup(IWineD3DSurfaceImpl *This);
|
||||
HRESULT surface_init(IWineD3DSurfaceImpl *surface, WINED3DSURFTYPE surface_type, UINT alignment,
|
||||
UINT width, UINT height, UINT level, BOOL lockable, BOOL discard, WINED3DMULTISAMPLE_TYPE multisample_type,
|
||||
|
Loading…
x
Reference in New Issue
Block a user