3
3
// For conditions of distribution and use, see copyright notice in nabla.h
4
4
#ifndef _NBL_ASSET_C_SPIRV_INTROSPECTOR_H_INCLUDED_
5
5
#define _NBL_ASSET_C_SPIRV_INTROSPECTOR_H_INCLUDED_
6
-
6
+ # if 0
7
7
#include "nbl/core/declarations.h"
8
8
9
9
#include <cstdint>
@@ -27,6 +27,20 @@ namespace spirv_cross
27
27
struct SPIRType;
28
28
}
29
29
30
+ // podzielic CIntrospectionData na dwie klasy
31
+ // jedna bez inputOutput i bez push constant blocka `CIntrospectionData`
32
+ // druga dziedziczy z pierwszej i dodaje te 2 rzeczy `CStageIntrospectionData`
33
+
34
+ // wszystkie struktury w CIntrospecionData powininny u¿ywaæ bit flagi, ozaczaj¹cej shader stage (core::unordered_map)
35
+ // CStageIntrospecionData nie powinien u¿ywaæ bit flagi, ozaczaj¹cej shader stage (core::vector)
36
+
37
+ // hashowane s¹ tylko set i binding
38
+ // dla spec constant tylko specConstantID
39
+ // validacja kolizji (dla SSpecConstants mo¿e siê jedynie ró¿niæ name)
40
+ // ogarn¹æ sytuacje gdy jeden descriptor binding ma wiêcej arrayElementCount ni¿ w SPIR-V
41
+ // w `CStageIntrospectionData` powinien byæ trzymana struktura `SIntrospectionParams`
42
+
43
+ //
30
44
namespace nbl::asset
31
45
{
32
46
class NBL_API2 CSPIRVIntrospector : public core::Uncopyable
@@ -88,6 +102,7 @@ class NBL_API2 CSPIRVIntrospector : public core::Uncopyable
88
102
//! Sorted by `location`
89
103
core::vector<SShaderInfoVariant> inputOutput;
90
104
105
+ //! Push constants uniform block
91
106
struct {
92
107
bool present;
93
108
core::string name;
@@ -123,7 +138,7 @@ class NBL_API2 CSPIRVIntrospector : public core::Uncopyable
123
138
return false;
124
139
if (cpuShader->getContent()->getSize() != rhs.cpuShader->getContent()->getSize())
125
140
return false;
126
- return memcmp (cpuShader->getContent ()->getPointer (), rhs.cpuShader ->getContent ()->getPointer (), cpuShader->getContent ()->getSize ()) == 0 ;;
141
+ return memcmp(cpuShader->getContent()->getPointer(), rhs.cpuShader->getContent()->getPointer(), cpuShader->getContent()->getSize()) == 0;
127
142
}
128
143
};
129
144
@@ -132,43 +147,26 @@ class NBL_API2 CSPIRVIntrospector : public core::Uncopyable
132
147
133
148
//! params.cpuShader.contentType should be ECT_SPIRV
134
149
//! the compiled SPIRV must be compiled with IShaderCompiler::SCompilerOptions::debugInfoFlags enabling EDIF_SOURCE_BIT implicitly or explicitly, with no `spirvOptimizer` used in order to include names in introspection data
150
+ // powinna zwracac CStageIntrospectionData
135
151
core::smart_refctd_ptr<const CIntrospectionData> introspect(const SIntrospectionParams& params, bool insertToCache = true);
136
152
153
+ //
154
+ //core::smart_refctd_ptr<const CIntrospectionData> merge(const std::span<const CStageIntrospectionData>& asdf, const ICPUShader::SSPecInfo::spec_constant_map_t& = {});
155
+
137
156
// When the methods take a span of shaders, they are computing things for an imaginary pipeline that includes **all** of them
157
+ // przeniesc do CIntrospectionData
138
158
std::pair<bool/*is shadow sampler*/, IImageView<ICPUImage>::E_TYPE> getImageInfoFromIntrospection(uint32_t set, uint32_t binding, const std::span<const ICPUShader::SSpecInfo> _infos);
139
-
140
- inline core::smart_refctd_dynamic_array<SPushConstantRange> createPushConstantRangesFromIntrospection (const std::span<const ICPUShader::SSpecInfo> _infos)
141
- {
142
- core::vector<core::smart_refctd_ptr<const CIntrospectionData>> introspections (_infos.size ());
143
- if (!introspectAllShaders (introspections.data (),_infos))
144
- return nullptr ;
145
-
146
- return createPushConstantRangesFromIntrospection_impl (introspections.data (),_infos);
147
- }
148
- inline core::smart_refctd_ptr<ICPUDescriptorSetLayout> createApproximateDescriptorSetLayoutFromIntrospection (uint32_t set, const std::span<const ICPUShader::SSpecInfo> _infos)
149
- {
150
- core::vector<core::smart_refctd_ptr<const CIntrospectionData>> introspections (_infos.size ());
151
- if (!introspectAllShaders (introspections.data (),_infos))
152
- return nullptr ;
153
-
154
- return createApproximateDescriptorSetLayoutFromIntrospection_impl (set,introspections.data (), _infos);
155
- }
156
- inline core::smart_refctd_ptr<ICPUPipelineLayout> createApproximatePipelineLayoutFromIntrospection (const std::span<const ICPUShader::SSpecInfo> _infos)
157
- {
158
- core::vector<core::smart_refctd_ptr<const CIntrospectionData>> introspections (_infos.size ());
159
- if (!introspectAllShaders (introspections.data (),_infos))
160
- return nullptr ;
161
-
162
- return createApproximatePipelineLayoutFromIntrospection_impl (introspections.data (),_infos);
163
- }
164
159
165
160
//
166
161
inline core::smart_refctd_ptr<ICPUComputePipeline> createApproximateComputePipelineFromIntrospection(const ICPUShader::SSpecInfo& info)
162
+ //TODO: inline core::smart_refctd_ptr<ICPUComputePipeline> createApproximateComputePipelineFromIntrospection(CStageIntrospectionData* asdf)
167
163
{
168
164
if (info.shader->getStage()!=IShader::ESS_COMPUTE)
169
165
return nullptr;
170
166
171
167
core::smart_refctd_ptr<const CIntrospectionData> introspection = nullptr;
168
+
169
+ //TODO: zamiast tego mergujemy `CStageIntrospectionData` w `CIntrospectionData` u¿ywaj¹c `merge`
172
170
if (!introspectAllShaders(&introspection,{&info,1}))
173
171
return nullptr;
174
172
@@ -180,15 +178,24 @@ class NBL_API2 CSPIRVIntrospector : public core::Uncopyable
180
178
181
179
//
182
180
core::smart_refctd_ptr<ICPURenderpassIndependentPipeline> createApproximateRenderpassIndependentPipelineFromIntrospection(const std::span<const ICPUShader::SSpecInfo> _infos);
181
+
182
+ struct CShaderStages
183
+ {
184
+ const CStageIntrospectionData* vertex = nullptr;
185
+ const CStageIntrospectionData* fragment = nullptr;
186
+ const CStageIntrospectionData* control = nullptr;
187
+ const CStageIntrospectionData* evaluation = nullptr;
188
+ const CStageIntrospectionData* geometry = nullptr;
189
+ }
190
+ core::smart_refctd_ptr<ICPUGraphicsPipeline> createApproximateGraphicsPipeline(const CShaderStages& shaderStages);
183
191
184
192
private:
185
- using mapId2SpecConst_t = core::unordered_map<uint32_t , const CIntrospectionData::SSpecConstant*>;
193
+ //TODO: przenieϾ jako members do CIntrospectionData
194
+ core::smart_refctd_dynamic_array<SPushConstantRange> createPushConstantRangesFromIntrospection_impl();
195
+ core::smart_refctd_ptr<ICPUDescriptorSetLayout> createApproximateDescriptorSetLayoutFromIntrospection_impl(const uint32_t setID);
196
+ core::smart_refctd_ptr<ICPUPipelineLayout> createApproximatePipelineLayoutFromIntrospection_impl();
186
197
187
- core::smart_refctd_dynamic_array<SPushConstantRange> createPushConstantRangesFromIntrospection_impl (core::smart_refctd_ptr<const CIntrospectionData>* const introspections, const std::span<const ICPUShader::SSpecInfo> shaders);
188
- core::smart_refctd_ptr<ICPUDescriptorSetLayout> createApproximateDescriptorSetLayoutFromIntrospection_impl (uint32_t _set, core::smart_refctd_ptr<const CIntrospectionData>* const introspections, const std::span<const ICPUShader::SSpecInfo> shaders);
189
- core::smart_refctd_ptr<ICPUPipelineLayout> createApproximatePipelineLayoutFromIntrospection_impl (core::smart_refctd_ptr<const CIntrospectionData>* const introspections, const std::span<const ICPUShader::SSpecInfo> shaders);
190
-
191
- bool introspectAllShaders (core::smart_refctd_ptr<const CIntrospectionData>* introspection, const std::span<const ICPUShader::SSpecInfo> _infos);
198
+ core::smart_refctd_ptr<CStageIntrospectionData> introspectShader(const ICPUShader::SSpecInfo _infos);
192
199
193
200
core::smart_refctd_ptr<const CIntrospectionData> doIntrospection(spirv_cross::Compiler& _comp, const std::string& entryPoint, const IShader::E_SHADER_STAGE stage) const;
194
201
void shaderMemBlockIntrospection(spirv_cross::Compiler& _comp, impl::SShaderMemoryBlock& _res, uint32_t _blockBaseTypeID, uint32_t _varID, const mapId2SpecConst_t& _sortedId2sconst) const;
@@ -213,9 +220,11 @@ class NBL_API2 CSPIRVIntrospector : public core::Uncopyable
213
220
};
214
221
215
222
using ParamsToDataMap = core::unordered_map<SIntrospectionParams,core::smart_refctd_ptr<const CIntrospectionData>, KeyHasher>;
223
+ // using ParamsToDataMap = core::unordered_set<core::smart_refctd_ptr<const CStageIntrospectionData>, KeyHasher, KeyEquals>;
216
224
ParamsToDataMap m_introspectionCache;
217
225
};
218
226
219
227
} // nbl::asset
220
228
221
229
#endif
230
+ #endif
0 commit comments