Separate Fxc bindings and bump version 1.8.2

This commit is contained in:
Amer Koleci
2022-10-10 09:06:57 +02:00
parent 3c7e8e69b2
commit eade223582
21 changed files with 168 additions and 129 deletions

View File

@@ -0,0 +1,146 @@
// Copyright © Amer Koleci and Contributors.
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
using System.Buffers;
using System.Text.RegularExpressions;
using System.Text;
namespace Win32.Graphics.Direct3D.Fxc;
public static unsafe partial class Apis
{
public static ID3DInclude* D3D_COMPILE_STANDARD_FILE_INCLUDE => (ID3DInclude*)(nuint)1;
public static ComPtr<ID3DBlob> D3DCompile(
ReadOnlySpan<char> source,
ReadOnlySpan<char> entryPoint,
ReadOnlySpan<char> target,
CompileFlags flags = CompileFlags.None)
{
int maxLength = Encoding.ASCII.GetMaxByteCount(source.Length);
byte[] sourceBuffer = ArrayPool<byte>.Shared.Rent(maxLength);
int writtenBytes = Encoding.ASCII.GetBytes(source, sourceBuffer);
maxLength = Encoding.ASCII.GetMaxByteCount(entryPoint.Length);
byte[] entryPointBuffer = ArrayPool<byte>.Shared.Rent(maxLength);
int entryPointWrittenBytes = Encoding.ASCII.GetBytes(entryPoint, entryPointBuffer);
maxLength = Encoding.ASCII.GetMaxByteCount(target.Length);
byte[] targetBuffer = ArrayPool<byte>.Shared.Rent(maxLength);
int targetWrittenBytes = Encoding.ASCII.GetBytes(target, targetBuffer);
try
{
using ComPtr<ID3DBlob> d3dBlobBytecode = default;
using ComPtr<ID3DBlob> d3dBlobErrors = default;
HResult hr = D3DCompile(
sourceBuffer.AsSpan(0, writtenBytes),
entryPointBuffer.AsSpan(0, entryPointWrittenBytes),
targetBuffer.AsSpan(0, targetWrittenBytes),
flags,
d3dBlobBytecode.GetAddressOf(),
d3dBlobErrors.GetAddressOf());
if (hr.Failure)
{
// Throw if an error was retrieved, then also double check the HRESULT
if (d3dBlobErrors.Get() is not null)
{
ThrowHslsCompilationException(d3dBlobErrors.Get());
}
}
hr.ThrowIfFailed();
return d3dBlobBytecode.Move();
}
finally
{
ArrayPool<byte>.Shared.Return(sourceBuffer);
ArrayPool<byte>.Shared.Return(entryPointBuffer);
ArrayPool<byte>.Shared.Return(targetBuffer);
}
}
public static HResult D3DCompile(
ReadOnlySpan<byte> source,
ReadOnlySpan<byte> entryPoint,
ReadOnlySpan<byte> target,
CompileFlags flags,
ID3DBlob** byteCode,
ID3DBlob** errorMessage)
{
fixed (byte* sourcePtr = source)
fixed (byte* entryPointPtr = entryPoint)
fixed (byte* targetPtr = target)
{
HResult hr = D3DCompile(
pSrcData: sourcePtr,
SrcDataSize: (nuint)source.Length,
pSourceName: null,
pDefines: null,
pInclude: D3D_COMPILE_STANDARD_FILE_INCLUDE,
pEntrypoint: (sbyte*)entryPointPtr,
pTarget: (sbyte*)targetPtr,
Flags1: flags,
Flags2: 0u,
ppCode: byteCode,
ppErrorMsgs: errorMessage);
return hr;
}
}
public static HResult D3DCompile(
ReadOnlySpan<byte> source,
ReadOnlySpan<byte> entryPoint,
ReadOnlySpan<byte> target,
ID3DInclude* includeHandler,
CompileFlags flags,
ID3DBlob** byteCode,
ID3DBlob** errorMessage)
{
fixed (byte* sourcePtr = source)
fixed (byte* entryPointPtr = entryPoint)
fixed (byte* targetPtr = target)
{
HResult hr = D3DCompile(
pSrcData: sourcePtr,
SrcDataSize: (nuint)source.Length,
pSourceName: null,
pDefines: null,
pInclude: includeHandler,
pEntrypoint: (sbyte*)entryPointPtr,
pTarget: (sbyte*)targetPtr,
Flags1: flags,
Flags2: 0u,
ppCode: byteCode,
ppErrorMsgs: errorMessage);
return hr;
}
}
#if NET6_0_OR_GREATER
[DoesNotReturn]
#endif
[MethodImpl(MethodImplOptions.NoInlining)]
private static void ThrowHslsCompilationException(ID3DBlob* d3DOperationResult)
{
string message = new((sbyte*)d3DOperationResult->GetBufferPointer());
// The error message will be in a format like this:
// "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\Roslyn\Shader@0x0000019AD1B4BA70(22,32-35): error X3004: undeclared identifier 'this'"
// This regex tries to match the unnecessary header and remove it, if present. This doesn't need to be bulletproof, and this regex should match all cases anyway.
message = Regex.Replace(message, @"^[A-Z]:\\[^:]+: (\w+ \w+:)", static m => m.Groups[1].Value, RegexOptions.Multiline).Trim();
// Add a trailing '.' if not present
if (message is { Length: > 0 } &&
message[message.Length - 1] != '.')
{
message += '.';
}
throw new FxcCompilationException(message);
}
}

