@@ -25,7 +25,6 @@ class AutoexposureApp final : public examples::SimpleWindowedApplication, public
2525
2626 constexpr static inline std::string_view DefaultImagePathsFile = " ../../media/noises/spp_benchmark_4k_512.exr" ;
2727
28-
2928public:
3029 // Yay thanks to multiple inheritance we cannot forward ctors anymore
3130 inline AutoexposureApp (const path& _localInputCWD, const path& _localOutputCWD, const path& _sharedInputCWD, const path& _sharedOutputCWD) :
@@ -108,6 +107,65 @@ class AutoexposureApp final : public examples::SimpleWindowedApplication, public
108107
109108 auto queue = getGraphicsQueue ();
110109
110+ // init the surface and create the swapchain
111+ {
112+ ISwapchain::SCreationParams swapchainParams = { .surface = smart_refctd_ptr<ISurface>(m_surface->getSurface ()) };
113+ // Need to choose a surface format
114+ if (!swapchainParams.deduceFormat (m_physicalDevice))
115+ return logFail (" Could not choose a Surface Format for the Swapchain!" );
116+ // We actually need external dependencies to ensure ordering of the Implicit Layout Transitions relative to the semaphore signals
117+ constexpr IGPURenderpass::SCreationParams::SSubpassDependency dependencies[] = {
118+ // wipe-transition to ATTACHMENT_OPTIMAL
119+ {
120+ .srcSubpass = IGPURenderpass::SCreationParams::SSubpassDependency::External,
121+ .dstSubpass = 0 ,
122+ .memoryBarrier = {
123+ // since we're uploading the image data we're about to draw
124+ .srcStageMask = asset::PIPELINE_STAGE_FLAGS::COPY_BIT,
125+ .srcAccessMask = asset::ACCESS_FLAGS::TRANSFER_WRITE_BIT,
126+ .dstStageMask = asset::PIPELINE_STAGE_FLAGS::COLOR_ATTACHMENT_OUTPUT_BIT,
127+ // because we clear and don't blend
128+ .dstAccessMask = asset::ACCESS_FLAGS::COLOR_ATTACHMENT_WRITE_BIT
129+ }
130+ // leave view offsets and flags default
131+ },
132+ // ATTACHMENT_OPTIMAL to PRESENT_SRC
133+ {
134+ .srcSubpass = 0 ,
135+ .dstSubpass = IGPURenderpass::SCreationParams::SSubpassDependency::External,
136+ .memoryBarrier = {
137+ .srcStageMask = asset::PIPELINE_STAGE_FLAGS::COLOR_ATTACHMENT_OUTPUT_BIT,
138+ .srcAccessMask = asset::ACCESS_FLAGS::COLOR_ATTACHMENT_WRITE_BIT
139+ // we can have NONE as the Destinations because the spec says so about presents
140+ }
141+ // leave view offsets and flags default
142+ },
143+ IGPURenderpass::SCreationParams::DependenciesEnd
144+ };
145+ auto scResources = std::make_unique<CDefaultSwapchainFramebuffers>(m_device.get (), swapchainParams.surfaceFormat .format , dependencies);
146+ if (!scResources->getRenderpass ())
147+ return logFail (" Failed to create Renderpass!" );
148+ if (!m_surface || !m_surface->init (queue, std::move (scResources), swapchainParams.sharedParams ))
149+ return logFail (" Could not create Window & Surface or initialize the Surface!" );
150+ }
151+
152+ // Now create the pipeline
153+ /* {
154+ const asset::SPushConstantRange range = {
155+ .stageFlags = IShader::E_SHADER_STAGE::ESS_FRAGMENT,
156+ .offset = 0,
157+ .size = sizeof(push_constants_t)
158+ };
159+ auto layout = m_device->createPipelineLayout({ &range,1 }, nullptr, nullptr, nullptr, core::smart_refctd_ptr(dsLayout));
160+ const IGPUShader::SSpecInfo fragSpec = {
161+ .entryPoint = "main",
162+ .shader = fragmentShader.get()
163+ };
164+ m_pipeline = fsTriProtoPPln.createPipeline(fragSpec, layout.get(), scResources->getRenderpass());
165+ if (!m_pipeline)
166+ return logFail("Could not create Graphics Pipeline!");
167+ }*/
168+
111169 // need resetttable commandbuffers for the upload utility
112170 {
113171 m_cmdPool = m_device->createCommandPool (queue->getFamilyIndex (), IGPUCommandPool::CREATE_FLAGS::RESET_COMMAND_BUFFER_BIT);
@@ -257,8 +315,6 @@ class AutoexposureApp final : public examples::SimpleWindowedApplication, public
257315 }
258316
259317protected:
260- smart_refctd_ptr<IWindow> m_window;
261- smart_refctd_ptr<CSimpleResizeSurface<CDefaultSwapchainFramebuffers>> m_surface;
262318 smart_refctd_ptr<IGPUImage> m_gpuImg;
263319 smart_refctd_ptr<IGPUImageView> m_gpuImgView;
264320
@@ -270,6 +326,10 @@ class AutoexposureApp final : public examples::SimpleWindowedApplication, public
270326 std::array<smart_refctd_ptr<IGPUDescriptorSet>, ISwapchain::MaxImages> m_descriptorSets;
271327 smart_refctd_ptr<IGPUCommandPool> m_cmdPool;
272328 std::array<smart_refctd_ptr<IGPUCommandBuffer>, ISwapchain::MaxImages> m_cmdBufs;
329+
330+ // window
331+ smart_refctd_ptr<IWindow> m_window;
332+ smart_refctd_ptr<CSimpleResizeSurface<CDefaultSwapchainFramebuffers>> m_surface;
273333};
274334
275335NBL_MAIN_FUNC (AutoexposureApp)
0 commit comments