test/binding: inherit PhysicalGpu from Handle
And rename PhysicalGpu to PhysicalDevice, gpu to phy.
diff --git a/tests/blit_tests.cpp b/tests/blit_tests.cpp
index 9c301ec..d93ef25 100644
--- a/tests/blit_tests.cpp
+++ b/tests/blit_tests.cpp
@@ -777,7 +777,7 @@
mem_info.allocationSize = mem_req.size;
mem_info.memoryTypeIndex = 0;
- err = dev_.gpu().set_memory_type(mem_req.memoryTypeBits, &mem_info, 0);
+ err = dev_.phy().set_memory_type(mem_req.memoryTypeBits, &mem_info, 0);
ASSERT_VK_SUCCESS(err);
err = vkAllocMemory(dev_.obj(), &mem_info, &event_mem);
@@ -1301,7 +1301,7 @@
VkFormatProperties props;
VkResult err;
- err = vkGetPhysicalDeviceFormatInfo(dev_.gpu().obj(), it->format, &props);
+ err = vkGetPhysicalDeviceFormatInfo(dev_.phy().handle(), it->format, &props);
ASSERT_EQ(err, VK_SUCCESS);
if (it->tiling == VK_IMAGE_TILING_LINEAR && !(props.linearTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
@@ -1468,7 +1468,7 @@
VkFormatProperties props;
VkResult err;
- err = vkGetPhysicalDeviceFormatInfo(dev_.gpu().obj(), it->format, &props);
+ err = vkGetPhysicalDeviceFormatInfo(dev_.phy().handle(), it->format, &props);
ASSERT_EQ(err, VK_SUCCESS);
if (it->tiling == VK_IMAGE_TILING_LINEAR && !(props.linearTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
diff --git a/tests/image_tests.cpp b/tests/image_tests.cpp
index b7702dc..dd60907 100644
--- a/tests/image_tests.cpp
+++ b/tests/image_tests.cpp
@@ -225,7 +225,7 @@
mem_info.allocationSize = mem_req.size;
mem_info.memoryTypeIndex = 0;
- err = m_device->gpu().set_memory_type(mem_req.memoryTypeBits, &mem_info, 0);
+ err = m_device->phy().set_memory_type(mem_req.memoryTypeBits, &mem_info, 0);
ASSERT_VK_SUCCESS(err);
/* allocate memory */
diff --git a/tests/init.cpp b/tests/init.cpp
index 9c70b98..8d71265 100644
--- a/tests/init.cpp
+++ b/tests/init.cpp
@@ -122,9 +122,9 @@
this->m_device = new vk_testing::Device(objs[m_device_id]);
this->m_device->init();
- props = m_device->gpu().properties();
+ props = m_device->phy().properties();
- queue_props = this->m_device->gpu().queue_properties();
+ queue_props = this->m_device->phy().queue_properties();
for (i = 0; i < queue_props.size(); i++) {
if (queue_props[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
graphics_queue_node_index = i;
@@ -201,7 +201,7 @@
mem_info.allocationSize = mem_req.size;
mem_info.memoryTypeIndex = 0;
- err = m_device->gpu().set_memory_type(mem_req.memoryTypeBits, &mem_info, 0);
+ err = m_device->phy().set_memory_type(mem_req.memoryTypeBits, &mem_info, 0);
ASSERT_VK_SUCCESS(err);
err = vkAllocMemory(device(), &mem_info, &event_mem);
@@ -294,7 +294,7 @@
mem_info.allocationSize = mem_req.size * MAX_QUERY_SLOTS;
mem_info.memoryTypeIndex = 0;
- err = m_device->gpu().set_memory_type(mem_req.memoryTypeBits, &mem_info, 0);
+ err = m_device->phy().set_memory_type(mem_req.memoryTypeBits, &mem_info, 0);
ASSERT_VK_SUCCESS(err);
err = vkAllocMemory(device(), &mem_info, &query_mem);
@@ -340,7 +340,7 @@
VkResult err;
VkQueue queue;
- const VkPhysicalDeviceQueueProperties props = device->gpu().queue_properties()[queue_node_index];
+ const VkPhysicalDeviceQueueProperties props = device->phy().queue_properties()[queue_node_index];
for (que_idx = 0; que_idx < props.queueCount; que_idx++) {
// TODO: Need to add support for separate MEMMGR and work queues, including synchronization
err = vkGetDeviceQueue(device->obj(), queue_node_index, que_idx, &queue);
@@ -490,7 +490,7 @@
mem_info.allocationSize = mem_req.size;
mem_info.memoryTypeIndex = 0;
- err = m_device->gpu().set_memory_type(mem_req.memoryTypeBits, &mem_info, 0);
+ err = m_device->phy().set_memory_type(mem_req.memoryTypeBits, &mem_info, 0);
ASSERT_VK_SUCCESS(err);
err = vkAllocMemory(device(), &mem_info, &image_mem);
diff --git a/tests/layer_validation_tests.cpp b/tests/layer_validation_tests.cpp
index 35223df..61a8f63 100644
--- a/tests/layer_validation_tests.cpp
+++ b/tests/layer_validation_tests.cpp
@@ -538,7 +538,7 @@
mem_alloc.allocationSize = mem_reqs.size;
- err = m_device->gpu().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0);
+ err = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0);
ASSERT_VK_SUCCESS(err);
// allocate memory
@@ -609,7 +609,7 @@
mem_alloc.allocationSize = mem_reqs.size;
- err = m_device->gpu().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0);
+ err = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0);
ASSERT_VK_SUCCESS(err);
// allocate memory
@@ -680,7 +680,7 @@
ASSERT_VK_SUCCESS(err);
mem_alloc.allocationSize = mem_reqs.size;
- err = m_device->gpu().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0);
+ err = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0);
ASSERT_VK_SUCCESS(err);
// allocate 2 memory objects
@@ -752,7 +752,7 @@
ASSERT_VK_SUCCESS(err);
mem_alloc.allocationSize = mem_reqs.size;
- err = m_device->gpu().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0);
+ err = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0);
ASSERT_VK_SUCCESS(err);
// Allocate memory
@@ -2309,7 +2309,7 @@
mem_info.allocationSize = mem_req.size;
mem_info.memoryTypeIndex = 0;
- err = m_device->gpu().set_memory_type(mem_req.memoryTypeBits, &mem_info, 0);
+ err = m_device->phy().set_memory_type(mem_req.memoryTypeBits, &mem_info, 0);
ASSERT_VK_SUCCESS(err);
err = vkAllocMemory(device(), &mem_info, &event_mem);
diff --git a/tests/test_environment.cpp b/tests/test_environment.cpp
index 78bb249..5bb7166 100644
--- a/tests/test_environment.cpp
+++ b/tests/test_environment.cpp
@@ -99,7 +99,7 @@
ASSERT_EQ(VK_SUCCESS, err);
ASSERT_GT(count, default_dev_);
- vk_testing::PhysicalGpu phys_dev(gpus[0]);
+ vk_testing::PhysicalDevice phys_dev(gpus[0]);
device_extensions = phys_dev.extensions();
for (uint32_t i = 0; i < device_extension_names.size(); i++) {
diff --git a/tests/vkrenderframework.cpp b/tests/vkrenderframework.cpp
index c460457..7361e29 100644
--- a/tests/vkrenderframework.cpp
+++ b/tests/vkrenderframework.cpp
@@ -308,7 +308,7 @@
VkFormatProperties props;
VkResult err;
- err = vkGetPhysicalDeviceFormatInfo(m_device->gpu().obj(), m_render_target_fmt, &props);
+ err = vkGetPhysicalDeviceFormatInfo(m_device->phy().handle(), m_render_target_fmt, &props);
ASSERT_VK_SUCCESS(err);
if (props.linearTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) {
@@ -402,8 +402,8 @@
{
init();
- props = gpu().properties();
- queue_props = &gpu().queue_properties()[0];
+ props = phy().properties();
+ queue_props = &phy().queue_properties()[0];
}
VkDeviceObj::VkDeviceObj(uint32_t id,
@@ -413,8 +413,8 @@
{
init(layer_names, extension_names);
- props = gpu().properties();
- queue_props = &gpu().queue_properties()[0];
+ props = phy().properties();
+ queue_props = &phy().queue_properties()[0];
}
void VkDeviceObj::get_device_queue()
@@ -685,7 +685,7 @@
mipCount++;
}
- err = vkGetPhysicalDeviceFormatInfo(m_device->gpu().obj(), fmt, &image_fmt);
+ err = vkGetPhysicalDeviceFormatInfo(m_device->phy().handle(), fmt, &image_fmt);
ASSERT_VK_SUCCESS(err);
if (requested_tiling == VK_IMAGE_TILING_LINEAR) {
diff --git a/tests/vktestbinding.cpp b/tests/vktestbinding.cpp
index 6755901..aad7cb5 100644
--- a/tests/vktestbinding.cpp
+++ b/tests/vktestbinding.cpp
@@ -86,43 +86,43 @@
error_callback = callback;
}
-VkPhysicalDeviceProperties PhysicalGpu::properties() const
+VkPhysicalDeviceProperties PhysicalDevice::properties() const
{
VkPhysicalDeviceProperties info;
- EXPECT(vkGetPhysicalDeviceProperties(gpu_, &info) == VK_SUCCESS);
+ EXPECT(vkGetPhysicalDeviceProperties(handle(), &info) == VK_SUCCESS);
return info;
}
-VkPhysicalDevicePerformance PhysicalGpu::performance() const
+VkPhysicalDevicePerformance PhysicalDevice::performance() const
{
VkPhysicalDevicePerformance info;
- EXPECT(vkGetPhysicalDevicePerformance(gpu_, &info) == VK_SUCCESS);
+ EXPECT(vkGetPhysicalDevicePerformance(handle(), &info) == VK_SUCCESS);
return info;
}
-std::vector<VkPhysicalDeviceQueueProperties> PhysicalGpu::queue_properties() const
+std::vector<VkPhysicalDeviceQueueProperties> PhysicalDevice::queue_properties() const
{
std::vector<VkPhysicalDeviceQueueProperties> info;
uint32_t count;
- if (EXPECT(vkGetPhysicalDeviceQueueCount(gpu_, &count) == VK_SUCCESS)) {
+ if (EXPECT(vkGetPhysicalDeviceQueueCount(handle(), &count) == VK_SUCCESS)) {
info.resize(count);
- if (!EXPECT(vkGetPhysicalDeviceQueueProperties(gpu_, count, &info[0]) == VK_SUCCESS))
+ if (!EXPECT(vkGetPhysicalDeviceQueueProperties(handle(), count, &info[0]) == VK_SUCCESS))
info.clear();
}
return info;
}
-VkPhysicalDeviceMemoryProperties PhysicalGpu::memory_properties() const
+VkPhysicalDeviceMemoryProperties PhysicalDevice::memory_properties() const
{
VkPhysicalDeviceMemoryProperties info;
- EXPECT(vkGetPhysicalDeviceMemoryProperties(gpu_, &info) == VK_SUCCESS);
+ EXPECT(vkGetPhysicalDeviceMemoryProperties(handle(), &info) == VK_SUCCESS);
return info;
@@ -188,7 +188,7 @@
/*
* Return list of PhysicalDevice extensions provided by the ICD / Loader
*/
-std::vector<VkExtensionProperties> PhysicalGpu::extensions() const
+std::vector<VkExtensionProperties> PhysicalDevice::extensions() const
{
return extensions(NULL);
}
@@ -197,18 +197,18 @@
* Return list of PhysicalDevice extensions provided by the specified layer
* If pLayerName is NULL, will return extensions for ICD / loader.
*/
-std::vector<VkExtensionProperties> PhysicalGpu::extensions(const char *pLayerName) const
+std::vector<VkExtensionProperties> PhysicalDevice::extensions(const char *pLayerName) const
{
std::vector<VkExtensionProperties> exts;
VkResult err;
do {
uint32_t extCount = 0;
- err = vkGetPhysicalDeviceExtensionProperties(obj(), pLayerName, &extCount, NULL);
+ err = vkGetPhysicalDeviceExtensionProperties(handle(), pLayerName, &extCount, NULL);
if (err == VK_SUCCESS) {
exts.reserve(extCount);
- err = vkGetPhysicalDeviceExtensionProperties(obj(), pLayerName, &extCount, &exts[0]);
+ err = vkGetPhysicalDeviceExtensionProperties(handle(), pLayerName, &extCount, &exts[0]);
}
} while (err == VK_INCOMPLETE);
@@ -217,7 +217,7 @@
return exts;
}
-VkResult PhysicalGpu::set_memory_type(const uint32_t type_bits, VkMemoryAllocInfo *info, const VkFlags properties) const
+VkResult PhysicalDevice::set_memory_type(const uint32_t type_bits, VkMemoryAllocInfo *info, const VkFlags properties) const
{
uint32_t type_mask = type_bits;
// Search memtypes to find first index with those properties
@@ -238,18 +238,18 @@
/*
* Return list of PhysicalDevice layers
*/
-std::vector<VkLayerProperties> PhysicalGpu::layers() const
+std::vector<VkLayerProperties> PhysicalDevice::layers() const
{
std::vector<VkLayerProperties> layer_props;
VkResult err;
do {
uint32_t layer_count = 0;
- err = vkGetPhysicalDeviceLayerProperties(obj(), &layer_count, NULL);
+ err = vkGetPhysicalDeviceLayerProperties(handle(), &layer_count, NULL);
if (err == VK_SUCCESS) {
layer_props.reserve(layer_count);
- err = vkGetPhysicalDeviceLayerProperties(obj(), &layer_count, &layer_props[0]);
+ err = vkGetPhysicalDeviceLayerProperties(handle(), &layer_count, &layer_props[0]);
}
} while (err == VK_INCOMPLETE);
@@ -336,7 +336,7 @@
for (int i = 0; i < mem_reqs.size(); i++) {
info = GpuMemory::alloc_info(mem_reqs[i], next_info);
- dev_->gpu().set_memory_type(mem_reqs[i].memoryTypeBits, &info, 0);
+ dev_->phy().set_memory_type(mem_reqs[i].memoryTypeBits, &info, 0);
primary_mem_ = &internal_mems_[i];
internal_mems_[i].init(*dev_, info);
bind_memory(internal_mems_[i], 0);
@@ -355,7 +355,7 @@
for (int i = 0; i < mem_reqs.size(); i++) {
info = GpuMemory::alloc_info(mem_reqs[i], next_info);
- dev_->gpu().set_memory_type(mem_reqs[i].memoryTypeBits, &info, reqs);
+ dev_->phy().set_memory_type(mem_reqs[i].memoryTypeBits, &info, reqs);
primary_mem_ = &internal_mems_[i];
internal_mems_[i].init(*dev_, info);
bind_memory(internal_mems_[i], 0);
@@ -410,7 +410,7 @@
void Device::init(std::vector<const char *> &layers, std::vector<const char *> &extensions)
{
// request all queues
- const std::vector<VkPhysicalDeviceQueueProperties> queue_props = gpu_.queue_properties();
+ const std::vector<VkPhysicalDeviceQueueProperties> queue_props = phy_.queue_properties();
std::vector<VkDeviceQueueCreateInfo> queue_info;
queue_info.reserve(queue_props.size());
for (int i = 0; i < queue_props.size(); i++) {
@@ -440,7 +440,7 @@
void Device::init(const VkDeviceCreateInfo &info)
{
VkDevice obj;
- if (EXPECT(vkCreateDevice(gpu_.obj(), &info, &obj) == VK_SUCCESS)) {
+ if (EXPECT(vkCreateDevice(phy_.handle(), &info, &obj) == VK_SUCCESS)) {
base_type::init(obj, VK_OBJECT_TYPE_DEVICE);
}
@@ -453,13 +453,13 @@
VkResult err;
uint32_t queue_node_count;
- err = vkGetPhysicalDeviceQueueCount(gpu_.obj(), &queue_node_count);
+ err = vkGetPhysicalDeviceQueueCount(phy_.handle(), &queue_node_count);
EXPECT(err == VK_SUCCESS);
EXPECT(queue_node_count >= 1);
VkPhysicalDeviceQueueProperties* queue_props = new VkPhysicalDeviceQueueProperties[queue_node_count];
- err = vkGetPhysicalDeviceQueueProperties(gpu_.obj(), queue_node_count, queue_props);
+ err = vkGetPhysicalDeviceQueueProperties(phy_.handle(), queue_node_count, queue_props);
EXPECT(err == VK_SUCCESS);
for (uint32_t i = 0; i < queue_node_count; i++) {
@@ -512,7 +512,7 @@
VkFormatProperties Device::format_properties(VkFormat format)
{
VkFormatProperties data;
- if (!EXPECT(vkGetPhysicalDeviceFormatInfo(gpu().obj(), format, &data) == VK_SUCCESS))
+ if (!EXPECT(vkGetPhysicalDeviceFormatInfo(phy().handle(), format, &data) == VK_SUCCESS))
memset(&data, 0, sizeof(data));
return data;
diff --git a/tests/vktestbinding.h b/tests/vktestbinding.h
index 247f0fd..87cfe3f 100644
--- a/tests/vktestbinding.h
+++ b/tests/vktestbinding.h
@@ -33,7 +33,7 @@
typedef void (*ErrorCallback)(const char *expr, const char *file, unsigned int line, const char *function);
void set_error_callback(ErrorCallback callback);
-class PhysicalGpu;
+class PhysicalDevice;
class BaseObject;
class Object;
class DynamicStateObject;
@@ -119,15 +119,13 @@
} // namespace internal
-class PhysicalGpu {
+class PhysicalDevice : public internal::Handle<VkPhysicalDevice> {
public:
- explicit PhysicalGpu(VkPhysicalDevice gpu) : gpu_(gpu)
+ explicit PhysicalDevice(VkPhysicalDevice phy) : Handle(phy)
{
memory_properties_ = memory_properties();
}
- const VkPhysicalDevice &obj() const { return gpu_; }
-
VkPhysicalDeviceProperties properties() const;
VkPhysicalDevicePerformance performance() const;
VkPhysicalDeviceMemoryProperties memory_properties() const;
@@ -146,8 +144,8 @@
void add_extension_dependencies(uint32_t dependency_count,
VkExtensionProperties *depencency_props,
std::vector<VkExtensionProperties> &ext_list);
+
VkPhysicalDeviceMemoryProperties memory_properties_;
- VkPhysicalDevice gpu_;
};
class BaseObject {
@@ -258,7 +256,7 @@
class Device : public DerivedObject<VkDevice, BaseObject, VK_OBJECT_TYPE_DEVICE> {
public:
- explicit Device(VkPhysicalDevice gpu) : gpu_(gpu) {}
+ explicit Device(VkPhysicalDevice phy) : phy_(phy) {}
~Device();
VkDevice device() const { return obj(); }
@@ -268,7 +266,7 @@
void init(std::vector<const char*> &layers, std::vector<const char *> &extensions); // all queues, all extensions, etc
void init() { std::vector<const char *> layers; std::vector<const char *> extensions; init(layers, extensions); };
- const PhysicalGpu &gpu() const { return gpu_; }
+ const PhysicalDevice &phy() const { return phy_; }
// vkGetDeviceProcAddr()
void *get_proc(const char *name) const { return vkGetDeviceProcAddr(obj(), name); }
@@ -319,7 +317,7 @@
void init_queues();
void init_formats();
- PhysicalGpu gpu_;
+ PhysicalDevice phy_;
std::vector<Queue *> queues_[QUEUE_COUNT];
std::vector<Format> formats_;