View File

@@ -0,0 +1,40 @@
// Copyright © Amer Koleci and Contributors.
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
using System.Text;
namespace Win32.Graphics.Direct3D.Fxc;
/// <summary>
/// A custom <see cref="Exception"/> type that indicates when a shader compilation with the FXC compiler has failed.
/// </summary>
public sealed class FxcCompilationException : Exception
{
/// <summary>
/// Creates a new <see cref="FxcCompilationException"/> instance.
/// </summary>
/// <param name="error">The error message produced by the DXC compiler.</param>
internal FxcCompilationException(string error)
: base(GetExceptionMessage(error))
{
}
/// <summary>
/// Gets a formatted exception message for a given compilation error.
/// </summary>
/// <param name="error">The input compilatin error message from the FXC compiler.</param>
/// <returns>A formatted error message for a new <see cref="FxcCompilationException"/> instance.</returns>
private static string GetExceptionMessage(string error)
{
StringBuilder builder = new(512);
builder.AppendLine("The FXC compiler encountered one or more errors while trying to compile the shader:");
builder.AppendLine();
builder.AppendLine(error.Trim());
builder.AppendLine();
builder.AppendLine("Make sure to only be using supported features by checking the README file in the ComputeSharp repository: https://github.com/Sergio0694/ComputeSharp.");
builder.Append("If you're sure that your C# shader code is valid, please open an issue an include a working repro and this error message.");
return builder.ToString();
}
}

View File

