@@ -227,6 +227,46 @@ class AutoexposureApp final : public examples::SimpleWindowedApplication, public
227227 };
228228 }
229229
230+ // Allocate and create buffer for Luma Gather
231+ {
232+ // Allocate memory
233+ nbl::video::IDeviceMemoryAllocator::SAllocation allocation = {};
234+ smart_refctd_ptr<IGPUBuffer> buffer;
235+ // smart_refctd_ptr<nbl::video::IGPUDescriptorSet> ds;
236+ {
237+ auto build_buffer = [this ](
238+ smart_refctd_ptr<ILogicalDevice> m_device,
239+ nbl::video::IDeviceMemoryAllocator::SAllocation* allocation,
240+ smart_refctd_ptr<IGPUBuffer>& buffer,
241+ size_t buffer_size,
242+ const char * label)
243+ {
244+ IGPUBuffer::SCreationParams params;
245+ params.size = buffer_size;
246+ params.usage = IGPUBuffer::EUF_STORAGE_BUFFER_BIT | IGPUBuffer::EUF_SHADER_DEVICE_ADDRESS_BIT;
247+ buffer = m_device->createBuffer (std::move (params));
248+ if (!buffer)
249+ return logFail (" Failed to create GPU buffer of size %d!\n " , buffer_size);
250+
251+ buffer->setObjectDebugName (label);
252+
253+ auto reqs = buffer->getMemoryReqs ();
254+ reqs.memoryTypeBits &= m_physicalDevice->getHostVisibleMemoryTypeBits ();
255+
256+ *allocation = m_device->allocate (reqs, buffer.get (), IDeviceMemoryAllocation::EMAF_DEVICE_ADDRESS_BIT);
257+ if (!allocation->isValid ())
258+ return logFail (" Failed to allocate Device Memory compatible with our GPU Buffer!\n " );
259+
260+ assert (allocation->memory .get () == buffer->getBoundMemory ().memory );
261+ };
262+
263+ auto x = m_physicalDevice->getLimits ();
264+
265+ build_buffer (m_device, &allocation, buffer, m_physicalDevice->getLimits ().maxSubgroupSize , " Luma Gather Buffer" );
266+ }
267+ m_lumaGatherBDA = buffer->getDeviceAddress ();
268+ }
269+
230270 // Allocate and Leave 1/4 for image uploads, to test image copy with small memory remaining
231271 {
232272 uint32_t localOffset = video::StreamingTransientDataBufferMT<>::invalid_value;
@@ -347,8 +387,6 @@ class AutoexposureApp final : public examples::SimpleWindowedApplication, public
347387 queue->endCapture ();
348388 }
349389
350- m_computeSubgroupSize = m_physicalDevice->getLimits ().maxComputeWorkgroupSubgroups ;
351-
352390 return true ;
353391 }
354392
@@ -487,8 +525,8 @@ class AutoexposureApp final : public examples::SimpleWindowedApplication, public
487525 smart_refctd_ptr<IWindow> m_window;
488526 smart_refctd_ptr<CSimpleResizeSurface<CDefaultSwapchainFramebuffers>> m_surface;
489527
490- // constants
491- uint32_t m_computeSubgroupSize = 0 ;
528+ // luma gather
529+ uint64_t m_lumaGatherBDA ;
492530};
493531
494532NBL_MAIN_FUNC (AutoexposureApp)
@@ -531,20 +569,6 @@ int main()
531569 if (!device)
532570 return 1; // could not create selected driver.
533571
534- QToQuitEventReceiver receiver;
535- device->setEventReceiver(&receiver);
536-
537- IVideoDriver* driver = device->getVideoDriver();
538-
539- nbl::io::IFileSystem* filesystem = device->getFileSystem();
540- IAssetManager* am = device->getAssetManager();
541-
542- IAssetLoader::SAssetLoadParams lp;
543- auto imageBundle = am->getAsset("../../media/noises/spp_benchmark_4k_512.exr", lp);
544-
545- auto glslCompiler = am->getCompilerSet();
546- const auto inputColorSpace = std::make_tuple(inFormat,ECP_SRGB,EOTF_IDENTITY);
547-
548572 using LumaMeterClass = ext::LumaMeter::CLumaMeter;
549573 constexpr auto MeterMode = LumaMeterClass::EMM_MEDIAN;
550574 const float minLuma = 1.f/2048.f;
0 commit comments