Support creating sysmem buffers in RAM domain
For ram-domain images, the uncached MOCS will be used. This will let us
get rid of VK_IMAGE_USAGE_SCANOUT_BIT_GOOGLE.
Change-Id: Ie4da764d069dba4f958431d86addf609de0dcea1
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 6b6d2ee..dfb976c 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -649,7 +649,9 @@
const int kParamCount = 4;
struct anv_fuchsia_image_plane_params params[kParamCount];
isl_tiling_flags_t tiling_flags;
- VkResult result = anv_image_params_from_fuchsia_image(device, pCreateInfo, params, &tiling_flags);
+ bool non_cache_coherent;
+ VkResult result = anv_image_params_from_fuchsia_image(device, pCreateInfo, params,
+ &tiling_flags, &non_cache_coherent);
if (result != VK_SUCCESS)
return result;
@@ -658,16 +660,19 @@
for (uint32_t i = 1; i < kParamCount; i++) {
assert(params[i].bytes_per_row == 0 || params[i].bytes_per_row == bytes_per_row);
}
+ // Disable compression bc sysmem doesn't support it.
+ uint32_t extra_usage_flags = ISL_SURF_USAGE_DISABLE_AUX_BIT;
+ if (non_cache_coherent) {
+ extra_usage_flags |= ISL_SURF_USAGE_DISPLAY_BIT;
+ }
result = anv_image_create(device,
- &(struct anv_image_create_info) {
- .vk_info = pCreateInfo,
- .stride = bytes_per_row,
- .isl_tiling_flags = tiling_flags,
- // Disable compression bc sysmem doesn't support it.
- .isl_extra_usage_flags = ISL_SURF_USAGE_DISABLE_AUX_BIT,
- },
- pAllocator,
- pImage);
+ &(struct anv_image_create_info){
+ .vk_info = pCreateInfo,
+ .stride = bytes_per_row,
+ .isl_tiling_flags = tiling_flags,
+ .isl_extra_usage_flags = extra_usage_flags,
+ },
+ pAllocator, pImage);
if (result != VK_SUCCESS)
return result;
@@ -1230,9 +1235,11 @@
}
state_inout->clear_address = clear_address;
- uint32_t mocs = (view_usage == ISL_SURF_USAGE_RENDER_TARGET_BIT) &&
- (image->usage & VK_IMAGE_USAGE_SCANOUT_BIT_GOOGLE) ?
- device->uncached_mocs : anv_mocs_for_bo(device, state_inout->address.bo);
+ uint32_t mocs = (view_usage == ISL_SURF_USAGE_RENDER_TARGET_BIT) &&
+ ((isl_surf->usage & ISL_SURF_USAGE_DISPLAY_BIT) ||
+ (image->usage & VK_IMAGE_USAGE_SCANOUT_BIT_GOOGLE))
+ ? device->uncached_mocs
+ : anv_mocs_for_bo(device, state_inout->address.bo);
isl_surf_fill_state(&device->isl_dev, state_inout->state.map,
.surf = isl_surf,
.view = &view,
diff --git a/src/intel/vulkan/anv_magma_buffer_collection.c b/src/intel/vulkan/anv_magma_buffer_collection.c
index 431b51d..b1c7ea1 100644
--- a/src/intel/vulkan/anv_magma_buffer_collection.c
+++ b/src/intel/vulkan/anv_magma_buffer_collection.c
@@ -221,8 +221,12 @@
if (result != VK_SUCCESS)
return result;
- magma_buffer_format_constraints_t format_constraints = {
- .count = 1, .usage = 0, .secure_permitted = false, .secure_required = false};
+ magma_buffer_format_constraints_t format_constraints = {.count = 1,
+ .usage = 0,
+ .secure_permitted = false,
+ .secure_required = false,
+ .ram_domain_supported = true,
+ .cpu_domain_supported = true};
magma_sysmem_buffer_constraints_t constraints;
status = magma_buffer_constraints_create(sysmem_connection, &format_constraints, &constraints);
@@ -254,7 +258,7 @@
VkResult anv_image_params_from_fuchsia_image(
VkDevice vk_device, const VkImageCreateInfo* pCreateInfo,
struct anv_fuchsia_image_plane_params params_out[MAGMA_MAX_IMAGE_PLANES],
- isl_tiling_flags_t* tiling_flags_out)
+ isl_tiling_flags_t* tiling_flags_out, bool* not_cache_coherent_out)
{
assert(pCreateInfo->arrayLayers == 1);
assert(pCreateInfo->extent.depth == 1);
@@ -279,12 +283,18 @@
status =
magma_get_buffer_format_modifier(description, &has_format_modifier, &format_modifier);
}
+ uint32_t coherency_domain;
+ if (status == MAGMA_STATUS_OK) {
+ status = magma_get_buffer_coherency_domain(description, &coherency_domain);
+ }
magma_buffer_format_description_release(description);
if (status != MAGMA_STATUS_OK)
return ANV_MAGMA_DRET(VK_ERROR_FORMAT_NOT_SUPPORTED);
+ *not_cache_coherent_out = coherency_domain == MAGMA_COHERENCY_DOMAIN_RAM;
+
*tiling_flags_out = ISL_TILING_LINEAR_BIT;
if (has_format_modifier) {
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 2c4292d..3fe8ae5 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -3325,11 +3325,11 @@
uint32_t byte_offset;
};
-VkResult anv_image_params_from_fuchsia_image(
- VkDevice vk_device,
- const VkImageCreateInfo *pCreateInfo,
- struct anv_fuchsia_image_plane_params params_out[4],
- isl_tiling_flags_t* tiling_flags_out);
+VkResult anv_image_params_from_fuchsia_image(VkDevice vk_device,
+ const VkImageCreateInfo* pCreateInfo,
+ struct anv_fuchsia_image_plane_params params_out[4],
+ isl_tiling_flags_t* tiling_flags_out,
+ bool* not_cache_coherent_out);
#endif