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

D3D12_RAYTRACING_INSTANCE_DESC

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

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

フィールド

フィールドサイズx64x86説明
TransformFLOAT48+0+03x4のインスタンス変換行列(行優先のfloat配列)。
_bitfield1DWORD4+48+48インスタンスIDと可視性マスクをパックしたビットフィールド。
_bitfield2DWORD4+52+52ヒットグループオフセットとフラグをパックしたビットフィールド。
AccelerationStructureULONGLONG8+56+56参照するボトムレベル加速構造のGPU仮想アドレス。

各言語での定義

#include <windows.h>

// D3D12_RAYTRACING_INSTANCE_DESC  (x64 64 / x86 64 バイト)
typedef struct D3D12_RAYTRACING_INSTANCE_DESC {
    FLOAT Transform[12];
    DWORD _bitfield1;
    DWORD _bitfield2;
    ULONGLONG AccelerationStructure;
} D3D12_RAYTRACING_INSTANCE_DESC;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct D3D12_RAYTRACING_INSTANCE_DESC
{
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] public float[] Transform;
    public uint _bitfield1;
    public uint _bitfield2;
    public ulong AccelerationStructure;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure D3D12_RAYTRACING_INSTANCE_DESC
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=12)> Public Transform() As Single
    Public _bitfield1 As UInteger
    Public _bitfield2 As UInteger
    Public AccelerationStructure As ULong
End Structure
import ctypes
from ctypes import wintypes

class D3D12_RAYTRACING_INSTANCE_DESC(ctypes.Structure):
    _fields_ = [
        ("Transform", ctypes.c_float * 12),
        ("_bitfield1", wintypes.DWORD),
        ("_bitfield2", wintypes.DWORD),
        ("AccelerationStructure", ctypes.c_ulonglong),
    ]
#[repr(C)]
pub struct D3D12_RAYTRACING_INSTANCE_DESC {
    pub Transform: [f32; 12],
    pub _bitfield1: u32,
    pub _bitfield2: u32,
    pub AccelerationStructure: u64,
}
import "golang.org/x/sys/windows"

type D3D12_RAYTRACING_INSTANCE_DESC struct {
	Transform [12]float32
	_bitfield1 uint32
	_bitfield2 uint32
	AccelerationStructure uint64
}
type
  D3D12_RAYTRACING_INSTANCE_DESC = record
    Transform: array[0..11] of Single;
    _bitfield1: DWORD;
    _bitfield2: DWORD;
    AccelerationStructure: UInt64;
  end;
const D3D12_RAYTRACING_INSTANCE_DESC = extern struct {
    Transform: [12]f32,
    _bitfield1: u32,
    _bitfield2: u32,
    AccelerationStructure: u64,
};
type
  D3D12_RAYTRACING_INSTANCE_DESC {.bycopy.} = object
    Transform: array[12, float32]
    _bitfield1: uint32
    _bitfield2: uint32
    AccelerationStructure: uint64
struct D3D12_RAYTRACING_INSTANCE_DESC
{
    float[12] Transform;
    uint _bitfield1;
    uint _bitfield2;
    ulong AccelerationStructure;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; D3D12_RAYTRACING_INSTANCE_DESC サイズ: 64 バイト(x64)
dim st, 16    ; 4byte整数×16(構造体サイズ 64 / 4 切り上げ)
; Transform : FLOAT (+0, 48byte)  varptr(st)+0 を基点に操作(48byte:入れ子/配列)
; _bitfield1 : DWORD (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; _bitfield2 : DWORD (+52, 4byte)  st.13 = 値  /  値 = st.13   (lpoke/lpeek も可)
; AccelerationStructure : ULONGLONG (+56, 8byte)  qpoke st,56,値 / qpeek(st,56)  ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global D3D12_RAYTRACING_INSTANCE_DESC
    #field float Transform 12
    #field int _bitfield1
    #field int _bitfield2
    #field int64 AccelerationStructure
#endstruct

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