ユーザ用ツール

サイト用ツール


d3d:d3d12:texture

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
最新のリビジョン両方とも次のリビジョン
d3d:d3d12:texture [2015/09/20 20:27] – [例] ogad3d:d3d12:texture [2015/09/20 20:39] – [例] oga
行 23: 行 23:
  
 ===== 例 ===== ===== 例 =====
 +
 +Texture 用 Resource 作成。
  
 <code cpp> <code cpp>
行 42: 行 44:
  
 iD3DDevice->CreateCommitedResource( &heap, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS(&iTexture) ); iD3DDevice->CreateCommitedResource( &heap, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS(&iTexture) );
 +</code>
  
 +Footprint 取得。
 +
 +<code cpp>
 D3D12_PLACED_SUBRESOURCE_FOOTPRINT  footprint; D3D12_PLACED_SUBRESOURCE_FOOTPRINT  footprint;
 UINT64  total_bytes= 0; UINT64  total_bytes= 0;
 iD3DDevice->GetCopyableFootprints( &desc, 0, 1, 0, &footprint, nullptr, nullptr, &total_bytes ); iD3DDevice->GetCopyableFootprints( &desc, 0, 1, 0, &footprint, nullptr, nullptr, &total_bytes );
 </code> </code>
 +
 +Upload 用 Buffer 作成
  
 <code cpp> <code cpp>
行 67: 行 75:
 </code> </code>
  
 +Upload Buffer への書き込み。
  
 +<code cpp>
 +void*  ptr= nullptr;
 +iUploadBuffer->Map( 0, nullptr, &ptr );
 +memcpy( reinterpret_cast<unsigned char*>(ptr) + footprint.Offset, pixel_data, pixel_data_size );
 +</code>
 +
 +Copy コマンド作成
 +
 +<code cpp>
 +D3D12_TEXTURE_COPY_LOCATION  dest;
 +memset( &dest, 0, sizeof(dest) );
 +dest.pResource= iTexture;
 +dest.Type= D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
 +dest.SubresourceIndex= 0;
 +
 +D3D12_TEXTURE_COPY_LOCATION  src;
 +memset( &src, 0, sizeof(src) );
 +src.pResource= iUploadBuffer;
 +src.Type= D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
 +src.PlacedFootprint= footprint;
 +
 +ID3D12GraphicsCommandList*  iCommandList= GetCurrentCommandList();
 +iCommandList->CopyTextureRegion( &dest, 0, 0, 0, &src, nullptr );
 +</code>
 +
 +ResourceBarrier 挿入
 +
 +<code cpp>
 +D3D12_RESOURCE_BARRIER  barrier;
 +memset( &barrier, 0, sizeof(barrier) );
 +barrier.Type= D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
 +barrier.Transition.pResource= iTexture;
 +barrier.Transition.Subresource= D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
 +barrier.Transition.StateBefore= D3D12_RESOURCE_STATE_COPY_DEST;
 +barrier.Transition.StateAfter= D3D12_RESOURCE_STATE_GENERIC_READ;
 +
 +iCommandList->ResourceBarrier( 1, &barrier );
 +</code>
  
  
d3d/d3d12/texture.txt · 最終更新: 2015/09/20 20:45 by oga

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki