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

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
287 changes: 4 additions & 283 deletions include/nbl/asset/ECommonEnums.h

Large diffs are not rendered by default.

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
Loading
Loading