KhronosGroup / KhronosGroup/Vulkan-ValidationLayers

Handle multiple array of BDA structs with runtime arrays inside them

Open
#12,629 2 comments 0 reactions 1 assignee Claimed by @spencer-lunarg View on GitHub
GPU-AV
Dominant language
C++
Stars
1k
Forks
504
Avg merge
11h 35m
Merged PRs (30d)
224

Description

`dEQP-VK.ssbo.phys.layout.random.all_per_block_buffers.45`

```
TEST_F(PositiveGpuAVBufferDeviceAddress, Test) {
RETURN_IF_SKIP(InitGpuVUBufferDeviceAddress(false));

const char* shader_source = R"glsl(#version 450
#extension GL_EXT_shader_16bit_storage : enable
#extension GL_EXT_shader_8bit_storage : enable
#extension GL_EXT_scalar_block_layout : enable
#extension GL_EXT_buffer_reference : enable
#extension GL_EXT_nonuniform_qualifier : enable
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : enable
#extension GL_EXT_shader_64bit_indexing : enable
layout(local_size_x = 1) in;

layout(std140, binding = 0) buffer AcBlock { highp uint ac_numPassed; };

struct sA
{
lowp vec2 mA;
highp vec3 mB;
highp float mC;
mediump mat3 mD;
};
struct sB
{
mediump uvec3 mA;
mediump mat2x3 mB;
bool mC;
};
layout(std140, buffer_reference) buffer BlockB
{
sA a;
mediump mat3 b;
mediump mat2 c;
bvec2 d;
highp mat3 e[];
};
layout(std140, column_major, buffer_reference) readonly buffer BlockC
{
bool f[];
};
layout(std140, row_major, buffer_reference) buffer BlockD
{
mediump ivec2 g;
sB h[1];
highp mat4 i;
highp ivec3 j[];
};
layout (push_constant, std430) uniform PC {
BlockB blockB[3];
BlockC blockC;
BlockD blockD;
};

bool compare_float (highp float a, highp float b) { return abs(a - b) < 0.05; }
bool compare_vec2 (highp vec2 a, highp vec2 b) { return compare_float(a.x, b.x)&&compare_float(a.y, b.y); }
bool compare_vec3 (highp vec3 a, highp vec3 b) { return compare_float(a.x, b.x)&&compare_float(a.y, b.y)&&compare_float(a.z, b.z); }
bool compare_vec4 (highp vec4 a, highp vec4 b) { return compare_float(a.x, b.x)&&compare_float(a.y, b.y)&&compare_float(a.z, b.z)&&compare_float(a.w, b.w); }
bool compare_mat2 (highp mat2 a, highp mat2 b) { return compare_vec2(a[0], b[0])&&compare_vec2(a[1], b[1]); }
bool compare_mat2x3 (highp mat2x3 a, highp mat2x3 b){ return compare_vec3(a[0], b[0])&&compare_vec3(a[1], b[1]); }
bool compare_mat3 (highp mat3 a, highp mat3 b) { return compare_vec3(a[0], b[0])&&compare_vec3(a[1], b[1])&&compare_vec3(a[2], b[2]); }
bool compare_mat4 (highp mat4 a, highp mat4 b) { return compare_vec4(a[0], b[0])&&compare_vec4(a[1], b[1])&&compare_vec4(a[2], b[2])&&compare_vec4(a[3], b[3]); }
bool compare_ivec2 (highp ivec2 a, highp ivec2 b) { return a == b; }
bool compare_ivec3 (highp ivec3 a, highp ivec3 b) { return a == b; }
bool compare_uvec3 (highp uvec3 a, highp uvec3 b) { return a == b; }
bool compare_bool (bool a, bool b) { return a == b; }
bool compare_bvec2 (bvec2 a, bvec2 b) { return a == b; }

void main (void)
{
bool allOk = true;
allOk = compare_vec2((blockB[0].a.mA), vec2(0.0, 7.0)) && allOk;
allOk = compare_vec3((blockB[0].a.mB), vec3(4.0, -8.0, -2.0)) && allOk;
allOk = compare_float((blockB[0].a.mC), -7.0) && allOk;
allOk = compare_mat3(blockB[0].a.mD, mat3(1.0, 0.0, 5.0, 7.0, -2.0, -5.0, -1.0, -9.0, -3.0)) && allOk;
allOk = compare_mat2(blockB[0].c, mat2(0.0, 9.0, 1.0, -3.0)) && allOk;
allOk = compare_bvec2((blockB[0].d), bvec2(true, false)) && allOk;
allOk = compare_mat3(blockB[0].e[0u], mat3(9.0, 3.0, 1.0, -2.0, 9.0, 6.0, -3.0, 8.0, -9.0)) && allOk;
allOk = compare_mat3(blockB[0].e[1u], mat3(6.0, -3.0, -6.0, -4.0, 2.0, -7.0, 7.0, 4.0, -3.0)) && allOk;
allOk = compare_mat3(blockB[0].e[2u], mat3(6.0, -3.0, -3.0, 9.0, 3.0, 2.0, -8.0, -7.0, -6.0)) && allOk;
allOk = compare_vec2((blockB[1].a.mA), vec2(-6.0, -3.0)) && allOk;
allOk = compare_vec3((blockB[1].a.mB), vec3(4.0, -2.0, -6.0)) && allOk;
allOk = compare_float((blockB[1].a.mC), -8.0) && allOk;
allOk = compare_mat3(blockB[1].a.mD, mat3(-6.0, -2.0, 2.0, -1.0, 8.0, -8.0, -2.0, -7.0, -1.0)) && allOk;
allOk = compare_mat2(blockB[1].c, mat2(-5.0, 5.0, 9.0, -8.0)) && allOk;
allOk = compare_bvec2((blockB[1].d), bvec2(true, false)) && allOk;
allOk = compare_mat3(blockB[1].e[0u], mat3(-2.0, 9.0, 3.0, -3.0, -8.0, -5.0, -1.0, 4.0, -8.0)) && allOk;
allOk = compare_mat3(blockB[1].e[1u], mat3(-4.0, 2.0, -8.0, 2.0, -3.0, 1.0, 2.0, 9.0, 0.0)) && allOk;
allOk = compare_mat3(blockB[1].e[2u], mat3(-2.0, 9.0, 2.0, 4.0, 8.0, -8.0, 3.0, -8.0, -7.0)) && allOk;
allOk = compare_vec2((blockB[2].a.mA), vec2(3.0, -3.0)) && allOk;
allOk = compare_vec3((blockB[2].a.mB), vec3(3.0, -6.0, -4.0)) && allOk;
allOk = compare_float((blockB[2].a.mC), -8.0) && allOk;
allOk = compare_mat3(blockB[2].a.mD, mat3(-7.0, 6.0, -5.0, 9.0, 6.0, 4.0, -4.0, 0.0, 2.0)) && allOk;
allOk = compare_mat2(blockB[2].c, mat2(4.0, 3.0, 1.0, -3.0)) && allOk;
allOk = compare_bvec2((blockB[2].d), bvec2(true, true)) && allOk;
allOk = compare_mat3(blockB[2].e[0u], mat3(-1.0, -8.0, 5.0, 7.0, 6.0, 6.0, 6.0, -5.0, 7.0)) && allOk;
allOk = compare_mat3(blockB[2].e[1u], mat3(-5.0, 0.0, 1.0, -8.0, 9.0, 4.0, 8.0, 9.0, 8.0)) && allOk;
allOk = compare_mat3(blockB[2].e[2u], mat3(4.0, 5.0, -9.0, -7.0, -2.0, 0.0, 8.0, -4.0, 9.0)) && allOk;
allOk = compare_mat3(blockB[2].e[3u], mat3(1.0, 7.0, 7.0, 8.0, -6.0, 7.0, 8.0, 4.0, -5.0)) && allOk;
allOk = compare_mat3(blockB[2].e[4u], mat3(-6.0, 0.0, -7.0, 9.0, 6.0, -1.0, 8.0, -2.0, -3.0)) && allOk;
allOk = compare_ivec2((blockD.g), ivec2(3, -7)) && allOk;
if (allOk)
ac_numPassed++;

blockB[0].a.mA = (vec2(6.0, -8.0));
blockB[0].a.mB = (vec3(-5.0, -5.0, 8.0));
blockB[0].a.mC = (-6.0);
blockB[0].a.mD = (mat3(-1.0, -8.0, -8.0, -6.0, 1.0, -2.0, 4.0, 9.0, -9.0));
blockB[0].b = (mat3(-5.0, 8.0, 3.0, -1.0, 7.0, -2.0, -7.0, -4.0, -2.0));
blockB[0].c = (mat2(0.0, -2.0, -6.0, 1.0));
blockB[0].d = (bvec2(false, true));
blockB[0].e[0u] = (mat3(-5.0, -8.0, -3.0, -5.0, 0.0, -9.0, -5.0, -5.0, 3.0));
blockB[0].e[1u] = (mat3(8.0, 3.0, 1.0, 2.0, -5.0, 2.0, 9.0, 3.0, -6.0));
blockB[0].e[2u] = (mat3(-6.0, -8.0, 5.0, -8.0, 4.0, -1.0, -9.0, -7.0, 3.0));
blockB[1].a.mA = (vec2(7.0, -2.0));
blockB[1].a.mB = (vec3(-8.0, 9.0, 0.0));
blockB[1].a.mC = (-8.0);
blockB[1].a.mD = (mat3(-2.0, -5.0, -7.0, 8.0, 0.0, 8.0, 6.0, 1.0, 1.0));
blockB[1].b = (mat3(9.0, 8.0, 4.0, 3.0, 8.0, -2.0, -2.0, -9.0, -8.0));
blockB[1].c = (mat2(5.0, 0.0, -9.0, 5.0));
blockB[1].d = (bvec2(false, true));
blockB[1].e[0u] = (mat3(7.0, 7.0, 9.0, -4.0, 7.0, 9.0, 7.0, 7.0, 5.0));
blockB[1].e[1u] = (mat3(2.0, -7.0, 8.0, 4.0, -2.0, -4.0, 1.0, 7.0, -2.0));
blockB[1].e[2u] = (mat3(0.0, 5.0, -7.0, 4.0, -1.0, 7.0, -5.0, -9.0, 3.0));
blockB[2].a.mA = (vec2(9.0, -1.0));
blockB[2].a.mB = (vec3(-6.0, 2.0, 9.0));
blockB[2].a.mC = (-5.0);
blockB[2].a.mD = (mat3(6.0, 0.0, -3.0, 2.0, -7.0, 9.0, -8.0, 3.0, -1.0));
blockB[2].b = (mat3(-4.0, -2.0, -8.0, 0.0, -1.0, -6.0, -8.0, -9.0, 0.0));
blockB[2].c = (mat2(-4.0, 9.0, 6.0, -2.0));
blockB[2].d = (bvec2(false, true));
blockB[2].e[0u] = (mat3(5.0, 0.0, -3.0, -1.0, 0.0, -5.0, 3.0, -2.0, -9.0));
blockB[2].e[1u] = (mat3(2.0, -4.0, 4.0, -1.0, 6.0, -2.0, 2.0, 4.0, 5.0));
blockB[2].e[2u] = (mat3(5.0, 6.0, -1.0, 2.0, 3.0, 9.0, 1.0, -1.0, 2.0));
blockB[2].e[3u] = (mat3(4.0, 3.0, 9.0, 8.0, 9.0, 4.0, -4.0, -8.0, 4.0));
blockB[2].e[4u] = (mat3(1.0, 5.0, -4.0, -8.0, 7.0, -6.0, 7.0, 6.0, 4.0));
blockD.i = (mat4(3.0, 5.0, -4.0, 6.0, -9.0, -5.0, 9.0, 0.0, -4.0, 4.0, -2.0, -4.0, 3.0, -4.0, -2.0, -8.0));
}
)glsl";

const VkDescriptorSetLayoutBinding binding = {0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_COMPUTE_BIT, nullptr};
OneOffDescriptorSet descriptor_set(m_device, {binding});
VkPushConstantRange push_range;
push_range.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
push_range.offset = 0u;
push_range.size = sizeof(VkDeviceAddress) * 5u;
const vkt::PipelineLayout pipeline_layout(*m_device, {&descriptor_set.layout_}, {push_range});

CreateComputePipelineHelper pipe(*this);
pipe.cp_ci_.layout = pipeline_layout;
pipe.cs_ = VkShaderObj(*m_device, shader_source, VK_SHADER_STAGE_COMPUTE_BIT, SPV_ENV_VULKAN_1_2);
pipe.CreateComputePipeline();

vkt::Buffer counter_buffer(*m_device, 16u, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, kHostVisibleMemProps);
VkBufferUsageFlags usage = VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT;
vkt::Buffer block_b0(*m_device, 320u, usage, vkt::device_address);
vkt::Buffer block_b1(*m_device, 320u, usage, vkt::device_address);
vkt::Buffer block_b2(*m_device, 416u, usage, vkt::device_address);
vkt::Buffer block_c(*m_device, 16u, usage, vkt::device_address);
vkt::Buffer block_d(*m_device, 160u, usage, vkt::device_address);

descriptor_set.WriteDescriptorBufferInfo(0, counter_buffer, 0u, 16u, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
descriptor_set.UpdateDescriptorSets();

VkDeviceAddress push_constants[5] = {
block_b0.Address(), block_b1.Address(), block_b2.Address(), block_c.Address(), block_d.Address(),
};

m_command_buffer.Begin();
vk::CmdPushConstants(m_command_buffer, pipeline_layout, VK_SHADER_STAGE_COMPUTE_BIT, 0u, push_range.size,
push_constants);
vk::CmdBindPipeline(m_command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipe);
vk::CmdBindDescriptorSets(m_command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline_layout, 0u, 1u, &descriptor_set.set_, 0u,
nullptr);
vk::CmdDispatch(m_command_buffer, 1u, 1u, 1u);
m_command_buffer.End();

m_default_queue->SubmitAndWait(m_command_buffer);
}
```

```
> gpuav::LogInstrumentationError(gpuav::Validator & gpuav, VkCommandBuffer_T * const cb_handle, const LogObjectList & objlist, const gpuav::CommonInstrumentationErrorInfo & error_info, const unsigned int * error_record, const Location & loc_with_debug_region, const std::vector,std::allocator>> & error_loggers) Line 426 C++
gpuav::PreCallSetupShaderInstrumentationResources::__l39::(const unsigned int * error_record, const Location & loc_with_debug_region, const LogObjectList & objlist) Line 677 C++
stdext::inplace_function_detail::vtable::{ctor}::__l1::::operator()(void * storage_ptr, const unsigned int * && , const Location & , const LogObjectList & ) Line 83 C++
[External Code]
stdext::inplace_function::operator()(const unsigned int * , const Location & , const LogObjectList & ) Line 248 C++
gpuav::CommandBufferSubState::OnCompletion(VkQueue_T * queue, const std::vector> & initial_label_stack, const Location & loc) Line 384 C++
gpuav::QueueSubState::Retire(vvl::QueueSubmission & submission) Line 597 C++
vvl::Queue::Retire(vvl::QueueSubmission & submission) Line 321 C++
vvl::Queue::ThreadFunc() Line 341 C++
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.