Skip to content

Commit

Permalink
Revert "feat: Adjust DirectTex for all platforms (#2314)" (#2337)
Browse files Browse the repository at this point in the history
This reverts commit f23ce73.
  • Loading branch information
Eideren authored Jun 19, 2024
1 parent a6c42cb commit 2556707
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 138 deletions.
3 changes: 0 additions & 3 deletions deps/TextureWrappers/Release/linux-x64/DxtWrapper.so

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "dxt_wrapper.h"

// Utilities functions
void dxtComputePitch( DXGI_FORMAT fmt, int width, int height, int& rowPitch, int& slicePitch, DirectX::CP_FLAGS flags = DirectX::CP_FLAGS_NONE )
void dxtComputePitch( DXGI_FORMAT fmt, int width, int height, int& rowPitch, int& slicePitch, int flags = DirectX::CP_FLAGS_NONE )
{
size_t rowPitchT, slicePitchT;
DirectX::ComputePitch(fmt, width, height, rowPitchT, slicePitchT, flags);
Expand All @@ -13,22 +13,22 @@ void dxtComputePitch( DXGI_FORMAT fmt, int width, int height, int& rowPitch, int

bool dxtIsCompressed(DXGI_FORMAT fmt) { return DirectX::IsCompressed(fmt); }

HRESULT dxtConvert( const DirectX::Image& srcImage, DXGI_FORMAT format, DirectX::TEX_FILTER_FLAGS filter, float threshold, DirectX::ScratchImage& cImage )
HRESULT dxtConvert( const DirectX::Image& srcImage, DXGI_FORMAT format, int filter, float threshold, DirectX::ScratchImage& cImage )
{
return DirectX::Convert(srcImage, format, filter, threshold, cImage);
}

HRESULT dxtConvertArray( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, DXGI_FORMAT format, DirectX::TEX_FILTER_FLAGS filter, float threshold, DirectX::ScratchImage& cImage )
HRESULT dxtConvertArray( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, DXGI_FORMAT format, int filter, float threshold, DirectX::ScratchImage& cImage )
{
return DirectX::Convert(srcImages, nimages, metadata, format, filter, threshold, cImage);
}

HRESULT dxtCompress( const DirectX::Image& srcImage, DXGI_FORMAT format, DirectX::TEX_COMPRESS_FLAGS compress, float alphaRef, DirectX::ScratchImage& cImage )
HRESULT dxtCompress( const DirectX::Image& srcImage, DXGI_FORMAT format, int compress, float alphaRef, DirectX::ScratchImage& cImage )
{
return DirectX::Compress(srcImage, format, compress, alphaRef, cImage);
}

HRESULT dxtCompressArray( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, DXGI_FORMAT format, DirectX::TEX_COMPRESS_FLAGS compress, float alphaRef, DirectX::ScratchImage& cImages )
HRESULT dxtCompressArray( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, DXGI_FORMAT format, int compress, float alphaRef, DirectX::ScratchImage& cImages )
{
return DirectX::Compress(srcImages, nimages, metadata, format, compress, alphaRef, cImages);
}
Expand All @@ -43,44 +43,44 @@ HRESULT dxtDecompressArray( const DirectX::Image* cImages, int nimages, const Di
return DirectX::Decompress(cImages, nimages, metadata, format, images);
}

HRESULT dxtGenerateMipMaps( const DirectX::Image& baseImage, DirectX::TEX_FILTER_FLAGS filter, int levels, DirectX::ScratchImage& mipChain, bool allow1D = false)
HRESULT dxtGenerateMipMaps( const DirectX::Image& baseImage, int filter, int levels, DirectX::ScratchImage& mipChain, bool allow1D = false)
{
return DirectX::GenerateMipMaps(baseImage, filter, levels, mipChain, allow1D);
}

HRESULT dxtGenerateMipMapsArray( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, DirectX::TEX_FILTER_FLAGS filter, int levels, DirectX::ScratchImage& mipChain )
HRESULT dxtGenerateMipMapsArray( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, int filter, int levels, DirectX::ScratchImage& mipChain )
{
return DirectX::GenerateMipMaps(srcImages, nimages, metadata, filter, levels, mipChain);
}

HRESULT dxtGenerateMipMaps3D( const DirectX::Image* baseImages, int depth, DirectX::TEX_FILTER_FLAGS filter, int levels, DirectX::ScratchImage& mipChain )
HRESULT dxtGenerateMipMaps3D( const DirectX::Image* baseImages, int depth, int filter, int levels, DirectX::ScratchImage& mipChain )
{
return DirectX::GenerateMipMaps3D(baseImages, depth, filter, levels, mipChain);
}

HRESULT dxtGenerateMipMaps3DArray( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, DirectX::TEX_FILTER_FLAGS filter, int levels, DirectX::ScratchImage& mipChain )
HRESULT dxtGenerateMipMaps3DArray( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, int filter, int levels, DirectX::ScratchImage& mipChain )
{
return DirectX::GenerateMipMaps3D(srcImages, nimages, metadata, filter, levels, mipChain);
}

HRESULT dxtResize(const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, int width, int height, DirectX::TEX_FILTER_FLAGS filter, DirectX::ScratchImage& result )
HRESULT dxtResize(const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, int width, int height, int filter, DirectX::ScratchImage& result )
{
return DirectX::Resize(srcImages, nimages, metadata, width, height, filter, result);
}

HRESULT dxtComputeNormalMap( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, DirectX::CNMAP_FLAGS flags, float amplitude, DXGI_FORMAT format, DirectX::ScratchImage& normalMaps )
HRESULT dxtComputeNormalMap( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, int flags, float amplitude, DXGI_FORMAT format, DirectX::ScratchImage& normalMaps )
{
return DirectX::ComputeNormalMap(srcImages, nimages, metadata, flags, amplitude, format, normalMaps);
}

HRESULT dxtPremultiplyAlpha( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, DirectX::TEX_PMALPHA_FLAGS flags, DirectX::ScratchImage& result )
HRESULT dxtPremultiplyAlpha( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, int flags, DirectX::ScratchImage& result )
{
return DirectX::PremultiplyAlpha(srcImages, nimages, metadata, flags, result);
}


// I/O functions
HRESULT dxtLoadDDSFile(LPCWSTR szFile, DirectX::DDS_FLAGS flags, DirectX::TexMetadata* metadata, DirectX::ScratchImage& image)
HRESULT dxtLoadDDSFile(LPCWSTR szFile, int flags, DirectX::TexMetadata* metadata, DirectX::ScratchImage& image)
{
return DirectX::LoadFromDDSFile(szFile, flags, metadata, image);
}
Expand All @@ -90,12 +90,17 @@ HRESULT dxtLoadTGAFile(LPCWSTR szFile, DirectX::TexMetadata* metadata, DirectX::
return DirectX::LoadFromTGAFile(szFile, metadata, image);
}

HRESULT dxtSaveToDDSFile( const DirectX::Image& image, DirectX::DDS_FLAGS flags, LPCWSTR szFile )
HRESULT dxtLoadWICFile(LPCWSTR szFile, int flags, DirectX::TexMetadata* metadata, DirectX::ScratchImage& image)
{
return DirectX::LoadFromWICFile(szFile, flags, metadata, image);
}

HRESULT dxtSaveToDDSFile( const DirectX::Image& image, int flags, LPCWSTR szFile )
{
return DirectX::SaveToDDSFile(image, flags, szFile);
}

HRESULT dxtSaveToDDSFileArray( const DirectX::Image* images, int nimages, const DirectX::TexMetadata& metadata, DirectX::DDS_FLAGS flags, LPCWSTR szFile )
HRESULT dxtSaveToDDSFileArray( const DirectX::Image* images, int nimages, const DirectX::TexMetadata& metadata, int flags, LPCWSTR szFile )
{
return DirectX::SaveToDDSFile(images, nimages, metadata, flags, szFile);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,35 @@
#ifndef DXT_WRAPPER_H
#define DXT_WRAPPER_H

#ifdef _MSC_VER
#define DXT_API __declspec(dllexport)
#else
#if __GNUC__ >= 4
#define DXT_API __attribute__ ((visibility("default")))
#else
#define DXT_API
#endif
#endif

#include "DirectXTex.h"

extern "C" {

// Utilities functions
DXT_API void dxtComputePitch( DXGI_FORMAT fmt, int width, int height, int& rowPitch, int& slicePitch, DirectX::CP_FLAGS flags );
DXT_API void dxtComputePitch( DXGI_FORMAT fmt, int width, int height, int& rowPitch, int& slicePitch, int flags );
DXT_API bool dxtIsCompressed(DXGI_FORMAT fmt);
DXT_API HRESULT dxtConvert( const DirectX::Image& srcImage, DXGI_FORMAT format, DirectX::TEX_FILTER_FLAGS filter, float threshold, DirectX::ScratchImage& cImage );
DXT_API HRESULT dxtConvertArray( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, DXGI_FORMAT format, DirectX::TEX_FILTER_FLAGS filter, float threshold, DirectX::ScratchImage& cImage );
DXT_API HRESULT dxtCompress( const DirectX::Image& srcImage, DXGI_FORMAT format, DirectX::TEX_COMPRESS_FLAGS compress, float alphaRef, DirectX::ScratchImage& cImage );
DXT_API HRESULT dxtCompressArray( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, DXGI_FORMAT format, DirectX::TEX_COMPRESS_FLAGS compress, float alphaRef, DirectX::ScratchImage& cImages );
DXT_API HRESULT dxtDecompress( const DirectX::Image& cImage, DXGI_FORMAT format, DirectX::ScratchImage& image );
DXT_API HRESULT dxtConvert( const DirectX::Image& srcImage, DXGI_FORMAT format, int filter, float threshold, DirectX::ScratchImage& cImage );
DXT_API HRESULT dxtConvertArray( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, DXGI_FORMAT format, int filter, float threshold, DirectX::ScratchImage& cImage );
DXT_API HRESULT dxtCompress( const DirectX::Image& srcImage, DXGI_FORMAT format, int compress, float alphaRef, DirectX::ScratchImage& cImage );
DXT_API HRESULT dxtCompressArray( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, DXGI_FORMAT format, int compress, float alphaRef, DirectX::ScratchImage& cImages );
DXT_API HRESULT dxtDecompress( const DirectX::Image& cImage, DXGI_FORMAT format, DirectX::ScratchImage& image );
DXT_API HRESULT dxtDecompressArray( const DirectX::Image* cImages, int nimages, const DirectX::TexMetadata& metadata, DXGI_FORMAT format, DirectX::ScratchImage& images );
DXT_API HRESULT dxtGenerateMipMaps( const DirectX::Image& baseImage, DirectX::TEX_FILTER_FLAGS filter, int levels, DirectX::ScratchImage& mipChain, bool allow1D);
DXT_API HRESULT dxtGenerateMipMapsArray( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, DirectX::TEX_FILTER_FLAGS filter, int levels, DirectX::ScratchImage& mipChain );
DXT_API HRESULT dxtGenerateMipMaps3D( const DirectX::Image* baseImages, int depth, DirectX::TEX_FILTER_FLAGS filter, int levels, DirectX::ScratchImage& mipChain );
DXT_API HRESULT dxtGenerateMipMaps3DArray( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, DirectX::TEX_FILTER_FLAGS filter, int levels, DirectX::ScratchImage& mipChain );
DXT_API HRESULT dxtResize(const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, int width, int height, DirectX::TEX_FILTER_FLAGS filter, DirectX::ScratchImage& result );
DXT_API HRESULT dxtComputeNormalMap( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, DirectX::CNMAP_FLAGS flags, float amplitude, DXGI_FORMAT format, DirectX::ScratchImage& normalMaps );
DXT_API HRESULT dxtPremultiplyAlpha( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, DirectX::TEX_PMALPHA_FLAGS flags, DirectX::ScratchImage& result );
DXT_API HRESULT dxtGenerateMipMaps( const DirectX::Image& baseImage, int filter, int levels, DirectX::ScratchImage& mipChain, bool allow1D);
DXT_API HRESULT dxtGenerateMipMapsArray( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, int filter, int levels, DirectX::ScratchImage& mipChain );
DXT_API HRESULT dxtGenerateMipMaps3D( const DirectX::Image* baseImages, int depth, int filter, int levels, DirectX::ScratchImage& mipChain );
DXT_API HRESULT dxtGenerateMipMaps3DArray( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, int filter, int levels, DirectX::ScratchImage& mipChain );
DXT_API HRESULT dxtResize(const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, int width, int height, int filter, DirectX::ScratchImage& result );
DXT_API HRESULT dxtComputeNormalMap( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, int flags, float amplitude, DXGI_FORMAT format, DirectX::ScratchImage& normalMaps );
DXT_API HRESULT dxtPremultiplyAlpha( const DirectX::Image* srcImages, int nimages, const DirectX::TexMetadata& metadata, int flags, DirectX::ScratchImage& result );

// I/O functions
DXT_API HRESULT dxtLoadTGAFile(LPCWSTR szFile, DirectX::TexMetadata* metadata, DirectX::ScratchImage& image);
DXT_API HRESULT dxtLoadDDSFile(LPCWSTR szFile, DirectX::DDS_FLAGS flags, DirectX::TexMetadata* metadata, DirectX::ScratchImage& image);
DXT_API HRESULT dxtSaveToDDSFile( const DirectX::Image& image, DirectX::DDS_FLAGS flags, LPCWSTR szFile );
DXT_API HRESULT dxtSaveToDDSFileArray( const DirectX::Image* images, int nimages, const DirectX::TexMetadata& metadata, DirectX::DDS_FLAGS flags, LPCWSTR szFile );
DXT_API HRESULT dxtLoadWICFile(LPCWSTR szFile, int wicflags, DirectX::TexMetadata* metadata, DirectX::ScratchImage& image);
DXT_API HRESULT dxtLoadDDSFile(LPCWSTR szFile, int ddsflags, DirectX::TexMetadata* metadata, DirectX::ScratchImage& image);
DXT_API HRESULT dxtSaveToDDSFile( const DirectX::Image& image, int flags, LPCWSTR szFile );
DXT_API HRESULT dxtSaveToDDSFileArray( const DirectX::Image* images, int nimages, const DirectX::TexMetadata& metadata, int flags, LPCWSTR szFile );

// Scratch Image
DXT_API DirectX::ScratchImage * dxtCreateScratchImage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,13 @@ internal class Utilities
private extern static void dxtComputePitch(DXGI_FORMAT fmt, int width, int height, out int rowPitch, out int slicePitch, CP_FLAGS flags);

[DllImport("DxtWrapper", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
private extern static uint dxtLoadDDSFile([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTC32StringMarshaller))] string filePath, DDS_FLAGS flags, out TexMetadata metadata, IntPtr image);
private extern static uint dxtLoadDDSFile(String filePath, DDS_FLAGS flags, out TexMetadata metadata, IntPtr image);

[DllImport("DxtWrapper", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
private extern static uint dxtLoadTGAFile([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTC32StringMarshaller))] string filePath, out TexMetadata metadata, IntPtr image);
private extern static uint dxtLoadTGAFile(String filePath, out TexMetadata metadata, IntPtr image);

[DllImport("DxtWrapper", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
private extern static uint dxtLoadWICFile(String filePath, WIC_FLAGS flags, out TexMetadata metadata, IntPtr image);

[DllImport("DxtWrapper", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
private extern static bool dxtIsCompressed(DXGI_FORMAT fmt);
Expand All @@ -543,10 +546,10 @@ internal class Utilities
private extern static uint dxtDecompressArray(DxtImage[] cImages, int nimages, ref TexMetadata metadata, DXGI_FORMAT format, IntPtr images);

[DllImport("DxtWrapper", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
private extern static uint dxtSaveToDDSFile(ref DxtImage dxtImage, DDS_FLAGS flags, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTC32StringMarshaller))] string szFile);
private extern static uint dxtSaveToDDSFile(ref DxtImage dxtImage, DDS_FLAGS flags, string szFile);

[DllImport("DxtWrapper", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
private extern static uint dxtSaveToDDSFileArray(DxtImage[] dxtImages, int nimages, ref TexMetadata metadata, DDS_FLAGS flags, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTC32StringMarshaller))] string szFile);
private extern static uint dxtSaveToDDSFileArray(DxtImage[] dxtImages, int nimages, ref TexMetadata metadata, DDS_FLAGS flags, string szFile);

[DllImport("DxtWrapper", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
private extern static uint dxtGenerateMipMaps(ref DxtImage baseImage, TEX_FILTER_FLAGS filter, int levels, IntPtr mipChain, bool allow1D);
Expand Down Expand Up @@ -574,16 +577,21 @@ public static void ComputePitch(DXGI_FORMAT fmt, int width, int height, out int
dxtComputePitch(fmt, width, height, out rowPitch, out slicePitch, flags);
}

public static HRESULT LoadDDSFile(string filePath, DDS_FLAGS flags, out TexMetadata metadata, ScratchImage image)
public static HRESULT LoadDDSFile(String filePath, DDS_FLAGS flags, out TexMetadata metadata, ScratchImage image)
{
return HandleHRESULT(dxtLoadDDSFile(filePath, flags, out metadata, image.ptr));
}

public static HRESULT LoadTGAFile(string filePath, out TexMetadata metadata, ScratchImage image)
public static HRESULT LoadTGAFile(String filePath, out TexMetadata metadata, ScratchImage image)
{
return HandleHRESULT(dxtLoadTGAFile(filePath, out metadata, image.ptr));
}

public static HRESULT LoadWICFile(String filePath, WIC_FLAGS flags, out TexMetadata metadata, ScratchImage image)
{
return HandleHRESULT(dxtLoadWICFile(filePath, flags, out metadata, image.ptr));
}

public static HRESULT SaveToDDSFile(ref DxtImage dxtImage, DDS_FLAGS flags, string szFile)
{
return HandleHRESULT(dxtSaveToDDSFile(ref dxtImage, flags, szFile));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<StrideNativeLib Include="$(MSBuildThisFileDirectory)..\..\..\deps\FreeImage\Release\**\*.dll">
<Link>runtimes\%(RecursiveDir)native\%(Filename)%(Extension)</Link>
</StrideNativeLib>
<StrideNativeLib Include="$(MSBuildThisFileDirectory)..\..\..\deps\TextureWrappers\Release\**\*.dll;$(MSBuildThisFileDirectory)..\..\..\deps\TextureWrappers\Release\**\*.so">
<StrideNativeLib Include="$(MSBuildThisFileDirectory)..\..\..\deps\TextureWrappers\Release\**\*.dll">
<Link>runtimes\%(RecursiveDir)native\%(Filename)%(Extension)</Link>
</StrideNativeLib>
<StrideNativeLib Include="$(MSBuildThisFileDirectory)..\..\..\deps\PVRTT\**\*.dll">
Expand Down
Loading

0 comments on commit 2556707

Please sign in to comment.