@@ -0,0 +1,67 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
namespace Win32.Graphics.Direct3D.Fxc;
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3D_BLOB_PART"]/*' />
/// <unmanaged>D3D_BLOB_PART</unmanaged>
public enum BlobPart : int
{
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3D_BLOB_PART::D3D_BLOB_INPUT_SIGNATURE_BLOB"]/*' />
/// <unmanaged>D3D_BLOB_INPUT_SIGNATURE_BLOB</unmanaged>
InputSignatureBlob = 0,
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3D_BLOB_PART::D3D_BLOB_OUTPUT_SIGNATURE_BLOB"]/*' />
/// <unmanaged>D3D_BLOB_OUTPUT_SIGNATURE_BLOB</unmanaged>
OutputSignatureBlob = 1,
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3D_BLOB_PART::D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB"]/*' />
/// <unmanaged>D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB</unmanaged>
InputAndOutputSignatureBlob = 2,
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3D_BLOB_PART::D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB"]/*' />
/// <unmanaged>D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB</unmanaged>
PatchConstantSignatureBlob = 3,
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3D_BLOB_PART::D3D_BLOB_ALL_SIGNATURE_BLOB"]/*' />
/// <unmanaged>D3D_BLOB_ALL_SIGNATURE_BLOB</unmanaged>
AllSignatureBlob = 4,
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3D_BLOB_PART::D3D_BLOB_DEBUG_INFO"]/*' />
/// <unmanaged>D3D_BLOB_DEBUG_INFO</unmanaged>
DebugInfo = 5,
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3D_BLOB_PART::D3D_BLOB_LEGACY_SHADER"]/*' />
/// <unmanaged>D3D_BLOB_LEGACY_SHADER</unmanaged>
LegacyShader = 6,
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3D_BLOB_PART::D3D_BLOB_XNA_PREPASS_SHADER"]/*' />
/// <unmanaged>D3D_BLOB_XNA_PREPASS_SHADER</unmanaged>
XNAPrepassShader = 7,
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3D_BLOB_PART::D3D_BLOB_XNA_SHADER"]/*' />
/// <unmanaged>D3D_BLOB_XNA_SHADER</unmanaged>
XNAShader = 8,
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3D_BLOB_PART::D3D_BLOB_PDB"]/*' />
/// <unmanaged>D3D_BLOB_PDB</unmanaged>
Pdb = 9,
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3D_BLOB_PART::D3D_BLOB_PRIVATE_DATA"]/*' />
/// <unmanaged>D3D_BLOB_PRIVATE_DATA</unmanaged>
PrivateData = 10,
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3D_BLOB_PART::D3D_BLOB_ROOT_SIGNATURE"]/*' />
/// <unmanaged>D3D_BLOB_ROOT_SIGNATURE</unmanaged>
RootSignature = 11,
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3D_BLOB_PART::D3D_BLOB_DEBUG_NAME"]/*' />
/// <unmanaged>D3D_BLOB_DEBUG_NAME</unmanaged>
DebugName = 12,
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3D_BLOB_PART::D3D_BLOB_TEST_ALTERNATE_SHADER"]/*' />
/// <unmanaged>D3D_BLOB_TEST_ALTERNATE_SHADER</unmanaged>
TestAlternateShader = 32768,
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3D_BLOB_PART::D3D_BLOB_TEST_COMPILE_DETAILS"]/*' />
/// <unmanaged>D3D_BLOB_TEST_COMPILE_DETAILS</unmanaged>
TestCompileDetails = 32769,
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3D_BLOB_PART::D3D_BLOB_TEST_COMPILE_PERF"]/*' />
/// <unmanaged>D3D_BLOB_TEST_COMPILE_PERF</unmanaged>
TestCompilePerf = 32770,
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3D_BLOB_PART::D3D_BLOB_TEST_COMPILE_REPORT"]/*' />
/// <unmanaged>D3D_BLOB_TEST_COMPILE_REPORT</unmanaged>
TestCompileReport = 32771,
}

View File

@@ -0,0 +1,21 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
namespace Win32.Graphics.Direct3D.Fxc;
/// <unmanaged>D3DCOMPILE_EFFECT</unmanaged>
[Flags]
public enum CompileEffectFlags : uint
{
None = 0,
/// <unmanaged>D3DCOMPILE_EFFECT_CHILD_EFFECT</unmanaged>
ChildEffect = 1,
/// <unmanaged>D3DCOMPILE_EFFECT_ALLOW_SLOW_OPS</unmanaged>
AllowSlowOps = 2,
}

View File

