Skip to content

Commit 8464015

Browse files
committed
Merge branch 'erfan_merge' of https://github.com/Devsh-Graphics-Programming/Nabla into przemog_port
2 parents 0d5aa8f + bd1e199 commit 8464015

File tree

21 files changed

+633
-495
lines changed

21 files changed

+633
-495
lines changed

3rdparty/SPIRV-Tools

Submodule SPIRV-Tools updated 258 files

3rdparty/glslang

3rdparty/nbl_spirv_cross

Submodule nbl_spirv_cross updated 426 files

examples_tests/06.MeshLoaders/main.cpp

Lines changed: 47 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ class MeshLoadersApp : public ApplicationBase
3939
nbl::core::smart_refctd_ptr<nbl::video::IUtilities> utilities;
4040
nbl::core::smart_refctd_ptr<nbl::video::ILogicalDevice> logicalDevice;
4141
nbl::video::IPhysicalDevice* physicalDevice;
42-
std::array<video::IGPUQueue*, CommonAPI::InitOutput::MaxQueuesCount> queues;
42+
std::array<video::IGPUQueue*, CommonAPI::InitOutput::MaxQueuesCount> queues;
4343
nbl::core::smart_refctd_ptr<nbl::video::ISwapchain> swapchain;
4444
nbl::core::smart_refctd_ptr<nbl::video::IGPURenderpass> renderpass;
45-
std::array<nbl::core::smart_refctd_ptr<nbl::video::IGPUFramebuffer>, CommonAPI::InitOutput::MaxSwapChainImageCount> fbo;
46-
std::array<nbl::core::smart_refctd_ptr<nbl::video::IGPUCommandPool>, CommonAPI::InitOutput::MaxQueuesCount> commandPools;
45+
std::array<nbl::core::smart_refctd_ptr<nbl::video::IGPUFramebuffer>, CommonAPI::InitOutput::MaxSwapChainImageCount> fbo;
46+
std::array<nbl::core::smart_refctd_ptr<nbl::video::IGPUCommandPool>, CommonAPI::InitOutput::MaxQueuesCount> commandPools;
4747
nbl::core::smart_refctd_ptr<nbl::system::ISystem> system;
4848
nbl::core::smart_refctd_ptr<nbl::asset::IAssetManager> assetManager;
4949
nbl::video::IGPUObjectFromAssetConverter::SParams cpu2gpuParams;
@@ -152,8 +152,8 @@ class MeshLoadersApp : public ApplicationBase
152152
initOutput.window = core::smart_refctd_ptr(window);
153153
initOutput.system = core::smart_refctd_ptr(system);
154154

155-
const auto swapchainImageUsage = static_cast<asset::IImage::E_USAGE_FLAGS>(asset::IImage::EUF_COLOR_ATTACHMENT_BIT);
156-
const video::ISurface::SFormat surfaceFormat(asset::EF_R8G8B8A8_SRGB, asset::ECP_COUNT, asset::EOTF_UNKNOWN);
155+
const auto swapchainImageUsage = static_cast<asset::IImage::E_USAGE_FLAGS>(asset::IImage::EUF_COLOR_ATTACHMENT_BIT);
156+
const video::ISurface::SFormat surfaceFormat(asset::EF_R8G8B8A8_SRGB, asset::ECP_SRGB, asset::EOTF_sRGB);
157157

158158
CommonAPI::InitWithDefaultExt(initOutput, video::EAT_OPENGL_ES, "MeshLoaders", WIN_W, WIN_H, SC_IMG_COUNT, swapchainImageUsage, surfaceFormat, nbl::asset::EF_D32_SFLOAT);
159159
window = std::move(initOutput.window);
@@ -196,6 +196,14 @@ class MeshLoadersApp : public ApplicationBase
196196

197197
quantNormalCache->saveCacheToFile<asset::EF_A2B10G10R10_SNORM_PACK32>(system.get(), sharedOutputCWD / "normalCache101010.sse");
198198
}
199+
200+
// Fix FrontFace and BlendParams for meshBuffers
201+
for (size_t i = 0ull; i < meshRaw->getMeshBuffers().size(); ++i)
202+
{
203+
auto& meshBuffer = meshRaw->getMeshBuffers().begin()[i];
204+
meshBuffer->getPipeline()->getRasterizationParams().frontFaceIsCCW = false;
205+
}
206+
199207
// we can safely assume that all meshbuffers within mesh loaded from OBJ has same DS1 layout (used for camera-specific data)
200208
firstMeshBuffer = *meshRaw->getMeshBuffers().begin();
201209
pipelineMetadata = metaOBJ->getAssetSpecificMetadata(firstMeshBuffer->getPipeline());
@@ -232,8 +240,8 @@ class MeshLoadersApp : public ApplicationBase
232240
ubomemreq.vulkanReqs.size = neededDS1UBOsz;
233241
video::IGPUBuffer::SCreationParams gpuuboCreationParams;
234242
gpuuboCreationParams.canUpdateSubRange = true;
235-
gpuuboCreationParams.usage = asset::IBuffer::EUF_UNIFORM_BUFFER_BIT;
236-
gpuuboCreationParams.sharingMode = asset::E_SHARING_MODE::ESM_CONCURRENT;
243+
gpuuboCreationParams.usage = core::bitflag<asset::IBuffer::E_USAGE_FLAGS>(asset::IBuffer::EUF_UNIFORM_BUFFER_BIT) | asset::IBuffer::EUF_TRANSFER_DST_BIT;
244+
gpuuboCreationParams.sharingMode = asset::E_SHARING_MODE::ESM_EXCLUSIVE;
237245
gpuuboCreationParams.queueFamilyIndexCount = 0u;
238246
gpuuboCreationParams.queueFamilyIndices = nullptr;
239247

