refactor d3d11/d3d12/d3dcompiler dependencies

This commit is contained in:
jakubtomsu
2026-02-17 18:27:34 +01:00
parent 39c725a084
commit 97e09b19d1
4 changed files with 67 additions and 61 deletions

View File

@@ -4,7 +4,7 @@ package directx_d3d11
foreign import "system:d3d11.lib"
import "../dxgi"
import "../d3d_compiler"
import "../d3d_common"
import "core:sys/windows"
IUnknown :: dxgi.IUnknown
@@ -26,9 +26,7 @@ LPCWSTR :: windows.LPCWSTR
RECT :: dxgi.RECT
SIZE :: dxgi.SIZE
IModuleInstance :: d3d_compiler.ID3D11ModuleInstance
IBlob :: d3d_compiler.ID3DBlob
IModule :: d3d_compiler.ID3D11Module
IBlob :: d3d_common.ID3DBlob
@(default_calling_convention="system", link_prefix="D3D11")
foreign d3d11 {
@@ -3569,6 +3567,34 @@ PARAMETER_DESC :: struct {
FirstOutComponent: u32,
}
IModule :: struct #raw_union {
#subtype iunknown: IUnknown,
using id3d11module_vtable: ^IModule_VTable,
}
IModule_VTable :: struct {
using iunknown_vtable: IUnknown_VTable,
CreateInstance: proc "system" (this: ^IModule, pNamespace: LPCSTR, ppModuleInstance: ^^IModuleInstance) -> HRESULT,
}
IModuleInstance :: struct #raw_union {
#subtype iunknown: IUnknown,
using id3d11moduleinstance_vtable: ^IModuleInstance_VTable,
}
IModuleInstance_VTable :: struct {
using iunknown_vtable: IUnknown_VTable,
BindConstantBuffer: proc "system" (this: ^IModuleInstance, uSrcSlot: u32, uDstSlot: u32, cbDstOffset: u32) -> HRESULT,
BindConstantBufferByName: proc "system" (this: ^IModuleInstance, pName: LPCSTR, uDstSlot: u32, cbDstOffset: u32) -> HRESULT,
BindResource: proc "system" (this: ^IModuleInstance, uSrcSlot: u32, uDstSlot: u32, uCount: u32) -> HRESULT,
BindResourceByName: proc "system" (this: ^IModuleInstance, pName: LPCSTR, uDstSlot: u32, uCount: u32) -> HRESULT,
BindSampler: proc "system" (this: ^IModuleInstance, uSrcSlot: u32, uDstSlot: u32, uCount: u32) -> HRESULT,
BindSamplerByName: proc "system" (this: ^IModuleInstance, pName: LPCSTR, uDstSlot: u32, uCount: u32) -> HRESULT,
BindUnorderedAccessView: proc "system" (this: ^IModuleInstance, uSrcSlot: u32, uDstSlot: u32, uCount: u32) -> HRESULT,
BindUnorderedAccessViewByName: proc "system" (this: ^IModuleInstance, pName: LPCSTR, uDstSlot: u32, uCount: u32) -> HRESULT,
BindResourceAsUnorderedAccessView: proc "system" (this: ^IModuleInstance, uSrcSrvSlot: u32, uDstUavSlot: u32, uCount: u32) -> HRESULT,
BindResourceAsUnorderedAccessViewByName: proc "system" (this: ^IModuleInstance, pSrvName: LPCSTR, uDstUavSlot: u32, uCount: u32) -> HRESULT,
}
ID3D11ShaderReflectionType_UUID_STRING :: "6E6FFA6A-9BAE-4613-A51E-91652D508C21"
ID3D11ShaderReflectionType_UUID := &IID{0x6E6FFA6A, 0x9BAE, 0x4613, {0xA5, 0x1E, 0x91, 0x65, 0x2D, 0x50, 0x8C, 0x21}}
IShaderReflectionType :: struct {

View File

@@ -4,7 +4,7 @@ package directx_d3d12
foreign import "system:d3d12.lib"
import "../dxgi"
import "../d3d_compiler"
import "../d3d_common"
import win32 "core:sys/windows"
IUnknown :: dxgi.IUnknown
@@ -26,9 +26,7 @@ RECT :: dxgi.RECT
LPCSTR :: win32.LPCSTR
LPCWSTR :: win32.LPCWSTR
IModuleInstance :: d3d_compiler.ID3D11ModuleInstance
IBlob :: d3d_compiler.ID3DBlob
IModule :: d3d_compiler.ID3D11Module
IBlob :: d3d_common.ID3DBlob
@(default_calling_convention="system", link_prefix="D3D12")
foreign d3d12 {
@@ -1236,7 +1234,7 @@ TRI_STATE :: enum i32 {
UNKNOWN = -1,
FALSE = 0,
TRUE = 1,
}
}
FEATURE_DATA_OPTIONS12 :: struct {
MSPrimitivesPipelineStatisticIncludesCulledPrimitives: TRI_STATE,
@@ -2597,7 +2595,7 @@ IDescriptorHeap_VTable :: struct {
GetDesc: proc "system" (this: ^IDescriptorHeap, desc: ^DESCRIPTOR_HEAP_DESC),
GetCPUDescriptorHandleForHeapStart: proc "system" (this: ^IDescriptorHeap, handle: ^CPU_DESCRIPTOR_HANDLE),
GetGPUDescriptorHandleForHeapStart: proc "system" (this: ^IDescriptorHeap, handle: ^GPU_DESCRIPTOR_HANDLE),
}
}
IQueryHeap_UUID_STRING :: "0d9658ae-ed45-469e-a61d-970ec583cab4"
IQueryHeap_UUID := &IID{0x0d9658ae, 0xed45, 0x469e, {0xa6, 0x1d, 0x97, 0x0e, 0xc5, 0x83, 0xca, 0xb4}}
@@ -5495,7 +5493,7 @@ IGraphicsCommandList7_VTable :: struct {
SHADER_VERSION_TYPE :: enum u32 {
PIXEL_SHADER = 0,
VERTEX_SHADER = 1,
GEOMETRY_SHADER = 2,
GEOMETRY_SHADER = 2,
HULL_SHADER = 3,
DOMAIN_SHADER = 4,

View File

@@ -0,0 +1,25 @@
// Declarations shared between D3D versions.
// Based on d3dcommon.h
package d3d_common
import "core:sys/windows"
IID :: windows.IID
SIZE_T :: windows.SIZE_T
IUnknown :: windows.IUnknown
IUnknown_VTable :: windows.IUnknown_VTable
ID3D10Blob_UUID_STRING :: "8BA5FB08-5195-40E2-AC58-0D989C3A0102"
ID3D10Blob_UUID := &IID{0x8BA5FB08, 0x5195, 0x40E2, {0xAC, 0x58, 0x0D, 0x98, 0x9C, 0x3A, 0x01, 0x02}}
ID3D10Blob :: struct #raw_union {
#subtype iunknown: IUnknown,
using id3d10blob_vtable: ^ID3D10Blob_VTable,
}
ID3D10Blob_VTable :: struct {
using iunknown_vtable: IUnknown_VTable,
GetBufferPointer: proc "system" (this: ^ID3D10Blob) -> rawptr,
GetBufferSize: proc "system" (this: ^ID3D10Blob) -> SIZE_T,
}
ID3DBlob :: ID3D10Blob
ID3DBlob_VTable :: ID3D10Blob_VTable

View File

@@ -7,8 +7,9 @@ import win32 "core:sys/windows"
D3DCOMPILER_DLL_A :: "d3dcompiler_47.dll"
COMPILER_VERSION :: 47
import "../dxgi"
import "../d3d11"
import "../d3d_common"
BOOL :: dxgi.BOOL
IID :: dxgi.IID
@@ -17,6 +18,8 @@ HRESULT :: dxgi.HRESULT
IUnknown :: dxgi.IUnknown
IUnknown_VTable :: dxgi.IUnknown_VTable
ID3DBlob :: d3d_common.ID3DBlob
LPCSTR :: win32.LPCSTR
LPCWSTR :: win32.LPCWSTR
@@ -34,7 +37,7 @@ foreign d3dcompiler {
Disassemble :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, Flags: u32, szComments: LPCSTR, ppDisassembly: ^^ID3DBlob) -> HRESULT ---
DisassembleRegion :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, Flags: u32, szComments: LPCSTR, StartByteOffset: SIZE_T, NumInsts: SIZE_T, pFinishByteOffset: ^SIZE_T, ppDisassembly: ^^ID3DBlob) -> HRESULT ---
CreateLinker :: proc(ppLinker: ^^ID3D11Linker) -> HRESULT ---
LoadModule :: proc(pSrcData: rawptr, cbSrcDataSize: SIZE_T, ppModule: ^^ID3D11Module) -> HRESULT ---
LoadModule :: proc(pSrcData: rawptr, cbSrcDataSize: SIZE_T, ppModule: ^^d3d11.IModule) -> HRESULT ---
GetTraceInstructionOffsets :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, Flags: u32, StartInstIndex: SIZE_T, NumInsts: SIZE_T, pOffsets: ^SIZE_T, pTotalInsts: ^SIZE_T) -> HRESULT ---
GetInputSignatureBlob :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, ppSignatureBlob: ^^ID3DBlob) -> HRESULT ---
GetOutputSignatureBlob :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, ppSignatureBlob: ^^ID3DBlob) -> HRESULT ---
@@ -121,23 +124,6 @@ SHADER_MACRO :: struct {
Definition: LPCSTR,
}
ID3D10Blob_UUID_STRING :: "8BA5FB08-5195-40E2-AC58-0D989C3A0102"
ID3D10Blob_UUID := &IID{0x8BA5FB08, 0x5195, 0x40E2, {0xAC, 0x58, 0x0D, 0x98, 0x9C, 0x3A, 0x01, 0x02}}
ID3D10Blob :: struct #raw_union {
#subtype iunknown: IUnknown,
using id3d10blob_vtable: ^ID3D10Blob_VTable,
}
ID3D10Blob_VTable :: struct {
using iunknown_vtable: IUnknown_VTable,
GetBufferPointer: proc "system" (this: ^ID3D10Blob) -> rawptr,
GetBufferSize: proc "system" (this: ^ID3D10Blob) -> SIZE_T,
}
ID3DBlob :: ID3D10Blob
ID3DBlob_VTable :: ID3D10Blob_VTable
INCLUDE_TYPE :: enum i32 {
INCLUDE_LOCAL = 0,
INCLUDE_SYSTEM = 1,
@@ -158,43 +144,14 @@ ID3DInclude_VTable :: struct {
D3DCOMPILE_STANDARD_FILE_INCLUDE :: (^ID3DInclude)(uintptr(1))
ID3D11Module :: struct #raw_union {
#subtype iunknown: IUnknown,
using id3d11module_vtable: ^ID3D11Module_VTable,
}
ID3D11Module_VTable :: struct {
using iunknown_vtable: IUnknown_VTable,
CreateInstance: proc "system" (this: ^ID3D11Module, pNamespace: LPCSTR, ppModuleInstance: ^^ID3D11ModuleInstance) -> HRESULT,
}
ID3D11ModuleInstance :: struct #raw_union {
#subtype iunknown: IUnknown,
using id3d11moduleinstance_vtable: ^ID3D11ModuleInstance_VTable,
}
ID3D11ModuleInstance_VTable :: struct {
using iunknown_vtable: IUnknown_VTable,
BindConstantBuffer: proc "system" (this: ^ID3D11ModuleInstance, uSrcSlot: u32, uDstSlot: u32, cbDstOffset: u32) -> HRESULT,
BindConstantBufferByName: proc "system" (this: ^ID3D11ModuleInstance, pName: LPCSTR, uDstSlot: u32, cbDstOffset: u32) -> HRESULT,
BindResource: proc "system" (this: ^ID3D11ModuleInstance, uSrcSlot: u32, uDstSlot: u32, uCount: u32) -> HRESULT,
BindResourceByName: proc "system" (this: ^ID3D11ModuleInstance, pName: LPCSTR, uDstSlot: u32, uCount: u32) -> HRESULT,
BindSampler: proc "system" (this: ^ID3D11ModuleInstance, uSrcSlot: u32, uDstSlot: u32, uCount: u32) -> HRESULT,
BindSamplerByName: proc "system" (this: ^ID3D11ModuleInstance, pName: LPCSTR, uDstSlot: u32, uCount: u32) -> HRESULT,
BindUnorderedAccessView: proc "system" (this: ^ID3D11ModuleInstance, uSrcSlot: u32, uDstSlot: u32, uCount: u32) -> HRESULT,
BindUnorderedAccessViewByName: proc "system" (this: ^ID3D11ModuleInstance, pName: LPCSTR, uDstSlot: u32, uCount: u32) -> HRESULT,
BindResourceAsUnorderedAccessView: proc "system" (this: ^ID3D11ModuleInstance, uSrcSrvSlot: u32, uDstUavSlot: u32, uCount: u32) -> HRESULT,
BindResourceAsUnorderedAccessViewByName: proc "system" (this: ^ID3D11ModuleInstance, pSrvName: LPCSTR, uDstUavSlot: u32, uCount: u32) -> HRESULT,
}
ID3D11Linker :: struct #raw_union {
#subtype iunknown: IUnknown,
using id3d11linker_vtable: ^ID3D11Linker_VTable,
}
ID3D11Linker_VTable :: struct {
using iunknown_vtable: IUnknown_VTable,
Link: proc "system" (this: ^ID3D11Linker, pEntry: ^ID3D11ModuleInstance, pEntryName: LPCSTR, pTargetName: LPCSTR, uFlags: u32, ppShaderBlob: ^^ID3DBlob, ppErrorBuffer: ^^ID3DBlob) -> HRESULT,
UseLibrary: proc "system" (this: ^ID3D11Linker, pLibraryMI: ^ID3D11ModuleInstance) -> HRESULT,
Link: proc "system" (this: ^ID3D11Linker, pEntry: ^d3d11.IModuleInstance, pEntryName: LPCSTR, pTargetName: LPCSTR, uFlags: u32, ppShaderBlob: ^^ID3DBlob, ppErrorBuffer: ^^ID3DBlob) -> HRESULT,
UseLibrary: proc "system" (this: ^ID3D11Linker, pLibraryMI: ^d3d11.IModuleInstance) -> HRESULT,
AddClipPlaneFromCBuffer: proc "system" (this: ^ID3D11Linker, uCBufferSlot: u32, uCBufferEntry: u32) -> HRESULT,
}