diff --git a/include/nbl/builtin/hlsl/bitonic_sort/common.hlsl b/include/nbl/builtin/hlsl/bitonic_sort/common.hlsl new file mode 100644 index 0000000000..0aaa8940df --- /dev/null +++ b/include/nbl/builtin/hlsl/bitonic_sort/common.hlsl @@ -0,0 +1,63 @@ +#ifndef _NBL_BUILTIN_HLSL_BITONIC_SORT_COMMON_INCLUDED_ +#define _NBL_BUILTIN_HLSL_BITONIC_SORT_COMMON_INCLUDED_ + +#include "nbl/builtin/hlsl/cpp_compat.hlsl" +#include "nbl/builtin/hlsl/functional.hlsl" +#include "nbl/builtin/hlsl/subgroup/basic.hlsl" +#include "nbl/builtin/hlsl/glsl_compat/subgroup_shuffle.hlsl" + +namespace nbl +{ +namespace hlsl +{ +namespace bitonic_sort +{ + +template +struct bitonic_sort_config +{ + using key_t = KeyType; + using value_t = ValueType; + using comparator_t = Comparator; + static const uint32_t SubgroupSizeLog2 = SubgroupSizelog2; + static const uint32_t SubgroupSize = 1u << SubgroupSizeLog2; +}; + +template +struct bitonic_sort; + + +template +struct LocalPasses +{ + static const uint32_t N = 1u << Log2N; + void operator()(bool ascending, sortable_t data[N], NBL_CONST_REF_ARG(Comparator) comp); +}; + +// Specialization for 2 elements (Log2N=1) +template +struct LocalPasses +{ + static const uint32_t N = 2; + + void operator()(bool ascending, sortable_t data[N], NBL_CONST_REF_ARG(Comparator) comp) + { + // For ascending: swap if data[1] < data[0] (put smaller first) + // For descending: swap if data[0] < data[1] (put larger first) + const bool needSwap = ascending ? comp(data[1], data[0]) : comp(data[0], data[1]); + + if (needSwap) + { + sortable_t temp = data[0]; + data[0] = data[1]; + data[1] = temp; + } + } +}; + + +} // namespace bitonic_sort +} // namespace hlsl +} // namespace nbl + +#endif diff --git a/include/nbl/builtin/hlsl/concepts/accessors/bitonic_sort.hlsl b/include/nbl/builtin/hlsl/concepts/accessors/bitonic_sort.hlsl new file mode 100644 index 0000000000..a39e91ffb3 --- /dev/null +++ b/include/nbl/builtin/hlsl/concepts/accessors/bitonic_sort.hlsl @@ -0,0 +1,31 @@ +#ifndef _NBL_BUILTIN_HLSL_CONCEPTS_ACCESSORS_BITONIC_SORT_INCLUDED_ +#define _NBL_BUILTIN_HLSL_CONCEPTS_ACCESSORS_BITONIC_SORT_INCLUDED_ + +#include "nbl/builtin/hlsl/concepts/accessors/generic_shared_data.hlsl" + +namespace nbl +{ +namespace hlsl +{ +namespace workgroup +{ +namespace bitonic_sort +{ +// The SharedMemoryAccessor MUST provide the following methods: +// * void get(uint32_t index, NBL_REF_ARG(uint32_t) value); +// * void set(uint32_t index, in uint32_t value); +// * void workgroupExecutionAndMemoryBarrier(); +template +NBL_BOOL_CONCEPT BitonicSortSharedMemoryAccessor = concepts::accessors::GenericSharedMemoryAccessor; + +// The Accessor MUST provide the following methods: +// * void get(uint32_t index, NBL_REF_ARG(pair) value); +// * void set(uint32_t index, in pair value); +template +NBL_BOOL_CONCEPT BitonicSortAccessor = concepts::accessors::GenericDataAccessor, I>; + +} +} +} +} +#endif diff --git a/include/nbl/builtin/hlsl/memory_accessor.hlsl b/include/nbl/builtin/hlsl/memory_accessor.hlsl index 2194b1e917..cee8617e1a 100644 --- a/include/nbl/builtin/hlsl/memory_accessor.hlsl +++ b/include/nbl/builtin/hlsl/memory_accessor.hlsl @@ -22,18 +22,6 @@ namespace nbl { namespace hlsl { - -// TODO: flesh out and move to `nbl/builtin/hlsl/utility.hlsl` -template -struct pair -{ - using first_type = T1; - using second_type = T2; - - first_type first; - second_type second; -}; - namespace accessor_adaptors { namespace impl @@ -227,4 +215,4 @@ struct Offset : impl::OffsetBase } } } -#endif \ No newline at end of file +#endif diff --git a/include/nbl/builtin/hlsl/subgroup/bitonic_sort.hlsl b/include/nbl/builtin/hlsl/subgroup/bitonic_sort.hlsl new file mode 100644 index 0000000000..165904a02d --- /dev/null +++ b/include/nbl/builtin/hlsl/subgroup/bitonic_sort.hlsl @@ -0,0 +1,94 @@ +#ifndef _NBL_BUILTIN_HLSL_SUBGROUP_BITONIC_SORT_INCLUDED_ +#define _NBL_BUILTIN_HLSL_SUBGROUP_BITONIC_SORT_INCLUDED_ + +#include "nbl/builtin/hlsl/bitonic_sort/common.hlsl" +#include "nbl/builtin/hlsl/subgroup/basic.hlsl" +#include "nbl/builtin/hlsl/glsl_compat/subgroup_shuffle.hlsl" + +namespace nbl +{ +namespace hlsl +{ +namespace subgroup +{ +namespace bitonic_sort +{ +using namespace nbl::hlsl::bitonic_sort; + +template +struct bitonic_sort_wgtype +{ + using WGType = WorkgroupType; + using key_t = KeyType; + using comparator_t = Comparator; + + static void mergeStage( + uint32_t stage, + bool bitonicAscending, + uint32_t invocationID, + NBL_REF_ARG(WGType) lo, + NBL_REF_ARG(WGType) hi) + { + comparator_t comp; + + [unroll] + for (uint32_t pass = 0u; pass <= stage; ++pass) + { + uint32_t stride = 1u << (stage - pass); + uint32_t partner = stride >> 1; + + if (partner == 0u) + { + bool swap = comp(hi.key, lo.key) == bitonicAscending; + WGType tmp = lo; + lo.key = swap ? hi.key : lo.key; + lo.workgroupRelativeIndex = swap ? hi.workgroupRelativeIndex : lo.workgroupRelativeIndex; + hi.key = swap ? tmp.key : hi.key; + hi.workgroupRelativeIndex = swap ? tmp.workgroupRelativeIndex : hi.workgroupRelativeIndex; + } + else + { + bool isUpper = (invocationID & partner) != 0u; + + // Select which element to trade and shuffle members individually + key_t tradingKey = isUpper ? hi.key : lo.key; + uint32_t tradingIdx = isUpper ? hi.workgroupRelativeIndex : lo.workgroupRelativeIndex; + + tradingKey = glsl::subgroupShuffleXor(tradingKey, partner); + tradingIdx = glsl::subgroupShuffleXor(tradingIdx, partner); + + lo.key = isUpper ? lo.key : tradingKey; + lo.workgroupRelativeIndex = isUpper ? lo.workgroupRelativeIndex : tradingIdx; + hi.key = isUpper ? tradingKey : hi.key; + hi.workgroupRelativeIndex = isUpper ? tradingIdx : hi.workgroupRelativeIndex; + + bool swap = comp(hi.key, lo.key) == bitonicAscending; + WGType tmp = lo; + lo.key = swap ? hi.key : lo.key; + lo.workgroupRelativeIndex = swap ? hi.workgroupRelativeIndex : lo.workgroupRelativeIndex; + hi.key = swap ? tmp.key : hi.key; + hi.workgroupRelativeIndex = swap ? tmp.workgroupRelativeIndex : hi.workgroupRelativeIndex; + } + } + } + + static void __call(bool ascending, NBL_REF_ARG(WGType) lo, NBL_REF_ARG(WGType) hi) + { + uint32_t id = glsl::gl_SubgroupInvocationID(); + uint32_t log2 = glsl::gl_SubgroupSizeLog2(); + + [unroll] + for (uint32_t s = 0u; s <= log2; ++s) + { + bool dir = (s == log2) ? ascending : ((id & (1u << s)) != 0u); + mergeStage(s, dir, id, lo, hi); + } + } +}; + +} // namespace bitonic_sort +} // namespace subgroup +} // namespace hlsl +} // namespace nbl + +#endif diff --git a/include/nbl/builtin/hlsl/utility.hlsl b/include/nbl/builtin/hlsl/utility.hlsl index 21f1eb1909..07c4b10624 100644 --- a/include/nbl/builtin/hlsl/utility.hlsl +++ b/include/nbl/builtin/hlsl/utility.hlsl @@ -1,40 +1,70 @@ -// Copyright (C) 2024 - DevSH Graphics Programming Sp. z O.O. -// This file is part of the "Nabla Engine". -// For conditions of distribution and use, see copyright notice in nabla.h -#ifndef _NBL_BUILTIN_HLSL_UTILITY_INCLUDED_ -#define _NBL_BUILTIN_HLSL_UTILITY_INCLUDED_ - - -#include - - -// for now we only implement declval -namespace nbl -{ -namespace hlsl -{ -template -const static bool always_true = true; -#ifndef __HLSL_VERSION - -template -std::add_rvalue_reference_t declval() noexcept -{ - static_assert(false,"Actually calling declval is ill-formed."); -} - -#else - -namespace experimental -{ - -template -T declval() {} - -} - -#endif -} -} - -#endif +// Copyright (C) 2024 - DevSH Graphics Programming Sp. z O.O. +// This file is part of the "Nabla Engine". +// For conditions of distribution and use, see copyright notice in nabla.h +#ifndef _NBL_BUILTIN_HLSL_UTILITY_INCLUDED_ +#define _NBL_BUILTIN_HLSL_UTILITY_INCLUDED_ + + +#include + + +namespace nbl +{ +namespace hlsl +{ + +template +struct pair +{ + using first_type = T1; + using second_type = T2; + + first_type first; + second_type second; +}; + +template +pair make_pair(T1 f, T2 s) +{ + pair p; + p.first = f; + p.second = s; + return p; +} + +template +void swap(NBL_REF_ARG(pair) a, NBL_REF_ARG(pair) b) +{ + T1 temp_first = a.first; + T2 temp_second = a.second; + a.first = b.first; + a.second = b.second; + b.first = temp_first; + b.second = temp_second; +} + +template +const static bool always_true = true; +#ifndef __HLSL_VERSION + +template +std::add_rvalue_reference_t declval() noexcept +{ + static_assert(false,"Actually calling declval is ill-formed."); +} + +#else + +namespace experimental +{ + +template +T declval() {} + +} + +#endif +} +} + +#endif diff --git a/include/nbl/builtin/hlsl/workgroup/bitonic_sort.hlsl b/include/nbl/builtin/hlsl/workgroup/bitonic_sort.hlsl new file mode 100644 index 0000000000..94cacd71cf --- /dev/null +++ b/include/nbl/builtin/hlsl/workgroup/bitonic_sort.hlsl @@ -0,0 +1,289 @@ +#ifndef _NBL_BUILTIN_HLSL_WORKGROUP_BITONIC_SORT_INCLUDED_ +#define _NBL_BUILTIN_HLSL_WORKGROUP_BITONIC_SORT_INCLUDED_ + +#include "nbl/builtin/hlsl/bitonic_sort/common.hlsl" +#include "nbl/builtin/hlsl/subgroup/bitonic_sort.hlsl" +#include "nbl/builtin/hlsl/workgroup/basic.hlsl" +#include "nbl/builtin/hlsl/memory_accessor.hlsl" + +namespace nbl +{ +namespace hlsl +{ +namespace workgroup +{ +namespace bitonic_sort +{ +using namespace nbl::hlsl::bitonic_sort; + +template< + uint16_t E_log2, + uint16_t WG_log2, + typename KeyType, + typename ValueType, + typename Comparator = less, + uint32_t SharedMemDWORDs = 16384u +> +struct bitonic_sort_config +{ + static const uint32_t ElementsPerThreadLog2 = E_log2; + static const uint32_t WorkgroupSizeLog2 = WG_log2; + static const uint32_t E = 1u << E_log2; + static const uint32_t WG = 1u << WG_log2; + static const uint32_t WorkgroupSize = WG; + static const uint32_t Total = WG * E; + static const uint32_t SharedmemDWORDs = SharedMemDWORDs; + + // R = number of elements that can fit in shared memory before barrier + // Required shared mem per element = 2 * sizeof(uint32_t) for key + index + static const uint32_t ElementsInShared = SharedMemDWORDs / 2u; // 2 DWORDs per element + + static const uint32_t R = (ElementsInShared < WG) ? ElementsInShared : WG; + + static const uint32_t Batches = (WG + R - 1u) / R; + + + using key_t = KeyType; + using value_t = ValueType; + using comparator_t = Comparator; + using WGType = WorkgroupType; +}; + +template +inline void atomicOpPairs( + bool ascending, + WorkgroupType elems[config::E], + NBL_CONST_REF_ARG(Comp) comp) +{ + + LocalPasses, 1, Comp> localSort; + + [unroll] + for (uint32_t pairIdx = 0u; pairIdx < config::E / 2u; ++pairIdx) + { + WorkgroupType pair[2]; + pair[0] = elems[pairIdx * 2u]; + pair[1] = elems[pairIdx * 2u + 1u]; + + localSort(ascending, pair, comp); + + elems[pairIdx * 2u] = pair[0]; + elems[pairIdx * 2u + 1u] = pair[1]; + } +} + +template +inline void inThreadShuffleSortPairs( + uint32_t stride, + bool ascending, + WorkgroupType elems[config::E], + NBL_CONST_REF_ARG(Comp) comp) +{ + uint32_t partner = stride >> 1; + + [unroll] + for (uint32_t i = 0u; i < config::E; i += stride) + { + uint32_t j = i + partner; + bool valid = j < config::E; + bool swap = valid && (comp(elems[j].key, elems[i].key) == ascending); + + WorkgroupType tmp = elems[i]; + + elems[i].key = swap ? elems[j].key : elems[i].key; + elems[i].workgroupRelativeIndex = swap ? elems[j].workgroupRelativeIndex : elems[i].workgroupRelativeIndex; + elems[j].key = swap ? tmp.key : elems[j].key; + elems[j].workgroupRelativeIndex = swap ? tmp.workgroupRelativeIndex : elems[j].workgroupRelativeIndex; + } +} + +template +inline void subgroupShuffleSortPairs( + uint32_t stride, + bool ascending, + WorkgroupType elems[config::E], + uint32_t subgroupInvocationID, + NBL_CONST_REF_ARG(Comp) comp) +{ + uint32_t partner = stride >> 1; + bool isUpper = (subgroupInvocationID & partner) != 0u; + + [unroll] + for (uint32_t i = 0u; i < config::E; i += 2u) + { + uint32_t j = i + 1u; + + typename config::key_t tradingKey = isUpper ? elems[j].key : elems[i].key; + uint32_t tradingIdx = isUpper ? elems[j].workgroupRelativeIndex : elems[i].workgroupRelativeIndex; + + tradingKey = glsl::subgroupShuffleXor(tradingKey, partner); + tradingIdx = glsl::subgroupShuffleXor(tradingIdx, partner); + + elems[i].key = isUpper ? elems[i].key : tradingKey; + elems[i].workgroupRelativeIndex = isUpper ? elems[i].workgroupRelativeIndex : tradingIdx; + elems[j].key = isUpper ? tradingKey : elems[j].key; + elems[j].workgroupRelativeIndex = isUpper ? tradingIdx : elems[j].workgroupRelativeIndex; + + bool swap = comp(elems[j].key, elems[i].key) == ascending; + WorkgroupType tmp = elems[i]; + + elems[i].key = swap ? elems[j].key : elems[i].key; + elems[i].workgroupRelativeIndex = swap ? elems[j].workgroupRelativeIndex : elems[i].workgroupRelativeIndex; + elems[j].key = swap ? tmp.key : elems[j].key; + elems[j].workgroupRelativeIndex = swap ? tmp.workgroupRelativeIndex : elems[j].workgroupRelativeIndex; + } +} + +template +inline void workgroupShuffleSortPairs( + uint32_t stride, + bool ascending, + WorkgroupType elems[config::E], + uint32_t tid, + NBL_REF_ARG(SMem) smem, + NBL_CONST_REF_ARG(Comp) comp) +{ + using K = accessor_adaptors::StructureOfArrays; + using I = accessor_adaptors::StructureOfArrays >; + + K k = K(smem); + I idx = I(smem); + + const uint32_t R = config::R; + const uint32_t A = config::Batches; + + bool isUpper = ((tid * config::E) & stride) != 0u; + + [unroll] + for (uint32_t a = 0u; a < A; ++a) + { + uint32_t start = a * R; + uint32_t end = min((a+1u)*R, config::WG); + bool active = (tid >= start) && (tid < end); + + [unroll] + for (uint32_t i = 0u; i < config::E/2; ++i) + { + uint32_t localIdx = isUpper ? (i + config::E/2) : i; + if (active && (localIdx < config::E)) + { + k.set(tid*config::E + localIdx, elems[localIdx].key); + idx.set(tid*config::E + localIdx, elems[localIdx].workgroupRelativeIndex); + } + } + smem.workgroupExecutionAndMemoryBarrier(); + + [unroll] + for (uint32_t i = 0u; i < config::E/2; ++i) + { + uint32_t localIdx = isUpper ? i : (i + config::E/2); + if (active && (localIdx < config::E)) + { + uint32_t myElemIdx = tid * config::E + (isUpper ? (i + config::E/2) : i); + uint32_t partnerElemIdx = myElemIdx ^ stride; + uint32_t pTid = partnerElemIdx / config::E; + uint32_t partnerLocalIdx = partnerElemIdx % config::E; + + k.get(pTid*config::E + partnerLocalIdx, elems[localIdx].key); + idx.get(pTid*config::E + partnerLocalIdx, elems[localIdx].workgroupRelativeIndex); + } + } + smem.workgroupExecutionAndMemoryBarrier(); + } + + atomicOpPairs(ascending, elems, comp); +} + +template +inline void ShufflesSort( + uint32_t stride, + bool ascending, + WorkgroupType elems[config::E], + uint32_t tid, + uint32_t subgroupInvocationID, + NBL_REF_ARG(SMem) smem, + NBL_CONST_REF_ARG(Comp) comp) +{ + if (stride == 1u) + { + atomicOpPairs(ascending, elems, comp); + return; + } + + const uint32_t E_half = config::E / 2u; + const uint32_t subgroupThreshold = E_half * glsl::gl_SubgroupSize(); + const uint32_t workgroupThreshold = E_half * config::WG; + + [flatten] + if (stride < E_half) + { + inThreadShuffleSortPairs(stride, ascending, elems, comp); + } + else [flatten] if (stride < subgroupThreshold) + { + subgroupShuffleSortPairs(stride, ascending, elems, subgroupInvocationID, comp); + } + else + { + workgroupShuffleSortPairs(stride, ascending, elems, tid, smem, comp); + } +} + +template +struct BitonicSort +{ + template + static void __call(Accessor acc, SMem smem) + { + uint32_t tid = glsl::gl_LocalInvocationID().x; + uint32_t subgroupInvocationID = glsl::gl_SubgroupInvocationID(); + WorkgroupType elems[config::E]; + + using KVPair = nbl::hlsl::pair; + + [unroll] + for (uint32_t i = 0u; i < config::E; ++i) + { + uint32_t idx = tid * config::E + i; + KVPair kvpair; + acc.template get(idx, kvpair); + elems[i].key = kvpair.first; + elems[i].workgroupRelativeIndex = kvpair.second; + } + + typename config::comparator_t comp; + + atomicOpPairs(true, elems, comp); + + for (uint32_t BigStride = 2u; BigStride <= config::Total; BigStride <<= 1u) + { + bool bitonicDir = ((tid * config::E) & BigStride) == 0u; + + ShufflesSort(BigStride, bitonicDir, elems, tid, subgroupInvocationID, smem, comp); + + [unroll] + for (uint32_t smallStride = BigStride >> 1u; smallStride >= 1u; smallStride >>= 1u) + { + bool mergeDir = ((tid * config::E) & smallStride) == 0u; + ShufflesSort(smallStride, mergeDir, elems, tid, subgroupInvocationID, smem, comp); + } + } + + [unroll] + for (uint32_t i = 0u; i < config::E; ++i) + { + KVPair output; + output.first = elems[i].key; + output.second = elems[i].workgroupRelativeIndex; + acc.template set(tid * config::E + i, output); + } + } +}; + +} // bitonic_sort +} // workgroup +} // hlsl +} // nbl + +#endif \ No newline at end of file diff --git a/src/nbl/builtin/CMakeLists.txt b/src/nbl/builtin/CMakeLists.txt index e8798499f9..872ee6ef31 100644 --- a/src/nbl/builtin/CMakeLists.txt +++ b/src/nbl/builtin/CMakeLists.txt @@ -15,7 +15,15 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "shader/loader/gltf/fragment_impl.g LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "shader/loader/gltf/uv.frag") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "shader/loader/gltf/color.frag") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "shader/loader/gltf/no_uv_color.frag") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "material/lambertian/singletexture/specialized_shader.vert") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "material/lambertian/singletexture/specialized_shader.frag") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "material/debug/vertex_color/specialized_shader.vert") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "material/debug/vertex_normal/specialized_shader.vert") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "material/debug/vertex_normal/specialized_shader.frag") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "material/debug/vertex_uv/specialized_shader.frag") # generic GLSL headers after this line +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/macros.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/algorithm.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/ieee754.glsl") # barycentric LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/barycentric/extensions.glsl") @@ -31,6 +39,30 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/bda/legacy_bda_accessor.hlsl" # bump mapping LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bump_mapping/fragment.glsl") # TODO: rename to `frag.glsl` LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bump_mapping/utils.glsl") +# bxdf +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bxdf/common.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bxdf/common_samples.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bxdf/fresnel.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bxdf/ndf/common.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bxdf/ndf/blinn_phong.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bxdf/ndf/beckmann.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bxdf/ndf/ggx.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bxdf/geom/smith/common.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bxdf/geom/smith/beckmann.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bxdf/geom/smith/ggx.glsl") +# brdf +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bxdf/brdf/diffuse/lambert.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bxdf/brdf/diffuse/oren_nayar.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bxdf/brdf/specular/blinn_phong.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bxdf/brdf/specular/beckmann.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bxdf/brdf/specular/ggx.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bxdf/brdf/diffuse/fresnel_correction.glsl") +# bsdf +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bxdf/bsdf/diffuse/lambert.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bxdf/bsdf/specular/common.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bxdf/bsdf/specular/dielectric.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bxdf/bsdf/specular/beckmann.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/bxdf/bsdf/specular/ggx.glsl") # colorspace LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/colorspace/EOTF.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/colorspace/OETF.glsl") @@ -55,15 +87,19 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/format/constants.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/loader/mtl/common.glsl") # LoD Library LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/lod_library/structs.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/lod_library/descriptor_set.glsl") # math and limits LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/math/constants.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/math/complex.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/math/functions.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/math/quaternions.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/math/typeless_arithmetic.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/limits/numeric.glsl") # material_compiler LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/material_compiler/common.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/material_compiler/common_declarations.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/material_compiler/common_invariant_declarations.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/material_compiler/rasterization/impl.glsl") # property pool LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/property_pool/transfer.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/property_pool/copy.comp") @@ -73,7 +109,6 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/random/xoroshiro.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/random/pcg.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/random/lcg.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/random/tea.hlsl") -LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/random/dim_adaptor_recursive.hlsl") # sampling LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/sampling/bilinear.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/sampling/box_muller_transform.glsl") @@ -84,6 +119,14 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/sampling/projected_spherical_ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/sampling/spherical_rectangle.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/sampling/spherical_triangle.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/sampling/quantized_sequence.glsl") +# global exclusive scan +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/scan/direct.comp") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/scan/declarations.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/scan/descriptors.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/scan/default_scheduler.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/scan/indirect.comp") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/scan/parameters_struct.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/scan/virtual_workgroup.glsl") # faster and easier scan LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/scanning_append/scanning_append.glsl") # scene @@ -102,11 +145,30 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/skinning/debug.vert") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/skinning/linear.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/skinning/render_descriptor_set.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/skinning/update_descriptor_set.glsl") +# subgroup emulation +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/subgroup/arithmetic_portability.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/subgroup/arithmetic_portability_impl.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/subgroup/basic_portability.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/subgroup/fft.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/subgroup/shared_arithmetic_portability.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/subgroup/shared_shuffle_portability.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/subgroup/shuffle_portability.glsl") # utilities LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/utils/common.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/utils/culling.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/utils/compressed_normal_matrix_t.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/utils/normal_decode.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/utils/normal_encode.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/utils/transform.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/utils/morton.glsl") +# workgroup "intrinsics" +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/workgroup/arithmetic.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/workgroup/basic.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/workgroup/ballot.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/workgroup/fft.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/workgroup/shared_arithmetic.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/workgroup/shared_ballot.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/workgroup/shared_fft.glsl") #transform_tree LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/transform_tree/global_transform_update.comp") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/transform_tree/global_transform_and_normal_matrix_update.comp") @@ -120,7 +182,14 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/transform_tree/relative_trans LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/transform_tree/relative_transform_update_common.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/transform_tree/relative_transform_update_descriptor_set.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/transform_tree/debug.vert") -# +# ext shouldn't be built into the engine, but there's no harm including some non-dynamic GLSL source to make life easier +#LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/ext/.glsl") +# radix sort +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/ext/FFT/default_compute_fft.comp") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/ext/FFT/fft.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/ext/FFT/parameters_struct.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/ext/FFT/parameters.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/ext/FFT/types.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/ext/LumaMeter/common.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/ext/LumaMeter/impl.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/ext/ToneMapper/operators.glsl") @@ -133,6 +202,10 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/ext/MitsubaLoader/material_co LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/ext/OIT/oit.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/ext/OIT/insert_node.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/ext/OIT/resolve.frag") +# virtual geometry +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/virtual_geometry/descriptors.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/virtual_geometry/virtual_attribute.glsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/virtual_geometry/virtual_attribute_fetch.glsl") # depth pyramid generator LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/ext/DepthPyramidGenerator/common.glsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/ext/DepthPyramidGenerator/push_constants_struct_common.h") @@ -141,7 +214,6 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/ext/DepthPyramidGenerator/vir # HLSL LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/macros.h") -LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/indirect_commands.hlsl") # emulated LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/emulated/float64_t.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/emulated/float64_t_impl.hlsl") @@ -195,6 +267,7 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/limits.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/type_traits.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/tuple.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/utility.hlsl") + #metaprogramming LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/mpl.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/member_test_macros.hlsl") @@ -218,7 +291,6 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/format/shared_exp.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/format.hlsl") #linear algebra LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/math/linalg/fast_affine.hlsl") -LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/math/linalg/transform.hlsl") # TODO: rename `equations` to `polynomials` probably LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/math/functions.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/math/geometry.hlsl") @@ -261,6 +333,8 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/ndarray_addressing.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/shapes/util.hlsl") #FFT LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/fft/common.hlsl") +#Bitonic_sort +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/bitonic_sort/common.hlsl") #sort LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/sort/common.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/sort/counting.hlsl") @@ -297,6 +371,7 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/subgroup/basic.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/subgroup/arithmetic_portability.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/subgroup/arithmetic_portability_impl.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/subgroup/fft.hlsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/subgroup/bitonic_sort.hlsl") #subgroup2 LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/subgroup2/ballot.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/subgroup2/arithmetic_params.hlsl") @@ -310,6 +385,7 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/workgroup/basic.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/workgroup/ballot.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/workgroup/broadcast.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/workgroup/fft.hlsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/workgroup/bitonic_sort.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/workgroup/scratch_size.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/workgroup/shared_scan.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/workgroup/shuffle.hlsl") @@ -343,6 +419,7 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/concepts/accessors/mip_mapped LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/concepts/accessors/storable_image.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/concepts/accessors/generic_shared_data.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/concepts/accessors/fft.hlsl") +LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/concepts/accessors/bitonic_sort.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/concepts/accessors/workgroup_arithmetic.hlsl") #tgmath LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/tgmath.hlsl") @@ -352,4 +429,4 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/tgmath/output_structs.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/prefix_sum_blur/blur.hlsl") LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/prefix_sum_blur/box_sampler.hlsl") -ADD_CUSTOM_BUILTIN_RESOURCES(nblBuiltinResourceData NBL_RESOURCES_TO_EMBED "${NBL_ROOT_PATH}/include" "nbl/builtin" "nbl::builtin" "${NBL_ROOT_PATH_BINARY}/include" "${NBL_ROOT_PATH_BINARY}/src" "STATIC" "INTERNAL") \ No newline at end of file +ADD_CUSTOM_BUILTIN_RESOURCES(nblBuiltinResourceData NBL_RESOURCES_TO_EMBED "${NBL_ROOT_PATH}/include" "nbl/builtin" "nbl::builtin" "${NBL_ROOT_PATH_BINARY}/include" "${NBL_ROOT_PATH_BINARY}/src" "STATIC" "INTERNAL")