Skip to content

Commit e391e99

Browse files
authored
Merge pull request #597 from Devsh-Graphics-Programming/examples_rewrite
Examples Rewrite
2 parents 05476da + 338ea05 commit e391e99

30 files changed

+264
-249
lines changed

3rdparty/nbl_spirv_cross

Submodule nbl_spirv_cross updated 1128 files

include/nbl/asset/IDescriptorSetLayout.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,9 @@ class IDescriptorSetLayout : public virtual core::IReferenceCounted
278278
{
279279
bindings[i].binding = i;
280280
bindings[i].type = type;
281-
bindings[i].count = counts ? counts[i]:1u;
281+
bindings[i].createFlags = SBinding::E_CREATE_FLAGS::ECF_NONE;
282282
bindings[i].stageFlags = stageAccessFlags ? stageAccessFlags[i]:asset::IShader::ESS_ALL;
283+
bindings[i].count = counts ? counts[i]:1u;
283284
bindings[i].samplers = nullptr;
284285
}
285286
}

include/nbl/asset/utils/CSPIRVIntrospector.h

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,36 @@ namespace nbl::asset
3333
class NBL_API2 CSPIRVIntrospector : public core::Uncopyable
3434
{
3535
public:
36-
37-
class NBL_API2 CIntrospectionData : public core::IReferenceCounted
36+
static IDescriptor::E_TYPE resType2descType(E_SHADER_RESOURCE_TYPE _t)
3837
{
38+
switch (_t)
39+
{
40+
case ESRT_COMBINED_IMAGE_SAMPLER:
41+
return IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER;
42+
break;
43+
case ESRT_STORAGE_IMAGE:
44+
return IDescriptor::E_TYPE::ET_STORAGE_IMAGE;
45+
break;
46+
case ESRT_UNIFORM_TEXEL_BUFFER:
47+
return IDescriptor::E_TYPE::ET_UNIFORM_TEXEL_BUFFER;
48+
break;
49+
case ESRT_STORAGE_TEXEL_BUFFER:
50+
return IDescriptor::E_TYPE::ET_STORAGE_TEXEL_BUFFER;
51+
break;
52+
case ESRT_UNIFORM_BUFFER:
53+
return IDescriptor::E_TYPE::ET_UNIFORM_BUFFER;
54+
break;
55+
case ESRT_STORAGE_BUFFER:
56+
return IDescriptor::E_TYPE::ET_STORAGE_BUFFER;
57+
break;
58+
default:
59+
break;
60+
}
61+
return IDescriptor::E_TYPE::ET_COUNT;
62+
}
63+
64+
class NBL_API2 CIntrospectionData : public core::IReferenceCounted
65+
{
3966
protected:
4067
~CIntrospectionData();
4168

@@ -64,6 +91,7 @@ class NBL_API2 CSPIRVIntrospector : public core::Uncopyable
6491

6592
struct {
6693
bool present;
94+
core::string name;
6795
SShaderPushConstant info;
6896
} pushConstant;
6997

include/nbl/asset/utils/ShaderRes.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,6 @@ struct SShaderMemoryBlock
137137

138138
SMember::SMembers members;
139139

140-
//! Note: for SSBOs and UBOs it's the block name, but for push_constant it's the instance name.
141-
std::string name;
142-
143140
//! size!=rtSizedArrayOneElementSize implies that last member is rutime-sized array (e.g. buffer SSBO { float buf[]; }).
144141
//! Use getRuntimeSize for size of the struct with assumption of passed number of elements.
145142
size_t size;
@@ -174,6 +171,8 @@ struct SShaderPushConstant : public impl::SShaderMemoryBlock
174171

175172
struct SShaderResourceVariant
176173
{
174+
//! Note: for SSBOs and UBOs it's the block name, but for push_constant it's the instance name.
175+
std::string name;
177176
//! binding
178177
uint32_t binding;
179178
E_SHADER_RESOURCE_TYPE type;
@@ -186,6 +185,7 @@ struct SShaderResourceVariant
186185
//! Then user can look up default value of this specialization constant in SIntrospectionData::specConstants.
187186
bool descCountIsSpecConstant;
188187

188+
189189
template<E_SHADER_RESOURCE_TYPE restype>
190190
SShaderResource<restype>& get() { return reinterpret_cast<SShaderResource<restype>&>(variant); }
191191
template<E_SHADER_RESOURCE_TYPE restype>

include/nbl/builtin/hlsl/cpp_compat.hlsl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ using add_pointer = std::add_pointer<T>;
3333
#define NBL_REF_ARG(T) typename nbl::hlsl::add_reference<T>::type
3434
#define NBL_CONST_REF_ARG(T) typename nbl::hlsl::add_reference<std::add_const_t<T>>::type
3535

36-
// it includes vector and matrix
37-
#include <nbl/builtin/hlsl/cpp_compat/intrinsics.h>
38-
3936
#else
4037

4138
#define ARROW .arrow().
@@ -68,4 +65,7 @@ struct add_pointer
6865

6966
#endif
7067

68+
// it includes vector and matrix
69+
#include <nbl/builtin/hlsl/cpp_compat/intrinsics.h>
70+
7171
#endif

include/nbl/builtin/hlsl/cpp_compat/matrix.hlsl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
#include <nbl/builtin/hlsl/cpp_compat/vector.hlsl>
55

6-
#ifndef __HLSL_VERSION
7-
namespace nbl::hlsl
6+
namespace nbl
87
{
9-
8+
namespace hlsl
9+
{
10+
#ifndef __HLSL_VERSION
1011
template<typename T, uint16_t N, uint16_t M>
1112
struct matrix final : private glm::mat<N,M,T>
1213
{
@@ -55,12 +56,13 @@ struct matrix final : private glm::mat<N,M,T>
5556
return glm::transpose(reinterpret_cast<Base const&>(m));
5657
}
5758
};
59+
#endif
5860

5961

6062
#define NBL_TYPEDEF_MATRICES_FOR_ROW(T, R) \
61-
using T ## R ## x4 = matrix<T, R, 4>; \
62-
using T ## R ## x3 = matrix<T, R, 3>; \
63-
using T ## R ## x2 = matrix<T, R, 2>;
63+
typedef matrix<T, R, 4> T ## R ## x4; \
64+
typedef matrix<T, R, 3> T ## R ## x3; \
65+
typedef matrix<T, R, 2> T ## R ## x2;
6466

6567
#define NBL_TYPEDEF_MATRICES_FOR_SCALAR(T) \
6668
NBL_TYPEDEF_MATRICES_FOR_ROW(T, 4) \
@@ -80,8 +82,7 @@ NBL_TYPEDEF_MATRICES_FOR_SCALAR(float64_t);
8082

8183
#undef NBL_TYPEDEF_MATRICES_FOR_ROW
8284
#undef NBL_TYPEDEF_MATRICES_FOR_SCALAR
83-
8485
}
85-
#endif
86+
}
8687

8788
#endif
Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,21 @@
11
#ifndef _NBL_BUILTIN_HLSL_CPP_COMPAT_VECTOR_INCLUDED_
22
#define _NBL_BUILTIN_HLSL_CPP_COMPAT_VECTOR_INCLUDED_
33

4+
// stuff for C++
45
#ifndef __HLSL_VERSION
6+
#include <stdint.h>
7+
8+
#include <half.h>
59

610
#define GLM_FORCE_SWIZZLE
711
#include <glm/glm.hpp>
812
#include <glm/detail/_swizzle.hpp>
9-
#include <stdint.h>
10-
#include <half.h>
1113

1214
namespace nbl::hlsl
1315
{
14-
1516
template<typename T, uint16_t N>
1617
using vector = glm::vec<N, T>;
1718

18-
// ideally we should have sized bools, but no idea what they'd be
19-
using bool4 = vector<bool, 4>;
20-
using bool3 = vector<bool, 3>;
21-
using bool2 = vector<bool, 2>;
22-
using bool1 = vector<bool, 1>;
23-
24-
using int32_t4 = vector<int32_t, 4>;
25-
using int32_t3 = vector<int32_t, 3>;
26-
using int32_t2 = vector<int32_t, 2>;
27-
using int32_t1 = vector<int32_t, 1>;
28-
29-
using uint32_t4 = vector<uint32_t, 4>;
30-
using uint32_t3 = vector<uint32_t, 3>;
31-
using uint32_t2 = vector<uint32_t, 2>;
32-
using uint32_t1 = vector<uint32_t, 1>;
33-
34-
// TODO: halfN -> needs class implementation or C++23 std:float16_t
35-
36-
using float16_t = half;
37-
using float16_t4 = vector<float16_t, 4>;
38-
using float16_t3 = vector<float16_t, 3>;
39-
using float16_t2 = vector<float16_t, 2>;
40-
using float16_t1 = vector<float16_t, 1>;
41-
42-
using float32_t = float;
43-
using float32_t4 = vector<float32_t, 4>;
44-
using float32_t3 = vector<float32_t, 3>;
45-
using float32_t2 = vector<float32_t, 2>;
46-
using float32_t1 = vector<float32_t, 1>;
47-
48-
using float64_t = double;
49-
using float64_t4 = vector<float64_t, 4>;
50-
using float64_t3 = vector<float64_t, 3>;
51-
using float64_t2 = vector<float64_t, 2>;
52-
using float64_t1 = vector<float64_t, 1>;
53-
5419
template<typename T, uint16_t N>
5520
glm::vec<N, bool> operator<(const glm::vec<N, T>& lhs, const glm::vec<N, T>& rhs)
5621
{
@@ -77,4 +42,38 @@ glm::vec<N, bool> operator>=(const glm::vec<N, T>& lhs, const glm::vec<N, T>& rh
7742
}
7843
#endif
7944

45+
// general typedefs for both langs
46+
namespace nbl
47+
{
48+
namespace hlsl
49+
{
50+
typedef half float16_t;
51+
typedef float float32_t;
52+
typedef double float64_t;
53+
54+
#define NBL_TYPEDEF_VECTORS(T) \
55+
typedef vector<T,4> T ## 4; \
56+
typedef vector<T,3> T ## 3; \
57+
typedef vector<T,2> T ## 2; \
58+
typedef vector<T,1> T ## 1
59+
60+
// ideally we should have sized bools, but no idea what they'd be
61+
NBL_TYPEDEF_VECTORS(bool);
62+
63+
NBL_TYPEDEF_VECTORS(int16_t);
64+
NBL_TYPEDEF_VECTORS(int32_t);
65+
NBL_TYPEDEF_VECTORS(int64_t);
66+
67+
NBL_TYPEDEF_VECTORS(uint16_t);
68+
NBL_TYPEDEF_VECTORS(uint32_t);
69+
NBL_TYPEDEF_VECTORS(uint64_t);
70+
71+
NBL_TYPEDEF_VECTORS(float16_t);
72+
NBL_TYPEDEF_VECTORS(float32_t);
73+
NBL_TYPEDEF_VECTORS(float64_t);
74+
75+
#undef NBL_TYPEDEF_VECTORS
76+
}
77+
}
78+
8079
#endif

include/nbl/builtin/hlsl/limits.hlsl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// C++ headers
1111
#ifndef __HLSL_VERSION
1212
#include <limits>
13-
#include <openexr/IlmBase/Imath/ImathHalfLimits.h>
13+
#include "halfLimits.h"
1414
#endif
1515

1616
/*
@@ -262,9 +262,9 @@ struct numeric_limits : impl::numeric_limits<T> {};
262262

263263

264264
template<class T>
265-
struct numeric_limits : std::conditional_t<std::is_same_v<T,float16_t>,IMATH_INTERNAL_NAMESPACE::limits<T>,std::numeric_limits<T>>
265+
struct numeric_limits : std::numeric_limits<T>
266266
{
267-
using base = std::conditional_t<std::is_same_v<T,float16_t>,IMATH_INTERNAL_NAMESPACE::limits<T>,std::numeric_limits<T>>;
267+
using base = std::numeric_limits<T>;
268268
using uint_type = std::remove_cvref_t<decltype(impl::num_traits<T>::infinity)>;
269269

270270
NBL_CONSTEXPR_STATIC_INLINE T min = base::min();

include/nbl/core/decl/smart_refctd_ptr.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ template< class U, class T >
124124
smart_refctd_ptr<U> smart_refctd_ptr_static_cast(smart_refctd_ptr<T>&& smart_ptr);
125125

126126
template< class U, class T >
127-
smart_refctd_ptr<U> move_and_static_cast(smart_refctd_ptr<T>&& smart_ptr);
127+
smart_refctd_ptr<U> move_and_static_cast(smart_refctd_ptr<T>& smart_ptr);
128+
template< class U, class T >
129+
smart_refctd_ptr<U> move_and_static_cast(smart_refctd_ptr<T>&& smart_ptr) {return move_and_static_cast<U,T>(smart_ptr);}
128130

129131

130132
template< class U, class T >
@@ -133,7 +135,9 @@ template< class U, class T >
133135
smart_refctd_ptr<U> smart_refctd_ptr_dynamic_cast(smart_refctd_ptr<T>&& smart_ptr);
134136

135137
template< class U, class T >
136-
smart_refctd_ptr<U> move_and_dynamic_cast(smart_refctd_ptr<T>&& smart_ptr);
138+
smart_refctd_ptr<U> move_and_dynamic_cast(smart_refctd_ptr<T>& smart_ptr);
139+
template< class U, class T >
140+
smart_refctd_ptr<U> move_and_dynamic_cast(smart_refctd_ptr<T>&& smart_ptr) {return move_and_dynamic_cast<U,T>(smart_ptr);}
137141

138142
} // end namespace nbl::core
139143

0 commit comments

Comments
 (0)