Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/rendercore_optix7/rendercore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ void RenderCore::SetMaterials( CoreMaterial* mat, const int materialCount )
if (materialBuffer == 0 || materialCount > materialBuffer->GetSize())
{
delete hostMaterialBuffer;
hostMaterialBuffer = new CUDAMaterial[materialCount];
hostMaterialBuffer = new CUDAMaterial[materialCount + 512];
}
for (int i = 0; i < materialCount; i++)
{
Expand Down Expand Up @@ -556,9 +556,11 @@ void RenderCore::SetMaterials( CoreMaterial* mat, const int materialCount )
// just set the new material data
materialBuffer->SetHostData( hostMaterialBuffer );
}
else /* if (materialCount > materialBuffer->GetSize()) */
else if (materialCount > materialBuffer->GetSize())
{
// TODO: realloc, remove +512 during allocation
delete materialBuffer;
materialBuffer = new CoreBuffer<CUDAMaterial>( materialCount + 512, ON_HOST | ON_DEVICE | STAGED, hostMaterialBuffer );
}
materialBuffer->StageCopyToDevice();
stageMaterialList( materialBuffer->DevPtr() );
Expand Down