Skip to content

Commit

Permalink
tests: Test and framework refactoring/improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
aqnuep committed Mar 27, 2024
1 parent d2b1d67 commit bdee7fb
Show file tree
Hide file tree
Showing 23 changed files with 654 additions and 651 deletions.
16 changes: 9 additions & 7 deletions scripts/vksc_convert_tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,6 @@
"NegativePipeline.CreateFlags",
"NegativePipeline.CreateFlagsCompute"
]
},
{
"reason": "Uses too many objects",
"cases": [
"@Note: This test case assumes 10000 descriptor sets can be created from a single pool",
"PositiveThreading.DebugObjectNames"
]
}
],
"modify": [
Expand Down Expand Up @@ -387,6 +380,15 @@
"patch": [
"m_errorMonitor->SetAllowedFailureMsg(\"VUID-VkRenderPassCreateInfo2-flags-zerobitmask\")"
]
},
{
"reason": "This test case creates 10000 descriptor sets from a single pool",
"cases": [
"PositiveThreading.DebugObjectNames"
],
"patch": [
"ObjectReservation().descriptorSetRequestCount = 10000"
]
}
]
}
3 changes: 2 additions & 1 deletion tests/vulkansc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,16 @@ target_sources(vksc_layer_validation_tests PRIVATE
negative/object_reservation.cpp
negative/others.cpp
negative/pipeline.cpp
negative/pipeline_cache_data.cpp
negative/ported.cpp
negative/render_pass.cpp
negative/shader_spirv.cpp
negative/wsi.cpp
positive/device_create.cpp
positive/implicit.cpp
positive/instance.cpp
positive/others.cpp
positive/pipeline.cpp
positive/pipeline_cache_data.cpp
positive/shader_spirv.cpp
)

Expand Down
5 changes: 3 additions & 2 deletions tests/vulkansc/converted/threading_positive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ TEST_F(PositiveThreading, NullFenceCollision) {
m_errorMonitor->SetBailout(NULL);
}

// Uses too many objects
TEST_F(PositiveThreading, DISABLED_DebugObjectNames) {
TEST_F(PositiveThreading, DebugObjectNames) {
// This test case creates 10000 descriptor sets from a single pool
ObjectReservation().descriptorSetRequestCount = 10000;
AddRequiredExtensions(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
RETURN_IF_SKIP(Init());

Expand Down
27 changes: 22 additions & 5 deletions tests/vulkansc/framework/vksc_layer_validation_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class VkSCLayerTest : public VkLayerTest {

class VkSCPositiveLayerTest : public VkSCLayerTest {};

class VkSCDeviceCreateLayerTest : public VkSCLayerTest {
class VkSCDeviceCreateTest : public VkSCLayerTest {
public:
VkPhysicalDeviceProperties phys_dev_props;

Expand Down Expand Up @@ -53,7 +53,7 @@ class VkSCDeviceCreateLayerTest : public VkSCLayerTest {
}
};

class VkSCPipelineCacheDataLayerTest : public VkSCDeviceCreateLayerTest {
class VkSCPipelineCacheDataTest : public VkSCDeviceCreateTest {
public:
VkPipelineCacheCreateInfo create_info{};

Expand All @@ -78,7 +78,24 @@ class VkSCPipelineCacheDataLayerTest : public VkSCDeviceCreateLayerTest {
vksc::PipelineCacheBuilder builder{};
};

class VkSCPositivePipelineCacheDataLayerTest : public VkSCPipelineCacheDataLayerTest {};
class VkSCNegativeDeviceCreate : public VkSCDeviceCreateTest {};

class VkSCShaderSpirvTest : public VkSCLayerTest {};
class VkSCPositiveShaderSpirvTest : public VkSCShaderSpirvTest {};
class VkSCNegativePipelineCacheData : public VkSCPipelineCacheDataTest {};
class VkSCPositivePipelineCacheData : public VkSCPipelineCacheDataTest {};

class VkSCNegativeShaderSpirv : public VkSCLayerTest {};
class VkSCPositiveShaderSpirv : public VkSCLayerTest {};

class VkSCPositiveRemoved : public VkSCLayerTest {};

class VkSCNegativeImplicit : public VkSCLayerTest {};
class VkSCPositiveImplicit : public VkSCLayerTest {};

class VkSCNegativeCommand : public VkSCLayerTest {};

class VkSCPositiveInstance : public VkSCLayerTest {};

class VkSCNegativePipeline : public VkSCLayerTest {};
class VkSCPositivePipeline : public VkSCLayerTest {};

class VkSCNegativeRenderPass : public VkSCLayerTest {};
19 changes: 2 additions & 17 deletions tests/vulkansc/framework/vksc_render_framework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ void VkSCRenderFramework::InitFramework(void *instance_pnext) {

void VkSCRenderFramework::InitState(VkPhysicalDeviceFeatures *features, void *create_device_pnext,
const VkCommandPoolCreateFlags flags) {
auto default_object_reservation_info = vksc::GetDefaultObjectReservationCreateInfo();
if (!vku::FindStructInPNextChain<VkDeviceObjectReservationCreateInfo>(create_device_pnext)) {
// If no object reservation was specified by the test case, then we add the default one
default_object_reservation_info.pNext = create_device_pnext;
create_device_pnext = &default_object_reservation_info;
object_reservation_info_.pNext = create_device_pnext;
create_device_pnext = &object_reservation_info_;
}

auto builder_object_reservation_info = vku::InitStruct<VkDeviceObjectReservationCreateInfo>();
Expand Down Expand Up @@ -63,20 +62,6 @@ VkPipelineCache VkSCRenderFramework::GetDefaultPipelineCache() {
return default_pipeline_cache_;
}

VkPhysicalDeviceVulkanSC10Features VkSCRenderFramework::GetVulkanSC10Features(VkPhysicalDevice phys_dev) {
auto sc_10_features = vku::InitStruct<VkPhysicalDeviceVulkanSC10Features>();
auto features2 = vku::InitStruct<VkPhysicalDeviceFeatures2>(&sc_10_features);
vksc::GetPhysicalDeviceFeatures2(phys_dev, &features2);
return sc_10_features;
}

VkPhysicalDeviceVulkanSC10Properties VkSCRenderFramework::GetVulkanSC10Properties(VkPhysicalDevice phys_dev) {
auto sc_10_props = vku::InitStruct<VkPhysicalDeviceVulkanSC10Properties>();
auto props2 = vku::InitStruct<VkPhysicalDeviceProperties2>(&sc_10_props);
vksc::GetPhysicalDeviceProperties2(phys_dev, &props2);
return sc_10_props;
}

VkSCCompatibilityRenderFramework::VkSCCompatibilityRenderFramework()
: VkSCRenderFramework(), dispatch_helper_(this), shader_modules_(), on_demand_pipeline_caches_() {
assert(s_instance == nullptr);
Expand Down
37 changes: 32 additions & 5 deletions tests/vulkansc/framework/vksc_render_framework.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class PipelineCache;
// Render framework used by Vulkan SC tests
class VkSCRenderFramework : public VkRenderFramework {
public:
VkSCRenderFramework() : VkRenderFramework(), object_reservation_info_(vksc::GetDefaultObjectReservationCreateInfo()) {}
virtual ~VkSCRenderFramework() override;

void InitFramework(void *instance_pnext = NULL);
Expand All @@ -30,19 +31,42 @@ class VkSCRenderFramework : public VkRenderFramework {

VkPipelineCache GetDefaultPipelineCache();

static VkPhysicalDeviceVulkanSC10Features GetVulkanSC10Features(VkPhysicalDevice phys_dev);
static VkPhysicalDeviceVulkanSC10Properties GetVulkanSC10Properties(VkPhysicalDevice phys_dev);
VkPhysicalDeviceVulkanSC10Features GetVulkanSC10Features() const {
auto sc_10_features = vku::InitStruct<VkPhysicalDeviceVulkanSC10Features>();
auto features2 = vku::InitStruct<VkPhysicalDeviceFeatures2>(&sc_10_features);
vksc::GetPhysicalDeviceFeatures2(gpu(), &features2);
return sc_10_features;
}

VkPhysicalDeviceVulkanSC10Properties GetVulkanSC10Properties() const {
auto sc_10_props = vku::InitStruct<VkPhysicalDeviceVulkanSC10Properties>();
auto props2 = vku::InitStruct<VkPhysicalDeviceProperties2>(&sc_10_props);
vksc::GetPhysicalDeviceProperties2(gpu(), &props2);
return sc_10_props;
}

VkPhysicalDeviceFeatures GetVulkanFeatures() const {
VkPhysicalDeviceFeatures features;
vksc::GetPhysicalDeviceFeatures(gpu(), &features);
return features;
}

VkPhysicalDeviceProperties GetVulkanProperties() const {
VkPhysicalDeviceProperties props;
vksc::GetPhysicalDeviceProperties(gpu(), &props);
return props;
}

template <typename T>
T GetVulkanFeatures() const {
T GetFeatures() const {
auto features = vku::InitStruct<T>();
auto features2 = vku::InitStruct<VkPhysicalDeviceFeatures2>(&features);
vksc::GetPhysicalDeviceFeatures2(gpu(), &features2);
return features;
}

template <typename T>
T GetVulkanProperties() const {
T GetProperties() const {
auto props = vku::InitStruct<T>();
auto props2 = vku::InitStruct<VkPhysicalDeviceProperties2>(&props);
vksc::GetPhysicalDeviceProperties2(gpu(), &props2);
Expand All @@ -54,9 +78,12 @@ class VkSCRenderFramework : public VkRenderFramework {
return &pipeline_cache_builders_.back();
}

VkDeviceObjectReservationCreateInfo &ObjectReservation() { return object_reservation_info_; }

private:
VkPipelineCache default_pipeline_cache_{VK_NULL_HANDLE};
std::vector<vksc::PipelineCacheBuilder> pipeline_cache_builders_;
std::vector<vksc::PipelineCacheBuilder> pipeline_cache_builders_{};
VkDeviceObjectReservationCreateInfo object_reservation_info_;
};

// Render framework used by compatible Vulkan tests
Expand Down
4 changes: 2 additions & 2 deletions tests/vulkansc/framework/vksc_test_dispatch_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ static VkSCCompatibilityRenderFramework& RenderFramework() { return VkSCCompatib

template <typename T>
static T Features() {
return RenderFramework().GetVulkanFeatures<T>();
return RenderFramework().GetFeatures<T>();
}

template <typename T>
static T Props() {
return RenderFramework().GetVulkanProperties<T>();
return RenderFramework().GetProperties<T>();
}

static const char* GetCompatibilityProcName(const char* pName) {
Expand Down
28 changes: 14 additions & 14 deletions tests/vulkansc/negative/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "../framework/vksc_layer_validation_tests.h"

TEST_F(VkSCLayerTest, CreateCommandPoolMissingMemoryReservationInfo) {
TEST_F(VkSCNegativeCommand, CreateCommandPoolMissingMemoryReservationInfo) {
TEST_DESCRIPTION("vkCreateCommandPool - missing VkCommandPoolMemoryReservationCreateInfo");

RETURN_IF_SKIP(Init());
Expand All @@ -24,7 +24,7 @@ TEST_F(VkSCLayerTest, CreateCommandPoolMissingMemoryReservationInfo) {
m_errorMonitor->VerifyFound();
}

TEST_F(VkSCLayerTest, CreateCommandPoolInvalidReservedSize) {
TEST_F(VkSCNegativeCommand, CreateCommandPoolInvalidReservedSize) {
TEST_DESCRIPTION("vkCreateCommandPool - commandPoolReservedSize is zero");

RETURN_IF_SKIP(Init());
Expand All @@ -41,7 +41,7 @@ TEST_F(VkSCLayerTest, CreateCommandPoolInvalidReservedSize) {
m_errorMonitor->VerifyFound();
}

TEST_F(VkSCLayerTest, CreateCommandPoolInvalidMaxCommandBuffers) {
TEST_F(VkSCNegativeCommand, CreateCommandPoolInvalidMaxCommandBuffers) {
TEST_DESCRIPTION("vkCreateCommandPool - commandPoolMaxCommandBuffers is zero or greater than maxCommandPoolCommandBuffers");

RETURN_IF_SKIP(Init());
Expand All @@ -62,12 +62,12 @@ TEST_F(VkSCLayerTest, CreateCommandPoolInvalidMaxCommandBuffers) {
m_errorMonitor->SetAllowedFailureMsg("VUID-VkCommandPoolMemoryReservationCreateInfo-commandPoolMaxCommandBuffers-05074");
m_errorMonitor->SetDesiredFailureMsg(kErrorBit,
"VUID-VkCommandPoolMemoryReservationCreateInfo-commandPoolMaxCommandBuffers-05090");
mem_reservation_info.commandPoolMaxCommandBuffers = GetVulkanSC10Properties(gpu()).maxCommandPoolCommandBuffers + 1;
mem_reservation_info.commandPoolMaxCommandBuffers = GetVulkanSC10Properties().maxCommandPoolCommandBuffers + 1;
vksc::CreateCommandPool(m_device->device(), &create_info, nullptr, &cmd_pool);
m_errorMonitor->VerifyFound();
}

TEST_F(VkSCLayerTest, AllocateCommandBuffersExceededMaxCommandBuffers) {
TEST_F(VkSCNegativeCommand, AllocateCommandBuffersExceededMaxCommandBuffers) {
TEST_DESCRIPTION("vkAllocateCommandBuffers - cannot allocate more command buffers from pool than commandPoolMaxCommandBuffers");

RETURN_IF_SKIP(Init());
Expand Down Expand Up @@ -128,12 +128,12 @@ TEST_F(VkSCLayerTest, AllocateCommandBuffersExceededMaxCommandBuffers) {
}
}

TEST_F(VkSCLayerTest, ResetCommandBufferNotSupported) {
TEST_F(VkSCNegativeCommand, ResetCommandBufferNotSupported) {
TEST_DESCRIPTION("vkReset/BeginCommandBuffer - commandPoolResetCommandBuffer not supported");

RETURN_IF_SKIP(Init());

if (GetVulkanSC10Properties(gpu()).commandPoolResetCommandBuffer) {
if (GetVulkanSC10Properties().commandPoolResetCommandBuffer) {
GTEST_SKIP() << "Only applicable if commandPoolResetCommandBuffer is not supported";
}

Expand Down Expand Up @@ -162,12 +162,12 @@ TEST_F(VkSCLayerTest, ResetCommandBufferNotSupported) {
m_errorMonitor->VerifyFound();
}

TEST_F(VkSCLayerTest, CommandPoolMultipleRecordingNotSupported) {
TEST_F(VkSCNegativeCommand, CommandPoolMultipleRecordingNotSupported) {
TEST_DESCRIPTION("vkBeginCommandBuffer - commandPoolMultipleCommandBuffersRecording not supported");

RETURN_IF_SKIP(Init());

if (GetVulkanSC10Properties(gpu()).commandPoolMultipleCommandBuffersRecording) {
if (GetVulkanSC10Properties().commandPoolMultipleCommandBuffersRecording) {
GTEST_SKIP() << "Only applicable if commandPoolMultipleCommandBuffersRecording is not supported";
}

Expand Down Expand Up @@ -201,12 +201,12 @@ TEST_F(VkSCLayerTest, CommandPoolMultipleRecordingNotSupported) {
cb_other_pool.end();
}

TEST_F(VkSCLayerTest, SimulatenousUseNotSupported) {
TEST_F(VkSCNegativeCommand, SimulatenousUseNotSupported) {
TEST_DESCRIPTION("vkBeginCommandBuffer - commandBufferSimultaneousUse not supported");

RETURN_IF_SKIP(Init());

if (GetVulkanSC10Properties(gpu()).commandBufferSimultaneousUse) {
if (GetVulkanSC10Properties().commandBufferSimultaneousUse) {
GTEST_SKIP() << "Only applicable if commandBufferSimultaneousUse is not supported";
}

Expand All @@ -230,7 +230,7 @@ TEST_F(VkSCLayerTest, SimulatenousUseNotSupported) {
m_errorMonitor->VerifyFound();
}

TEST_F(VkSCLayerTest, SecondaryCommandBufferNullOrImagelessFramebuffer) {
TEST_F(VkSCNegativeCommand, SecondaryCommandBufferNullOrImagelessFramebuffer) {
TEST_DESCRIPTION("vkBeginCommandBuffer - test effects of secondaryCommandBufferNullOrImagelessFramebuffer");

RETURN_IF_SKIP(InitFramework());
Expand Down Expand Up @@ -313,7 +313,7 @@ TEST_F(VkSCLayerTest, SecondaryCommandBufferNullOrImagelessFramebuffer) {
begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
begin_info.pInheritanceInfo = &inherit_info;

const char *expected_vuid = GetVulkanSC10Properties(gpu()).secondaryCommandBufferNullOrImagelessFramebuffer
const char *expected_vuid = GetVulkanSC10Properties().secondaryCommandBufferNullOrImagelessFramebuffer
? "VUID-VkCommandBufferBeginInfo-flags-05009"
: "VUID-VkCommandBufferBeginInfo-flags-05010";

Expand All @@ -322,7 +322,7 @@ TEST_F(VkSCLayerTest, SecondaryCommandBufferNullOrImagelessFramebuffer) {
vksc::BeginCommandBuffer(cmd_buffer.handle(), &begin_info);
m_errorMonitor->VerifyFound();

if (!GetVulkanSC10Properties(gpu()).secondaryCommandBufferNullOrImagelessFramebuffer) {
if (!GetVulkanSC10Properties().secondaryCommandBufferNullOrImagelessFramebuffer) {
// Check with no framebuffer
inherit_info.framebuffer = VK_NULL_HANDLE;

Expand Down
Loading

0 comments on commit bdee7fb

Please sign in to comment.