Generate gaussian splat chunks during PLY import

This commit is contained in:
2026-04-11 07:13:32 +08:00
parent 92d5cc61cf
commit ff4e3f639a
3 changed files with 208 additions and 16 deletions

View File

@@ -554,16 +554,18 @@ TEST(RenderResourceCacheTest, GetOrCreateGaussianSplatSupportsSourceAssetImportP
ASSERT_NE(cached, nullptr);
EXPECT_EQ(cached->residencyState, RenderResourceCache::GaussianSplatResidencyState::GpuReady);
EXPECT_EQ(cached->splatCount, 2u);
EXPECT_EQ(state->createBufferCalls, 4);
EXPECT_EQ(state->createShaderViewCalls, 4);
EXPECT_EQ(cached->chunkCount, 1u);
EXPECT_EQ(cached->chunks.elementStride, sizeof(GaussianSplatChunkRecord));
EXPECT_EQ(state->createBufferCalls, 5);
EXPECT_EQ(state->createShaderViewCalls, 5);
const auto handleAgain = manager.Load<GaussianSplat>("Assets/sample.ply");
ASSERT_TRUE(handleAgain.IsValid());
const RenderResourceCache::CachedGaussianSplat* cachedAgain =
cache.GetOrCreateGaussianSplat(&device, handleAgain.Get());
EXPECT_EQ(cachedAgain, cached);
EXPECT_EQ(state->createBufferCalls, 4);
EXPECT_EQ(state->createShaderViewCalls, 4);
EXPECT_EQ(state->createBufferCalls, 5);
EXPECT_EQ(state->createShaderViewCalls, 5);
}
manager.UnloadAll();

View File

@@ -456,7 +456,7 @@ TEST(GaussianSplatLoader, AssetDatabaseImportsSyntheticPlyAndLinearizesData) {
auto* gaussianSplat = static_cast<GaussianSplat*>(result.resource);
ASSERT_NE(gaussianSplat, nullptr);
EXPECT_EQ(gaussianSplat->GetSplatCount(), 2u);
EXPECT_EQ(gaussianSplat->GetChunkCount(), 0u);
EXPECT_EQ(gaussianSplat->GetChunkCount(), 1u);
EXPECT_EQ(gaussianSplat->GetCameraCount(), 0u);
ExpectVector3Near(gaussianSplat->GetBounds().GetMin(), Vector3(-4.0f, -5.0f, -6.0f));
ExpectVector3Near(gaussianSplat->GetBounds().GetMax(), Vector3(1.0f, 2.0f, 3.0f));
@@ -465,6 +465,7 @@ TEST(GaussianSplatLoader, AssetDatabaseImportsSyntheticPlyAndLinearizesData) {
ASSERT_NE(gaussianSplat->GetOtherRecords(), nullptr);
ASSERT_NE(gaussianSplat->GetColorRecords(), nullptr);
ASSERT_NE(gaussianSplat->GetSHRecords(), nullptr);
ASSERT_NE(gaussianSplat->FindSection(GaussianSplatSectionType::Chunks), nullptr);
ExpectVector3Near(gaussianSplat->GetPositionRecords()[0].position, vertices[0].position);
ExpectVector3Near(gaussianSplat->GetPositionRecords()[1].position, vertices[1].position);
@@ -497,6 +498,8 @@ TEST(GaussianSplatLoader, RoomPlyBuildsArtifactAndLoadsThroughResourceManager) {
const XCEngine::Core::uint32 expectedVertexCount = ReadPlyVertexCount(fixturePath);
ASSERT_GT(expectedVertexCount, 0u);
const XCEngine::Core::uint32 expectedChunkCount =
(expectedVertexCount + kGaussianSplatChunkSize - 1u) / kGaussianSplatChunkSize;
const fs::path projectRoot = CreateTestProjectRoot("gaussian_splat_room_import");
const fs::path assetsDir = projectRoot / "Assets";
@@ -514,10 +517,12 @@ TEST(GaussianSplatLoader, RoomPlyBuildsArtifactAndLoadsThroughResourceManager) {
const auto firstHandle = manager.Load<GaussianSplat>("Assets/room.ply");
ASSERT_TRUE(firstHandle.IsValid());
EXPECT_EQ(firstHandle->GetSplatCount(), expectedVertexCount);
EXPECT_EQ(firstHandle->GetChunkCount(), expectedChunkCount);
EXPECT_EQ(firstHandle->GetPositionFormat(), GaussianSplatSectionFormat::VectorFloat32);
EXPECT_EQ(firstHandle->GetOtherFormat(), GaussianSplatSectionFormat::OtherFloat32);
EXPECT_EQ(firstHandle->GetColorFormat(), GaussianSplatSectionFormat::ColorRGBA32F);
EXPECT_EQ(firstHandle->GetSHFormat(), GaussianSplatSectionFormat::SHFloat32);
EXPECT_EQ(firstHandle->GetChunkFormat(), GaussianSplatSectionFormat::ChunkFloat32);
AssetRef assetRef;
ASSERT_TRUE(manager.TryGetAssetRef("Assets/room.ply", ResourceType::GaussianSplat, assetRef));
@@ -547,7 +552,9 @@ TEST(GaussianSplatLoader, RoomPlyBuildsArtifactAndLoadsThroughResourceManager) {
const auto secondHandle = manager.Load<GaussianSplat>(assetRef);
ASSERT_TRUE(secondHandle.IsValid());
EXPECT_EQ(secondHandle->GetSplatCount(), expectedVertexCount);
EXPECT_EQ(secondHandle->GetChunkCount(), expectedChunkCount);
ASSERT_NE(secondHandle->FindSection(GaussianSplatSectionType::SH), nullptr);
ASSERT_NE(secondHandle->FindSection(GaussianSplatSectionType::Chunks), nullptr);
}
manager.SetResourceRoot("");