Skip to content

Commit 87a9c44

Browse files
committed
Removed SPIRV ref holding in CVulkanShader
1 parent b2ded94 commit 87a9c44

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

src/nbl/video/CVulkanLogicalDevice.h

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,7 @@ class CVulkanLogicalDevice final : public ILogicalDevice
550550

551551
const asset::ICPUBuffer* source = cpushader->getSPVorGLSL();
552552

553-
core::smart_refctd_ptr<asset::ICPUBuffer> spirv =
554-
core::smart_refctd_ptr_static_cast<asset::ICPUBuffer>(source->clone(1u));
555-
553+
core::smart_refctd_ptr<asset::ICPUBuffer> spirv;
556554
if (cpushader->containsGLSL())
557555
{
558556
const char* begin = static_cast<const char*>(source->getPointer());
@@ -577,6 +575,10 @@ class CVulkanLogicalDevice final : public ILogicalDevice
577575
logger,
578576
m_physicalDevice->getLimits().spirvVersion);
579577
}
578+
else
579+
{
580+
spirv = core::smart_refctd_ptr_static_cast<asset::ICPUBuffer>(source->clone(1u));
581+
}
580582

581583
if (!spirv)
582584
return nullptr;
@@ -591,7 +593,7 @@ class CVulkanLogicalDevice final : public ILogicalDevice
591593
if (m_devf.vk.vkCreateShaderModule(m_vkdev, &vk_createInfo, nullptr, &vk_shaderModule) == VK_SUCCESS)
592594
{
593595
return core::make_smart_refctd_ptr<video::CVulkanShader>(
594-
core::smart_refctd_ptr<CVulkanLogicalDevice>(this), std::move(spirv), cpushader->getStage(), std::string(cpushader->getFilepathHint()), vk_shaderModule);
596+
core::smart_refctd_ptr<CVulkanLogicalDevice>(this), cpushader->getStage(), std::string(cpushader->getFilepathHint()), vk_shaderModule);
595597
}
596598
else
597599
{
@@ -1132,14 +1134,6 @@ class CVulkanLogicalDevice final : public ILogicalDevice
11321134

11331135
const CVulkanShader* vulkanShader = static_cast<const CVulkanShader*>(_unspecialized);
11341136

1135-
auto spirv = core::smart_refctd_ptr<const asset::ICPUBuffer>(static_cast<const CVulkanShader*>(_unspecialized)->getSPV());
1136-
1137-
if (spvopt)
1138-
spirv = spvopt->optimize(spirv.get(), m_physicalDevice->getDebugCallback()->getLogger());
1139-
1140-
if (!spirv)
1141-
return nullptr;
1142-
11431137
return core::make_smart_refctd_ptr<CVulkanSpecializedShader>(
11441138
core::smart_refctd_ptr<CVulkanLogicalDevice>(this),
11451139
core::smart_refctd_ptr<const CVulkanShader>(vulkanShader), specInfo);

src/nbl/video/CVulkanShader.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,19 @@ class CVulkanShader : public IGPUShader
1212
public:
1313
CVulkanShader(
1414
core::smart_refctd_ptr<ILogicalDevice>&& dev,
15-
core::smart_refctd_ptr<asset::ICPUBuffer>&& spirv,
1615
const E_SHADER_STAGE stage,
1716
std::string&& filepathHint,
1817
VkShaderModule vk_shaderModule)
19-
: IGPUShader(std::move(dev), stage, std::move(filepathHint)),
20-
m_spirv(std::move(spirv)), m_vkShaderModule(vk_shaderModule)
21-
{}
18+
: IGPUShader(std::move(dev), stage, std::move(filepathHint))
19+
, m_vkShaderModule(vk_shaderModule)
20+
{
21+
}
2222

2323
~CVulkanShader();
2424

25-
const asset::ICPUBuffer* getSPV() const { return m_spirv.get(); };
26-
2725
inline VkShaderModule getInternalObject() const { return m_vkShaderModule; }
2826

2927
private:
30-
core::smart_refctd_ptr<asset::ICPUBuffer> m_spirv;
3128
VkShaderModule m_vkShaderModule = VK_NULL_HANDLE;
3229

3330
};

0 commit comments

Comments
 (0)