diff --git a/src/panfrost/vulkan/csf/panvk_vX_queue.c b/src/panfrost/vulkan/csf/panvk_vX_queue.c index b2e4369df68..27dd24c34a2 100644 --- a/src/panfrost/vulkan/csf/panvk_vX_queue.c +++ b/src/panfrost/vulkan/csf/panvk_vX_queue.c @@ -598,12 +598,11 @@ create_group(struct panvk_queue *queue, }; struct drm_panthor_group_create gc = { - .compute_core_mask = phys_dev->kmod.props.shader_present, - .fragment_core_mask = phys_dev->kmod.props.shader_present, + .compute_core_mask = phys_dev->compute_core_mask, + .fragment_core_mask = phys_dev->fragment_core_mask, .tiler_core_mask = 1, - .max_compute_cores = util_bitcount64(phys_dev->kmod.props.shader_present), - .max_fragment_cores = - util_bitcount64(phys_dev->kmod.props.shader_present), + .max_compute_cores = util_bitcount64(phys_dev->compute_core_mask), + .max_fragment_cores = util_bitcount64(phys_dev->fragment_core_mask), .max_tiler_cores = 1, .priority = group_priority, .queues = DRM_PANTHOR_OBJ_ARRAY(ARRAY_SIZE(qc), qc), diff --git a/src/panfrost/vulkan/panvk_instance.c b/src/panfrost/vulkan/panvk_instance.c index 888b1620783..b03d98d0262 100644 --- a/src/panfrost/vulkan/panvk_instance.c +++ b/src/panfrost/vulkan/panvk_instance.c @@ -162,6 +162,11 @@ static const driOptionDescription panvk_dri_options[] = { DRI_CONF_VK_WSI_FORCE_SWAPCHAIN_TO_CURRENT_EXTENT(false) DRI_CONF_VK_X11_IGNORE_SUBOPTIMAL(false) DRI_CONF_SECTION_END + + DRI_CONF_SECTION_MISCELLANEOUS + DRI_CONF_PAN_COMPUTE_CORE_MASK(~0ull) + DRI_CONF_PAN_FRAGMENT_CORE_MASK(~0ull) + DRI_CONF_SECTION_END }; static void diff --git a/src/panfrost/vulkan/panvk_physical_device.c b/src/panfrost/vulkan/panvk_physical_device.c index f905c32d91a..b1627d16a96 100644 --- a/src/panfrost/vulkan/panvk_physical_device.c +++ b/src/panfrost/vulkan/panvk_physical_device.c @@ -130,6 +130,39 @@ get_cache_uuid(uint16_t family, void *uuid) return 0; } +static VkResult +get_core_mask(struct panvk_physical_device *device, + const struct panvk_instance *instance, const char *option_name, + uint64_t *mask) +{ + uint64_t present = device->kmod.props.shader_present; + *mask = driQueryOptionu64(&instance->dri_options, option_name) & present; + + if (!*mask) + return panvk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED, + "None of the cores specified in %s are present. " + "Available shader cores are 0x%" PRIx64 ".\n", + option_name, present); + + return VK_SUCCESS; +} + +static VkResult +get_core_masks(struct panvk_physical_device *device, + const struct panvk_instance *instance) +{ + VkResult result; + + result = get_core_mask(device, instance, "pan_compute_core_mask", + &device->compute_core_mask); + if (result != VK_SUCCESS) + return result; + result = get_core_mask(device, instance, "pan_fragment_core_mask", + &device->fragment_core_mask); + + return result; +} + static VkResult get_device_sync_types(struct panvk_physical_device *device, const struct panvk_instance *instance) @@ -1049,6 +1082,10 @@ panvk_physical_device_init(struct panvk_physical_device *device, goto fail; } + result = get_core_masks(device, instance); + if (result != VK_SUCCESS) + goto fail; + result = get_device_sync_types(device, instance); if (result != VK_SUCCESS) goto fail; diff --git a/src/panfrost/vulkan/panvk_physical_device.h b/src/panfrost/vulkan/panvk_physical_device.h index fa213c3558b..ebe81284b3e 100644 --- a/src/panfrost/vulkan/panvk_physical_device.h +++ b/src/panfrost/vulkan/panvk_physical_device.h @@ -52,6 +52,9 @@ struct panvk_physical_device { const struct vk_sync_type *sync_types[3]; struct wsi_device wsi_device; + + uint64_t compute_core_mask; + uint64_t fragment_core_mask; }; VK_DEFINE_HANDLE_CASTS(panvk_physical_device, vk.base, VkPhysicalDevice, diff --git a/src/util/driconf.h b/src/util/driconf.h index 8712c3b4dbb..5b0481912c8 100644 --- a/src/util/driconf.h +++ b/src/util/driconf.h @@ -641,6 +641,18 @@ DRI_CONF_OPT_B(disable_conservative_lrz, def, \ "Disable conservative LRZ") +/** + * \brief panfrost specific configuration options + */ + +#define DRI_CONF_PAN_COMPUTE_CORE_MASK(def) \ + DRI_CONF_OPT_U64(pan_compute_core_mask, def, 0, UINT64_MAX, \ + "Bitmask of shader cores that may be used for compute jobs. If unset, defaults to scheduling across all available cores.") + +#define DRI_CONF_PAN_FRAGMENT_CORE_MASK(def) \ + DRI_CONF_OPT_U64(pan_fragment_core_mask, def, 0, UINT64_MAX, \ + "Bitmask of shader cores that may be used for fragment jobs. If unset, defaults to scheduling across all available cores.") + /** * \brief Turnip specific configuration options */