Repository navigation
Implement FlipRotate without WIC for non-Windows platforms - #746
Joel Kiptoo (Kiptoo-Deus) wants to merge 5 commits into
Conversation
FlipRotate was the only image operation that always needed WIC, so it was not available when building for Linux / WSL. On non-Windows platforms it now moves whole pixels directly, for any format with a whole number of bytes per pixel that is not compressed, packed, planar or palettized (others return HRESULT_E_NOT_SUPPORTED). Flips are applied to the source before the rotation, which is how WIC combines WICBitmapTransformOptions. The Windows code paths are unchanged. Fixes microsoft#350
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Got access to a Windows machine and tested the flip/rotate order against WIC. It matches. I compared the WIC output with the new non-WIC path byte for byte across a bunch of formats, every rotation/flip combination, and both overloads, with no differences. I also flipped the order in my reference to make sure the test would catch it, and that fails on the 90/270 + single flip cases as expected. So WIC does flip first, same as Wine. The library also builds cleanly on MSVC x64 with the new |
|
The arm64ec failures are a new 'known issue' thing. Don't worry about them. This is great, but to be consistent the non-WIC path should be available on Windows as well, which will make it easier to add it to the test coverage as well. You should code it to use your non-WIC version on (a) Linux where WIC is not available and (b) on Windows if you pass a flag telling it to use non-wic paths. Something like: |
|
Done, added I ran it on my Windows PC, comparing WIC against the forced non-WIC path across a handful of formats, every rotate/flip combo, with and without mips. Output was identical in every case. |
Fixes #350.
FlipRotatewas the only image operation that always used WIC, soDirectXTexFlipRotate.cppwas only built on Windows and the functions were declared under#ifdef _WIN32.This builds it on all platforms. On Windows nothing changes: the WIC path and the float16/float32 conversion path are the same code, now inside
#ifdef _WIN32. On other platforms, a newPerformFlipRotatemoves whole pixels directly:HRESULT_E_NOT_SUPPORTED, checked before the result is allocated.memcpywhen there's no horizontal flip and no 90/270 rotation.IWICBitmapFlipRotator(dlls/windowscodecs/fliprotate.c), where the flip is applied to the source before the rotation (e.g.TEX_FR_ROTATE90 | TEX_FR_FLIP_HORIZONTALis an anti-transpose). I couldn't check this against WIC itself, so it would be worth confirming on Windows. It only matters for a 90/270 rotation combined with exactly one flip.Testing on macOS (arm64, Apple clang), building
DirectXTexwith its own CMake against the vcpkgdirectx-headersanddirectxmathports:DirectXTexFlipRotate.cppincluded, with no new warnings.FlipRotateoverloads against a straightforward reference (flip the source, then rotate clockwise in 90 degree steps) for every rotation/flip combination, on a 7x5 image with 3 array slices, inR8_UNORM,R16_UNORM,R8G8B8A8_UNORM,R16G16B16A16_FLOAT,R32G32B32_FLOATandR32G32B32A32_UINT(1 to 16 bytes per pixel). It also checks thatBC1_UNORM,NV12,YUY2,R1_UNORM,P8andR8G8_B8G8_UNORMreturnHRESULT_E_NOT_SUPPORTED, and that null pixels returnE_POINTER. 187 checks pass.I haven't built the Windows configurations. The only change there is the added
#ifdef _WIN32guards around the existing code.