| 302 | } |
| 303 | |
| 304 | void StaticModel::FlushVertexColors() |
| 305 | { |
| 306 | RenderContext::GPULocker.Lock(); |
| 307 | for (int32 lodIndex = 0; lodIndex < _vertexColorsCount; lodIndex++) |
| 308 | { |
| 309 | auto& vertexColorsData = _vertexColorsData[lodIndex]; |
| 310 | auto& vertexColorsBuffer = _vertexColorsBuffer[lodIndex]; |
| 311 | if (vertexColorsData.HasItems()) |
| 312 | { |
| 313 | const uint32 size = vertexColorsData.Count() * sizeof(Color32); |
| 314 | if (!vertexColorsBuffer) |
| 315 | vertexColorsBuffer = GPUDevice::Instance->CreateBuffer(TEXT("VertexColors")); |
| 316 | if (vertexColorsBuffer->GetSize() != size) |
| 317 | { |
| 318 | auto layout = GPUVertexLayout::Get({{ VertexElement::Types::Color, 2, 0, 0, PixelFormat::R8G8B8A8_UNorm }}); |
| 319 | if (vertexColorsBuffer->Init(GPUBufferDescription::Vertex(layout, sizeof(Color32), vertexColorsData.Count(), nullptr))) |
| 320 | break; |
| 321 | } |
| 322 | GPUDevice::Instance->GetMainContext()->UpdateBuffer(vertexColorsBuffer, vertexColorsData.Get(), size); |
| 323 | } |
| 324 | else |
| 325 | { |
| 326 | SAFE_DELETE_GPU_RESOURCE(vertexColorsBuffer); |
| 327 | } |
| 328 | } |
| 329 | RenderContext::GPULocker.Unlock(); |
| 330 | } |
| 331 | |
| 332 | void StaticModel::OnAssetUnloaded(Asset* asset, void* caller) |
| 333 | { |
nothing calls this directly
no test coverage detected