Merge vk-gl-cts/vulkan-cts-1.2.6 into vk-gl-cts/master
authorAlexander Galazin <alexander.galazin@arm.com>
Wed, 16 Jun 2021 09:38:56 +0000 (11:38 +0200)
committerAlexander Galazin <alexander.galazin@arm.com>
Wed, 16 Jun 2021 09:38:56 +0000 (11:38 +0200)
Change-Id: I5c61c18e70c4065effbf14c1e74b6f5b4b45c358

1  2 
external/vulkancts/framework/vulkan/vkRayTracingUtil.cpp
external/vulkancts/modules/vulkan/api/vktApiFeatureInfo.cpp
external/vulkancts/modules/vulkan/ray_tracing/vktRayTracingMiscTests.cpp

index 7bf18557caa5be71fad8ecbd547a4c6742208f5f,d3d5a59c07ac887b99dc426ead0b226d613c05e5..3c60d31c60d4fd11cc7c0646844168f4e634da2e
@@@ -1476,77 -1499,76 +1500,85 @@@ BufferWithMemory* createInstanceBuffer 
  
        const VkDeviceSize                      bufferSizeBytes         = bottomLevelInstances.size() * sizeof(VkAccelerationStructureInstanceKHR);
        const VkBufferCreateInfo        bufferCreateInfo        = makeBufferCreateInfo(bufferSizeBytes, VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
-       return new BufferWithMemory(vk, device, allocator, bufferCreateInfo, MemoryRequirement::HostVisible | MemoryRequirement::Coherent | MemoryRequirement::DeviceAddress);
+       try
+       {
+               return new BufferWithMemory(vk, device, allocator, bufferCreateInfo, MemoryRequirement::Cached | MemoryRequirement::HostVisible | MemoryRequirement::Coherent | MemoryRequirement::DeviceAddress);
+       }
+       catch (const tcu::NotSupportedError&)
+       {
+               // retry without Cached flag
+               return new BufferWithMemory(vk, device, allocator, bufferCreateInfo, MemoryRequirement::HostVisible | MemoryRequirement::Coherent | MemoryRequirement::DeviceAddress);
+       }
  }
  
 -void updateInstanceBuffer (const DeviceInterface&                                                                                     vk,
 -                                                 const VkDevice                                                                                                       device,
 -                                                 std::vector<de::SharedPtr<BottomLevelAccelerationStructure> >        bottomLevelInstances,
 -                                                 std::vector<InstanceData>                                                                            instanceData,
 -                                                 BufferWithMemory*                                                                                            instanceBuffer,
 -                                                 VkAccelerationStructureBuildTypeKHR                                                          buildType,
 -                                                 bool                                                                                                                         inactiveInstances)
 +void updateSingleInstance (const DeviceInterface&                                     vk,
 +                                                 const VkDevice                                                       device,
 +                                                 const BottomLevelAccelerationStructure&      bottomLevelAccelerationStructure,
 +                                                 const InstanceData&                                          instanceData,
 +                                                 deUint8*                                                                     bufferLocation,
 +                                                 VkAccelerationStructureBuildTypeKHR          buildType,
 +                                                 bool                                                                         inactiveInstances)
  {
 -      DE_ASSERT(bottomLevelInstances.size() != 0);
 -      DE_ASSERT(bottomLevelInstances.size() == instanceData.size());
 -
 -      const Allocation&                       instancesAlloc          = instanceBuffer->getAllocation();
 +      const VkAccelerationStructureKHR accelerationStructureKHR = *bottomLevelAccelerationStructure.getPtr();
  
 -      deUint8*                                        bufferStart                     = static_cast<deUint8*>(instancesAlloc.getHostPtr());
 -      VkDeviceSize                            bufferOffset            = 0;
 +      // This part needs to be fixed once a new version of the VkAccelerationStructureInstanceKHR will be added to vkStructTypes.inl
 +      VkDeviceAddress accelerationStructureAddress;
 +      if (buildType == VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR)
 +      {
 +              VkAccelerationStructureDeviceAddressInfoKHR asDeviceAddressInfo =
 +              {
 +                      VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_DEVICE_ADDRESS_INFO_KHR,       // VkStructureType                              sType;
 +                      DE_NULL,                                                                                                                        // const void*                                  pNext;
 +                      accelerationStructureKHR                                                                                        // VkAccelerationStructureKHR   accelerationStructure;
 +              };
 +              accelerationStructureAddress = vk.getAccelerationStructureDeviceAddressKHR(device, &asDeviceAddressInfo);
 +      }
  
 -      for (size_t instanceNdx = 0; instanceNdx < bottomLevelInstances.size(); ++instanceNdx)
 +      deUint64 structureReference;
 +      if (inactiveInstances)
 +      {
 +              // Instances will be marked inactive by making their references VK_NULL_HANDLE or having address zero.
 +              structureReference = 0ull;
 +      }
 +      else
        {
 -              const BottomLevelAccelerationStructure&         bottomLevelAccelerationStructure        = *bottomLevelInstances[instanceNdx];
 -              const VkAccelerationStructureKHR                        accelerationStructureKHR                        = *bottomLevelAccelerationStructure.getPtr();
 +              structureReference      = (buildType == VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR)
 +                                                      ? deUint64(accelerationStructureAddress)
 +                                                      : deUint64(accelerationStructureKHR.getInternal());
 +      }
  
 -              // This part needs to be fixed once a new version of the VkAccelerationStructureInstanceKHR will be added to vkStructTypes.inl
 -              VkDeviceAddress accelerationStructureAddress;
 -              if (buildType == VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR)
 -              {
 -                      VkAccelerationStructureDeviceAddressInfoKHR asDeviceAddressInfo =
 -                      {
 -                              VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_DEVICE_ADDRESS_INFO_KHR,       // VkStructureType                              sType;
 -                              DE_NULL,                                                                                                                        // const void*                                  pNext;
 -                              accelerationStructureKHR                                                                                        // VkAccelerationStructureKHR   accelerationStructure;
 -                      };
 -                      accelerationStructureAddress = vk.getAccelerationStructureDeviceAddressKHR(device, &asDeviceAddressInfo);
 -              }
 +      VkAccelerationStructureInstanceKHR      accelerationStructureInstanceKHR = makeVkAccelerationStructureInstanceKHR
 +      (
 +              instanceData.matrix,                                                                    //  VkTransformMatrixKHR                transform;
 +              instanceData.instanceCustomIndex,                                               //  deUint32                                    instanceCustomIndex:24;
 +              instanceData.mask,                                                                              //  deUint32                                    mask:8;
 +              instanceData.instanceShaderBindingTableRecordOffset,    //  deUint32                                    instanceShaderBindingTableRecordOffset:24;
 +              instanceData.flags,                                                                             //  VkGeometryInstanceFlagsKHR  flags:8;
 +              structureReference                                                                              //  deUint64                                    accelerationStructureReference;
 +      );
  
 -              deUint64 structureReference;
 -              if (inactiveInstances)
 -              {
 -                      // Instances will be marked inactive by making their references VK_NULL_HANDLE or having address zero.
 -                      structureReference = 0ull;
 -              }
 -              else
 -              {
 -                      structureReference      = (buildType == VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR)
 -                                                              ? deUint64(accelerationStructureAddress)
 -                                                              : deUint64(accelerationStructureKHR.getInternal());
 -              }
 +      deMemcpy(bufferLocation, &accelerationStructureInstanceKHR, sizeof(VkAccelerationStructureInstanceKHR));
 +}
  
 -              VkAccelerationStructureInstanceKHR      accelerationStructureInstanceKHR = makeVkAccelerationStructureInstanceKHR
 -              (
 -                      instanceData[instanceNdx].matrix,                                                                                                       //  VkTransformMatrixKHR                transform;
 -                      instanceData[instanceNdx].instanceCustomIndex,                                                                          //  deUint32                                    instanceCustomIndex:24;
 -                      instanceData[instanceNdx].mask,                                                                                                         //  deUint32                                    mask:8;
 -                      instanceData[instanceNdx].instanceShaderBindingTableRecordOffset,                                       //  deUint32                                    instanceShaderBindingTableRecordOffset:24;
 -                      instanceData[instanceNdx].flags,                                                                                                        //  VkGeometryInstanceFlagsKHR  flags:8;
 -                      structureReference                                                                                                                                      //  deUint64                                    accelerationStructureReference;
 -              );
 +void updateInstanceBuffer (const DeviceInterface&                                                                                             vk,
 +                                                 const VkDevice                                                                                                               device,
 +                                                 const std::vector<de::SharedPtr<BottomLevelAccelerationStructure>>&  bottomLevelInstances,
 +                                                 const std::vector<InstanceData>&                                                                             instanceData,
 +                                                 const BufferWithMemory*                                                                                              instanceBuffer,
 +                                                 VkAccelerationStructureBuildTypeKHR                                                                  buildType,
 +                                                 bool                                                                                                                                 inactiveInstances)
 +{
 +      DE_ASSERT(bottomLevelInstances.size() != 0);
 +      DE_ASSERT(bottomLevelInstances.size() == instanceData.size());
  
 -              deMemcpy(&bufferStart[bufferOffset], &accelerationStructureInstanceKHR, sizeof(VkAccelerationStructureInstanceKHR));
 +      auto&                   instancesAlloc          = instanceBuffer->getAllocation();
 +      auto                    bufferStart                     = reinterpret_cast<deUint8*>(instancesAlloc.getHostPtr());
 +      VkDeviceSize    bufferOffset            = 0ull;
  
 +      for (size_t instanceNdx = 0; instanceNdx < bottomLevelInstances.size(); ++instanceNdx)
 +      {
 +              const auto& blas = *bottomLevelInstances[instanceNdx];
 +              updateSingleInstance(vk, device, blas, instanceData[instanceNdx], bufferStart + bufferOffset, buildType, inactiveInstances);
                bufferOffset += sizeof(VkAccelerationStructureInstanceKHR);
        }