|
| 1 | +#ifndef _NBL_BUILTIN_GLSL_SUBGROUP_ARITHMETIC_PORTABILITY_INCLUDED_ |
| 2 | +#define _NBL_BUILTIN_GLSL_SUBGROUP_ARITHMETIC_PORTABILITY_INCLUDED_ |
| 3 | + |
| 4 | + |
| 5 | +#include <nbl/builtin/glsl/subgroup/shared_arithmetic_portability.glsl> |
| 6 | + |
| 7 | + |
| 8 | +#ifdef NBL_GL_KHR_shader_subgroup_arithmetic |
| 9 | + |
| 10 | + |
| 11 | +#define nbl_glsl_subgroupAdd subgroupAnd |
| 12 | + |
| 13 | +#define nbl_glsl_subgroupAdd subgroupXor |
| 14 | + |
| 15 | +#define nbl_glsl_subgroupAdd subgroupOr |
| 16 | + |
| 17 | + |
| 18 | +#define nbl_glsl_subgroupAdd subgroupAdd |
| 19 | + |
| 20 | +#define nbl_glsl_subgroupAdd subgroupMul |
| 21 | + |
| 22 | +#define nbl_glsl_subgroupAdd subgroupMin |
| 23 | + |
| 24 | +#define nbl_glsl_subgroupAdd subgroupMax |
| 25 | + |
| 26 | + |
| 27 | +#define nbl_glsl_subgroupExclusiveAdd subgroupExclusiveAnd |
| 28 | +#define nbl_glsl_subgroupInclusiveAdd subgroupInclusiveAnd |
| 29 | + |
| 30 | +#define nbl_glsl_subgroupExclusiveAdd subgroupExclusiveXor |
| 31 | +#define nbl_glsl_subgroupInclusiveAdd subgroupInclusiveXor |
| 32 | + |
| 33 | +#define nbl_glsl_subgroupExclusiveAdd subgroupExclusiveOr |
| 34 | +#define nbl_glsl_subgroupInclusiveAdd subgroupInclusiveOr |
| 35 | + |
| 36 | + |
| 37 | +#define nbl_glsl_subgroupExclusiveAdd subgroupExclusiveAdd |
| 38 | +#define nbl_glsl_subgroupInclusiveAdd subgroupInclusiveAdd |
| 39 | + |
| 40 | +#define nbl_glsl_subgroupExclusiveAdd subgroupExclusiveMul |
| 41 | +#define nbl_glsl_subgroupInclusiveAdd subgroupInclusiveMul |
| 42 | + |
| 43 | +#define nbl_glsl_subgroupExclusiveAdd subgroupExclusiveMin |
| 44 | +#define nbl_glsl_subgroupInclusiveAdd subgroupInclusiveMin |
| 45 | + |
| 46 | +#define nbl_glsl_subgroupExclusiveAdd subgroupExclusiveMax |
| 47 | +#define nbl_glsl_subgroupInclusiveAdd subgroupInclusiveMax |
| 48 | + |
| 49 | + |
| 50 | +#else |
| 51 | + |
| 52 | + |
| 53 | +// If you're planning to use the emulated `nbl_glsl_subgroup` with workgroup sizes not divisible by subgroup size, you should clear the _NBL_GLSL_SCRATCH_SHARED_DEFINED_ to the identity value yourself. |
| 54 | +#define nbl_glsl_subgroupAnd(VALUE) nbl_glsl_subgroupAnd_impl(true,VALUE) |
| 55 | + |
| 56 | +#define nbl_glsl_subgroupXor(VALUE) nbl_glsl_subgroupXor_impl(true,VALUE) |
| 57 | + |
| 58 | +#define nbl_glsl_subgroupOr(VALUE) nbl_glsl_subgroupOr_impl(true,VALUE) |
| 59 | + |
| 60 | + |
| 61 | +#define nbl_glsl_subgroupAdd(VALUE) nbl_glsl_subgroupAdd_impl(true,VALUE) |
| 62 | + |
| 63 | +#define nbl_glsl_subgroupMul(VALUE) nbl_glsl_subgroupMul_impl(true,VALUE) |
| 64 | + |
| 65 | +#define nbl_glsl_subgroupMin(VALUE) nbl_glsl_subgroupMin_impl(true,VALUE) |
| 66 | + |
| 67 | +#define nbl_glsl_subgroupMax(VALUE) nbl_glsl_subgroupMax_impl(true,VALUE) |
| 68 | + |
| 69 | + |
| 70 | +#define nbl_glsl_subgroupExclusiveAnd(VALUE) nbl_glsl_subgroupExclusiveAnd_impl(true,VALUE) |
| 71 | +#define nbl_glsl_subgroupInclusiveAnd(VALUE) nbl_glsl_subgroupInclusiveAnd_impl(true,VALUE) |
| 72 | + |
| 73 | +#define nbl_glsl_subgroupExclusiveXor(VALUE) nbl_glsl_subgroupExclusiveXor_impl(true,VALUE) |
| 74 | +#define nbl_glsl_subgroupInclusiveXor(VALUE) nbl_glsl_subgroupInclusiveXor_impl(true,VALUE) |
| 75 | + |
| 76 | +#define nbl_glsl_subgroupExclusiveOr(VALUE) nbl_glsl_subgroupExclusiveOr_impl(true,VALUE) |
| 77 | +#define nbl_glsl_subgroupInclusiveOr(VALUE) nbl_glsl_subgroupInclusiveOr_impl(true,VALUE) |
| 78 | + |
| 79 | + |
| 80 | +#define nbl_glsl_subgroupExclusiveAdd(VALUE) nbl_glsl_subgroupExclusiveAdd_impl(true,VALUE) |
| 81 | +#define nbl_glsl_subgroupInclusiveAdd(VALUE) nbl_glsl_subgroupInclusiveAdd_impl(true,VALUE) |
| 82 | + |
| 83 | +#define nbl_glsl_subgroupExclusiveMul(VALUE) nbl_glsl_subgroupExclusiveMul_impl(true,VALUE) |
| 84 | +#define nbl_glsl_subgroupInclusiveMul(VALUE) nbl_glsl_subgroupInclusiveMul_impl(true,VALUE) |
| 85 | + |
| 86 | +#define nbl_glsl_subgroupExclusiveMin(VALUE) nbl_glsl_subgroupExclusiveMin_impl(true,VALUE) |
| 87 | +#define nbl_glsl_subgroupInclusiveMin(VALUE) nbl_glsl_subgroupInclusiveMin_impl(true,VALUE) |
| 88 | + |
| 89 | +#define nbl_glsl_subgroupExclusiveMax(VALUE) nbl_glsl_subgroupExclusiveMax_impl(true,VALUE) |
| 90 | +#define nbl_glsl_subgroupInclusiveMax(VALUE) nbl_glsl_subgroupInclusiveMax_impl(true,VALUE) |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | +#ifdef _NBL_GLSL_SCRATCH_SHARED_DEFINED_ |
| 95 | + #if NBL_GLSL_LESS(_NBL_GLSL_SCRATCH_SHARED_SIZE_DEFINED_,_NBL_GLSL_SUBGROUP_ARITHMETIC_EMULATION_SHARED_SIZE_NEEDED_) |
| 96 | + #error "Not enough shared memory declared" |
| 97 | + #endif |
| 98 | +#else |
| 99 | + #if NBL_GLSL_GREATER(_NBL_GLSL_SUBGROUP_ARITHMETIC_EMULATION_SHARED_SIZE_NEEDED_,0) |
| 100 | + #define _NBL_GLSL_SCRATCH_SHARED_DEFINED_ nbl_glsl_subgroupArithmeticEmulationScratchShared |
| 101 | + #define _NBL_GLSL_SCRATCH_SHARED_SIZE_DEFINED_ _NBL_GLSL_SUBGROUP_ARITHMETIC_EMULATION_SHARED_SIZE_NEEDED_ |
| 102 | + shared uint _NBL_GLSL_SCRATCH_SHARED_DEFINED_[_NBL_GLSL_SUBGROUP_ARITHMETIC_EMULATION_SHARED_SIZE_NEEDED_]; |
| 103 | + #endif |
| 104 | +#endif |
| 105 | + |
| 106 | + |
| 107 | +#include <nbl/builtin/glsl/subgroup/arithmetic_portability_impl.glsl> |
| 108 | + |
| 109 | + |
| 110 | +#endif // NBL_GL_KHR_shader_subgroup_arithmetic |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | +#endif |
0 commit comments