Win32 API 日本語リファレンス
ホームAI.MachineLearning.DirectML › DML_BINDING_TABLE_DESC

DML_BINDING_TABLE_DESC

構造体
サイズx64: 32 バイト / x86: 24 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
DispatchableIDMLDispatchable*8/4+0+0バインディング対象となるディスパッチ可能オブジェクト(演算子初期化子や実行可能オブジェクト)へのポインタ。
CPUDescriptorHandleD3D12_CPU_DESCRIPTOR_HANDLE8/4+8+4ディスクリプタヒープ範囲の先頭を指すCPU側ディスクリプタハンドル。
GPUDescriptorHandleD3D12_GPU_DESCRIPTOR_HANDLE8+16+8ディスクリプタヒープ範囲の先頭を指すGPU側ディスクリプタハンドル。
SizeInDescriptorsDWORD4+24+16バインディングテーブルが使用するディスクリプタの個数。

各言語での定義

#include <windows.h>

// D3D12_CPU_DESCRIPTOR_HANDLE  (x64 8 / x86 4 バイト)
typedef struct D3D12_CPU_DESCRIPTOR_HANDLE {
    UINT_PTR ptr;
} D3D12_CPU_DESCRIPTOR_HANDLE;

// D3D12_GPU_DESCRIPTOR_HANDLE  (x64 8 / x86 8 バイト)
typedef struct D3D12_GPU_DESCRIPTOR_HANDLE {
    ULONGLONG ptr;
} D3D12_GPU_DESCRIPTOR_HANDLE;

