X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Famd%2Fvulkan%2Fradv_device.c;h=5b93083913b9c81afbe69d0595b9cdd066a557a3;hb=93200ce4c6f543808e768c379a04bea577d55c72;hp=275bbe525533c5605469b14876c6170b2e44ac09;hpb=2fa83dc64d7930a169cfabf0ec67c36b43dc0cab;p=mesa.git diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index 275bbe52553..5b93083913b 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -615,6 +615,7 @@ DRI_CONF_BEGIN DRI_CONF_RADV_REPORT_LLVM9_VERSION_STRING("false") DRI_CONF_RADV_ENABLE_MRT_OUTPUT_NAN_FIXUP("false") DRI_CONF_RADV_NO_DYNAMIC_BOUNDS("false") + DRI_CONF_RADV_OVERRIDE_UNIFORM_OFFSET_ALIGNMENT(0) DRI_CONF_SECTION_END DRI_CONF_SECTION_DEBUG @@ -628,6 +629,8 @@ static void radv_init_dri_options(struct radv_instance *instance) driParseConfigFiles(&instance->dri_options, &instance->available_dri_options, 0, "radv", NULL, + instance->applicationName, + instance->applicationVersion, instance->engineName, instance->engineVersion); } @@ -655,6 +658,11 @@ VkResult radv_CreateInstance( if (pCreateInfo->pApplicationInfo) { const VkApplicationInfo *app = pCreateInfo->pApplicationInfo; + instance->applicationName = + vk_strdup(&instance->alloc, app->pApplicationName, + VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + instance->applicationVersion = app->applicationVersion; + instance->engineName = vk_strdup(&instance->alloc, app->pEngineName, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); @@ -791,6 +799,7 @@ void radv_DestroyInstance( } vk_free(&instance->alloc, instance->engineName); + vk_free(&instance->alloc, instance->applicationName); VG(VALGRIND_DESTROY_MEMPOOL(instance)); @@ -1437,6 +1446,21 @@ radv_max_descriptor_set_size() 64 /* storage image */); } +static uint32_t +radv_uniform_buffer_offset_alignment(const struct radv_physical_device *pdevice) +{ + uint32_t uniform_offset_alignment = driQueryOptioni(&pdevice->instance->dri_options, + "radv_override_uniform_offset_alignment"); + if (!util_is_power_of_two_or_zero(uniform_offset_alignment)) { + fprintf(stderr, "ERROR: invalid radv_override_uniform_offset_alignment setting %d:" + "not a power of two\n", uniform_offset_alignment); + uniform_offset_alignment = 0; + } + + /* Take at least the hardware limit. */ + return MAX2(uniform_offset_alignment, 4); +} + void radv_GetPhysicalDeviceProperties( VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties* pProperties) @@ -1519,7 +1543,7 @@ void radv_GetPhysicalDeviceProperties( .viewportSubPixelBits = 8, .minMemoryMapAlignment = 4096, /* A page */ .minTexelBufferOffsetAlignment = 4, - .minUniformBufferOffsetAlignment = 4, + .minUniformBufferOffsetAlignment = radv_uniform_buffer_offset_alignment(pdevice), .minStorageBufferOffsetAlignment = 4, .minTexelOffset = -32, .maxTexelOffset = 31, @@ -2566,6 +2590,25 @@ static void radv_device_finish_border_color(struct radv_device *device) } } +VkResult +_radv_device_set_lost(struct radv_device *device, + const char *file, int line, + const char *msg, ...) +{ + VkResult err; + va_list ap; + + p_atomic_inc(&device->lost); + + va_start(ap, msg); + err = __vk_errorv(device->physical_device->instance, device, + VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, + VK_ERROR_DEVICE_LOST, file, line, msg, ap); + va_end(ap); + + return err; +} + VkResult radv_CreateDevice( VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, @@ -3399,8 +3442,7 @@ radv_init_graphics_state(struct radeon_cmdbuf *cs, struct radv_queue *queue) static void radv_init_compute_state(struct radeon_cmdbuf *cs, struct radv_queue *queue) { - struct radv_physical_device *physical_device = queue->device->physical_device; - si_emit_compute(physical_device, cs); + si_emit_compute(queue->device, cs); } static VkResult @@ -4480,7 +4522,7 @@ fail: * VK_ERROR_DEVICE_LOST to ensure the clients do not attempt * to submit the same job again to this device. */ - result = VK_ERROR_DEVICE_LOST; + result = radv_device_set_lost(queue->device, "vkQueueSubmit() failed"); } radv_free_temp_syncobjs(queue->device, @@ -4701,6 +4743,9 @@ VkResult radv_QueueSubmit( uint32_t fence_idx = 0; bool flushed_caches = false; + if (radv_device_is_lost(queue->device)) + return VK_ERROR_DEVICE_LOST; + if (fence != VK_NULL_HANDLE) { for (uint32_t i = 0; i < submitCount; ++i) if (radv_submit_has_effects(pSubmits + i)) @@ -4770,6 +4815,9 @@ VkResult radv_QueueWaitIdle( { RADV_FROM_HANDLE(radv_queue, queue, _queue); + if (radv_device_is_lost(queue->device)) + return VK_ERROR_DEVICE_LOST; + pthread_mutex_lock(&queue->pending_mutex); while (!list_is_empty(&queue->pending_submissions)) { pthread_cond_wait(&queue->device->timeline_cond, &queue->pending_mutex); @@ -4779,9 +4827,10 @@ VkResult radv_QueueWaitIdle( if (!queue->device->ws->ctx_wait_idle(queue->hw_ctx, radv_queue_family_to_ring(queue->queue_family_index), queue->queue_idx)) { - return vk_errorf(queue->device->instance, VK_ERROR_DEVICE_LOST, - "Failed to wait for a '%s' queue to be idle. " - "GPU hang ?", radv_get_queue_family_name(queue)); + return radv_device_set_lost(queue->device, + "Failed to wait for a '%s' queue " + "to be idle. GPU hang ?", + radv_get_queue_family_name(queue)); } return VK_SUCCESS; @@ -5080,6 +5129,26 @@ static VkResult radv_alloc_memory(struct radv_device *device, } else { close(import_info->fd); } + + if (mem->image && mem->image->plane_count == 1 && + !vk_format_is_depth_or_stencil(mem->image->vk_format)) { + struct radeon_bo_metadata metadata; + device->ws->buffer_get_metadata(mem->bo, &metadata); + + struct radv_image_create_info create_info = { + .no_metadata_planes = true, + .bo_metadata = &metadata + }; + + /* This gives a basic ability to import radeonsi images + * that don't have DCC. This is not guaranteed by any + * spec and can be removed after we support modifiers. */ + result = radv_image_create_layout(device, create_info, mem->image); + if (result != VK_SUCCESS) { + device->ws->buffer_destroy(mem->bo); + goto fail; + } + } } else if (host_ptr_info) { assert(host_ptr_info->handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT); mem->bo = device->ws->buffer_from_ptr(device->ws, host_ptr_info->pHostPointer, @@ -5428,6 +5497,9 @@ static bool radv_sparse_bind_has_effects(const VkBindSparseInfo *info) VkResult result; uint32_t fence_idx = 0; + if (radv_device_is_lost(queue->device)) + return VK_ERROR_DEVICE_LOST; + if (fence != VK_NULL_HANDLE) { for (uint32_t i = 0; i < bindInfoCount; ++i) if (radv_sparse_bind_has_effects(pBindInfo + i)) @@ -5610,6 +5682,10 @@ VkResult radv_WaitForFences( uint64_t timeout) { RADV_FROM_HANDLE(radv_device, device, _device); + + if (radv_device_is_lost(device)) + return VK_ERROR_DEVICE_LOST; + timeout = radv_get_absolute_timeout(timeout); if (device->always_use_syncobj && @@ -5766,6 +5842,9 @@ VkResult radv_GetFenceStatus(VkDevice _device, VkFence _fence) fence->temporary.kind != RADV_FENCE_NONE ? &fence->temporary : &fence->permanent; + if (radv_device_is_lost(device)) + return VK_ERROR_DEVICE_LOST; + switch (part->kind) { case RADV_FENCE_NONE: break; @@ -6091,6 +6170,9 @@ radv_GetSemaphoreCounterValue(VkDevice _device, RADV_FROM_HANDLE(radv_device, device, _device); RADV_FROM_HANDLE(radv_semaphore, semaphore, _semaphore); + if (radv_device_is_lost(device)) + return VK_ERROR_DEVICE_LOST; + struct radv_semaphore_part *part = semaphore->temporary.kind != RADV_SEMAPHORE_NONE ? &semaphore->temporary : &semaphore->permanent; @@ -6148,6 +6230,10 @@ radv_WaitSemaphores(VkDevice _device, uint64_t timeout) { RADV_FROM_HANDLE(radv_device, device, _device); + + if (radv_device_is_lost(device)) + return VK_ERROR_DEVICE_LOST; + uint64_t abs_timeout = radv_get_absolute_timeout(timeout); if (radv_semaphore_from_handle(pWaitInfo->pSemaphores[0])->permanent.kind == RADV_SEMAPHORE_TIMELINE) @@ -6284,8 +6370,12 @@ VkResult radv_GetEventStatus( VkDevice _device, VkEvent _event) { + RADV_FROM_HANDLE(radv_device, device, _device); RADV_FROM_HANDLE(radv_event, event, _event); + if (radv_device_is_lost(device)) + return VK_ERROR_DEVICE_LOST; + if (*event->map == 1) return VK_EVENT_SET; return VK_EVENT_RESET;