Skip to content

Commit

Permalink
tests: Fix fragmentStoresAndAtomics for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-lunarg committed Jun 18, 2024
1 parent 5f40c59 commit c43d88b
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 52 deletions.
8 changes: 3 additions & 5 deletions layers/state_tracker/shader_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1934,11 +1934,9 @@ bool ResourceInterfaceVariable::IsStorageBuffer(const ResourceInterfaceVariable&
const bool physical_storage_buffer = variable.storage_class == spv::StorageClassPhysicalStorageBuffer;
const bool storage_buffer = variable.storage_class == spv::StorageClassStorageBuffer;
const bool uniform = variable.storage_class == spv::StorageClassUniform;
const bool buffer_block =
(variable.decorations.Has(DecorationSet::buffer_block_bit) ||
(variable.type_struct_info && variable.type_struct_info->decorations.Has(DecorationSet::buffer_block_bit)));
const bool block = (variable.decorations.Has(DecorationSet::block_bit) ||
(variable.type_struct_info && variable.type_struct_info->decorations.Has(DecorationSet::block_bit)));
// Block decorations are always on the struct of the variable
const bool buffer_block = variable.type_struct_info && variable.type_struct_info->decorations.Has(DecorationSet::buffer_block_bit);
const bool block = variable.type_struct_info && variable.type_struct_info->decorations.Has(DecorationSet::block_bit);
return ((uniform && buffer_block) || ((storage_buffer || physical_storage_buffer) && block));
}

