Fix NanoVDBLoader: reset command list before use
This commit is contained in:
@@ -8,8 +8,13 @@
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
bool LoadNanoVDB(const char* filePath, NanoVDBData& outData, ID3D12GraphicsCommandList* cmdList) {
|
||||
bool LoadNanoVDB(const char* filePath, NanoVDBData& outData, ID3D12GraphicsCommandList* cmdList, ID3D12CommandAllocator* cmdAlloc) {
|
||||
try {
|
||||
if (cmdAlloc && cmdList) {
|
||||
cmdAlloc->Reset();
|
||||
cmdList->Reset(cmdAlloc, nullptr);
|
||||
}
|
||||
|
||||
nanovdb::GridHandle<nanovdb::HostBuffer> gridHandle = nanovdb::io::readGrid(filePath);
|
||||
|
||||
const uint64_t byteSize = gridHandle.buffer().bufferSize();
|
||||
|
||||
@@ -10,6 +10,6 @@ struct NanoVDBData {
|
||||
uint64_t elementCount;
|
||||
};
|
||||
|
||||
bool LoadNanoVDB(const char* filePath, NanoVDBData& outData, ID3D12GraphicsCommandList* cmdList = nullptr);
|
||||
bool LoadNanoVDB(const char* filePath, NanoVDBData& outData, ID3D12GraphicsCommandList* cmdList, ID3D12CommandAllocator* cmdAlloc = nullptr);
|
||||
void FreeNanoVDB(NanoVDBData& data);
|
||||
|
||||
|
||||
12
main.cpp
12
main.cpp
@@ -17,26 +17,32 @@ LPCWSTR gWindowClassName = L"BattleFire";
|
||||
|
||||
void RunNanoVDBTest() {
|
||||
ID3D12GraphicsCommandList* commandList = GetCommandList();
|
||||
ID3D12CommandAllocator* commandAllocator = GetCommandAllocator();
|
||||
const char* vdbFiles[] = {
|
||||
"Res/NanoVDB/bunny.nvdb"
|
||||
};
|
||||
|
||||
NanoVDBData vdbData = {};
|
||||
|
||||
for (int i = 0; i < sizeof(vdbFiles) / sizeof(vdbFiles[0]); i++) {
|
||||
const char* currentVdbFile = vdbFiles[i];
|
||||
printf("[NanoVDB Test] Loading: %s\n", currentVdbFile);
|
||||
|
||||
NanoVDBData vdbData;
|
||||
bool loadSuccess = LoadNanoVDB(currentVdbFile, vdbData, commandList);
|
||||
bool loadSuccess = LoadNanoVDB(currentVdbFile, vdbData, commandList, commandAllocator);
|
||||
if (loadSuccess) {
|
||||
printf(" SUCCESS - %llu bytes, %llu elements\n",
|
||||
(unsigned long long)vdbData.byteSize,
|
||||
(unsigned long long)vdbData.elementCount);
|
||||
FreeNanoVDB(vdbData);
|
||||
} else {
|
||||
printf(" FAILED\n");
|
||||
}
|
||||
}
|
||||
printf("[NanoVDB Test] Done.\n");
|
||||
|
||||
FreeNanoVDB(vdbData);
|
||||
|
||||
EndCommandList();
|
||||
WaitForCompletionOfCommandList();
|
||||
}
|
||||
|
||||
LRESULT CALLBACK WindowProc(HWND inHWND, UINT inMSG, WPARAM inWParam, LPARAM inLParam) {
|
||||
|
||||
Reference in New Issue
Block a user