Memcpy related fixes.
This commit is contained in:
parent
88d74de291
commit
6f29f580bd
|
|
@ -36,7 +36,7 @@ TextureManager::Commit(Texture *texture)
|
|||
|
||||
// Ensure it is copyable.
|
||||
static_assert(std::is_trivially_copyable_v<Texture>);
|
||||
memcpy(allocatedTexture, texture, sizeof *texture);
|
||||
*allocatedTexture = *texture;
|
||||
|
||||
// Take ownership of the buffer.
|
||||
texture->m_MipLevels_ &= ~Texture::OWNED_BIT;
|
||||
|
|
@ -51,7 +51,7 @@ TextureManager::Commit(Texture *texture)
|
|||
|
||||
// Ensure it is copyable.
|
||||
static_assert(std::is_trivially_copyable_v<Texture>);
|
||||
memcpy(allocatedTexture, texture, sizeof *texture);
|
||||
*allocatedTexture = *texture;
|
||||
|
||||
texture->m_MipLevels_ &= ~Texture::OWNED_BIT;
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ BufferManager::Commit(StorageBuffer *buffer)
|
|||
|
||||
// Ensure it is copyable.
|
||||
static_assert(std::is_trivially_copyable_v<StorageBuffer>);
|
||||
memcpy(allocatedBuffer, buffer, sizeof *buffer);
|
||||
*allocatedBuffer = *buffer;
|
||||
|
||||
// Take ownership of the buffer.
|
||||
buffer->m_Size_ &= ~StorageBuffer::OWNED_BIT;
|
||||
|
|
@ -130,7 +130,7 @@ BufferManager::Commit(StorageBuffer *buffer)
|
|||
|
||||
// Ensure it is copyable.
|
||||
static_assert(std::is_trivially_copyable_v<StorageBuffer>);
|
||||
memcpy(allocatedBuffer, buffer, sizeof *buffer);
|
||||
*allocatedBuffer = *buffer;
|
||||
|
||||
buffer->m_Size_ &= ~StorageBuffer::OWNED_BIT;
|
||||
|
||||
|
|
|
|||
|
|
@ -154,10 +154,14 @@ LightManager::AddDirectional(const vec3 &direction, const vec3 &color, f32 inten
|
|||
if (m_MetaInfo.m_PointLightMaxCount > 0) // Edge Case: nullptr at size 0
|
||||
{
|
||||
Light *oldPointStart = m_Lights.data() + oldPointLightOffset;
|
||||
Light *newPointStart = oldPointStart + 2;
|
||||
Light *oldPointEnd = oldPointStart + pointLightMaxCount;
|
||||
Light *newPointEnd = oldPointEnd + 2;
|
||||
|
||||
static_assert(std::is_trivially_copyable_v<Light>);
|
||||
memcpy(newPointStart, oldPointStart, pointLightMaxCount * sizeof *newPointStart);
|
||||
|
||||
// Overlaps since 0 -> 2, 1 -> 3, 2 -> 4 (old 2 is lost)
|
||||
// Backward copy fixes this.
|
||||
std::copy_backward(oldPointStart, oldPointEnd, newPointEnd);
|
||||
}
|
||||
|
||||
m_MetaInfo.m_PointLightOffset += 2;
|
||||
|
|
|
|||
Loading…
Reference in New Issue