Skip to content

Commit 1cf36f7

Browse files
committed
device cap traits
1 parent 8ffcce7 commit 1cf36f7

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

include/nbl/builtin/hlsl/device_capabilities_traits.hlsl

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,44 @@
77
#include <nbl/builtin/hlsl/member_test_macros.hlsl>
88

99
#ifdef __HLSL_VERSION
10+
11+
NBL_GENERATE_MEMBER_TESTER(shaderFloat64);
12+
NBL_GENERATE_MEMBER_TESTER(shaderDrawParameters);
13+
NBL_GENERATE_MEMBER_TESTER(subgroupArithmetic);
14+
NBL_GENERATE_MEMBER_TESTER(fragmentShaderPixelInterlock);
15+
NBL_GENERATE_MEMBER_TESTER(maxOptimallyResidentWorkgroupInvocations);
16+
17+
#define NBL_GENERATE_GET_OR_DEFAULT(field, ty, default) \
18+
template<typename S, bool = has_member_##field<S>::value> struct get_or_default_##field : integral_constant<ty,S::field> {}; \
19+
template<typename S> struct get_or_default_##field<S,false> : integral_constant<ty,default> {};
20+
1021
namespace nbl
1122
{
1223
namespace hlsl
1324
{
25+
26+
namespace impl
27+
{
28+
NBL_GENERATE_GET_OR_DEFAULT(shaderFloat64, bool, false);
29+
NBL_GENERATE_GET_OR_DEFAULT(shaderDrawParameters, bool, false);
30+
NBL_GENERATE_GET_OR_DEFAULT(subgroupArithmetic, bool, false);
31+
NBL_GENERATE_GET_OR_DEFAULT(fragmentShaderPixelInterlock, bool, false);
32+
NBL_GENERATE_GET_OR_DEFAULT(maxOptimallyResidentWorkgroupInvocations, uint16_t, 0);
33+
}
34+
35+
1436
template<typename device_capabilities>
1537
struct device_capabilities_traits
1638
{
17-
// TODO: check for members and default them to sane things, only do the 5 members in CJITIncludeLoader.cpp struct, we'll do the rest on `vulkan_1_3` branch with Nahim
39+
NBL_CONSTEXPR_STATIC_INLINE bool shaderFloat64 = impl::get_or_default_shaderFloat64<device_capabilities>::value;
40+
NBL_CONSTEXPR_STATIC_INLINE bool shaderDrawParameters = impl::get_or_default_shaderDrawParameters<device_capabilities>::value;
41+
NBL_CONSTEXPR_STATIC_INLINE bool subgroupArithmetic = impl::get_or_default_subgroupArithmetic<device_capabilities>::value;
42+
NBL_CONSTEXPR_STATIC_INLINE bool fragmentShaderPixelInterlock = impl::get_or_default_fragmentShaderPixelInterlock<device_capabilities>::value;
43+
NBL_CONSTEXPR_STATIC_INLINE uint16_t maxOptimallyResidentWorkgroupInvocations = impl::get_or_default_maxOptimallyResidentWorkgroupInvocations<device_capabilities>::value;
1844
};
45+
46+
#undef NBL_GENERATE_GET_OR_DEFAULT
47+
1948
}
2049
}
2150
#endif

0 commit comments

Comments
 (0)