Add sampler support and refactor resource handling
Enhanced shader and resource systems with `Sampler` support, including updates to `ShaderPropertyType`, HLSL code, and resource management. Refactored `Result` structs for better type safety and added new enums for texture and comparison settings. Improved `MeshRenderPass` to dynamically load textures and samplers. Updated SDL compiler and token lexicon for `Sampler` handling. Embedded debug info in project files and streamlined resource state tracking.
This commit is contained in:
@@ -106,34 +106,35 @@ public struct Material : IResourceReleasable, IHandleType
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly unsafe Result<ResultStatus> SetPropertyCache<T>(ref readonly T data)
|
||||
public readonly unsafe ResultStatus SetPropertyCache<T>(ref readonly T data)
|
||||
where T : unmanaged
|
||||
{
|
||||
if (sizeof(T) != _cBufferCache.Size)
|
||||
{
|
||||
return new Result<ResultStatus>(false, ResultStatus.InvalidArgument);
|
||||
return ResultStatus.InvalidArgument;
|
||||
}
|
||||
|
||||
Unsafe.WriteUnaligned(_cBufferCache.CpuData.GetUnsafePtr(), data);
|
||||
return Result.Success(ResultStatus.Success);
|
||||
return ResultStatus.Success;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly unsafe Result<ResultStatus> SetRawPropertyCache(ReadOnlySpan<byte> data)
|
||||
public readonly unsafe ResultStatus SetRawPropertyCache(ReadOnlySpan<byte> data)
|
||||
{
|
||||
if (data.Length != _cBufferCache.Size)
|
||||
{
|
||||
return new Result<ResultStatus>(false, ResultStatus.InvalidArgument);
|
||||
return ResultStatus.InvalidArgument;
|
||||
}
|
||||
|
||||
Unsafe.WriteUnaligned(_cBufferCache.CpuData.GetUnsafePtr(), data);
|
||||
return Result.Success(ResultStatus.Success);
|
||||
return ResultStatus.Success;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly void UploadData(ICommandBuffer cmb)
|
||||
{
|
||||
cmb.UploadBuffer(_cBufferCache.GpuResource, _cBufferCache.CpuData.AsSpan());
|
||||
cmb.ResourceBarrier(_cBufferCache.GpuResource.AsResource(), ResourceState.VertexAndConstantBuffer);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -8,7 +8,7 @@ using Misaki.HighPerformance.Mathematics;
|
||||
|
||||
namespace Ghost.Graphics.Core;
|
||||
|
||||
public unsafe readonly ref struct RenderingContext
|
||||
public readonly unsafe ref struct RenderingContext
|
||||
{
|
||||
private readonly IGraphicsEngine _engine;
|
||||
private readonly ICommandBuffer _directCmd;
|
||||
@@ -144,8 +144,8 @@ public unsafe readonly ref struct RenderingContext
|
||||
localToWorld = localToWorld,
|
||||
worldBoundsMin = meshData.BoundingBox.Min,
|
||||
worldBoundsMax = meshData.BoundingBox.Max,
|
||||
vertexBuffer = (uint)_engine.ResourceDatabase.GetBindlessIndex(meshData.VertexBuffer.AsResource()),
|
||||
indexBuffer = (uint)_engine.ResourceDatabase.GetBindlessIndex(meshData.IndexBuffer.AsResource()),
|
||||
vertexBuffer = _engine.ResourceDatabase.GetBindlessIndex(meshData.VertexBuffer.AsResource()).GetValueOrThrow(ResultStatus.Success),
|
||||
indexBuffer = _engine.ResourceDatabase.GetBindlessIndex(meshData.IndexBuffer.AsResource()).GetValueOrThrow(ResultStatus.Success),
|
||||
};
|
||||
|
||||
var bufferHandle = meshData.ObjectDataBuffer.AsResource();
|
||||
|
||||
@@ -6,6 +6,8 @@ public readonly struct GPUResource : IHandleType;
|
||||
public readonly struct Texture : IHandleType;
|
||||
public readonly struct GraphicsBuffer : IHandleType;
|
||||
|
||||
public readonly struct Sampler : IIdentifierType;
|
||||
|
||||
public static class ResourceHandleExtensions
|
||||
{
|
||||
public static Handle<GPUResource> AsResource(this Handle<Texture> texture)
|
||||
|
||||
Reference in New Issue
Block a user