@@ -0,0 +1,69 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
namespace Win32.Graphics.Direct3D.Fxc;
/// <unmanaged>D3DCOMPILE</unmanaged>
[Flags]
public enum CompileFlags : uint
{
None = 0,
/// <unmanaged>D3DCOMPILE_DEBUG</unmanaged>
Debug = 1,
/// <unmanaged>D3DCOMPILE_SKIP_VALIDATION</unmanaged>
SkipValidation = 2,
/// <unmanaged>D3DCOMPILE_SKIP_OPTIMIZATION</unmanaged>
SkipOptimization = 4,
/// <unmanaged>D3DCOMPILE_PACK_MATRIX_ROW_MAJOR</unmanaged>
PackMatrixRowMajor = 8,
/// <unmanaged>D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR</unmanaged>
PackMatrixColumnMajor = 16,
/// <unmanaged>D3DCOMPILE_PARTIAL_PRECISION</unmanaged>
PartialPrecision = 32,
/// <unmanaged>D3DCOMPILE_FORCE_VS_SOFTWARE_NO_OPT</unmanaged>
ForceVSSoftwareNoOpt = 64,
/// <unmanaged>D3DCOMPILE_FORCE_PS_SOFTWARE_NO_OPT</unmanaged>
ForcePSSoftwareNoOpt = 128,
/// <unmanaged>D3DCOMPILE_NO_PRESHADER</unmanaged>
NoPreshader = 256,
/// <unmanaged>D3DCOMPILE_AVOID_FLOW_CONTROL</unmanaged>
AvoidFlowControl = 512,
/// <unmanaged>D3DCOMPILE_PREFER_FLOW_CONTROL</unmanaged>
PreferFlowControl = 1024,
/// <unmanaged>D3DCOMPILE_ENABLE_STRICTNESS</unmanaged>
EnableStrictness = 2048,
/// <unmanaged>D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY</unmanaged>
EnableBackwardsCompatibility = 4096,
/// <unmanaged>D3DCOMPILE_IEEE_STRICTNESS</unmanaged>
IeeeStrictness = 8192,
/// <unmanaged>D3DCOMPILE_OPTIMIZATION_LEVEL0</unmanaged>
OptimizationLevel0 = 16384,
/// <unmanaged>D3DCOMPILE_OPTIMIZATION_LEVEL1</unmanaged>
OptimizationLevel1 = 0,
/// <unmanaged>D3DCOMPILE_OPTIMIZATION_LEVEL2</unmanaged>
OptimizationLevel2 = 49152,
/// <unmanaged>D3DCOMPILE_OPTIMIZATION_LEVEL3</unmanaged>
OptimizationLevel3 = 32768,
/// <unmanaged>D3DCOMPILE_RESERVED16</unmanaged>
Reserved16 = 65536,
/// <unmanaged>D3DCOMPILE_RESERVED17</unmanaged>
Reserved17 = 131072,
/// <unmanaged>D3DCOMPILE_WARNINGS_ARE_ERRORS</unmanaged>
WarningsAreErrors = 262144,
/// <unmanaged>D3DCOMPILE_RESOURCES_MAY_ALIAS</unmanaged>
ResourcesMayAlias = 524288,
/// <unmanaged>D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES</unmanaged>
EnableUnboundedDescriptorTables = 1048576,
/// <unmanaged>D3DCOMPILE_ALL_RESOURCES_BOUND</unmanaged>
AllResourcesBound = 2097152,
/// <unmanaged>D3DCOMPILE_DEBUG_NAME_FOR_SOURCE</unmanaged>
DebugNameForSource = 4194304,
/// <unmanaged>D3DCOMPILE_DEBUG_NAME_FOR_BINARY</unmanaged>
DebugNameForBinary = 8388608,
}

View File

@@ -0,0 +1,23 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
namespace Win32.Graphics.Direct3D.Fxc;
/// <unmanaged>D3DCOMPILE_FLAGS2</unmanaged>
[Flags]
public enum CompileFlags2 : uint
{
None = 0,
/// <unmanaged>D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_LATEST</unmanaged>
ForceRootSignatureLatest = 0,
/// <unmanaged>D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_1_0</unmanaged>
ForceRootSignature10 = 16,
/// <unmanaged>D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_1_1</unmanaged>
ForceRootSignature11 = 32,
}

View File

@@ -0,0 +1,23 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
namespace Win32.Graphics.Direct3D.Fxc;
/// <unmanaged>D3DCOMPILE_SECDATA</unmanaged>
[Flags]
public enum CompileSecondaryFlags : uint
{
None = 0,
/// <unmanaged>D3DCOMPILE_SECDATA_MERGE_UAV_SLOTS</unmanaged>
MergeUavSlots = 1,
/// <unmanaged>D3DCOMPILE_SECDATA_PRESERVE_TEMPLATE_SLOTS</unmanaged>
PreserveTemplateSlots = 2,
/// <unmanaged>D3DCOMPILE_SECDATA_REQUIRE_TEMPLATE_MATCH</unmanaged>
RequireTemplateMatch = 4,
}

View File

