Skip to content

Commit 5d990a3

Browse files
author
kevyuu
committed
Rename ISPIRVDebloater to ISPIRVEntryPointTrimmer
1 parent 47900b1 commit 5d990a3

File tree

6 files changed

+88
-88
lines changed

6 files changed

+88
-88
lines changed

include/nbl/asset/utils/ISPIRVDebloater.h renamed to include/nbl/asset/utils/ISPIRVEntryPointTrimmer.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef _NBL_ASSET_I_SPIRV_DEBLOATER_H_INCLUDED_
2-
#define _NBL_ASSET_I_SPIRV_DEBLOATER_H_INCLUDED_
1+
#ifndef _NBL_ASSET_I_SPIRV_ENTRY_POINT_TRIMMER_H_INCLUDED_
2+
#define _NBL_ASSET_I_SPIRV_ENTRY_POINT_TRIMMER_H_INCLUDED_
33

44
#include "nbl/core/declarations.h"
55

@@ -10,14 +10,14 @@
1010
namespace nbl::asset
1111
{
1212

13-
class ISPIRVDebloater final : public core::IReferenceCounted
13+
class ISPIRVEntryPointTrimmer final : public core::IReferenceCounted
1414
{
1515
public:
16-
ISPIRVDebloater();
16+
ISPIRVEntryPointTrimmer();
1717

1818
struct Result
1919
{
20-
core::smart_refctd_ptr<ICPUBuffer> spirv; // nullptr if there is some entry point not found or spirv does not need to be debloated
20+
core::smart_refctd_ptr<ICPUBuffer> spirv; // nullptr if there is some entry point not found or spirv does not need to be trimmed
2121
bool isSuccess;
2222

2323
inline operator bool() const
@@ -45,20 +45,20 @@ class ISPIRVDebloater final : public core::IReferenceCounted
4545
}
4646
};
4747

48-
Result debloat(const ICPUBuffer* spirvBuffer, const core::set<EntryPoint>& entryPoints, system::logger_opt_ptr logger = nullptr) const;
48+
Result trim(const ICPUBuffer* spirvBuffer, const core::set<EntryPoint>& entryPoints, system::logger_opt_ptr logger = nullptr) const;
4949

50-
inline core::smart_refctd_ptr<const IShader> debloat(const IShader* shader, const core::set<EntryPoint>& entryPoints, system::logger_opt_ptr logger = nullptr) const
50+
inline core::smart_refctd_ptr<const IShader> trim(const IShader* shader, const core::set<EntryPoint>& entryPoints, system::logger_opt_ptr logger = nullptr) const
5151
{
5252
if (shader->getContentType() != IShader::E_CONTENT_TYPE::ECT_SPIRV)
5353
{
5454
logger.log("shader content must be spirv!", system::ILogger::ELL_ERROR);
5555
return nullptr;
5656
}
5757
const auto buffer = shader->getContent();
58-
const auto result = debloat(buffer, entryPoints, logger);
58+
const auto result = trim(buffer, entryPoints, logger);
5959
if (result && result.spirv.get() == nullptr)
6060
{
61-
// when debloat does not happen return original shader
61+
// when trim does not happen return original shader
6262
return core::smart_refctd_ptr<const IShader>(shader);
6363
}
6464

include/nbl/video/ILogicalDevice.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "nbl/asset/asset.h"
55
#include "nbl/asset/utils/ISPIRVOptimizer.h"
6-
#include "nbl/asset/utils/ISPIRVDebloater.h"
6+
#include "nbl/asset/utils/ISPIRVEntryPointTrimmer.h"
77
#include "nbl/asset/utils/CCompilerSet.h"
88

99
#include "nbl/video/SPhysicalDeviceFeatures.h"
@@ -1315,7 +1315,7 @@ class NBL_API2 ILogicalDevice : public core::IReferenceCounted, public IDeviceMe
13151315
uint16_t firstQueueIndex = 0u;
13161316
};
13171317
const std::array<QueueFamilyInfo,MaxQueueFamilies> m_queueFamilyInfos;
1318-
core::smart_refctd_ptr<asset::ISPIRVDebloater> m_spirvDebloater;
1318+
core::smart_refctd_ptr<asset::ISPIRVEntryPointTrimmer> m_spirvTrimmer;
13191319

13201320
private:
13211321
const SPhysicalDeviceLimits& getPhysicalDeviceLimits() const;

src/nbl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ set(NBL_ASSET_SOURCES
162162

163163
# Shaders
164164
${NBL_ROOT_PATH}/src/nbl/asset/utils/ISPIRVOptimizer.cpp
165-
${NBL_ROOT_PATH}/src/nbl/asset/utils/ISPIRVDebloater.cpp
165+
${NBL_ROOT_PATH}/src/nbl/asset/utils/ISPIRVEntryPointTrimmer.cpp
166166
${NBL_ROOT_PATH}/src/nbl/asset/utils/IShaderCompiler.cpp
167167
${NBL_ROOT_PATH}/src/nbl/asset/utils/CGLSLCompiler.cpp
168168
${NBL_ROOT_PATH}/src/nbl/asset/utils/CHLSLCompiler.cpp

src/nbl/asset/utils/ISPIRVDebloater.cpp renamed to src/nbl/asset/utils/ISPIRVEntryPointTrimmer.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "nbl/asset/utils/ISPIRVDebloater.h"
1+
#include "nbl/asset/utils/ISPIRVEntryPointTrimmer.h"
22
#include "nbl/asset/utils/ISPIRVOptimizer.h"
33
#include "nbl_spirv_cross/spirv.hpp"
44

@@ -10,7 +10,7 @@ using namespace nbl::asset;
1010

1111
static constexpr spv_target_env SPIRV_VERSION = spv_target_env::SPV_ENV_UNIVERSAL_1_6;
1212

13-
ISPIRVDebloater::ISPIRVDebloater()
13+
ISPIRVEntryPointTrimmer::ISPIRVEntryPointTrimmer()
1414
{
1515
constexpr auto optimizationPasses = std::array{
1616
ISPIRVOptimizer::EOP_DEAD_BRANCH_ELIM,
@@ -78,7 +78,7 @@ static bool validate(const uint32_t* binary, uint32_t binarySize, nbl::system::l
7878
return core.Validate(binary, binarySize, validatorOptions);
7979
}
8080

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
8282
{
8383
const auto* spirv = static_cast<const uint32_t*>(spirvBuffer->getPointer());
8484
const auto spirvDwordCount = spirvBuffer->getSize() / 4;
@@ -134,7 +134,7 @@ ISPIRVDebloater::Result ISPIRVDebloater::debloat(const ICPUBuffer* spirvBuffer,
134134
std::vector<uint32_t> minimizedSpirv;
135135
core::unordered_set<uint32_t> removedEntryPointIds;
136136

137-
bool needDebloat = false;
137+
bool needtrim = false;
138138
auto offset = HEADER_SIZE;
139139
auto parse_instruction = [](uint32_t instruction) -> std::tuple<uint32_t, uint32_t>
140140
{
@@ -185,16 +185,16 @@ ISPIRVDebloater::Result ISPIRVDebloater::debloat(const ICPUBuffer* spirvBuffer,
185185
foundEntryPoint += 1; // a valid spirv will have unique entry points, so this should works
186186
} else
187187
{
188-
if (needDebloat == false)
188+
if (needtrim == false)
189189
{
190190
minimizedSpirv.reserve(spirvDwordCount);
191191
minimizedSpirv.insert(minimizedSpirv.end(), spirv, spirv + curOffset);
192-
needDebloat = true;
192+
needtrim = true;
193193
}
194194
removedEntryPointIds.insert(curEntryPointId);
195195
continue;
196196
}
197-
if (!needDebloat) continue;
197+
if (!needtrim) continue;
198198
minimizedSpirv.insert(minimizedSpirv.end(), spirv + curOffset, spirv + offset);
199199
}
200200

@@ -208,7 +208,7 @@ ISPIRVDebloater::Result ISPIRVDebloater::debloat(const ICPUBuffer* spirvBuffer,
208208
};
209209
}
210210

211-
if (!needDebloat)
211+
if (!needtrim)
212212
{
213213
return {
214214
.spirv = nullptr,
@@ -236,22 +236,22 @@ ISPIRVDebloater::Result ISPIRVDebloater::debloat(const ICPUBuffer* spirvBuffer,
236236

237237
assert(validate(minimizedSpirv.data(), minimizedSpirv.size(), logger));
238238

239-
auto debloatedSpirv = m_optimizer->optimize(minimizedSpirv.data(), minimizedSpirv.size(), logger);
239+
auto trimmedSpirv = m_optimizer->optimize(minimizedSpirv.data(), minimizedSpirv.size(), logger);
240240

241241
#ifdef _NBL_DEBUG
242242
logger.log("Before stripping capabilities:", nbl::system::ILogger::ELL_DEBUG);
243243
printCapabilities(spirv, spirvDwordCount, logger);
244244
logger.log("\n", nbl::system::ILogger::ELL_DEBUG);
245245

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;
248248
logger.log("After stripping capabilities:", nbl::system::ILogger::ELL_DEBUG);
249-
printCapabilities(debloatedSpirvBuffer, debloatedSpirvDwordCount, logger);
249+
printCapabilities(trimmedSpirvBuffer, trimmedSpirvDwordCount, logger);
250250
logger.log("\n", nbl::system::ILogger::ELL_DEBUG);
251251
#endif
252252

253253
return {
254-
.spirv = std::move(debloatedSpirv),
254+
.spirv = std::move(trimmedSpirv),
255255
.isSuccess = true,
256256
};
257257

src/nbl/video/CVulkanLogicalDevice.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "nbl/video/CVulkanLogicalDevice.h"
22

3-
#include "nbl/asset/utils/ISPIRVDebloater.h"
3+
#include "nbl/asset/utils/ISPIRVEntryPointTrimmer.h"
44
#include "nbl/video/CThreadSafeQueueAdapter.h"
55
#include "nbl/video/surface/CSurfaceVulkan.h"
66

0 commit comments

Comments
 (0)