Re: [1/5] d3dx9: Implement D3DXLoadVolumeFromMemory.

2012-06-29 Thread Józef Kucia
On Thu, Jun 28, 2012 at 2:27 PM, Matteo Bruni matteo.myst...@gmail.com wrote:
 I'm not quite sure of the right and bottom misalignment checks. If the
 tests confirm that, of course that's okay.


Native accepts misaligned boxes, but in order to implement it S3TC
decompressor and compressor is needed. I'll make it a FIXME.




Re: [1/5] d3dx9: Implement D3DXLoadVolumeFromMemory.

2012-06-28 Thread Matteo Bruni
2012/6/27 Józef Kucia joseph.ku...@gmail.com:
 ---

Hi Józef,

 +void copy_simple_data(const BYTE *src, UINT srcpitch, SIZE src_size, const 
 PixelFormatDesc *srcformat,
 +BYTE *dest, UINT destpitch, SIZE dst_size, const PixelFormatDesc 
 *destformat, D3DCOLOR colorkey) DECLSPEC_HIDDEN;
 +

You are not actually using this function in the patch.

 +        if (dst_box-Left  dst_box-Right || dst_box-Right  desc.Width)
 +            return D3DERR_INVALIDCALL;
 +        if (dst_box-Top  dst_box-Bottom || dst_box-Bottom  desc.Height)
 +            return D3DERR_INVALIDCALL;
 +        if (dst_box-Front  dst_box-Back || dst_box-Back  desc.Depth)
 +            return D3DERR_INVALIDCALL;
 +
 +        dst_width = dst_box-Right - dst_box-Left;
 +        dst_height = dst_box-Bottom - dst_box-Top;
 +        dst_depth = dst_box-Back - dst_box-Front;
 +        if (!dst_width || !dst_height || !dst_depth)
 +            return D3DERR_INVALIDCALL;

You can avoid the last check by comparing e.g. (dst_box-Left =
dst_box-Right) above, instead of using .

 +        if (src_box-Left  (src_format_desc-block_width - 1)
 +                || src_box-Top  (src_format_desc-block_height - 1)
 +                || (src_box-Right  (src_format_desc-block_width - 1)
 +                     src_width != desc.Width)
 +                || (src_box-Bottom  (src_format_desc-block_height - 1)
 +                     src_height != desc.Height))
 +        {
 +            WARN(Source box (%u, %u, %u, %u) is misaligned\n,
 +                    src_box-Left, src_box-Top, src_box-Right, 
 src_box-Bottom);
 +            return D3DXERR_INVALIDDATA;
 +        }

I'm not quite sure of the right and bottom misalignment checks. If the
tests confirm that, of course that's okay.

 +        for (slice = 0; slice  src_depth; slice++)
 +        {
 +            src_addr = src_memory;
 +            src_addr += slice * src_slice_pitch;

Shouldn't you take into account src_box-Front?