ホーム › Graphics.Direct3D12 › D3D12CreateDevice
D3D12CreateDevice
関数指定したアダプターと機能レベルでDirect3D12デバイスを作成する。
シグネチャ
// d3d12.dll
#include <windows.h>
HRESULT D3D12CreateDevice(
IUnknown* pAdapter, // optional
D3D_FEATURE_LEVEL MinimumFeatureLevel,
const GUID* riid,
void** ppDevice // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pAdapter | IUnknown* | inoptional |
| MinimumFeatureLevel | D3D_FEATURE_LEVEL | in |
| riid | GUID* | in |
| ppDevice | void** | outoptional |
戻り値の型: HRESULT
各言語での呼び出し定義
// d3d12.dll
#include <windows.h>
HRESULT D3D12CreateDevice(
IUnknown* pAdapter, // optional
D3D_FEATURE_LEVEL MinimumFeatureLevel,
const GUID* riid,
void** ppDevice // optional
);[DllImport("d3d12.dll", ExactSpelling = true)]
static extern int D3D12CreateDevice(
IntPtr pAdapter, // IUnknown* optional
int MinimumFeatureLevel, // D3D_FEATURE_LEVEL
ref Guid riid, // GUID*
IntPtr ppDevice // void** optional, out
);<DllImport("d3d12.dll", ExactSpelling:=True)>
Public Shared Function D3D12CreateDevice(
pAdapter As IntPtr, ' IUnknown* optional
MinimumFeatureLevel As Integer, ' D3D_FEATURE_LEVEL
ByRef riid As Guid, ' GUID*
ppDevice As IntPtr ' void** optional, out
) As Integer
End Function' pAdapter : IUnknown* optional
' MinimumFeatureLevel : D3D_FEATURE_LEVEL
' riid : GUID*
' ppDevice : void** optional, out
Declare PtrSafe Function D3D12CreateDevice Lib "d3d12" ( _
ByVal pAdapter As LongPtr, _
ByVal MinimumFeatureLevel As Long, _
ByVal riid As LongPtr, _
ByVal ppDevice As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
D3D12CreateDevice = ctypes.windll.d3d12.D3D12CreateDevice
D3D12CreateDevice.restype = ctypes.c_int
D3D12CreateDevice.argtypes = [
ctypes.c_void_p, # pAdapter : IUnknown* optional
ctypes.c_int, # MinimumFeatureLevel : D3D_FEATURE_LEVEL
ctypes.c_void_p, # riid : GUID*
ctypes.c_void_p, # ppDevice : void** optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('d3d12.dll')
D3D12CreateDevice = Fiddle::Function.new(
lib['D3D12CreateDevice'],
[
Fiddle::TYPE_VOIDP, # pAdapter : IUnknown* optional
Fiddle::TYPE_INT, # MinimumFeatureLevel : D3D_FEATURE_LEVEL
Fiddle::TYPE_VOIDP, # riid : GUID*
Fiddle::TYPE_VOIDP, # ppDevice : void** optional, out
],
Fiddle::TYPE_INT)#[link(name = "d3d12")]
extern "system" {
fn D3D12CreateDevice(
pAdapter: *mut core::ffi::c_void, // IUnknown* optional
MinimumFeatureLevel: i32, // D3D_FEATURE_LEVEL
riid: *const GUID, // GUID*
ppDevice: *mut *mut () // void** optional, out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("d3d12.dll")]
public static extern int D3D12CreateDevice(IntPtr pAdapter, int MinimumFeatureLevel, ref Guid riid, IntPtr ppDevice);
"@
$api = Add-Type -MemberDefinition $sig -Name 'd3d12_D3D12CreateDevice' -Namespace Win32 -PassThru
# $api::D3D12CreateDevice(pAdapter, MinimumFeatureLevel, riid, ppDevice)#uselib "d3d12.dll"
#func global D3D12CreateDevice "D3D12CreateDevice" sptr, sptr, sptr, sptr
; D3D12CreateDevice pAdapter, MinimumFeatureLevel, varptr(riid), ppDevice ; 戻り値は stat
; pAdapter : IUnknown* optional -> "sptr"
; MinimumFeatureLevel : D3D_FEATURE_LEVEL -> "sptr"
; riid : GUID* -> "sptr"
; ppDevice : void** optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "d3d12.dll" #cfunc global D3D12CreateDevice "D3D12CreateDevice" sptr, int, var, sptr ; res = D3D12CreateDevice(pAdapter, MinimumFeatureLevel, riid, ppDevice) ; pAdapter : IUnknown* optional -> "sptr" ; MinimumFeatureLevel : D3D_FEATURE_LEVEL -> "int" ; riid : GUID* -> "var" ; ppDevice : void** optional, out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "d3d12.dll" #cfunc global D3D12CreateDevice "D3D12CreateDevice" sptr, int, sptr, sptr ; res = D3D12CreateDevice(pAdapter, MinimumFeatureLevel, varptr(riid), ppDevice) ; pAdapter : IUnknown* optional -> "sptr" ; MinimumFeatureLevel : D3D_FEATURE_LEVEL -> "int" ; riid : GUID* -> "sptr" ; ppDevice : void** optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT D3D12CreateDevice(IUnknown* pAdapter, D3D_FEATURE_LEVEL MinimumFeatureLevel, GUID* riid, void** ppDevice) #uselib "d3d12.dll" #cfunc global D3D12CreateDevice "D3D12CreateDevice" intptr, int, var, intptr ; res = D3D12CreateDevice(pAdapter, MinimumFeatureLevel, riid, ppDevice) ; pAdapter : IUnknown* optional -> "intptr" ; MinimumFeatureLevel : D3D_FEATURE_LEVEL -> "int" ; riid : GUID* -> "var" ; ppDevice : void** optional, out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT D3D12CreateDevice(IUnknown* pAdapter, D3D_FEATURE_LEVEL MinimumFeatureLevel, GUID* riid, void** ppDevice) #uselib "d3d12.dll" #cfunc global D3D12CreateDevice "D3D12CreateDevice" intptr, int, intptr, intptr ; res = D3D12CreateDevice(pAdapter, MinimumFeatureLevel, varptr(riid), ppDevice) ; pAdapter : IUnknown* optional -> "intptr" ; MinimumFeatureLevel : D3D_FEATURE_LEVEL -> "int" ; riid : GUID* -> "intptr" ; ppDevice : void** optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
d3d12 = windows.NewLazySystemDLL("d3d12.dll")
procD3D12CreateDevice = d3d12.NewProc("D3D12CreateDevice")
)
// pAdapter (IUnknown* optional), MinimumFeatureLevel (D3D_FEATURE_LEVEL), riid (GUID*), ppDevice (void** optional, out)
r1, _, err := procD3D12CreateDevice.Call(
uintptr(pAdapter),
uintptr(MinimumFeatureLevel),
uintptr(riid),
uintptr(ppDevice),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction D3D12CreateDevice(
pAdapter: Pointer; // IUnknown* optional
MinimumFeatureLevel: Integer; // D3D_FEATURE_LEVEL
riid: PGUID; // GUID*
ppDevice: Pointer // void** optional, out
): Integer; stdcall;
external 'd3d12.dll' name 'D3D12CreateDevice';result := DllCall("d3d12\D3D12CreateDevice"
, "Ptr", pAdapter ; IUnknown* optional
, "Int", MinimumFeatureLevel ; D3D_FEATURE_LEVEL
, "Ptr", riid ; GUID*
, "Ptr", ppDevice ; void** optional, out
, "Int") ; return: HRESULT●D3D12CreateDevice(pAdapter, MinimumFeatureLevel, riid, ppDevice) = DLL("d3d12.dll", "int D3D12CreateDevice(void*, int, void*, void*)")
# 呼び出し: D3D12CreateDevice(pAdapter, MinimumFeatureLevel, riid, ppDevice)
# pAdapter : IUnknown* optional -> "void*"
# MinimumFeatureLevel : D3D_FEATURE_LEVEL -> "int"
# riid : GUID* -> "void*"
# ppDevice : void** optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。