@@ -321,114 +321,6 @@ public vector<T,N> atan(vector<T,N> y, vector<T,N> x)
321
321
return atan2(y, x);
322
322
}
323
323
324
- __generic < T : __BuiltinFloatingPointType>
325
- [__readNone]
326
- [ForceInline]
327
- [require(cpp_cuda_glsl_hlsl_spirv, GLSL_130)]
328
- public T asinh(T x)
329
- {
330
- __target_switch
331
- {
332
- case cpp: __intrinsic_asm " $P_asinh($0)" ;
333
- case cuda: __intrinsic_asm " $P_asinh($0)" ;
334
- case glsl: __intrinsic_asm " asinh" ;
335
- case spirv: return spirv_asm {
336
- OpExtInst $$T result glsl450 Asinh $x
337
- };
338
- default :
339
- return log(x + sqrt(x * x + T(1 )));
340
- }
341
- }
342
-
343
- __generic < T : __BuiltinFloatingPointType, let N:int >
344
- [__readNone]
345
- [ForceInline]
346
- [require(cpp_cuda_glsl_hlsl_spirv, GLSL_130)]
347
- public vector< T,N> asinh(vector< T,N> x)
348
- {
349
- __target_switch
350
- {
351
- case glsl: __intrinsic_asm " asinh" ;
352
- case spirv: return spirv_asm {
353
- OpExtInst $$vector< T,N> result glsl450 Asinh $x
354
- };
355
- default :
356
- VECTOR_MAP_UNARY(T, N, asinh, x);
357
- }
358
- }
359
-
360
- __generic < T : __BuiltinFloatingPointType>
361
- [__readNone]
362
- [ForceInline]
363
- [require(cpp_cuda_glsl_hlsl_spirv, GLSL_130)]
364
- public T acosh(T x)
365
- {
366
- __target_switch
367
- {
368
- case cpp: __intrinsic_asm " $P_acosh($0)" ;
369
- case cuda: __intrinsic_asm " $P_acosh($0)" ;
370
- case glsl: __intrinsic_asm " acosh" ;
371
- case spirv: return spirv_asm {
372
- OpExtInst $$T result glsl450 Acosh $x
373
- };
374
- default :
375
- return log(x + sqrt( x * x - T(1 )));
376
- }
377
- }
378
-
379
- __generic < T : __BuiltinFloatingPointType, let N:int >
380
- [__readNone]
381
- [ForceInline]
382
- [require(cpp_cuda_glsl_hlsl_spirv, GLSL_130)]
383
- public vector< T,N> acosh(vector< T,N> x)
384
- {
385
- __target_switch
386
- {
387
- case glsl: __intrinsic_asm " acosh" ;
388
- case spirv: return spirv_asm {
389
- OpExtInst $$vector< T,N> result glsl450 Acosh $x
390
- };
391
- default :
392
- VECTOR_MAP_UNARY(T, N, acosh, x);
393
- }
394
- }
395
-
396
- __generic < T : __BuiltinFloatingPointType>
397
- [__readNone]
398
- [ForceInline]
399
- [require(cpp_cuda_glsl_hlsl_spirv, GLSL_130)]
400
- public T atanh(T x)
401
- {
402
- __target_switch
403
- {
404
- case cpp: __intrinsic_asm " $P_atanh($0)" ;
405
- case cuda: __intrinsic_asm " $P_atanh($0)" ;
406
- case glsl: __intrinsic_asm " atanh" ;
407
- case spirv: return spirv_asm {
408
- OpExtInst $$T result glsl450 Atanh $x
409
- };
410
- default :
411
- return T(0 . 5 ) * log((T(1 ) + x) / (T(1 ) - x));
412
- }
413
- }
414
-
415
- __generic < T : __BuiltinFloatingPointType, let N:int >
416
- [__readNone]
417
- [ForceInline]
418
- [require(cpp_cuda_glsl_hlsl_spirv, sm_2_0_GLSL_140)]
419
- public vector< T,N> atanh(vector< T,N> x)
420
- {
421
- __target_switch
422
- {
423
- case glsl: __intrinsic_asm " atanh" ;
424
- case spirv: return spirv_asm {
425
- OpExtInst $$vector< T,N> result glsl450 Atanh $x
426
- };
427
- default :
428
- VECTOR_MAP_UNARY(T, N, atanh, x);
429
- }
430
- }
431
-
432
324
//
433
325
// Section 8.2. Exponential Functions
434
326
//
@@ -458,66 +350,19 @@ public vector<T, N> inversesqrt(vector<T, N> x)
458
350
__generic < T : __BuiltinFloatingPointType>
459
351
[__readNone]
460
352
[ForceInline]
461
- [require(cpp_cuda_glsl_hlsl_spirv , GLSL_130)]
353
+ [require(cpp_cuda_glsl_hlsl_metal_spirv , GLSL_130)]
462
354
public T roundEven(T x)
463
355
{
464
- __target_switch
465
- {
466
- case glsl: __intrinsic_asm " roundEven" ;
467
- case spirv: return spirv_asm {
468
- OpExtInst $$T result glsl450 RoundEven $x
469
- };
470
- default :
471
- T nearest = round(x);
472
-
473
- // Check if the value is exactly halfway between two integers
474
- if (abs(x - nearest) == T(0 . 5 ))
475
- {
476
- // If halfway, choose the even number
477
- if (mod(nearest, T(2 )) != T(0 ))
478
- {
479
- // If the nearest number is odd,
480
- // move to the closest even number
481
- nearest -= ((x < nearest) ? T(1 ) : T(- 1 ));
482
- }
483
- }
484
- return nearest;
485
- }
356
+ return rint(x);
486
357
}
487
358
488
359
__generic < T : __BuiltinFloatingPointType, let N:int >
489
360
[__readNone]
490
361
[ForceInline]
491
- [require(cpp_cuda_glsl_hlsl_spirv , GLSL_130)]
362
+ [require(cpp_cuda_glsl_hlsl_metal_spirv , GLSL_130)]
492
363
public vector< T,N> roundEven(vector< T,N> x)
493
364
{
494
- __target_switch
495
- {
496
- case glsl: __intrinsic_asm " roundEven" ;
497
- case spirv: return spirv_asm {
498
- OpExtInst $$vector< T,N> result glsl450 RoundEven $x
499
- };
500
- default :
501
- VECTOR_MAP_UNARY(T, N, roundEven, x);
502
- }
503
- }
504
-
505
- __generic < T : __BuiltinFloatingPointType>
506
- [__readNone]
507
- [ForceInline]
508
- [require(cpp_cuda_glsl_hlsl_spirv, sm_2_0_GLSL_140)]
509
- public T fract(T x)
510
- {
511
- return frac(x);
512
- }
513
-
514
- __generic < T : __BuiltinFloatingPointType, let N:int >
515
- [__readNone]
516
- [ForceInline]
517
- [require(cpp_cuda_glsl_hlsl_spirv, sm_2_0_GLSL_140)]
518
- public vector< T, N> fract(vector< T, N> x)
519
- {
520
- return frac(x);
365
+ return rint(x);
521
366
}
522
367
523
368
__generic < T : __BuiltinFloatingPointType>
@@ -824,44 +669,6 @@ uint float2half(float f)
824
669
return (s | e | m);
825
670
}
826
671
827
- __generic < T : __BuiltinFloatingPointType, E : __BuiltinIntegerType>
828
- [__readNone]
829
- [require(cpp_cuda_glsl_hlsl_spirv, sm_2_0_GLSL_140)]
830
- public T ldexp(T x, E exp)
831
- {
832
- __target_switch
833
- {
834
- case hlsl: __intrinsic_asm " ldexp" ;
835
- case glsl: __intrinsic_asm " ldexp" ;
836
- case spirv: return spirv_asm {
837
- OpExtInst $$T result glsl450 Ldexp $x $exp
838
- };
839
- default :
840
- return ldexp(x, __floatCast< T> (exp));
841
- }
842
- }
843
-
844
- __generic < T : __BuiltinFloatingPointType, E : __BuiltinIntegerType, let N : int >
845
- [__readNone]
846
- [require(cpp_cuda_glsl_hlsl_spirv, sm_2_0_GLSL_140)]
847
- public vector< T, N> ldexp(vector< T, N> x, vector< E, N> exp)
848
- {
849
- __target_switch
850
- {
851
- case hlsl: __intrinsic_asm " ldexp" ;
852
- case glsl: __intrinsic_asm " ldexp" ;
853
- case spirv: return spirv_asm {
854
- OpExtInst $$vector< T,N> result glsl450 Ldexp $x $exp
855
- };
856
- default :
857
- vector< T,N> temp;
858
- [ForceUnroll]
859
- for (int i = 0 ; i < N; ++ i)
860
- temp [i] = __floatCast< T> (exp [i]);
861
- return ldexp(x, temp);
862
- }
863
- }
864
-
865
672
[__readNone]
866
673
[ForceInline]
867
674
[require(cpp_cuda_glsl_hlsl_spirv, shader5_sm_4_0)]
0 commit comments