summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2017-05-17 13:14:45 -0700
committerJason Ekstrand <jason.ekstrand@intel.com>2017-05-17 13:24:32 -0700
commitd3a4aa1e59ed8891d345417ad341dfb442c9456f (patch)
tree6f9683005d0423f200b5e25b7c7d4ef120a466a5
parent1e1be2451b0757902ecd2405ade0c0186a952b2a (diff)
t: Get rid of t_mem_type_index
There isn't a single type index that works for all mmapable things. Instead, we need to actually look at the requirements.
-rw-r--r--include/tapi/t_data.h23
-rw-r--r--include/util/cru_image.h2
-rw-r--r--src/framework/test/t_data.c18
-rw-r--r--src/framework/test/t_image.c2
-rw-r--r--src/framework/test/t_phase_setup.c86
-rw-r--r--src/framework/test/test.h3
-rw-r--r--src/tests/func/4-vertex-buffers.c2
-rw-r--r--src/tests/func/cmd-buffer/secondary.c2
-rw-r--r--src/tests/func/compute-local-id.c2
-rw-r--r--src/tests/func/compute-num-workgroups.c2
-rw-r--r--src/tests/func/compute.c2
-rw-r--r--src/tests/func/copy/copy-buffer.c2
-rw-r--r--src/tests/func/depthstencil/arrayed-clear.c5
-rw-r--r--src/tests/func/depthstencil/basic.c2
-rw-r--r--src/tests/func/desc/binding.c2
-rw-r--r--src/tests/func/desc/dynamic.c2
-rw-r--r--src/tests/func/draw-indexed.c2
-rw-r--r--src/tests/func/first.c7
-rw-r--r--src/tests/func/gs/basic.c5
-rw-r--r--src/tests/func/interleaved-cmd-buffers.c4
-rw-r--r--src/tests/func/miptree/miptree.c8
-rw-r--r--src/tests/func/push-constants/basic.c5
-rw-r--r--src/tests/func/renderpass/clear.c7
-rw-r--r--src/tests/func/shader/fragcoord.c2
-rw-r--r--src/tests/func/ssbo/interleave.c4
-rw-r--r--src/tests/func/sync/semaphore-fd.c10
-rw-r--r--src/tests/stress/lots-of-surface-state.c8
-rw-r--r--src/util/cru_vk_image.c20
28 files changed, 65 insertions, 174 deletions
diff --git a/include/tapi/t_data.h b/include/tapi/t_data.h
index 99f1b73..9610670 100644
--- a/include/tapi/t_data.h
+++ b/include/tapi/t_data.h
@@ -22,25 +22,6 @@
/// \file
/// \brief Test data
///
-/// Crucible provides some default Vulkan memory types, described below. On
-/// UMA systems, the default-provided types may be identical, because the
-/// Vulkan implementation may expose only a single type. On NUMA systems, the
-/// default-provided types are likely to be distinct. To ensure that your test
-/// works correctly on NUMA systems, write your test assuming that
-/// t_mem_type_index_for_mmap and t_mem_type_index_for_device_access point to
-/// distinct types.
-///
-/// - t_mem_type_index_for_mmap: Prefer this memory type when allocating
-/// memory that will be mapped with vkMapMemory. This type has properties
-/// VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT and
-/// VK_MEMORY_PROPERTY_HOST_NON_COHERENT_BIT. The Vulkan spec requires
-/// implementations to expose at least one such memory type.
-///
-/// - t_mem_type_for_device_access: Prefer this memory type for best
-/// performance during device-access. This type may have no property but
-/// VK_MEMORY_PROPERTY_DEVICE_ONLY, which excludes support for
-/// vkMapMemory.
-///
#pragma once
@@ -57,8 +38,6 @@ typedef struct cru_image cru_image_t;
#define t_physical_dev (*__t_physical_dev())
#define t_physical_dev_props (__t_physical_dev_props())
#define t_physical_dev_mem_props (__t_physical_dev_mem_props())
-#define t_mem_type_index_for_mmap (__t_mem_type_index_for_mmap())
-#define t_mem_type_index_for_device_access (__t_mem_type_index_for_device_access())
#define t_device (*__t_device())
#define t_queue (*__t_queue())
#define t_descriptor_pool (*__t_descriptor_pool())
@@ -84,8 +63,6 @@ const VkDevice *__t_device(void);
const VkPhysicalDevice *__t_physical_dev(void);
const VkPhysicalDeviceProperties *__t_physical_dev_props(void);
const VkPhysicalDeviceMemoryProperties *__t_physical_dev_mem_props(void);
-const uint32_t __t_mem_type_index_for_mmap(void);
-const uint32_t __t_mem_type_index_for_device_access(void);
const VkQueue *__t_queue(void);
const VkDescriptorPool *__t_descriptor_pool(void);
const VkCommandPool *__t_cmd_pool(void);
diff --git a/include/util/cru_image.h b/include/util/cru_image.h
index 610fe89..48db399 100644
--- a/include/util/cru_image.h
+++ b/include/util/cru_image.h
@@ -92,7 +92,7 @@ cru_image_from_vk_image(VkDevice dev, VkQueue queue, VkImage image,
VkFormat format, VkImageAspectFlagBits aspect,
uint32_t level0_width, uint32_t level0_height,
uint32_t miplevel, uint32_t array_slice,
- uint32_t tmp_mem_type_index);
+ VkMemoryPropertyFlags tmp_mem_props);
bool cru_image_write_file(cru_image_t *image, const char *filename);
bool cru_image_copy(cru_image_t *dest, cru_image_t *src);
diff --git a/src/framework/test/t_data.c b/src/framework/test/t_data.c
index 9f7eb9e..3a3568c 100644
--- a/src/framework/test/t_data.c
+++ b/src/framework/test/t_data.c
@@ -66,24 +66,6 @@ __t_physical_dev_mem_props(void)
return &t->vk.physical_dev_mem_props;
}
-const uint32_t
-__t_mem_type_index_for_mmap(void)
-{
- ASSERT_TEST_IN_MAJOR_PHASE;
- GET_CURRENT_TEST(t);
-
- return t->vk.mem_type_index_for_mmap;
-}
-
-const uint32_t
-__t_mem_type_index_for_device_access(void)
-{
- ASSERT_TEST_IN_MAJOR_PHASE;
- GET_CURRENT_TEST(t);
-
- return t->vk.mem_type_index_for_device_access;
-}
-
const VkQueue *
__t_queue(void)
{
diff --git a/src/framework/test/t_image.c b/src/framework/test/t_image.c
index bd0cbba..266ce6d 100644
--- a/src/framework/test/t_image.c
+++ b/src/framework/test/t_image.c
@@ -47,7 +47,7 @@ t_new_cru_image_from_vk_image(VkDevice dev, VkQueue queue, VkImage image,
cru_image_t *cimg = cru_image_from_vk_image(t_device, queue, image,
format, aspect, level0_width, level0_height, miplevel,
- array_slice, t_mem_type_index_for_mmap);
+ array_slice, VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
if (!cimg)
t_failf("%s: failed to create image", __func__);
diff --git a/src/framework/test/t_phase_setup.c b/src/framework/test/t_phase_setup.c
index 0ee4c0f..db92f7b 100644
--- a/src/framework/test/t_phase_setup.c
+++ b/src/framework/test/t_phase_setup.c
@@ -62,44 +62,6 @@ static const VkAllocationCallbacks test_alloc_cb = {
.pfnInternalFree = test_vk_dummy_notify,
};
-/// Find the best VkMemoryType whose properties contain each flag in
-/// required_flags and contain no flag in the union of required_flags and
-/// allowed_flags.
-///
-/// On success, return the type's index into the
-/// VkPhysicalDeviceMemoryProperties::memoryTypes array.
-/// On failure, return UINT32_MAX.
-static uint32_t
-find_best_mem_type_index(
- const VkPhysicalDeviceMemoryProperties *mem_props,
- VkMemoryPropertyFlags required_flags,
- VkMemoryPropertyFlags allowed_flags)
-{
- uint32_t best_type_index = UINT32_MAX;
- VkMemoryHeap best_heap;
-
- allowed_flags |= required_flags;
-
- for (uint32_t i = 0; i < mem_props->memoryTypeCount; ++i) {
- VkMemoryType type = mem_props->memoryTypes[i];
- VkMemoryHeap heap = mem_props->memoryHeaps[type.heapIndex];
-
- if ((type.propertyFlags & required_flags) != required_flags)
- continue;
-
- if ((type.propertyFlags & ~allowed_flags) != 0)
- continue;
-
- // Prefer the type with the largest heap.
- if (best_type_index == UINT32_MAX || heap.size > best_heap.size) {
- best_type_index = i;
- best_heap = heap;
- }
- }
-
- return best_type_index;
-}
-
static void
t_setup_phys_dev(void)
{
@@ -121,46 +83,6 @@ t_setup_phys_dev(void)
}
static void
-t_setup_phys_dev_mem_props(void)
-{
- ASSERT_TEST_IN_SETUP_PHASE;
- GET_CURRENT_TEST(t);
-
- qoGetPhysicalDeviceMemoryProperties(t->vk.physical_dev,
- &t->vk.physical_dev_mem_props);
-
- // The Vulkan spec (git aaed022) requires the implementation to expose at
- // least one host-visible and host-coherent memory type.
- t->vk.mem_type_index_for_mmap = find_best_mem_type_index(
- &t->vk.physical_dev_mem_props,
- /*require*/ VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
- VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
- /*allow*/ ~0);
-
- // The best memory type for device-access is one which gives the best
- // performance, which is likely one that is device-visible but not
- // host-visible.
- t->vk.mem_type_index_for_device_access = find_best_mem_type_index(
- &t->vk.physical_dev_mem_props,
- /*require*/ VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
- /*allow*/ ~VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
-
- if (t->vk.mem_type_index_for_device_access == UINT32_MAX) {
- // There exists no device-only memory type. For device-access, then,
- // simply prefer the overall "best" memory type.
- t->vk.mem_type_index_for_device_access = find_best_mem_type_index(
- &t->vk.physical_dev_mem_props,
- /*require*/ VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, /*allow*/ ~0);
- }
-
- t_assertf(t->vk.mem_type_index_for_mmap != UINT32_MAX,
- "failed to find a host-visible, host-coherent VkMemoryType in "
- "VkPhysicalDeviceMemoryProperties");
-
- t_assert(t->vk.mem_type_index_for_device_access != UINT32_MAX);
-}
-
-static void
t_setup_framebuffer(void)
{
ASSERT_TEST_IN_SETUP_PHASE;
@@ -188,7 +110,7 @@ t_setup_framebuffer(void)
VkDeviceMemory color_mem = qoAllocImageMemory(t->vk.device,
t->vk.color_image,
- .memoryTypeIndex = t->vk.mem_type_index_for_device_access);
+ .properties = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
qoBindImageMemory(t->vk.device, t->vk.color_image, color_mem,
/*offset*/ 0);
@@ -245,7 +167,7 @@ t_setup_framebuffer(void)
VkDeviceMemory ds_mem = qoAllocImageMemory(t->vk.device,
t->vk.ds_image,
- .memoryTypeIndex = t->vk.mem_type_index_for_device_access);
+ .properties = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
qoBindImageMemory(t->vk.device, t->vk.ds_image, ds_mem,
/*offset*/ 0);
@@ -395,7 +317,9 @@ t_setup_vulkan(void)
t_cleanup_push_vk_instance(t->vk.instance, &test_alloc_cb);
t_setup_phys_dev();
- t_setup_phys_dev_mem_props();
+
+ qoGetPhysicalDeviceMemoryProperties(t->vk.physical_dev,
+ &t->vk.physical_dev_mem_props);
res = vkEnumerateDeviceExtensionProperties(t->vk.physical_dev, NULL,
&t->vk.device_extension_count, NULL);
diff --git a/src/framework/test/test.h b/src/framework/test/test.h
index cb874c0..7fcac88 100644
--- a/src/framework/test/test.h
+++ b/src/framework/test/test.h
@@ -159,9 +159,6 @@ struct test {
VkImage ds_image;
VkImageView depthstencil_image_view;
-
- uint32_t mem_type_index_for_mmap;
- uint32_t mem_type_index_for_device_access;
} vk;
};
diff --git a/src/tests/func/4-vertex-buffers.c b/src/tests/func/4-vertex-buffers.c
index aab090a..5384d4f 100644
--- a/src/tests/func/4-vertex-buffers.c
+++ b/src/tests/func/4-vertex-buffers.c
@@ -54,7 +54,7 @@ test(void)
.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
VkDeviceMemory mem = qoAllocBufferMemory(t_device, buffers[i],
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
qoBindBufferMemory(t_device, buffers[i], mem, 0);
diff --git a/src/tests/func/cmd-buffer/secondary.c b/src/tests/func/cmd-buffer/secondary.c
index c38440b..939ee0b 100644
--- a/src/tests/func/cmd-buffer/secondary.c
+++ b/src/tests/func/cmd-buffer/secondary.c
@@ -31,7 +31,7 @@ make_vbo(void)
.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
VkDeviceMemory vbo_mem = qoAllocBufferMemory(t_device, vbo,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
float *vbo_map = qoMapMemory(t_device, vbo_mem, /*offset*/ 0,
vbo_size, /*flags*/ 0);
diff --git a/src/tests/func/compute-local-id.c b/src/tests/func/compute-local-id.c
index 0424c87..1568d08 100644
--- a/src/tests/func/compute-local-id.c
+++ b/src/tests/func/compute-local-id.c
@@ -80,7 +80,7 @@ common_init(VkShaderModule cs, const uint32_t ssbo_size)
VkBuffer buffer_out = qoCreateBuffer(t_device, .size = ssbo_size);
VkDeviceMemory mem_out = qoAllocBufferMemory(t_device, buffer_out,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
qoBindBufferMemory(t_device, buffer_out, mem_out, 0);
vkUpdateDescriptorSets(t_device,
diff --git a/src/tests/func/compute-num-workgroups.c b/src/tests/func/compute-num-workgroups.c
index f41d058..35cae17 100644
--- a/src/tests/func/compute-num-workgroups.c
+++ b/src/tests/func/compute-num-workgroups.c
@@ -96,7 +96,7 @@ common_init(CTX *ctx)
ctx->ssbo_buf = qoCreateBuffer(t_device, .size = ctx->ssbo_size);
ctx->ssbo = qoAllocBufferMemory(t_device, ctx->ssbo_buf,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
qoBindBufferMemory(t_device, ctx->ssbo_buf, ctx->ssbo, 0);
vkUpdateDescriptorSets(t_device,
diff --git a/src/tests/func/compute.c b/src/tests/func/compute.c
index 1ada519..aa19836 100644
--- a/src/tests/func/compute.c
+++ b/src/tests/func/compute.c
@@ -83,7 +83,7 @@ test(void)
VkBuffer buffer = qoCreateBuffer(t_device, .size = 1024);
VkDeviceMemory mem = qoAllocBufferMemory(t_device, buffer,
- .memoryTypeIndex = t_mem_type_index_for_device_access);
+ .properties = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
qoBindBufferMemory(t_device, buffer, mem, 0);
diff --git a/src/tests/func/copy/copy-buffer.c b/src/tests/func/copy/copy-buffer.c
index fe03d84..961b749 100644
--- a/src/tests/func/copy/copy-buffer.c
+++ b/src/tests/func/copy/copy-buffer.c
@@ -37,7 +37,7 @@ test_large_copy(void)
VkDeviceMemory mem = qoAllocMemoryFromRequirements(t_device,
&total_buffer_reqs,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
void *map = qoMapMemory(t_device, mem, 0, total_buffer_reqs.size, 0);
diff --git a/src/tests/func/depthstencil/arrayed-clear.c b/src/tests/func/depthstencil/arrayed-clear.c
index 11eed0d..9be6c5e 100644
--- a/src/tests/func/depthstencil/arrayed-clear.c
+++ b/src/tests/func/depthstencil/arrayed-clear.c
@@ -69,7 +69,7 @@ test(void)
.usage = VK_IMAGE_USAGE_SAMPLED_BIT |
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
VkDeviceMemory depth_mem1 = qoAllocImageMemory(t_device, depth_test,
- .memoryTypeIndex = t_mem_type_index_for_device_access);
+ .properties = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
qoBindImageMemory(t_device, depth_test, depth_mem1, 0);
VkImageView depth_test_view = qoCreateImageView(t_device,
@@ -111,7 +111,8 @@ test(void)
VkBuffer buffer = qoCreateBuffer(t_device, .size = 4096, .usage =
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT);
VkDeviceMemory buffer_mem = qoAllocBufferMemory(t_device, buffer,
- .memoryTypeIndex = t_mem_type_index_for_device_access);
+ .properties = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
+ VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
qoBindBufferMemory(t_device, buffer, buffer_mem, 0);
// Initialize the buffer floats to a known value
diff --git a/src/tests/func/depthstencil/basic.c b/src/tests/func/depthstencil/basic.c
index e76bcc3..a4e7c28 100644
--- a/src/tests/func/depthstencil/basic.c
+++ b/src/tests/func/depthstencil/basic.c
@@ -147,7 +147,7 @@ test(void)
.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
VkDeviceMemory vertex_mem = qoAllocBufferMemory(t_device, vertex_buffer,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
qoBindBufferMemory(t_device, vertex_buffer, vertex_mem, /*offset*/ 0);
diff --git a/src/tests/func/desc/binding.c b/src/tests/func/desc/binding.c
index 8bd3360..9cbfecf 100644
--- a/src/tests/func/desc/binding.c
+++ b/src/tests/func/desc/binding.c
@@ -60,7 +60,7 @@ test(void)
.size = buffer_size);
VkDeviceMemory mem = qoAllocBufferMemory(t_device, buffer,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
qoBindBufferMemory(t_device, buffer, mem, 0);
diff --git a/src/tests/func/desc/dynamic.c b/src/tests/func/desc/dynamic.c
index 53af344..0b44f8f 100644
--- a/src/tests/func/desc/dynamic.c
+++ b/src/tests/func/desc/dynamic.c
@@ -174,7 +174,7 @@ test(void)
.size = 4096);
VkDeviceMemory mem = qoAllocBufferMemory(t_device, buffer,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
void *map = qoMapMemory(t_device, mem, 0, 4096, 0);
memset(map, 192, 4096);
diff --git a/src/tests/func/draw-indexed.c b/src/tests/func/draw-indexed.c
index 9d2bb9e..d635f7a 100644
--- a/src/tests/func/draw-indexed.c
+++ b/src/tests/func/draw-indexed.c
@@ -46,7 +46,7 @@ test(void)
VK_BUFFER_USAGE_INDEX_BUFFER_BIT);
VkDeviceMemory mem = qoAllocBufferMemory(t_device, buffer,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
map = qoMapMemory(t_device, mem, 0, buffer_size, 0);
qoBindBufferMemory(t_device, buffer, mem, 0);
diff --git a/src/tests/func/first.c b/src/tests/func/first.c
index 8cac6f0..8e4f28d 100644
--- a/src/tests/func/first.c
+++ b/src/tests/func/first.c
@@ -196,7 +196,7 @@ test(void)
.size = sizeof(uniform_data));
VkDeviceMemory uniform_mem = qoAllocBufferMemory(t_device, uniform_buffer,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
qoBindBufferMemory(t_device, uniform_buffer,
uniform_mem, /*offset*/ 0);
@@ -221,7 +221,7 @@ test(void)
.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
VkDeviceMemory vertex_mem = qoAllocBufferMemory(t_device, vertex_buffer,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
memcpy(qoMapMemory(t_device, vertex_mem, /*offset*/ 0,
sizeof(vertex_data), /*flags*/ 0),
@@ -247,8 +247,7 @@ test(void)
qoGetImageMemoryRequirements(t_device, texture);
VkDeviceMemory texture_mem = qoAllocMemoryFromRequirements(t_device,
- &texture_reqs,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ &texture_reqs, .properties = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
qoBindImageMemory(t_device, texture, texture_mem, /*offset*/ 0);
diff --git a/src/tests/func/gs/basic.c b/src/tests/func/gs/basic.c
index 7255829..bcc51c4 100644
--- a/src/tests/func/gs/basic.c
+++ b/src/tests/func/gs/basic.c
@@ -148,9 +148,8 @@ test_basic_gs(void)
.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT |
VK_BUFFER_USAGE_INDEX_BUFFER_BIT);
- VkDeviceMemory mem =
- qoAllocBufferMemory(t_device, buffer,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ VkDeviceMemory mem = qoAllocBufferMemory(t_device, buffer,
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
map = qoMapMemory(t_device, mem, 0, sizeof(vertex_data), 0);
qoBindBufferMemory(t_device, buffer, mem, 0);
diff --git a/src/tests/func/interleaved-cmd-buffers.c b/src/tests/func/interleaved-cmd-buffers.c
index 2db4fd5..305f26f 100644
--- a/src/tests/func/interleaved-cmd-buffers.c
+++ b/src/tests/func/interleaved-cmd-buffers.c
@@ -70,7 +70,7 @@ setup_src(struct src *src)
qoGetImageMemoryRequirements(t_device, image);
VkDeviceMemory mem = qoAllocMemoryFromRequirements(t_device, &mem_reqs,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
void *vk_map = qoMapMemory(t_device, mem, 0, mem_reqs.size, 0);
@@ -97,7 +97,7 @@ setup_dest(struct dest *dest)
VkBuffer buffer = qoCreateBuffer(t_device, .size = buffer_size);
VkDeviceMemory mem = qoAllocBufferMemory(t_device, buffer,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
void *map = qoMapMemory(t_device, mem, /*offset*/ 0,
buffer_size, /*flags*/ 0);
diff --git a/src/tests/func/miptree/miptree.c b/src/tests/func/miptree/miptree.c
index 8f2186a..25568dc 100644
--- a/src/tests/func/miptree/miptree.c
+++ b/src/tests/func/miptree/miptree.c
@@ -513,11 +513,11 @@ miptree_create(void)
.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
VkDeviceMemory image_mem = qoAllocImageMemory(t_device, image,
- .memoryTypeIndex = t_mem_type_index_for_device_access);
+ .properties = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
VkDeviceMemory src_buffer_mem = qoAllocBufferMemory(t_device, src_buffer,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
VkDeviceMemory dest_buffer_mem = qoAllocBufferMemory(t_device, dest_buffer,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
void *src_buffer_map = qoMapMemory(t_device, src_buffer_mem,
/*offset*/ 0, buffer_size, 0);
@@ -1245,7 +1245,7 @@ init_draw_data(test_draw_data_t *draw_data)
.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
VkDeviceMemory vb_mem = qoAllocBufferMemory(t_device, vb,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
qoBindBufferMemory(t_device, vb, vb_mem, /*offset*/ 0);
diff --git a/src/tests/func/push-constants/basic.c b/src/tests/func/push-constants/basic.c
index c5518e6..87f75b2 100644
--- a/src/tests/func/push-constants/basic.c
+++ b/src/tests/func/push-constants/basic.c
@@ -137,9 +137,8 @@ test_push_constants(void)
VkBuffer vbo = qoCreateBuffer(t_device, .size = sizeof(vertices),
.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
- VkDeviceMemory mem =
- qoAllocBufferMemory(t_device, vbo,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ VkDeviceMemory mem = qoAllocBufferMemory(t_device, vbo,
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
qoBindBufferMemory(t_device, vbo, mem, /*offset*/ 0);
float *const vbo_map = qoMapMemory(t_device, mem, /*offset*/ 0,
sizeof(vertices), /*flags*/ 0);
diff --git a/src/tests/func/renderpass/clear.c b/src/tests/func/renderpass/clear.c
index 73ed246..06eb867 100644
--- a/src/tests/func/renderpass/clear.c
+++ b/src/tests/func/renderpass/clear.c
@@ -88,7 +88,7 @@ test_color8(void)
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
VkDeviceMemory mem = qoAllocImageMemory(t_device, images[i],
- .memoryTypeIndex = t_mem_type_index_for_device_access);
+ .properties = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
qoBindImageMemory(t_device, images[i], mem, 0);
@@ -146,8 +146,9 @@ test_color8(void)
.size = dest_buffer_size,
.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT);
- VkDeviceMemory dest_buffer_mem = qoAllocBufferMemory(t_device,
- dest_buffers[i], .memoryTypeIndex = t_mem_type_index_for_mmap);
+ VkDeviceMemory dest_buffer_mem =
+ qoAllocBufferMemory(t_device, dest_buffers[i],
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
qoBindBufferMemory(t_device, dest_buffers[i], dest_buffer_mem,
/*offset*/ 0);
diff --git a/src/tests/func/shader/fragcoord.c b/src/tests/func/shader/fragcoord.c
index 86d0683..1de4911 100644
--- a/src/tests/func/shader/fragcoord.c
+++ b/src/tests/func/shader/fragcoord.c
@@ -123,7 +123,7 @@ test_fragcoord(void)
.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
VkDeviceMemory vb_mem = qoAllocBufferMemory(t_device, vb,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
qoBindBufferMemory(t_device, vb, vb_mem, 0);
void *vb_map = qoMapMemory(t_device, vb_mem, 0, sizeof(vertices), 0);
diff --git a/src/tests/func/ssbo/interleave.c b/src/tests/func/ssbo/interleave.c
index 5ff5a24..f474128 100644
--- a/src/tests/func/ssbo/interleave.c
+++ b/src/tests/func/ssbo/interleave.c
@@ -141,7 +141,7 @@ test(void)
VkBuffer buffer_in = qoCreateBuffer(t_device, .size = 4096);
VkDeviceMemory mem_in = qoAllocBufferMemory(t_device, buffer_in,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
uint32_t *map_in = qoMapMemory(t_device, mem_in, 0, 4096, 0);
for (unsigned i = 0; i < 1024; i++)
@@ -151,7 +151,7 @@ test(void)
VkBuffer buffer_out = qoCreateBuffer(t_device, .size = 4096);
VkDeviceMemory mem_out = qoAllocBufferMemory(t_device, buffer_out,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
qoBindBufferMemory(t_device, buffer_out, mem_out, 0);
vkUpdateDescriptorSets(t_device,
diff --git a/src/tests/func/sync/semaphore-fd.c b/src/tests/func/sync/semaphore-fd.c
index 1c90f3f..dbe1fed 100644
--- a/src/tests/func/sync/semaphore-fd.c
+++ b/src/tests/func/sync/semaphore-fd.c
@@ -447,7 +447,7 @@ test_sanity(void)
VkDeviceMemory mem =
qoAllocMemoryFromRequirements(ctx.device, &buffer_reqs,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
qoBindBufferMemory(ctx.device, ctx.buffer, mem, 0);
@@ -528,7 +528,7 @@ test_opaque_fd(void)
VkDeviceMemory mem1 =
qoAllocMemoryFromRequirements(ctx1.device, &buffer_reqs,
- .memoryTypeIndex = t_mem_type_index_for_mmap,
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
.pNext = &(VkExportMemoryAllocateInfoKHX) {
.sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_KHX,
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHX,
@@ -544,7 +544,7 @@ test_opaque_fd(void)
VkDeviceMemory mem2 =
qoAllocMemoryFromRequirements(ctx2.device, &buffer_reqs,
- .memoryTypeIndex = t_mem_type_index_for_mmap,
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
.pNext = &(VkImportMemoryFdInfoKHX) {
.sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHX,
.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHX,
@@ -682,7 +682,7 @@ test_sync_fd(void)
VkDeviceMemory mem1 =
qoAllocMemoryFromRequirements(ctx1.device, &buffer_reqs,
- .memoryTypeIndex = t_mem_type_index_for_mmap,
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
.pNext = &(VkExportMemoryAllocateInfoKHX) {
.sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_KHX,
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHX,
@@ -698,7 +698,7 @@ test_sync_fd(void)
VkDeviceMemory mem2 =
qoAllocMemoryFromRequirements(ctx2.device, &buffer_reqs,
- .memoryTypeIndex = t_mem_type_index_for_mmap,
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
.pNext = &(VkImportMemoryFdInfoKHX) {
.sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHX,
.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHX,
diff --git a/src/tests/stress/lots-of-surface-state.c b/src/tests/stress/lots-of-surface-state.c
index a30b69a..dc6bec7 100644
--- a/src/tests/stress/lots-of-surface-state.c
+++ b/src/tests/stress/lots-of-surface-state.c
@@ -124,7 +124,7 @@ test_lots_of_surface_state(VkShaderModule vs, VkShaderModule fs,
.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT);
VkDeviceMemory ubo_mem = qoAllocBufferMemory(t_device, ubo,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
float *const ubo_map = qoMapMemory(t_device, ubo_mem, /*offset*/ 0,
ubo_size, /*flags*/ 0);
@@ -138,7 +138,7 @@ test_lots_of_surface_state(VkShaderModule vs, VkShaderModule fs,
.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
VkDeviceMemory vbo_mem = qoAllocBufferMemory(t_device, vbo,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
float *const vbo_map = qoMapMemory(t_device, vbo_mem, /*offset*/ 0,
vbo_size, /*flags*/ 0);
@@ -494,7 +494,7 @@ test_lots_of_surface_state_cs(bool use_dynamic_offsets)
.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT);
VkDeviceMemory ubo_mem = qoAllocBufferMemory(t_device, ubo,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
float *const ubo_map = qoMapMemory(t_device, ubo_mem, /*offset*/ 0,
ubo_size, /*flags*/ 0);
@@ -517,7 +517,7 @@ test_lots_of_surface_state_cs(bool use_dynamic_offsets)
.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT);
VkDeviceMemory ssbo_mem = qoAllocBufferMemory(t_device, ssbo,
- .memoryTypeIndex = t_mem_type_index_for_mmap);
+ .properties = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
qoBindBufferMemory(t_device, ssbo, ssbo_mem, /*offset*/ 0);
diff --git a/src/util/cru_vk_image.c b/src/util/cru_vk_image.c
index 308095a..aea540e 100644
--- a/src/util/cru_vk_image.c
+++ b/src/util/cru_vk_image.c
@@ -41,7 +41,7 @@ struct cru_vk_image {
VkDevice vk_dev;
VkQueue vk_queue;
- uint32_t vk_tmp_mem_type_index;
+ VkMemoryPropertyFlags vk_tmp_mem_props;
struct {
VkImage vk_image;
@@ -100,10 +100,22 @@ setup_map(cru_vk_image_t *self)
VkMemoryRequirements mem_reqs;
vkGetBufferMemoryRequirements(dev, self->map.vk_buffer, &mem_reqs);
+ uint32_t type_index = UINT32_MAX;
+ const VkPhysicalDeviceMemoryProperties *props = t_physical_dev_mem_props;
+ for (uint32_t i = 0; i < props->memoryTypeCount; i++) {
+ const VkMemoryType *type = &props->memoryTypes[i];
+ if ((mem_reqs.memoryTypeBits & (1 << i)) &&
+ (type->propertyFlags & self->vk_tmp_mem_props) == self->vk_tmp_mem_props) {
+ type_index = i;
+ break;
+ }
+ }
+ assert(type_index < props->memoryTypeCount);
+
r = vkAllocateMemory(dev, &(VkMemoryAllocateInfo) {
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
- .memoryTypeIndex = self->vk_tmp_mem_type_index,
.allocationSize = mem_reqs.size,
+ .memoryTypeIndex = type_index,
},
NULL,
&self->map.vk_mem);
@@ -281,7 +293,7 @@ cru_image_from_vk_image(VkDevice dev, VkQueue queue, VkImage image,
VkFormat format, VkImageAspectFlagBits aspect,
uint32_t level0_width, uint32_t level0_height,
uint32_t miplevel, uint32_t array_slice,
- uint32_t tmp_mem_type_index)
+ VkMemoryPropertyFlags tmp_mem_props)
{
cru_vk_image_t *self = xzalloc(sizeof(*self));
@@ -294,7 +306,7 @@ cru_image_from_vk_image(VkDevice dev, VkQueue queue, VkImage image,
self->vk_dev = dev;
self->vk_queue = queue;
- self->vk_tmp_mem_type_index = tmp_mem_type_index;
+ self->vk_tmp_mem_props = tmp_mem_props;
self->target.vk_image = image;
self->target.vk_aspect = aspect;
self->target.miplevel = miplevel;