mem_req.size, alloc_size, mem_req.memoryTypeBits, mem_type_bits);
}
- /* TODO When alloc_size is fixed to return host storage size, we will
- * also check alloc_size is not smaller than mem_req.size here.
- */
+ if (alloc_size < mem_req.size) {
+ result = VK_ERROR_INVALID_EXTERNAL_HANDLE;
+ goto fail;
+ }
+
mem_type_bits &= mem_req.memoryTypeBits;
if (!mem_type_bits) {
result = VK_ERROR_INVALID_EXTERNAL_HANDLE;
if (result != VK_SUCCESS)
return result;
- /* TODO When alloc_size is fixed to return host storage size, we will
- * also check alloc_size is not smaller than mem_req.size here.
- */
VkMemoryRequirements mem_req;
vn_GetImageMemoryRequirements(device, dedicated_info->image, &mem_req);
+ if (alloc_size < mem_req.size)
+ return VK_ERROR_INVALID_EXTERNAL_HANDLE;
+
alloc_size = mem_req.size;
}
if (dedicated_info && dedicated_info->buffer != VK_NULL_HANDLE) {
- /* TODO When alloc_size is fixed to return host storage size, we will
- * also check alloc_size is not smaller than mem_req.size here.
- */
VkMemoryRequirements mem_req;
vn_GetBufferMemoryRequirements(device, dedicated_info->buffer,
&mem_req);
+ if (alloc_size < mem_req.size)
+ return VK_ERROR_INVALID_EXTERNAL_HANDLE;
+
alloc_size = mem_req.size;
}
renderer_info->has_dma_buf_import) {
#ifdef ANDROID
if (renderer_exts->EXT_image_drm_format_modifier &&
- renderer_exts->EXT_queue_family_foreign) {
+ renderer_exts->EXT_queue_family_foreign &&
+ instance->experimental.memoryResourceAllocationSize == VK_TRUE) {
exts->ANDROID_external_memory_android_hardware_buffer = true;
exts->ANDROID_native_buffer = true;
}
if (result != VK_SUCCESS)
goto fail;
+ if (instance->renderer_info.vk_mesa_venus_protocol_spec_version ==
+ 100000) {
+ size_t size = 0;
+ vn_call_vkGetVenusExperimentalFeatureData100000MESA(instance, &size,
+ NULL);
+ size = MIN2(size, sizeof(instance->experimental));
+ vn_call_vkGetVenusExperimentalFeatureData100000MESA(
+ instance, &size, &instance->experimental);
+ }
+
result = vn_instance_init_renderer_versions(instance);
if (result != VK_SUCCESS)
goto fail;
#include "vn_common.h"
+#include "venus-protocol/vn_protocol_driver_defines.h"
+
#include "vn_cs.h"
#include "vn_device_memory.h"
#include "vn_renderer.h"
mtx_t physical_device_mutex;
struct vn_physical_device *physical_devices;
uint32_t physical_device_count;
+
+ /* XXX staged features to be merged to core venus protocol */
+ VkVenusExperimentalFeatures100000MESA experimental;
};
VK_DEFINE_HANDLE_CASTS(vn_instance,
base.base.base,
vn_instance_roundtrip(dev->instance);
+ VkMemoryResourceAllocationSizeProperties100000MESA alloc_size_props = {
+ .sType =
+ VK_STRUCTURE_TYPE_MEMORY_RESOURCE_ALLOCATION_SIZE_PROPERTIES_100000_MESA,
+ .pNext = NULL,
+ .allocationSize = 0,
+ };
VkMemoryResourcePropertiesMESA props = {
.sType = VK_STRUCTURE_TYPE_MEMORY_RESOURCE_PROPERTIES_MESA,
- .pNext = NULL,
+ .pNext =
+ dev->instance->experimental.memoryResourceAllocationSize == VK_TRUE
+ ? &alloc_size_props
+ : NULL,
.memoryTypeBits = 0,
};
result = vn_call_vkGetMemoryResourcePropertiesMESA(dev->instance, device,
if (result != VK_SUCCESS)
return result;
- /* XXX extend VkMemoryResourcePropertiesMESA for host storage size */
- *out_alloc_size = lseek(fd, 0, SEEK_END);
+ *out_alloc_size = alloc_size_props.allocationSize;
*out_mem_type_bits = props.memoryTypeBits;
return VK_SUCCESS;