Fix null shader module in raytracing tests
authorJaakko Konttinen <jaakko.konttinen@amd.com>
Thu, 30 Jul 2020 22:02:32 +0000 (18:02 -0400)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Wed, 5 Aug 2020 07:14:18 +0000 (03:14 -0400)
The dEQP-VK.ray_tracing_pipeline.build.gpu_cpu.* tests use a shader module
multiple times in two different hit groups. The variable is in Move
container, so the first call to addShader() moves the module handle to
the pipeline object and replaces the variable's value with a null
handle.  A subsequent call to addShader() then adds the null handle
as a shader stage module for another hit group.

I fixed it by just moving some code around to allow a second version of
addShader() that accepts a shared pointer instead.

Affects:

dEQP-VK.ray_tracing_pipeline.build.gpu_cpu.*
dEQP-VK.ray_tracing_pipeline.build.gpu_cpuht.*

Components: Vulkan
Change-Id: Ic2a4998e79b23cd43aaa1f6f267f60469de8f83a

external/vulkancts/framework/vulkan/vkRayTracingUtil.cpp
external/vulkancts/framework/vulkan/vkRayTracingUtil.hpp
external/vulkancts/modules/vulkan/ray_tracing/vktRayTracingBuildTests.cpp

index 99d9829..37ef386 100644 (file)
@@ -2008,6 +2008,11 @@ RayTracingPipeline::~RayTracingPipeline ()
 
 void RayTracingPipeline::addShader (VkShaderStageFlagBits shaderStage, Move<VkShaderModule> shaderModule, deUint32 group)
 {
+       addShader(shaderStage, makeVkSharedPtr(shaderModule), group);
+}
+
+void RayTracingPipeline::addShader (VkShaderStageFlagBits shaderStage, de::SharedPtr<Move<VkShaderModule>> shaderModule, deUint32 group)
+{
        if (group >= m_shadersGroupCreateInfos.size())
        {
                for (size_t groupNdx = m_shadersGroupCreateInfos.size(); groupNdx <= group; ++groupNdx)
@@ -2076,7 +2081,7 @@ void RayTracingPipeline::addShader (VkShaderStageFlagBits shaderStage, Move<VkSh
                        DE_NULL,                                                                                                //  const void*                                                 pNext;
                        (VkPipelineShaderStageCreateFlags)0,                                    //  VkPipelineShaderStageCreateFlags    flags;
                        shaderStage,                                                                                    //  VkShaderStageFlagBits                               stage;
-                       *shaderModule,                                                                                  //  VkShaderModule                                              module;
+                       **shaderModule,                                                                                 //  VkShaderModule                                              module;
                        "main",                                                                                                 //  const char*                                                 pName;
                        DE_NULL,                                                                                                //  const VkSpecializationInfo*                 pSpecializationInfo;
                };
@@ -2084,7 +2089,7 @@ void RayTracingPipeline::addShader (VkShaderStageFlagBits shaderStage, Move<VkSh
                m_shaderCreateInfos.push_back(shaderCreateInfo);
        }
 
-       m_shadersModules.push_back(makeVkSharedPtr(shaderModule));
+       m_shadersModules.push_back(shaderModule);
 }
 
 void RayTracingPipeline::addLibrary (de::SharedPtr<de::MovePtr<RayTracingPipeline>> pipelineLibrary)
index cebb31e..6bfc8c0 100644 (file)
@@ -526,6 +526,9 @@ public:
        void                                                                                                            addShader                                       (VkShaderStageFlagBits                                                                  shaderStage,
                                                                                                                                                                                         Move<VkShaderModule>                                                                   shaderModule,
                                                                                                                                                                                         deUint32                                                                                               group);
+       void                                                                                                            addShader                                       (VkShaderStageFlagBits                                                                  shaderStage,
+                                                                                                                                                                                        de::SharedPtr<Move<VkShaderModule>>                                    shaderModule,
+                                                                                                                                                                                        deUint32                                                                                               group);
        void                                                                                                            addLibrary                                      (de::SharedPtr<de::MovePtr<RayTracingPipeline>>                 pipelineLibrary);
        Move<VkPipeline>                                                                                        createPipeline                          (const DeviceInterface&                                                                 vk,
                                                                                                                                                                                         const VkDevice                                                                                 device,
index be5ca47..039dac5 100644 (file)
@@ -399,7 +399,7 @@ de::MovePtr<BufferWithMemory> RayTracingBuildTestInstance::runTest (bool useGpuB
 
        de::MovePtr<RayTracingPipeline>         rayTracingPipeline                                      = de::newMovePtr<RayTracingPipeline>();
        Move<VkShaderModule>                            raygenShader                                            = createShaderModule(vkd, device, m_context.getBinaryCollection().get("rgen"), 0);
-       Move<VkShaderModule>                            hitShader                                                       = createShaderModule(vkd, device, m_context.getBinaryCollection().get("ahit"), 0);
+       de::SharedPtr<Move<VkShaderModule>>     hitShader                                                       = makeVkSharedPtr(createShaderModule(vkd, device, m_context.getBinaryCollection().get("ahit"), 0));
        Move<VkShaderModule>                            missShader                                                      = createShaderModule(vkd, device, m_context.getBinaryCollection().get("miss"), 0);
        Move<VkShaderModule>                            intersectionShader                                      = createShaderModule(vkd, device, m_context.getBinaryCollection().get("sect"), 0);
        rayTracingPipeline->addShader(VK_SHADER_STAGE_RAYGEN_BIT_KHR,           raygenShader,           0u);