@@ -0,0 +1,19 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
namespace Win32.Graphics.Direct3D.Fxc;
/// <unmanaged>D3D_COMPRESS_SHADER</unmanaged>
[Flags]
public enum CompressShaderFlags : uint
{
None = 0,
/// <unmanaged>D3D_COMPRESS_SHADER_KEEP_ALL_PARTS</unmanaged>
KeepAllParts = 1,
}

View File

@@ -0,0 +1,33 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
namespace Win32.Graphics.Direct3D.Fxc;
/// <unmanaged>D3D_DISASM</unmanaged>
[Flags]
public enum DisasmFlags : uint
{
None = 0,
/// <unmanaged>D3D_DISASM_ENABLE_COLOR_CODE</unmanaged>
EnableColorCode = 1,
/// <unmanaged>D3D_DISASM_ENABLE_DEFAULT_VALUE_PRINTS</unmanaged>
EnableDefaultValuePrints = 2,
/// <unmanaged>D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING</unmanaged>
EnableInstructionNumbering = 4,
/// <unmanaged>D3D_DISASM_ENABLE_INSTRUCTION_CYCLE</unmanaged>
EnableInstructionCycle = 8,
/// <unmanaged>D3D_DISASM_DISABLE_DEBUG_INFO</unmanaged>
DisableDebugInfo = 16,
/// <unmanaged>D3D_DISASM_ENABLE_INSTRUCTION_OFFSET</unmanaged>
EnableInstructionOffset = 32,
/// <unmanaged>D3D_DISASM_INSTRUCTION_ONLY</unmanaged>
InstructionOnly = 64,
/// <unmanaged>D3D_DISASM_PRINT_HEX_LITERALS</unmanaged>
PrintHexLiterals = 128,
}

View File

