Skip to content

Commit fc1983f

Browse files
author
kevyuu
committed
Small fixes on SpirvTrimTask
1 parent 04bcf0d commit fc1983f

File tree

2 files changed

+3
-53
lines changed

2 files changed

+3
-53
lines changed

include/nbl/video/IGPURayTracingPipeline.h

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,39 +39,6 @@ class IGPURayTracingPipeline : public IGPUPipeline<asset::IRayTracingPipeline<c
3939
return 1 + hits.size() + misses.size() + callables.size();
4040
}
4141

42-
inline uint32_t getMissShaderCount() const
43-
{
44-
auto count = 0;
45-
for (const auto& miss : misses)
46-
count += (miss.shader != nullptr);
47-
return count;
48-
}
49-
50-
inline uint32_t getHitShaderCount() const
51-
{
52-
auto count = 0;
53-
for (const auto& hit : hits)
54-
{
55-
count += (hit.closestHit.shader != nullptr);
56-
count += (hit.anyHit.shader != nullptr);
57-
count += (hit.intersection.shader != nullptr);
58-
}
59-
return count;
60-
}
61-
62-
inline uint32_t getCallableShaderCount() const
63-
{
64-
auto count = 0;
65-
for (const auto& callable : callables)
66-
count += (callable.shader != nullptr ? 1 : 0);
67-
return count;
68-
}
69-
70-
inline uint32_t getShaderCount() const
71-
{
72-
return getMissShaderCount() + getHitShaderCount() + getCallableShaderCount();
73-
}
74-
7542
};
7643

7744
IGPUPipelineLayout* layout = nullptr;

src/nbl/video/ILogicalDevice.cpp

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ class SpirvTrimTask
1414
struct ShaderInfo
1515
{
1616
EntryPoints entryPoints;
17-
const asset::IShader* trimmedShaders;
17+
const asset::IShader* trimmedShader;
1818
};
1919

2020
SpirvTrimTask(asset::ISPIRVEntryPointTrimmer* trimer, system::logger_opt_ptr logger) : m_trimmer(trimer), m_logger(logger)
2121
{
2222

2323
}
2424

25-
void insertEntryPoint(const IGPUPipelineBase::SShaderSpecInfo& shaderSpec, hlsl::ShaderStage stage)
25+
void insertEntryPoint(const IGPUPipelineBase::SShaderSpecInfo& shaderSpec, const hlsl::ShaderStage stage)
2626
{
2727
const auto* shader = shaderSpec.shader;
2828
auto it = m_shaderInfoMap.find(shader);
@@ -37,16 +37,14 @@ class SpirvTrimTask
3737
auto findResult = m_shaderInfoMap.find(shader);
3838
assert(findResult != m_shaderInfoMap.end());
3939
const auto& entryPoints = findResult->second.entryPoints;
40-
auto& trimmedShader = findResult->second.trimmedShaders;
40+
auto& trimmedShader = findResult->second.trimmedShader;
4141

4242
auto trimmedShaderSpec = shaderSpec;
4343
if (shader != nullptr)
4444
{
4545
if (trimmedShader == nullptr)
4646
{
47-
const auto outShadersData = outShaders.data();
4847
outShaders.push_back(m_trimmer->trim(shader, entryPoints, m_logger));
49-
assert(outShadersData == outShaders.data());
5048
trimmedShader = outShaders.back().get();
5149
}
5250
trimmedShaderSpec.shader = trimmedShader;
@@ -1060,22 +1058,7 @@ bool ILogicalDevice::createRayTracingPipelines(IGPUPipelineCache* const pipeline
10601058
}
10611059

10621060
core::vector<IGPURayTracingPipeline::SCreationParams> newParams(params.begin(), params.end());
1063-
const auto raygenCount = params.size(); // assume every param have raygen
1064-
const auto missShaderCount = std::accumulate(params.begin(), params.end(), 0, [](uint32_t sum, auto& param)
1065-
{
1066-
return sum + param.shaderGroups.getMissShaderCount();
1067-
});
1068-
const auto hitShaderCount = std::accumulate(params.begin(), params.end(), 0, [](uint32_t sum, auto& param)
1069-
{
1070-
return sum + param.shaderGroups.getHitShaderCount();
1071-
});
1072-
const auto callableShaderCount = std::accumulate(params.begin(), params.end(), 0, [](uint32_t sum, auto& param)
1073-
{
1074-
return sum + param.shaderGroups.getCallableShaderCount();
1075-
});
1076-
const auto shaderCount = raygenCount + missShaderCount + hitShaderCount + callableShaderCount;
10771061
core::vector<core::smart_refctd_ptr<const asset::IShader>> trimmedShaders; // vector to hold all the trimmed shaders, so the pointer from the new ShaderSpecInfo is not dangling
1078-
trimmedShaders.reserve(shaderCount);
10791062

10801063
const auto missGroupCount = std::accumulate(params.begin(), params.end(), 0, [](uint32_t sum, auto& param)
10811064
{

0 commit comments

Comments
 (0)