Skip to content

Commit 1228f5f

Browse files
committed
Merge branch 'vulkan_1_3' into suballocdescriptorset
2 parents 59c65ae + 240372a commit 1228f5f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2368
-754
lines changed

3rdparty/dxc/dxc

Submodule dxc updated 311 files

include/nbl/asset/ECommonEnums.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,15 @@ NBL_ENUM_ADD_BITWISE_OPERATORS(ACCESS_FLAGS)
145145

146146
struct SMemoryBarrier
147147
{
148+
// TODO: pack these up into just `src` and `dst` with another struct
148149
core::bitflag<PIPELINE_STAGE_FLAGS> srcStageMask = PIPELINE_STAGE_FLAGS::NONE;
149150
core::bitflag<ACCESS_FLAGS> srcAccessMask = ACCESS_FLAGS::NONE;
150151
core::bitflag<PIPELINE_STAGE_FLAGS> dstStageMask = PIPELINE_STAGE_FLAGS::NONE;
151152
core::bitflag<ACCESS_FLAGS> dstAccessMask = ACCESS_FLAGS::NONE;
152153

153154
auto operator<=>(const SMemoryBarrier&) const = default;
154155

155-
// utilities
156+
// Make the immediately previous barrier after this one
156157
inline SMemoryBarrier prevBarrier(const core::bitflag<PIPELINE_STAGE_FLAGS> prevStageMask, const core::bitflag<ACCESS_FLAGS> prevAccessMask) const
157158
{
158159
return {
@@ -162,6 +163,12 @@ struct SMemoryBarrier
162163
.dstAccessMask = srcAccessMask
163164
};
164165
}
166+
// Make the immediately previous barrier if you know the penultimate, as in one before the last (previous)
167+
inline SMemoryBarrier prevBarrier(const SMemoryBarrier& penultimate) const
168+
{
169+
return prevBarrier(penultimate.dstStageMask,penultimate.dstAccessMask);
170+
}
171+
// Make the immediately next barrier after this one
165172
inline SMemoryBarrier nextBarrier(const core::bitflag<PIPELINE_STAGE_FLAGS> nextStageMask, const core::bitflag<ACCESS_FLAGS> nextAccessMask) const
166173
{
167174
return {
@@ -171,6 +178,11 @@ struct SMemoryBarrier
171178
.dstAccessMask = nextAccessMask
172179
};
173180
}
181+
// Make the immediately next barrier, if you know the barrier thats after the immediately next one
182+
inline SMemoryBarrier nextBarrier(const SMemoryBarrier& twoAhead) const
183+
{
184+
return prevBarrier(twoAhead.srcStageMask,twoAhead.srcAccessMask);
185+
}
174186
};
175187

176188
inline core::bitflag<ACCESS_FLAGS> allAccessesFromStages(core::bitflag<PIPELINE_STAGE_FLAGS> stages)

include/nbl/asset/ICPUFramebuffer.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
#ifndef __NBL_I_CPU_FRAMEBUFFER_H_INCLUDED__
2-
#define __NBL_I_CPU_FRAMEBUFFER_H_INCLUDED__
1+
#ifndef _NBL_I_CPU_FRAMEBUFFER_H_INCLUDED_
2+
#define _NBL_I_CPU_FRAMEBUFFER_H_INCLUDED_
33

44
#include "nbl/asset/IFramebuffer.h"
55
#include "nbl/asset/IAsset.h"
66
#include "nbl/asset/ICPUImageView.h"
77
#include "nbl/asset/ICPURenderpass.h"
88

9-
namespace nbl {
10-
namespace asset
9+
namespace nbl::asset
1110
{
1211

13-
class ICPUFramebuffer final : public IAsset, public IFramebuffer<ICPURenderpass, ICPUImageView>
12+
class ICPUFramebuffer final : public IAsset, public IFramebuffer<ICPURenderpass,ICPUImageView>
1413
{
15-
using base_t = IFramebuffer<ICPURenderpass, ICPUImageView>;
14+
using base_t = IFramebuffer<ICPURenderpass,ICPUImageView>;
1615

1716
public:
1817
using base_t::base_t;
@@ -49,6 +48,4 @@ class ICPUFramebuffer final : public IAsset, public IFramebuffer<ICPURenderpass,
4948
};
5049

5150
}
52-
}
53-
5451
#endif

include/nbl/asset/IFramebuffer.h

Lines changed: 167 additions & 154 deletions
Large diffs are not rendered by default.

include/nbl/asset/IRenderpass.h

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,11 @@ class IRenderpass
169169
using SColorAttachmentsRef = SRenderAttachmentsRef<SColorAttachmentRef>;
170170

171171

172-
auto operator<=>(const SSubpassDescription&) const = default;
172+
//
173+
bool operator!=(const SSubpassDescription&) const;
174+
inline bool operator==(const SSubpassDescription& rhs) const {return !((*this)!=rhs);}
173175

176+
//
174177
bool valid(const SCreationParams& params, const uint32_t depthStencilAttachmentCount, const uint32_t colorAttachmentCount) const;
175178

176179

@@ -255,16 +258,16 @@ class IRenderpass
255258

256259
inline const SCreationParams& getCreationParameters() const { return m_params; }
257260

258-
inline uint32_t getDepthStencilAttachmentCount() const { return m_depthStencilAttachments->size(); }
259-
inline uint32_t getColorAttachmentCount() const { return m_colorAttachments->size(); }
260-
inline uint32_t getDepthStencilLoadOpAttachmentEnd() const { return m_loadOpDepthStencilAttachmentEnd; }
261-
inline uint32_t getColorLoadOpAttachmentEnd() const { return m_loadOpColorAttachmentEnd; }
261+
inline uint32_t getDepthStencilAttachmentCount() const {return m_depthStencilAttachments ? (m_depthStencilAttachments->size()-1):0;}
262+
inline uint32_t getColorAttachmentCount() const {return m_colorAttachments ? (m_colorAttachments->size()-1):0;}
263+
inline uint32_t getDepthStencilLoadOpAttachmentEnd() const {return m_loadOpDepthStencilAttachmentEnd;}
264+
inline uint32_t getColorLoadOpAttachmentEnd() const {return m_loadOpColorAttachmentEnd;}
262265

263-
inline uint32_t getSubpassCount() const { return m_subpasses->size(); }
264-
inline uint32_t getDependencyCount() const { return m_subpassDependencies->size(); }
266+
inline uint32_t getSubpassCount() const {return m_subpasses->size()-1;}
267+
inline uint32_t getDependencyCount() const {return m_subpassDependencies ? (m_subpassDependencies->size()-1):0;}
265268

266-
inline bool hasViewMasks() const { return m_viewMaskMSB>0; }
267-
inline int8_t getViewMaskMSB() const { return m_viewMaskMSB; }
269+
inline bool hasViewMasks() const {return m_viewMaskMSB>0;}
270+
inline int8_t getViewMaskMSB() const {return m_viewMaskMSB;}
268271

269272

270273
struct SCreationParamValidationResult final
@@ -367,7 +370,11 @@ inline IRenderpass::SCreationParamValidationResult IRenderpass::validateCreation
367370
return retval;
368371