@@ -0,0 +1,97 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
namespace Win32.Graphics.Direct3D.Fxc;
public static unsafe partial class Apis
{
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DReadFileToBlob"]/*' />
[DllImport("D3DCOMPILER_47.dll", ExactSpelling = true)]
public static extern HResult D3DReadFileToBlob(ushort* pFileName, Graphics.Direct3D.ID3DBlob** ppContents);
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DWriteBlobToFile"]/*' />
[DllImport("D3DCOMPILER_47.dll", ExactSpelling = true)]
public static extern HResult D3DWriteBlobToFile(Graphics.Direct3D.ID3DBlob* pBlob, ushort* pFileName, Bool32 bOverwrite);
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DCompile"]/*' />
[DllImport("D3DCOMPILER_47.dll", ExactSpelling = true)]
public static extern HResult D3DCompile(void* pSrcData, nuint SrcDataSize, sbyte* pSourceName, Graphics.Direct3D.ShaderMacro* pDefines, Graphics.Direct3D.ID3DInclude* pInclude, sbyte* pEntrypoint, sbyte* pTarget, CompileFlags Flags1, uint Flags2, Graphics.Direct3D.ID3DBlob** ppCode, Graphics.Direct3D.ID3DBlob** ppErrorMsgs);
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DCompile2"]/*' />
[DllImport("D3DCOMPILER_47.dll", ExactSpelling = true)]
public static extern HResult D3DCompile2(void* pSrcData, nuint SrcDataSize, sbyte* pSourceName, Graphics.Direct3D.ShaderMacro* pDefines, Graphics.Direct3D.ID3DInclude* pInclude, sbyte* pEntrypoint, sbyte* pTarget, CompileFlags Flags1, uint Flags2, uint SecondaryDataFlags, void* pSecondaryData, nuint SecondaryDataSize, Graphics.Direct3D.ID3DBlob** ppCode, Graphics.Direct3D.ID3DBlob** ppErrorMsgs);
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DCompileFromFile"]/*' />
[DllImport("D3DCOMPILER_47.dll", ExactSpelling = true)]
public static extern HResult D3DCompileFromFile(ushort* pFileName, Graphics.Direct3D.ShaderMacro* pDefines, Graphics.Direct3D.ID3DInclude* pInclude, sbyte* pEntrypoint, sbyte* pTarget, CompileFlags Flags1, uint Flags2, Graphics.Direct3D.ID3DBlob** ppCode, Graphics.Direct3D.ID3DBlob** ppErrorMsgs);
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DPreprocess"]/*' />
[DllImport("D3DCOMPILER_47.dll", ExactSpelling = true)]
public static extern HResult D3DPreprocess(void* pSrcData, nuint SrcDataSize, sbyte* pSourceName, Graphics.Direct3D.ShaderMacro* pDefines, Graphics.Direct3D.ID3DInclude* pInclude, Graphics.Direct3D.ID3DBlob** ppCodeText, Graphics.Direct3D.ID3DBlob** ppErrorMsgs);
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DGetDebugInfo"]/*' />
[DllImport("D3DCOMPILER_47.dll", ExactSpelling = true)]
public static extern HResult D3DGetDebugInfo(void* pSrcData, nuint SrcDataSize, Graphics.Direct3D.ID3DBlob** ppDebugInfo);
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DReflect"]/*' />
[DllImport("D3DCOMPILER_47.dll", ExactSpelling = true)]
public static extern HResult D3DReflect(void* pSrcData, nuint SrcDataSize, Guid* pInterface, void** ppReflector);
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DReflectLibrary"]/*' />
[DllImport("D3DCOMPILER_47.dll", ExactSpelling = true)]
public static extern HResult D3DReflectLibrary(void* pSrcData, nuint SrcDataSize, Guid* riid, void** ppReflector);
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DDisassemble"]/*' />
[DllImport("D3DCOMPILER_47.dll", ExactSpelling = true)]
public static extern HResult D3DDisassemble(void* pSrcData, nuint SrcDataSize, DisasmFlags Flags, sbyte* szComments, Graphics.Direct3D.ID3DBlob** ppDisassembly);
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DDisassembleRegion"]/*' />
[DllImport("D3DCOMPILER_47.dll", ExactSpelling = true)]
public static extern HResult D3DDisassembleRegion(void* pSrcData, nuint SrcDataSize, uint Flags, sbyte* szComments, nuint StartByteOffset, nuint NumInsts, nuint* pFinishByteOffset, Graphics.Direct3D.ID3DBlob** ppDisassembly);
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DGetTraceInstructionOffsets"]/*' />
[DllImport("D3DCOMPILER_47.dll", ExactSpelling = true)]
public static extern HResult D3DGetTraceInstructionOffsets(void* pSrcData, nuint SrcDataSize, uint Flags, nuint StartInstIndex, nuint NumInsts, nuint* pOffsets, nuint* pTotalInsts);
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DGetInputSignatureBlob"]/*' />
[DllImport("D3DCOMPILER_47.dll", ExactSpelling = true)]
public static extern HResult D3DGetInputSignatureBlob(void* pSrcData, nuint SrcDataSize, Graphics.Direct3D.ID3DBlob** ppSignatureBlob);
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DGetOutputSignatureBlob"]/*' />
[DllImport("D3DCOMPILER_47.dll", ExactSpelling = true)]
public static extern HResult D3DGetOutputSignatureBlob(void* pSrcData, nuint SrcDataSize, Graphics.Direct3D.ID3DBlob** ppSignatureBlob);
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DGetInputAndOutputSignatureBlob"]/*' />
[DllImport("D3DCOMPILER_47.dll", ExactSpelling = true)]
public static extern HResult D3DGetInputAndOutputSignatureBlob(void* pSrcData, nuint SrcDataSize, Graphics.Direct3D.ID3DBlob** ppSignatureBlob);
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DStripShader"]/*' />
[DllImport("D3DCOMPILER_47.dll", ExactSpelling = true)]
public static extern HResult D3DStripShader(void* pShaderBytecode, nuint BytecodeLength, uint uStripFlags, Graphics.Direct3D.ID3DBlob** ppStrippedBlob);
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DGetBlobPart"]/*' />
[DllImport("D3DCOMPILER_47.dll", ExactSpelling = true)]
public static extern HResult D3DGetBlobPart(void* pSrcData, nuint SrcDataSize, BlobPart Part, uint Flags, Graphics.Direct3D.ID3DBlob** ppPart);
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DSetBlobPart"]/*' />
[DllImport("D3DCOMPILER_47.dll", ExactSpelling = true)]
public static extern HResult D3DSetBlobPart(void* pSrcData, nuint SrcDataSize, BlobPart Part, uint Flags, void* pPart, nuint PartSize, Graphics.Direct3D.ID3DBlob** ppNewShader);
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DCreateBlob"]/*' />
[DllImport("D3DCOMPILER_47.dll", ExactSpelling = true)]
public static extern HResult D3DCreateBlob(nuint Size, Graphics.Direct3D.ID3DBlob** ppBlob);
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DCompressShaders"]/*' />
[DllImport("D3DCOMPILER_47.dll", ExactSpelling = true)]
public static extern HResult D3DCompressShaders(uint uNumShaders, ShaderData* pShaderData, CompressShaderFlags uFlags, Graphics.Direct3D.ID3DBlob** ppCompressedData);
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DDecompressShaders"]/*' />
[DllImport("D3DCOMPILER_47.dll", ExactSpelling = true)]
public static extern HResult D3DDecompressShaders(void* pSrcData, nuint SrcDataSize, uint uNumShaders, uint uStartIndex, uint* pIndices, uint uFlags, Graphics.Direct3D.ID3DBlob** ppShaders, uint* pTotalShaders);
}

