Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[directxmesh, directxtex, directxtk(12), uvatlas] Updated for October 2024 releases #41878

Merged
merged 15 commits into from
Nov 4, 2024
8 changes: 4 additions & 4 deletions ports/directxmesh/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
set(DIRECTXMESH_TAG sep2024)
set(DIRECTXMESH_TAG oct2024)

vcpkg_check_linkage(ONLY_STATIC_LIBRARY)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO Microsoft/DirectXMesh
REF ${DIRECTXMESH_TAG}
SHA512 ea0f39c14613e60e967eaea2735f73730a1c79f9fdd9b3d799b6c765843804dd7c002dedac8f566989bac99dc41dfa9b1a9a14e141a0917f888d3e3c6ecf47cb
SHA512 a7d6eca75315a8f24fdc7753fd0e0b26b1b170ef0ffa1954065164f5da567ba09d1605c45cae91cf73dccc04f52162c3ad62f6a83eddf33c076e6ffb4723276d
HEAD_REF main
)

Expand Down Expand Up @@ -41,7 +41,7 @@ if("tools" IN_LIST FEATURES)
MESHCONVERT_EXE
URLS "https://github.com/Microsoft/DirectXMesh/releases/download/${DIRECTXMESH_TAG}/meshconvert.exe"
FILENAME "meshconvert-${DIRECTXMESH_TAG}.exe"
SHA512 f7cfd5d89d92bfe9e6b58691444b9b49e42b88b721f52abe40af4a090f3ff45476727116131fae2d4bbb74e81ff7d998ccbdb01bb037391d743e44823c490786
SHA512 6b437004ee3b8a44d475db51f01558d777bf3c65b1ea132606b9b682ab6310dbdf0c939ecdf7b621255b6130a424de6db368dd73b8d22393bd932342fd3f45e0
)

file(INSTALL
Expand All @@ -56,7 +56,7 @@ if("tools" IN_LIST FEATURES)
MESHCONVERT_EXE
URLS "https://github.com/Microsoft/DirectXMesh/releases/download/${DIRECTXMESH_TAG}/meshconvert_arm64.exe"
FILENAME "meshconvert-${DIRECTXMESH_TAG}-arm64.exe"
SHA512 71d677b95fa964dc3a6d3e3804fa86fb86ec0a5165045baeb42fa4e025c68806edf4cb737906f1f4287e877d5443eda9e5c38e51a9aa62c76ba84f68ba48c69e
SHA512 e4f9eb983ea6cfbf18c342d5f1a52210d933ca6bbe7fe5dbca4fee516106f02ac4936804ab222c337ac42eb809c16f06132d51ffa44fb67315c2f28f282afdf3
)

file(INSTALL
Expand Down
2 changes: 1 addition & 1 deletion ports/directxmesh/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "directxmesh",
"version-date": "2024-09-04",
"version-date": "2024-10-28",
"description": "DirectXMesh geometry processing library",
"homepage": "https://github.com/Microsoft/DirectXMesh",
"documentation": "https://github.com/microsoft/DirectXMesh/wiki",
Expand Down
19 changes: 19 additions & 0 deletions ports/directxtex/Fix-for-CMake-on-WSL.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ec26d0b..e26b5a1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -311,7 +311,11 @@ endif()

if(MINGW OR (NOT WIN32))
find_package(directxmath CONFIG REQUIRED)
+ target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::DirectXMath)
+
find_package(directx-headers CONFIG REQUIRED)
+ target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::DirectX-Headers)
+ target_compile_definitions(${PROJECT_NAME} PUBLIC USING_DIRECTX_HEADERS)
else()
find_package(directxmath CONFIG QUIET)
find_package(directx-headers CONFIG QUIET)
--
2.47.0.windows.1

