mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 11:18:08 +02:00
anv: Replace the 2 sparse booleans by 1 enum
Having just one place to check the Sparse type is less error prone. For example in i915 it was always setting sparse_uses_trtt to true even if running in gfx 9 that don't support sparse. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Signed-off-by: José Roberto de Souza <jose.souza@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28161>
This commit is contained in:
parent
ec892c4d2b
commit
9102cb972a
7 changed files with 38 additions and 29 deletions
|
|
@ -1385,7 +1385,7 @@ anv_queue_submit_sparse_bind_locked(struct anv_queue *queue,
|
|||
* supposed to be used by applications that request sparse to be enabled
|
||||
* but don't actually *use* it.
|
||||
*/
|
||||
if (!device->physical->has_sparse) {
|
||||
if (device->physical->sparse_type == ANV_SPARSE_TYPE_NOT_SUPPORTED) {
|
||||
if (INTEL_DEBUG(DEBUG_SPARSE))
|
||||
fprintf(stderr, "=== application submitting sparse operations: "
|
||||
"buffer_bind:%d image_opaque_bind:%d image_bind:%d\n",
|
||||
|
|
|
|||
|
|
@ -439,8 +439,7 @@ get_features(const struct anv_physical_device *pdevice,
|
|||
const bool mesh_shader =
|
||||
pdevice->vk.supported_extensions.EXT_mesh_shader;
|
||||
|
||||
const bool has_sparse_or_fake = pdevice->instance->has_fake_sparse ||
|
||||
pdevice->has_sparse;
|
||||
const bool has_sparse_or_fake = pdevice->sparse_type != ANV_SPARSE_TYPE_NOT_SUPPORTED;
|
||||
|
||||
*features = (struct vk_features) {
|
||||
/* Vulkan 1.0 */
|
||||
|
|
@ -1209,12 +1208,12 @@ get_properties(const struct anv_physical_device *pdevice,
|
|||
const uint32_t max_workgroup_size =
|
||||
MIN2(1024, 32 * devinfo->max_cs_workgroup_threads);
|
||||
|
||||
const bool has_sparse_or_fake = pdevice->instance->has_fake_sparse ||
|
||||
pdevice->has_sparse;
|
||||
const bool has_sparse_or_fake = pdevice->sparse_type != ANV_SPARSE_TYPE_NOT_SUPPORTED;
|
||||
const bool sparse_uses_trtt = pdevice->sparse_type == ANV_SPARSE_TYPE_TRTT;
|
||||
|
||||
uint64_t sparse_addr_space_size =
|
||||
!has_sparse_or_fake ? 0 :
|
||||
pdevice->sparse_uses_trtt ? pdevice->va.trtt.size :
|
||||
sparse_uses_trtt ? pdevice->va.trtt.size :
|
||||
pdevice->va.high_heap.size;
|
||||
|
||||
VkSampleCountFlags sample_counts =
|
||||
|
|
@ -2095,8 +2094,7 @@ static void
|
|||
anv_physical_device_init_queue_families(struct anv_physical_device *pdevice)
|
||||
{
|
||||
uint32_t family_count = 0;
|
||||
VkQueueFlags sparse_flags = (pdevice->instance->has_fake_sparse ||
|
||||
pdevice->has_sparse) ?
|
||||
VkQueueFlags sparse_flags = pdevice->sparse_type != ANV_SPARSE_TYPE_NOT_SUPPORTED ?
|
||||
VK_QUEUE_SPARSE_BINDING_BIT : 0;
|
||||
|
||||
if (pdevice->engine_info) {
|
||||
|
|
@ -2110,7 +2108,7 @@ anv_physical_device_init_queue_families(struct anv_physical_device *pdevice)
|
|||
const bool kernel_supports_non_render_engines =
|
||||
pdevice->info.kmd_type == INTEL_KMD_TYPE_XE || pdevice->has_vm_control;
|
||||
const bool sparse_supports_non_render_engines =
|
||||
!pdevice->has_sparse || !pdevice->sparse_uses_trtt;
|
||||
pdevice->sparse_type != ANV_SPARSE_TYPE_TRTT;
|
||||
const bool can_use_non_render_engines =
|
||||
kernel_supports_non_render_engines &&
|
||||
sparse_supports_non_render_engines;
|
||||
|
|
@ -2408,15 +2406,20 @@ anv_physical_device_try_create(struct vk_instance *vk_instance,
|
|||
|
||||
/* While xe.ko can use both vm_bind and TR-TT, i915.ko only has TR-TT. */
|
||||
if (device->info.kmd_type == INTEL_KMD_TYPE_XE) {
|
||||
device->has_sparse = true;
|
||||
device->sparse_uses_trtt =
|
||||
debug_get_bool_option("ANV_SPARSE_USE_TRTT", false);
|
||||
if (debug_get_bool_option("ANV_SPARSE_USE_TRTT", false))
|
||||
device->sparse_type = ANV_SPARSE_TYPE_TRTT;
|
||||
else
|
||||
device->sparse_type = ANV_SPARSE_TYPE_VM_BIND;
|
||||
} else {
|
||||
device->has_sparse =
|
||||
device->info.ver >= 12 &&
|
||||
device->has_exec_timeline &&
|
||||
debug_get_bool_option("ANV_SPARSE", true);
|
||||
device->sparse_uses_trtt = true;
|
||||
if (device->info.ver >= 12 &&
|
||||
device->has_exec_timeline &&
|
||||
debug_get_bool_option("ANV_SPARSE", true)) {
|
||||
device->sparse_type = ANV_SPARSE_TYPE_TRTT;
|
||||
} else if (instance->has_fake_sparse) {
|
||||
device->sparse_type = ANV_SPARSE_TYPE_FAKE;
|
||||
} else {
|
||||
device->sparse_type = ANV_SPARSE_TYPE_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
device->always_flush_cache = INTEL_DEBUG(DEBUG_STALL) ||
|
||||
|
|
@ -5001,7 +5004,7 @@ void anv_GetDeviceBufferMemoryRequirements(
|
|||
const bool is_sparse =
|
||||
pInfo->pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT;
|
||||
|
||||
if (!device->physical->has_sparse &&
|
||||
if ((device->physical->sparse_type == ANV_SPARSE_TYPE_NOT_SUPPORTED) &&
|
||||
INTEL_DEBUG(DEBUG_SPARSE) &&
|
||||
pInfo->pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_BINDING_BIT |
|
||||
VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT |
|
||||
|
|
@ -5026,7 +5029,7 @@ VkResult anv_CreateBuffer(
|
|||
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||
struct anv_buffer *buffer;
|
||||
|
||||
if (!device->physical->has_sparse &&
|
||||
if ((device->physical->sparse_type == ANV_SPARSE_TYPE_NOT_SUPPORTED) &&
|
||||
INTEL_DEBUG(DEBUG_SPARSE) &&
|
||||
pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_BINDING_BIT |
|
||||
VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT |
|
||||
|
|
|
|||
|
|
@ -1832,7 +1832,7 @@ void anv_GetPhysicalDeviceSparseImageFormatProperties2(
|
|||
VK_OUTARRAY_MAKE_TYPED(VkSparseImageFormatProperties2, props,
|
||||
pProperties, pPropertyCount);
|
||||
|
||||
if (!physical_device->has_sparse) {
|
||||
if (physical_device->sparse_type == ANV_SPARSE_TYPE_NOT_SUPPORTED) {
|
||||
if (INTEL_DEBUG(DEBUG_SPARSE))
|
||||
fprintf(stderr, "=== [%s:%d] [%s]\n", __FILE__, __LINE__, __func__);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1874,7 +1874,7 @@ VkResult anv_CreateImage(
|
|||
{
|
||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||
|
||||
if (!device->physical->has_sparse &&
|
||||
if ((device->physical->sparse_type == ANV_SPARSE_TYPE_NOT_SUPPORTED) &&
|
||||
INTEL_DEBUG(DEBUG_SPARSE) &&
|
||||
pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_BINDING_BIT |
|
||||
VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT |
|
||||
|
|
@ -2084,7 +2084,7 @@ void anv_GetDeviceImageMemoryRequirements(
|
|||
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||
struct anv_image image = { 0 };
|
||||
|
||||
if (!device->physical->has_sparse &&
|
||||
if ((device->physical->sparse_type == ANV_SPARSE_TYPE_NOT_SUPPORTED) &&
|
||||
INTEL_DEBUG(DEBUG_SPARSE) &&
|
||||
pInfo->pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_BINDING_BIT |
|
||||
VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT |
|
||||
|
|
@ -2194,7 +2194,8 @@ void anv_GetImageSparseMemoryRequirements2(
|
|||
ANV_FROM_HANDLE(anv_image, image, pInfo->image);
|
||||
|
||||
if (!anv_sparse_residency_is_enabled(device)) {
|
||||
if (!device->physical->has_sparse && INTEL_DEBUG(DEBUG_SPARSE))
|
||||
if ((device->physical->sparse_type == ANV_SPARSE_TYPE_NOT_SUPPORTED) &&
|
||||
INTEL_DEBUG(DEBUG_SPARSE))
|
||||
fprintf(stderr, "=== [%s:%d] [%s]\n", __FILE__, __LINE__, __func__);
|
||||
|
||||
*pSparseMemoryRequirementCount = 0;
|
||||
|
|
@ -2216,7 +2217,8 @@ void anv_GetDeviceImageSparseMemoryRequirements(
|
|||
struct anv_image image = { 0 };
|
||||
|
||||
if (!anv_sparse_residency_is_enabled(device)) {
|
||||
if (!device->physical->has_sparse && INTEL_DEBUG(DEBUG_SPARSE))
|
||||
if ((device->physical->sparse_type == ANV_SPARSE_TYPE_NOT_SUPPORTED) &&
|
||||
INTEL_DEBUG(DEBUG_SPARSE))
|
||||
fprintf(stderr, "=== [%s:%d] [%s]\n", __FILE__, __LINE__, __func__);
|
||||
|
||||
*pSparseMemoryRequirementCount = 0;
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ anv_shader_stage_to_nir(struct anv_device *device,
|
|||
.ray_tracing_position_fetch = rt_enabled,
|
||||
.shader_clock = true,
|
||||
.shader_viewport_index_layer = true,
|
||||
.sparse_residency = pdevice->has_sparse,
|
||||
.sparse_residency = pdevice->sparse_type != ANV_SPARSE_TYPE_NOT_SUPPORTED,
|
||||
.stencil_export = true,
|
||||
.storage_8bit = true,
|
||||
.storage_16bit = true,
|
||||
|
|
|
|||
|
|
@ -1019,8 +1019,12 @@ struct anv_physical_device {
|
|||
/** True if we have the means to do sparse binding (e.g., a Kernel driver
|
||||
* a vm_bind ioctl).
|
||||
*/
|
||||
bool has_sparse;
|
||||
bool sparse_uses_trtt;
|
||||
enum anv_sparse_type {
|
||||
ANV_SPARSE_TYPE_NOT_SUPPORTED = 0,
|
||||
ANV_SPARSE_TYPE_VM_BIND,
|
||||
ANV_SPARSE_TYPE_TRTT,
|
||||
ANV_SPARSE_TYPE_FAKE,
|
||||
} sparse_type;
|
||||
|
||||
/** True if HW supports ASTC LDR */
|
||||
bool has_astc_ldr;
|
||||
|
|
|
|||
|
|
@ -625,7 +625,7 @@ anv_sparse_bind(struct anv_device *device,
|
|||
dump_anv_vm_bind(device, &submit->binds[b]);
|
||||
}
|
||||
|
||||
return device->physical->sparse_uses_trtt ?
|
||||
return device->physical->sparse_type == ANV_SPARSE_TYPE_TRTT ?
|
||||
anv_sparse_bind_trtt(device, submit) :
|
||||
anv_sparse_bind_vm_bind(device, submit);
|
||||
}
|
||||
|
|
@ -640,7 +640,7 @@ anv_init_sparse_bindings(struct anv_device *device,
|
|||
{
|
||||
uint64_t size = align64(size_, ANV_SPARSE_BLOCK_SIZE);
|
||||
|
||||
if (device->physical->sparse_uses_trtt)
|
||||
if (device->physical->sparse_type == ANV_SPARSE_TYPE_TRTT)
|
||||
alloc_flags |= ANV_BO_ALLOC_TRTT;
|
||||
|
||||
sparse->address = anv_vma_alloc(device, size, ANV_SPARSE_BLOCK_SIZE,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue