diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c index 73f7b29cf3f..bd35ef35a9e 100644 --- a/src/intel/vulkan/anv_batch_chain.c +++ b/src/intel/vulkan/anv_batch_chain.c @@ -1412,7 +1412,8 @@ anv_queue_submit(struct vk_queue *vk_queue, VkResult anv_queue_submit_simple_batch(struct anv_queue *queue, - struct anv_batch *batch) + struct anv_batch *batch, + bool is_companion_rcs_batch) { struct anv_device *device = queue->device; VkResult result = VK_SUCCESS; @@ -1440,14 +1441,18 @@ anv_queue_submit_simple_batch(struct anv_queue *queue, if (INTEL_DEBUG(DEBUG_BATCH) && intel_debug_batch_in_range(device->debug_frame_desc->frame_id)) { - intel_print_batch(queue->decoder, - batch_bo->map, - batch_bo->size, - batch_bo->offset, false); + int render_queue_idx = + anv_get_first_render_queue_index(device->physical); + struct intel_batch_decode_ctx *ctx = is_companion_rcs_batch ? + &device->decoder[render_queue_idx] : + queue->decoder; + intel_print_batch(ctx, batch_bo->map, batch_bo->size, batch_bo->offset, + false); } result = device->kmd_backend->execute_simple_batch(queue, batch_bo, - batch_size); + batch_size, + is_companion_rcs_batch); anv_bo_pool_free(&device->batch_bo_pool, batch_bo); diff --git a/src/intel/vulkan/anv_gem_stubs.c b/src/intel/vulkan/anv_gem_stubs.c index 463ecdb415f..80c0e764050 100644 --- a/src/intel/vulkan/anv_gem_stubs.c +++ b/src/intel/vulkan/anv_gem_stubs.c @@ -59,9 +59,8 @@ stub_gem_mmap(struct anv_device *device, struct anv_bo *bo, uint64_t offset, } static VkResult -stub_execute_simple_batch(struct anv_queue *queue, - struct anv_bo *batch_bo, - uint32_t batch_bo_size) +stub_execute_simple_batch(struct anv_queue *queue, struct anv_bo *batch_bo, + uint32_t batch_bo_size, bool is_companion_rcs_batch) { return VK_ERROR_UNKNOWN; } diff --git a/src/intel/vulkan/anv_kmd_backend.h b/src/intel/vulkan/anv_kmd_backend.h index 36d334374bd..2dd53eaf5ef 100644 --- a/src/intel/vulkan/anv_kmd_backend.h +++ b/src/intel/vulkan/anv_kmd_backend.h @@ -59,7 +59,8 @@ struct anv_kmd_backend { int (*gem_vm_unbind)(struct anv_device *device, struct anv_bo *bo); VkResult (*execute_simple_batch)(struct anv_queue *queue, struct anv_bo *batch_bo, - uint32_t batch_bo_size); + uint32_t batch_bo_size, + bool is_companion_rcs_batch); VkResult (*queue_exec_locked)(struct anv_queue *queue, uint32_t wait_count, const struct vk_sync_wait *waits, diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index ea3bfb6e9e0..8405a18dd4d 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1752,7 +1752,8 @@ void anv_queue_finish(struct anv_queue *queue); VkResult anv_queue_submit(struct vk_queue *queue, struct vk_queue_submit *submit); VkResult anv_queue_submit_simple_batch(struct anv_queue *queue, - struct anv_batch *batch); + struct anv_batch *batch, + bool is_companion_rcs_batch); void anv_queue_trace(struct anv_queue *queue, const char *label, bool frame, bool begin); diff --git a/src/intel/vulkan/genX_init_state.c b/src/intel/vulkan/genX_init_state.c index 9c74464d4c0..961d252eb8c 100644 --- a/src/intel/vulkan/genX_init_state.c +++ b/src/intel/vulkan/genX_init_state.c @@ -322,7 +322,7 @@ init_common_queue_state(struct anv_queue *queue, struct anv_batch *batch) } static VkResult -init_render_queue_state(struct anv_queue *queue) +init_render_queue_state(struct anv_queue *queue, bool is_companion_rcs_batch) { struct anv_device *device = queue->device; UNUSED const struct intel_device_info *devinfo = queue->device->info; @@ -589,7 +589,7 @@ init_render_queue_state(struct anv_queue *queue) assert(batch.next <= batch.end); - return anv_queue_submit_simple_batch(queue, &batch); + return anv_queue_submit_simple_batch(queue, &batch, is_companion_rcs_batch); } static VkResult @@ -653,7 +653,8 @@ init_compute_queue_state(struct anv_queue *queue) assert(batch.next <= batch.end); - return anv_queue_submit_simple_batch(queue, &batch); + return anv_queue_submit_simple_batch(queue, &batch, + false /* is_companion_rcs_batch */); } void @@ -678,11 +679,20 @@ genX(init_device_state)(struct anv_device *device) struct anv_queue *queue = &device->queues[i]; switch (queue->family->engine_class) { case INTEL_ENGINE_CLASS_RENDER: - res = init_render_queue_state(queue); + res = init_render_queue_state(queue, false /* is_companion_rcs_batch */); break; - case INTEL_ENGINE_CLASS_COMPUTE: + case INTEL_ENGINE_CLASS_COMPUTE: { res = init_compute_queue_state(queue); + if (res != VK_SUCCESS) + return res; + + /** + * Execute RCS init batch by default on the companion RCS command buffer in + * order to support MSAA copy/clear operations on compute queue. + */ + res = init_render_queue_state(queue, true /* is_companion_rcs_batch */); break; + } case INTEL_ENGINE_CLASS_VIDEO: res = VK_SUCCESS; break; diff --git a/src/intel/vulkan/i915/anv_batch_chain.c b/src/intel/vulkan/i915/anv_batch_chain.c index 875b3abba6c..a52ba522df4 100644 --- a/src/intel/vulkan/i915/anv_batch_chain.c +++ b/src/intel/vulkan/i915/anv_batch_chain.c @@ -320,17 +320,22 @@ pin_state_pool(struct anv_device *device, static void get_context_and_exec_flags(struct anv_queue *queue, + bool is_companion_rcs_batch, uint64_t *exec_flags, uint32_t *context_id) { assert(queue != NULL); struct anv_device *device = queue->device; - /* Submit to index 0 which is the main (CCS/BCS etc) virtual engine. */ + + /** Submit batch to index 0 which is the main virtual engine */ *exec_flags = device->physical->has_vm_control ? 0 : queue->exec_flags; - *context_id = device->physical->has_vm_control ? queue->context_id : - device->context_id; + *context_id = device->physical->has_vm_control ? + is_companion_rcs_batch ? + queue->companion_rcs_id : + queue->context_id : + device->context_id; } static VkResult @@ -444,7 +449,7 @@ setup_execbuf_for_cmd_buffers(struct anv_execbuf *execbuf, uint64_t exec_flags = 0; uint32_t context_id; - get_context_and_exec_flags(queue, &exec_flags, &context_id); + get_context_and_exec_flags(queue, false, &exec_flags, &context_id); execbuf->execbuf = (struct drm_i915_gem_execbuffer2) { .buffers_ptr = (uintptr_t) execbuf->objects, @@ -478,7 +483,7 @@ setup_empty_execbuf(struct anv_execbuf *execbuf, struct anv_queue *queue) uint64_t exec_flags = 0; uint32_t context_id; - get_context_and_exec_flags(queue, &exec_flags, &context_id); + get_context_and_exec_flags(queue, false, &exec_flags, &context_id); execbuf->execbuf = (struct drm_i915_gem_execbuffer2) { .buffers_ptr = (uintptr_t) execbuf->objects, @@ -542,7 +547,7 @@ setup_utrace_execbuf(struct anv_execbuf *execbuf, struct anv_queue *queue, uint64_t exec_flags = 0; uint32_t context_id; - get_context_and_exec_flags(queue, &exec_flags, &context_id); + get_context_and_exec_flags(queue, false, &exec_flags, &context_id); execbuf->execbuf = (struct drm_i915_gem_execbuffer2) { .buffers_ptr = (uintptr_t) execbuf->objects, @@ -770,7 +775,7 @@ i915_queue_exec_locked(struct anv_queue *queue, uint64_t exec_flags = 0; uint32_t context_id; - get_context_and_exec_flags(queue, &exec_flags, &context_id); + get_context_and_exec_flags(queue, false, &exec_flags, &context_id); struct drm_i915_gem_execbuffer2 query_pass_execbuf = { .buffers_ptr = (uintptr_t) &query_pass_object, @@ -812,7 +817,7 @@ i915_queue_exec_locked(struct anv_queue *queue, VkResult i915_execute_simple_batch(struct anv_queue *queue, struct anv_bo *batch_bo, - uint32_t batch_bo_size) + uint32_t batch_bo_size, bool is_companion_rcs_batch) { struct anv_device *device = queue->device; struct anv_execbuf execbuf = { @@ -826,7 +831,8 @@ i915_execute_simple_batch(struct anv_queue *queue, struct anv_bo *batch_bo, uint64_t exec_flags = 0; uint32_t context_id; - get_context_and_exec_flags(queue, &exec_flags, &context_id); + get_context_and_exec_flags(queue, is_companion_rcs_batch, &exec_flags, + &context_id); execbuf.execbuf = (struct drm_i915_gem_execbuffer2) { .buffers_ptr = (uintptr_t) execbuf.objects, diff --git a/src/intel/vulkan/i915/anv_batch_chain.h b/src/intel/vulkan/i915/anv_batch_chain.h index 5e3f14fd00b..aa3dbe32437 100644 --- a/src/intel/vulkan/i915/anv_batch_chain.h +++ b/src/intel/vulkan/i915/anv_batch_chain.h @@ -40,7 +40,7 @@ i915_queue_exec_trace(struct anv_queue *queue, struct anv_utrace_submit *submit); VkResult i915_execute_simple_batch(struct anv_queue *queue, struct anv_bo *batch_bo, - uint32_t batch_bo_size); + uint32_t batch_bo_size, bool is_companion_rcs_batch); VkResult i915_queue_exec_locked(struct anv_queue *queue, uint32_t wait_count, diff --git a/src/intel/vulkan/xe/anv_batch_chain.c b/src/intel/vulkan/xe/anv_batch_chain.c index 988812bbba6..0f713e7ac8a 100644 --- a/src/intel/vulkan/xe/anv_batch_chain.c +++ b/src/intel/vulkan/xe/anv_batch_chain.c @@ -30,13 +30,17 @@ #include "drm-uapi/xe_drm.h" VkResult -xe_execute_simple_batch(struct anv_queue *queue, struct anv_bo *batch_bo, - uint32_t batch_bo_size) +xe_execute_simple_batch(struct anv_queue *queue, + struct anv_bo *batch_bo, + uint32_t batch_bo_size, + bool is_companion_rcs_batch) { struct anv_device *device = queue->device; VkResult result = VK_SUCCESS; uint32_t syncobj_handle; - + uint32_t exec_queue_id = is_companion_rcs_batch ? + queue->companion_rcs_id : + queue->exec_queue_id; if (drmSyncobjCreate(device->fd, 0, &syncobj_handle)) return vk_errorf(device, VK_ERROR_UNKNOWN, "Unable to create sync obj"); @@ -45,7 +49,7 @@ xe_execute_simple_batch(struct anv_queue *queue, struct anv_bo *batch_bo, .handle = syncobj_handle, }; struct drm_xe_exec exec = { - .exec_queue_id = queue->exec_queue_id, + .exec_queue_id = exec_queue_id, .num_batch_buffer = 1, .address = batch_bo->offset, .num_syncs = 1, diff --git a/src/intel/vulkan/xe/anv_batch_chain.h b/src/intel/vulkan/xe/anv_batch_chain.h index 9ee877e0494..a3a59f03d70 100644 --- a/src/intel/vulkan/xe/anv_batch_chain.h +++ b/src/intel/vulkan/xe/anv_batch_chain.h @@ -36,7 +36,7 @@ struct anv_utrace_submit; VkResult xe_execute_simple_batch(struct anv_queue *queue, struct anv_bo *batch_bo, - uint32_t batch_bo_size); + uint32_t batch_bo_size, bool is_companion_rcs_batch); VkResult xe_queue_exec_locked(struct anv_queue *queue, uint32_t wait_count,