Skip to content

Commit ba5200d

Browse files
committed
Merge branch 'asset-conversion-v3' into tad_flatten_updates
2 parents cbbad0b + 48a3652 commit ba5200d

File tree

9 files changed

+47
-16
lines changed

9 files changed

+47
-16
lines changed

include/nbl/asset/ICPUBuffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class ICPUBuffer : public asset::IBuffer, public IPreHashed
6262
return static_cast<core::blake3_hash_t>(hasher);
6363
}
6464

65-
inline bool missingContent() const {return !data;}
65+
inline bool missingContent() const override {return !data;}
6666

6767
//! Returns pointer to data.
6868
const void* getPointer() const {return data;}

include/nbl/asset/ICPUGraphicsPipeline.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ICPUGraphicsPipeline final : public ICPUPipeline<IGraphicsPipeline<ICPUPip
4646

4747
inline size_t getDependantCount() const override
4848
{
49-
auto stageCount = 1; // the layout
49+
auto stageCount = 2; // the layout and renderpass
5050
for (const auto& stage : m_stages)
5151
if (stage.shader)
5252
stageCount++;
@@ -79,12 +79,16 @@ class ICPUGraphicsPipeline final : public ICPUPipeline<IGraphicsPipeline<ICPUPip
7979
}
8080
inline IAsset* getDependant_impl(const size_t ix) override
8181
{
82+
if (ix==0)
83+
return m_layout.get();
84+
if (ix==1)
85+
return m_renderpass.get();
8286
size_t stageCount = 0;
8387
for (auto& stage : m_stages)
8488
if (stage.shader)
85-
if ((stageCount++)==ix)
89+
if ((stageCount++)==ix-2)
8690
return stage.shader.get();
87-
return m_layout.get();
91+
return nullptr;
8892
}
8993

9094
inline int8_t stageToIndex(const ICPUShader::E_SHADER_STAGE stage) const override

include/nbl/asset/ICPUImage.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ class NBL_API2 ICPUImage final : public IImage, public IPreHashed
4444
constexpr static inline auto AssetType = ET_IMAGE;
4545
inline IAsset::E_TYPE getAssetType() const override { return AssetType; }
4646

47-
// Having regions specififed to upload is optional!
48-
inline size_t getDependantCount() const override {return !missingContent()&&buffer ? 1:0;}
47+
// Do not report buffer as dependant, as we will simply drop it instead of discarding its contents!
48+
inline size_t getDependantCount() const override {return 0;}
4949

5050
core::blake3_hash_t computeContentHash() const override;
5151

52+
// Having regions specififed to upload is optional! So to have content missing we must have regions but no buffer content
5253
inline bool missingContent() const override
5354
{
54-
return !regions || regions->empty() || !buffer;
55+
return regions && !regions->empty() && (!buffer || buffer->missingContent());
5556
}
5657

5758
virtual bool validateCopies(const SImageCopy* pRegionsBegin, const SImageCopy* pRegionsEnd, const ICPUImage* src) const
@@ -205,7 +206,6 @@ class NBL_API2 ICPUImage final : public IImage, public IPreHashed
205206
inline void discardContent_impl() override
206207
{
207208
buffer = nullptr;
208-
regions = nullptr;
209209
}
210210

211211
// TODO: maybe we shouldn't make a single buffer back all regions?

include/nbl/asset/IGraphicsPipeline.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,8 @@ struct SPrimitiveAssemblyParams
6666
static_assert(sizeof(SPrimitiveAssemblyParams)==2u, "Unexpected size!");
6767

6868

69-
template<typename PipelineLayoutType, typename ShaderType, typename RenderpassType>
70-
class IGraphicsPipeline : public IPipeline<PipelineLayoutType>
69+
class IGraphicsPipelineBase : public virtual core::IReferenceCounted
7170
{
72-
protected:
73-
using renderpass_t = RenderpassType;
74-
7571
public:
7672
constexpr static inline uint8_t GRAPHICS_SHADER_STAGE_COUNT = 5u;
7773

@@ -83,6 +79,15 @@ class IGraphicsPipeline : public IPipeline<PipelineLayoutType>
8379
SBlendParams blend = {};
8480
uint32_t subpassIx = 0u;
8581
};
82+
};
83+
84+
template<typename PipelineLayoutType, typename ShaderType, typename RenderpassType>
85+
class IGraphicsPipeline : public IPipeline<PipelineLayoutType>, public IGraphicsPipelineBase
86+
{
87+
protected:
88+
using renderpass_t = RenderpassType;
89+
90+
public:
8691
struct SCreationParams : IPipeline<PipelineLayoutType>::SCreationParams
8792
{
8893
protected:

include/nbl/asset/IPreHashed.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class IPreHashed : public IAsset
3030
// One can free up RAM by discarding content, but keep the pointers and content hash around.
3131
// This is a good alternative to simply ejecting assets from the <path,asset> cache as it prevents repeated loads.
3232
// And you can still hash the asset DAG and find your already converted GPU objects.
33+
// NOTE: `missingContent` is only about this DAG node!
3334
virtual bool missingContent() const = 0;
3435
inline void discardContent()
3536
{

include/nbl/asset/RasterizationStates.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
#include "nbl/asset/IRenderpass.h"
1111

1212

13-
namespace nbl::asset
13+
namespace nbl
14+
{
15+
namespace asset
1416
{
1517

1618
struct SViewport
@@ -293,4 +295,21 @@ struct SBlendParams
293295
};
294296

295297
}
298+
299+
300+
// hasher specs
301+
namespace core
302+
{
303+
304+
template<typename Dummy>
305+
struct blake3_hasher::update_impl<asset::SStencilOpParams,Dummy>
306+
{
307+
static inline void __call(blake3_hasher& hasher, const asset::SStencilOpParams& input)
308+
{
309+
hasher.update(&input,sizeof(input));
310+
}
311+
};
312+
313+
}
314+
}
296315
#endif

include/nbl/video/ISemaphore.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ class ISemaphore : public IBackendObject
6060
return true;
6161
}
6262

63+
inline operator SWaitInfo() const {return {m_semaphore.get(),m_waitValue};}
64+
6365
NBL_API2 WAIT_RESULT wait() const;
6466

6567
protected:

src/nbl/asset/interchange/CImageWriterOpenEXR.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ bool CImageWriterOpenEXR::writeAsset(system::IFile* _file, const SAssetWritePara
196196

197197
auto imageSmart = asset::IImageAssetHandlerBase::createImageDataForCommonWriting(IAsset::castDown<const ICPUImageView>(_params.rootAsset), _params.logger);
198198
const asset::ICPUImage* image = imageSmart.get();
199-
if (IPreHashed::anyDependantDiscardedContents(image))
199+
if (image->missingContent())
200200
return false;
201201

202202
system::IFile* file = _override->getOutputFile(_file, ctx, { image, 0u });

0 commit comments

Comments
 (0)