@@ -17,6 +17,7 @@ using namespace asset;
1717using namespace ui ;
1818using namespace video ;
1919
20+ // defines for sampler tests can be found in the file below
2021#include " app_resources/push_constants.hlsl"
2122
2223
@@ -126,17 +127,47 @@ class ColorSpaceTestSampleApp final : public examples::SimpleWindowedApplication
126127 .AnisotropicFilter = 0
127128 });
128129
129- const IGPUDescriptorSetLayout::SBinding bindings[1 ] = {{
130+ #if defined(COMBINED_IMMUTABLE) || defined(COMBINED_MUTABLE)
131+ const IGPUDescriptorSetLayout::SBinding bindings[1 ] = { {
130132 .binding = 0 ,
131133 .type = IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER,
132134 .createFlags = IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_NONE,
133135 .stageFlags = IShader::ESS_FRAGMENT,
134136 .count = 1 ,
135- .samplers = &defaultSampler
136- }};
137+ #if defined(COMBINED_IMMUTABLE)
138+ .immutableSamplers = &defaultSampler
139+ #else
140+ .immutableSamplers = nullptr
141+ #endif
142+ }
143+ };
144+ #else
145+ const IGPUDescriptorSetLayout::SBinding bindings[2 ] = { {
146+ .binding = 0 ,
147+ .type = IDescriptor::E_TYPE::ET_SAMPLED_IMAGE,
148+ .createFlags = IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_NONE,
149+ .stageFlags = IShader::ESS_FRAGMENT,
150+ .count = 1 ,
151+ .immutableSamplers = nullptr
152+ },
153+ {
154+ .binding = 1 ,
155+ .type = IDescriptor::E_TYPE::ET_SAMPLER,
156+ .createFlags = IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_NONE,
157+ .stageFlags = IShader::ESS_FRAGMENT,
158+ .count = 1 ,
159+ #if defined(SEPARATED_IMMUTABLE)
160+ .immutableSamplers = &defaultSampler
161+ #else
162+ .immutableSamplers = nullptr
163+ #endif
164+ }
165+ };
166+ #endif
137167 dsLayout = m_device->createDescriptorSetLayout (bindings);
138168 if (!dsLayout)
139169 return logFail (" Failed to Create Descriptor Layout" );
170+
140171 }
141172
142173 ISwapchain::SCreationParams swapchainParams = {.surface =m_surface->getSurface ()};
@@ -257,6 +288,12 @@ class ColorSpaceTestSampleApp final : public examples::SimpleWindowedApplication
257288 // We do a very simple thing, display an image and wait `DisplayImageMs` to show it
258289 inline void workLoopBody () override
259290 {
291+ // Make the sampler persist in the workloopbody
292+ #if defined(COMBINED_MUTABLE) || defined(SEPARATED_MUTABLE)
293+ static auto defaultSampler = m_device->createSampler ({
294+ .AnisotropicFilter = 0
295+ });
296+ #endif
260297 // load the image view
261298 system::path filename, extension;
262299 smart_refctd_ptr<ICPUImageView> cpuImgView;
@@ -390,13 +427,36 @@ class ColorSpaceTestSampleApp final : public examples::SimpleWindowedApplication
390427 info.desc = m_device->createImageView (std::move (viewParams));
391428 }
392429
430+ #if defined(COMBINED_IMMUTABLE) || defined(COMBINED_MUTABLE) || defined(SEPARATED_IMMUTABLE)
431+ #if defined(COMBINED_MUTABLE)
432+ info.info .image .sampler = defaultSampler;
433+ #endif
393434 const IGPUDescriptorSet::SWriteDescriptorSet writes[] = {{
394435 .dstSet = ds,
395436 .binding = 0 ,
396437 .arrayElement = 0 ,
397438 .count = 1 ,
398439 .info = &info
399440 }};
441+ #else
442+ IGPUDescriptorSet::SDescriptorInfo samplerInfo = {};
443+ samplerInfo.desc = defaultSampler;
444+ samplerInfo.info .image .sampler = defaultSampler;
445+ const IGPUDescriptorSet::SWriteDescriptorSet writes[] = { {
446+ .dstSet = ds,
447+ .binding = 0 ,
448+ .arrayElement = 0 ,
449+ .count = 1 ,
450+ .info = &info
451+ },
452+ {
453+ .dstSet = ds,
454+ .binding = 1 ,
455+ .arrayElement = 0 ,
456+ .count = 1 ,
457+ .info = &samplerInfo
458+ }};
459+ #endif
400460 m_device->updateDescriptorSets (writes,{});
401461 }
402462
0 commit comments