summaryrefslogtreecommitdiff
path: root/source/slang/hlsl.meta.slang
diff options
context:
space:
mode:
authorArielG-NV <159081215+ArielG-NV@users.noreply.github.com>2024-06-26 09:37:18 -0400
committerGitHub <noreply@github.com>2024-06-26 09:37:18 -0400
commite1d0ef2002d7b0f459cf689ec1f8e37c4ff2afba (patch)
treeaf4ab4fdd522a26458b56d4e642962f086630b21 /source/slang/hlsl.meta.slang
parent969dd4cc7246bfe89103efcb00f399606e804e98 (diff)
Expand upon existing `ImageSubscript` support (Metal, GLSL, SPIRV) (#4408)
* Add additional `ImageSubscript` features: 1. Added ImageSubscript support for Metal & a test case * Merge GLSL/SPIRV/Metal `ImageSubscript` legalization pass 2. Added multisample support to glsl/spirv/metal for when using ImageSubscript * Added in this PR since the overhaul of the code merges together GLSL/SPIRV/Metal implementation 3. Fixed minor metal texture `Load`/`Read` bugs * [HLSL methods of access do not support subscript accessor for texture cube array](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/texturecubearray) * removed swizzling of uint/int/float * other odd bugs which were causing compile errors note: Compute tests do not work due to what seems to be the GFX backend (causes crash without error report). The tests are disabled. * disable LOD with texture 1d seems that LOD for 1d textures need to be a compile time constant as per an error metal throws * syntax error in hlsl.meta * static_assert alone with intrinsic_asm error provides cleaner errors Note: `static_assert` seems to be unstable and not be fully respected (still require `intrinsic_asm` to avoid a stdlib compile error) * change comment to `// lod is not supported for 1D texture * add `static_assert` in related code gen paths * address review * address review * add asserts as per review comment, NOTE: unclear if these should be release 'asserts' as well
Diffstat (limited to 'source/slang/hlsl.meta.slang')
-rw-r--r--source/slang/hlsl.meta.slang31
1 files changed, 13 insertions, 18 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang
index 597e4dc06..94a5208b0 100644
--- a/source/slang/hlsl.meta.slang
+++ b/source/slang/hlsl.meta.slang
@@ -2416,11 +2416,12 @@ extension __TextureImpl<T,Shape,isArray,0,sampleCount,0,isShadow,isCombined,form
__intrinsic_asm "$c$0.read(vec<uint,3>(($1).xyz), uint(($1).w))$z";
break;
case $(SLANG_TEXTURE_CUBE):
+ static_assert(isArray == 0, "Unsupported 'Load' of 'texture cube array' for 'metal' target");
if (isShadow == 1)
{
if (isArray == 1)
// T read(uint2 coord, uint face, uint array, uint lod = 0) const
- __intrinsic_asm "$0.read(vec<uint,2>(($1).xy), uint(($1).z), uint(($1).w))";
+ __intrinsic_asm "<invalid intrinsics>";
else
// T read(uint2 coord, uint face, uint lod = 0) const
__intrinsic_asm "$c$0.read(vec<uint,2>(($1).xy), uint(($1).z), uint(($1).w))$z";
@@ -2429,14 +2430,14 @@ extension __TextureImpl<T,Shape,isArray,0,sampleCount,0,isShadow,isCombined,form
{
if (isArray == 1)
// Tv read(uint2 coord, uint face, uint array, uint lod = 0) const
- __intrinsic_asm "$0.read(vec<uint,2>(($1).xy), uint(($1).z), uint(($1).w))";
+ __intrinsic_asm "<invalid intrinsics>";
else
// Tv read(uint2 coord, uint face, uint lod = 0) const
__intrinsic_asm "$c$0.read(vec<uint,2>(($1).xy), uint(($1).z), uint(($1).w))$z";
}
break;
}
- // TODO: This needs to be handled by the capability system
+ static_assert(false, "Unsupported 'Load' of 'texture' for 'metal' target");
__intrinsic_asm "<invalid intrinsics>";
case glsl:
__intrinsic_asm "$ctexelFetch($0, ($1).$w1b, ($1).$w1e)$z";
@@ -2819,6 +2820,7 @@ extension __TextureImpl<T,Shape,isArray,0,sampleCount,$(access),isShadow, 0,form
__intrinsic_asm "$c$0.read(vec<uint,3>(($1).xyz))$z";
break;
case $(SLANG_TEXTURE_CUBE):
+ static_assert(isArray == 0, "Unsupported 'Load' of 'texture cube array' for 'metal' target");
if (isShadow == 1)
{
if (isArray == 1)
@@ -2839,7 +2841,7 @@ extension __TextureImpl<T,Shape,isArray,0,sampleCount,$(access),isShadow, 0,form
}
break;
}
- // TODO: This needs to be handled by the capability system
+ static_assert(false, "Unsupported 'Load' of 'texture' for 'metal' target");
__intrinsic_asm "<invalid intrinsics>";
}
}
@@ -2960,10 +2962,10 @@ extension __TextureImpl<T,Shape,isArray,0,sampleCount,$(access),isShadow, 0,form
// lod is not supported for 1D texture
if (isArray == 1)
// void write(Tv color, uint coord, uint array, uint lod = 0) const
- __intrinsic_asm "$0.write($2, uint(($1).x))";
+ __intrinsic_asm "$0.write($2, uint(($1).x), uint(($1).y))";
else
// void write(Tv color, uint coord, uint lod = 0) const
- __intrinsic_asm "$0.write($2, uint(($1).x))";
+ __intrinsic_asm "$0.write($2, uint($1))";
break;
case $(SLANG_TEXTURE_2D):
if (isShadow == 1)
@@ -2991,23 +2993,16 @@ extension __TextureImpl<T,Shape,isArray,0,sampleCount,$(access),isShadow, 0,form
__intrinsic_asm "$0.write($2, vec<uint,3>(($1).xyz))";
break;
case $(SLANG_TEXTURE_CUBE):
+ static_assert(isArray == 0, "Unsupported 'Store' of 'texture cube array' for 'metal' target");
if (isShadow == 1)
{
- if (isArray == 1)
- // void write(Tv color, uint2 coord, uint face, uint array, uint lod = 0) const
- __intrinsic_asm "$0.write($2, vec<uint,2>(($1).xy), uint(($1).z)%6, uint(($1).z)/6)";
- else
- // void write(Tv color, uint2 coord, uint face, uint lod = 0) const
- __intrinsic_asm "$0.write($2, vec<uint,2>(($1).xy), uint(($1).z))";
+ // void write(Tv color, uint2 coord, uint face, uint lod = 0) const
+ __intrinsic_asm "$0.write($2, vec<uint,2>(($1).xy), uint(($1).z), uint(($1).w))";
}
else
{
- if (isArray == 1)
- // void write(Tv color, uint2 coord, uint face, uint array, uint lod = 0) const
- __intrinsic_asm "$0.write($2, vec<uint,2>(($1).xy), uint(($1).z)%6, uint(($1).z)/6)";
- else
- // void write(Tv color, uint2 coord, uint face, uint lod = 0) const
- __intrinsic_asm "$0.write($2, vec<uint,2>(($1).xy), uint(($1).z))";
+ // void write(Tv color, uint2 coord, uint face, uint lod = 0) const
+ __intrinsic_asm "$0.write($2, vec<uint,2>(($1).xy), uint(($1).z), uint(($1).w))";
}
break;
}