Skip to content

Commit e96c79c

Browse files
committed
CCompilerSet instead of GLSLCompiler + bunch of renames
1 parent 4cea6e3 commit e96c79c

17 files changed

+568
-568
lines changed

include/nbl/asset/IAssetManager.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "nbl/asset/interchange/IAssetLoader.h"
1818
#include "nbl/asset/interchange/IAssetWriter.h"
1919

20-
#include "nbl/asset/utils/CGLSLCompiler.h"
20+
#include "nbl/asset/utils/CCompilerSet.h"
2121
#include "nbl/asset/utils/IGeometryCreator.h"
2222

2323

@@ -119,14 +119,15 @@ class NBL_API IAssetManager : public core::IReferenceCounted, public core::QuitS
119119

120120
core::smart_refctd_ptr<IGeometryCreator> m_geometryCreator;
121121
core::smart_refctd_ptr<IMeshManipulator> m_meshManipulator;
122-
core::smart_refctd_ptr<CGLSLCompiler> m_glslCompiler;
122+
core::smart_refctd_ptr<CCompilerSet> m_compilerSet;
123123
// called as a part of constructor only
124124
void initializeMeshTools();
125125

126126
public:
127127
//! Constructor
128-
explicit IAssetManager(core::smart_refctd_ptr<system::ISystem>&& _s) :
129-
m_system(std::move(_s)),
128+
explicit IAssetManager(core::smart_refctd_ptr<system::ISystem>&& system, core::smart_refctd_ptr<CCompilerSet>&& compilerSet = nullptr) :
129+
m_system(std::move(system)),
130+
m_compilerSet(std::move(compilerSet)),
130131
m_defaultLoaderOverride(this)
131132
{
132133
initializeMeshTools();
@@ -144,7 +145,7 @@ class NBL_API IAssetManager : public core::IReferenceCounted, public core::QuitS
144145

145146
const IGeometryCreator* getGeometryCreator() const;
146147
IMeshManipulator* getMeshManipulator();
147-
CGLSLCompiler* getGLSLCompiler() const { return m_glslCompiler.get(); }
148+
CCompilerSet* getCompilerSet() const { return m_compilerSet.get(); }
148149

149150
protected:
150151
virtual ~IAssetManager()

include/nbl/asset/ICPUBuffer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ template<
125125
>
126126
class NBL_API CCustomAllocatorCPUBuffer;
127127

128+
using CDummyCPUBuffer = CCustomAllocatorCPUBuffer<core::null_allocator<uint8_t>, true>;
129+
128130
//! Specialization of ICPUBuffer capable of taking custom allocators
129131
/*
130132
Take a look that with this usage you have to specify custom alloctor

include/nbl/asset/utils/IShaderCompiler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
125125
{
126126
IShader::E_SHADER_STAGE stage = IShader::E_SHADER_STAGE::ESS_UNKNOWN;
127127
E_SPIRV_VERSION targetSpirvVersion = E_SPIRV_VERSION::ESV_1_6;
128-
std::string_view entryPoint = nullptr;
129-
std::string_view sourceIdentifier = nullptr;
128+
std::string_view entryPoint = "";
129+
std::string_view sourceIdentifier = "";
130130
const ISPIRVOptimizer* spirvOptimizer = nullptr;
131131
system::logger_opt_ptr logger = nullptr;
132132
const CIncludeFinder* includeFinder = nullptr;

include/nbl/video/COpenGL_Connection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class NBL_API2 COpenGL_Connection final : public IAPIConnection
2727
const egl::CEGL& getInternalObject() const;
2828

2929
private:
30-
inline COpenGL_Connection(const SFeatures& enabledFeatures, core::smart_refctd_ptr<asset::CGLSLCompiler>&& glslc) : IAPIConnection(enabledFeatures, std::move(glslc))
30+
inline COpenGL_Connection(const SFeatures& enabledFeatures) : IAPIConnection(enabledFeatures)
3131
{}
3232
};
3333

include/nbl/video/CVulkanConnection.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class NBL_API2 CVulkanConnection final : public IAPIConnection
2929
explicit CVulkanConnection(
3030
VkInstance instance,
3131
const SFeatures& enabledFeatures,
32-
core::smart_refctd_ptr<asset::CGLSLCompiler>&& glslc,
3332
std::unique_ptr<CVulkanDebugCallback>&& debugCallback,
3433
VkDebugUtilsMessengerEXT vk_debugMessenger);
3534

include/nbl/video/IAPIConnection.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,12 @@ class NBL_API2 IAPIConnection : public core::IReferenceCounted
4545

4646
const SFeatures& getEnabledFeatures() const { return m_enabledFeatures; };
4747

48-
inline asset::CGLSLCompiler* getGLSLCompiler() const { return m_glslCompiler.get(); }
49-
5048
protected:
51-
IAPIConnection(const SFeatures& enabledFeatures, core::smart_refctd_ptr<asset::CGLSLCompiler>&& glslc);
49+
IAPIConnection(const SFeatures& enabledFeatures);
5250

5351
std::vector<std::unique_ptr<IPhysicalDevice>> m_physicalDevices;
5452
renderdoc_api_t* m_rdoc_api;
5553
SFeatures m_enabledFeatures = {};
56-
core::smart_refctd_ptr<asset::CGLSLCompiler> m_glslCompiler;
5754
};
5855

5956
}

include/nbl/video/ILogicalDevice.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class NBL_API ILogicalDevice : public core::IReferenceCounted, public IDeviceMem
5252
uint32_t queueParamsCount;
5353
const SQueueCreationParams* queueParams;
5454
SPhysicalDeviceFeatures featuresToEnable;
55+
core::smart_refctd_ptr<asset::CCompilerSet> compilerSet = nullptr;
5556
};
5657

5758
struct SDescriptorSetCreationParams
@@ -501,15 +502,15 @@ class NBL_API ILogicalDevice : public core::IReferenceCounted, public IDeviceMem
501502
virtual const void* getNativeHandle() const = 0;
502503

503504
// these are the defines which shall be added to any IGPUShader which has its source as GLSL
504-
inline core::SRange<const char* const> getExtraGLSLDefines() const
505+
inline core::SRange<const char* const> getExtraShaderDefines() const
505506
{
506-
const char* const* begin = m_extraGLSLDefines.data();
507-
return {begin,begin+m_extraGLSLDefines.size()};
507+
const char* const* begin = m_extraShaderDefines.data();
508+
return {begin,begin+m_extraShaderDefines.size()};
508509
}
509510

510511
protected:
511512
ILogicalDevice(core::smart_refctd_ptr<IAPIConnection>&& api, IPhysicalDevice* physicalDevice, const SCreationParams& params)
512-
: m_api(api), m_physicalDevice(physicalDevice), m_enabledFeatures(params.featuresToEnable)
513+
: m_api(api), m_physicalDevice(physicalDevice), m_enabledFeatures(params.featuresToEnable), m_compilerSet(params.compilerSet)
513514
{
514515
uint32_t qcnt = 0u;
515516
uint32_t greatestFamNum = 0u;
@@ -585,38 +586,38 @@ class NBL_API ILogicalDevice : public core::IReferenceCounted, public IDeviceMem
585586
virtual core::smart_refctd_ptr<IGPUGraphicsPipeline> createGraphicsPipeline_impl(IGPUPipelineCache* pipelineCache, IGPUGraphicsPipeline::SCreationParams&& params) = 0;
586587
virtual bool createGraphicsPipelines_impl(IGPUPipelineCache* pipelineCache, core::SRange<const IGPUGraphicsPipeline::SCreationParams> params, core::smart_refctd_ptr<IGPUGraphicsPipeline>* output) = 0;
587588

588-
void addCommonGLSLDefines(std::ostringstream& pool, const bool runningInRenderDoc);
589+
void addCommonShaderDefines(std::ostringstream& pool, const bool runningInRenderDoc);
589590

590591
template<typename... Args>
591-
inline void addGLSLDefineToPool(std::ostringstream& pool, const char* define, Args&&... args)
592+
inline void addShaderDefineToPool(std::ostringstream& pool, const char* define, Args&&... args)
592593
{
593594
const ptrdiff_t pos = pool.tellp();
594-
m_extraGLSLDefines.push_back(reinterpret_cast<const char*>(pos));
595+
m_extraShaderDefines.push_back(reinterpret_cast<const char*>(pos));
595596
pool << define << " ";
596597
((pool << std::forward<Args>(args)), ...);
597598
}
598-
inline void finalizeGLSLDefinePool(std::ostringstream&& pool)
599+
inline void finalizeShaderDefinePool(std::ostringstream&& pool)
599600
{
600-
m_GLSLDefineStringPool.resize(static_cast<size_t>(pool.tellp())+m_extraGLSLDefines.size());
601-
const auto data = ptrdiff_t(m_GLSLDefineStringPool.data());
601+
m_ShaderDefineStringPool.resize(static_cast<size_t>(pool.tellp())+m_extraShaderDefines.size());
602+
const auto data = ptrdiff_t(m_ShaderDefineStringPool.data());
602603

603604
const auto str = pool.str();
604605
size_t nullCharsWritten = 0u;
605-
for (auto i=0u; i<m_extraGLSLDefines.size(); i++)
606+
for (auto i=0u; i<m_extraShaderDefines.size(); i++)
606607
{
607-
auto& dst = m_extraGLSLDefines[i];
608-
const auto len = (i!=(m_extraGLSLDefines.size()-1u) ? ptrdiff_t(m_extraGLSLDefines[i+1]):str.length())-ptrdiff_t(dst);
608+
auto& dst = m_extraShaderDefines[i];
609+
const auto len = (i!=(m_extraShaderDefines.size()-1u) ? ptrdiff_t(m_extraShaderDefines[i+1]):str.length())-ptrdiff_t(dst);
609610
const char* src = str.data()+ptrdiff_t(dst);
610611
dst += data+(nullCharsWritten++);
611612
memcpy(const_cast<char*>(dst),src,len);
612613
const_cast<char*>(dst)[len] = 0;
613614
}
614615
}
615616

616-
core::vector<char> m_GLSLDefineStringPool;
617-
core::vector<const char*> m_extraGLSLDefines;
618-
617+
core::vector<char> m_ShaderDefineStringPool;
618+
core::vector<const char*> m_extraShaderDefines;
619619

620+
core::smart_refctd_ptr<asset::CCompilerSet> m_compilerSet;
620621
core::smart_refctd_ptr<IAPIConnection> m_api;
621622
SPhysicalDeviceFeatures m_enabledFeatures;
622623
IPhysicalDevice* m_physicalDevice;

include/nbl/video/IPhysicalDevice.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -613,13 +613,6 @@ class NBL_API2 IPhysicalDevice : public core::Interface, public core::Unmovable
613613
//
614614
inline system::ISystem* getSystem() const {return m_system.get();}
615615

616-
inline asset::CGLSLCompiler* getGLSLCompiler() const
617-
{
618-
if (m_api)
619-
return m_api->getGLSLCompiler();
620-
return nullptr;
621-
}
622-
623616
virtual IDebugCallback* getDebugCallback() = 0;
624617

625618
core::smart_refctd_ptr<ILogicalDevice> createLogicalDevice(ILogicalDevice::SCreationParams&& params)
@@ -699,7 +692,6 @@ class NBL_API2 IPhysicalDevice : public core::Interface, public core::Unmovable
699692

700693
IAPIConnection* m_api; // dumb pointer to avoid circ ref
701694
core::smart_refctd_ptr<system::ISystem> m_system;
702-
core::smart_refctd_ptr<asset::CGLSLCompiler> m_GLSLCompiler;
703695

704696
SProperties m_properties = {};
705697
SFeatures m_features = {};

src/nbl/asset/IAssetManager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ void IAssetManager::initializeMeshTools()
121121
{
122122
m_meshManipulator = core::make_smart_refctd_ptr<CMeshManipulator>();
123123
m_geometryCreator = core::make_smart_refctd_ptr<CGeometryCreator>(m_meshManipulator.get());
124-
m_glslCompiler = core::make_smart_refctd_ptr<CGLSLCompiler>(core::smart_refctd_ptr(m_system));
124+
if (!m_compilerSet)
125+
m_compilerSet = core::make_smart_refctd_ptr<CCompilerSet>(core::smart_refctd_ptr(m_system));
125126
}
126127

127128
const IGeometryCreator* IAssetManager::getGeometryCreator() const

src/nbl/video/COpenGLShader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ using namespace nbl::core;
88
using namespace nbl::asset;
99
using namespace nbl::video;
1010

11-
// TODO: deduce the following in COpenGLPhysicalDevice from the OpenGL extension presence, and then add the defines as standardy from IPhysicalDevice : addCommonGLSLDefines() instead
11+
// TODO: deduce the following in COpenGLPhysicalDevice from the OpenGL extension presence, and then add the defines as standardy from IPhysicalDevice : addCommonShaderDefines() instead
1212
// The subgroup stuff is a bit hard cause we made up "extra" extensions such as `NBL_GL_KHR_shader_subgroup_ballot_inverse_ballot_bit_count` (probably best to expose as extra features)
1313
// [TODO] Clean this up with new define injection https://github.com/Devsh-Graphics-Programming/Nabla/pull/394 and redo prefix sum sample/workgroup ops example
1414
const char* COpenGLShader::k_openGL2VulkanExtensionMap = R"(

0 commit comments

Comments
 (0)