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:
@@ -16,6 +16,7 @@ public enum ShaderPropertyType
|
||||
Bool, Bool2, Bool3, Bool4,
|
||||
Texture2D, Texture3D, TextureCube,
|
||||
Texture2DArray, TextureCubeArray,
|
||||
Sampler
|
||||
}
|
||||
|
||||
public struct ShaderEntryPoint
|
||||
@@ -133,6 +134,7 @@ public static class ShaderDescriptorExtensions
|
||||
ShaderPropertyType.TextureCube => 4,
|
||||
ShaderPropertyType.Texture2DArray => 4,
|
||||
ShaderPropertyType.TextureCubeArray => 4,
|
||||
ShaderPropertyType.Sampler => 4,
|
||||
_ => 0,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Ghost.Core;
|
||||
|
||||
public readonly struct Result
|
||||
@@ -39,11 +37,13 @@ public readonly struct Result
|
||||
}
|
||||
|
||||
public static Result<T, S> Create<T, S>(T value, S status)
|
||||
where S : Enum
|
||||
{
|
||||
return new Result<T, S>(value, status);
|
||||
}
|
||||
|
||||
public static RefResult<T, S> CreateRef<T, S>(ref T value, S status)
|
||||
where S : Enum
|
||||
{
|
||||
return new RefResult<T, S>(ref value, status);
|
||||
}
|
||||
@@ -105,6 +105,7 @@ public enum ResultStatus : byte
|
||||
}
|
||||
|
||||
public readonly struct Result<T, S>
|
||||
where S : Enum
|
||||
{
|
||||
private readonly T _value;
|
||||
private readonly S _status;
|
||||
@@ -127,6 +128,7 @@ public readonly struct Result<T, S>
|
||||
}
|
||||
|
||||
public readonly ref struct RefResult<T, S>
|
||||
where S : Enum
|
||||
{
|
||||
private readonly ref T _value;
|
||||
private readonly S _status;
|
||||
@@ -173,6 +175,23 @@ public static class ResultExtensions
|
||||
return result.IsSuccess ? result.Value : defaultValue;
|
||||
}
|
||||
|
||||
public static T GetValueOrThrow<T, S>(this Result<T, S> result, S expect)
|
||||
where S : Enum
|
||||
{
|
||||
if (result.Status?.Equals(expect) ?? false)
|
||||
{
|
||||
throw new InvalidOperationException($"Operation failed: expected status {expect}, but got {result.Status}");
|
||||
}
|
||||
|
||||
return result.Value;
|
||||
}
|
||||
|
||||
public static T? GetValueOrDefault<T, S>(this Result<T, S> result, S expect, T? defaultValue = default)
|
||||
where S : Enum
|
||||
{
|
||||
return (result.Status?.Equals(expect) ?? false) ? defaultValue : result.Value;
|
||||
}
|
||||
|
||||
public static Result OnSuccess(this Result result, Action action)
|
||||
{
|
||||
if (result.IsSuccess)
|
||||
|
||||
Reference in New Issue
Block a user