Skip to content

Commit

Permalink
tests: Buffer views atomics with mismatched formats
Browse files Browse the repository at this point in the history
  • Loading branch information
ziga-lunarg committed Feb 24, 2025
1 parent aab9e95 commit f2b1e31
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions tests/unit/atomics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1513,3 +1513,96 @@ TEST_F(NegativeAtomic, VertexPipelineStoresAndAtomics) {
pipe.CreateGraphicsPipeline();
m_errorMonitor->VerifyFound();
}

TEST_F(NegativeAtomic, BufferViewInt64Drawtime32) {
SetTargetApiVersion(VK_API_VERSION_1_1);
AddRequiredExtensions(VK_EXT_SHADER_IMAGE_ATOMIC_INT64_EXTENSION_NAME);
AddRequiredFeature(vkt::Feature::shaderInt64);
AddRequiredFeature(vkt::Feature::shaderImageInt64Atomics);
RETURN_IF_SKIP(Init());

const VkFormat format = VK_FORMAT_R64_UINT;
VkFormatProperties format_properties;
vk::GetPhysicalDeviceFormatProperties(Gpu(), format, &format_properties);
if (!(format_properties.bufferFeatures & VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT)) {
GTEST_SKIP() << "Test requires support for VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT";
}

std::string cs_source = R"glsl(
#version 450
#extension GL_KHR_memory_scope_semantics : enable
layout(set = 0, binding = 0, r32ui) uniform uimageBuffer z;
void main() {
uint y = imageAtomicLoad(z, 1, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
}
)glsl";

CreateComputePipelineHelper pipe(*this);
pipe.cs_ = std::make_unique<VkShaderObj>(this, cs_source.c_str(), VK_SHADER_STAGE_COMPUTE_BIT, SPV_ENV_VULKAN_1_1);
pipe.dsl_bindings_[0] = {0, VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 1, VK_SHADER_STAGE_ALL, nullptr};
pipe.CreateComputePipeline();

vkt::Buffer buffer(*m_device, 256, VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT);
vkt::BufferView view(*m_device, buffer, format);

pipe.descriptor_set_->WriteDescriptorBufferView(0, view);
pipe.descriptor_set_->UpdateDescriptorSets();

m_command_buffer.Begin();
vk::CmdBindPipeline(m_command_buffer.handle(), VK_PIPELINE_BIND_POINT_COMPUTE, pipe.Handle());
vk::CmdBindDescriptorSets(m_command_buffer.handle(), VK_PIPELINE_BIND_POINT_COMPUTE, pipe.pipeline_layout_.handle(), 0, 1,
&pipe.descriptor_set_->set_, 0, nullptr);

m_errorMonitor->SetDesiredError("VUID-vkCmdDispatch-SampledType-04472");
vk::CmdDispatch(m_command_buffer.handle(), 1, 1, 1);
m_errorMonitor->VerifyFound();
m_command_buffer.End();
}

TEST_F(NegativeAtomic, BufferViewInt64Drawtime64) {
TEST_DESCRIPTION("Test VK_EXT_shader_image_atomic_int64 draw time with 64 bit image view.");
SetTargetApiVersion(VK_API_VERSION_1_1);
AddRequiredExtensions(VK_EXT_SHADER_IMAGE_ATOMIC_INT64_EXTENSION_NAME);
AddRequiredFeature(vkt::Feature::shaderInt64);
AddRequiredFeature(vkt::Feature::shaderImageInt64Atomics);
RETURN_IF_SKIP(Init());

const VkFormat format = VK_FORMAT_R32_UINT;
VkFormatProperties format_properties;
vk::GetPhysicalDeviceFormatProperties(Gpu(), format, &format_properties);
if (!(format_properties.bufferFeatures & VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT)) {
GTEST_SKIP() << "Test requires support for VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT";
}

std::string cs_source = R"glsl(
#version 450
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : enable
#extension GL_EXT_shader_image_int64 : enable
#extension GL_KHR_memory_scope_semantics : enable
layout(set = 0, binding = 0, r64ui) uniform u64imageBuffer z;
void main() {
uint64_t y = imageAtomicLoad(z, 1, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
}
)glsl";

CreateComputePipelineHelper pipe(*this);
pipe.cs_ = std::make_unique<VkShaderObj>(this, cs_source.c_str(), VK_SHADER_STAGE_COMPUTE_BIT, SPV_ENV_VULKAN_1_1);
pipe.dsl_bindings_[0] = {0, VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 1, VK_SHADER_STAGE_ALL, nullptr};
pipe.CreateComputePipeline();

vkt::Buffer buffer(*m_device, 256, VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT);
vkt::BufferView view(*m_device, buffer, format);

pipe.descriptor_set_->WriteDescriptorBufferView(0, view, VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER);
pipe.descriptor_set_->UpdateDescriptorSets();

m_command_buffer.Begin();
vk::CmdBindPipeline(m_command_buffer.handle(), VK_PIPELINE_BIND_POINT_COMPUTE, pipe.Handle());
vk::CmdBindDescriptorSets(m_command_buffer.handle(), VK_PIPELINE_BIND_POINT_COMPUTE, pipe.pipeline_layout_.handle(), 0, 1,
&pipe.descriptor_set_->set_, 0, nullptr);

m_errorMonitor->SetDesiredError("VUID-vkCmdDispatch-SampledType-04473");
vk::CmdDispatch(m_command_buffer.handle(), 1, 1, 1);
m_errorMonitor->VerifyFound();
m_command_buffer.End();
}

0 comments on commit f2b1e31

Please sign in to comment.