d3d12: Fix indexed quad draw

We were not positionning the index buffer correctly in the heap.
This commit is contained in:
vlj 2015-05-25 18:47:54 +02:00 committed by Vincent Lejeune
parent 82545a7b56
commit e9fab57a0e
1 changed files with 17 additions and 14 deletions

View File

@ -320,17 +320,23 @@ std::pair<std::vector<D3D12_VERTEX_BUFFER_VIEW>, D3D12_INDEX_BUFFER_VIEW> D3D12G
{ {
D3D12_INDEX_BUFFER_VIEW indexBufferView = {}; D3D12_INDEX_BUFFER_VIEW indexBufferView = {};
size_t indexSize; size_t indexSize;
switch (m_indexed_array.m_type)
{ if (!indexed_draw)
default: // If it's not indexed draw, use 16 bits unsigned short
case CELL_GCM_DRAW_INDEX_ARRAY_TYPE_16:
indexBufferView.Format = DXGI_FORMAT_R16_UINT; indexBufferView.Format = DXGI_FORMAT_R16_UINT;
indexSize = 2; else
break; {
case CELL_GCM_DRAW_INDEX_ARRAY_TYPE_32: switch (m_indexed_array.m_type)
indexBufferView.Format = DXGI_FORMAT_R32_UINT; {
indexSize = 4; default: abort();
break; case CELL_GCM_DRAW_INDEX_ARRAY_TYPE_16:
indexBufferView.Format = DXGI_FORMAT_R16_UINT;
indexSize = 2;
break;
case CELL_GCM_DRAW_INDEX_ARRAY_TYPE_32:
indexBufferView.Format = DXGI_FORMAT_R32_UINT;
indexSize = 4;
break;
}
} }
if (indexed_draw && !m_forcedIndexBuffer) if (indexed_draw && !m_forcedIndexBuffer)
@ -347,7 +353,7 @@ std::pair<std::vector<D3D12_VERTEX_BUFFER_VIEW>, D3D12_INDEX_BUFFER_VIEW> D3D12G
ID3D12Resource *indexBuffer; ID3D12Resource *indexBuffer;
check(m_device->CreatePlacedResource( check(m_device->CreatePlacedResource(
getCurrentResourceStorage().m_vertexIndexBuffersHeap, getCurrentResourceStorage().m_vertexIndexBuffersHeap,
D3D12_HEAP_FLAG_NONE, bufferHeapOffset,
&getBufferResourceDesc(subBufferSize), &getBufferResourceDesc(subBufferSize),
D3D12_RESOURCE_STATE_GENERIC_READ, D3D12_RESOURCE_STATE_GENERIC_READ,
nullptr, nullptr,
@ -393,9 +399,6 @@ std::pair<std::vector<D3D12_VERTEX_BUFFER_VIEW>, D3D12_INDEX_BUFFER_VIEW> D3D12G
indexBufferView.SizeInBytes = (UINT)subBufferSize; indexBufferView.SizeInBytes = (UINT)subBufferSize;
indexBufferView.BufferLocation = indexBuffer->GetGPUVirtualAddress(); indexBufferView.BufferLocation = indexBuffer->GetGPUVirtualAddress();
if (m_forcedIndexBuffer)
indexBufferView.Format = DXGI_FORMAT_R16_UINT;
result.second = indexBufferView; result.second = indexBufferView;
} }
return result; return result;