369372
retval.subpassCount = 0xdeadbeefu;
370-
auto setRetvalFalse = [&retval]()->bool{retval.subpassCount = 0; return false;};
373+
auto setRetvalFalse = [&retval]()->bool
374+
{
375+
retval.subpassCount = 0; return false;
376+
};
377+
371378
core::visit_token_terminated_array(params.depthStencilAttachments,SCreationParams::DepthStencilAttachmentsEnd,[&params,setRetvalFalse,&retval](const SCreationParams::SDepthStencilAttachmentDescription& attachment)->bool
372379
{
373380
if (!attachment.valid())
@@ -500,6 +507,27 @@ inline bool IRenderpass::SCreationParams::SColorAttachmentDescription::valid() c
500507
}
501508

502509

510+
inline bool IRenderpass::SCreationParams::SSubpassDescription::operator!=(const SSubpassDescription& other) const
511+
{
512+
if (depthStencilAttachment!=other.depthStencilAttachment)
513+
return true;
514+
for (auto i=0u; i<MaxColorAttachments; i++)
515+
if (colorAttachments[i]!=other.colorAttachments[i])
516+
return true;
517+
auto tokenTerminatedSequenceUnequal = []<typename T>(const T* lhs, const T* rhs, const T& endToken) -> bool
518+
{
519+
while ((*lhs)!=endToken && (*rhs)!=endToken)
520+
if ((*lhs)!=(*rhs))
521+
return true;
522+
return (*lhs)!=(*rhs);
523+
};
524+
if (tokenTerminatedSequenceUnequal(inputAttachments,other.inputAttachments,InputAttachmentsEnd))
525+
return true;
526+
if (tokenTerminatedSequenceUnequal(preserveAttachments,other.preserveAttachments,PreserveAttachmentsEnd))
527+
return true;
528+
return viewMask!=other.viewMask || flags!=other.flags;
529+
}
530+
503531
inline bool IRenderpass::SCreationParams::SSubpassDescription::valid(const SCreationParams& params, const uint32_t depthStencilAttachmentCount, const uint32_t colorAttachmentCount) const
504532
{
505533
// TODO: https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkSubpassDescription2-pNext-06870
Lines changed: 59 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,76 @@
11
// Copyright (C) 2018-2020 - DevSH Graphics Programming Sp. z O.O.
22
// This file is part of the "Nabla Engine".
33
// For conditions of distribution and use, see copyright notice in nabla.h
4+
#ifndef _NBL_ASSET_E_COLOR_SPACE_H_INCLUDED_
5+
#define _NBL_ASSET_E_COLOR_SPACE_H_INCLUDED_
46

5-
#ifndef __NBL_ASSET_E_COLOR_SPACE_H_INCLUDED__
6-
#define __NBL_ASSET_E_COLOR_SPACE_H_INCLUDED__
7-
8-
namespace nbl
7+
// TODO: move to HLSL and turn into enum classes (when 8bit int comes)
8+
namespace nbl::asset
99
{
10-
namespace asset
11-
{
12-
//! Specifies a color space of an image
13-
enum E_COLOR_PRIMARIES
14-
{
15-
//! Specifies support for the sRGB color space. The primaries are the same for scRGB and BT709, only EOTFs differ.
16-
ECP_SRGB,
17-
18-
//! Specifies support for the Display-P3 color space to be displayed using an sRGB-like EOTF.
19-
ECP_DISPLAY_P3,
20-
21-
//! Specifies support for the DCI-P3 color space to be displayed using the DCI-P3 EOTF. Note that values in such an image are interpreted as XYZ encoded color data by the presentation engine.
22-
ECP_DCI_P3,
23-
24-
//! Specifies support for the BT2020 color space to be displayed using a linear EOTF. Same primaries are used for HDR10 and DolbyVision
25-
ECP_BT2020,
26-
27-
//! Specifies support for the AdobeRGB color space to be displayed.
28-
ECP_ADOBERGB,
10+
//! Specifies a color space of an image
11+
enum E_COLOR_PRIMARIES : uint8_t
12+
{
13+
//! Specifies support for the sRGB color space. The primaries are the same for scRGB and BT709, only EOTFs differ.
14+
ECP_SRGB,
2915

30-
//! The reference ACES color space, not really supported by any graphics API for display/swapchain
31-
ECP_ACES,
16+
//! Specifies support for the Display-P3 color space to be displayed using an sRGB-like EOTF.
17+
ECP_DISPLAY_P3,
3218

33-
//! The slightly different primary space for ACES with quantization (ACEScc and ACEScct use same primaries)
34-
ECP_ACES_CC_T,
19+
//! Specifies support for the DCI-P3 color space to be displayed using the DCI-P3 EOTF. Note that values in such an image are interpreted as XYZ encoded color data by the presentation engine.
20+
ECP_DCI_P3,
3521

36-
//! Specifies that color components are used �as is�. This is intended to allow applications to supply data for color spaces not described here.
37-
ECP_PASS_THROUGH,
22+
//! Specifies support for the BT2020 color space to be displayed using a linear EOTF. Same primaries are used for HDR10 and DolbyVision
23+
ECP_BT2020,
3824

39-
//! For internal
40-
ECP_COUNT
41-
};
25+
//! Specifies support for the AdobeRGB color space to be displayed.
26+
ECP_ADOBERGB,
4227

43-
//! Data to linear value for images
44-
enum ELECTRO_OPTICAL_TRANSFER_FUNCTION
45-
{
46-
EOTF_IDENTITY,
47-
EOTF_sRGB,
48-
EOTF_DCI_P3_XYZ,
49-
EOTF_SMPTE_170M,
50-
EOTF_SMPTE_ST2084,
51-
EOTF_HDR10_HLG,
52-
EOTF_GAMMA_2_2,
53-
EOTF_ACEScc,
54-
EOTF_ACEScct,
28+
//! The reference ACES color space, not really supported by any graphics API for display/swapchain
29+
ECP_ACES,
5530

56-
EOTF_UNKNOWN
57-
};
31+
//! The slightly different primary space for ACES with quantization (ACEScc and ACEScct use same primaries)
32+
ECP_ACES_CC_T,
5833

59-
//! Linear value to data for displays and swapchains
60-
enum OPTICO_ELECTRICAL_TRANSFER_FUNCTION
61-
{
62-
OETF_IDENTITY,
63-
OETF_sRGB,
64-
OETF_DCI_P3_XYZ,
65-
OETF_SMPTE_170M,
66-
OETF_SMPTE_ST2084,
67-
OETF_HDR10_HLG,
68-
OETF_GAMMA_2_2,
69-
OETF_ACEScc,
70-
OETF_ACEScct,
34+
//! Specifies that color components are used �as is�. This is intended to allow applications to supply data for color spaces not described here.
35+
ECP_PASS_THROUGH,
7136

72-
OETF_UNKNOWN
73-
};
37+
//! For internal
38+
ECP_COUNT
39+
};
7440

75-
static_assert(EOTF_UNKNOWN == static_cast<ELECTRO_OPTICAL_TRANSFER_FUNCTION>(OETF_UNKNOWN), "Definitions of transfer functions don't match");
76-
}
41+
//! Data to linear value for images
42+
enum ELECTRO_OPTICAL_TRANSFER_FUNCTION : uint8_t
43+
{
44+
EOTF_IDENTITY,
45+
EOTF_sRGB,
46+
EOTF_DCI_P3_XYZ,
47+
EOTF_SMPTE_170M,
48+
EOTF_SMPTE_ST2084,
49+
EOTF_HDR10_HLG,
50+
EOTF_GAMMA_2_2,
51+
EOTF_ACEScc,
52+
EOTF_ACEScct,
53+
54+
EOTF_UNKNOWN
55+
};
56+
57+
//! Linear value to data for displays and swapchains
58+
enum OPTICO_ELECTRICAL_TRANSFER_FUNCTION : uint8_t
59+
{
60+
OETF_IDENTITY,
61+
OETF_sRGB,
62+
OETF_DCI_P3_XYZ,
63+
OETF_SMPTE_170M,
64+
OETF_SMPTE_ST2084,
65+
OETF_HDR10_HLG,
66+
OETF_GAMMA_2_2,
67+
OETF_ACEScc,
68+
OETF_ACEScct,
69+
70+
OETF_UNKNOWN
71+
};
72+
73+
static_assert(EOTF_UNKNOWN == static_cast<ELECTRO_OPTICAL_TRANSFER_FUNCTION>(OETF_UNKNOWN), "Definitions of transfer functions don't match");
7774
}
7875

7976
#endif

include/nbl/builtin/hlsl/cpp_compat/intrinsics.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ inline matrix<T,M,N> transpose(const matrix<T,N,M>& m)
7171
return glm::transpose(reinterpret_cast<typename matrix<T,N,M>::Base const&>(m));
7272
}
7373

74+
template<typename T>
75+
inline T bitfieldExtract( T val, uint32_t offsetBits, uint32_t numBits )
76+
{
77+
return glm::bitfieldExtract( val, int32_t( offsetBits ), int32_t( numBits ) );
78+
}
7479

7580
#undef NBL_BIT_OP_GLM_PASSTHROUGH
7681
#undef NBL_SIMPLE_GLM_PASSTHROUGH

include/nbl/builtin/hlsl/glsl_compat/core.hlsl

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "nbl/builtin/hlsl/cpp_compat.hlsl"
88
#include "nbl/builtin/hlsl/spirv_intrinsics/core.hlsl"
9+
#include "nbl/builtin/hlsl/type_traits.hlsl"
910

1011
namespace nbl
1112
{
@@ -18,7 +19,7 @@ namespace glsl
1819
template<typename T>
1920
T atomicAdd(NBL_REF_ARG(T) ptr, T value)
2021
{
21-
return spirv::atomicAnd<T>(ptr, spv::ScopeDevice, spv::DecorationRelaxedPrecision, value);
22+
return spirv::atomicAdd<T>(ptr, spv::ScopeDevice, spv::DecorationRelaxedPrecision, value);
2223
}
2324
template<typename T>
2425
T atomicAnd(NBL_REF_ARG(T) ptr, T value)
@@ -83,6 +84,50 @@ void tess_ctrl_barrier() {
8384
void memoryBarrierShared() {
8485
spirv::memoryBarrier(spv::ScopeDevice, spv::MemorySemanticsAcquireReleaseMask | spv::MemorySemanticsWorkgroupMemoryMask);
8586
}
87+
88+
namespace impl
89+
{
90+
91+
template<typename T, bool isSigned, bool isIntegral>
92+
struct bitfieldExtract {};
93+
94+
template<typename T, bool isSigned>
95+
struct bitfieldExtract<T, isSigned, false>
96+
{
97+
T operator()( T val, uint32_t offsetBits, uint32_t numBits )
98+
{
99+
static_assert( is_integral<T>::value, "T is not an integral type!" );
100+
return val;
101+
}
102+
};
103+
104+
template<typename T>
105+
struct bitfieldExtract<T, true, true>
106+
{
107+
T operator()( T val, uint32_t offsetBits, uint32_t numBits )
108+
{
109+
return spirv::bitFieldSExtract<T>( val, offsetBits, numBits );
110+
}
111+
};
112+
113+
template<typename T>
114+
struct bitfieldExtract<T, false, true>
115+
{
116+
T operator()( T val, uint32_t offsetBits, uint32_t numBits )
117+
{
118+
return spirv::bitFieldUExtract<T>( val, offsetBits, numBits );
119+
}
120+
};
121+
122+
}
123+
124+
template<typename T>
125+
T bitfieldExtract( T val, uint32_t offsetBits, uint32_t numBits )
126+
{
127+
return impl::bitfieldExtract<T, is_signed<T>::value, is_integral<T>::value>::template
128+
( val, offsetBits, numBits );
129+
}
130+
86131
#endif
87132

88133
}

include/nbl/builtin/hlsl/spirv_intrinsics/core.hlsl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@ void memoryBarrier(uint32_t memoryScope, uint32_t memorySemantics);
129129
template<class T, class U>
130130
[[vk::ext_instruction(spv::OpBitcast)]]
131131
T bitcast(U);
132+
133+
template<typename Unsigned>
134+
[[vk::ext_instruction( spv::OpBitFieldUExtract )]]
135+
Unsigned bitFieldUExtract( Unsigned val, uint32_t offsetBits, uint32_t numBits );
136+
137+
template<typename Signed>
138+
[[vk::ext_instruction( spv::OpBitFieldSExtract )]]
139+
Signed bitFieldSExtract( Signed val, uint32_t offsetBits, uint32_t numBits );
140+
132141
}
133142
#endif
134143
}

0 commit comments

Comments
 (0)