300 changes: 300 additions & 0 deletions ports/directxtex/Support-using-C-17-std-byte.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,300 @@
diff --git a/Auxiliary/DirectXTexXbox.h b/Auxiliary/DirectXTexXbox.h
index 0829c8f..9f75866 100644
--- a/Auxiliary/DirectXTexXbox.h
+++ b/Auxiliary/DirectXTexXbox.h
@@ -132,6 +132,39 @@ namespace Xbox
HRESULT __cdecl SaveToDDSMemory(_In_ const XboxImage& xbox, _Out_ DirectX::Blob& blob);
HRESULT __cdecl SaveToDDSFile(_In_ const XboxImage& xbox, _In_z_ const wchar_t* szFile);

+#ifdef __cpp_lib_byte
+ inline HRESULT __cdecl GetMetadataFromDDSMemory(
+ _In_reads_bytes_(size) const std::byte* pSource, _In_ size_t size,
+ _Out_ DirectX::TexMetadata& metadata, _Out_ bool& isXbox)
+ {
+ return GetMetadataFromDDSMemory(reinterpret_cast<const uint8_t*>(pSource), size, metadata, isXbox);
+ }
+
+ inline HRESULT __cdecl GetMetadataFromDDSMemoryEx(
+ _In_reads_bytes_(size) const std::byte* pSource, _In_ size_t size,
+ _Out_ DirectX::TexMetadata& metadata, _Out_ bool& isXbox,
+ _Out_opt_ DirectX::DDSMetaData* ddPixelFormat)
+ {
+ return GetMetadataFromDDSMemoryEx(reinterpret_cast<const uint8_t*>(pSource), size, metadata, isXbox, ddPixelFormat);
+ }
+
+ inline HRESULT __cdecl LoadFromDDSMemory(
+ _In_reads_bytes_(size) const std::byte* pSource, _In_ size_t size,
+ _Out_opt_ DirectX::TexMetadata* metadata, _Out_ XboxImage& image)
+ {
+ return LoadFromDDSMemory(reinterpret_cast<const uint8_t*>(pSource), size, metadata, image);
+ }
+
+ inline HRESULT __cdecl LoadFromDDSMemoryEx(
+ _In_reads_bytes_(size) const std::byte* pSource, _In_ size_t size,
+ _Out_opt_ DirectX::TexMetadata* metadata,
+ _Out_opt_ DirectX::DDSMetaData* ddPixelFormat,
+ _Out_ XboxImage& image)
+ {
+ return LoadFromDDSMemoryEx(reinterpret_cast<const uint8_t*>(pSource), size, metadata, ddPixelFormat, image);
+ }
+#endif // __cpp_lib_byte
+
//---------------------------------------------------------------------------------
// Xbox Texture Tiling / Detiling (requires XG DLL to be present at runtime)

@@ -178,4 +211,20 @@ namespace Xbox
const XboxImage& xbox,
_Out_writes_bytes_(maxsize) uint8_t* pDestination, _In_ size_t maxsize) noexcept;

+#ifdef __cpp_lib_byte
+ inline HRESULT __cdecl EncodeDDSHeader(
+ const XboxImage& xbox,
+ _Out_writes_bytes_(maxsize) std::byte* pDestination, _In_ size_t maxsize) noexcept
+ {
+ return EncodeDDSHeader(xbox, reinterpret_cast<uint8_t*>(pDestination), maxsize);
+ }
+
+ inline HRESULT __cdecl EncodeDDSHeader(
+ const XboxImage& xbox,
+ _Reserved_ std::nullptr_t, _In_ size_t maxsize) noexcept
+ {
+ return EncodeDDSHeader(xbox, static_cast<uint8_t*>(nullptr), maxsize);
+ }
+#endif
+
} // namespace
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cffe5ca..ec26d0b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -319,13 +319,13 @@ endif()

if(directxmath_FOUND)
message(STATUS "Using DirectXMath package")
- target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::DirectXMath)
+ target_link_libraries(${PROJECT_NAME} PRIVATE Microsoft::DirectXMath)
endif()

