ID3D11On12Device
COM公式ドキュメント
Direct3D11on12 における D3D11 リソースの作成、ラップ、解放を扱います。
メソッド 3
vtbl = vtable インデックス(0始まり)。HSP等からCOMメソッドをインデックス指定で呼ぶ際に使用します。0〜2 は IUnknown。
このメソッドは、D3D 11on12 で使用する D3D11 リソースを作成します。
| pResource12 | IUnknown* | in | 作成済みの D3D12 リソースまたはヒープへのポインター。 |
| pFlags11 | D3D11_RESOURCE_FLAGS* | in | リソース/ヒープのプロパティから推測されるフラグを、アプリケーションが上書きできるようにする D3D11_RESOURCE_FLAGS 構造体。 D3D11_RESOURCE_FLAGS 構造体には、バインドフラグ、その他 (misc) フラグ、CPU アクセスフラグが含まれます。 |
| InState | D3D12_RESOURCE_STATES | in | 入力時のリソースの用途。D3D12_RESOURCE_STATES 列挙型の定数のビット単位 OR の組み合わせで指定します。 |
| OutState | D3D12_RESOURCE_STATES | in | 出力時のリソースの用途。D3D12_RESOURCE_STATES 列挙型の定数のビット単位 OR の組み合わせで指定します。 |
| riid | GUID* | in | ラップされたリソースのインターフェイスのグローバル一意識別子 (GUID)。 ラップされたリソースのインターフェイスの REFIID (GUID) は、__uuidof() マクロを使用して取得できます。 たとえば、__uuidof(ID3D11Resource) により、ラップされたリソースのインターフェイスの GUID が取得されます。 |
| ppResource11 | void** | outoptional | メソッドから制御が戻った後、新しく作成されたラップ済みの D3D11 リソースまたはヒープを指します。 |
戻り値
型: HRESULT
このメソッドは Direct3D 12 の戻り値コードのいずれかを返します。
D3D 11on12 用にラップされていた D3D11 リソースを解放します。
| ppResources | ID3D11Resource** | in | ID3D11Resource で定義される D3D11 リソースの集合へのポインターを指定します。 |
| NumResources | DWORD | in | リソースの数。 |
解説(Remarks)
Flush を呼び出す前にこのメソッドを呼び出してください。適切な「out」状態へのリソースバリアーが挿入され、以降それらのリソースが「in」状態にあると見なされるようマークされます。 リソースの一覧を指定しない場合は、ラップされたすべてのリソースが遷移します。 これらのリソースは、ID3D11On12Device::AcquireWrappedResources が呼び出されるまで、ハザード追跡において「未取得 (not acquired)」としてマークされます。
キー付きミューテックス (keyed mutex) のリソースをこのメソッドに渡すことはできません。代わりに IDXGIKeyedMutex::ReleaseSync を使用してください。
例
11On12 デバイスを介して D2D を使用し、D3D12 の上にテキストを描画します。
// Render text over D3D12 using D2D via the 11On12 device.
void D3D1211on12::RenderUI()
{
D2D1_SIZE_F rtSize = m_d2dRenderTargets[m_frameIndex]->GetSize();
D2D1_RECT_F textRect = D2D1::RectF(0, 0, rtSize.width, rtSize.height);
static const WCHAR text[] = L"11On12";
// Acquire our wrapped render target resource for the current back buffer.
m_d3d11On12Device->AcquireWrappedResources(m_wrappedBackBuffers[m_frameIndex].GetAddressOf(), 1);
// Render text directly to the back buffer.
m_d2dDeviceContext->SetTarget(m_d2dRenderTargets[m_frameIndex].Get());
m_d2dDeviceContext->BeginDraw();
m_d2dDeviceContext->SetTransform(D2D1::Matrix3x2F::Identity());
m_d2dDeviceContext->DrawTextW(
text,
_countof(text) - 1,
m_textFormat.Get(),
&textRect,
m_textBrush.Get()
);
ThrowIfFailed(m_d2dDeviceContext->EndDraw());
// Release our wrapped render target resource. Releasing
// transitions the back buffer resource to the state specified
// as the OutState when the wrapped resource was created.
m_d3d11On12Device->ReleaseWrappedResources(m_wrappedBackBuffers[m_frameIndex].GetAddressOf(), 1);
// Flush to submit the 11 command list to the shared command queue.
m_d3d11DeviceContext->Flush();
}
D3D12 リファレンスのサンプルコードを参照してください。
D3D 11on12 で使用する D3D11 リソースを取得します。ラップされたリソースへの描画を再開できることを示します。
| ppResources | ID3D11Resource** | in | ID3D11Resource で定義される D3D11 リソースの集合へのポインターを指定します。 |
| NumResources | DWORD | in | リソースの数。 |
解説(Remarks)
このメソッドは、ハザード追跡においてリソースを「取得済み (acquired)」としてマークします。
キー付きミューテックス (keyed mutex) のリソースをこのメソッドに渡すことはできません。代わりに IDXGIKeyedMutex::AcquireSync を使用してください。
例
11On12 デバイスを介して D2D を使用し、D3D12 の上にテキストを描画します。
// Render text over D3D12 using D2D via the 11On12 device.
void D3D1211on12::RenderUI()
{
D2D1_SIZE_F rtSize = m_d2dRenderTargets[m_frameIndex]->GetSize();
D2D1_RECT_F textRect = D2D1::RectF(0, 0, rtSize.width, rtSize.height);
static const WCHAR text[] = L"11On12";
// Acquire our wrapped render target resource for the current back buffer.
m_d3d11On12Device->AcquireWrappedResources(m_wrappedBackBuffers[m_frameIndex].GetAddressOf(), 1);
// Render text directly to the back buffer.
m_d2dDeviceContext->SetTarget(m_d2dRenderTargets[m_frameIndex].Get());
m_d2dDeviceContext->BeginDraw();
m_d2dDeviceContext->SetTransform(D2D1::Matrix3x2F::Identity());
m_d2dDeviceContext->DrawTextW(
text,
_countof(text) - 1,
m_textFormat.Get(),
&textRect,
m_textBrush.Get()
);
ThrowIfFailed(m_d2dDeviceContext->EndDraw());
// Release our wrapped render target resource. Releasing
// transitions the back buffer resource to the state specified
// as the OutState when the wrapped resource was created.
m_d3d11On12Device->ReleaseWrappedResources(m_wrappedBackBuffers[m_frameIndex].GetAddressOf(), 1);
// Flush to submit the 11 command list to the shared command queue.
m_d3d11DeviceContext->Flush();
}
D3D12 リファレンスのサンプルコードを参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
HSP用 COM定義
#usecom / #comfunc によるHSPのCOM呼び出し定義。数字は vtbl インデックス(0始まり)。クラスIDが無い場合 #usecom の末尾は "{}"、ある場合は "{CLSID}"。
#define global IID_ID3D11On12Device "{85611E73-70A9-490E-9614-A9E302777904}" #usecom global ID3D11On12Device IID_ID3D11On12Device "{}" #comfunc global ID3D11On12Device_CreateWrappedResource 3 sptr,var,int,int,var,sptr #comfunc global ID3D11On12Device_ReleaseWrappedResources 4 sptr,int #comfunc global ID3D11On12Device_AcquireWrappedResources 5 sptr,int ; ※数字は vtbl インデックス(0始まり)。0/1/2 は IUnknown(QueryInterface/AddRef/Release)。 ; ※このインターフェースは直接 CoCreateInstance するクラスIDが無いため "{}"(他メソッド/アクティベーションで取得)。 ; ※出力/バッファ引数は var(変数直渡し)。varptr 方式にも切替可。 ; ※ハンドル/void*等の不透明ポインタは IronHSP では intptr 指定が可能。#define global IID_ID3D11On12Device "{85611E73-70A9-490E-9614-A9E302777904}" #usecom global ID3D11On12Device IID_ID3D11On12Device "{}" #comfunc global ID3D11On12Device_CreateWrappedResource 3 sptr,sptr,int,int,sptr,sptr #comfunc global ID3D11On12Device_ReleaseWrappedResources 4 sptr,int #comfunc global ID3D11On12Device_AcquireWrappedResources 5 sptr,int ; ※数字は vtbl インデックス(0始まり)。0/1/2 は IUnknown(QueryInterface/AddRef/Release)。 ; ※このインターフェースは直接 CoCreateInstance するクラスIDが無いため "{}"(他メソッド/アクティベーションで取得)。 ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。 ; ※ハンドル/void*等の不透明ポインタは IronHSP では intptr 指定が可能。