feat(wrapper): span-based interop, resource API refactor

Refactored native wrappers to use ReadOnlySpan<T> for pointer parameters, improving .NET safety and interop. Enhanced wrapper generator with $TYPE and prefix/suffix-based parameter remapping. Added platform-specific native library loading for meshoptimizer, nvtt, and ufbx. Updated D3D12GraphicsEngineFactory for native DLL resolution and removed redundant logic from UnitTestApp. Changed RenderGraphBuilder's resource extraction API to use QueryTextureExtraction/QueryBufferExtraction with explicit handles and flags. Removed IRenderer and D3D12Renderer, moving RenderContext to RenderPipeline. Improved mesh loading, resource management, and updated test shader conventions. Updated project references, build settings, and added launchSettings.json for tooling.

BREAKING CHANGE: Native wrapper APIs now use ReadOnlySpan<T> instead of pointers. RenderGraphBuilder resource extraction API has changed. IRenderer and D3D12Renderer have been removed.
This commit is contained in:
2026-04-01 14:50:20 +09:00
parent 0b6e5b8501
commit a00cb27529
41 changed files with 491 additions and 482 deletions

View File

@@ -17,6 +17,16 @@ public enum AccessFlags : byte
ReadWrite = Read | Write,
}
[Flags]
public enum ResourceExtractionFlags : byte
{
None = 0,
/// <summary>
/// Releases the old resource after extraction.
/// </summary>
ReleaseAfterExtract = 1 << 0,
}
public interface IRenderGraphBuilder : IDisposable
{
/// <summary>
@@ -33,17 +43,6 @@ public interface IRenderGraphBuilder : IDisposable
/// <returns>An identifier for the newly created texture resource.</returns>
Identifier<RGTexture> CreateTexture(in RGTextureDesc desc, string name);
/// <summary>
/// Creates multiple texture resources based on the specified desc.
/// </summary>
/// <remarks>
/// Those textures will be used as multi buffering in the render graph automaticlly and not aliasable with other resources.
/// </remarks>
/// <param name="desc">A structure that defines the properties and configuration of the texture to create.</param>
/// <param name="name">The base name of the texture resources. The actual name for each texture will be generated by appending an index to this base name.</param>
/// <param name="textureIDs">A span to receive the identifiers for the newly created texture resources. The length of the span determines how many textures will be created.</param>
void CreateTextures(in RGTextureDesc desc, string name, Span<Identifier<RGTexture>> textureIDs);
/// <summary>
/// Creates a new buffer resource based on the specified desc.
/// </summary>
@@ -52,17 +51,6 @@ public interface IRenderGraphBuilder : IDisposable
/// <returns>An identifier for the newly created buffer resource.</returns>
Identifier<RGBuffer> CreateBuffer(in BufferDesc desc, string name);
/// <summary>
/// Creates multiple buffer resources based on the specified desc.
/// </summary>
/// <remarks>
/// Those buffers will be used as multi buffering in the render graph automaticlly and not aliasable with other resources.
/// </remarks>
/// <param name="desc">A structure that defines the properties and configuration of the buffer to create.</param>
/// <param name="name">The base name of the buffer resources. The actual name for each buffer will be generated by appending an index to this base name.</param>
/// <param name="bufferIDs">A span to receive the identifiers for the newly created buffer resources. The length of the span determines how many buffers will be created.</param>
void CreateBuffers(in BufferDesc desc, string name, Span<Identifier<RGBuffer>> bufferIDs);
/// <summary>
/// Registers the specified texture for use in the current render graph pass with the given access mode.
/// </summary>
@@ -83,16 +71,16 @@ public interface IRenderGraphBuilder : IDisposable
/// <summary>
/// Extracts the actual texture resource associated with the given identifier for use in outside of the render graph execution context.
/// </summary>
/// <param name="texture">The identifier of the texture to be extracted.</param>
/// <returns>A handle to the actual texture resource that can be used outside of the render graph execution context.</returns>
Handle<GPUTexture> ExtractTexture(Identifier<RGTexture> texture);
/// <param name="src">The identifier of the texture to be extracted.</param>
/// <param name="dst">A handle to receive the actual GPU texture resource.</param>
void QueryTextureExtraction(Identifier<RGTexture> src, Handle<GPUTexture> dst, ResourceExtractionFlags flags = ResourceExtractionFlags.ReleaseAfterExtract);
/// <summary>
/// Extracts the actual buffer resource associated with the given identifier for use in outside of the render graph execution context.
/// </summary>
/// <param name="buffer">The identifier of the buffer to be extracted.</param>
/// <returns>A handle to the actual buffer resource that can be used outside of the render graph execution context.</returns>
Handle<GPUBuffer> ExtractBuffer(Identifier<RGBuffer> buffer);
/// <param name="src">The identifier of the buffer to be extracted.</param>
/// <param name="dst">A handle to receive the actual GPU buffer resource.</param>
void QueryBufferExtraction(Identifier<RGBuffer> src, Handle<GPUBuffer> dst, ResourceExtractionFlags flags = ResourceExtractionFlags.ReleaseAfterExtract);
}
public interface IRasterRenderGraphBuilder : IRenderGraphBuilder
@@ -244,18 +232,6 @@ internal class RenderGraphBuilder : IRasterRenderGraphBuilder, IComputeRenderGra
return handle;
}
public void CreateTextures(in RGTextureDesc desc, string name, Span<Identifier<RGTexture>> textureIDs)
{
// TODO: Create multiple textures, mark them as no aliasable, and add them to the resource registry and current pass.
throw new NotImplementedException();
}
public void CreateBuffers(in BufferDesc desc, string name, Span<Identifier<RGBuffer>> bufferIDs)
{
// TODO: Create multiple buffers, mark them as no aliasable, and add them to the resource registry and current pass.
throw new NotImplementedException();
}
public Identifier<RGTexture> UseTexture(Identifier<RGTexture> texture, AccessFlags flags)
{
ThrowIfDisposed();
@@ -268,13 +244,13 @@ internal class RenderGraphBuilder : IRasterRenderGraphBuilder, IComputeRenderGra
return UseResource(buffer.AsResource(), flags, RenderGraphResourceType.Buffer).AsBuffer();
}
// TODO: Implement ExtractTexture and ExtractBuffer to allow users to get the actual GPU resources for use outside of the render graph execution context.
public Handle<GPUTexture> ExtractTexture(Identifier<RGTexture> texture)
// TODO: Implement QueryTextureExtraction and QueryBufferExtraction to allow users to get the actual GPU resources for use outside of the render graph execution context.
public void QueryTextureExtraction(Identifier<RGTexture> src, Handle<GPUTexture> dst, ResourceExtractionFlags flags = ResourceExtractionFlags.ReleaseAfterExtract)
{
throw new NotImplementedException();
}
public Handle<GPUBuffer> ExtractBuffer(Identifier<RGBuffer> buffer)
public void QueryBufferExtraction(Identifier<RGBuffer> src, Handle<GPUBuffer> dst, ResourceExtractionFlags flags = ResourceExtractionFlags.ReleaseAfterExtract)
{
throw new NotImplementedException();
}