Skip to content

Commit 15e489f

Browse files
committed
Allocate and create texture for tonemapping
1 parent cef80b3 commit 15e489f

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

26_Autoexposure/main.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,30 @@ class AutoexposureApp final : public examples::SimpleWindowedApplication, public
471471

472472
// Allocate and create texture for tonemapping
473473
{
474+
IGPUImage::SCreationParams imageParams = {};
475+
imageParams = m_gpuImg->getCreationParameters();
476+
// promote format because RGB8 and friends don't actually exist in HW
477+
{
478+
const IPhysicalDevice::SImageFormatPromotionRequest request = {
479+
.originalFormat = imageParams.format,
480+
.usages = IPhysicalDevice::SFormatImageUsages::SUsage(imageParams.usage)
481+
};
482+
imageParams.format = m_physicalDevice->promoteImageFormat(request, imageParams.tiling);
483+
}
484+
if (imageParams.type == IGPUImage::ET_3D)
485+
imageParams.flags |= IGPUImage::ECF_2D_ARRAY_COMPATIBLE_BIT;
486+
m_gpuTonemapImg = m_device->createImage(std::move(imageParams));
487+
if (!m_gpuTonemapImg || !m_device->allocate(m_gpuTonemapImg->getMemoryReqs(), m_gpuTonemapImg.get()).isValid())
488+
return false;
489+
m_gpuTonemapImg->setObjectDebugName("Autoexposure Tonemapper Image");
490+
491+
IGPUImageView::SCreationParams gpuTonemapImgViewParams = {
492+
.image = m_gpuTonemapImg,
493+
.viewType = IGPUImageView::ET_2D,
494+
.format = m_gpuTonemapImg->getCreationParameters().format
495+
};
496+
497+
m_gpuTonemapImgView = m_device->createImageView(std::move(gpuTonemapImgViewParams));
474498
}
475499

476500
return true;
@@ -479,7 +503,6 @@ class AutoexposureApp final : public examples::SimpleWindowedApplication, public
479503
// We do a very simple thing, display an image and wait `DisplayImageMs` to show it
480504
inline void workLoopBody() override
481505
{
482-
483506
// Acquire
484507
auto acquire = m_surface->acquireNextImage();
485508
if (!acquire)

0 commit comments

Comments
 (0)