Skip to content

Commit 0dbb22f

Browse files
Fix example 27, but Vulkan still has errors
1 parent ccc026f commit 0dbb22f

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

examples_tests/27.PLYSTLDemo/main.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ APP_CONSTRUCTOR(PLYSTLDemo)
149149
const auto swapchainImageUsage = static_cast<asset::IImage::E_USAGE_FLAGS>(asset::IImage::EUF_COLOR_ATTACHMENT_BIT);
150150
const video::ISurface::SFormat surfaceFormat(asset::EF_R8G8B8A8_SRGB, asset::ECP_COUNT, asset::EOTF_UNKNOWN);
151151

152-
CommonAPI::InitWithDefaultExt(initOutput, video::EAT_OPENGL_ES, "plystldemo", WIN_W, WIN_H, SC_IMG_COUNT, swapchainImageUsage, surfaceFormat, nbl::asset::EF_D32_SFLOAT);
152+
CommonAPI::InitWithDefaultExt(initOutput, video::EAT_OPENGL/*Vulkan doesn't work yet*/, "plystldemo", WIN_W, WIN_H, SC_IMG_COUNT, swapchainImageUsage, surfaceFormat, nbl::asset::EF_D32_SFLOAT);
153153
window = std::move(initOutput.window);
154154
gl = std::move(initOutput.apiConnection);
155155
surface = std::move(initOutput.surface);
@@ -194,19 +194,23 @@ APP_CONSTRUCTOR(PLYSTLDemo)
194194
gpuComputeFence = logicalDevice->createFence(static_cast<video::IGPUFence::E_CREATE_FLAGS>(0));
195195
gpuComputeSemaphore = logicalDevice->createSemaphore();
196196

197-
cpu2gpuParams.assetManager = assetManager.get();
197+
cpu2gpuParams.utilities = utilities.get();
198198
cpu2gpuParams.device = logicalDevice.get();
199-
cpu2gpuParams.finalQueueFamIx = queues[decltype(initOutput)::EQT_GRAPHICS]->getFamilyIndex();
200-
cpu2gpuParams.limits = gpuPhysicalDevice->getLimits();
199+
cpu2gpuParams.assetManager = assetManager.get();
201200
cpu2gpuParams.pipelineCache = nullptr;
202-
cpu2gpuParams.sharingMode = nbl::asset::ESM_CONCURRENT;
203-
cpu2gpuParams.utilities = utilities.get();
201+
cpu2gpuParams.limits = gpuPhysicalDevice->getLimits();
202+
cpu2gpuParams.finalQueueFamIx = queues[decltype(initOutput)::EQT_GRAPHICS]->getFamilyIndex();
203+
cpu2gpuParams.sharingMode = nbl::asset::ESM_EXCLUSIVE;
204204

205-
cpu2gpuParams.perQueue[nbl::video::IGPUObjectFromAssetConverter::EQU_TRANSFER].semaphore = &gpuTransferSemaphore;
205+
logicalDevice->createCommandBuffers(commandPools[CommonAPI::InitOutput::EQT_TRANSFER_UP].get(),video::IGPUCommandBuffer::EL_PRIMARY,1u,&cpu2gpuParams.perQueue[nbl::video::IGPUObjectFromAssetConverter::EQU_TRANSFER].cmdbuf);
206206
cpu2gpuParams.perQueue[nbl::video::IGPUObjectFromAssetConverter::EQU_TRANSFER].queue = queues[decltype(initOutput)::EQT_TRANSFER_UP];
207-
208-
cpu2gpuParams.perQueue[nbl::video::IGPUObjectFromAssetConverter::EQU_COMPUTE].semaphore = &gpuComputeSemaphore;
207+
cpu2gpuParams.perQueue[nbl::video::IGPUObjectFromAssetConverter::EQU_TRANSFER].semaphore = &gpuTransferSemaphore;
208+
209+
logicalDevice->createCommandBuffers(commandPools[CommonAPI::InitOutput::EQT_COMPUTE].get(),video::IGPUCommandBuffer::EL_PRIMARY,1u,&cpu2gpuParams.perQueue[nbl::video::IGPUObjectFromAssetConverter::EQU_COMPUTE].cmdbuf);
209210
cpu2gpuParams.perQueue[nbl::video::IGPUObjectFromAssetConverter::EQU_COMPUTE].queue = queues[decltype(initOutput)::EQT_COMPUTE];
211+
cpu2gpuParams.perQueue[nbl::video::IGPUObjectFromAssetConverter::EQU_COMPUTE].semaphore = &gpuComputeSemaphore;
212+
213+
cpu2gpuParams.beginCommandBuffers();
210214
}
211215