if(directx-headers_FOUND)
message(STATUS "Using DirectX-Headers package")
- target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::DirectX-Headers)
- target_compile_definitions(${PROJECT_NAME} PUBLIC USING_DIRECTX_HEADERS)
+ target_link_libraries(${PROJECT_NAME} PRIVATE Microsoft::DirectX-Headers)
+ target_compile_definitions(${PROJECT_NAME} PRIVATE USING_DIRECTX_HEADERS)
target_compile_options(${PROJECT_NAME} PRIVATE $<$<CXX_COMPILER_ID:MSVC,Intel>:/wd4062> $<$<CXX_COMPILER_ID:Clang,IntelLLVM>:-Wno-switch-enum>)
walbourn marked this conversation as resolved.
Show resolved Hide resolved
endif()

diff --git a/DirectXTex/DirectXTex.h b/DirectXTex/DirectXTex.h
index e24142c..4dc36c8 100644
--- a/DirectXTex/DirectXTex.h
+++ b/DirectXTex/DirectXTex.h
@@ -382,6 +382,34 @@ namespace DirectX
_In_z_ const wchar_t* szFile,
_Out_ TexMetadata& metadata) noexcept;

+#ifdef __cpp_lib_byte
+ HRESULT __cdecl GetMetadataFromDDSMemory(
+ _In_reads_bytes_(size) const std::byte* pSource, _In_ size_t size,
+ _In_ DDS_FLAGS flags,
+ _Out_ TexMetadata& metadata) noexcept;
+ HRESULT __cdecl GetMetadataFromDDSMemoryEx(
+ _In_reads_bytes_(size) const std::byte* pSource, _In_ size_t size,
+ _In_ DDS_FLAGS flags,
+ _Out_ TexMetadata& metadata,
+ _Out_opt_ DDSMetaData* ddPixelFormat) noexcept;
+ HRESULT __cdecl GetMetadataFromHDRMemory(
+ _In_reads_bytes_(size) const std::byte* pSource, _In_ size_t size,
+ _Out_ TexMetadata& metadata) noexcept;
+ HRESULT __cdecl GetMetadataFromTGAMemory(
+ _In_reads_bytes_(size) const std::byte* pSource, _In_ size_t size,
+ _In_ TGA_FLAGS flags,
+ _Out_ TexMetadata& metadata) noexcept;
+
+#ifdef _WIN32
+ HRESULT __cdecl GetMetadataFromWICMemory(
+ _In_reads_bytes_(size) const std::byte* pSource, _In_ size_t size,
+ _In_ WIC_FLAGS flags,
+ _Out_ TexMetadata& metadata,
+ _In_ std::function<void __cdecl(IWICMetadataQueryReader*)> getMQR = nullptr);
+#endif
+#endif // __cpp_lib_byte
+
+
//---------------------------------------------------------------------------------
// Bitmap image container
struct Image
@@ -590,6 +618,34 @@ namespace DirectX
HRESULT __cdecl SaveToTGAMemory(_In_ const Image& image, _Out_ Blob& blob, _In_opt_ const TexMetadata* metadata = nullptr) noexcept;
HRESULT __cdecl SaveToTGAFile(_In_ const Image& image, _In_z_ const wchar_t* szFile, _In_opt_ const TexMetadata* metadata = nullptr) noexcept;

