Skip to content

Commit c2cf167

Browse files
committed
Moved vulkan code to CVulkanPipelineExecutableInfo.h and moved data to pipeline base
1 parent 75ebe75 commit c2cf167

12 files changed

Lines changed: 265 additions & 255 deletions

include/nbl/video/CVulkanRayTracingPipeline.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class CVulkanRayTracingPipeline final : public IGPURayTracingPipeline
2525

2626
inline VkPipeline getInternalObject() const { return m_vkPipeline; }
2727

28+
void populateExecutableInfo(bool includeInternalRepresentations);
29+
2830
virtual const SShaderGroupHandle& getRaygen() const override;
2931
virtual std::span<const SShaderGroupHandle> getMissHandles() const override;
3032
virtual std::span<const SShaderGroupHandle> getHitHandles() const override;

include/nbl/video/IGPUPipeline.h

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "nbl/video/SPipelineCreationParams.h"
1111
#include "nbl/asset/ICPUPipeline.h"
1212
#include "nbl/asset/IPipeline.h"
13+
#include "nbl/system/to_string.h"
1314

1415
namespace nbl::video
1516
{
@@ -127,6 +128,21 @@ class IGPUPipelineBase {
127128

128129
using SShaderEntryMap = SShaderSpecInfo::entry_map_t;
129130

131+
// Per-executable info from VK_KHR_pipeline_executable_properties
132+
struct SExecutableInfo
133+
{
134+
std::string name;
135+
std::string description;
136+
core::bitflag<hlsl::ShaderStage> stages = hlsl::ShaderStage::ESS_UNKNOWN;
137+
uint32_t subgroupSize = 0;
138+
std::string statistics;
139+
std::string internalRepresentations;
140+
};
141+
142+
inline std::span<const SExecutableInfo> getExecutableInfo() const { return m_executableInfo; }
143+
144+
protected:
145+
core::vector<SExecutableInfo> m_executableInfo;
130146
};
131147

132148
// Common Base class for pipelines
@@ -146,4 +162,51 @@ class IGPUPipeline : public IBackendObject, public PipelineNonBackendObjectBase,
146162

147163
}
148164

165+
namespace nbl::system::impl
166+
{
167+
168+
template<>
169+
struct to_string_helper<video::IGPUPipelineBase::SExecutableInfo>
170+
{
171+
static std::string __call(const video::IGPUPipelineBase::SExecutableInfo& info)
172+
{
173+
std::string result;
174+
result += "======== ";
175+
result += info.name;
176+
result += " ========\n";
177+
result += info.description;
178+
result += "\nSubgroup Size: ";
179+
result += std::to_string(info.subgroupSize);
180+
if (!info.statistics.empty())
181+
{
182+
result += "\n";
183+
result += info.statistics;
184+
}
185+
if (!info.internalRepresentations.empty())
186+
{
187+
result += "\n";
188+
result += info.internalRepresentations;
189+
}
190+
return result;
191+
}
192+
};
193+
194+
// Another version for core::vector?
195+
template<>
196+
struct to_string_helper<std::span<const video::IGPUPipelineBase::SExecutableInfo>>
197+
{
198+
static std::string __call(const std::span<const video::IGPUPipelineBase::SExecutableInfo>& infos)
199+
{
200+
std::string result;
201+
for (const auto& info : infos)
202+
{
203+
result += to_string_helper<video::IGPUPipelineBase::SExecutableInfo>::__call(info);
204+
result += "\n";
205+
}
206+
return result;
207+
}
208+
};
209+
210+
}
211+
149212
#endif

include/nbl/video/ILogicalDevice.h

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,47 +1034,6 @@ class NBL_API2 ILogicalDevice : public core::IReferenceCounted, public IDeviceMe
10341034
const std::span<const IGPURayTracingPipeline::SCreationParams> params,
10351035
core::smart_refctd_ptr<IGPURayTracingPipeline>* const output);
10361036

