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

D3D12_RESOURCE_DESC

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

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

フィールド

フィールドサイズx64x86説明
DimensionD3D12_RESOURCE_DIMENSION4+0+0リソースの次元。バッファ・1D/2D/3Dテクスチャを指定する。
AlignmentULONGLONG8+8+8リソースのアライメント(バイト)。0で既定値となる。
WidthULONGLONG8+16+16リソースの幅。バッファ時はバイト長を表す。
HeightDWORD4+24+24リソースの高さ(テクセル)。バッファ時は1。
DepthOrArraySizeWORD2+28+283D時の奥行き、または1D/2D時の配列サイズ。
MipLevelsWORD2+30+30ミップマップレベル数。0で最大まで自動生成。
FormatDXGI_FORMAT4+32+32リソースのDXGIフォーマット。バッファ時はUNKNOWN。
SampleDescDXGI_SAMPLE_DESC8+36+36マルチサンプリングのサンプル数と品質。
LayoutD3D12_TEXTURE_LAYOUT4+44+44テクスチャのメモリレイアウト。未知・行優先・スウィズル等を指定する。
FlagsD3D12_RESOURCE_FLAGS4+48+48リソースの用途フラグ。RT/DS/UAV許可などを指定する。

各言語での定義

#include <windows.h>

// DXGI_SAMPLE_DESC  (x64 8 / x86 8 バイト)
typedef struct DXGI_SAMPLE_DESC {
    DWORD Count;
    DWORD Quality;
} DXGI_SAMPLE_DESC;

