@@ -17,6 +17,7 @@ using namespace asset;
17
17
using namespace ui ;
18
18
using namespace video ;
19
19
20
+ // defines for sampler tests can be found in the file below
20
21
#include " app_resources/push_constants.hlsl"
21
22
22
23
@@ -126,17 +127,47 @@ class ColorSpaceTestSampleApp final : public examples::SimpleWindowedApplication
126
127
.AnisotropicFilter = 0
127
128
});
128
129
129
- const IGPUDescriptorSetLayout::SBinding bindings[1 ] = {{
130
+ #if defined(COMBINED_IMMUTABLE) || defined(COMBINED_MUTABLE)
131
+ const IGPUDescriptorSetLayout::SBinding bindings[1 ] = { {
130
132
.binding = 0 ,
131
133
.type = IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER,
132
134
.createFlags = IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_NONE,
133
135
.stageFlags = IShader::ESS_FRAGMENT,
134
136
.count = 1 ,
137
+ #if defined(COMBINED_IMMUTABLE)
135
138
.samplers = &defaultSampler
136
- }};
139
+ #else
140
+ .samplers = 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
+ .samplers = 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
+ .samplers = &defaultSampler
161
+ #else
162
+ .samplers = nullptr
163
+ #endif
164
+ }
165
+ };
166
+ #endif
137
167
dsLayout = m_device->createDescriptorSetLayout (bindings);
138
168
if (!dsLayout)
139
169
return logFail (" Failed to Create Descriptor Layout" );
170
+
140
171
}
141
172
142
173
ISwapchain::SCreationParams swapchainParams = {.surface =m_surface->getSurface ()};
@@ -257,6 +288,12 @@ class ColorSpaceTestSampleApp final : public examples::SimpleWindowedApplication
257
288
// We do a very simple thing, display an image and wait `DisplayImageMs` to show it
258
289
inline void workLoopBody () override
259
290
{
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
260
297
// load the image view
261
298
system::path filename, extension;
262
299
smart_refctd_ptr<ICPUImageView> cpuImgView;
@@ -390,13 +427,36 @@ class ColorSpaceTestSampleApp final : public examples::SimpleWindowedApplication
390
427
info.desc = m_device->createImageView (std::move (viewParams));
391
428
}
392
429
430
+ #if defined(COMBINED_IMMUTABLE) || defined(COMBINED_MUTABLE) || defined(SEPARATED_IMMUTABLE)
431
+ #if defined(COMBINED_MUTABLE)
432
+ info.info .image .sampler = defaultSampler;
433
+ #endif
393
434
const IGPUDescriptorSet::SWriteDescriptorSet writes[] = {{
394
435
.dstSet = ds,
395
436
.binding = 0 ,
396
437
.arrayElement = 0 ,
397
438
.count = 1 ,
398
439
.info = &info
399
440
}};
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
400
460
m_device->updateDescriptorSets (writes,{});
401
461
}
402
462
0 commit comments