Win32 API 日本語リファレンス
ホームGraphics.Direct3D12 › D3D12_SET_WORK_GRAPH_DESC

D3D12_SET_WORK_GRAPH_DESC

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

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

フィールド

フィールドサイズx64x86説明
ProgramIdentifierD3D12_PROGRAM_IDENTIFIER32+0+0設定するワークグラフプログラムの識別子。
FlagsD3D12_SET_WORK_GRAPH_FLAGS4+32+32ワークグラフ設定の動作を制御するフラグ。バッキングメモリ初期化などを指定する。
BackingMemoryD3D12_GPU_VIRTUAL_ADDRESS_RANGE16+40+40ワークグラフ用バッキングメモリのアドレス範囲。
NodeLocalRootArgumentsTableD3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE24+56+56ノードのローカルルート引数テーブルのアドレス範囲とストライド。

各言語での定義

#include <windows.h>

// D3D12_PROGRAM_IDENTIFIER  (x64 32 / x86 32 バイト)
typedef struct D3D12_PROGRAM_IDENTIFIER {
    ULONGLONG OpaqueData[4];
} D3D12_PROGRAM_IDENTIFIER;

// D3D12_GPU_VIRTUAL_ADDRESS_RANGE  (x64 16 / x86 16 バイト)
typedef struct D3D12_GPU_VIRTUAL_ADDRESS_RANGE {
    ULONGLONG StartAddress;
    ULONGLONG SizeInBytes;
} D3D12_GPU_VIRTUAL_ADDRESS_RANGE;

// D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE  (x64 24 / x86 24 バイト)
typedef struct D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE {
    ULONGLONG StartAddress;
    ULONGLONG SizeInBytes;
    ULONGLONG StrideInBytes;
} D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE;

