@@ -12,9 +12,9 @@ using namespace nbl::asset;
12
12
using namespace nbl ::video;
13
13
using namespace ext ::FFT;
14
14
15
- core::SRange<const asset:: SPushConstantRange> FFT::getDefaultPushConstantRanges ()
15
+ core::SRange<const SPushConstantRange> FFT::getDefaultPushConstantRanges ()
16
16
{
17
- static const asset:: SPushConstantRange ranges[1 ] =
17
+ static const SPushConstantRange ranges[1 ] =
18
18
{
19
19
{
20
20
ISpecializedShader::ESS_COMPUTE,
@@ -25,9 +25,31 @@ core::SRange<const asset::SPushConstantRange> FFT::getDefaultPushConstantRanges(
25
25
return {ranges, ranges+1 };
26
26
}
27
27
28
- core::SRange< const video::IGPUDescriptorSetLayout::SBinding > FFT::getDefaultBindings (video:: IVideoDriver* driver, DataType inputType )
28
+ core::smart_refctd_ptr<IGPUSampler > FFT::getSampler ( IVideoDriver* driver,ISampler::E_TEXTURE_CLAMP textureWrap )
29
29
{
30
- static core::smart_refctd_ptr<IGPUSampler> sampler;
30
+ IGPUSampler::SParams params =
31
+ {
32
+ {
33
+ textureWrap,
34
+ textureWrap,
35
+ textureWrap,
36
+ ISampler::ETBC_FLOAT_TRANSPARENT_BLACK,
37
+ ISampler::ETF_NEAREST,
38
+ ISampler::ETF_NEAREST,
39
+ ISampler::ESMM_NEAREST,
40
+ 0u ,
41
+ 0u ,
42
+ ISampler::ECO_ALWAYS
43
+ }
44
+ };
45
+ // TODO: cache using the asset manager's caches
46
+ return driver->createGPUSampler (params);
47
+ }
48
+
49
+ core::smart_refctd_ptr<IGPUDescriptorSetLayout> FFT::getDefaultDescriptorSetLayout (IVideoDriver* driver, FFT::DataType inputType)
50
+ {
51
+ const bool usingTexture = inputType==DataType::TEXTURE2D;
52
+ core::smart_refctd_ptr<IGPUSampler> sampler = usingTexture ? getSampler (driver,ISampler::ETC_CLAMP_TO_EDGE):nullptr ;
31
53
32
54
static IGPUDescriptorSetLayout::SBinding bnd[] =
33
55
{
@@ -36,7 +58,7 @@ core::SRange<const video::IGPUDescriptorSetLayout::SBinding> FFT::getDefaultBind
36
58
EDT_STORAGE_BUFFER,
37
59
1u ,
38
60
ISpecializedShader::ESS_COMPUTE,
39
- &sampler
61
+ usingTexture ? &sampler: nullptr
40
62
},
41
63
{
42
64
1u ,
@@ -47,38 +69,24 @@ core::SRange<const video::IGPUDescriptorSetLayout::SBinding> FFT::getDefaultBind
47
69
},
48
70
};
49
71
50
- if (DataType::SSBO == inputType) {
51
- bnd[0 ].type = EDT_STORAGE_BUFFER;
52
- } else if (DataType::TEXTURE2D == inputType) {
72
+ if (usingTexture)
53
73
bnd[0 ].type = EDT_COMBINED_IMAGE_SAMPLER;
54
- }
55
-
56
- bnd[0 ].samplers = nullptr ;
57
-
58
- if (!sampler)
59
- {
60
- IGPUSampler::SParams params =
61
- {
62
- {
63
- ISampler::ETC_CLAMP_TO_EDGE,
64
- ISampler::ETC_CLAMP_TO_EDGE,
65
- ISampler::ETC_CLAMP_TO_EDGE,
66
- ISampler::ETBC_FLOAT_OPAQUE_BLACK,
67
- ISampler::ETF_NEAREST,
68
- ISampler::ETF_NEAREST,
69
- ISampler::ESMM_NEAREST,
70
- 0u ,
71
- 0u ,
72
- ISampler::ECO_ALWAYS
73
- }
74
- };
75
- sampler = driver->createGPUSampler (params);
76
- }
77
-
78
- return {bnd, bnd+sizeof (bnd)/sizeof (IGPUDescriptorSetLayout::SBinding)};
74
+ else
75
+ bnd[0 ].type = EDT_STORAGE_BUFFER;
76
+ return driver->createGPUDescriptorSetLayout (bnd,bnd+sizeof (bnd)/sizeof (IGPUDescriptorSetLayout::SBinding));
77
+ }
78
+
79
+ //
80
+ core::smart_refctd_ptr<IGPUPipelineLayout> FFT::getDefaultPipelineLayout (IVideoDriver* driver, FFT::DataType inputType)
81
+ {
82
+ auto pcRange = getDefaultPushConstantRanges ();
83
+ return driver->createGPUPipelineLayout (
84
+ pcRange.begin (),pcRange.end (),
85
+ getDefaultDescriptorSetLayout (driver,inputType),nullptr ,nullptr ,nullptr
86
+ );
79
87
}
80
88
81
- core::smart_refctd_ptr<video:: IGPUSpecializedShader> FFT::createShader (video:: IVideoDriver* driver, DataType inputType, uint32_t maxDimensionSize)
89
+ core::smart_refctd_ptr<IGPUSpecializedShader> FFT::createShader (IVideoDriver* driver, DataType inputType, uint32_t maxDimensionSize)
82
90
{
83
91
uint32_t const maxPaddedDimensionSize = core::roundUpToPoT (maxDimensionSize);
84
92
@@ -93,27 +101,25 @@ R"===(#version 430 core
93
101
94
102
)===" ;
95
103
96
- const size_t extraSize = 32 + 32 + 32 + 32 ;
104
+ constexpr size_t extraSize = 10u * 2u + 1u ;
97
105
98
106
const uint32_t useSSBOforInput = (DataType::SSBO == inputType) ? 1 : 0 ;
99
- auto shader = core::make_smart_refctd_ptr<ICPUBuffer>(strlen (sourceFmt)+extraSize+1u );
107
+ auto source = core::make_smart_refctd_ptr<ICPUBuffer>(strlen (sourceFmt)+extraSize+1u );
100
108
snprintf (
101
- reinterpret_cast <char *>(shader ->getPointer ()),shader ->getSize (), sourceFmt,
109
+ reinterpret_cast <char *>(source ->getPointer ()),source ->getSize (), sourceFmt,
102
110
useSSBOforInput,
103
111
DEFAULT_WORK_GROUP_SIZE,
104
112
maxPaddedDimensionSize
105
113
);
106
114
107
- auto cpuSpecializedShader = core::make_smart_refctd_ptr<ICPUSpecializedShader>(
108
- core::make_smart_refctd_ptr<ICPUShader>(std::move (shader),ICPUShader::buffer_contains_glsl),
109
- ISpecializedShader::SInfo{nullptr , nullptr , " main" , asset::ISpecializedShader::ESS_COMPUTE}
110
- );
115
+ auto shader = driver->createGPUShader (core::make_smart_refctd_ptr<ICPUShader>(std::move (source),asset::ICPUShader::buffer_contains_glsl));
111
116
112
- auto gpuShader = driver->createGPUShader (nbl::core::smart_refctd_ptr<const ICPUShader>(cpuSpecializedShader->getUnspecialized ()));
113
-
114
- auto gpuSpecializedShader = driver->createGPUSpecializedShader (gpuShader.get (), cpuSpecializedShader->getSpecializationInfo ());
117
+ auto specializedShader = driver->createGPUSpecializedShader (
118
+ shader.get (),
119
+ ISpecializedShader::SInfo{nullptr , nullptr , " main" , ISpecializedShader::ESS_COMPUTE}
120
+ );
115
121
116
- return gpuSpecializedShader ;
122
+ return specializedShader ;
117
123
}
118
124
119
125
void FFT::defaultBarrier ()
0 commit comments