Skip to content

Commit bb9bcbc

Browse files
committed
brought back spirv ref for spirv optimizer
1 parent cc5d289 commit bb9bcbc

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/nbl/video/CVulkanLogicalDevice.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ class CVulkanLogicalDevice final : public ILogicalDevice
596596
if (m_devf.vk.vkCreateShaderModule(m_vkdev, &vk_createInfo, nullptr, &vk_shaderModule) == VK_SUCCESS)
597597
{
598598
return core::make_smart_refctd_ptr<video::CVulkanShader>(
599-
core::smart_refctd_ptr<CVulkanLogicalDevice>(this), cpushader->getStage(), std::string(cpushader->getFilepathHint()), vk_shaderModule);
599+
core::smart_refctd_ptr<CVulkanLogicalDevice>(this), std::move(spirv), cpushader->getStage(), std::string(cpushader->getFilepathHint()), vk_shaderModule);
600600
}
601601
else
602602
{
@@ -1138,6 +1138,14 @@ class CVulkanLogicalDevice final : public ILogicalDevice
11381138

11391139
const CVulkanShader* vulkanShader = IBackendObject::device_compatibility_cast<const CVulkanShader*>(_unspecialized, this);
11401140

1141+
auto spirv = core::smart_refctd_ptr<const asset::ICPUBuffer>(static_cast<const CVulkanShader*>(_unspecialized)->getSPV());
1142+
1143+
if (spvopt)
1144+
spirv = spvopt->optimize(spirv.get(), m_physicalDevice->getDebugCallback()->getLogger());
1145+
1146+
if (!spirv)
1147+
return nullptr;
1148+
11411149
return core::make_smart_refctd_ptr<CVulkanSpecializedShader>(
11421150
core::smart_refctd_ptr<CVulkanLogicalDevice>(this),
11431151
core::smart_refctd_ptr<const CVulkanShader>(vulkanShader), specInfo);

src/nbl/video/CVulkanShader.h

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

2323
~CVulkanShader();
24+
25+
const asset::ICPUBuffer* getSPV() const { return m_spirv.get(); };
2426

2527
inline VkShaderModule getInternalObject() const { return m_vkShaderModule; }
2628

2729
private:
30+
// We want to use the SPIR-V optimizer later.
31+
core::smart_refctd_ptr<asset::ICPUBuffer> m_spirv;
2832
VkShaderModule m_vkShaderModule = VK_NULL_HANDLE;
2933

3034
};

0 commit comments

Comments
 (0)