// D3D12_SET_WORK_GRAPH_DESC  (x64 80 / x86 80 バイト)
typedef struct D3D12_SET_WORK_GRAPH_DESC {
    D3D12_PROGRAM_IDENTIFIER ProgramIdentifier;
    D3D12_SET_WORK_GRAPH_FLAGS Flags;
    D3D12_GPU_VIRTUAL_ADDRESS_RANGE BackingMemory;
    D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE NodeLocalRootArgumentsTable;
} D3D12_SET_WORK_GRAPH_DESC;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct D3D12_PROGRAM_IDENTIFIER
{
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public ulong[] OpaqueData;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct D3D12_GPU_VIRTUAL_ADDRESS_RANGE
{
    public ulong StartAddress;
    public ulong SizeInBytes;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE
{
    public ulong StartAddress;
    public ulong SizeInBytes;
    public ulong StrideInBytes;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct D3D12_SET_WORK_GRAPH_DESC
{
    public D3D12_PROGRAM_IDENTIFIER ProgramIdentifier;
    public int Flags;
    public D3D12_GPU_VIRTUAL_ADDRESS_RANGE BackingMemory;
    public D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE NodeLocalRootArgumentsTable;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure D3D12_PROGRAM_IDENTIFIER
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public OpaqueData() As ULong
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure D3D12_GPU_VIRTUAL_ADDRESS_RANGE
    Public StartAddress As ULong
    Public SizeInBytes As ULong
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE
    Public StartAddress As ULong
    Public SizeInBytes As ULong
    Public StrideInBytes As ULong
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure D3D12_SET_WORK_GRAPH_DESC
    Public ProgramIdentifier As D3D12_PROGRAM_IDENTIFIER
    Public Flags As Integer
    Public BackingMemory As D3D12_GPU_VIRTUAL_ADDRESS_RANGE
    Public NodeLocalRootArgumentsTable As D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE
End Structure
import ctypes
from ctypes import wintypes

class D3D12_PROGRAM_IDENTIFIER(ctypes.Structure):
    _fields_ = [
        ("OpaqueData", ctypes.c_ulonglong * 4),
    ]

class D3D12_GPU_VIRTUAL_ADDRESS_RANGE(ctypes.Structure):
    _fields_ = [
        ("StartAddress", ctypes.c_ulonglong),
        ("SizeInBytes", ctypes.c_ulonglong),
    ]

class D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE(ctypes.Structure):
    _fields_ = [
        ("StartAddress", ctypes.c_ulonglong),
        ("SizeInBytes", ctypes.c_ulonglong),
        ("StrideInBytes", ctypes.c_ulonglong),
    ]

class D3D12_SET_WORK_GRAPH_DESC(ctypes.Structure):
    _fields_ = [
        ("ProgramIdentifier", D3D12_PROGRAM_IDENTIFIER),
        ("Flags", ctypes.c_int),
        ("BackingMemory", D3D12_GPU_VIRTUAL_ADDRESS_RANGE),
        ("NodeLocalRootArgumentsTable", D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE),
    ]
#[repr(C)]
pub struct D3D12_PROGRAM_IDENTIFIER {
    pub OpaqueData: [u64; 4],
}

#[repr(C)]
pub struct D3D12_GPU_VIRTUAL_ADDRESS_RANGE {
    pub StartAddress: u64,
    pub SizeInBytes: u64,
}

#[repr(C)]
pub struct D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE {
    pub StartAddress: u64,
    pub SizeInBytes: u64,
    pub StrideInBytes: u64,
}

#[repr(C)]
pub struct D3D12_SET_WORK_GRAPH_DESC {
    pub ProgramIdentifier: D3D12_PROGRAM_IDENTIFIER,
    pub Flags: i32,
    pub BackingMemory: D3D12_GPU_VIRTUAL_ADDRESS_RANGE,
    pub NodeLocalRootArgumentsTable: D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE,
}
import "golang.org/x/sys/windows"

type D3D12_PROGRAM_IDENTIFIER struct {
	OpaqueData [4]uint64
}

type D3D12_GPU_VIRTUAL_ADDRESS_RANGE struct {
	StartAddress uint64
	SizeInBytes uint64
}

type D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE struct {
	StartAddress uint64
	SizeInBytes uint64
	StrideInBytes uint64
}

type D3D12_SET_WORK_GRAPH_DESC struct {
	ProgramIdentifier D3D12_PROGRAM_IDENTIFIER
	Flags int32
	BackingMemory D3D12_GPU_VIRTUAL_ADDRESS_RANGE
	NodeLocalRootArgumentsTable D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE
}
type
  D3D12_PROGRAM_IDENTIFIER = record
    OpaqueData: array[0..3] of UInt64;
  end;

  D3D12_GPU_VIRTUAL_ADDRESS_RANGE = record
    StartAddress: UInt64;
    SizeInBytes: UInt64;
  end;

  D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE = record
    StartAddress: UInt64;
    SizeInBytes: UInt64;
    StrideInBytes: UInt64;
  end;

  D3D12_SET_WORK_GRAPH_DESC = record
    ProgramIdentifier: D3D12_PROGRAM_IDENTIFIER;
    Flags: Integer;
    BackingMemory: D3D12_GPU_VIRTUAL_ADDRESS_RANGE;
    NodeLocalRootArgumentsTable: D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE;
  end;
const D3D12_PROGRAM_IDENTIFIER = extern struct {
    OpaqueData: [4]u64,
};

const D3D12_GPU_VIRTUAL_ADDRESS_RANGE = extern struct {
    StartAddress: u64,
    SizeInBytes: u64,
};

const D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE = extern struct {
    StartAddress: u64,
    SizeInBytes: u64,
    StrideInBytes: u64,
};

const D3D12_SET_WORK_GRAPH_DESC = extern struct {
    ProgramIdentifier: D3D12_PROGRAM_IDENTIFIER,
    Flags: i32,
    BackingMemory: D3D12_GPU_VIRTUAL_ADDRESS_RANGE,
    NodeLocalRootArgumentsTable: D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE,
};
type
  D3D12_PROGRAM_IDENTIFIER {.bycopy.} = object
    OpaqueData: array[4, uint64]

  D3D12_GPU_VIRTUAL_ADDRESS_RANGE {.bycopy.} = object
    StartAddress: uint64
    SizeInBytes: uint64

  D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE {.bycopy.} = object
    StartAddress: uint64
    SizeInBytes: uint64
    StrideInBytes: uint64

  D3D12_SET_WORK_GRAPH_DESC {.bycopy.} = object
    ProgramIdentifier: D3D12_PROGRAM_IDENTIFIER
    Flags: int32
    BackingMemory: D3D12_GPU_VIRTUAL_ADDRESS_RANGE
    NodeLocalRootArgumentsTable: D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE
struct D3D12_PROGRAM_IDENTIFIER
{
    ulong[4] OpaqueData;
}

struct D3D12_GPU_VIRTUAL_ADDRESS_RANGE
{
    ulong StartAddress;
    ulong SizeInBytes;
}

struct D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE
{
    ulong StartAddress;
    ulong SizeInBytes;
    ulong StrideInBytes;
}

struct D3D12_SET_WORK_GRAPH_DESC
{
    D3D12_PROGRAM_IDENTIFIER ProgramIdentifier;
    int Flags;
    D3D12_GPU_VIRTUAL_ADDRESS_RANGE BackingMemory;
    D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE NodeLocalRootArgumentsTable;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; D3D12_SET_WORK_GRAPH_DESC サイズ: 80 バイト(x64)
dim st, 20    ; 4byte整数×20(構造体サイズ 80 / 4 切り上げ)
; ProgramIdentifier : D3D12_PROGRAM_IDENTIFIER (+0, 32byte)  varptr(st)+0 を基点に操作(32byte:入れ子/配列)
; Flags : D3D12_SET_WORK_GRAPH_FLAGS (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; BackingMemory : D3D12_GPU_VIRTUAL_ADDRESS_RANGE (+40, 16byte)  varptr(st)+40 を基点に操作(16byte:入れ子/配列)
; NodeLocalRootArgumentsTable : D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE (+56, 24byte)  varptr(st)+56 を基点に操作(24byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global D3D12_PROGRAM_IDENTIFIER
    #field int64 OpaqueData 4
#endstruct

#defstruct global D3D12_GPU_VIRTUAL_ADDRESS_RANGE
    #field int64 StartAddress
    #field int64 SizeInBytes
#endstruct

#defstruct global D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE
    #field int64 StartAddress
    #field int64 SizeInBytes
    #field int64 StrideInBytes
#endstruct

#defstruct global D3D12_SET_WORK_GRAPH_DESC
    #field D3D12_PROGRAM_IDENTIFIER ProgramIdentifier
    #field int Flags
    #field D3D12_GPU_VIRTUAL_ADDRESS_RANGE BackingMemory
    #field D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE NodeLocalRootArgumentsTable
#endstruct

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