// D3D12_RESOURCE_DESC  (x64 56 / x86 56 バイト)
typedef struct D3D12_RESOURCE_DESC {
    D3D12_RESOURCE_DIMENSION Dimension;
    ULONGLONG Alignment;
    ULONGLONG Width;
    DWORD Height;
    WORD DepthOrArraySize;
    WORD MipLevels;
    DXGI_FORMAT Format;
    DXGI_SAMPLE_DESC SampleDesc;
    D3D12_TEXTURE_LAYOUT Layout;
    D3D12_RESOURCE_FLAGS Flags;
} D3D12_RESOURCE_DESC;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DXGI_SAMPLE_DESC
{
    public uint Count;
    public uint Quality;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct D3D12_RESOURCE_DESC
{
    public int Dimension;
    public ulong Alignment;
    public ulong Width;
    public uint Height;
    public ushort DepthOrArraySize;
    public ushort MipLevels;
    public int Format;
    public DXGI_SAMPLE_DESC SampleDesc;
    public int Layout;
    public int Flags;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DXGI_SAMPLE_DESC
    Public Count As UInteger
    Public Quality As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure D3D12_RESOURCE_DESC
    Public Dimension As Integer
    Public Alignment As ULong
    Public Width As ULong
    Public Height As UInteger
    Public DepthOrArraySize As UShort
    Public MipLevels As UShort
    Public Format As Integer
    Public SampleDesc As DXGI_SAMPLE_DESC
    Public Layout As Integer
    Public Flags As Integer
End Structure
import ctypes
from ctypes import wintypes

class DXGI_SAMPLE_DESC(ctypes.Structure):
    _fields_ = [
        ("Count", wintypes.DWORD),
        ("Quality", wintypes.DWORD),
    ]

class D3D12_RESOURCE_DESC(ctypes.Structure):
    _fields_ = [
        ("Dimension", ctypes.c_int),
        ("Alignment", ctypes.c_ulonglong),
        ("Width", ctypes.c_ulonglong),
        ("Height", wintypes.DWORD),
        ("DepthOrArraySize", ctypes.c_ushort),
        ("MipLevels", ctypes.c_ushort),
        ("Format", ctypes.c_int),
        ("SampleDesc", DXGI_SAMPLE_DESC),
        ("Layout", ctypes.c_int),
        ("Flags", ctypes.c_int),
    ]
#[repr(C)]
pub struct DXGI_SAMPLE_DESC {
    pub Count: u32,
    pub Quality: u32,
}

#[repr(C)]
pub struct D3D12_RESOURCE_DESC {
    pub Dimension: i32,
    pub Alignment: u64,
    pub Width: u64,
    pub Height: u32,
    pub DepthOrArraySize: u16,
    pub MipLevels: u16,
    pub Format: i32,
    pub SampleDesc: DXGI_SAMPLE_DESC,
    pub Layout: i32,
    pub Flags: i32,
}
import "golang.org/x/sys/windows"

type DXGI_SAMPLE_DESC struct {
	Count uint32
	Quality uint32
}

type D3D12_RESOURCE_DESC struct {
	Dimension int32
	Alignment uint64
	Width uint64
	Height uint32
	DepthOrArraySize uint16
	MipLevels uint16
	Format int32
	SampleDesc DXGI_SAMPLE_DESC
	Layout int32
	Flags int32
}
type
  DXGI_SAMPLE_DESC = record
    Count: DWORD;
    Quality: DWORD;
  end;

  D3D12_RESOURCE_DESC = record
    Dimension: Integer;
    Alignment: UInt64;
    Width: UInt64;
    Height: DWORD;
    DepthOrArraySize: Word;
    MipLevels: Word;
    Format: Integer;
    SampleDesc: DXGI_SAMPLE_DESC;
    Layout: Integer;
    Flags: Integer;
  end;
const DXGI_SAMPLE_DESC = extern struct {
    Count: u32,
    Quality: u32,
};

const D3D12_RESOURCE_DESC = extern struct {
    Dimension: i32,
    Alignment: u64,
    Width: u64,
    Height: u32,
    DepthOrArraySize: u16,
    MipLevels: u16,
    Format: i32,
    SampleDesc: DXGI_SAMPLE_DESC,
    Layout: i32,
    Flags: i32,
};
type
  DXGI_SAMPLE_DESC {.bycopy.} = object
    Count: uint32
    Quality: uint32

  D3D12_RESOURCE_DESC {.bycopy.} = object
    Dimension: int32
    Alignment: uint64
    Width: uint64
    Height: uint32
    DepthOrArraySize: uint16
    MipLevels: uint16
    Format: int32
    SampleDesc: DXGI_SAMPLE_DESC
    Layout: int32
    Flags: int32
struct DXGI_SAMPLE_DESC
{
    uint Count;
    uint Quality;
}

struct D3D12_RESOURCE_DESC
{
    int Dimension;
    ulong Alignment;
    ulong Width;
    uint Height;
    ushort DepthOrArraySize;
    ushort MipLevels;
    int Format;
    DXGI_SAMPLE_DESC SampleDesc;
    int Layout;
    int Flags;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; D3D12_RESOURCE_DESC サイズ: 56 バイト(x64)
dim st, 14    ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; Dimension : D3D12_RESOURCE_DIMENSION (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Alignment : ULONGLONG (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; Width : ULONGLONG (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; Height : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; DepthOrArraySize : WORD (+28, 2byte)  wpoke st,28,値  /  値 = wpeek(st,28)
; MipLevels : WORD (+30, 2byte)  wpoke st,30,値  /  値 = wpeek(st,30)
; Format : DXGI_FORMAT (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; SampleDesc : DXGI_SAMPLE_DESC (+36, 8byte)  varptr(st)+36 を基点に操作(8byte:入れ子/配列)
; Layout : D3D12_TEXTURE_LAYOUT (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; Flags : D3D12_RESOURCE_FLAGS (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global DXGI_SAMPLE_DESC
    #field int Count
    #field int Quality
#endstruct

#defstruct global D3D12_RESOURCE_DESC
    #field int Dimension
    #field int64 Alignment
    #field int64 Width
    #field int Height
    #field short DepthOrArraySize
    #field short MipLevels
    #field int Format
    #field DXGI_SAMPLE_DESC SampleDesc
    #field int Layout
    #field int Flags
#endstruct

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