anv/trtt: don't just crash when we can't find device->trtt.queue

Please refer to the big comment this patch introduces.

Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30252>
This commit is contained in:
Paulo Zanoni
2024-07-09 12:56:16 -07:00
parent 3ab8ff99fa
commit c65a76db85

View File

@@ -624,8 +624,34 @@ anv_sparse_bind_trtt(struct anv_device *device,
VkResult result;
/* TR-TT submission needs a queue even when the API entry point doesn't
* give one, such as resource creation. */
assert(trtt->queue != NULL);
* provide one, such as resource creation. We pick this queue from the user
* created queues at init_device_state() under anv_CreateDevice.
*
* It is technically possible for the user to create sparse resources even
* when they don't have a sparse queue: they won't be able to bind the
* resource but they should still be able to use the resource and rely on
* its unbound behavior. We haven't spotted any real world application or
* even test suite that exercises this behavior.
*
* For now let's just print an error message and return, which means that
* resource creation will succeed but the behavior will be undefined if the
* resource is used, which goes against our claim that we support the
* sparseResidencyNonResidentStrict property.
*
* TODO: be fully spec-compliant here. Maybe have a device-internal queue
* independent of the application's queues for the TR-TT operations.
*/
if (!trtt->queue) {
static bool warned = false;
if (unlikely(!warned)) {
fprintf(stderr, "FIXME: application has created a sparse resource "
"but no queues capable of binding sparse resources were "
"created. Using these resources will result in undefined "
"behavior.\n");
warned = true;
}
return VK_SUCCESS;
}
if (!sparse_submit->queue)
sparse_submit->queue = trtt->queue;