@@ -855,6 +855,10 @@ float __glsl_texture_level_offset_1d_shadow<TTexture, TCoord, TOffset>(TTexture
855
855
}
856
856
}
857
857
858
+ __intrinsic_op($(kIROp_MetalCastToDepthTexture))
859
+ __generic<T:ITexelElement, Shape: __ITextureShape, let isArray:int, let isMS:int, let sampleCount:int, let access:int, let isShadow:int, let isCombined:int, let format:int>
860
+ _Texture<T,Shape,isArray,isMS,sampleCount,access,1,isCombined,format> __metal_asDepthTexture(_Texture<T,Shape,isArray,isMS,sampleCount,access,isShadow,isCombined,format> tex);
861
+
858
862
//@public:
859
863
860
864
__generic<T:ITexelElement, Shape: __ITextureShape, let isArray:int, let isMS:int, let sampleCount:int, let isShadow:int, let format:int>
@@ -1676,6 +1680,96 @@ extension _Texture<T,Shape,isArray,isMS,sampleCount,access,isShadow,0,format>
1676
1680
}
1677
1681
}
1678
1682
}
1683
+ __generic<T:ITexelElement, Shape: __ITextureShape, let isArray:int, let isMS:int, let sampleCount:int, let format:int>
1684
+ float __metal_SampleCmp(_Texture<T,Shape,isArray,isMS,sampleCount,0,1,0,format> t, SamplerComparisonState s, vector<float, Shape.dimensions+isArray> location, float compareValue)
1685
+ {
1686
+ if (isArray == 1)
1687
+ {
1688
+ switch (Shape.flavor)
1689
+ {
1690
+ case $(SLANG_TEXTURE_2D):
1691
+ __intrinsic_asm "$0.sample_compare($1, ($2).xy, uint(($2).z), $3)";
1692
+ case $(SLANG_TEXTURE_CUBE):
1693
+ __intrinsic_asm "$0.sample_compare($1, ($2).xyz, uint(($2).w), $3)";
1694
+ }
1695
+ }
1696
+ else
1697
+ {
1698
+ switch (Shape.flavor)
1699
+ {
1700
+ case $(SLANG_TEXTURE_2D):
1701
+ case $(SLANG_TEXTURE_CUBE):
1702
+ __intrinsic_asm ".sample_compare";
1703
+ }
1704
+ }
1705
+ __intrinsic_asm "<invalid intrinsic>";
1706
+ }
1707
+ __generic<T:ITexelElement, Shape: __ITextureShape, let isArray:int, let isMS:int, let sampleCount:int, let format:int>
1708
+ float __metal_SampleCmp(_Texture<T,Shape,isArray,isMS,sampleCount,0,1,0,format> t, SamplerComparisonState s, vector<float, Shape.dimensions+isArray> location, float compareValue, constexpr vector<int, Shape.planeDimensions> offset)
1709
+ {
1710
+ if (isArray == 1)
1711
+ {
1712
+ switch (Shape.flavor)
1713
+ {
1714
+ case $(SLANG_TEXTURE_2D):
1715
+ __intrinsic_asm "$0.sample_compare($1, ($2).xy, uint(($2).z), $3, $4)";
1716
+ }
1717
+ }
1718
+ else
1719
+ {
1720
+ switch (Shape.flavor)
1721
+ {
1722
+ case $(SLANG_TEXTURE_2D):
1723
+ __intrinsic_asm "$0.sample_compare($1, $2, $3, $4)";
1724
+ }
1725
+ }
1726
+ __intrinsic_asm "<invalid intrinsic>";
1727
+ }
1728
+
1729
+ __generic<T:ITexelElement, Shape: __ITextureShape, let isArray:int, let isMS:int, let sampleCount:int, let format:int>
1730
+ float __metal_SampleCmpLevel(_Texture<T,Shape,isArray,isMS,sampleCount,0,1,0,format> t, SamplerComparisonState s, vector<float, Shape.dimensions+isArray> location, float compareValue, float level)
1731
+ {
1732
+ if (isArray == 1)
1733
+ {
1734
+ switch (Shape.flavor)
1735
+ {
1736
+ case $(SLANG_TEXTURE_2D):
1737
+ __intrinsic_asm "$0.sample_compare($1, ($2).xy, uint(($2).z), $3, level($4))";
1738
+ case $(SLANG_TEXTURE_CUBE):
1739
+ __intrinsic_asm "$0.sample_compare($1, ($2).xyz, uint(($2).w), $3, level($4))";
1740
+ }
1741
+ }
1742
+ else
1743
+ {
1744
+ switch (Shape.flavor)
1745
+ {
1746
+ case $(SLANG_TEXTURE_2D):
1747
+ case $(SLANG_TEXTURE_CUBE):
1748
+ __intrinsic_asm "$0.sample_compare($1, $2, $3, level($4))";
1749
+ }
1750
+ }
1751
+ __intrinsic_asm "<invalid intrinsic>";
1752
+ }
1753
+ __generic<T:ITexelElement, Shape: __ITextureShape, let isArray:int, let isMS:int, let sampleCount:int, let format:int>
1754
+ float __metal_SampleCmpLevel(_Texture<T,Shape,isArray,isMS,sampleCount,0,1,0,format> t, SamplerComparisonState s, vector<float, Shape.dimensions+isArray> location, float compareValue, float level, constexpr vector<int, Shape.planeDimensions> offset)
1755
+ {
1756
+ switch (Shape.flavor)
1757
+ {
1758
+ case $(SLANG_TEXTURE_2D):
1759
+ if (isArray == 1)
1760
+ {
1761
+ // T sample_compare(sampler s, float2 coord, uint array, float compare_value, lod_options options, int2 offset = int2(0)) const
1762
+ __intrinsic_asm "$0.sample_compare($1, ($2).xy, uint(($2).z), $3, level($4), $5)";
1763
+ }
1764
+ else
1765
+ {
1766
+ // T sample_compare(sampler s, float2 coord, float compare_value, lod_options options, int2 offset = int2(0)) const
1767
+ __intrinsic_asm "$0.sample_compare($1, $2, $3, level($4), $5)";
1768
+ }
1769
+ break;
1770
+ }
1771
+ __intrinsic_asm "<invalid intrinsic>";
1772
+ }
1679
1773
1680
1774
__generic<T:ITexelElement, Shape: __ITextureShape, let isArray:int, let isMS:int, let sampleCount:int, let isShadow:int, let format:int>
1681
1775
extension _Texture<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format>
@@ -2082,26 +2176,7 @@ extension _Texture<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format>
2082
2176
, "HLSL supports only float and half type textures");
2083
2177
__intrinsic_asm ".SampleCmp";
2084
2178
case metal:
2085
- if (isArray == 1)
2086
- {
2087
- switch (Shape.flavor)
2088
- {
2089
- case $(SLANG_TEXTURE_2D):
2090
- __intrinsic_asm "$0.sample_compare($1, ($2).xy, uint(($2).z), $3)";
2091
- case $(SLANG_TEXTURE_CUBE):
2092
- __intrinsic_asm "$0.sample_compare($1, ($2).xyz, uint(($2).w), $3)";
2093
- }
2094
- }
2095
- else
2096
- {
2097
- switch (Shape.flavor)
2098
- {
2099
- case $(SLANG_TEXTURE_2D):
2100
- case $(SLANG_TEXTURE_CUBE):
2101
- __intrinsic_asm ".sample_compare";
2102
- }
2103
- }
2104
- __intrinsic_asm "<invalid intrinsic>";
2179
+ return __metal_SampleCmp(__metal_asDepthTexture(this), s, location, compareValue);
2105
2180
case spirv:
2106
2181
return spirv_asm
2107
2182
{
@@ -2183,23 +2258,7 @@ extension _Texture<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format>
2183
2258
, "HLSL supports only float and half type textures");
2184
2259
__intrinsic_asm ".SampleCmp";
2185
2260
case metal:
2186
- if (isArray == 1)
2187
- {
2188
- switch (Shape.flavor)
2189
- {
2190
- case $(SLANG_TEXTURE_2D):
2191
- __intrinsic_asm "$0.sample_compare($1, ($2).xy, uint(($2).z), $3, $4)";
2192
- }
2193
- }
2194
- else
2195
- {
2196
- switch (Shape.flavor)
2197
- {
2198
- case $(SLANG_TEXTURE_2D):
2199
- __intrinsic_asm ".sample_compare";
2200
- }
2201
- }
2202
- __intrinsic_asm "<invalid intrinsic>";
2261
+ return __metal_SampleCmp(__metal_asDepthTexture(this), s, location, compareValue, offset);
2203
2262
case spirv:
2204
2263
return spirv_asm
2205
2264
{
@@ -2311,26 +2370,7 @@ extension _Texture<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format>
2311
2370
, "HLSL supports only float and half type textures");
2312
2371
__intrinsic_asm ".SampleCmpLevel";
2313
2372
case metal:
2314
- if (isArray == 1)
2315
- {
2316
- switch (Shape.flavor)
2317
- {
2318
- case $(SLANG_TEXTURE_2D):
2319
- __intrinsic_asm "$0.sample_compare($1, ($2).xy, uint(($2).z), $3, level($4))";
2320
- case $(SLANG_TEXTURE_CUBE):
2321
- __intrinsic_asm "$0.sample_compare($1, ($2).xyz, uint(($2).w), $3, level($4))";
2322
- }
2323
- }
2324
- else
2325
- {
2326
- switch (Shape.flavor)
2327
- {
2328
- case $(SLANG_TEXTURE_2D):
2329
- case $(SLANG_TEXTURE_CUBE):
2330
- __intrinsic_asm "$0.sample_compare($1, $2, $3, level($4))";
2331
- }
2332
- }
2333
- __intrinsic_asm "<invalid intrinsic>";
2373
+ return __metal_SampleCmpLevel(__metal_asDepthTexture(this), s, location, compareValue, level);
2334
2374
case spirv:
2335
2375
return spirv_asm
2336
2376
{
@@ -2362,25 +2402,7 @@ extension _Texture<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format>
2362
2402
, "HLSL supports only float and half type textures");
2363
2403
__intrinsic_asm ".SampleCmpLevel";
2364
2404
case metal:
2365
- if (isShadow == 1)
2366
- {
2367
- switch (Shape.flavor)
2368
- {
2369
- case $(SLANG_TEXTURE_2D):
2370
- if (isArray == 1)
2371
- {
2372
- // T sample_compare(sampler s, float2 coord, uint array, float compare_value, lod_options options, int2 offset = int2(0)) const
2373
- __intrinsic_asm "$0.sample_compare($1, ($2).xy, uint(($2).z), $3, level($4), $5)";
2374
- }
2375
- else
2376
- {
2377
- // T sample_compare(sampler s, float2 coord, float compare_value, lod_options options, int2 offset = int2(0)) const
2378
- __intrinsic_asm "$0.sample_compare($1, $2, $3, level($4), $5)";
2379
- }
2380
- break;
2381
- }
2382
- }
2383
- __intrinsic_asm "<invalid intrinsic>";
2405
+ return __metal_SampleCmpLevel(__metal_asDepthTexture(this), s, location, compareValue, level, offset);
2384
2406
case spirv:
2385
2407
return spirv_asm
2386
2408
{
0 commit comments