Skip to content
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

Hashing of assets #468

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

Hashing of assets #468

wants to merge 22 commits into from

Conversation

Hazardu
Copy link
Contributor

@Hazardu Hazardu commented Mar 1, 2023

##Description
Adds new methods to IAsset interface as a prerequisite for asset converter v2

IAssets derived classes

A list of classes that need their implementation of hash, compare, canBeRestoredFrom written/changed

  • ICPUBufferView
  • ICPUAccelerationStructure
  • ICPUAnimationLibrary
  • ICPUBuffer
  • ICPUCommandBuffer
  • ICPUComputePipeline
  • ICPUDescriptorSet
  • ICPUDescriptorSetLayout
  • ICPUEvent
  • ICPURenderpass
  • ICPUFramebuffer
  • ICPUGraphicsPipeline
  • ICPUFramebuffer
  • ICPUImage
  • ICPUImageView
  • ICPUMesh
  • ICPUMeshBuffer
  • ICPUPipelineCache
  • ICPUPipelineLayout
  • ICPUSpecializedShader
  • ICPURenderpass
  • ICPURenderpassIndependentPipeline
  • ICPUSampler
  • ICPUShader
  • ICPUSkeleton ?

@Hazardu
Copy link
Contributor Author

Hazardu commented Mar 1, 2023

@devshgraphicsprogramming Could you take a look at the implementation of the new methods in ICPUBufferView before I make analogous methods in the other IAsset derived classes?

@Hazardu
Copy link
Contributor Author

Hazardu commented Mar 1, 2023

Also i have not seen any mention of ICPUSkeleton in #376
Is this something obsolete?

@devshgraphicsprogramming
Copy link
Member

Also i have not seen any mention of ICPUSkeleton in #376 Is this something obsolete?

not fully developed yet

return compatible(_other);
}


bool canBeRestoredFrom(const IAsset* _other) const override
{
auto* other = static_cast<const ICPUAccelerationStructure*>(_other);
_NBL_TODO();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because canBeRestoredFrom is incomplete im not sure which fields to compare in compatible

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats fine, as long as you make a compatible_impl() with an _NBL_TODO

E_TYPE getAssetType() const override
{
return ET_COMMAND_BUFFER;
return AssetType;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though this entire class is incomplete, ive changed the getAssetType to look similar to other IAsset derived classes

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can probably nuke that entire class/header, we intend to have a GPU-Task-Graph instead to deal with synchronisation/layout transitions later

Copy link
Contributor Author

@Hazardu Hazardu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have messed up some things by hashing immutable fields in classes without any other members

include/nbl/asset/ICPUAccelerationStructure.h Show resolved Hide resolved
bool equals(const IAsset* _other) const override
{
auto* other = static_cast<const ICPUBuffer*>(_other);
return compatible(other) && (m_creationParams.usage.value == other->m_creationParams.usage.value);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memcmp the two buffers or compare the void* data; of the two buffers

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you want to compare usage in compatible_impl probably

and please compare pointers not contents, will be much much faster and more accurate

P.S. you also want to turn equals into equals_impl pattern too

include/nbl/asset/ICPUGraphicsPipeline.h Show resolved Hide resolved
include/nbl/asset/ICPUImage.h Show resolved Hide resolved
include/nbl/asset/ICPUImageView.h Show resolved Hide resolved
include/nbl/asset/ICPUBuffer.h Show resolved Hide resolved
@devshgraphicsprogramming
Copy link
Member

btw can you make IAsset() constructor protected?

@devshgraphicsprogramming
Copy link
Member

devshgraphicsprogramming commented Mar 8, 2023

@devshgraphicsprogramming
Copy link
Member

devshgraphicsprogramming commented Mar 8, 2023

We can also probably nuke

		//! Checks if the object is either not dummy or dummy but in some cache for a purpose
		inline bool isInValidState() { return !isDummyObjectForCacheAliasing /* || !isCached TODO*/; }

from IAsset

P.S. and a bunch of other things, basically anything not used after implementing https://discord.com/channels/593902898015109131/1078226704092381194/1083069244650045600

Comment on lines +75 to +79
bool canBeRestoredFrom(const IAsset* _other) const override
{
auto* other = static_cast<ICPUBufferView*>(_other);
auto* other = static_cast<const ICPUBufferView*>(_other);
return compatible(other) && m_buffer->canBeRestoredFrom(other->m_buffer.get());
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devshgraphicsprogramming
Copy link
Member

devshgraphicsprogramming commented Mar 8, 2023

Also restoreFromDummy_impl_call needs to be templated on class AssetT cause otherwise its not doing anything useful for us.

Btw it should be the responsibility of the convertToDummy and restore _impl functions to manipulate isDummyObjectForCacheAliasing cause for some objects it makes no sense to change it at all.

So no convertToDummy_impl or common

superceded by https://discord.com/channels/593902898015109131/1078226704092381194/1083069244650045600

Base automatically changed from descriptor_lifetime_tracking to master March 10, 2023 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants