Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- Tests show that source rectangle misalignment never causes the function to fail. Just take the resample path in those cases.
Also reorganize the code a bit.
dlls/d3dx9_36/surface.c | 36 +++++++++++++++-------------------- dlls/d3dx9_36/tests/surface.c | 2 +- dlls/d3dx9_36/tests/texture.c | 34 ++++++++++++++++----------------- 3 files changed, 32 insertions(+), 40 deletions(-)
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index a2eca9cbdbd..e85805df8ec 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -1848,10 +1848,10 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, DWORD filter, D3DCOLOR color_key) { const struct pixel_format_desc *srcformatdesc, *destformatdesc; + struct volume src_size, dst_size; IDirect3DSurface9 *surface; D3DSURFACE_DESC surfdesc; D3DLOCKED_RECT lockrect; - struct volume src_size, dst_size; HRESULT hr;
TRACE("(%p, %p, %s, %p, %#x, %u, %p, %s, %#x, 0x%08x)\n", @@ -1871,14 +1871,18 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, return E_FAIL; }
- if (filter == D3DX_DEFAULT) - filter = D3DX_FILTER_TRIANGLE | D3DX_FILTER_DITHER; - - IDirect3DSurface9_GetDesc(dst_surface, &surfdesc); + srcformatdesc = get_format_info(src_format); + if (srcformatdesc->type == FORMAT_UNKNOWN) + { + FIXME("Unsupported format %#x.\n", src_format); + return E_NOTIMPL; + }
src_size.width = src_rect->right - src_rect->left; src_size.height = src_rect->bottom - src_rect->top; src_size.depth = 1; + + IDirect3DSurface9_GetDesc(dst_surface, &surfdesc); if (!dst_rect) { dst_size.width = surfdesc.Width; @@ -1899,14 +1903,10 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, return D3D_OK; } dst_size.depth = 1; - - srcformatdesc = get_format_info(src_format); destformatdesc = get_format_info(surfdesc.Format); - if (srcformatdesc->type == FORMAT_UNKNOWN) - { - FIXME("Unsupported format %#x.\n", src_format); - return E_NOTIMPL; - } + + if (filter == D3DX_DEFAULT) + filter = D3DX_FILTER_TRIANGLE | D3DX_FILTER_DITHER;
if (FAILED(hr = lock_surface(dst_surface, dst_rect, &lockrect, &surface, TRUE))) return hr; @@ -1914,16 +1914,10 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, if (src_format == surfdesc.Format && dst_size.width == src_size.width && dst_size.height == src_size.height - && color_key == 0) /* Simple copy. */ + && color_key == 0 + && !(src_rect->left & (srcformatdesc->block_width - 1)) + && !(src_rect->top & (srcformatdesc->block_height - 1))) /* Simple copy. */ { - if (src_rect->left & (srcformatdesc->block_width - 1) - || src_rect->top & (srcformatdesc->block_height - 1)) - { - WARN("Source rect %s is misaligned.\n", wine_dbgstr_rect(src_rect)); - unlock_surface(dst_surface, dst_rect, surface, FALSE); - return D3DXERR_INVALIDDATA; - } - copy_pixels(src_memory, src_pitch, 0, lockrect.pBits, lockrect.Pitch, 0, &src_size, srcformatdesc); } diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index 04ce57fa4f5..ba441879597 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -1351,7 +1351,7 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
hr = D3DXLoadSurfaceFromMemory(newsurf, NULL, &rect, &dds_dxt5_8_8[128], D3DFMT_DXT5, 16 * 2, NULL, &rect, D3DX_FILTER_POINT, 0); - todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
check_release((IUnknown *)newsurf, 1); check_release((IUnknown *)tex, 0); diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c index fc1589d25e3..49aed94a174 100644 --- a/dlls/d3dx9_36/tests/texture.c +++ b/dlls/d3dx9_36/tests/texture.c @@ -1804,28 +1804,26 @@ static void test_D3DXCreateTextureFromFileInMemory(IDirect3DDevice9 *device)
hr = D3DXLoadSurfaceFromMemory(surface, NULL, &rect, &dds_dxt5_8_8[128], D3DFMT_DXT5, 16 * 2, NULL, &rect, D3DX_FILTER_POINT, 0); - todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - if (SUCCEEDED(hr)) - { - hr = D3DXLoadSurfaceFromSurface(uncompressed_surface, NULL, NULL, surface, NULL, NULL, D3DX_FILTER_NONE, 0); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = D3DXLoadSurfaceFromSurface(uncompressed_surface, NULL, NULL, surface, NULL, NULL, D3DX_FILTER_NONE, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- hr = IDirect3DSurface9_LockRect(uncompressed_surface, &lock_rect, NULL, D3DLOCK_READONLY); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - for (y = 0; y < 8; ++y) + hr = IDirect3DSurface9_LockRect(uncompressed_surface, &lock_rect, NULL, D3DLOCK_READONLY); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + for (y = 0; y < 8; ++y) + { + for (x = 0; x < 8; ++x) { - for (x = 0; x < 8; ++x) - { - ok(compare_color(((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x], - dds_dxt5_8_8_expected_misaligned_3[y * 8 + x], 0), - "Color at position %u, %u is 0x%08x, expected 0x%08x.\n", - x, y, ((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x], - dds_dxt5_8_8_expected_misaligned_3[y * 8 + x]); - } + todo_wine_if (x >= 2 && x < 6 && y >= 2 && y < 6) + ok(compare_color(((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x], + dds_dxt5_8_8_expected_misaligned_3[y * 8 + x], 0), + "Color at position %u, %u is 0x%08x, expected 0x%08x.\n", + x, y, ((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x], + dds_dxt5_8_8_expected_misaligned_3[y * 8 + x]); } - hr = IDirect3DSurface9_UnlockRect(uncompressed_surface); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); } + hr = IDirect3DSurface9_UnlockRect(uncompressed_surface); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
IDirect3DSurface9_Release(uncompressed_surface); IDirect3DSurface9_Release(surface);
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=41936 Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- It turns out I had this patch in my queue, which is very similar to the one sent by Paul recently.
dlls/d3dx9_36/surface.c | 3 +++ dlls/d3dx9_36/tests/surface.c | 11 +++++++++++ 2 files changed, 14 insertions(+)
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index e85805df8ec..5cc9b39acfe 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -1911,6 +1911,9 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, if (FAILED(hr = lock_surface(dst_surface, dst_rect, &lockrect, &surface, TRUE))) return hr;
+ src_memory = (BYTE *)src_memory + src_rect->top / srcformatdesc->block_height * src_pitch + + src_rect->left / srcformatdesc->block_width * srcformatdesc->block_byte_count; + if (src_format == surfdesc.Format && dst_size.width == src_size.width && dst_size.height == src_size.height diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index ba441879597..1a39d82961d 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -942,8 +942,19 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
check_release((IUnknown*)surf, 0);
+ SetRect(&rect, 1, 1, 2, 2); + hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 1, 1, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &surf, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a8b8g8r8, + D3DFMT_A8R8G8B8, 8, NULL, &rect, D3DX_FILTER_NONE, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY); + check_pixel_4bpp(&lockrect, 0, 0, 0x8dc32bf6); + IDirect3DSurface9_UnlockRect(surf); + check_release((IUnknown *)surf, 0);
/* test color conversion */ + SetRect(&rect, 0, 0, 2, 2); /* A8R8G8B8 */ hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 2, 2, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &surf, NULL); if(FAILED(hr)) skip("Failed to create a surface (%#x)\n", hr);
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dx9_36/surface.c | 116 +++++++++++++++++++++------------- dlls/d3dx9_36/tests/texture.c | 11 ++-- 2 files changed, 77 insertions(+), 50 deletions(-)
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index 5cc9b39acfe..5665bdc3b46 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -1848,7 +1848,8 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, DWORD filter, D3DCOLOR color_key) { const struct pixel_format_desc *srcformatdesc, *destformatdesc; - struct volume src_size, dst_size; + struct volume src_size, dst_size, dst_size_aligned; + RECT dst_rect_temp, dst_rect_aligned; IDirect3DSurface9 *surface; D3DSURFACE_DESC surfdesc; D3DLOCKED_RECT lockrect; @@ -1883,10 +1884,14 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, src_size.depth = 1;
IDirect3DSurface9_GetDesc(dst_surface, &surfdesc); + destformatdesc = get_format_info(surfdesc.Format); if (!dst_rect) { - dst_size.width = surfdesc.Width; - dst_size.height = surfdesc.Height; + dst_rect = &dst_rect_temp; + dst_rect_temp.left = 0; + dst_rect_temp.top = 0; + dst_rect_temp.right = surfdesc.Width; + dst_rect_temp.bottom = surfdesc.Height; } else { @@ -1897,18 +1902,36 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, WARN("Invalid dst_rect specified.\n"); return D3DERR_INVALIDCALL; } - dst_size.width = dst_rect->right - dst_rect->left; - dst_size.height = dst_rect->bottom - dst_rect->top; - if (!dst_size.width || !dst_size.height) + if (dst_rect->left == dst_rect->right || dst_rect->top == dst_rect->bottom) + { + WARN("Empty dst_rect specified.\n"); return D3D_OK; + } } + + dst_rect_aligned = *dst_rect; + if (dst_rect_aligned.left & (destformatdesc->block_width - 1)) + dst_rect_aligned.left = dst_rect_aligned.left & ~(destformatdesc->block_width - 1); + if (dst_rect_aligned.top & (destformatdesc->block_height - 1)) + dst_rect_aligned.top = dst_rect_aligned.top & ~(destformatdesc->block_height - 1); + if (dst_rect_aligned.right & (destformatdesc->block_width - 1) && dst_rect_aligned.right != surfdesc.Width) + dst_rect_aligned.right = min((dst_rect_aligned.right + destformatdesc->block_width - 1) + & ~(destformatdesc->block_width - 1), surfdesc.Width); + if (dst_rect_aligned.bottom & (destformatdesc->block_height - 1) && dst_rect_aligned.bottom != surfdesc.Height) + dst_rect_aligned.bottom = min((dst_rect_aligned.bottom + destformatdesc->block_height - 1) + & ~(destformatdesc->block_height - 1), surfdesc.Height); + + dst_size.width = dst_rect->right - dst_rect->left; + dst_size.height = dst_rect->bottom - dst_rect->top; dst_size.depth = 1; - destformatdesc = get_format_info(surfdesc.Format); + dst_size_aligned.width = dst_rect_aligned.right - dst_rect_aligned.left; + dst_size_aligned.height = dst_rect_aligned.bottom - dst_rect_aligned.top; + dst_size_aligned.depth = 1;
if (filter == D3DX_DEFAULT) filter = D3DX_FILTER_TRIANGLE | D3DX_FILTER_DITHER;
- if (FAILED(hr = lock_surface(dst_surface, dst_rect, &lockrect, &surface, TRUE))) + if (FAILED(hr = lock_surface(dst_surface, &dst_rect_aligned, &lockrect, &surface, TRUE))) return hr;
src_memory = (BYTE *)src_memory + src_rect->top / srcformatdesc->block_height * src_pitch @@ -1919,8 +1942,11 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, && dst_size.height == src_size.height && color_key == 0 && !(src_rect->left & (srcformatdesc->block_width - 1)) - && !(src_rect->top & (srcformatdesc->block_height - 1))) /* Simple copy. */ + && !(src_rect->top & (srcformatdesc->block_height - 1)) + && !(dst_rect->left & (destformatdesc->block_width - 1)) + && !(dst_rect->top & (destformatdesc->block_height - 1))) { + TRACE("Simple copy.\n"); copy_pixels(src_memory, src_pitch, 0, lockrect.pBits, lockrect.Pitch, 0, &src_size, srcformatdesc); } @@ -1928,6 +1954,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, { const struct pixel_format_desc *dst_format; DWORD *src_uncompressed = NULL; + BYTE *dst_uncompressed = NULL; unsigned int dst_pitch; BYTE *dst_mem;
@@ -1935,7 +1962,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, || !is_conversion_to_supported(destformatdesc)) { FIXME("Unsupported format conversion %#x -> %#x.\n", src_format, surfdesc.Format); - unlock_surface(dst_surface, dst_rect, surface, FALSE); + unlock_surface(dst_surface, &dst_rect_aligned, surface, FALSE); return E_NOTIMPL; }
@@ -1948,7 +1975,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, src_uncompressed = heap_alloc(src_size.width * src_size.height * sizeof(DWORD)); if (!src_uncompressed) { - unlock_surface(dst_surface, dst_rect, surface, FALSE); + unlock_surface(dst_surface, &dst_rect_aligned, surface, FALSE); return E_OUTOFMEMORY; }
@@ -1988,15 +2015,23 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
if (destformatdesc->type == FORMAT_DXT) { - dst_mem = heap_alloc(dst_size.width * dst_size.height * sizeof(DWORD)); - if (!dst_mem) + BOOL dst_misaligned = dst_rect->left != dst_rect_aligned.left + || dst_rect->top != dst_rect_aligned.top + || dst_rect->right != dst_rect_aligned.right + || dst_rect->bottom != dst_rect_aligned.bottom; + + dst_uncompressed = HeapAlloc(GetProcessHeap(), dst_misaligned ? HEAP_ZERO_MEMORY : 0, + dst_size_aligned.width * dst_size_aligned.height * sizeof(DWORD)); + if (!dst_uncompressed) { heap_free(src_uncompressed); - unlock_surface(dst_surface, dst_rect, surface, FALSE); + unlock_surface(dst_surface, &dst_rect_aligned, surface, FALSE); return E_OUTOFMEMORY; } - dst_pitch = dst_size.width * sizeof(DWORD); + dst_pitch = dst_size_aligned.width * sizeof(DWORD); dst_format = get_format_info(D3DFMT_A8B8G8R8); + dst_mem = dst_uncompressed + (dst_rect->top - dst_rect_aligned.top) * dst_pitch + + (dst_rect->left - dst_rect_aligned.left) * sizeof(DWORD); } else { @@ -2023,41 +2058,34 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
heap_free(src_uncompressed);
- if (destformatdesc->type == FORMAT_DXT) + if (dst_uncompressed) { - if (dst_rect && (dst_rect->left || dst_rect->top)) - { - FIXME("Not implemented for destination rect left / top != 0.\n"); - } - else - { - GLenum gl_format = 0; + GLenum gl_format = 0;
- TRACE("Compressing DXTn surface.\n"); - switch(surfdesc.Format) - { - case D3DFMT_DXT1: - gl_format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; - break; - case D3DFMT_DXT2: - case D3DFMT_DXT3: - gl_format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - break; - case D3DFMT_DXT4: - case D3DFMT_DXT5: - gl_format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - break; - default: - ERR("Unexpected destination compressed format %u.\n", surfdesc.Format); - } - tx_compress_dxtn(4, dst_size.width, dst_size.height, - dst_mem, gl_format, lockrect.pBits, lockrect.Pitch); + TRACE("Compressing DXTn surface.\n"); + switch(surfdesc.Format) + { + case D3DFMT_DXT1: + gl_format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + break; + case D3DFMT_DXT2: + case D3DFMT_DXT3: + gl_format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + break; + case D3DFMT_DXT4: + case D3DFMT_DXT5: + gl_format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + break; + default: + ERR("Unexpected destination compressed format %u.\n", surfdesc.Format); } - heap_free(dst_mem); + tx_compress_dxtn(4, dst_size_aligned.width, dst_size_aligned.height, + dst_uncompressed, gl_format, lockrect.pBits, lockrect.Pitch); + heap_free(dst_uncompressed); } }
- return unlock_surface(dst_surface, dst_rect, surface, TRUE); + return unlock_surface(dst_surface, &dst_rect_aligned, surface, TRUE); }
/************************************************************ diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c index 49aed94a174..6d39bf72b92 100644 --- a/dlls/d3dx9_36/tests/texture.c +++ b/dlls/d3dx9_36/tests/texture.c @@ -1814,12 +1814,11 @@ static void test_D3DXCreateTextureFromFileInMemory(IDirect3DDevice9 *device) { for (x = 0; x < 8; ++x) { - todo_wine_if (x >= 2 && x < 6 && y >= 2 && y < 6) - ok(compare_color(((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x], - dds_dxt5_8_8_expected_misaligned_3[y * 8 + x], 0), - "Color at position %u, %u is 0x%08x, expected 0x%08x.\n", - x, y, ((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x], - dds_dxt5_8_8_expected_misaligned_3[y * 8 + x]); + ok(compare_color(((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x], + dds_dxt5_8_8_expected_misaligned_3[y * 8 + x], 0), + "Color at position %u, %u is 0x%08x, expected 0x%08x.\n", + x, y, ((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x], + dds_dxt5_8_8_expected_misaligned_3[y * 8 + x]); } } hr = IDirect3DSurface9_UnlockRect(uncompressed_surface);
We aren't necessarily rewriting the whole surface (e.g. rect smaller than the whole surface, color key).
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dx9_36/surface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index 5665bdc3b46..bd2055d54d1 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -209,7 +209,7 @@ HRESULT lock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, D3DLO DWORD lock_flag; HRESULT hr;
- lock_flag = write ? D3DLOCK_DISCARD : D3DLOCK_READONLY; + lock_flag = write ? 0 : D3DLOCK_READONLY; *temp_surface = NULL; if (FAILED(hr = IDirect3DSurface9_LockRect(surface, lock, surface_rect, lock_flag))) {
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dx9_36/surface.c | 2 +- dlls/d3dx9_36/tests/texture.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index bd2055d54d1..b47509aa38a 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -1168,7 +1168,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface, wicrect.Height = imginfo.Height; }
- SetRect(&rect, 0, 0, wicrect.Width, wicrect.Height); + SetRect(&rect, wicrect.X, wicrect.Y, wicrect.X + wicrect.Width, wicrect.Y + wicrect.Height);
if (imginfo.ImageFileFormat == D3DXIFF_DDS) { diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c index 6d39bf72b92..229c857ac2e 100644 --- a/dlls/d3dx9_36/tests/texture.c +++ b/dlls/d3dx9_36/tests/texture.c @@ -1824,6 +1824,28 @@ static void test_D3DXCreateTextureFromFileInMemory(IDirect3DDevice9 *device) hr = IDirect3DSurface9_UnlockRect(uncompressed_surface); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = D3DXLoadSurfaceFromFileInMemory(surface, NULL, &rect, dds_dxt5_8_8, + sizeof(dds_dxt5_8_8), &rect, D3DX_FILTER_POINT, 0, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = D3DXLoadSurfaceFromSurface(uncompressed_surface, NULL, NULL, surface, NULL, NULL, D3DX_FILTER_NONE, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DSurface9_LockRect(uncompressed_surface, &lock_rect, NULL, D3DLOCK_READONLY); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + for (y = 0; y < 8; ++y) + { + for (x = 0; x < 8; ++x) + { + ok(compare_color(((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x], + dds_dxt5_8_8_expected_misaligned_3[y * 8 + x], 0), + "Color at position %u, %u is 0x%08x, expected 0x%08x.\n", + x, y, ((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x], + dds_dxt5_8_8_expected_misaligned_3[y * 8 + x]); + } + } + hr = IDirect3DSurface9_UnlockRect(uncompressed_surface); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + IDirect3DSurface9_Release(uncompressed_surface); IDirect3DSurface9_Release(surface); IDirect3DTexture9_Release(texture);