From 5e54fec06dd6ae4311734387ec1a0d1b4e090873 Mon Sep 17 00:00:00 2001 From: gomkyung2 Date: Wed, 8 Jan 2025 18:25:25 +0900 Subject: [PATCH] Fix lifetime issue. --- .../vulkan/pipeline/PrimitiveRenderer.cppm | 20 +++++++++++-------- .../pipeline/UnlitPrimitiveRenderer.cppm | 19 ++++++++++-------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/interface/vulkan/pipeline/PrimitiveRenderer.cppm b/interface/vulkan/pipeline/PrimitiveRenderer.cppm index db1f63c..f3e717b 100644 --- a/interface/vulkan/pipeline/PrimitiveRenderer.cppm +++ b/interface/vulkan/pipeline/PrimitiveRenderer.cppm @@ -42,24 +42,28 @@ namespace vk_gltf_viewer::vulkan::inline pipeline { const rp::Scene &sceneRenderPass ) const { const auto vertexShaderSpecializationData = getVertexShaderSpecializationData(); + const vk::SpecializationInfo vertexShaderSpecializationInfo { + SpecializationMap::value, + vk::ArrayProxyNoTemporaries { vertexShaderSpecializationData }, + }; + const auto fragmentShaderSpecializationData = getFragmentShaderSpecializationData(); + const vk::SpecializationInfo fragmentShaderSpecializationInfo { + SpecializationMap::value, + vk::ArrayProxyNoTemporaries { fragmentShaderSpecializationData }, + }; + const vku::RefHolder pipelineStages = createPipelineStages( device, vku::Shader { std::apply(LIFT(shader_selector::primitive_vert), getVertexShaderVariants()), vk::ShaderStageFlagBits::eVertex, - vku::unsafeAddress(vk::SpecializationInfo { - SpecializationMap::value, - vk::ArrayProxyNoTemporaries { vertexShaderSpecializationData }, - }), + &vertexShaderSpecializationInfo, }, vku::Shader { std::apply(LIFT(shader_selector::primitive_frag), getFragmentShaderVariants()), vk::ShaderStageFlagBits::eFragment, - vku::unsafeAddress(vk::SpecializationInfo { - SpecializationMap::value, - vk::ArrayProxyNoTemporaries { fragmentShaderSpecializationData }, - }), + &fragmentShaderSpecializationInfo, }); switch (alphaMode) { diff --git a/interface/vulkan/pipeline/UnlitPrimitiveRenderer.cppm b/interface/vulkan/pipeline/UnlitPrimitiveRenderer.cppm index 1d4c3a8..e2698d1 100644 --- a/interface/vulkan/pipeline/UnlitPrimitiveRenderer.cppm +++ b/interface/vulkan/pipeline/UnlitPrimitiveRenderer.cppm @@ -34,25 +34,28 @@ namespace vk_gltf_viewer::vulkan::inline pipeline { const rp::Scene &sceneRenderPass ) const { const auto vertexShaderSpecializationData = getVertexShaderSpecializationData(); + const vk::SpecializationInfo vertexShaderSpecializationInfo { + SpecializationMap::value, + vk::ArrayProxyNoTemporaries { vertexShaderSpecializationData }, + }; + const auto fragmentShaderSpecializationData = getFragmentShaderSpecializationData(); + const vk::SpecializationInfo fragmentShaderSpecializationInfo { + SpecializationMap::value, + vk::ArrayProxyNoTemporaries { fragmentShaderSpecializationData }, + }; const vku::RefHolder pipelineStages = createPipelineStages( device, vku::Shader { std::apply(LIFT(shader_selector::unlit_primitive_vert), getVertexShaderVariants()), vk::ShaderStageFlagBits::eVertex, - vku::unsafeAddress(vk::SpecializationInfo { - SpecializationMap::value, - vk::ArrayProxyNoTemporaries { vertexShaderSpecializationData }, - }), + &vertexShaderSpecializationInfo }, vku::Shader { std::apply(LIFT(shader_selector::unlit_primitive_frag), getFragmentShaderVariants()), vk::ShaderStageFlagBits::eFragment, - vku::unsafeAddress(vk::SpecializationInfo { - SpecializationMap::value, - vk::ArrayProxyNoTemporaries { fragmentShaderSpecializationData }, - }), + &fragmentShaderSpecializationInfo, }); switch (alphaMode) {