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

D3D12_DISPATCH_RAYS_DESC

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

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

フィールド

フィールドサイズx64x86説明
RayGenerationShaderRecordD3D12_GPU_VIRTUAL_ADDRESS_RANGE16+0+0レイ生成シェーダーレコードのアドレス範囲。
MissShaderTableD3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE24+16+16ミスシェーダーテーブルのアドレス範囲とストライド。
HitGroupTableD3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE24+40+40ヒットグループテーブルのアドレス範囲とストライド。
CallableShaderTableD3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE24+64+64呼び出し可能シェーダーテーブルのアドレス範囲とストライド。
WidthDWORD4+88+88レイディスパッチのX方向の数。
HeightDWORD4+92+92レイディスパッチのY方向の数。
DepthDWORD4+96+96レイディスパッチのZ方向の数。

各言語での定義

#include <windows.h>

// 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_DISPATCH_RAYS_DESC  (x64 104 / x86 104 バイト)
typedef struct D3D12_DISPATCH_RAYS_DESC {
    D3D12_GPU_VIRTUAL_ADDRESS_RANGE RayGenerationShaderRecord;
    D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE MissShaderTable;
    D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE HitGroupTable;
    D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE CallableShaderTable;
    DWORD Width;
    DWORD Height;
    DWORD Depth;
} D3D12_DISPATCH_RAYS_DESC;
using System;
using System.Runtime.InteropServices;

[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_DISPATCH_RAYS_DESC
{
    public D3D12_GPU_VIRTUAL_ADDRESS_RANGE RayGenerationShaderRecord;
    public D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE MissShaderTable;
    public D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE HitGroupTable;
    public D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE CallableShaderTable;
    public uint Width;
    public uint Height;
    public uint Depth;
}
Imports System.Runtime.InteropServices

<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_DISPATCH_RAYS_DESC
    Public RayGenerationShaderRecord As D3D12_GPU_VIRTUAL_ADDRESS_RANGE
    Public MissShaderTable As D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE
    Public HitGroupTable As D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE
    Public CallableShaderTable As D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE
    Public Width As UInteger
    Public Height As UInteger
    Public Depth As UInteger
End Structure
import ctypes
from ctypes import wintypes

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_DISPATCH_RAYS_DESC(ctypes.Structure):
    _fields_ = [
        ("RayGenerationShaderRecord", D3D12_GPU_VIRTUAL_ADDRESS_RANGE),
        ("MissShaderTable", D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE),
        ("HitGroupTable", D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE),
        ("CallableShaderTable", D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE),
        ("Width", wintypes.DWORD),
        ("Height", wintypes.DWORD),
        ("Depth", wintypes.DWORD),
    ]
#[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_DISPATCH_RAYS_DESC {
    pub RayGenerationShaderRecord: D3D12_GPU_VIRTUAL_ADDRESS_RANGE,
    pub MissShaderTable: D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE,
    pub HitGroupTable: D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE,
    pub CallableShaderTable: D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE,
    pub Width: u32,
    pub Height: u32,
    pub Depth: u32,
}
import "golang.org/x/sys/windows"

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_DISPATCH_RAYS_DESC struct {
	RayGenerationShaderRecord D3D12_GPU_VIRTUAL_ADDRESS_RANGE
	MissShaderTable D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE
	HitGroupTable D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE
	CallableShaderTable D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE
	Width uint32
	Height uint32
	Depth uint32
}
type
  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_DISPATCH_RAYS_DESC = record
    RayGenerationShaderRecord: D3D12_GPU_VIRTUAL_ADDRESS_RANGE;
    MissShaderTable: D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE;
    HitGroupTable: D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE;
    CallableShaderTable: D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE;
    Width: DWORD;
    Height: DWORD;
    Depth: DWORD;
  end;
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_DISPATCH_RAYS_DESC = extern struct {
    RayGenerationShaderRecord: D3D12_GPU_VIRTUAL_ADDRESS_RANGE,
    MissShaderTable: D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE,
    HitGroupTable: D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE,
    CallableShaderTable: D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE,
    Width: u32,
    Height: u32,
    Depth: u32,
};
type
  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_DISPATCH_RAYS_DESC {.bycopy.} = object
    RayGenerationShaderRecord: D3D12_GPU_VIRTUAL_ADDRESS_RANGE
    MissShaderTable: D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE
    HitGroupTable: D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE
    CallableShaderTable: D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE
    Width: uint32
    Height: uint32
    Depth: uint32
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_DISPATCH_RAYS_DESC
{
    D3D12_GPU_VIRTUAL_ADDRESS_RANGE RayGenerationShaderRecord;
    D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE MissShaderTable;
    D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE HitGroupTable;
    D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE CallableShaderTable;
    uint Width;
    uint Height;
    uint Depth;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; D3D12_DISPATCH_RAYS_DESC サイズ: 104 バイト(x64)
dim st, 26    ; 4byte整数×26(構造体サイズ 104 / 4 切り上げ)
; RayGenerationShaderRecord : D3D12_GPU_VIRTUAL_ADDRESS_RANGE (+0, 16byte)  varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; MissShaderTable : D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE (+16, 24byte)  varptr(st)+16 を基点に操作(24byte:入れ子/配列)
; HitGroupTable : D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE (+40, 24byte)  varptr(st)+40 を基点に操作(24byte:入れ子/配列)
; CallableShaderTable : D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE (+64, 24byte)  varptr(st)+64 を基点に操作(24byte:入れ子/配列)
; Width : DWORD (+88, 4byte)  st.22 = 値  /  値 = st.22   (lpoke/lpeek も可)
; Height : DWORD (+92, 4byte)  st.23 = 値  /  値 = st.23   (lpoke/lpeek も可)
; Depth : DWORD (+96, 4byte)  st.24 = 値  /  値 = st.24   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#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_DISPATCH_RAYS_DESC
    #field D3D12_GPU_VIRTUAL_ADDRESS_RANGE RayGenerationShaderRecord
    #field D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE MissShaderTable
    #field D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE HitGroupTable
    #field D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE CallableShaderTable
    #field int Width
    #field int Height
    #field int Depth
#endstruct

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