1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
///////////////////////////////////////////////////////////////////////////////
// Copyright(c) 2019 Advanced Micro Devices, Inc.All rights reserved
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
/// \author AMD Developer Tools Team
/// \description gfxrecon_decode test main entry point
///////////////////////////////////////////////////////////////////////////////
#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>
#include "decode/vulkan_handle_mapping_util.h"
#include "decode/vulkan_object_info.h"
#include "decode/vulkan_object_info_table.h"
#include "format/format.h"
#include "format/format_util.h"
#include "vulkan/vulkan.h"
#include <vector>
const VkBuffer kBufferHandles[] = { gfxrecon::format::FromHandleId<VkBuffer>(0xabcd),
gfxrecon::format::FromHandleId<VkBuffer>(0xbcda),
gfxrecon::format::FromHandleId<VkBuffer>(0xcdab),
gfxrecon::format::FromHandleId<VkBuffer>(0xdabc) };
const gfxrecon::format::HandleId kBufferIds[] = { 12, 24, 48, 96 };
const gfxrecon::format::HandleId kDeviceId = 6;
TEST_CASE("handle IDs need to be mapped to valid handles", "[wrapper]")
{
gfxrecon::util::Log::Init(gfxrecon::util::Log::kErrorSeverity);
gfxrecon::decode::VulkanObjectInfoTable info_table;
// Basic add.
gfxrecon::decode::handle_mapping::AddHandle<gfxrecon::decode::BufferInfo>(
kDeviceId,
kBufferIds[0],
kBufferHandles[0],
&info_table,
&gfxrecon::decode::VulkanObjectInfoTable::AddBufferInfo);
SECTION("Add a total of four entries to the object table")
{
// Basic array add.
gfxrecon::decode::handle_mapping::AddHandleArray<gfxrecon::decode::BufferInfo>(
kDeviceId,
&kBufferIds[1],
1,
&kBufferHandles[1],
1,
&info_table,
&gfxrecon::decode::VulkanObjectInfoTable::AddBufferInfo);
// Array add with info and different ID/handle counts.
gfxrecon::decode::handle_mapping::AddHandleArray<gfxrecon::decode::BufferInfo>(
kDeviceId,
&kBufferIds[2],
1,
&kBufferHandles[2],
2,
std::vector<gfxrecon::decode::BufferInfo>(1),
&info_table,
&gfxrecon::decode::VulkanObjectInfoTable::AddBufferInfo);
// Add with info.
gfxrecon::decode::handle_mapping::AddHandle<gfxrecon::decode::BufferInfo>(
kDeviceId,
kBufferIds[3],
kBufferHandles[3],
gfxrecon::decode::BufferInfo{},
&info_table,
&gfxrecon::decode::VulkanObjectInfoTable::AddBufferInfo);
std::vector<const gfxrecon::decode::BufferInfo*> buffers;
info_table.VisitBufferInfo([&buffers](const gfxrecon::decode::BufferInfo* info) { buffers.push_back(info); });
REQUIRE(buffers.size() == 4);
}
SECTION("Add a duplicate entry to the object table, which is ignored")
{
gfxrecon::decode::handle_mapping::AddHandle<gfxrecon::decode::BufferInfo>(
kDeviceId,
kBufferIds[0],
kBufferHandles[0],
&info_table,
&gfxrecon::decode::VulkanObjectInfoTable::AddBufferInfo);
std::vector<const gfxrecon::decode::BufferInfo*> buffers;
info_table.VisitBufferInfo([&buffers](const gfxrecon::decode::BufferInfo* info) { buffers.push_back(info); });
REQUIRE(buffers.size() == 1);
}
SECTION("Remove an entry from the object table")
{
gfxrecon::decode::handle_mapping::RemoveHandle(
kBufferIds[0], &info_table, &gfxrecon::decode::VulkanObjectInfoTable::RemoveBufferInfo);
std::vector<const gfxrecon::decode::BufferInfo*> buffers;
info_table.VisitBufferInfo([&buffers](const gfxrecon::decode::BufferInfo* info) { buffers.push_back(info); });
REQUIRE(buffers.size() == 0);
}
SECTION("Buffer ID 12 maps to a valid buffer handle")
{
auto buffer = gfxrecon::decode::handle_mapping::MapHandle<gfxrecon::decode::BufferInfo>(
kBufferIds[0], info_table, &gfxrecon::decode::VulkanObjectInfoTable::GetBufferInfo);
REQUIRE(buffer == kBufferHandles[0]);
}
SECTION("Invalid buffer ID 99 does not map to a valid buffer handle")
{
auto buffer = gfxrecon::decode::handle_mapping::MapHandle<gfxrecon::decode::BufferInfo>(
99, info_table, &gfxrecon::decode::VulkanObjectInfoTable::GetBufferInfo);
REQUIRE(buffer == VK_NULL_HANDLE);
}
SECTION("An integer ID with value 12 and type VK_OBJECT_TYPE_BUFFER maps to a valid buffer handle represented as "
"an integer")
{
auto object = gfxrecon::decode::handle_mapping::MapHandle(kBufferIds[0], VK_OBJECT_TYPE_BUFFER, info_table);
REQUIRE(object == gfxrecon::format::ToHandleId(kBufferHandles[0]));
}
gfxrecon::util::Log::Release();
}
|