1037-
// Per-executable info from VK_KHR_pipeline_executable_properties
1038-
struct SPipelineExecutableInfo
1039-
{
1040-
std::string name;
1041-
std::string description;
1042-
core::bitflag<hlsl::ShaderStage> stages = hlsl::ShaderStage::ESS_UNKNOWN;
1043-
uint32_t subgroupSize = 0;
1044-
std::string statistics;
1045-
std::string internalRepresentations;
1046-
};
1047-
1048-
// Query pipeline executable properties (VK_KHR_pipeline_executable_properties).
1049-
// Pipeline must have been created with CAPTURE_STATISTICS flag for statistics.
1050-
// Pipeline must have been created with CAPTURE_INTERNAL_REPRESENTATIONS flag for IR.
1051-
template<typename Pipeline>
1052-
core::vector<SPipelineExecutableInfo> getPipelineExecutableProperties(const Pipeline* pipeline, bool includeInternalRepresentations = false)
1053-
{
1054-
if (!pipeline)
1055-
{
1056-
NBL_LOG_ERROR("Null pipeline");
1057-
return {};
1058-
}
1059-
using flags_t = Pipeline::SCreationParams::FLAGS;
1060-
if (!pipeline->getCreationFlags().hasFlags(flags_t::CAPTURE_STATISTICS))
1061-
{
1062-
NBL_LOG_ERROR("Pipeline was not created with CAPTURE_STATISTICS flag");
1063-
return {};
1064-
}
1065-
if (includeInternalRepresentations && !pipeline->getCreationFlags().hasFlags(flags_t::CAPTURE_INTERNAL_REPRESENTATIONS))
1066-
{
1067-
NBL_LOG_ERROR("Pipeline was not created with CAPTURE_INTERNAL_REPRESENTATIONS flag");
1068-
return {};
1069-
}
1070-
auto properties = getPipelineExecutableProperties_impl(pipeline, includeInternalRepresentations);
1071-
if (properties.empty())
1072-
{
1073-
NBL_LOG_ERROR("Driver returned 0 executables for pipeline created with CAPTURE_STATISTICS flag. This pipeline type may not be supported by the driver's VK_KHR_pipeline_executable_properties implementation.");
1074-
}
1075-
return properties;
1076-
}
1077-
10781037
// queries
10791038
inline core::smart_refctd_ptr<IQueryPool> createQueryPool(const IQueryPool::SCreationParams& params)
10801039
{
@@ -1352,10 +1311,6 @@ class NBL_API2 ILogicalDevice : public core::IReferenceCounted, public IDeviceMe
13521311
const SSpecializationValidationResult& validation
13531312
) = 0;
13541313

1355-
virtual core::vector<SPipelineExecutableInfo> getPipelineExecutableProperties_impl(const IGPUComputePipeline* pipeline, bool includeInternalRepresentations) = 0;
1356-
virtual core::vector<SPipelineExecutableInfo> getPipelineExecutableProperties_impl(const IGPUGraphicsPipeline* pipeline, bool includeInternalRepresentations) = 0;
1357-
virtual core::vector<SPipelineExecutableInfo> getPipelineExecutableProperties_impl(const IGPURayTracingPipeline* pipeline, bool includeInternalRepresentations) = 0;
1358-
13591314
virtual core::smart_refctd_ptr<IQueryPool> createQueryPool_impl(const IQueryPool::SCreationParams& params) = 0;
13601315
virtual bool getQueryPoolResults_impl(const IQueryPool* const queryPool, const uint32_t firstQuery, const uint32_t queryCount, void* const pData, const size_t stride, const core::bitflag<IQueryPool::RESULTS_FLAGS> flags) = 0;
13611316

@@ -1665,51 +1620,5 @@ inline bool ILogicalDevice::validateMemoryBarrier(const uint32_t queueFamilyInde
16651620

16661621
} // namespace nbl::video
16671622

