using Ghost.Core;
using Ghost.Graphics.Data;
namespace Ghost.Graphics.RHI;
public interface IResourceDatabase
{
///
/// Imports an external unmanaged resource and returns a handle for use within the resource management system.
///
/// The type of the unmanaged resource pointer to import.
/// A pointer to the external unmanaged resource to be imported. Must remain valid for the duration of the resource's usage.
/// The initial state to assign to the imported resource.
/// A handle representing the imported resource, which can be used for subsequent operations.
public unsafe Handle ImportExternalResource(T resourcePtr, ResourceState initialState)
where T : unmanaged;
///
/// Retrieves the current state of the specified resource.
///
/// The handle that uniquely identifies the resource whose state is to be retrieved. Must not be null.
/// A ResourceState value representing the current state of the resource associated with the specified handle.
public ResourceState GetResourceState(Handle handle);
///
/// Sets the state of the specified resource handle to the given value.
///
/// The handle that identifies the resource whose state will be updated. Cannot be null.
/// The new state to assign to the resource represented by .
public void SetResourceState(Handle handle, ResourceState state);
///
/// Retrieves the description of a GPU resource associated with the specified handle.
///
/// A handle that identifies the GPU resource for which to obtain the description. Must reference a valid resource.
/// A ResourceDesc structure containing details about the specified GPU resource.
public ResourceDesc GetResourceDescription(Handle handle);
///
/// Retrieves the bindless index associated with the specified GPU resource handle.
///
/// A handle to the GPU resource for which to obtain the bindless index. Must reference a valid, currently registered resource.
/// The bindless index corresponding to the specified GPU resource handle. -1 if the resource does not support bindless access or is not found.
public int GetBindlessIndex(Handle handle);
///
/// Removes a resource from the database using its handle.
///
/// The handle of the resource to be removed.
public void ReleaseResource(Handle handle);
///
/// Adds a mesh to the resource database and returns its handle.
///
/// The mesh data to be added to the database.
/// The representing the newly added mesh."/>
public Handle AddMesh(ref readonly Mesh mesh);
///
/// Determines whether a mesh with the specified Handle exists.
///
/// The handle of the mesh to check for existence. Cannot be null.
/// true if a mesh with the specified Handle exists; otherwise, false.
public bool HasMesh(Handle handle);
///
/// Returns a reference to the mesh associated with the specified handle.
///
/// The handle of the mesh to retrieve. Must refer to a valid mesh; otherwise, the behavior is undefined.
/// A reference to the mesh corresponding to the specified handle.
public ref Mesh GetMeshReference(Handle handle);
///
/// Releases the mesh resource associated with the specified handle, freeing any resources held by it. Includes both CPU and GPU resources.
///
/// The handle of the mesh to release. Must refer to a mesh that was previously created and not already released.
public void ReleaseMesh(Handle handle);
///
/// Adds a new material to the collection and returns its unique handle.
///
/// The material to add. The material must be fully initialized before calling this method.
/// The representing the newly added material.
public Handle AddMaterial(ref readonly Material material);
///
/// Determines whether a material with the specified handle exists in the collection.
///
/// The handle of the material to check for existence.
/// true if a material with the specified handle exists; otherwise, false.
public bool HasMaterial(Handle handle);
///
/// Gets a reference to the material associated with the specified handle.
///
/// The handle of the material to retrieve. Must refer to a valid material.
/// A reference to the material corresponding to the specified handle.
public ref Material GetMaterialReference(Handle handle);
///
/// Releases the material associated with the specified handle, making it available for reuse or disposal.
///
/// The handle of the material to release. Must refer to a material that has been previously acquired.
public void ReleaseMaterial(Handle handle);
///
/// Adds the specified shader to the collection and returns its unique identifier.
///
/// The shader to add. The shader is passed by read-only reference and will not be modified.
/// The representing the newly added shader.
public Identifier AddShader(ref readonly Shader shader);
///
/// Determines whether a shader with the specified identifier exists in the collection.
///
/// The identifier of the shader to check for existence.
/// true if a shader with the specified identifier exists; otherwise, false.
public bool HasShader(Identifier id);
///
/// Returns a reference to the shader associated with the specified identifier.
///
/// The identifier of the shader to retrieve. Must refer to a valid shader.
/// A reference to the shader corresponding to the specified identifier.
public ref Shader GetShaderReference(Identifier id);
///
/// Releases the shader associated with the specified identifier, freeing any resources allocated to it.
///
/// The identifier of the shader to release. Must refer to a valid, previously created shader.
public void ReleaseShader(Identifier id);
}