Skip to content

Commit

Permalink
tests: Use AddRequiredFeature where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-lunarg committed Oct 3, 2024
1 parent 7839cda commit f0fbbd2
Show file tree
Hide file tree
Showing 42 changed files with 431 additions and 1,400 deletions.
13 changes: 2 additions & 11 deletions tests/unit/best_practices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1157,17 +1157,8 @@ TEST_F(VkBestPracticesLayerTest, ThreadUpdateDescriptorUpdateAfterBindNoCollisio

AddRequiredExtensions(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
AddRequiredExtensions(VK_KHR_MAINTENANCE_3_EXTENSION_NAME);
RETURN_IF_SKIP(InitFramework());

// Create a device that enables descriptorBindingStorageBufferUpdateAfterBind
VkPhysicalDeviceDescriptorIndexingFeaturesEXT indexing_features = vku::InitStructHelper();
auto features2 = GetPhysicalDeviceFeatures2(indexing_features);

if (VK_FALSE == indexing_features.descriptorBindingStorageBufferUpdateAfterBind) {
GTEST_SKIP() << "Test requires (unsupported) descriptorBindingStorageBufferUpdateAfterBind";
}

RETURN_IF_SKIP(InitState(nullptr, &features2));
AddRequiredFeature(vkt::Feature::descriptorBindingStorageBufferUpdateAfterBind);
RETURN_IF_SKIP(Init());
InitRenderTarget();

std::array<VkDescriptorBindingFlagsEXT, 2> flags = {
Expand Down
11 changes: 3 additions & 8 deletions tests/unit/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2216,14 +2216,9 @@ TEST_F(NegativeCommand, ExclusiveScissorNV) {

AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
AddRequiredExtensions(VK_NV_SCISSOR_EXCLUSIVE_EXTENSION_NAME);
RETURN_IF_SKIP(InitFramework());

// Create a device that enables exclusive scissor but disables multiViewport
VkPhysicalDeviceExclusiveScissorFeaturesNV exclusive_scissor_features = vku::InitStructHelper();
auto features2 = GetPhysicalDeviceFeatures2(exclusive_scissor_features);
features2.features.multiViewport = VK_FALSE;

RETURN_IF_SKIP(InitState(nullptr, &features2));
AddDisabledFeature(vkt::Feature::multiViewport);
AddRequiredFeature(vkt::Feature::exclusiveScissor);
RETURN_IF_SKIP(Init());
InitRenderTarget();

if (m_device->Physical().limits_.maxViewports <= 1) {
Expand Down
13 changes: 2 additions & 11 deletions tests/unit/command_positive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,8 @@ TEST_F(PositiveCommand, DrawIndirectCountWithFeature) {
TEST_DESCRIPTION("Use VK_KHR_draw_indirect_count in 1.2 with feature bit enabled");

SetTargetApiVersion(VK_API_VERSION_1_2);
RETURN_IF_SKIP(InitFramework());

VkPhysicalDeviceVulkan12Features features12 = vku::InitStructHelper();
features12.drawIndirectCount = VK_TRUE;
auto features2 = GetPhysicalDeviceFeatures2(features12);
if (features12.drawIndirectCount != VK_TRUE) {
printf("drawIndirectCount not supported, skipping test\n");
return;
}

RETURN_IF_SKIP(InitState(nullptr, &features2));
AddRequiredFeature(vkt::Feature::drawIndirectCount);
RETURN_IF_SKIP(Init());
InitRenderTarget();

vkt::Buffer indirect_buffer(*m_device, sizeof(VkDrawIndirectCommand), VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT,
Expand Down
14 changes: 4 additions & 10 deletions tests/unit/copy_buffer_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1774,13 +1774,9 @@ TEST_F(NegativeCopyBufferImage, ImageMultiPlaneSizeExceeded) {
}

TEST_F(NegativeCopyBufferImage, ImageFormatSizeMismatch) {
// Enable KHR multiplane req'd extensions
AddRequiredExtensions(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME);
RETURN_IF_SKIP(InitFramework());
VkPhysicalDeviceSamplerYcbcrConversionFeaturesKHR mp_features = vku::InitStructHelper();
auto features2 = GetPhysicalDeviceFeatures2(mp_features);

RETURN_IF_SKIP(InitState(nullptr, &features2));
AddRequiredFeature(vkt::Feature::samplerYcbcrConversion);
RETURN_IF_SKIP(Init());

if (!FormatFeaturesAreSupported(Gpu(), VK_FORMAT_R8_UNORM, VK_IMAGE_TILING_OPTIMAL,
VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT)) {
Expand Down Expand Up @@ -1841,10 +1837,8 @@ TEST_F(NegativeCopyBufferImage, ImageFormatSizeMismatch) {
}

// DstImage is a mismatched plane of a multi-planar format
if (!mp_features.samplerYcbcrConversion) {
printf("No multi-planar support; section of tests skipped.\n");
} else if (FormatFeaturesAreSupported(gpu(), VK_FORMAT_G8_B8R8_2PLANE_420_UNORM, VK_IMAGE_TILING_OPTIMAL,
VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT)) {
if (FormatFeaturesAreSupported(gpu(), VK_FORMAT_G8_B8R8_2PLANE_420_UNORM, VK_IMAGE_TILING_OPTIMAL,
VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT)) {
image_create_info.format = VK_FORMAT_G8_B8R8_2PLANE_420_UNORM;
vkt::Image image_8b_16b_420_unorm(*m_device, image_create_info, vkt::set_layout);

Expand Down
26 changes: 10 additions & 16 deletions tests/unit/debug_printf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ TEST_F(NegativeDebugPrintf, MultiDraw) {
m_errorMonitor->VerifyFound();
}

TEST_F(NegativeDebugPrintf, MeshTaskShaders) {
TEST_F(NegativeDebugPrintf, MeshTaskShadersNV) {
TEST_DESCRIPTION("Test debug printf in mesh and task shaders.");

SetTargetApiVersion(VK_API_VERSION_1_1);
Expand Down Expand Up @@ -1809,22 +1809,16 @@ TEST_F(NegativeDebugPrintf, MeshTaskShaderObjects) {
AddRequiredExtensions(VK_EXT_SHADER_OBJECT_EXTENSION_NAME);
AddRequiredExtensions(VK_EXT_MESH_SHADER_EXTENSION_NAME);
AddRequiredExtensions(VK_KHR_MAINTENANCE_4_EXTENSION_NAME);
AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
AddRequiredFeature(vkt::Feature::maintenance4);
AddRequiredFeature(vkt::Feature::dynamicRendering);
AddRequiredFeature(vkt::Feature::shaderObject);
AddRequiredFeature(vkt::Feature::multiview);
AddRequiredFeature(vkt::Feature::meshShader);
AddRequiredFeature(vkt::Feature::taskShader);
AddDisabledFeature(vkt::Feature::multiviewMeshShader);
AddDisabledFeature(vkt::Feature::primitiveFragmentShadingRateMeshShader);
RETURN_IF_SKIP(InitDebugPrintfFramework());

// Create a device that enables mesh_shader
VkPhysicalDeviceMaintenance4Features maintenance_4_features = vku::InitStructHelper();
VkPhysicalDeviceDynamicRenderingFeatures dynamic_rendering_features = vku::InitStructHelper(&maintenance_4_features);
VkPhysicalDeviceShaderObjectFeaturesEXT shader_object_features = vku::InitStructHelper(&dynamic_rendering_features);
VkPhysicalDeviceMultiviewFeaturesKHR multiview_features = vku::InitStructHelper(&shader_object_features);
VkPhysicalDeviceFragmentShadingRateFeaturesKHR shading_rate_features = vku::InitStructHelper(&multiview_features);
VkPhysicalDeviceMeshShaderFeaturesEXT mesh_shader_features = vku::InitStructHelper(&shading_rate_features);
GetPhysicalDeviceFeatures2(mesh_shader_features);
if (!mesh_shader_features.taskShader || !mesh_shader_features.meshShader) {
GTEST_SKIP() << "Task or mesh shader not supported";
}

RETURN_IF_SKIP(InitState(nullptr, &mesh_shader_features));
RETURN_IF_SKIP(InitState());
InitDynamicRenderTarget();

static const char *taskShaderText = R"glsl(
Expand Down
39 changes: 8 additions & 31 deletions tests/unit/descriptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2473,21 +2473,10 @@ TEST_F(NegativeDescriptors, InlineUniformBlockEXT) {

SetTargetApiVersion(VK_API_VERSION_1_1);
AddRequiredExtensions(VK_EXT_INLINE_UNIFORM_BLOCK_EXTENSION_NAME);
AddOptionalExtensions(VK_KHR_MAINTENANCE_3_EXTENSION_NAME);
AddOptionalExtensions(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
RETURN_IF_SKIP(InitFramework());

// Enable descriptor indexing if supported, but don't require it.
bool has_descriptor_indexing =
IsExtensionsEnabled(VK_KHR_MAINTENANCE_3_EXTENSION_NAME) && IsExtensionsEnabled(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);

VkPhysicalDeviceDescriptorIndexingFeaturesEXT descriptor_indexing_features = vku::InitStructHelper();
void *pNext = has_descriptor_indexing ? &descriptor_indexing_features : nullptr;
// Create a device that enables inline_uniform_block
VkPhysicalDeviceInlineUniformBlockFeaturesEXT inline_uniform_block_features = vku::InitStructHelper(pNext);
auto features2 = GetPhysicalDeviceFeatures2(inline_uniform_block_features);

RETURN_IF_SKIP(InitState(nullptr, &features2));
AddRequiredExtensions(VK_KHR_MAINTENANCE_3_EXTENSION_NAME);
AddRequiredExtensions(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
AddRequiredFeature(vkt::Feature::inlineUniformBlock);
RETURN_IF_SKIP(Init());

VkPhysicalDeviceInlineUniformBlockPropertiesEXT inline_uniform_props = vku::InitStructHelper();
GetPhysicalDeviceProperties2(inline_uniform_props);
Expand Down Expand Up @@ -2907,15 +2896,8 @@ TEST_F(NegativeDescriptors, NullDescriptorsDisabled) {
TEST_F(NegativeDescriptors, NullDescriptorsEnabled) {
AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
AddRequiredExtensions(VK_EXT_ROBUSTNESS_2_EXTENSION_NAME);
RETURN_IF_SKIP(InitFramework());
VkPhysicalDeviceRobustness2FeaturesEXT robustness2_features = vku::InitStructHelper();
auto features2 = GetPhysicalDeviceFeatures2(robustness2_features);

if (!robustness2_features.nullDescriptor) {
GTEST_SKIP() << "nullDescriptor feature not supported";
}

RETURN_IF_SKIP(InitState(nullptr, &features2));
AddRequiredFeature(vkt::Feature::nullDescriptor);
RETURN_IF_SKIP(Init());
InitRenderTarget();

OneOffDescriptorSet descriptor_set(m_device, {
Expand Down Expand Up @@ -3995,13 +3977,8 @@ TEST_F(NegativeDescriptors, DISABLED_AllocatingVariableDescriptorSets) {

AddRequiredExtensions(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
RETURN_IF_SKIP(InitFramework());
VkPhysicalDeviceDescriptorIndexingFeaturesEXT indexing_features = vku::InitStructHelper();
auto features2 = GetPhysicalDeviceFeatures2(indexing_features);
if (indexing_features.descriptorBindingVariableDescriptorCount == VK_FALSE) {
GTEST_SKIP() << "descriptorBindingVariableDescriptorCount feature not supported";
}
RETURN_IF_SKIP(InitState(nullptr, &features2));
AddRequiredFeature(vkt::Feature::descriptorBindingVariableDescriptorCount);
RETURN_IF_SKIP(Init());

VkDescriptorBindingFlagsEXT flags[2] = {0, VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT};
VkDescriptorSetLayoutBindingFlagsCreateInfoEXT flags_create_info = vku::InitStructHelper();
Expand Down
20 changes: 6 additions & 14 deletions tests/unit/descriptors_positive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,13 +472,10 @@ TEST_F(PositiveDescriptors, CopyAccelerationStructureMutableDescriptors) {
AddRequiredExtensions(VK_EXT_MUTABLE_DESCRIPTOR_TYPE_EXTENSION_NAME);
AddRequiredExtensions(VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME);
AddRequiredExtensions(VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME);
RETURN_IF_SKIP(InitFramework());

VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT mutable_descriptor_type_features = vku::InitStructHelper();
VkPhysicalDeviceAccelerationStructureFeaturesKHR acc_struct_features = vku::InitStructHelper(&mutable_descriptor_type_features);
VkPhysicalDeviceBufferDeviceAddressFeaturesKHR bda_features = vku::InitStructHelper(&acc_struct_features);
GetPhysicalDeviceFeatures2(bda_features);
RETURN_IF_SKIP(InitState(nullptr, &bda_features));
AddRequiredFeature(vkt::Feature::mutableDescriptorType);
AddRequiredFeature(vkt::Feature::accelerationStructure);
AddRequiredFeature(vkt::Feature::bufferDeviceAddress);
RETURN_IF_SKIP(Init());

std::array descriptor_types = {VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR};

Expand Down Expand Up @@ -942,13 +939,8 @@ TEST_F(PositiveDescriptors, AttachmentFeedbackLoopLayout) {
TEST_DESCRIPTION("Read from image with layout attachment feedback loop");

AddRequiredExtensions(VK_EXT_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_EXTENSION_NAME);
RETURN_IF_SKIP(InitFramework());
VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT afll_features = vku::InitStructHelper();
GetPhysicalDeviceFeatures2(afll_features);
if (!afll_features.attachmentFeedbackLoopLayout) {
GTEST_SKIP() << "attachmentFeedbackLoopLayout not supported";
}
RETURN_IF_SKIP(InitState(nullptr, &afll_features));
AddRequiredFeature(vkt::Feature::attachmentFeedbackLoopLayout);
RETURN_IF_SKIP(Init());

VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
vkt::Image image(
Expand Down
59 changes: 11 additions & 48 deletions tests/unit/dynamic_rendering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2522,20 +2522,13 @@ TEST_F(NegativeDynamicRendering, AreaGreaterThanAttachmentExtent) {
AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
AddOptionalExtensions(VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME);
RETURN_IF_SKIP(InitFramework());
AddRequiredFeature(vkt::Feature::dynamicRendering);
RETURN_IF_SKIP(Init());

if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
GTEST_SKIP() << "Tests for 1.0 only";
}

VkPhysicalDeviceDynamicRenderingFeatures dynamic_rendering_features = vku::InitStructHelper();
auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
}

RETURN_IF_SKIP(InitState(nullptr, &features2));

vkt::Image colorImage(*m_device, 32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
vkt::ImageView colorImageView = colorImage.CreateView();

Expand Down Expand Up @@ -2814,22 +2807,10 @@ TEST_F(NegativeDynamicRendering, ShaderLayerBuiltIn) {

SetTargetApiVersion(VK_API_VERSION_1_1);
AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
RETURN_IF_SKIP(InitFramework());

VkPhysicalDeviceDynamicRenderingFeatures dynamic_rendering_features = vku::InitStructHelper();
VkPhysicalDeviceMultiviewFeatures multiview_features = vku::InitStructHelper(&dynamic_rendering_features);
auto features2 = GetPhysicalDeviceFeatures2(multiview_features);
if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
}
if (multiview_features.multiview == VK_FALSE) {
GTEST_SKIP() << "Test requires (unsupported) multiview";
}
if (multiview_features.multiviewGeometryShader == VK_FALSE) {
GTEST_SKIP() << "Test requires (unsupported) multiviewGeometryShader";
}

RETURN_IF_SKIP(InitState(nullptr, &features2));
AddRequiredFeature(vkt::Feature::dynamicRendering);
AddRequiredFeature(vkt::Feature::multiview);
AddRequiredFeature(vkt::Feature::multiviewGeometryShader);
RETURN_IF_SKIP(Init());
InitRenderTarget();

static char const *gsSource = R"glsl(
Expand Down Expand Up @@ -3351,19 +3332,12 @@ TEST_F(NegativeDynamicRendering, RenderArea) {
SetTargetApiVersion(VK_API_VERSION_1_0);
AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
RETURN_IF_SKIP(InitFramework());

AddRequiredFeature(vkt::Feature::dynamicRendering);
RETURN_IF_SKIP(Init());
if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
GTEST_SKIP() << "Tests for 1.0 only";
}

VkPhysicalDeviceDynamicRenderingFeatures dynamic_rendering_features = vku::InitStructHelper();
auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
}

RETURN_IF_SKIP(InitState(nullptr, &features2));
InitRenderTarget();

VkRenderingInfoKHR begin_rendering_info = vku::InitStructHelper();
Expand Down Expand Up @@ -4478,29 +4452,18 @@ TEST_F(NegativeDynamicRendering, FragmentShadingRateAttachmentSizeWithDeviceGrou
AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
AddRequiredExtensions(VK_KHR_MULTIVIEW_EXTENSION_NAME);

RETURN_IF_SKIP(InitFramework());
AddRequiredFeature(vkt::Feature::multiview);
AddRequiredFeature(vkt::Feature::dynamicRendering);
RETURN_IF_SKIP(Init());

if (!FormatFeaturesAreSupported(Gpu(), VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_TILING_OPTIMAL,
VK_FORMAT_FEATURE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR)) {
GTEST_SKIP() << "VK_FORMAT_FEATURE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR not supported";
}

VkPhysicalDeviceDynamicRenderingFeatures dynamic_rendering_features = vku::InitStructHelper();
VkPhysicalDeviceMultiviewFeaturesKHR multiview_features = vku::InitStructHelper(&dynamic_rendering_features);
VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(multiview_features);

if (multiview_features.multiview == VK_FALSE) {
GTEST_SKIP() << "Test requires (unsupported) multiview";
}
if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
}

VkPhysicalDeviceFragmentShadingRatePropertiesKHR fsr_properties = vku::InitStructHelper();
GetPhysicalDeviceProperties2(fsr_properties);

RETURN_IF_SKIP(InitState(nullptr, &features2));
vkt::Image image(*m_device, 32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR);
vkt::ImageView image_view = image.CreateView();
Expand Down
Loading

0 comments on commit f0fbbd2

Please sign in to comment.