Skip to content

Commit c035689

Browse files
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla
2 parents 99d4078 + 5254e8b commit c035689

File tree

2 files changed

+62
-26
lines changed

2 files changed

+62
-26
lines changed

include/nbl/video/IPhysicalDevice.h

Lines changed: 61 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -581,33 +581,15 @@ class NBL_API2 IPhysicalDevice : public core::Interface, public core::Unmovable
581581
);
582582
}
583583

584-
template<typename FORMAT_USAGE>
585-
struct FormatPromotionRequest
586-
{
584+
struct SBufferFormatPromotionRequest {
587585
asset::E_FORMAT originalFormat = asset::EF_UNKNOWN;
588-
FORMAT_USAGE usages = FORMAT_USAGE();
589-
590-
struct hash
591-
{
592-
// pack into 64bit for easy hashing
593-
uint64_t operator()(const FormatPromotionRequest<FORMAT_USAGE>& r) const
594-
{
595-
uint64_t msb = uint64_t(std::hash<FORMAT_USAGE>()(r.usages));
596-
return (msb << 32u) | r.originalFormat;
597-
}
598-
};
599-
600-
struct equal_to
601-
{
602-
bool operator()(const FormatPromotionRequest<FORMAT_USAGE>& l, const FormatPromotionRequest<FORMAT_USAGE>& r) const
603-
{
604-
return l.originalFormat == r.originalFormat && l.usages == r.usages;
605-
}
606-
};
586+
SFormatBufferUsages::SUsage usages = SFormatBufferUsages::SUsage();
607587
};
608588

609-
using SBufferFormatPromotionRequest = FormatPromotionRequest<IPhysicalDevice::SFormatBufferUsages::SUsage>;
610-
using SImageFormatPromotionRequest = FormatPromotionRequest<IPhysicalDevice::SFormatImageUsages::SUsage>;
589+
struct SImageFormatPromotionRequest {
590+
asset::E_FORMAT originalFormat = asset::EF_UNKNOWN;
591+
SFormatImageUsages::SUsage usages = SFormatImageUsages::SUsage();
592+
};
611593

612594
asset::E_FORMAT promoteBufferFormat(const SBufferFormatPromotionRequest req);
613595
asset::E_FORMAT promoteImageFormat(const SImageFormatPromotionRequest req, const IGPUImage::E_TILING tiling);
@@ -706,9 +688,38 @@ class NBL_API2 IPhysicalDevice : public core::Interface, public core::Unmovable
706688
SFormatImageUsages m_optimalTilingUsages = {};
707689
SFormatBufferUsages m_bufferUsages = {};
708690

709-
typedef core::unordered_map<FormatPromotionRequest<video::IPhysicalDevice::SFormatBufferUsages::SUsage>, asset::E_FORMAT, FormatPromotionRequest<video::IPhysicalDevice::SFormatBufferUsages::SUsage>::hash, FormatPromotionRequest<video::IPhysicalDevice::SFormatBufferUsages::SUsage>::equal_to> format_buffer_cache_t;
710-
typedef core::unordered_map<FormatPromotionRequest<video::IPhysicalDevice::SFormatImageUsages::SUsage>, asset::E_FORMAT, FormatPromotionRequest<video::IPhysicalDevice::SFormatImageUsages::SUsage>::hash, FormatPromotionRequest<video::IPhysicalDevice::SFormatImageUsages::SUsage>::equal_to> format_image_cache_t;
691+
struct SBufferFormatPromotionRequestHash
692+
{
693+
// pack into 64bit for easy hashing
694+
inline uint64_t operator()(const SBufferFormatPromotionRequest& r) const;
695+
};
711696

697+
struct SBufferFormatPromotionRequestEqualTo
698+
{
699+
inline bool operator()(const SBufferFormatPromotionRequest& l, const SBufferFormatPromotionRequest& r) const;
700+
};
701+
702+
struct SImageFormatPromotionRequestHash
703+
{
704+
// pack into 64bit for easy hashing
705+
inline uint64_t operator()(const SImageFormatPromotionRequest& r) const;
706+
};
707+
708+
struct SImageFormatPromotionRequestEqualTo
709+
{
710+
inline bool operator()(const SImageFormatPromotionRequest& l, const SImageFormatPromotionRequest& r) const;
711+
};
712+
713+
714+
715+
typedef core::unordered_map<SBufferFormatPromotionRequest, asset::E_FORMAT,
716+
SBufferFormatPromotionRequestHash,
717+
SBufferFormatPromotionRequestEqualTo> format_buffer_cache_t;
718+
typedef core::unordered_map<SImageFormatPromotionRequest, asset::E_FORMAT,
719+
SImageFormatPromotionRequestHash,
720+
SImageFormatPromotionRequestEqualTo> format_image_cache_t;
721+
722+
712723
struct format_promotion_cache_t
713724
{
714725
format_buffer_cache_t buffers;
@@ -755,4 +766,28 @@ namespace std
755766
};
756767
}
757768

769+
namespace nbl::video
770+
{
771+
inline uint64_t IPhysicalDevice::SBufferFormatPromotionRequestHash::operator()(const SBufferFormatPromotionRequest& r) const {
772+
uint64_t msb = uint64_t(std::hash<IPhysicalDevice::SFormatBufferUsages::SUsage>()(r.usages));
773+
return (msb << 32u) | r.originalFormat;
774+
}
775+
776+
inline uint64_t IPhysicalDevice::SImageFormatPromotionRequestHash::operator()(const SImageFormatPromotionRequest& r) const {
777+
uint64_t msb = uint64_t(std::hash<IPhysicalDevice::SFormatImageUsages::SUsage>()(r.usages));
778+
return (msb << 32u) | r.originalFormat;
779+
}
780+
781+
inline bool IPhysicalDevice::SBufferFormatPromotionRequestEqualTo::operator()(const SBufferFormatPromotionRequest& l, const SBufferFormatPromotionRequest& r) const
782+
{
783+
return l.originalFormat == r.originalFormat && l.usages == r.usages;
784+
}
785+
786+
inline bool IPhysicalDevice::SImageFormatPromotionRequestEqualTo::operator()(const SImageFormatPromotionRequest& l, const SImageFormatPromotionRequest& r) const
787+
{
788+
return l.originalFormat == r.originalFormat && l.usages == r.usages;
789+
}
790+
791+
792+
}
758793
#endif

include/nbl/video/utilities/IUtilities.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "nbl/video/IGPUBuffer.h"
88
#include "nbl/video/IGPUImage.h"
99
#include "nbl/video/ILogicalDevice.h"
10+
#include "nbl/video/IPhysicalDevice.h"
1011
#include "nbl/video/alloc/StreamingTransientDataBuffer.h"
1112
#include "nbl/video/utilities/CPropertyPoolHandler.h"
1213
#include "nbl/video/utilities/CScanner.h"

0 commit comments

Comments
 (0)