Skip to content

Commit f3ee9c0

Browse files
Use spans for reporting Physical Devices, then use set references for filtering
1 parent c0965e7 commit f3ee9c0

File tree

4 files changed

+8
-12
lines changed

4 files changed

+8
-12
lines changed

include/nbl/video/IAPIConnection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class NBL_API2 IAPIConnection : public core::IReferenceCounted
5757

5858
virtual IDebugCallback* getDebugCallback() const = 0;
5959

60-
core::SRange<IPhysicalDevice* const> getPhysicalDevices() const;
60+
std::span<IPhysicalDevice* const> getPhysicalDevices() const;
6161

6262
const SFeatures& getEnabledFeatures() const { return m_enabledFeatures; };
6363

include/nbl/video/utilities/SPhysicalDeviceFilter.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,10 @@ namespace nbl::video
6262

6363

6464
// sift through multiple devices
65-
core::set<IPhysicalDevice*> operator()(const core::SRange<IPhysicalDevice* const>& physicalDevices) const
65+
template<typename PhysicalDevice> requires std::is_same_v<std::remove_cv_t<PhysicalDevice>,video::IPhysicalDevice>
66+
void operator()(core::set<PhysicalDevice*>& physicalDevices) const
6667
{
67-
core::set<IPhysicalDevice*> ret;
68-
for (auto& physDev : physicalDevices)
69-
if (meetsRequirements(physDev))
70-
ret.insert(physDev);
71-
return ret;
68+
std::erase_if(physicalDevices,[&](const video::IPhysicalDevice* device)->bool{return !meetsRequirements(device);});
7269
}
7370

7471
// check one device

src/nbl/video/IAPIConnection.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010
namespace nbl::video
1111
{
1212

13-
core::SRange<IPhysicalDevice* const> IAPIConnection::getPhysicalDevices() const
13+
std::span<IPhysicalDevice* const> IAPIConnection::getPhysicalDevices() const
1414
{
1515
static_assert(sizeof(std::unique_ptr<IPhysicalDevice>) == sizeof(void*));
1616

17-
return core::SRange<IPhysicalDevice* const>(
18-
reinterpret_cast<IPhysicalDevice* const*>(m_physicalDevices.data()),
19-
reinterpret_cast<IPhysicalDevice* const*>(m_physicalDevices.data()) + m_physicalDevices.size());
17+
IPhysicalDevice* const* const begin = reinterpret_cast<IPhysicalDevice* const*>(m_physicalDevices.data());
18+
return {begin,m_physicalDevices.size()};
2019
}
2120

2221
IAPIConnection::IAPIConnection(const SFeatures& enabledFeatures)

0 commit comments

Comments
 (0)