Skip to content

Commit 8f1a30f

Browse files
committed
IntrospectionParams == operator
1 parent b27fd35 commit 8f1a30f

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

include/nbl/asset/utils/CSPIRVIntrospector.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,20 @@ class NBL_API2 CSPIRVIntrospector : public core::Uncopyable
8484
std::string entryPoint;
8585
core::smart_refctd_ptr<const ICPUShader> cpuShader;
8686

87-
bool operator==(const SIntrospectionParams& rhs) const { return true; /*TODO*/ }
87+
bool operator==(const SIntrospectionParams& rhs) const
88+
{
89+
if (entryPoint != rhs.entryPoint)
90+
return false;
91+
if (!rhs.cpuShader)
92+
return false;
93+
if (cpuShader->getStage() != rhs.cpuShader->getStage())
94+
return false;
95+
if (cpuShader->getContentType() != rhs.cpuShader->getContentType())
96+
return false;
97+
if (cpuShader->getContent()->getSize() != rhs.cpuShader->getContent()->getSize())
98+
return false;
99+
return memcmp(cpuShader->getContent()->getPointer(), rhs.cpuShader->getContent()->getPointer(), cpuShader->getContent()->getSize()) == 0;;
100+
}
88101
};
89102

90103
//In the future there's also going list of enabled extensions

src/nbl/asset/utils/CSPIRVIntrospector.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ core::smart_refctd_ptr<const CSPIRVIntrospector::CIntrospectionData> CSPIRVIntro
7272
return nullptr;
7373
if (params.cpuShader->getContentType() != IShader::E_CONTENT_TYPE::ECT_SPIRV)
7474
return nullptr;
75-
// auto introspectionData = m_introspectionCache.find(params);
76-
// if (introspectionData != m_introspectionCache.end())
77-
// {
78-
// return introspectionData->second;
79-
// }
75+
auto introspectionData = m_introspectionCache.find(params);
76+
if (introspectionData != m_introspectionCache.end())
77+
{
78+
return introspectionData->second;
79+
}
8080

8181
const ICPUBuffer* spv = params.cpuShader->getContent();
8282
spirv_cross::Compiler comp(reinterpret_cast<const uint32_t*>(spv->getPointer()), spv->getSize()/4u);

0 commit comments

Comments
 (0)