Expand Down
2 changes: 2 additions & 0 deletions tests/unit/descriptor_indexing_positive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ TEST_F(PositiveDescriptorIndexing, UpdateAfterBind) {
AddRequiredExtensions(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME);
AddRequiredExtensions(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
AddRequiredFeature(vkt::Feature::descriptorBindingStorageBufferUpdateAfterBind);
AddRequiredFeature(vkt::Feature::fragmentStoresAndAtomics);
AddRequiredFeature(vkt::Feature::synchronization2);
RETURN_IF_SKIP(Init());
InitRenderTarget();
Expand Down Expand Up @@ -235,6 +236,7 @@ TEST_F(PositiveDescriptorIndexing, PartiallyBoundDescriptors) {
AddRequiredExtensions(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME);
AddRequiredExtensions(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
AddRequiredFeature(vkt::Feature::descriptorBindingStorageBufferUpdateAfterBind);
AddRequiredFeature(vkt::Feature::fragmentStoresAndAtomics);
AddRequiredFeature(vkt::Feature::synchronization2);
RETURN_IF_SKIP(Init());
InitRenderTarget();
Expand Down
1 change: 1 addition & 0 deletions tests/unit/descriptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3580,6 +3580,7 @@ TEST_F(NegativeDescriptors, MutableDescriptorSetLayoutMissingFeature) {
TEST_F(NegativeDescriptors, ImageSubresourceOverlapBetweenRenderPassAndDescriptorSets) {
TEST_DESCRIPTION("Validate if attachments in render pass and descriptor set use the same image subresources");
AddRequiredFeature(vkt::Feature::shaderStorageImageWriteWithoutFormat);
AddRequiredFeature(vkt::Feature::fragmentStoresAndAtomics);
RETURN_IF_SKIP(Init());
InitRenderTarget();

Expand Down
16 changes: 4 additions & 12 deletions tests/unit/protected_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,22 +670,13 @@ TEST_F(NegativeProtectedMemory, MixingProtectedResources) {

SetTargetApiVersion(VK_API_VERSION_1_1);
AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);

RETURN_IF_SKIP(InitFramework());

VkPhysicalDeviceProtectedMemoryFeatures protected_memory_features = vku::InitStructHelper();
auto features2 = GetPhysicalDeviceFeatures2(protected_memory_features);

if (protected_memory_features.protectedMemory == VK_FALSE) {
GTEST_SKIP() << "protectedMemory feature not supported";
};
AddRequiredFeature(vkt::Feature::fragmentStoresAndAtomics);
AddRequiredFeature(vkt::Feature::protectedMemory);
RETURN_IF_SKIP(Init());

VkPhysicalDeviceProtectedMemoryProperties protected_memory_properties = vku::InitStructHelper();
GetPhysicalDeviceProperties2(protected_memory_properties);

// Turns m_commandBuffer into a unprotected command buffer without passing in a VkCommandPoolCreateFlags
RETURN_IF_SKIP(InitState(nullptr, &features2));

vkt::CommandPool protectedCommandPool(*m_device, m_device->graphics_queue_node_index_, VK_COMMAND_POOL_CREATE_PROTECTED_BIT);
vkt::CommandBuffer protectedCommandBuffer(*m_device, protectedCommandPool);

Expand Down Expand Up @@ -1192,6 +1183,7 @@ TEST_F(NegativeProtectedMemory, WriteToProtectedStorageBuffer) {
AddRequiredExtensions(VK_EXT_DESCRIPTOR_BUFFER_EXTENSION_NAME);
AddRequiredFeature(vkt::Feature::descriptorBuffer);
AddRequiredFeature(vkt::Feature::protectedMemory);
AddRequiredFeature(vkt::Feature::fragmentStoresAndAtomics);
RETURN_IF_SKIP(InitFramework());
RETURN_IF_SKIP(InitState(nullptr, nullptr, VK_COMMAND_POOL_CREATE_PROTECTED_BIT));
InitRenderTarget();
Expand Down
78 changes: 49 additions & 29 deletions tests/unit/shader_interface_positive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,12 +537,9 @@ TEST_F(PositiveShaderInterface, InputAttachmentMissingNotRead) {

TEST_F(PositiveShaderInterface, InputAttachmentArray) {
TEST_DESCRIPTION("Input Attachment array where need to follow the index into the array");

SetTargetApiVersion(VK_API_VERSION_1_2);
RETURN_IF_SKIP(InitFramework());
VkPhysicalDeviceVulkan12Features features12 = vku::InitStructHelper();
GetPhysicalDeviceFeatures2(features12);
RETURN_IF_SKIP(InitState(nullptr, &features12));
AddRequiredFeature(vkt::Feature::fragmentStoresAndAtomics);
RETURN_IF_SKIP(Init());

RenderPassSingleSubpass rp(*this);
rp.AddAttachmentDescription(m_render_target_fmt);
Expand Down Expand Up @@ -600,30 +597,6 @@ TEST_F(PositiveShaderInterface, InputAttachmentArray) {
CreatePipelineHelper::OneshotTest(*this, set_info, kErrorBit);
}

// use OpTypeRuntimeArray and index into it
// This is something that is needed to be validated at draw time, so should not be an error
if (features12.runtimeDescriptorArray && features12.shaderInputAttachmentArrayNonUniformIndexing) {
const char *fs_source = R"glsl(
#version 460
#extension GL_EXT_nonuniform_qualifier : require
layout(input_attachment_index=0, set=0, binding=0) uniform subpassInput xs[];
layout(set = 0, binding = 3) buffer ssbo { int rIndex; };
layout(location=0) out vec4 color;
void main() {
color = subpassLoad(xs[nonuniformEXT(rIndex)]);
}
)glsl";
VkShaderObj fs(this, fs_source, VK_SHADER_STAGE_FRAGMENT_BIT, SPV_ENV_VULKAN_1_0, SPV_SOURCE_GLSL);

const auto set_info = [&](CreatePipelineHelper &helper) {
helper.shader_stages_ = {helper.vs_->GetStageCreateInfo(), fs.GetStageCreateInfo()};
helper.dsl_bindings_ = {{0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 2, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr},
{3, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr}};
helper.gp_ci_.renderPass = rp.Handle();
};
CreatePipelineHelper::OneshotTest(*this, set_info, kErrorBit);
}

// Array of size 1
// loads from index 0, but not the invalid index 0 since has offest of 3
{
Expand Down Expand Up @@ -666,6 +639,53 @@ TEST_F(PositiveShaderInterface, InputAttachmentArray) {
}
}

TEST_F(PositiveShaderInterface, InputAttachmentRuntimeArray) {
TEST_DESCRIPTION("Input Attachment array where need to follow the index into the array");
SetTargetApiVersion(VK_API_VERSION_1_2);
AddRequiredFeature(vkt::Feature::fragmentStoresAndAtomics);
AddRequiredFeature(vkt::Feature::runtimeDescriptorArray);
AddRequiredFeature(vkt::Feature::shaderInputAttachmentArrayNonUniformIndexing);
RETURN_IF_SKIP(Init());

RenderPassSingleSubpass rp(*this);
rp.AddAttachmentDescription(m_render_target_fmt);
// index 0 is unused
rp.AddAttachmentReference({VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL});
// index 1 is is valid (for both color and input)
rp.AddAttachmentReference({0, VK_IMAGE_LAYOUT_GENERAL});
// index 2 and 3 point to same image as index 1
rp.AddAttachmentReference({0, VK_IMAGE_LAYOUT_GENERAL});
rp.AddAttachmentReference({0, VK_IMAGE_LAYOUT_GENERAL});
rp.AddInputAttachment(0);
rp.AddInputAttachment(1);
rp.AddInputAttachment(2);
rp.AddInputAttachment(3);
rp.AddColorAttachment(1);
rp.CreateRenderPass();

// use OpTypeRuntimeArray and index into it
// This is something that is needed to be validated at draw time, so should not be an error
const char *fs_source = R"glsl(
#version 460
#extension GL_EXT_nonuniform_qualifier : require
layout(input_attachment_index=0, set=0, binding=0) uniform subpassInput xs[];
layout(set = 0, binding = 3) buffer ssbo { int rIndex; };
layout(location=0) out vec4 color;
void main() {
color = subpassLoad(xs[nonuniformEXT(rIndex)]);
}
)glsl";
VkShaderObj fs(this, fs_source, VK_SHADER_STAGE_FRAGMENT_BIT, SPV_ENV_VULKAN_1_0, SPV_SOURCE_GLSL);

const auto set_info = [&](CreatePipelineHelper &helper) {
helper.shader_stages_ = {helper.vs_->GetStageCreateInfo(), fs.GetStageCreateInfo()};
helper.dsl_bindings_ = {{0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 2, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr},
{3, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr}};
helper.gp_ci_.renderPass = rp.Handle();
};
CreatePipelineHelper::OneshotTest(*this, set_info, kErrorBit);

}
TEST_F(PositiveShaderInterface, InputAttachmentDepthStencil) {
TEST_DESCRIPTION("Input Attachment sharing same variable, but different aspect");

Expand Down
1 change: 1 addition & 0 deletions tests/unit/shader_spirv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ TEST_F(NegativeShaderSpirv, SpirvStatelessMaintenance5) {
AddRequiredExtensions(VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME);
AddRequiredExtensions(VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_EXTENSION_NAME);
AddRequiredExtensions(VK_KHR_MAINTENANCE_5_EXTENSION_NAME);
AddRequiredFeature(vkt::Feature::vertexPipelineStoresAndAtomics);
AddRequiredFeature(vkt::Feature::maintenance5);
AddDisabledFeature(vkt::Feature::shaderInt16);
RETURN_IF_SKIP(Init());
Expand Down
9 changes: 3 additions & 6 deletions tests/unit/sync_val_positive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,13 +492,10 @@ TEST_F(PositiveSyncVal, LayoutTransitionWithAlreadyAvailableImage) {
TEST_F(PositiveSyncVal, ImageArrayDynamicIndexing) {
TEST_DESCRIPTION("Access different elements of the image array using dynamic indexing. There should be no hazards");
SetTargetApiVersion(VK_API_VERSION_1_2);
AddRequiredFeature(vkt::Feature::runtimeDescriptorArray);
AddRequiredFeature(vkt::Feature::fragmentStoresAndAtomics);
RETURN_IF_SKIP(InitSyncValFramework());
VkPhysicalDeviceVulkan12Features features12 = vku::InitStructHelper();
GetPhysicalDeviceFeatures2(features12);
if (features12.runtimeDescriptorArray != VK_TRUE) {
GTEST_SKIP() << "runtimeDescriptorArray not supported and is required";
}
RETURN_IF_SKIP(InitState(nullptr, &features12));
RETURN_IF_SKIP(InitState());
InitRenderTarget();

constexpr VkDescriptorType descriptor_type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
Expand Down

0 comments on commit c43d88b

Please sign in to comment.