#include "vkImageWithMemory.hpp"
#include "vkImageUtil.hpp"
#include "vkQueryUtil.hpp"
+#include "vkDeviceUtil.hpp"
#include "vkBuilderUtil.hpp"
#include "vkCmdUtil.hpp"
#include "vkTypeUtil.hpp"
class SingletonDevice
{
SingletonDevice (Context& context)
- : m_logicalDevice ()
+ : m_context(context), m_instanceWrapper(new CustomInstanceWrapper(context)), m_logicalDevice ()
{
// Note we are already checking the needed features are available in checkSupport().
VkPhysicalDeviceRobustness2FeaturesEXT robustness2Features = initVulkanStructure();
features2.pNext = &shaderImageAtomicInt64Features;
}
- context.getInstanceInterface().getPhysicalDeviceFeatures2(context.getPhysicalDevice(), &features2);
- m_logicalDevice = createRobustBufferAccessDevice(context, &features2);
+ const VkPhysicalDevice physicalDevice = chooseDevice(m_instanceWrapper->instance.getDriver(), m_instanceWrapper->instance, context.getTestContext().getCommandLine());
+ m_instanceWrapper->instance.getDriver().getPhysicalDeviceFeatures2(physicalDevice, &features2);
+ m_logicalDevice = createRobustBufferAccessDevice(context, m_instanceWrapper->instance, m_instanceWrapper->instance.getDriver(), &features2);
+
+#ifndef CTS_USES_VULKANSC
+ m_deviceDriver = de::MovePtr<DeviceDriver>(new DeviceDriver(context.getPlatformInterface(), m_instanceWrapper->instance, *m_logicalDevice));
+#else
+ m_deviceDriver = de::MovePtr<DeviceDriverSC, DeinitDeviceDeleter>(new DeviceDriverSC(context.getPlatformInterface(), m_instanceWrapper->instance, *m_logicalDevice, context.getTestContext().getCommandLine(), context.getResourceInterface(), m_context.getDeviceVulkanSC10Properties()), vk::DeinitDeviceDeleter(context.getResourceInterface().get(), *m_logicalDevice));
+#endif // CTS_USES_VULKANSC
}
public:
+ ~SingletonDevice()
+ {
+ }
+ static VkInstance getInstance(Context& context)
+ {
+ if (!m_singletonDevice)
+ m_singletonDevice = SharedPtr<SingletonDevice>(new SingletonDevice(context));
+ DE_ASSERT(m_singletonDevice);
+ return m_singletonDevice->m_instanceWrapper->instance;
+ }
+ static const InstanceInterface& getInstanceInterface(Context& context)
+ {
+ if (!m_singletonDevice)
+ m_singletonDevice = SharedPtr<SingletonDevice>(new SingletonDevice(context));
+ DE_ASSERT(m_singletonDevice);
+ return m_singletonDevice->m_instanceWrapper->instance.getDriver();
+ }
+
static VkDevice getDevice(Context& context)
{
if (!m_singletonDevice)
DE_ASSERT(m_singletonDevice);
return m_singletonDevice->m_logicalDevice.get();
}
+ static const DeviceInterface& getDeviceInterface(Context& context)
+ {
+ if (!m_singletonDevice)
+ m_singletonDevice = SharedPtr<SingletonDevice>(new SingletonDevice(context));
+ DE_ASSERT(m_singletonDevice);
+ return *(m_singletonDevice->m_deviceDriver.get());
+ }
static void destroy()
{
}
private:
+ const Context& m_context;
+ std::shared_ptr<CustomInstanceWrapper> m_instanceWrapper;
Move<vk::VkDevice> m_logicalDevice;
+#ifndef CTS_USES_VULKANSC
+ de::MovePtr<vk::DeviceDriver> m_deviceDriver;
+#else
+ de::MovePtr<vk::DeviceDriverSC, vk::DeinitDeviceDeleter> m_deviceDriver;
+#endif // CTS_USES_VULKANSC
+
static SharedPtr<SingletonDevice<FEATURES>> m_singletonDevice;
};
}
// Returns the appropriate singleton device for the given case.
+VkInstance getInstance(Context& ctx, const CaseDef& caseDef)
+{
+ if (formatIsR64(caseDef.format))
+ {
+ if (caseDef.testRobustness2)
+ return Robustness2Int64AtomicsSingleton::getInstance(ctx);
+ return ImageRobustnessInt64AtomicsSingleton::getInstance(ctx);
+ }
+
+ if (caseDef.testRobustness2)
+ return Robustness2Singleton::getInstance(ctx);
+ return ImageRobustnessSingleton::getInstance(ctx);
+}
+
+// Returns the appropriate singleton device driver for the given case.
+const InstanceInterface& getInstanceInterface(Context& ctx, const CaseDef& caseDef)
+{
+ if (formatIsR64(caseDef.format))
+ {
+ if (caseDef.testRobustness2)
+ return Robustness2Int64AtomicsSingleton::getInstanceInterface(ctx);
+ return ImageRobustnessInt64AtomicsSingleton::getInstanceInterface(ctx);
+ }
+
+ if (caseDef.testRobustness2)
+ return Robustness2Singleton::getInstanceInterface(ctx);
+ return ImageRobustnessSingleton::getInstanceInterface(ctx);
+}
+
+// Returns the appropriate singleton device for the given case.
VkDevice getLogicalDevice (Context& ctx, const CaseDef& caseDef)
{
if (formatIsR64(caseDef.format))
return ImageRobustnessSingleton::getDevice(ctx);
}
+// Returns the appropriate singleton device driver for the given case.
+const DeviceInterface& getDeviceInterface(Context& ctx, const CaseDef& caseDef)
+{
+ if (formatIsR64(caseDef.format))
+ {
+ if (caseDef.testRobustness2)
+ return Robustness2Int64AtomicsSingleton::getDeviceInterface(ctx);
+ return ImageRobustnessInt64AtomicsSingleton::getDeviceInterface(ctx);
+ }
+
+ if (caseDef.testRobustness2)
+ return Robustness2Singleton::getDeviceInterface(ctx);
+ return ImageRobustnessSingleton::getDeviceInterface(ctx);
+}
+
+
class Layout
{
public:
VkPhysicalDeviceRobustness2FeaturesEXT robustness2Features = initVulkanStructure();
VkPhysicalDeviceImageRobustnessFeaturesEXT imageRobustnessFeatures = initVulkanStructure();
VkPhysicalDeviceScalarBlockLayoutFeatures scalarLayoutFeatures = initVulkanStructure();
- VkPhysicalDeviceFeatures2KHR features2 = initVulkanStructure();
+ VkPhysicalDeviceFeatures2 features2 = initVulkanStructure();
context.requireInstanceFunctionality("VK_KHR_get_physical_device_properties2");
context.requireDeviceFunctionality("VK_EXT_shader_image_atomic_int64");
VkFormatProperties formatProperties;
- vki.getPhysicalDeviceFormatProperties(context.getPhysicalDevice(), m_data.format, &formatProperties);
+ vki.getPhysicalDeviceFormatProperties(physicalDevice, m_data.format, &formatProperties);
switch (m_data.descriptorType)
{
!features2.features.shaderStorageImageMultisample)
TCU_THROW(NotSupportedError, "shaderStorageImageMultisample not supported");
- if ((m_data.useTemplate || formatIsR64(m_data.format)) && !context.contextSupports(vk::ApiVersion(1, 1, 0)))
+ if ((m_data.useTemplate || formatIsR64(m_data.format)) && !context.contextSupports(vk::ApiVersion(0, 1, 1, 0)))
TCU_THROW(NotSupportedError, "Vulkan 1.1 not supported");
+#ifndef CTS_USES_VULKANSC
if ((m_data.descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER || m_data.descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) &&
!m_data.formatQualifier)
{
if (!(formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_2_STORAGE_WRITE_WITHOUT_FORMAT_BIT_KHR))
TCU_THROW(NotSupportedError, "Format does not support writing without format");
}
+#else
+ if ((m_data.descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER || m_data.descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) &&
+ !m_data.formatQualifier &&
+ (!features2.features.shaderStorageImageReadWithoutFormat || !features2.features.shaderStorageImageWriteWithoutFormat))
+ TCU_THROW(NotSupportedError, "shaderStorageImageReadWithoutFormat or shaderStorageImageWriteWithoutFormat not supported");
+#endif // CTS_USES_VULKANSC
if (m_data.pushDescriptor)
context.requireDeviceFunctionality("VK_KHR_push_descriptor");
// Normalized coordinates. Divide by "imageDim" and add 0.25 so we're not on a pixel boundary.
string genCoordNorm(const CaseDef &caseDef, string c, int numCoords, int numNormalizedCoords, int dim)
{
+ // dim can be 3 for cube_array. Reuse the number of layers in that case.
+ dim = std::min(dim, 2);
+
if (numCoords == 1)
return c + " / float(" + to_string(caseDef.imageDim[dim]) + ")";
tcu::TestStatus RobustnessExtsTestInstance::iterate (void)
{
- const InstanceInterface& vki = m_context.getInstanceInterface();
+ const VkInstance instance = getInstance(m_context, m_data);
+ const InstanceInterface& vki = getInstanceInterface(m_context, m_data);
const VkDevice device = getLogicalDevice(m_context, m_data);
- const DeviceDriver vk (m_context.getPlatformInterface(), m_context.getInstance(), device);
- const VkPhysicalDevice physicalDevice = m_context.getPhysicalDevice();
+ const vk::DeviceInterface& vk = getDeviceInterface(m_context, m_data);
+ const VkPhysicalDevice physicalDevice = chooseDevice(vki, instance, m_context.getTestContext().getCommandLine());
SimpleAllocator allocator (vk, device, getPhysicalDeviceMemoryProperties(vki, physicalDevice));
Layout layout;
properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
void** pNextTail = &properties.pNext;
+#ifndef CTS_USES_VULKANSC
VkPhysicalDeviceRayTracingPropertiesNV rayTracingProperties;
deMemset(&rayTracingProperties, 0, sizeof(rayTracingProperties));
rayTracingProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PROPERTIES_NV;
+#endif
VkPhysicalDeviceRobustness2PropertiesEXT robustness2Properties;
deMemset(&robustness2Properties, 0, sizeof(robustness2Properties));
robustness2Properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_PROPERTIES_EXT;
+#ifndef CTS_USES_VULKANSC
if (m_context.isDeviceFunctionalitySupported("VK_NV_ray_tracing"))
{
*pNextTail = &rayTracingProperties;
pNextTail = &rayTracingProperties.pNext;
}
+#endif
if (m_context.isDeviceFunctionalitySupported("VK_EXT_robustness2"))
{
case STAGE_COMPUTE:
bindPoint = VK_PIPELINE_BIND_POINT_COMPUTE;
break;
+#ifndef CTS_USES_VULKANSC
case STAGE_RAYGEN:
bindPoint = VK_PIPELINE_BIND_POINT_RAY_TRACING_NV;
break;
+#endif
default:
bindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
break;
vector<VkDescriptorSetLayoutBinding> &bindings = layout.layoutBindings;
VkDescriptorPoolCreateFlags poolCreateFlags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
+
+#ifndef CTS_USES_VULKANSC
VkDescriptorSetLayoutCreateFlags layoutCreateFlags = m_data.pushDescriptor ? VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR : 0;
+#else
+ VkDescriptorSetLayoutCreateFlags layoutCreateFlags = 0;
+#endif
// Create a layout and allocate a descriptor set for it.
if (m_data.viewType == VK_IMAGE_VIEW_TYPE_CUBE || m_data.viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY)
imageCreateFlags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
- const bool featureSampledImage = ((getPhysicalDeviceFormatProperties(m_context.getInstanceInterface(),
- m_context.getPhysicalDevice(),
+ const bool featureSampledImage = ((getPhysicalDeviceFormatProperties(vki,
+ physicalDevice,
m_data.format).optimalTilingFeatures &
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) == VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT);
int vecIndex = 0;
int numDynamic = 0;
+#ifndef CTS_USES_VULKANSC
vector<VkDescriptorUpdateTemplateEntry> imgTemplateEntriesBefore,
bufTemplateEntriesBefore,
texelBufTemplateEntriesBefore;
+#endif
for (size_t b = 0; b < bindings.size(); ++b)
{
&bufferViewVec[vecIndex], // pTexelBufferView
};
+#ifndef CTS_USES_VULKANSC
VkDescriptorUpdateTemplateEntry templateEntry =
{
(deUint32)b, // uint32_t dstBinding;
bufTemplateEntriesBefore.push_back(templateEntry);
break;
}
+#endif
vecIndex++;
// Randomly select between vkUpdateDescriptorSets and vkUpdateDescriptorSetWithTemplate
if (m_data.useTemplate)
{
+#ifndef CTS_USES_VULKANSC
VkDescriptorUpdateTemplateCreateInfo templateCreateInfo =
{
VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO, // VkStructureType sType;
vk.cmdBindDescriptorSets(*cmdBuffer, bindPoint, *pipelineLayout, 0, 1, &descriptorSet.get(), numDynamic, &zeros[0]);
}
+#endif
}
else
{
if (m_data.pushDescriptor)
{
+#ifndef CTS_USES_VULKANSC
if (writesBeforeBindVec.size())
{
vk.cmdPushDescriptorSetKHR(*cmdBuffer, bindPoint, *pipelineLayout, 0, (deUint32)writesBeforeBindVec.size(), &writesBeforeBindVec[0]);
}
+#endif
}
else
{
pipeline = makeComputePipeline(vk, device, *pipelineLayout, *shader);
}
+#ifndef CTS_USES_VULKANSC
else if (m_data.stage == STAGE_RAYGEN)
{
const Unique<VkShaderModule> shader(createShaderModule(vk, device, m_context.getBinaryCollection().get("test"), 0));
vk.getRayTracingShaderGroupHandlesNV(device, *pipeline, 0, 1, rayTracingProperties.shaderGroupHandleSize, ptr);
}
+#endif
else
{
const VkSubpassDescription subpassDesc =
{
vk.cmdDispatch(*cmdBuffer, DIM, DIM, 1);
}
+#ifndef CTS_USES_VULKANSC
else if (m_data.stage == STAGE_RAYGEN)
{
vk.cmdTraceRaysNV(*cmdBuffer,
DE_NULL, 0, 0,
DIM, DIM, 1);
}
+#endif
else
{
beginRenderPass(vk, *cmdBuffer, *renderPass, *framebuffer,
{ STAGE_COMPUTE, "comp", "compute" },
{ STAGE_FRAGMENT, "frag", "fragment" },
{ STAGE_VERTEX, "vert", "vertex" },
+#ifndef CTS_USES_VULKANSC
{ STAGE_RAYGEN, "rgen", "raygen" },
+#endif
};
TestGroupCase volCases[] =
TestGroupCase tempCases[] =
{
{ 0, "notemplate", "" },
+#ifndef CTS_USES_VULKANSC
{ 1, "template", "" },
+#endif
};
TestGroupCase pushCases[] =
{
{ 0, "bind", "" },
+#ifndef CTS_USES_VULKANSC
{ 1, "push", "" },
+#endif
};
TestGroupCase fmtQualCases[] =
Stage currentStage = static_cast<Stage>(stageCases[stageNdx].count);
VkFlags allShaderStages = VK_SHADER_STAGE_COMPUTE_BIT | VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT;
VkFlags allPipelineStages = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
+#ifndef CTS_USES_VULKANSC
if ((Stage)stageCases[stageNdx].count == STAGE_RAYGEN)
{
allShaderStages |= VK_SHADER_STAGE_RAYGEN_BIT_NV;
allPipelineStages |= VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_NV;
}
+#endif // CTS_USES_VULKANSC
if (descCases[descNdx].count == VERTEX_ATTRIBUTE_FETCH &&
currentStage != STAGE_VERTEX)