@@ -301,83 +301,68 @@ int main()
301
301
302
302
IAssetLoader::SAssetLoadParams lp;
303
303
auto srcImageBundle = am->getAsset (" ../../media/colorexr.exr" , lp);
304
- auto srcCpuImg = IAsset::castDown<ICPUImage>(srcImageBundle.getContents ().begin ()[0 ]);
305
304
auto kerImageBundle = am->getAsset (" ../../media/kernels/physical_flare_512.exr" , lp);
306
- auto kerCpuImg = IAsset::castDown<ICPUImage>(kerImageBundle.getContents ().begin ()[0 ]);
307
-
308
- IGPUImage::SCreationParams srcImgInfo;
309
- IGPUImage::SCreationParams kerImgInfo;
310
-
311
- smart_refctd_ptr<IGPUImage> outImg;
312
- smart_refctd_ptr<IGPUImageView> outImgView;
313
305
314
306
smart_refctd_ptr<IGPUImageView> srcImageView;
315
- IGPUImageView::SCreationParams srcImgViewInfo;
316
307
{
317
- srcImgInfo = srcCpuImg->getCreationParameters ();
318
-
319
- auto srcGpuImages = driver->getGPUObjectsFromAssets (&srcCpuImg.get (),&srcCpuImg.get ()+1 );
320
- auto srcGpuImage = srcGpuImages->operator [](0u );
308
+ auto srcGpuImages = driver->getGPUObjectsFromAssets <ICPUImage>(srcImageBundle.getContents ());
321
309
310
+ IGPUImageView::SCreationParams srcImgViewInfo;
322
311
srcImgViewInfo.flags = static_cast <IGPUImageView::E_CREATE_FLAGS>(0u );
323
- srcImgViewInfo.image = std::move (srcGpuImage );
312
+ srcImgViewInfo.image = srcGpuImages-> operator []( 0u );
324
313
srcImgViewInfo.viewType = IGPUImageView::ET_2D;
325
- srcImgViewInfo.format = srcImgInfo .format ;
314
+ srcImgViewInfo.format = srcImgViewInfo. image -> getCreationParameters () .format ;
326
315
srcImgViewInfo.subresourceRange .aspectMask = static_cast <IImage::E_ASPECT_FLAGS>(0u );
327
316
srcImgViewInfo.subresourceRange .baseMipLevel = 0 ;
328
317
srcImgViewInfo.subresourceRange .levelCount = 1 ;
329
318
srcImgViewInfo.subresourceRange .baseArrayLayer = 0 ;
330
319
srcImgViewInfo.subresourceRange .layerCount = 1 ;
331
- srcImageView = driver->createGPUImageView (IGPUImageView::SCreationParams (srcImgViewInfo));
320
+ srcImageView = driver->createGPUImageView (std::move (srcImgViewInfo));
332
321
}
333
322
smart_refctd_ptr<IGPUImageView> kerImageView;
334
323
{
335
- kerImgInfo = kerCpuImg->getCreationParameters ();
336
-
337
- auto kerGpuImages = driver->getGPUObjectsFromAssets (&kerCpuImg.get (),&kerCpuImg.get ()+1 );
338
- auto kerGpuImage = kerGpuImages->operator [](0u );
324
+ auto kerGpuImages = driver->getGPUObjectsFromAssets <ICPUImage>(kerImageBundle.getContents ());
339
325
340
326
IGPUImageView::SCreationParams kerImgViewInfo;
341
327
kerImgViewInfo.flags = static_cast <IGPUImageView::E_CREATE_FLAGS>(0u );
342
- kerImgViewInfo.image = std::move (kerGpuImage );
328
+ kerImgViewInfo.image = kerGpuImages-> operator []( 0u );
343
329
kerImgViewInfo.viewType = IGPUImageView::ET_2D;
344
- kerImgViewInfo.format = kerImgInfo .format ;
330
+ kerImgViewInfo.format = kerImgViewInfo. image -> getCreationParameters () .format ;
345
331
kerImgViewInfo.subresourceRange .aspectMask = static_cast <IImage::E_ASPECT_FLAGS>(0u );
346
332
kerImgViewInfo.subresourceRange .baseMipLevel = 0 ;
347
333
kerImgViewInfo.subresourceRange .levelCount = 1 ;
348
334
kerImgViewInfo.subresourceRange .baseArrayLayer = 0 ;
349
335
kerImgViewInfo.subresourceRange .layerCount = 1 ;
350
- kerImageView = driver->createGPUImageView (IGPUImageView::SCreationParams (kerImgViewInfo));
336
+ kerImageView = driver->createGPUImageView (std::move (kerImgViewInfo));
351
337
}
352
338
353
339
using FFTClass = ext::FFT::FFT;
354
340
355
- E_FORMAT srcFormat = srcImgInfo.format ;
356
- E_FORMAT kerFormat = kerImgInfo.format ;
357
- VkExtent3D srcDim = srcImgInfo.extent ;
358
- VkExtent3D kerDim = kerImgInfo.extent ;
341
+ const E_FORMAT srcFormat = srcImageView->getCreationParameters ().format ;
359
342
uint32_t srcNumChannels = getFormatChannelCount (srcFormat);
360
- uint32_t kerNumChannels = getFormatChannelCount (kerFormat );
343
+ uint32_t kerNumChannels = getFormatChannelCount (kerImageView-> getCreationParameters (). format );
361
344
// ! OVERRIDE (we dont need alpha)
362
345
srcNumChannels = channelCountOverride;
363
346
kerNumChannels = channelCountOverride;
364
347
assert (srcNumChannels == kerNumChannels); // Just to make sure, because the other case is not handled in this example
365
348
366
- VkExtent3D paddedDim = FFTClass::padDimensionToNextPOT (srcDim, kerDim);
367
- uint32_t maxPaddedDimensionSize = core::max (core::max (paddedDim.width , paddedDim.height ), paddedDim.depth );
368
-
369
- VkExtent3D outImageDim = srcDim;
349
+ const auto srcDim = srcImageView->getCreationParameters ().image ->getCreationParameters ().extent ;
370
350
371
351
// Create Out Image
352
+ smart_refctd_ptr<IGPUImage> outImg;
353
+ smart_refctd_ptr<IGPUImageView> outImgView;
372
354
{
373
- srcImgInfo.extent = outImageDim;
374
- outImg = driver->createDeviceLocalGPUImageOnDedMem (std::move (srcImgInfo));
355
+ auto dstImgViewInfo = srcImageView->getCreationParameters ();
375
356
376
- srcImgViewInfo.image = outImg;
377
- srcImgViewInfo.format = srcImgInfo.format ;
378
- outImgView = driver->createGPUImageView (IGPUImageView::SCreationParams (srcImgViewInfo));
379
- }
357
+ auto dstImgInfo = dstImgViewInfo.image ->getCreationParameters ();
358
+ outImg = driver->createDeviceLocalGPUImageOnDedMem (std::move (dstImgInfo));
380
359
360
+ dstImgViewInfo.image = outImg;
361
+ outImgView = driver->createGPUImageView (IGPUImageView::SCreationParams (dstImgViewInfo));
362
+ }
363
+ // TODO: re-examine
364
+ const VkExtent3D paddedDim = FFTClass::padDimensionToNextPOT (srcDim);
365
+ uint32_t maxPaddedDimensionSize = core::max (core::max (paddedDim.width , paddedDim.height ), paddedDim.depth );
381
366
auto fftGPUSpecializedShader_SSBOInput = FFTClass::createShader (driver, FFTClass::DataType::SSBO, maxPaddedDimensionSize);
382
367
auto fftGPUSpecializedShader_ImageInput = FFTClass::createShader (driver, FFTClass::DataType::TEXTURE2D, maxPaddedDimensionSize);
383
368
auto fftGPUSpecializedShader_KernelNormalization = [&]() -> auto
@@ -460,6 +445,7 @@ int main()
460
445
kernelNormalizedSpectrums[i] = createKernelSpectrum ();
461
446
462
447
// Precompute Kernel FFT
448
+ const auto kerDim = kerImageView->getCreationParameters ().image ->getCreationParameters ().extent ;
463
449
{
464
450
// Ker FFT X
465
451
auto fftDescriptorSet_Ker_FFT_X = driver->createGPUDescriptorSet (core::smart_refctd_ptr<const IGPUDescriptorSetLayout>(fftPipelineLayout_ImageInput->getDescriptorSetLayout (0u )));
@@ -610,8 +596,8 @@ int main()
610
596
auto & region = regions->front ();
611
597
612
598
region.bufferOffset = 0u ;
613
- region.bufferRowLength = srcCpuImg-> getRegions (). begin ()[ 0 ]. bufferRowLength ;
614
- region.bufferImageHeight = srcDim. height ;
599
+ region.bufferRowLength = 0u ;
600
+ region.bufferImageHeight = 0u ;
615
601
// region.imageSubresource.aspectMask = wait for Vulkan;
616
602
region.imageSubresource .mipLevel = 0u ;
617
603
region.imageSubresource .baseArrayLayer = 0u ;
0 commit comments