From d76bed6c1b03e5d7ef19c947fdd5fcaf33b595f7 Mon Sep 17 00:00:00 2001 From: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> Date: Tue, 14 May 2024 15:42:12 -0700 Subject: Implement texture functions for Metal target (#4158) * Impl texture APIs for Metal target This commit is to implement texture functions for Metal target. The following functions are implemented and tested. - GetDimensions() - CalculateLevelOfDetail() - CalculateLevelOfDetailUnclamped() - Sample() - SampleBias() - SampleLevel() - SampleCmp() - SampleCmpLevelZero() - Gather() - SampleGrad() - Load() Metal has limited support for the texture functions compared to HLSL. - LOD is not supported for 1D texture, - Depth textures are limited to 2D, 2DArray, Cube and CubeArray textures. - "Offset" variants are limited to 2D, 2DArray, 2D-Depth, 2DArray-Depth and 3D textures. The functions that cannot be implemented for Metal should properly be handled by the capability system later. * Fix the failing test, multi-file.hlsl I am not sure why this change is needed. * Fix compile errors on macOS 2nd try * Remove a typo character to fix the compile error * Trivial clean up * Remove `as_type` where it was intended as static_cast * Use a simpler sytax for __intrinsic_asm * Trivial clean up * Remove TEST_AFTER_FIXING_CAPABILITY_PROBLEM after fixing normalize * Fix the failing test properly * Fix an incorrect setup of Depth-cube texture --------- Co-authored-by: Yong He --- source/slang/slang-stdlib-textures.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source/slang/slang-stdlib-textures.h') diff --git a/source/slang/slang-stdlib-textures.h b/source/slang/slang-stdlib-textures.h index 6c07b1a46..a6166cc2d 100644 --- a/source/slang/slang-stdlib-textures.h +++ b/source/slang/slang-stdlib-textures.h @@ -68,8 +68,9 @@ public: const String& cuda, const String& spirvDefault, const String& spirvRWDefault, - const String& spirvCombined - ); + const String& spirvCombined, + const String& metal + ); void writeFuncWithSig( const char* funcName, const String& sig, @@ -78,6 +79,7 @@ public: const String& spirvRWDefault = String{}, const String& spirvCombined = String{}, const String& cuda = String{}, + const String& metal = String{}, const ReadNoneMode readNoneMode = ReadNoneMode::Never ); void writeFunc( @@ -89,6 +91,7 @@ public: const String& spirvRWDefault = String{}, const String& spirvCombined = String{}, const String& cuda = String{}, + const String& metal = String{}, const ReadNoneMode readNoneMode = ReadNoneMode::Never ); -- cgit v1.2.3