d3d12: Change some variable name to better reflect their behavior

This commit is contained in:
vlj 2015-05-13 19:08:47 +02:00 committed by Vincent Lejeune
parent b016fbc9e4
commit da5b047c58
2 changed files with 7 additions and 9 deletions

View file

@ -21,7 +21,7 @@ D3D12GSRender::D3D12GSRender()
: GSRender(), m_fbo(nullptr), m_PSO(nullptr) : GSRender(), m_fbo(nullptr), m_PSO(nullptr)
{ {
memset(m_vertexBufferSize, 0, sizeof(m_vertexBufferSize)); memset(m_vertexBufferSize, 0, sizeof(m_vertexBufferSize));
m_constantsBufferOffset = 0; m_constantsBufferSize = 0;
m_constantsBufferIndex = 0; m_constantsBufferIndex = 0;
m_currentScaleOffsetBufferIndex = 0; m_currentScaleOffsetBufferIndex = 0;
// Enable d3d debug layer // Enable d3d debug layer
@ -391,8 +391,6 @@ void D3D12GSRender::setScaleOffset()
void D3D12GSRender::FillVertexShaderConstantsBuffer() void D3D12GSRender::FillVertexShaderConstantsBuffer()
{ {
size_t bufferSize = 0;
void *constantsBufferMap; void *constantsBufferMap;
check(m_constantsBuffer->Map(0, nullptr, &constantsBufferMap)); check(m_constantsBuffer->Map(0, nullptr, &constantsBufferMap));
@ -402,15 +400,15 @@ void D3D12GSRender::FillVertexShaderConstantsBuffer()
float vector[] = { c.x, c.y, c.z, c.w }; float vector[] = { c.x, c.y, c.z, c.w };
memcpy((char*)constantsBufferMap + offset, vector, 4 * sizeof(float)); memcpy((char*)constantsBufferMap + offset, vector, 4 * sizeof(float));
size_t bufferSizeCandidate = offset + 4 * sizeof(float); size_t bufferSizeCandidate = offset + 4 * sizeof(float);
bufferSize = bufferSizeCandidate > bufferSize ? bufferSizeCandidate : bufferSize; m_constantsBufferSize = bufferSizeCandidate > m_constantsBufferSize ? bufferSizeCandidate : m_constantsBufferSize;
} }
m_constantsBuffer->Unmap(0, nullptr); m_constantsBuffer->Unmap(0, nullptr);
// Align to 256 byte // make it multiple of 256 bytes
bufferSize = (bufferSize + 255) & ~255; m_constantsBufferSize = (m_constantsBufferSize + 255) & ~255;
D3D12_CONSTANT_BUFFER_VIEW_DESC constantBufferViewDesc = {}; D3D12_CONSTANT_BUFFER_VIEW_DESC constantBufferViewDesc = {};
constantBufferViewDesc.BufferLocation = m_constantsBuffer->GetGPUVirtualAddress(); constantBufferViewDesc.BufferLocation = m_constantsBuffer->GetGPUVirtualAddress();
constantBufferViewDesc.SizeInBytes = (UINT)bufferSize; constantBufferViewDesc.SizeInBytes = (UINT)m_constantsBufferSize;
D3D12_CPU_DESCRIPTOR_HANDLE Handle = m_constantsBufferDescriptorsHeap->GetCPUDescriptorHandleForHeapStart(); D3D12_CPU_DESCRIPTOR_HANDLE Handle = m_constantsBufferDescriptorsHeap->GetCPUDescriptorHandleForHeapStart();
Handle.ptr += m_constantsBufferIndex * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); Handle.ptr += m_constantsBufferIndex * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
m_device->CreateConstantBufferView(&constantBufferViewDesc, Handle); m_device->CreateConstantBufferView(&constantBufferViewDesc, Handle);
@ -947,7 +945,7 @@ void D3D12GSRender::Flip()
gfxCommandList->Release(); gfxCommandList->Release();
m_inflightCommandList.clear(); m_inflightCommandList.clear();
memset(m_vertexBufferSize, 0, sizeof(m_vertexBufferSize)); memset(m_vertexBufferSize, 0, sizeof(m_vertexBufferSize));
m_constantsBufferOffset = 0; m_constantsBufferSize = 0;
m_constantsBufferIndex = 0; m_constantsBufferIndex = 0;
m_currentScaleOffsetBufferIndex = 0; m_currentScaleOffsetBufferIndex = 0;
} }

View file

@ -56,7 +56,7 @@ private:
ID3D12Resource *m_indexBuffer, *m_vertexBuffer[m_vertex_count]; ID3D12Resource *m_indexBuffer, *m_vertexBuffer[m_vertex_count];
ID3D12Resource *m_constantsBuffer; ID3D12Resource *m_constantsBuffer;
ID3D12DescriptorHeap *m_constantsBufferDescriptorsHeap; ID3D12DescriptorHeap *m_constantsBufferDescriptorsHeap;
size_t m_constantsBufferOffset, m_constantsBufferIndex; size_t m_constantsBufferSize, m_constantsBufferIndex;
ID3D12Resource *m_scaleOffsetBuffer; ID3D12Resource *m_scaleOffsetBuffer;
ID3D12DescriptorHeap *m_scaleOffsetDescriptorHeap; ID3D12DescriptorHeap *m_scaleOffsetDescriptorHeap;