Add 3DGS D3D12 MVS bootstrap and PLY loader
This commit is contained in:
89
MVS/3DGS-D3D12/include/XC3DGSD3D12/App.h
Normal file
89
MVS/3DGS-D3D12/include/XC3DGSD3D12/App.h
Normal file
@@ -0,0 +1,89 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <wrl/client.h>
|
||||
|
||||
#include "XC3DGSD3D12/GaussianPlyLoader.h"
|
||||
#include "XCEngine/RHI/RHIEnums.h"
|
||||
#include "XCEngine/RHI/RHITypes.h"
|
||||
#include "XCEngine/RHI/D3D12/D3D12CommandAllocator.h"
|
||||
#include "XCEngine/RHI/D3D12/D3D12Buffer.h"
|
||||
#include "XCEngine/RHI/D3D12/D3D12CommandList.h"
|
||||
#include "XCEngine/RHI/D3D12/D3D12CommandQueue.h"
|
||||
#include "XCEngine/RHI/D3D12/D3D12DescriptorHeap.h"
|
||||
#include "XCEngine/RHI/D3D12/D3D12Device.h"
|
||||
#include "XCEngine/RHI/D3D12/D3D12ResourceView.h"
|
||||
#include "XCEngine/RHI/D3D12/D3D12SwapChain.h"
|
||||
#include "XCEngine/RHI/D3D12/D3D12Texture.h"
|
||||
|
||||
namespace XC3DGSD3D12 {
|
||||
|
||||
class App {
|
||||
public:
|
||||
App();
|
||||
~App();
|
||||
|
||||
bool Initialize(HINSTANCE instance, int showCommand);
|
||||
int Run();
|
||||
void SetFrameLimit(unsigned int frameLimit);
|
||||
void SetGaussianScenePath(std::wstring scenePath);
|
||||
void SetSummaryPath(std::wstring summaryPath);
|
||||
const std::wstring& GetLastErrorMessage() const;
|
||||
|
||||
private:
|
||||
static constexpr int kBackBufferCount = 2;
|
||||
static constexpr int kDefaultWidth = 1280;
|
||||
static constexpr int kDefaultHeight = 720;
|
||||
|
||||
static LRESULT CALLBACK StaticWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
LRESULT WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
bool RegisterWindowClass(HINSTANCE instance);
|
||||
bool CreateMainWindow(HINSTANCE instance, int showCommand);
|
||||
bool LoadGaussianScene();
|
||||
bool InitializeRhi();
|
||||
bool InitializeGaussianGpuResources();
|
||||
void ShutdownGaussianGpuResources();
|
||||
void Shutdown();
|
||||
void RenderFrame();
|
||||
|
||||
HWND m_hwnd = nullptr;
|
||||
HINSTANCE m_instance = nullptr;
|
||||
int m_width = kDefaultWidth;
|
||||
int m_height = kDefaultHeight;
|
||||
bool m_running = false;
|
||||
bool m_isInitialized = false;
|
||||
bool m_hasRenderedAtLeastOneFrame = false;
|
||||
unsigned int m_frameLimit = 0;
|
||||
unsigned int m_renderedFrameCount = 0;
|
||||
std::wstring m_gaussianScenePath = L"room.ply";
|
||||
std::wstring m_summaryPath;
|
||||
std::wstring m_lastErrorMessage;
|
||||
GaussianSplatRuntimeData m_gaussianSceneData;
|
||||
XCEngine::RHI::D3D12Buffer m_gaussianPositionBuffer;
|
||||
XCEngine::RHI::D3D12Buffer m_gaussianOtherBuffer;
|
||||
XCEngine::RHI::D3D12Buffer m_gaussianShBuffer;
|
||||
XCEngine::RHI::D3D12Texture m_gaussianColorTexture;
|
||||
std::unique_ptr<XCEngine::RHI::D3D12ResourceView> m_gaussianPositionView;
|
||||
std::unique_ptr<XCEngine::RHI::D3D12ResourceView> m_gaussianOtherView;
|
||||
std::unique_ptr<XCEngine::RHI::D3D12ResourceView> m_gaussianShView;
|
||||
std::unique_ptr<XCEngine::RHI::D3D12ResourceView> m_gaussianColorView;
|
||||
std::vector<Microsoft::WRL::ComPtr<ID3D12Resource>> m_gaussianUploadBuffers;
|
||||
|
||||
XCEngine::RHI::D3D12Device m_device;
|
||||
XCEngine::RHI::D3D12CommandQueue m_commandQueue;
|
||||
XCEngine::RHI::D3D12SwapChain m_swapChain;
|
||||
XCEngine::RHI::D3D12CommandAllocator m_commandAllocator;
|
||||
XCEngine::RHI::D3D12CommandList m_commandList;
|
||||
XCEngine::RHI::D3D12Texture m_depthStencil;
|
||||
XCEngine::RHI::D3D12DescriptorHeap m_rtvHeap;
|
||||
XCEngine::RHI::D3D12DescriptorHeap m_dsvHeap;
|
||||
XCEngine::RHI::D3D12ResourceView m_rtvs[kBackBufferCount];
|
||||
XCEngine::RHI::D3D12ResourceView m_dsv;
|
||||
};
|
||||
|
||||
} // namespace XC3DGSD3D12
|
||||
46
MVS/3DGS-D3D12/include/XC3DGSD3D12/GaussianPlyLoader.h
Normal file
46
MVS/3DGS-D3D12/include/XC3DGSD3D12/GaussianPlyLoader.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace XC3DGSD3D12 {
|
||||
|
||||
struct Float3 {
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
float z = 0.0f;
|
||||
};
|
||||
|
||||
struct GaussianSplatRuntimeData {
|
||||
static constexpr uint32_t kColorTextureWidth = 2048;
|
||||
static constexpr uint32_t kPositionStride = sizeof(float) * 3;
|
||||
static constexpr uint32_t kOtherStride = sizeof(uint32_t) + sizeof(float) * 3;
|
||||
static constexpr uint32_t kColorStride = sizeof(float) * 4;
|
||||
static constexpr uint32_t kShCoefficientCount = 15;
|
||||
static constexpr uint32_t kShStride = sizeof(float) * 3 * 16;
|
||||
|
||||
uint32_t splatCount = 0;
|
||||
uint32_t colorTextureWidth = kColorTextureWidth;
|
||||
uint32_t colorTextureHeight = 0;
|
||||
Float3 boundsMin = {};
|
||||
Float3 boundsMax = {};
|
||||
std::vector<std::byte> positionData;
|
||||
std::vector<std::byte> otherData;
|
||||
std::vector<std::byte> colorData;
|
||||
std::vector<std::byte> shData;
|
||||
};
|
||||
|
||||
bool LoadGaussianSceneFromPly(
|
||||
const std::filesystem::path& filePath,
|
||||
GaussianSplatRuntimeData& outData,
|
||||
std::string& outErrorMessage);
|
||||
|
||||
bool WriteGaussianSceneSummary(
|
||||
const std::filesystem::path& filePath,
|
||||
const GaussianSplatRuntimeData& data,
|
||||
std::string& outErrorMessage);
|
||||
|
||||
} // namespace XC3DGSD3D12
|
||||
Reference in New Issue
Block a user