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

ID3D11On12Device

COM
IID85611e73-70a9-490e-9614-a9e302777904継承元IUnknown自前メソッド開始 vtbl3

公式ドキュメント

Direct3D11on12 における D3D11 リソースの作成、ラップ、解放を扱います。

メソッド 3

vtbl = vtable インデックス(0始まり)。HSP等からCOMメソッドをインデックス指定で呼ぶ際に使用します。0〜2 は IUnknown。

vtbl 3 HRESULT CreateWrappedResource(IUnknown* pResource12, D3D11_RESOURCE_FLAGS* pFlags11, D3D12_RESOURCE_STATES InState, D3D12_RESOURCE_STATES OutState, GUID* riid, void** ppResource11)

このメソッドは、D3D 11on12 で使用する D3D11 リソースを作成します。

pResource12IUnknown*in作成済みの D3D12 リソースまたはヒープへのポインター。
pFlags11D3D11_RESOURCE_FLAGS*inリソース/ヒープのプロパティから推測されるフラグを、アプリケーションが上書きできるようにする D3D11_RESOURCE_FLAGS 構造体。 D3D11_RESOURCE_FLAGS 構造体には、バインドフラグ、その他 (misc) フラグ、CPU アクセスフラグが含まれます。
InStateD3D12_RESOURCE_STATESin入力時のリソースの用途。D3D12_RESOURCE_STATES 列挙型の定数のビット単位 OR の組み合わせで指定します。
OutStateD3D12_RESOURCE_STATESin出力時のリソースの用途。D3D12_RESOURCE_STATES 列挙型の定数のビット単位 OR の組み合わせで指定します。
riidGUID*inラップされたリソースのインターフェイスのグローバル一意識別子 (GUID)。 ラップされたリソースのインターフェイスの REFIID (GUID) は、__uuidof() マクロを使用して取得できます。 たとえば、__uuidof(ID3D11Resource) により、ラップされたリソースのインターフェイスの GUID が取得されます。
ppResource11void**outoptionalメソッドから制御が戻った後、新しく作成されたラップ済みの D3D11 リソースまたはヒープを指します。

戻り値

型: HRESULT

このメソッドは Direct3D 12 の戻り値コードのいずれかを返します。

vtbl 4 void ReleaseWrappedResources(ID3D11Resource** ppResources, DWORD NumResources)

D3D 11on12 用にラップされていた D3D11 リソースを解放します。

ppResourcesID3D11Resource**inID3D11Resource で定義される D3D11 リソースの集合へのポインターを指定します。
NumResourcesDWORDinリソースの数。

解説(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 リファレンスのサンプルコードを参照してください。

vtbl 5 void AcquireWrappedResources(ID3D11Resource** ppResources, DWORD NumResources)

D3D 11on12 で使用する D3D11 リソースを取得します。ラップされたリソースへの描画を再開できることを示します。

ppResourcesID3D11Resource**inID3D11Resource で定義される D3D11 リソースの集合へのポインターを指定します。
NumResourcesDWORDinリソースの数。

解説(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 の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
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 指定が可能。