@@ -22,6 +22,7 @@ using namespace nbl;
22
22
using namespace asset ;
23
23
using namespace video ;
24
24
using namespace core ;
25
+ using namespace ui ;
25
26
26
27
class GLTFApp : public ApplicationBase
27
28
{
@@ -84,8 +85,10 @@ class GLTFApp : public ApplicationBase
84
85
void onAppInitialized_impl () override
85
86
{
86
87
initOutput.window = core::smart_refctd_ptr (window);
87
-
88
- CommonAPI::Init<WIN_W, WIN_H, SC_IMG_COUNT>(initOutput, video::EAT_OPENGL, " glTF" , asset::EF_D32_SFLOAT);
88
+
89
+ const auto swapchainImageUsage = static_cast <asset::IImage::E_USAGE_FLAGS>(asset::IImage::EUF_COLOR_ATTACHMENT_BIT);
90
+ const video::ISurface::SFormat surfaceFormat (asset::EF_B8G8R8A8_SRGB, asset::ECP_COUNT, asset::EOTF_UNKNOWN);
91
+ CommonAPI::InitWithDefaultExt (initOutput, video::EAT_OPENGL, " glTF" , WIN_W, WIN_H, SC_IMG_COUNT, swapchainImageUsage, surfaceFormat, asset::EF_D32_SFLOAT);
89
92
window = std::move (initOutput.window );
90
93
gl = std::move (initOutput.apiConnection );
91
94
surface = std::move (initOutput.surface );
@@ -95,7 +98,7 @@ class GLTFApp : public ApplicationBase
95
98
swapchain = std::move (initOutput.swapchain );
96
99
renderpass = std::move (initOutput.renderpass );
97
100
fbos = std::move (initOutput.fbo );
98
- commandPool = std::move (initOutput.commandPool );
101
+ commandPools = std::move (initOutput.commandPools );
99
102
assetManager = std::move (initOutput.assetManager );
100
103
logger = std::move (initOutput.logger );
101
104
inputSystem = std::move (initOutput.inputSystem );
@@ -104,7 +107,7 @@ class GLTFApp : public ApplicationBase
104
107
cpu2gpuParams = std::move (initOutput.cpu2gpuParams );
105
108
utilities = std::move (initOutput.utilities );
106
109
107
- transferUpQueue = queues[decltype (initOutput) ::EQT_TRANSFER_UP];
110
+ transferUpQueue = queues[CommonAPI::InitOutput ::EQT_TRANSFER_UP];
108
111
109
112
transformTreeManager = scene::ITransformTreeManager::create (utilities.get (),transferUpQueue);
110
113
ttDebugDrawPipeline = transformTreeManager->createDebugPipeline <scene::ITransformTreeWithNormalMatrices>(core::smart_refctd_ptr (renderpass));
@@ -114,37 +117,7 @@ class GLTFApp : public ApplicationBase
114
117
sicDebugDrawPipeline = sicManager->createDebugPipeline (core::smart_refctd_ptr (renderpass));
115
118
sicDescriptorSets = sicManager->createAllDescriptorSets (logicalDevice.get ());
116
119
117
- auto gpuTransferFence = logicalDevice->createFence (static_cast <video::IGPUFence::E_CREATE_FLAGS>(0 ));
118
- auto gpuComputeFence = logicalDevice->createFence (static_cast <video::IGPUFence::E_CREATE_FLAGS>(0 ));
119
-
120
120
nbl::video::IGPUObjectFromAssetConverter cpu2gpu;
121
- {
122
- cpu2gpuParams.perQueue [nbl::video::IGPUObjectFromAssetConverter::EQU_TRANSFER].fence = &gpuTransferFence;
123
- cpu2gpuParams.perQueue [nbl::video::IGPUObjectFromAssetConverter::EQU_COMPUTE].fence = &gpuComputeFence;
124
- }
125
-
126
- auto cpu2gpuWaitForFences = [&]() -> void
127
- {
128
- video::IGPUFence::E_STATUS waitStatus = video::IGPUFence::ES_NOT_READY;
129
- while (waitStatus != video::IGPUFence::ES_SUCCESS)
130
- {
131
- waitStatus = logicalDevice->waitForFences (1u , &gpuTransferFence.get (), false , 99999999ull );
132
- if (waitStatus == video::IGPUFence::ES_ERROR)
133
- assert (false );
134
- else if (waitStatus == video::IGPUFence::ES_TIMEOUT)
135
- break ;
136
- }
137
-
138
- waitStatus = video::IGPUFence::ES_NOT_READY;
139
- while (waitStatus != video::IGPUFence::ES_SUCCESS)
140
- {
141
- waitStatus = logicalDevice->waitForFences (1u , &gpuComputeFence.get (), false , 99999999ull );
142
- if (waitStatus == video::IGPUFence::ES_ERROR)
143
- assert (false );
144
- else if (waitStatus == video::IGPUFence::ES_TIMEOUT)
145
- break ;
146
- }
147
- };
148
121
149
122
auto createDescriptorPool = [&](const uint32_t amount, const E_DESCRIPTOR_TYPE type) // TODO: review
150
123
{
@@ -230,7 +203,7 @@ class GLTFApp : public ApplicationBase
230
203
nbl::core::smart_refctd_ptr<nbl::video::IGPUCommandBuffer> xferCmdbuf;
231
204
{
232
205
xferFence = logicalDevice->createFence (static_cast <nbl::video::IGPUFence::E_CREATE_FLAGS>(0 ));
233
- logicalDevice->createCommandBuffers (commandPool .get (),nbl::video::IGPUCommandBuffer::EL_PRIMARY,1u ,&xferCmdbuf);
206
+ logicalDevice->createCommandBuffers (commandPools[CommonAPI::InitOutput::EQT_TRANSFER_UP] .get (),nbl::video::IGPUCommandBuffer::EL_PRIMARY,1u ,&xferCmdbuf);
234
207
xferCmdbuf->begin (0 );
235
208
}
236
209
auto xferQueue = logicalDevice->getQueue (xferCmdbuf->getQueueFamilyIndex (),0u );
@@ -779,7 +752,7 @@ class GLTFApp : public ApplicationBase
779
752
camera = Camera (cameraPosition, core::vectorSIMDf (0 , 0 , 0 ), projectionMatrix, 0 .4f , 1 .f );
780
753
auto lastTime = std::chrono::system_clock::now ();
781
754
782
- logicalDevice->createCommandBuffers (commandPool .get (),video::IGPUCommandBuffer::EL_PRIMARY,FRAMES_IN_FLIGHT,commandBuffers);
755
+ logicalDevice->createCommandBuffers (commandPools[CommonAPI::InitOutput::EQT_GRAPHICS] .get (),video::IGPUCommandBuffer::EL_PRIMARY,FRAMES_IN_FLIGHT,commandBuffers);
783
756
784
757
//
785
758
oracle.reportBeginFrameRecord ();
@@ -795,7 +768,15 @@ class GLTFApp : public ApplicationBase
795
768
const auto & fboCreationParams = fbos[acquiredNextFBO]->getCreationParameters ();
796
769
auto gpuSourceImageView = fboCreationParams.attachments [0 ];
797
770
798
- bool status = ext::ScreenShot::createScreenShot (logicalDevice.get (), queues[decltype (initOutput)::EQT_TRANSFER_UP], renderFinished[resourceIx].get (), gpuSourceImageView.get (), assetManager.get (), " ScreenShot.png" );
771
+ bool status = ext::ScreenShot::createScreenShot (
772
+ logicalDevice.get (),
773
+ queues[CommonAPI::InitOutput::EQT_TRANSFER_UP],
774
+ renderFinished[resourceIx].get (),
775
+ gpuSourceImageView.get (),
776
+ assetManager.get (),
777
+ " ScreenShot.png" ,
778
+ asset::EIL_PRESENT_SRC,
779
+ static_cast <asset::E_ACCESS_FLAGS>(0u ));
799
780
assert (status);
800
781
}
801
782
@@ -1016,17 +997,17 @@ class GLTFApp : public ApplicationBase
1016
997
}
1017
998
1018
999
private:
1019
- CommonAPI::InitOutput<SC_IMG_COUNT> initOutput;
1000
+ CommonAPI::InitOutput initOutput;
1020
1001
nbl::core::smart_refctd_ptr<nbl::ui::IWindow> window;
1021
1002
nbl::core::smart_refctd_ptr<nbl::video::IAPIConnection> gl;
1022
1003
nbl::core::smart_refctd_ptr<nbl::video::ISurface> surface;
1023
1004
nbl::video::IPhysicalDevice* gpuPhysicalDevice;
1024
1005
nbl::core::smart_refctd_ptr<nbl::video::ILogicalDevice> logicalDevice;
1025
- std::array<nbl::video::IGPUQueue*, CommonAPI::InitOutput<SC_IMG_COUNT>::EQT_COUNT > queues = { nullptr , nullptr , nullptr , nullptr } ;
1006
+ std::array<nbl::video::IGPUQueue*, CommonAPI::InitOutput::MaxQueuesCount > queues;
1026
1007
nbl::core::smart_refctd_ptr<nbl::video::ISwapchain> swapchain;
1027
1008
nbl::core::smart_refctd_ptr<nbl::video::IGPURenderpass> renderpass;
1028
- std::array<nbl::core::smart_refctd_ptr<nbl::video::IGPUFramebuffer>, SC_IMG_COUNT > fbos;
1029
- nbl::core::smart_refctd_ptr<nbl::video::IGPUCommandPool> commandPool ;
1009
+ std::array<nbl::core::smart_refctd_ptr<nbl::video::IGPUFramebuffer>, CommonAPI::InitOutput::MaxSwapChainImageCount > fbos;
1010
+ std::array< nbl::core::smart_refctd_ptr<nbl::video::IGPUCommandPool>, CommonAPI::InitOutput::MaxQueuesCount> commandPools ;
1030
1011
nbl::core::smart_refctd_ptr<nbl::asset::IAssetManager> assetManager;
1031
1012
nbl::core::smart_refctd_ptr<nbl::system::ILogger> logger;
1032
1013
nbl::core::smart_refctd_ptr<CommonAPI::InputSystem> inputSystem;
0 commit comments