+#ifdef __cpp_lib_byte
+ HRESULT __cdecl LoadFromDDSMemory(
+ _In_reads_bytes_(size) const std::byte* pSource, _In_ size_t size,
+ _In_ DDS_FLAGS flags,
+ _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept;
+ HRESULT __cdecl LoadFromDDSMemoryEx(
+ _In_reads_bytes_(size) const std::byte* pSource, _In_ size_t size,
+ _In_ DDS_FLAGS flags,
+ _Out_opt_ TexMetadata* metadata,
+ _Out_opt_ DDSMetaData* ddPixelFormat,
+ _Out_ ScratchImage& image) noexcept;
+ HRESULT __cdecl LoadFromHDRMemory(
+ _In_reads_bytes_(size) const std::byte* pSource, _In_ size_t size,
+ _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept;
+ HRESULT __cdecl LoadFromTGAMemory(
+ _In_reads_bytes_(size) const std::byte* pSource, _In_ size_t size,
+ _In_ TGA_FLAGS flags,
+ _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept;
+
+#ifdef _WIN32
+ HRESULT __cdecl LoadFromWICMemory(
+ _In_reads_bytes_(size) const std::byte* pSource, _In_ size_t size,
+ _In_ WIC_FLAGS flags,
+ _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image,
+ _In_ std::function<void __cdecl(IWICMetadataQueryReader*)> getMQR = nullptr);
+#endif
+#endif // __cpp_lib_byte
+
//---------------------------------------------------------------------------------
// Texture conversion, resizing, mipmap generation, and block compression

@@ -959,6 +1015,18 @@ namespace DirectX
_Out_writes_bytes_to_opt_(maxsize, required) uint8_t* pDestination, _In_ size_t maxsize,
_Out_ size_t& required) noexcept;

+#ifdef __cpp_lib_byte
+ HRESULT __cdecl EncodeDDSHeader(
+ _In_ const TexMetadata& metadata, DDS_FLAGS flags,
+ _Out_writes_bytes_to_opt_(maxsize, required) std::byte* pDestination, _In_ size_t maxsize,
+ _Out_ size_t& required) noexcept;
+
+ HRESULT __cdecl EncodeDDSHeader(
+ _In_ const TexMetadata& metadata, DDS_FLAGS flags,
+ _Reserved_ std::nullptr_t, _In_ size_t maxsize,
+ _Out_ size_t& required) noexcept;
+#endif
+
//---------------------------------------------------------------------------------
// Direct3D interop

diff --git a/DirectXTex/DirectXTex.inl b/DirectXTex/DirectXTex.inl
index 49745ae..d20f41e 100644
--- a/DirectXTex/DirectXTex.inl
+++ b/DirectXTex/DirectXTex.inl
@@ -190,3 +190,85 @@ inline HRESULT __cdecl SaveToTGAFile(const Image& image, const wchar_t* szFile,
{
return SaveToTGAFile(image, TGA_FLAGS_NONE, szFile, metadata);
}
+
+
+//=====================================================================================
+// C++17 helpers
+//=====================================================================================
+#ifdef __cpp_lib_byte
+
+_Use_decl_annotations_
+inline HRESULT __cdecl GetMetadataFromDDSMemory(const std::byte* pSource, size_t size, DDS_FLAGS flags, TexMetadata& metadata) noexcept
+{
+ return GetMetadataFromDDSMemory(reinterpret_cast<const uint8_t*>(pSource), size, flags, metadata);
+}
+
+_Use_decl_annotations_
+inline HRESULT __cdecl LoadFromDDSMemory(const std::byte* pSource, size_t size, DDS_FLAGS flags, TexMetadata* metadata, ScratchImage& image) noexcept
+{
+ return LoadFromDDSMemory(reinterpret_cast<const uint8_t*>(pSource), size, flags, metadata, image);
+}
+
+_Use_decl_annotations_
+inline HRESULT __cdecl GetMetadataFromDDSMemoryEx(const std::byte* pSource, size_t size, DDS_FLAGS flags, TexMetadata& metadata, DDSMetaData* ddPixelFormat) noexcept
+{
+ return GetMetadataFromDDSMemoryEx(reinterpret_cast<const uint8_t*>(pSource), size, flags, metadata, ddPixelFormat);
+}
+
+_Use_decl_annotations_
+inline HRESULT __cdecl LoadFromDDSMemoryEx(const std::byte* pSource, size_t size, DDS_FLAGS flags, TexMetadata* metadata, DDSMetaData* ddPixelFormat, ScratchImage& image) noexcept
+{
+ return LoadFromDDSMemoryEx(reinterpret_cast<const uint8_t*>(pSource), size, flags, metadata, ddPixelFormat, image);
+}
+
+_Use_decl_annotations_
+inline HRESULT __cdecl GetMetadataFromHDRMemory(const std::byte* pSource, size_t size, TexMetadata& metadata) noexcept
+{
+ return GetMetadataFromHDRMemory(reinterpret_cast<const uint8_t*>(pSource), size, metadata);
+}
+
+_Use_decl_annotations_
+inline HRESULT __cdecl LoadFromHDRMemory(const std::byte* pSource, size_t size, TexMetadata* metadata, ScratchImage& image) noexcept
+{
+ return LoadFromHDRMemory(reinterpret_cast<const uint8_t*>(pSource), size, metadata, image);
+}
+
+_Use_decl_annotations_
+inline HRESULT __cdecl GetMetadataFromTGAMemory(const std::byte* pSource, size_t size, TGA_FLAGS flags, TexMetadata& metadata) noexcept
+{
+ return GetMetadataFromTGAMemory(reinterpret_cast<const uint8_t*>(pSource), size, flags, metadata);
+}
+
+_Use_decl_annotations_
+inline HRESULT __cdecl LoadFromTGAMemory(const std::byte* pSource, size_t size, TGA_FLAGS flags, TexMetadata* metadata, ScratchImage& image) noexcept
+{
+ return LoadFromTGAMemory(reinterpret_cast<const uint8_t*>(pSource), size, flags, metadata, image);
+}
+
+_Use_decl_annotations_
+inline HRESULT __cdecl EncodeDDSHeader(const TexMetadata& metadata, DDS_FLAGS flags, std::byte* pDestination, size_t maxsize, size_t& required) noexcept
+{
+ return EncodeDDSHeader(metadata, flags, reinterpret_cast<uint8_t*>(pDestination), maxsize, required);
+}
+
+_Use_decl_annotations_
+inline HRESULT __cdecl EncodeDDSHeader(const TexMetadata& metadata, DDS_FLAGS flags, std::nullptr_t, size_t maxsize, size_t& required) noexcept
+{
+ return EncodeDDSHeader(metadata, flags, static_cast<uint8_t*>(nullptr), maxsize, required);
+}
+
+#ifdef _WIN32
+_Use_decl_annotations_
+inline HRESULT __cdecl GetMetadataFromWICMemory(const std::byte* pSource, size_t size, WIC_FLAGS flags, TexMetadata& metadata, std::function<void __cdecl(IWICMetadataQueryReader*)> getMQR)
+{
+ return GetMetadataFromWICMemory(reinterpret_cast<const uint8_t*>(pSource), size, flags, metadata, getMQR);
+}
+
+_Use_decl_annotations_
+inline HRESULT __cdecl LoadFromWICMemory(const std::byte* pSource, size_t size, WIC_FLAGS flags, TexMetadata* metadata, ScratchImage& image, std::function<void __cdecl(IWICMetadataQueryReader*)> getMQR)
+{
+ return LoadFromWICMemory(reinterpret_cast<const uint8_t*>(pSource), size, flags, metadata, image, getMQR);
+}
+#endif // _WIN32
+
+#endif // __cpp_lib_byte
diff --git a/ScreenGrab/ScreenGrab12.cpp b/ScreenGrab/ScreenGrab12.cpp
index 7c19630..b8cd697 100644
--- a/ScreenGrab/ScreenGrab12.cpp
+++ b/ScreenGrab/ScreenGrab12.cpp
@@ -853,7 +853,11 @@ namespace

hr = commandList->Close();
if (FAILED(hr))
+ {
+ (*pStaging)->Release();
+ *pStaging = nullptr;
return hr;
+ }

// Execute the command list
pCommandQ->ExecuteCommandLists(1, CommandListCast(commandList.GetAddressOf()));
@@ -861,7 +865,11 @@ namespace
// Signal the fence
hr = pCommandQ->Signal(fence.Get(), 1);
if (FAILED(hr))
+ {
+ (*pStaging)->Release();
+ *pStaging = nullptr;
return hr;
+ }

// Block until the copy is complete
while (fence->GetCompletedValue() < 1)
--
2.47.0.windows.1

Loading