Skip to content

Rt pipeline asset conversion #905

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

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
4a37ba5
Implement createCylinder, createCone, createSphere, CreateArrow
Jun 25, 2025
2d8b7c4
Implement getIndexType convenience function for IPolygonGeometry
Jun 25, 2025
cdcaae9
Implement createIcosphere
Jun 28, 2025
2e063d7
Remove color parameter from create<Geometry>
Jun 28, 2025
f0b5064
Fix indentation
Jun 28, 2025
68a689c
Fix normal and uv type
Jun 29, 2025
ca7f182
Return nullptr if vertexCount overflow
Jun 29, 2025
a2b7b04
Remove simd vector from normal quantization cache
Jul 1, 2025
83f39d3
Fix SBuferRange to SBufferBinding conversion requirement
Jul 1, 2025
983ace9
createArrow multiple geometries
Jul 1, 2025
090dae2
DRY findLSB
Jul 2, 2025
9e9e233
Merge branch 'master' into mesh_loaders_kevin
Jul 3, 2025
d36687f
Add missing ECommonEnums.cpp to CMakelists.txt
Jul 3, 2025
d92b274
Cpu ray tracing pipeline asset conversion
Jul 14, 2025
6d2df49
Add groupIndex to shader hash
Jul 14, 2025
9eb0227
Small fix on rt pipeline has computation
Jul 15, 2025
73ac23f
Automatic no null flags insertion for rt pipeline in asset converter
Jul 15, 2025
bd3a266
Extract some common attribute view creation into its own function
Jul 18, 2025
489e2f2
Slight type naming improvement in geometry creator
Jul 18, 2025
de02323
Fix bug prone constant
Jul 18, 2025
1964b27
Accept tesselation as uint16_t parameter
Jul 18, 2025
2157235
Remove reciprocal_approxim usage
Jul 18, 2025
7728987
use hlsl::numbers instead of constant from core
Jul 18, 2025
53f81af
Reorder normal calculation so no need to normalize position
Jul 18, 2025
e29bbf9
Remove packSnorm
Jul 18, 2025
b957ca7
Small impovement on Icosphere index_t
Jul 18, 2025
75d486d
Remove unnecessary method on Icosphere
Jul 18, 2025
e0013cb
Fix normal quantization cache
Jul 21, 2025
4afd072
implement constexpr findLSB
Jul 23, 2025
a001472
Remove unused include
Jul 23, 2025
f8e837b
Fix createArrow to return ICPUGeometryCollection instead of vector of…
Jul 25, 2025
6552952
Add more ray tracing intersection query
Jul 25, 2025
e0b30d0
Add transform.hlsl to cmakelists
Jul 25, 2025
c6dd9ac
Transform data minimum alignment fix
Jul 25, 2025
c45f29c
Merge branch 'master' into mesh_loaders_kevin
Jul 25, 2025
86dae55
Fix after merge with master
Jul 25, 2025
c7caf76
Fix uninitialized bug in quantization cache
Jul 26, 2025
ae5a755
Add some comment in quantization cache
Jul 26, 2025
02d6c6d
Fix indentation in CGeometryCreator.cpp
Jul 28, 2025
bb45773
Fix indentation of CDirQuantCacheBase.h
Jul 28, 2025
1bedf2d
Fix indentation of CGeometryCreator.h
Jul 28, 2025
97977af
Merge branch 'mesh_loaders_kevin' into rt_pipeline_asset_conversion
Jul 30, 2025
5de6b84
Move creationFlags to cached params
Jul 30, 2025
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
287 changes: 4 additions & 283 deletions include/nbl/asset/ECommonEnums.h

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions include/nbl/asset/IAccelerationStructure.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ namespace nbl::asset
class IAccelerationStructure : public virtual core::IReferenceCounted
{
public:
static constexpr inline size_t TRANSFORM_DATA_MIN_ALIGNMENT = 16;

// build flags, we don't expose flags that don't make sense for certain levels
enum class BUILD_FLAGS : uint8_t
{
Expand Down
2 changes: 1 addition & 1 deletion include/nbl/asset/IBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ struct SBufferRange
inline operator SBufferRange<const BufferType>&() {return *reinterpret_cast<SBufferRange<const BufferType>*>(this);}
inline operator const SBufferRange<const BufferType>&() const {return *reinterpret_cast<const SBufferRange<const BufferType>*>(this);}

template<typename BT> requires std::is_same_v<std::remove_const_t<BT>,BufferType>
template<typename BT> requires (std::is_const_v<BT> && std::is_base_of_v<IBuffer,std::remove_const_t<BT>>)
inline operator SBufferBinding<BT>() const { return {.offset=offset,.buffer=buffer}; }

explicit inline operator bool() const {return isValid();}
Expand Down
38 changes: 27 additions & 11 deletions include/nbl/asset/ICPURayTracingPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ class ICPURayTracingPipeline final : public ICPUPipeline<IRayTracingPipeline<ICP
core::vector<SShaderSpecInfo> intersections;
};

static core::smart_refctd_ptr<ICPURayTracingPipeline> create(const ICPUPipelineLayout* layout)
static core::smart_refctd_ptr<ICPURayTracingPipeline> create(ICPUPipelineLayout* layout)
{
auto retval = new ICPURayTracingPipeline(layout);
return core::smart_refctd_ptr<ICPURayTracingPipeline>(retval,core::dont_grab);
}



constexpr static inline auto AssetType = ET_RAYTRACING_PIPELINE;
inline E_TYPE getAssetType() const override { return AssetType; }

Expand Down Expand Up @@ -83,12 +81,13 @@ class ICPURayTracingPipeline final : public ICPUPipeline<IRayTracingPipeline<ICP
return nullptr;
}