View File

@@ -0,0 +1,18 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
namespace Win32.Graphics.Direct3D.Fxc;
public static partial class Apis
{
public const uint D3D_COMPILER_VERSION = 47;
public const uint D3D_GET_INST_OFFSETS_INCLUDE_NON_EXECUTABLE = 1;
}

View File

@@ -0,0 +1,21 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
namespace Win32.Graphics.Direct3D.Fxc;
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3D_SHADER_DATA"]/*' />
/// <unmanaged>D3D_SHADER_DATA</unmanaged>
public partial struct ShaderData
{
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3D_SHADER_DATA::pBytecode"]/*' />
public unsafe void* pBytecode;
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3D_SHADER_DATA::BytecodeLength"]/*' />
public nuint BytecodeLength;
}

View File

@@ -0,0 +1,33 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
namespace Win32.Graphics.Direct3D.Fxc;
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DCOMPILER_STRIP_FLAGS"]/*' />
/// <unmanaged>D3DCOMPILER_STRIP_FLAGS</unmanaged>
[Flags]
public enum StripFlags : int
{
None = 0,
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DCOMPILER_STRIP_FLAGS::D3DCOMPILER_STRIP_REFLECTION_DATA"]/*' />
/// <unmanaged>D3DCOMPILER_STRIP_REFLECTION_DATA</unmanaged>
ReflectionData = 1,
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DCOMPILER_STRIP_FLAGS::D3DCOMPILER_STRIP_DEBUG_INFO"]/*' />
/// <unmanaged>D3DCOMPILER_STRIP_DEBUG_INFO</unmanaged>
DebugInfo = 2,
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DCOMPILER_STRIP_FLAGS::D3DCOMPILER_STRIP_TEST_BLOBS"]/*' />
/// <unmanaged>D3DCOMPILER_STRIP_TEST_BLOBS</unmanaged>
TestBlobs = 4,
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DCOMPILER_STRIP_FLAGS::D3DCOMPILER_STRIP_PRIVATE_DATA"]/*' />
/// <unmanaged>D3DCOMPILER_STRIP_PRIVATE_DATA</unmanaged>
PrivateData = 8,
/// <include file='../../Vortice.Win32/Generated/Graphics/Direct3D.xml' path='doc/member[@name="D3DCOMPILER_STRIP_FLAGS::D3DCOMPILER_STRIP_ROOT_SIGNATURE"]/*' />
/// <unmanaged>D3DCOMPILER_STRIP_ROOT_SIGNATURE</unmanaged>
RootSignature = 16,
}

View File

@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net7.0</TargetFrameworks>
<Description>FXC bindings.</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>
</PropertyGroup>
<ItemGroup>
<Using Include="System.Numerics" />
<Using Include="System.Diagnostics" />
<Using Include="System.Runtime.CompilerServices" />
<Using Include="System.Runtime.InteropServices" />
<Using Include="System.Diagnostics.CodeAnalysis" />
<Using Include="Win32.Numerics" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Vortice.Win32\Vortice.Win32.csproj" />
</ItemGroup>
</Project>