1
- #include " nbl/asset/utils/ISPIRVDebloater .h"
1
+ #include " nbl/asset/utils/ISPIRVEntryPointTrimmer .h"
2
2
#include " nbl/asset/utils/ISPIRVOptimizer.h"
3
3
#include " nbl_spirv_cross/spirv.hpp"
4
4
@@ -10,7 +10,7 @@ using namespace nbl::asset;
10
10
11
11
static constexpr spv_target_env SPIRV_VERSION = spv_target_env::SPV_ENV_UNIVERSAL_1_6;
12
12
13
- ISPIRVDebloater::ISPIRVDebloater ()
13
+ ISPIRVEntryPointTrimmer::ISPIRVEntryPointTrimmer ()
14
14
{
15
15
constexpr auto optimizationPasses = std::array{
16
16
ISPIRVOptimizer::EOP_DEAD_BRANCH_ELIM,
@@ -78,7 +78,7 @@ static bool validate(const uint32_t* binary, uint32_t binarySize, nbl::system::l
78
78
return core.Validate (binary, binarySize, validatorOptions);
79
79
}
80
80
81
- ISPIRVDebloater ::Result ISPIRVDebloater::debloat (const ICPUBuffer* spirvBuffer, const core::set<EntryPoint>& entryPoints, system::logger_opt_ptr logger) const
81
+ ISPIRVEntryPointTrimmer ::Result ISPIRVEntryPointTrimmer::trim (const ICPUBuffer* spirvBuffer, const core::set<EntryPoint>& entryPoints, system::logger_opt_ptr logger) const
82
82
{
83
83
const auto * spirv = static_cast <const uint32_t *>(spirvBuffer->getPointer ());
84
84
const auto spirvDwordCount = spirvBuffer->getSize () / 4 ;
@@ -134,7 +134,7 @@ ISPIRVDebloater::Result ISPIRVDebloater::debloat(const ICPUBuffer* spirvBuffer,
134
134
std::vector<uint32_t > minimizedSpirv;
135
135
core::unordered_set<uint32_t > removedEntryPointIds;
136
136
137
- bool needDebloat = false ;
137
+ bool needtrim = false ;
138
138
auto offset = HEADER_SIZE;
139
139
auto parse_instruction = [](uint32_t instruction) -> std::tuple<uint32_t , uint32_t >
140
140
{
@@ -185,16 +185,16 @@ ISPIRVDebloater::Result ISPIRVDebloater::debloat(const ICPUBuffer* spirvBuffer,
185
185
foundEntryPoint += 1 ; // a valid spirv will have unique entry points, so this should works
186
186
} else
187
187
{
188
- if (needDebloat == false )
188
+ if (needtrim == false )
189
189
{
190
190
minimizedSpirv.reserve (spirvDwordCount);
191
191
minimizedSpirv.insert (minimizedSpirv.end (), spirv, spirv + curOffset);
192
- needDebloat = true ;
192
+ needtrim = true ;
193
193
}
194
194
removedEntryPointIds.insert (curEntryPointId);
195
195
continue ;
196
196
}
197
- if (!needDebloat ) continue ;
197
+ if (!needtrim ) continue ;
198
198
minimizedSpirv.insert (minimizedSpirv.end (), spirv + curOffset, spirv + offset);
199
199
}
200
200
@@ -208,7 +208,7 @@ ISPIRVDebloater::Result ISPIRVDebloater::debloat(const ICPUBuffer* spirvBuffer,
208
208
};
209
209
}
210
210
211
- if (!needDebloat )
211
+ if (!needtrim )
212
212
{
213
213
return {
214
214
.spirv = nullptr ,
@@ -236,22 +236,22 @@ ISPIRVDebloater::Result ISPIRVDebloater::debloat(const ICPUBuffer* spirvBuffer,
236
236
237
237
assert (validate (minimizedSpirv.data (), minimizedSpirv.size (), logger));
238
238
239
- auto debloatedSpirv = m_optimizer->optimize (minimizedSpirv.data (), minimizedSpirv.size (), logger);
239
+ auto trimmedSpirv = m_optimizer->optimize (minimizedSpirv.data (), minimizedSpirv.size (), logger);
240
240
241
241
#ifdef _NBL_DEBUG
242
242
logger.log (" Before stripping capabilities:" , nbl::system::ILogger::ELL_DEBUG);
243
243
printCapabilities (spirv, spirvDwordCount, logger);
244
244
logger.log (" \n " , nbl::system::ILogger::ELL_DEBUG);
245
245
246
- const auto * debloatedSpirvBuffer = static_cast <const uint32_t *>(debloatedSpirv ->getPointer ());
247
- const auto debloatedSpirvDwordCount = debloatedSpirv ->getSize () / 4 ;
246
+ const auto * trimmedSpirvBuffer = static_cast <const uint32_t *>(trimmedSpirv ->getPointer ());
247
+ const auto trimmedSpirvDwordCount = trimmedSpirv ->getSize () / 4 ;
248
248
logger.log (" After stripping capabilities:" , nbl::system::ILogger::ELL_DEBUG);
249
- printCapabilities (debloatedSpirvBuffer, debloatedSpirvDwordCount , logger);
249
+ printCapabilities (trimmedSpirvBuffer, trimmedSpirvDwordCount , logger);
250
250
logger.log (" \n " , nbl::system::ILogger::ELL_DEBUG);
251
251
#endif
252
252
253
253
return {
254
- .spirv = std::move (debloatedSpirv ),
254
+ .spirv = std::move (trimmedSpirv ),
255
255
.isSuccess = true ,
256
256
};
257
257
0 commit comments