inline bool valid() const override final
{
if (!m_layout) return false;
if (!m_layout->valid()) return false;
if (m_raygen.valid() == SShaderSpecInfo::INVALID_SPEC_INFO) return false;
if (m_hitGroups.anyHits.size() != m_hitGroups.closestHits.size()) return false;
if (m_hitGroups.anyHits.size() != m_hitGroups.intersections.size()) return false;
return true;
}

Expand All @@ -102,7 +101,23 @@ class ICPURayTracingPipeline final : public ICPUPipeline<IRayTracingPipeline<ICP
return m_params;
}

inline uint32_t getMissGroupCount() const
{
return m_misses.size();
}

inline uint32_t getHitGroupCount() const
{
return m_hitGroups.anyHits.size();
}

inline uint32_t getCallableGroupCount() const
{
return m_callables.size();
}

protected:
using base_t::base_t;
virtual ~ICPURayTracingPipeline() = default;

private:
Expand All @@ -112,18 +127,19 @@ class ICPURayTracingPipeline final : public ICPUPipeline<IRayTracingPipeline<ICP
SHitGroupSpecInfos m_hitGroups;
core::vector<SShaderSpecInfo> m_callables;

explicit ICPURayTracingPipeline(const ICPUPipelineLayout* layout)
explicit ICPURayTracingPipeline(ICPUPipelineLayout* layout)
: base_t(layout, {})
{}