@@ -305,6 +313,7 @@ class MeshLoadersApp : public ApplicationBase
305313
}
306314
void onAppTerminated_impl() override
307315
{
316+
logicalDevice->waitIdle();
308317
}
309318
void workLoopBody() override
310319
{
@@ -344,36 +353,18 @@ class MeshLoadersApp : public ApplicationBase
344353
viewport.width = WIN_W;
345354
viewport.height = WIN_H;
346355
commandBuffer->setViewport(0u, 1u, &viewport);
347-
348-
swapchain->acquireNextImage(MAX_TIMEOUT, imageAcquire[resourceIx].get(), nullptr, &acquiredNextFBO);
349-
350-
nbl::video::IGPUCommandBuffer::SRenderpassBeginInfo beginInfo;
351-
{
352-
VkRect2D area;
353-
area.offset = { 0,0 };
354-
area.extent = { WIN_W, WIN_H };
355-
asset::SClearValue clear[2] = {};
356-
clear[0].color.float32[0] = 1.f;
357-
clear[0].color.float32[1] = 1.f;
358-
clear[0].color.float32[2] = 1.f;
359-
clear[0].color.float32[3] = 1.f;
360-
clear[1].depthStencil.depth = 0.f;
361-
362-
beginInfo.clearValueCount = 2u;
363-
beginInfo.framebuffer = fbo[acquiredNextFBO];
364-
beginInfo.renderpass = renderpass;
365-
beginInfo.renderArea = area;
366-
beginInfo.clearValues = clear;
367-
}
368-
369-
commandBuffer->beginRenderPass(&beginInfo, nbl::asset::ESC_INLINE);
356+
357+
VkRect2D scissor = {};
358+
scissor.offset = { 0, 0 };
359+
scissor.extent = { WIN_W, WIN_H };
360+
commandBuffer->setScissor(0u, 1u, &scissor);
370361

371362
core::matrix3x4SIMD modelMatrix;
372363
modelMatrix.setTranslation(nbl::core::vectorSIMDf(0, 0, 0, 0));
373-
374364
core::matrix4SIMD mvp = core::concatenateBFollowedByA(viewProjectionMatrix, modelMatrix);
375365

376-
core::vector<uint8_t> uboData(gpuubo->getSize());
366+
const size_t uboSize = gpuubo->getCachedCreationParams().declaredSize;
367+
core::vector<uint8_t> uboData(uboSize);
377368
for (const auto& shdrIn : pipelineMetadata->m_inputSemantics)
378369
{
379370
if (shdrIn.descriptorSection.type == asset::IRenderpassIndependentPipelineMetadata::ShaderInput::ET_UNIFORM_BUFFER && shdrIn.descriptorSection.uniformBufferObject.set == 1u && shdrIn.descriptorSection.uniformBufferObject.binding == ds1UboBinding)
@@ -397,8 +388,28 @@ class MeshLoadersApp : public ApplicationBase
397388
}
398389
}
399390
}
391+
commandBuffer->updateBuffer(gpuubo.get(), 0ull, uboSize, uboData.data());
392+
393+
nbl::video::IGPUCommandBuffer::SRenderpassBeginInfo beginInfo;
394+
{
395+
VkRect2D area;
396+
area.offset = { 0,0 };
397+
area.extent = { WIN_W, WIN_H };
398+
asset::SClearValue clear[2] = {};
399+
clear[0].color.float32[0] = 1.f;
400+
clear[0].color.float32[1] = 1.f;
401+
clear[0].color.float32[2] = 1.f;
402+
clear[0].color.float32[3] = 1.f;
403+
clear[1].depthStencil.depth = 0.f;
400404

401-
commandBuffer->updateBuffer(gpuubo.get(), 0ull, gpuubo->getSize(), uboData.data());
405+
beginInfo.clearValueCount = 2u;
406+
beginInfo.framebuffer = fbo[acquiredNextFBO];
407+
beginInfo.renderpass = renderpass;
408+
beginInfo.renderArea = area;
409+
beginInfo.clearValues = clear;
410+
}
411+
412+
commandBuffer->beginRenderPass(&beginInfo, nbl::asset::ESC_INLINE);
402413

