Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cpp compat intrinsics refactor #801

Merged
merged 21 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples_tests
30 changes: 30 additions & 0 deletions include/nbl/builtin/hlsl/array_accessors.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef _NBL_BUILTIN_HLSL_ARRAY_ACCESSORS_HLSL_INCLUDED_
#define _NBL_BUILTIN_HLSL_ARRAY_ACCESSORS_HLSL_INCLUDED_

#include <nbl/builtin/hlsl/cpp_compat/basic.h>

namespace nbl
{
namespace hlsl
{
template<typename ArrayType, typename ComponentType, typename I = uint32_t>
struct array_get
{
ComponentType operator()(NBL_CONST_REF_ARG(ArrayType) arr, const I ix) NBL_CONST_MEMBER_FUNC
{
return arr[ix];
}
};

template<typename ArrayType, typename ComponentType, typename I = uint32_t>
struct array_set
{
void operator()(NBL_REF_ARG(ArrayType) arr, I index, ComponentType val) NBL_CONST_MEMBER_FUNC
{
arr[index] = val;
}
};
}
}

#endif
2 changes: 1 addition & 1 deletion include/nbl/builtin/hlsl/cpp_compat.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <nbl/builtin/hlsl/cpp_compat/basic.h>
// it includes vector and matrix
#include <nbl/builtin/hlsl/cpp_compat/intrinsics.h>
#include <nbl/builtin/hlsl/cpp_compat/intrinsics.hlsl>
#include <nbl/builtin/hlsl/cpp_compat/promote.hlsl>

#endif
8 changes: 6 additions & 2 deletions include/nbl/builtin/hlsl/cpp_compat/basic.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ namespace nbl::hlsl

// We need variadic macro in order to handle multi parameter templates because the
// preprocessor parses the template parameters as different macro parameters.
#define NBL_REF_ARG(...) typename nbl::hlsl::add_reference<__VA_ARGS__ >::type
#define NBL_CONST_REF_ARG(...) typename nbl::hlsl::add_reference<std::add_const_t<__VA_ARGS__ >>::type
#define NBL_REF_ARG(...) __VA_ARGS__&
#define NBL_CONST_REF_ARG(...) const __VA_ARGS__&

// NOTE: implementation below will mess up template parameter deduction
//#define NBL_REF_ARG(...) typename nbl::hlsl::add_reference<__VA_ARGS__ >::type
//#define NBL_CONST_REF_ARG(...) typename nbl::hlsl::add_reference<std::add_const_t<__VA_ARGS__ >>::type

#else

Expand Down
144 changes: 0 additions & 144 deletions include/nbl/builtin/hlsl/cpp_compat/intrinsics.h

This file was deleted.

Loading