212216
auto loadAndGetCpuMesh = [&](system::path path) -> std::pair<core::smart_refctd_ptr<asset::ICPUMesh>, const asset::IAssetMetadata*>
@@ -336,6 +340,8 @@ APP_CONSTRUCTOR(PLYSTLDemo)
336340
core::smart_refctd_ptr<video::IGPUMesh> gpumesh;
337341
{
338342
auto gpu_array = cpu2gpu.getGPUObjectsFromAssets(&cpuMesh.get(), &cpuMesh.get() + 1, cpu2gpuParams);
343+
cpu2gpuParams.waitForCreationToComplete(true);
344+
cpu2gpuParams.beginCommandBuffers();
339345
if (!gpu_array || gpu_array->size() < 1u || !(*gpu_array)[0])
340346
assert(false);
341347

@@ -370,7 +376,7 @@ APP_CONSTRUCTOR(PLYSTLDemo)
370376

371377
core::vectorSIMDf cameraPosition(0, 5, -10);
372378
matrix4SIMD projectionMatrix = matrix4SIMD::buildProjectionMatrixPerspectiveFovLH(core::radians(60.0f), float(WIN_W) / WIN_H, 0.001, 1000);
373-
camera = Camera(cameraPosition, core::vectorSIMDf(0, 0, 0), projectionMatrix, 10.f, 1.f);
379+
camera = Camera(cameraPosition, core::vectorSIMDf(0, 0, 0), projectionMatrix, 0.01f, 1.f);
374380
lastTime = std::chrono::system_clock::now();
375381

376382
for (size_t i = 0ull; i < NBL_FRAMES_TO_AVERAGE; ++i)

examples_tests/Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ N = No support
5858
| FREE_SLOT | | | | | | | | | |
5959
| 25.Blur | S | N | S | S | N | S | N | S | |
6060
| FREE_SLOT | | | | | | | | | |
61-
| 27.PLYSTLDemo | Y | Y | Y | S | S | S | N | N | COMPILE_WITH_STL_LOADER & COMPILE_WITH_PLY_LOADER |
61+
| 27.PLYSTLDemo | Y | Y | B | S | S | S | N | N | COMPILE_WITH_STL_LOADER & COMPILE_WITH_PLY_LOADER |
6262
| FREE_SLOT | | | | | | | | | |
6363
| 29.SpecializationConstants | S | S | S | S | S | S | N | S | |
6464
| FREE_SLOT | | | | | | | | | |

include/nbl/video/utilities/IGPUObjectFromAssetConverter.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,13 @@ class IGPUObjectFromAssetConverter
157157
if (pFence && pFence.get()) // user wanted, and something actually got submitted
158158
fence_ptrs[count++] = pFence.get();
159159
}
160-
device->blockForFences(count,fence_ptrs);
161-
if(resetFencesAfterWait)
160+
if (count)
162161
{
163-
device->resetFences(count, fence_ptrs);
162+
device->blockForFences(count,fence_ptrs);
163+
if(resetFencesAfterWait)
164+
{
165+
device->resetFences(count, fence_ptrs);
166+
}
164167
}
165168
setFencesToNull();
166169
resetCommandBuffers();

0 commit comments

Comments
 (0)