1668-
namespace nbl::system::impl
1669-
{
1670-
1671-
template<>
1672-
struct to_string_helper<video::ILogicalDevice::SPipelineExecutableInfo>
1673-
{
1674-
static std::string __call(const video::ILogicalDevice::SPipelineExecutableInfo& info)
1675-
{
1676-
std::string result;
1677-
result += "======== ";
1678-
result += info.name;
1679-
result += " ========\n";
1680-
result += info.description;
1681-
result += "\nSubgroup Size: ";
1682-
result += std::to_string(info.subgroupSize);
1683-
if (!info.statistics.empty())
1684-
{
1685-
result += "\n";
1686-
result += info.statistics;
1687-
}
1688-
if (!info.internalRepresentations.empty())
1689-
{
1690-
result += "\n";
1691-
result += info.internalRepresentations;
1692-
}
1693-
return result;
1694-
}
1695-
};
1696-
1697-
template<>
1698-
struct to_string_helper<core::vector<video::ILogicalDevice::SPipelineExecutableInfo>>
1699-
{
1700-
static std::string __call(const core::vector<video::ILogicalDevice::SPipelineExecutableInfo>& infos)
1701-
{
1702-
std::string result;
1703-
for (const auto& info : infos)
1704-
{
1705-
result += to_string_helper<video::ILogicalDevice::SPipelineExecutableInfo>::__call(info);
1706-
result += "\n";
1707-
}
1708-
return result;
1709-
}
1710-
};
1711-
1712-
}
1713-
17141623
#include "nbl/undef_logging_macros.h"
17151624
#endif //_NBL_VIDEO_I_LOGICAL_DEVICE_H_INCLUDED_

src/nbl/video/CVulkanComputePipeline.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "nbl/video/CVulkanComputePipeline.h"
22

33
#include "nbl/video/CVulkanLogicalDevice.h"
4+
#include "nbl/video/CVulkanPipelineExecutableInfo.h"
45

56
namespace nbl::video
67
{
@@ -12,6 +13,12 @@ CVulkanComputePipeline::~CVulkanComputePipeline()
1213
vk->vk.vkDestroyPipeline(vulkanDevice->getInternalObject(), m_pipeline, nullptr);
1314
}
1415

16+
void CVulkanComputePipeline::populateExecutableInfo(bool includeInternalRepresentations)
17+
{
18+
const CVulkanLogicalDevice* vulkanDevice = static_cast<const CVulkanLogicalDevice*>(getOriginDevice());
19+
populateExecutableInfoFromVulkan(m_executableInfo, vulkanDevice->getFunctionTable(), vulkanDevice->getInternalObject(), m_pipeline, includeInternalRepresentations);
20+
}
21+
1522
void CVulkanComputePipeline::setObjectDebugName(const char* label) const
1623
{
1724
IBackendObject::setObjectDebugName(label);

src/nbl/video/CVulkanComputePipeline.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ class CVulkanComputePipeline final : public IGPUComputePipeline
2222
inline const void* getNativeHandle() const override { return &m_pipeline; }
2323

2424
inline VkPipeline getInternalObject() const { return m_pipeline; }
25-
25+
26+
void populateExecutableInfo(bool includeInternalRepresentations);
27+
2628
void setObjectDebugName(const char* label) const override;
2729

2830
private:

src/nbl/video/CVulkanGraphicsPipeline.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
#include "nbl/video/CVulkanGraphicsPipeline.h"
22

33
#include "nbl/video/CVulkanLogicalDevice.h"
4+
#include "CVulkanPipelineExecutableInfo.h"
45

56
namespace nbl::video
67
{
78

9+
void CVulkanGraphicsPipeline::populateExecutableInfo(bool includeInternalRepresentations)
10+
{
11+
const CVulkanLogicalDevice* vulkanDevice = static_cast<const CVulkanLogicalDevice*>(getOriginDevice());
12+
populateExecutableInfoFromVulkan(m_executableInfo, vulkanDevice->getFunctionTable(), vulkanDevice->getInternalObject(), m_vkPipeline, includeInternalRepresentations);
13+
}
14+
815
CVulkanGraphicsPipeline::~CVulkanGraphicsPipeline()
916
{
1017
const CVulkanLogicalDevice* vulkanDevice = static_cast<const CVulkanLogicalDevice*>(getOriginDevice());

src/nbl/video/CVulkanGraphicsPipeline.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class CVulkanGraphicsPipeline final : public IGPUGraphicsPipeline
1818

1919
inline VkPipeline getInternalObject() const {return m_vkPipeline;}
2020

21+
void populateExecutableInfo(bool includeInternalRepresentations);
22+
2123
private:
2224
~CVulkanGraphicsPipeline();
2325

0 commit comments

Comments
 (0)