// DML_BINDING_TABLE_DESC  (x64 32 / x86 24 バイト)
typedef struct DML_BINDING_TABLE_DESC {
    IDMLDispatchable* Dispatchable;
    D3D12_CPU_DESCRIPTOR_HANDLE CPUDescriptorHandle;
    D3D12_GPU_DESCRIPTOR_HANDLE GPUDescriptorHandle;
    DWORD SizeInDescriptors;
} DML_BINDING_TABLE_DESC;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct D3D12_CPU_DESCRIPTOR_HANDLE
{
    public UIntPtr ptr;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct D3D12_GPU_DESCRIPTOR_HANDLE
{
    public ulong ptr;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DML_BINDING_TABLE_DESC
{
    public IntPtr Dispatchable;
    public D3D12_CPU_DESCRIPTOR_HANDLE CPUDescriptorHandle;
    public D3D12_GPU_DESCRIPTOR_HANDLE GPUDescriptorHandle;
    public uint SizeInDescriptors;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure D3D12_CPU_DESCRIPTOR_HANDLE
    Public ptr As UIntPtr
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure D3D12_GPU_DESCRIPTOR_HANDLE
    Public ptr As ULong
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DML_BINDING_TABLE_DESC
    Public Dispatchable As IntPtr
    Public CPUDescriptorHandle As D3D12_CPU_DESCRIPTOR_HANDLE
    Public GPUDescriptorHandle As D3D12_GPU_DESCRIPTOR_HANDLE
    Public SizeInDescriptors As UInteger
End Structure
import ctypes
from ctypes import wintypes

class D3D12_CPU_DESCRIPTOR_HANDLE(ctypes.Structure):
    _fields_ = [
        ("ptr", ctypes.c_size_t),
    ]

class D3D12_GPU_DESCRIPTOR_HANDLE(ctypes.Structure):
    _fields_ = [
        ("ptr", ctypes.c_ulonglong),
    ]

class DML_BINDING_TABLE_DESC(ctypes.Structure):
    _fields_ = [
        ("Dispatchable", ctypes.c_void_p),
        ("CPUDescriptorHandle", D3D12_CPU_DESCRIPTOR_HANDLE),
        ("GPUDescriptorHandle", D3D12_GPU_DESCRIPTOR_HANDLE),
        ("SizeInDescriptors", wintypes.DWORD),
    ]
#[repr(C)]
pub struct D3D12_CPU_DESCRIPTOR_HANDLE {
    pub ptr: usize,
}

#[repr(C)]
pub struct D3D12_GPU_DESCRIPTOR_HANDLE {
    pub ptr: u64,
}

#[repr(C)]
pub struct DML_BINDING_TABLE_DESC {
    pub Dispatchable: *mut core::ffi::c_void,
    pub CPUDescriptorHandle: D3D12_CPU_DESCRIPTOR_HANDLE,
    pub GPUDescriptorHandle: D3D12_GPU_DESCRIPTOR_HANDLE,
    pub SizeInDescriptors: u32,
}
import "golang.org/x/sys/windows"

type D3D12_CPU_DESCRIPTOR_HANDLE struct {
	ptr uintptr
}

type D3D12_GPU_DESCRIPTOR_HANDLE struct {
	ptr uint64
}

type DML_BINDING_TABLE_DESC struct {
	Dispatchable uintptr
	CPUDescriptorHandle D3D12_CPU_DESCRIPTOR_HANDLE
	GPUDescriptorHandle D3D12_GPU_DESCRIPTOR_HANDLE
	SizeInDescriptors uint32
}
type
  D3D12_CPU_DESCRIPTOR_HANDLE = record
    ptr: NativeUInt;
  end;

  D3D12_GPU_DESCRIPTOR_HANDLE = record
    ptr: UInt64;
  end;

  DML_BINDING_TABLE_DESC = record
    Dispatchable: Pointer;
    CPUDescriptorHandle: D3D12_CPU_DESCRIPTOR_HANDLE;
    GPUDescriptorHandle: D3D12_GPU_DESCRIPTOR_HANDLE;
    SizeInDescriptors: DWORD;
  end;
const D3D12_CPU_DESCRIPTOR_HANDLE = extern struct {
    ptr: usize,
};

const D3D12_GPU_DESCRIPTOR_HANDLE = extern struct {
    ptr: u64,
};

const DML_BINDING_TABLE_DESC = extern struct {
    Dispatchable: ?*anyopaque,
    CPUDescriptorHandle: D3D12_CPU_DESCRIPTOR_HANDLE,
    GPUDescriptorHandle: D3D12_GPU_DESCRIPTOR_HANDLE,
    SizeInDescriptors: u32,
};
type
  D3D12_CPU_DESCRIPTOR_HANDLE {.bycopy.} = object
    ptr: uint

  D3D12_GPU_DESCRIPTOR_HANDLE {.bycopy.} = object
    ptr: uint64

  DML_BINDING_TABLE_DESC {.bycopy.} = object
    Dispatchable: pointer
    CPUDescriptorHandle: D3D12_CPU_DESCRIPTOR_HANDLE
    GPUDescriptorHandle: D3D12_GPU_DESCRIPTOR_HANDLE
    SizeInDescriptors: uint32
struct D3D12_CPU_DESCRIPTOR_HANDLE
{
    size_t ptr;
}

struct D3D12_GPU_DESCRIPTOR_HANDLE
{
    ulong ptr;
}

struct DML_BINDING_TABLE_DESC
{
    void* Dispatchable;
    D3D12_CPU_DESCRIPTOR_HANDLE CPUDescriptorHandle;
    D3D12_GPU_DESCRIPTOR_HANDLE GPUDescriptorHandle;
    uint SizeInDescriptors;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; DML_BINDING_TABLE_DESC サイズ: 24 バイト(x86)
dim st, 6    ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; Dispatchable : IDMLDispatchable* (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; CPUDescriptorHandle : D3D12_CPU_DESCRIPTOR_HANDLE (+4, 4byte)  varptr(st)+4 を基点に操作(4byte:入れ子/配列)
; GPUDescriptorHandle : D3D12_GPU_DESCRIPTOR_HANDLE (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; SizeInDescriptors : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DML_BINDING_TABLE_DESC サイズ: 32 バイト(x64)
dim st, 8    ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; Dispatchable : IDMLDispatchable* (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; CPUDescriptorHandle : D3D12_CPU_DESCRIPTOR_HANDLE (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; GPUDescriptorHandle : D3D12_GPU_DESCRIPTOR_HANDLE (+16, 8byte)  varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; SizeInDescriptors : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global D3D12_CPU_DESCRIPTOR_HANDLE
    #field intptr ptr
#endstruct

#defstruct global D3D12_GPU_DESCRIPTOR_HANDLE
    #field int64 ptr
#endstruct

#defstruct global DML_BINDING_TABLE_DESC
    #field intptr Dispatchable
    #field D3D12_CPU_DESCRIPTOR_HANDLE CPUDescriptorHandle
    #field D3D12_GPU_DESCRIPTOR_HANDLE GPUDescriptorHandle
    #field int SizeInDescriptors
#endstruct

stdim st, DML_BINDING_TABLE_DESC        ; NSTRUCT 変数を確保
st->SizeInDescriptors = 100
mes "SizeInDescriptors=" + st->SizeInDescriptors