set viewport and scissor

This commit is contained in:
Samuliak 2024-07-31 20:50:24 +02:00
parent be8a560496
commit 1fbd6ad376
4 changed files with 91 additions and 12 deletions

View file

@ -3,9 +3,11 @@
const size_t BUFFER_ALLOCATION_SIZE = 8 * 1024 * 1024;
// TODO: uncomment everything
MetalBufferAllocation MetalBufferAllocator::GetBufferAllocation(size_t size)
{
// First, try to find a free range
/*
for (uint32 i = 0; i < m_freeBufferRanges.size(); i++)
{
auto& range = m_freeBufferRanges[i];
@ -27,9 +29,10 @@ MetalBufferAllocation MetalBufferAllocator::GetBufferAllocation(size_t size)
return allocation;
}
}
*/
// If no free range was found, allocate a new buffer
MTL::Buffer* buffer = m_mtlr->GetDevice()->newBuffer(std::max(size, BUFFER_ALLOCATION_SIZE), MTL::ResourceStorageModeShared);
MTL::Buffer* buffer = m_mtlr->GetDevice()->newBuffer(/*std::max(*/size/*, BUFFER_ALLOCATION_SIZE)*/, MTL::ResourceStorageModeShared);
MetalBufferAllocation allocation;
allocation.bufferIndex = m_buffers.size();
@ -39,6 +42,7 @@ MetalBufferAllocation MetalBufferAllocator::GetBufferAllocation(size_t size)
m_buffers.push_back(buffer);
// If the buffer is larger than the requested size, add the remaining space to the free buffer ranges
/*
if (size < BUFFER_ALLOCATION_SIZE)
{
MetalBufferRange range;
@ -48,6 +52,7 @@ MetalBufferAllocation MetalBufferAllocator::GetBufferAllocation(size_t size)
m_freeBufferRanges.push_back(range);
}
*/
return allocation;
}