@@ -167,7 +167,7 @@ class NablaTutorialExampleApp : public ApplicationBase
167
167
const auto swapchainImageUsage = static_cast <asset::IImage::E_USAGE_FLAGS>(asset::IImage::EUF_COLOR_ATTACHMENT_BIT);
168
168
const video::ISurface::SFormat surfaceFormat (asset::EF_R8G8B8A8_SRGB, asset::ECP_COUNT, asset::EOTF_UNKNOWN);
169
169
170
- CommonAPI::InitWithDefaultExt (initOutput, video::EAT_OPENGL_ES , " NablaTutorialExample" , WIN_W, WIN_H, SC_IMG_COUNT, swapchainImageUsage, surfaceFormat, nbl::asset::EF_D32_SFLOAT);
170
+ CommonAPI::InitWithDefaultExt (initOutput, video::EAT_VULKAN , " NablaTutorialExample" , WIN_W, WIN_H, SC_IMG_COUNT, swapchainImageUsage, surfaceFormat, nbl::asset::EF_D32_SFLOAT);
171
171
window = std::move (initOutput.window );
172
172
windowCb = std::move (initOutput.windowCb );
173
173
apiConnection = std::move (initOutput.apiConnection );
@@ -202,13 +202,19 @@ class NablaTutorialExampleApp : public ApplicationBase
202
202
Loading an asset bundle. You can specify some flags
203
203
and parameters to have an impact on extraordinary
204
204
tasks while loading for example.
205
- */
205
+ */
206
206
207
207
asset::IAssetLoader::SAssetLoadParams loadingParams;
208
208
auto images_bundle = assetManager->getAsset (" ../../media/color_space_test/R8G8B8A8_1.png" , loadingParams);
209
209
assert (!images_bundle.getContents ().empty ());
210
210
auto image = images_bundle.getContents ().begin ()[0 ];
211
+
212
+ /*
213
+ By default an image that comes out of an image loader will only have the TRANSFER_DST usage flag.
214
+ We need to add more usages, as only we know what we'll do with the image farther along in the pipeline.
215
+ */
211
216
auto image_raw = static_cast <asset::ICPUImage*>(image.get ());
217
+ image_raw->addImageUsageFlags (asset::IImage::EUF_SAMPLED_BIT);
212
218
213
219
/*
214
220
Specifing gpu image view parameters to create a gpu
@@ -220,7 +226,16 @@ class NablaTutorialExampleApp : public ApplicationBase
220
226
cpu2gpuParams.waitForCreationToComplete ();
221
227
auto & gpuParams = gpuImage->getCreationParameters ();
222
228
223
- IImageView<IGPUImage>::SCreationParams gpuImageViewParams = { static_cast <IGPUImageView::E_CREATE_FLAGS>(0 ), gpuImage, IImageView<IGPUImage>::ET_2D, gpuParams.format , {}, {static_cast <IImage::E_ASPECT_FLAGS>(0u ), 0 , gpuParams.mipLevels , 0 , gpuParams.arrayLayers } };
229
+ IImageView<IGPUImage>::SCreationParams gpuImageViewParams = {
230
+ IGPUImageView::ECF_NONE,
231
+ gpuImage,
232
+ IImageView<IGPUImage>::ET_2D,
233
+ gpuParams.format ,
234
+ {},
235
+ {
236
+ IImage::EAF_COLOR_BIT, 0 , gpuParams.mipLevels , 0 , gpuParams.arrayLayers
237
+ }
238
+ };
224
239
auto gpuImageView = logicalDevice->createGPUImageView (std::move (gpuImageViewParams));
225
240
226
241
/*
@@ -279,15 +294,18 @@ class NablaTutorialExampleApp : public ApplicationBase
279
294
We know ahead of time that `SBasicViewParameters` struct is the expected structure of the only UBO block in the descriptor set nr. 1 of the shader.
280
295
*/
281
296
282
- IGPUBuffer::SCreationParams creationParams;
297
+ IGPUBuffer::SCreationParams creationParams = {} ;
283
298
creationParams.canUpdateSubRange = true ;
284
299
creationParams.usage = asset::IBuffer::EUF_UNIFORM_BUFFER_BIT;
285
- creationParams.sharingMode = asset::E_SHARING_MODE::ESM_CONCURRENT;
286
- creationParams.queueFamilyIndexCount = 0u ;
287
- creationParams.queueFamilyIndices = nullptr ;
288
300
IDriverMemoryBacked::SDriverMemoryRequirements memReq;
289
301
memReq.vulkanReqs .size = sizeof (SBasicViewParameters);
290
- gpuubo = logicalDevice->createGPUBufferOnDedMem (creationParams, memReq);
302
+ memReq.vulkanReqs .alignment = physicalDevice->getLimits ().UBOAlignment ;
303
+ memReq.vulkanReqs .memoryTypeBits = 0xffffffffu ;
304
+ memReq.memoryHeapLocation = IDriverMemoryAllocation::ESMT_DEVICE_LOCAL;
305
+ memReq.mappingCapability = IDriverMemoryAllocation::EMAF_NONE;
306
+ memReq.prefersDedicatedAllocation = true ;
307
+ memReq.requiresDedicatedAllocation = true ;
308
+ gpuubo = logicalDevice->createGPUBufferOnDedMem (creationParams,memReq);
291
309
292
310
/*
293
311
Creating descriptor sets - texture (sampler) and basic view parameters (UBO).
@@ -380,6 +398,7 @@ class NablaTutorialExampleApp : public ApplicationBase
380
398
if (cpuindexbuffer)
381
399
cpubuffers.push_back (cpuindexbuffer);
382
400
401
+ cpu2gpuParams.beginCommandBuffers ();
383
402
auto gpubuffers = cpu2gpu.getGPUObjectsFromAssets (cpubuffers.data (), cpubuffers.data () + cpubuffers.size (), cpu2gpuParams);
384
403
cpu2gpuParams.waitForCreationToComplete ();
385
404
0 commit comments