403414
for (size_t i = 0; i < gpumesh->getMeshBuffers().size(); ++i)
404415
{
@@ -422,7 +433,8 @@ class MeshLoadersApp : public ApplicationBase
422433

423434
commandBuffer->endRenderPass();
424435
commandBuffer->end();
425-
436+
437+
logicalDevice->resetFences(1, &fence.get());
426438
CommonAPI::Submit(logicalDevice.get(),
427439
swapchain.get(),
428440
commandBuffer.get(),
@@ -436,7 +448,7 @@ class MeshLoadersApp : public ApplicationBase
436448
}
437449
bool keepRunning() override
438450
{
439-
return true;// windowCb->isWindowOpen();
451+
return windowCb->isWindowOpen();
440452
}
441453
};
442454

examples_tests/07.SubpassBaking/main.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
using namespace nbl;
1515
using namespace core;
16+
using namespace ui;
1617

1718
int main(int argc, char** argv)
1819
{
@@ -28,7 +29,7 @@ int main(int argc, char** argv)
2829
const auto swapchainImageUsage = static_cast<asset::IImage::E_USAGE_FLAGS>(asset::IImage::EUF_COLOR_ATTACHMENT_BIT);
2930
const video::ISurface::SFormat surfaceFormat(asset::EF_B8G8R8A8_SRGB, asset::ECP_COUNT, asset::EOTF_UNKNOWN);
3031

31-
CommonAPI::InitWithDefaultExt(initOutput, video::EAT_OPENGL, "MeshLoaders", WIN_W, WIN_H, SC_IMG_COUNT, swapchainImageUsage, surfaceFormat, nbl::asset::EF_D32_SFLOAT);
32+
CommonAPI::InitWithDefaultExt(initOutput, video::EAT_VULKAN, "MeshLoaders", WIN_W, WIN_H, SC_IMG_COUNT, swapchainImageUsage, surfaceFormat, nbl::asset::EF_D32_SFLOAT);
3233
auto window = std::move(initOutput.window);
3334
auto gl = std::move(initOutput.apiConnection);
3435
auto surface = std::move(initOutput.surface);
@@ -144,10 +145,6 @@ int main(int argc, char** argv)
144145
for (size_t i = 0ull; i < meshRaw->getMeshBuffers().size(); ++i)
145146
{
146147
auto& meshBuffer = meshRaw->getMeshBuffers().begin()[i];
147-
148-
for (size_t i = 0ull; i < nbl::asset::SBlendParams::MAX_COLOR_ATTACHMENT_COUNT; i++)
149-
meshBuffer->getPipeline()->getBlendParams().blendParams[i].attachmentEnabled = (i == 0ull);
150-
151148
meshBuffer->getPipeline()->getRasterizationParams().frontFaceIsCCW = false;
152149
}
153150

@@ -395,7 +392,8 @@ int main(int argc, char** argv)
395392
const auto& viewMatrix = camera.getViewMatrix();
396393
const auto& viewProjectionMatrix = camera.getConcatenatedMatrix();
397394

398-
core::vector<uint8_t> uboData(cameraUBO->getSize());
395+
const size_t camUboSize = cameraUBO->getCachedCreationParams().declaredSize;
396+
core::vector<uint8_t> uboData(camUboSize);
399397
for (const auto& shdrIn : pipelineMetadata->m_inputSemantics)
400398
{
401399
if (shdrIn.descriptorSection.type==asset::IRenderpassIndependentPipelineMetadata::ShaderInput::ET_UNIFORM_BUFFER && shdrIn.descriptorSection.uniformBufferObject.set==1u && shdrIn.descriptorSection.uniformBufferObject.binding==cameraUBOBinding)
@@ -419,7 +417,7 @@ int main(int argc, char** argv)
419417
}
420418
}
421419
}
422-
commandBuffer->updateBuffer(cameraUBO.get(),0ull,cameraUBO->getSize(),uboData.data());
420+
commandBuffer->updateBuffer(cameraUBO.get(),0ull,camUboSize,uboData.data());
423421
}
424422

425423
// renderpass

examples_tests/22.RaytracedAO/Renderer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,6 @@ void Renderer::initSceneNonAreaLights(Renderer::InitializationData& initData)
674674
SBlendParams blendParams = {};
675675
blendParams.logicOpEnable = false;
676676
blendParams.logicOp = ELO_NO_OP;
677-
blendParams.blendParams[0].attachmentEnabled = true;
678677
blendParams.blendParams[0].blendEnable = true;
679678
blendParams.blendParams[0].srcColorFactor = asset::EBF_ONE;
680679
blendParams.blendParams[0].dstColorFactor = asset::EBF_ONE;

0 commit comments

Comments
 (0)