Improve ecs query performance;

This commit is contained in:
2025-10-12 19:49:05 +09:00
parent 682200cbf1
commit 6d1b510ac1
27 changed files with 1546 additions and 992 deletions

View File

@@ -149,21 +149,11 @@ internal unsafe static class D3D12ShaderCompiler
// Get compiled bytecode
using ComPtr<IDxcBlob> bytecodeBlob = default;
result.Get()->GetResult(bytecodeBlob.GetAddressOf());
if (bytecodeBlob.Get() == null)
{
throw new Exception("DXC compilation succeeded but no bytecode was produced");
}
ThrowIfFailed(result.Get()->GetResult(bytecodeBlob.GetAddressOf()));
// Get reflection data using DXC API
using ComPtr<IDxcBlob> reflectionBlob = default;
result.Get()->GetOutput(DXC_OUT_KIND.DXC_OUT_REFLECTION, __uuidof<IDxcBlob>(), reflectionBlob.GetVoidAddressOf(), null);
if (reflectionBlob.Get() == null)
{
throw new Exception("DXC compilation succeeded but no reflection data was produced");
}
ThrowIfFailed(result.Get()->GetOutput(DXC_OUT_KIND.DXC_OUT_REFLECTION, __uuidof<IDxcBlob>(), reflectionBlob.GetVoidAddressOf(), null));
var bytecodeSize = bytecodeBlob.Get()->GetBufferSize();
var bytecode = new UnsafeArray<byte>((int)bytecodeSize, Misaki.HighPerformance.LowLevel.Buffer.Allocator.Persistent);
@@ -210,12 +200,7 @@ internal unsafe static class D3D12ShaderCompiler
};
using ComPtr<ID3D12ShaderReflection> reflection = default;
utils.Get()->CreateReflection(&reflectionData, __uuidof<ID3D12ShaderReflection>(), reflection.GetVoidAddressOf());
if (reflection.Get() == null)
{
throw new Exception("Failed to create shader reflection from DXC output");
}
ThrowIfFailed(utils.Get()->CreateReflection(&reflectionData, __uuidof<ID3D12ShaderReflection>(), reflection.GetVoidAddressOf()));
D3D12_SHADER_DESC shaderDesc;
reflection.Get()->GetDesc(&shaderDesc);

View File

@@ -7,10 +7,7 @@ internal unsafe static class Win32Utility
{
public static void ThrowIfFailed(this HRESULT hr)
{
if (hr.FAILED)
{
throw new InvalidOperationException($"Operation failed with HRESULT: 0x{hr.Value:X8}");
}
Windows.ThrowIfFailed(hr);
}
public static void** GetVoidAddressOf<T>(this ComPtr<T> comPtr)