Skip to content

Commit f956d79

Browse files
Fix up ex 55:
- use file logger - remove redundant frames - get rid of Vulkan validation errors
1 parent 65a7286 commit f956d79

File tree

3 files changed

+10
-22
lines changed

3 files changed

+10
-22
lines changed

examples_tests/55.RGB18E7S3/main.cpp

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ using namespace nbl;
1313
using namespace core;
1414

1515
_NBL_STATIC_INLINE_CONSTEXPR size_t WORK_GROUP_SIZE = 32; //! work-items per work-group
16-
_NBL_STATIC_INLINE_CONSTEXPR size_t MAX_TEST_RGB_VALUES = WORK_GROUP_SIZE * 1; //! total number of rgb values to test
17-
_NBL_STATIC_INLINE_CONSTEXPR size_t FRAMES_IN_FLIGHT = 3u;
16+
_NBL_STATIC_INLINE_CONSTEXPR size_t MAX_TEST_RGB_VALUES = WORK_GROUP_SIZE * 1; //! total number of rgb values to test
1817

1918
enum E_SSBO
2019
{
@@ -45,7 +44,7 @@ int main()
4544
constexpr std::string_view APP_NAME = "RGB18E7S3 utility test";
4645

4746
CommonAPI::InitOutput initOutput;
48-
CommonAPI::InitWithNoExt(initOutput, video::EAT_OPENGL, APP_NAME.data());
47+
CommonAPI::InitWithNoExt(initOutput, video::EAT_VULKAN, APP_NAME.data());
4948
auto system = std::move(initOutput.system);
5049
auto gl = std::move(initOutput.apiConnection);
5150
auto logger = std::move(initOutput.logger);
@@ -81,6 +80,7 @@ int main()
8180
{
8281
auto cpuComputeShader = core::smart_refctd_ptr_static_cast<asset::ICPUSpecializedShader>(computeShaderBundle.getContents().begin()[0]);
8382

83+
cpu2gpuParams.beginCommandBuffers();
8484
auto gpu_array = cpu2gpu.getGPUObjectsFromAssets(&cpuComputeShader, &cpuComputeShader + 1, cpu2gpuParams);
8585
if (!gpu_array || gpu_array->size() < 1u || !(*gpu_array)[0])
8686
assert(false);
@@ -128,9 +128,9 @@ int main()
128128
ssboMemoryReqs.mappingCapability = video::IDriverMemoryAllocation::EMCAF_READ_AND_WRITE;
129129

130130
video::IGPUBuffer::SCreationParams ssboCreationParams;
131-
ssboCreationParams.usage = asset::IBuffer::EUF_STORAGE_BUFFER_BIT;
131+
ssboCreationParams.usage = core::bitflag(asset::IBuffer::EUF_STORAGE_BUFFER_BIT)|asset::IBuffer::EUF_TRANSFER_DST_BIT;
132132
ssboCreationParams.canUpdateSubRange = true;
133-
ssboCreationParams.sharingMode = asset::E_SHARING_MODE::ESM_CONCURRENT;
133+
ssboCreationParams.sharingMode = asset::E_SHARING_MODE::ESM_EXCLUSIVE;
134134
ssboCreationParams.queueFamilyIndexCount = 0u;
135135
ssboCreationParams.queueFamilyIndices = nullptr;
136136

@@ -182,13 +182,10 @@ int main()
182182
auto gpuCPipelineLayout = logicalDevice->createGPUPipelineLayout(nullptr, nullptr, std::move(gpuCDescriptorSetLayout), nullptr, nullptr, nullptr);
183183
auto gpuComputePipeline = logicalDevice->createGPUComputePipeline(nullptr, std::move(gpuCPipelineLayout), std::move(gpuComputeShader));
184184

185-
core::smart_refctd_ptr<video::IGPUCommandBuffer> commandBuffers[FRAMES_IN_FLIGHT];
186-
logicalDevice->createCommandBuffers(commandPools[CommonAPI::InitOutput::EQT_COMPUTE].get(), video::IGPUCommandBuffer::EL_PRIMARY, FRAMES_IN_FLIGHT, commandBuffers);
185+
core::smart_refctd_ptr<video::IGPUCommandBuffer> commandBuffer;
186+
logicalDevice->createCommandBuffers(commandPools[CommonAPI::InitOutput::EQT_COMPUTE].get(), video::IGPUCommandBuffer::EL_PRIMARY, 1u, &commandBuffer);
187187
auto gpuFence = logicalDevice->createFence(static_cast<video::IGPUFence::E_CREATE_FLAGS>(0));
188-
189-
for(size_t i = 0; i < FRAMES_IN_FLIGHT; ++i)
190188
{
191-
auto& commandBuffer = commandBuffers[i];
192189

193190
commandBuffer->begin(0);
194191

@@ -216,18 +213,7 @@ int main()
216213
queues[decltype(initOutput)::EQT_COMPUTE]->submit(1u, &submit, gpuFence.get());
217214
}
218215
}
219-
220-
{
221-
video::IGPUFence::E_STATUS waitStatus = video::IGPUFence::ES_NOT_READY;
222-
while (waitStatus != video::IGPUFence::ES_SUCCESS)
223-
{
224-
waitStatus = logicalDevice->waitForFences(1u, &gpuFence.get(), false, 99999999999ull);
225-
if (waitStatus == video::IGPUFence::ES_ERROR)
226-
assert(false);
227-
else if (waitStatus == video::IGPUFence::ES_TIMEOUT)
228-
break;
229-
}
230-
}
216+
logicalDevice->blockForFences(1u,&gpuFence.get());
231217

232218
video::IDriverMemoryAllocation::MappedMemoryRange mappedMemoryRange(gpuDownloadSSBOmapped->getBoundMemory(), 0u, gpuDownloadSSBOmapped->getSize());
233219
logicalDevice->mapMemory(mappedMemoryRange, video::IDriverMemoryAllocation::EMCAF_READ);

include/nbl/builtin/glsl/format/encode.glsl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define _IRR_BUILTIN_GLSL_FORMAT_ENCODE_INCLUDED_
33

44
#include <nbl/builtin/glsl/format/constants.glsl>
5+
#include <nbl/builtin/glsl/limits/numeric.glsl>
56

67
uvec3 nbl_glsl_impl_sharedExponentEncodeCommon(in vec3 clamped, in int newExpBias, in int newMaxExp, in int mantissaBits, out int shared_exp)
78
{

include/nbl/system/CFileLogger.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class CFileLogger : public IThreadsafeLogger
2323
const auto str = constructLogString(fmt, logLevel, args);
2424
ISystem::future_t<size_t> future;
2525
m_file->write(future,str.data(),m_file->getSize(),str.length());
26+
future.get(); // need to use the future to make sure op is actually executed :(
2627
}
2728

2829
core::smart_refctd_ptr<IFile> m_file;

0 commit comments

Comments
 (0)