inline void visitDependents_impl(std::function<bool(const IAsset*)> visit) const override
{
if (!visit(m_raygen.shader.get()) return;
for (const auto& missInfo : self->m_misses) if (!visit(missInfo.shader.get())) return;
for (const auto& anyHitInfo : self->m_hitGroups.anyHits) if (!visit(anyHitInfo.shader.get())) return;
for (const auto& closestHitInfo : self->m_hitGroups.closestHits) if (!visit(closestHitInfo.shader.get())) return;
for (const auto& intersectionInfo : self->m_hitGroups.intersections) if (!visit(intersectionInfo.shader.get())) return;
for (const auto& callableInfo : self->m_callables) if(!visit(callableInfo.shader.get())) return;
if (!visit(m_layout.get())) return;
if (!visit(m_raygen.shader.get())) return;
for (const auto& missInfo : m_misses) if (!visit(missInfo.shader.get())) return;
for (const auto& anyHitInfo : m_hitGroups.anyHits) if (!visit(anyHitInfo.shader.get())) return;
for (const auto& closestHitInfo : m_hitGroups.closestHits) if (!visit(closestHitInfo.shader.get())) return;
for (const auto& intersectionInfo : m_hitGroups.intersections) if (!visit(intersectionInfo.shader.get())) return;
for (const auto& callableInfo : m_callables) if(!visit(callableInfo.shader.get())) return;
}

inline core::smart_refctd_ptr<base_t> clone_impl(core::smart_refctd_ptr<ICPUPipelineLayout>&& layout, uint32_t depth) const override final
Expand Down
40 changes: 21 additions & 19 deletions include/nbl/asset/IPolygonGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,26 @@ class IPolygonGeometry : public IIndexableGeometry<BufferType>, public IPolygonG
// For User defined semantics
inline const core::vector<SDataView>& getAuxAttributeViews() const {return m_auxAttributeViews;}

inline E_INDEX_TYPE getIndexType() const
{
auto indexType = EIT_UNKNOWN;
// disallowed index format
if (base_t::m_indexView)
{
switch (base_t::m_indexView.composed.format)
{
case EF_R16_UINT:
indexType = EIT_16BIT;
break;
case EF_R32_UINT: [[fallthrough]];
indexType = EIT_32BIT;
break;
default:
break;
}
}
return indexType;
}

// Does not set the `transform` or `geometryFlags` fields, because it doesn't care about it.
// Also won't set second set of vertex data, opacity mipmaps, etc.
Expand All @@ -212,30 +232,12 @@ class IPolygonGeometry : public IIndexableGeometry<BufferType>, public IPolygonG
// must be a triangle list, but don't want to compare pointers
if (m_indexing && m_indexing->knownTopology()==EPT_TRIANGLE_LIST)// && m_indexing->degree() == TriangleList()->degree() && m_indexing->rate() == TriangleList->rate())
{
auto indexType = EIT_UNKNOWN;
// disallowed index format
if (base_t::m_indexView)
{
switch (base_t::m_indexView.composed.format)
{
case EF_R16_UINT:
indexType = EIT_16BIT;
break;
case EF_R32_UINT: [[fallthrough]];
indexType = EIT_32BIT;
break;
default:
break;
}
if (indexType==EIT_UNKNOWN)
return retval;
}
retval.vertexData[0] = base_t::m_positionView.src;
retval.indexData = base_t::m_indexView.src;
retval.maxVertex = base_t::m_positionView.getElementCount() - 1;
retval.vertexStride = base_t::m_positionView.composed.getStride();
retval.vertexFormat = base_t::m_positionView.composed.format;
retval.indexType = indexType;
retval.indexType = getIndexType();
}
return retval;
}
Expand Down
26 changes: 13 additions & 13 deletions include/nbl/asset/IRayTracingPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@ namespace nbl::asset
class IRayTracingPipelineBase : public virtual core::IReferenceCounted
{
public:
struct SCachedCreationParams final
{
uint32_t maxRecursionDepth : 6 = 0;
uint32_t dynamicStackSize : 1 = false;
};
};

template<typename PipelineLayoutType>
class IRayTracingPipeline : public IPipeline<PipelineLayoutType>, public IRayTracingPipelineBase
{
public:

#define base_flag(F) static_cast<uint64_t>(IPipelineBase::FLAGS::F)
enum class CreationFlags : uint64_t
{
Expand All @@ -43,7 +31,19 @@ class IRayTracingPipeline : public IPipeline<PipelineLayoutType>, public IRayTra
ALLOW_MOTION = 1<<20,
};
#undef base_flag
using FLAGS = CreationFlags;

struct SCachedCreationParams final
{
core::bitflag<CreationFlags> flags = CreationFlags::NONE;
uint32_t maxRecursionDepth : 6 = 0;
uint32_t dynamicStackSize : 1 = false;
};
};

template<typename PipelineLayoutType>
class IRayTracingPipeline : public IPipeline<PipelineLayoutType>, public IRayTracingPipelineBase
{
public:

inline const SCachedCreationParams& getCachedCreationParams() const { return m_params; }

Expand Down
Loading
Loading