Skip to content

Commit 3c6055b

Browse files
tests: Add extra Heap test
1 parent 37aa0f0 commit 3c6055b

1 file changed

Lines changed: 82 additions & 4 deletions

File tree

tests/unit/gpu_dump.cpp

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "descriptor_helper.h"
1616
#include "generated/vk_function_pointers.h"
1717
#include "pipeline_helper.h"
18+
#include "shader_templates.h"
1819
#include "utils/math_utils.h"
1920

2021
static const VkLayerSettingEXT kAllDumpSettings[3] = {
@@ -26,7 +27,7 @@ VkLayerSettingsCreateInfoEXT kAllDumpSettingCi = {VK_STRUCTURE_TYPE_LAYER_SETTIN
2627

2728
class NegativeGpuDump : public VkLayerTest {};
2829

29-
TEST_F(NegativeGpuDump, DumpDescriptors) {
30+
TEST_F(NegativeGpuDump, Descriptors) {
3031
SetTargetApiVersion(VK_API_VERSION_1_2);
3132
AddRequiredExtensions(VK_EXT_DESCRIPTOR_BUFFER_EXTENSION_NAME);
3233
AddRequiredExtensions(VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME);
@@ -86,7 +87,7 @@ TEST_F(NegativeGpuDump, DumpDescriptors) {
8687
m_command_buffer.End();
8788
}
8889

89-
TEST_F(NegativeGpuDump, DumpDescriptorBufferWithoutDescriptor) {
90+
TEST_F(NegativeGpuDump, DescriptorBufferWithoutDescriptor) {
9091
TEST_DESCRIPTION("https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/12250");
9192
SetTargetApiVersion(VK_API_VERSION_1_2);
9293
AddRequiredExtensions(VK_EXT_DESCRIPTOR_BUFFER_EXTENSION_NAME);
@@ -141,7 +142,7 @@ TEST_F(NegativeGpuDump, DumpDescriptorBufferWithoutDescriptor) {
141142
m_command_buffer.End();
142143
}
143144

144-
TEST_F(NegativeGpuDump, DumpDescriptorBufferWrongBindPoint) {
145+
TEST_F(NegativeGpuDump, DescriptorBufferWrongBindPoint) {
145146
SetTargetApiVersion(VK_API_VERSION_1_2);
146147
AddRequiredExtensions(VK_EXT_DESCRIPTOR_BUFFER_EXTENSION_NAME);
147148
AddRequiredExtensions(VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME);
@@ -195,7 +196,7 @@ TEST_F(NegativeGpuDump, DumpDescriptorBufferWrongBindPoint) {
195196
m_command_buffer.End();
196197
}
197198

198-
TEST_F(NegativeGpuDump, DumpCopyMemoryIndirect) {
199+
TEST_F(NegativeGpuDump, CopyMemoryIndirect) {
199200
AddRequiredExtensions(VK_KHR_COPY_MEMORY_INDIRECT_EXTENSION_NAME);
200201
AddRequiredFeature(vkt::Feature::indirectMemoryCopy);
201202
AddRequiredFeature(vkt::Feature::bufferDeviceAddress);
@@ -1067,3 +1068,80 @@ TEST_F(NegativeGpuDump, DescriptorHeapAlignmentHeapData) {
10671068

10681069
m_command_buffer.End();
10691070
}
1071+
1072+
TEST_F(NegativeGpuDump, DescriptorHeapWithoutDescriptor) {
1073+
SetTargetApiVersion(VK_API_VERSION_1_3);
1074+
AddRequiredExtensions(VK_EXT_DESCRIPTOR_HEAP_EXTENSION_NAME);
1075+
AddRequiredFeature(vkt::Feature::bufferDeviceAddress);
1076+
AddRequiredFeature(vkt::Feature::descriptorHeap);
1077+
AddRequiredFeature(vkt::Feature::runtimeDescriptorArray);
1078+
RETURN_IF_SKIP(InitFramework(&kAllDumpSettingCi));
1079+
RETURN_IF_SKIP(InitState());
1080+
InitRenderTarget();
1081+
1082+
VkPhysicalDeviceDescriptorHeapPropertiesEXT heap_props = vku::InitStructHelper();
1083+
GetPhysicalDeviceProperties2(heap_props);
1084+
1085+
// We want to easily control it for testing
1086+
if (heap_props.minResourceHeapReservedRange != 0) {
1087+
GTEST_SKIP() << "minResourceHeapReservedRange is not zero";
1088+
}
1089+
1090+
const VkDeviceSize resource_stride = heap_props.bufferDescriptorSize;
1091+
const VkDeviceSize heap_size = Align((resource_stride * 4), resource_stride);
1092+
vkt::Buffer descriptor_heap(*m_device, heap_size, VK_BUFFER_USAGE_2_DESCRIPTOR_HEAP_BIT_EXT, vkt::device_address);
1093+
1094+
const char* vs_source = R"glsl(
1095+
#version 450
1096+
layout(push_constant) uniform PushConstants {
1097+
vec4 x;
1098+
} pc;
1099+
1100+
void main() {
1101+
gl_Position = pc.x;
1102+
}
1103+
)glsl";
1104+
VkShaderObj vs(*m_device, vs_source, VK_SHADER_STAGE_VERTEX_BIT);
1105+
VkShaderObj fs(*m_device, kMinimalShaderGlsl, VK_SHADER_STAGE_FRAGMENT_BIT);
1106+
1107+
VkPipelineShaderStageCreateInfo stages[2];
1108+
stages[0] = vs.GetStageCreateInfo();
1109+
stages[1] = fs.GetStageCreateInfo();
1110+
1111+
VkPipelineCreateFlags2CreateInfoKHR pipeline_create_flags_2_create_info = vku::InitStructHelper();
1112+
pipeline_create_flags_2_create_info.flags = VK_PIPELINE_CREATE_2_DESCRIPTOR_HEAP_BIT_EXT;
1113+
1114+
CreatePipelineHelper pipe(*this, &pipeline_create_flags_2_create_info);
1115+
pipe.shader_stages_ = {vs.GetStageCreateInfo(), pipe.fs_->GetStageCreateInfo()};
1116+
pipe.gp_ci_.stageCount = 2u;
1117+
pipe.gp_ci_.pStages = stages;
1118+
pipe.gp_ci_.layout = VK_NULL_HANDLE;
1119+
pipe.CreateGraphicsPipeline(false);
1120+
1121+
m_command_buffer.Begin();
1122+
m_command_buffer.BeginRenderPass(m_renderPassBeginInfo);
1123+
1124+
float data[4] = {1.0, 2.0, 3.0, 4.0};
1125+
VkPushDataInfoEXT push_data_info = vku::InitStructHelper();
1126+
push_data_info.offset = 0;
1127+
push_data_info.data.size = 16;
1128+
push_data_info.data.address = data;
1129+
vk::CmdPushDataEXT(m_command_buffer, &push_data_info);
1130+
vk::CmdBindPipeline(m_command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipe);
1131+
1132+
m_errorMonitor->SetDesiredInfo("GPU-DUMP");
1133+
vk::CmdDraw(m_command_buffer, 3, 1, 0, 0);
1134+
m_errorMonitor->VerifyFound();
1135+
1136+
VkBindHeapInfoEXT bind_resource_info = vku::InitStructHelper();
1137+
bind_resource_info.heapRange = descriptor_heap.AddressRange();
1138+
bind_resource_info.reservedRangeOffset = 0;
1139+
bind_resource_info.reservedRangeSize = (uint32_t)resource_stride;
1140+
vk::CmdBindResourceHeapEXT(m_command_buffer, &bind_resource_info);
1141+
m_errorMonitor->SetDesiredInfo("GPU-DUMP");
1142+
vk::CmdDraw(m_command_buffer, 3, 1, 0, 0);
1143+
m_errorMonitor->VerifyFound();
1144+
1145+
m_command_buffer.EndRenderPass();
1146+
m_command_buffer.End();
1147+
}

0 commit comments

Comments
 (0)