wined3d: Use the format info to calculate compressed surface size in IWineD3DDeviceImpl_CreateSurface().
This commit is contained in:
parent
1ad485ff83
commit
e255f971e4
|
@ -898,7 +898,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface,
|
||||||
IWineD3DSurfaceImpl *object; /*NOTE: impl ref allowed since this is a create function */
|
IWineD3DSurfaceImpl *object; /*NOTE: impl ref allowed since this is a create function */
|
||||||
unsigned int Size = 1;
|
unsigned int Size = 1;
|
||||||
const struct GlPixelFormatDesc *glDesc = getFormatDescEntry(Format, &GLINFO_LOCATION);
|
const struct GlPixelFormatDesc *glDesc = getFormatDescEntry(Format, &GLINFO_LOCATION);
|
||||||
UINT mul_4w, mul_4h;
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("(%p) Create surface\n",This);
|
TRACE("(%p) Create surface\n",This);
|
||||||
|
@ -912,24 +911,18 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface,
|
||||||
* by the device.
|
* by the device.
|
||||||
*******************************/
|
*******************************/
|
||||||
|
|
||||||
/** DXTn mipmaps use the same number of 'levels' down to eg. 8x1, but since
|
|
||||||
* it is based around 4x4 pixel blocks it requires padding, so allocate enough
|
|
||||||
* space!
|
|
||||||
*********************************/
|
|
||||||
mul_4w = (Width + 3) & ~3;
|
|
||||||
mul_4h = (Height + 3) & ~3;
|
|
||||||
if (WINED3DFMT_UNKNOWN == Format) {
|
if (WINED3DFMT_UNKNOWN == Format) {
|
||||||
Size = 0;
|
Size = 0;
|
||||||
} else if (Format == WINED3DFMT_DXT1) {
|
}
|
||||||
/* DXT1 is half byte per pixel */
|
else if (glDesc->Flags & WINED3DFMT_FLAG_COMPRESSED)
|
||||||
Size = (mul_4w * glDesc->byte_count * mul_4h) >> 1;
|
{
|
||||||
|
UINT row_block_count = (Width + glDesc->block_width - 1) / glDesc->block_width;
|
||||||
} else if (Format == WINED3DFMT_DXT2 || Format == WINED3DFMT_DXT3 ||
|
UINT row_count = (Height + glDesc->block_height - 1) / glDesc->block_height;
|
||||||
Format == WINED3DFMT_DXT4 || Format == WINED3DFMT_DXT5 ||
|
Size = row_count * row_block_count * glDesc->block_byte_count;
|
||||||
Format == WINED3DFMT_ATI2N) {
|
}
|
||||||
Size = (mul_4w * glDesc->byte_count * mul_4h);
|
else
|
||||||
} else {
|
{
|
||||||
/* The pitch is a multiple of 4 bytes */
|
/* The pitch is a multiple of 4 bytes */
|
||||||
Size = ((Width * glDesc->byte_count) + This->surface_alignment - 1) & ~(This->surface_alignment - 1);
|
Size = ((Width * glDesc->byte_count) + This->surface_alignment - 1) & ~(This->surface_alignment - 1);
|
||||||
Size *= Height;
|
Size *= Height;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue