X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fintel%2Fvulkan%2Fanv_device.c;h=2e91980d3285535309348cb53cb53f5b5d2033e4;hb=f124f4a394680f8a1847339770c8d245282bbe01;hp=ce2045ecf7bc5375eeb5aa58d2a730194cb88dc8;hpb=869e393eb36e6912ca16fcfd060892c0de07bb49;p=mesa.git diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index ce2045ecf7b..2e91980d328 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -28,7 +28,7 @@ #include #include "anv_private.h" -#include "mesa/main/git_sha1.h" +#include "anv_timestamp.h" #include "util/strtod.h" #include "util/debug.h" @@ -67,12 +67,13 @@ anv_physical_device_init(struct anv_physical_device *device, device->_loader_data.loaderMagic = ICD_LOADER_MAGIC; device->instance = instance; - device->path = path; + + assert(strlen(path) < ARRAY_SIZE(device->path)); + strncpy(device->path, path, ARRAY_SIZE(device->path)); device->chipset_id = anv_gem_get_param(fd, I915_PARAM_CHIPSET_ID); if (!device->chipset_id) { - result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED, - "failed to get chipset id: %m"); + result = VK_ERROR_INITIALIZATION_FAILED; goto fail; } @@ -99,6 +100,17 @@ anv_physical_device_init(struct anv_physical_device *device, goto fail; } + device->cmd_parser_version = -1; + if (device->info->gen == 7) { + device->cmd_parser_version = + anv_gem_get_param(fd, I915_PARAM_CMD_PARSER_VERSION); + if (device->cmd_parser_version == -1) { + result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED, + "failed to get command parser version"); + goto fail; + } + } + if (anv_gem_get_aperture(fd, &device->aperture_size) == -1) { result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED, "failed to get aperture size: %m"); @@ -138,6 +150,10 @@ anv_physical_device_init(struct anv_physical_device *device, device->compiler->shader_debug_log = compiler_debug_log; device->compiler->shader_perf_log = compiler_perf_log; + result = anv_init_wsi(device); + if (result != VK_SUCCESS) + goto fail; + /* XXX: Actually detect bit6 swizzling */ isl_device_init(&device->isl_dev, device->info, swizzled); @@ -151,6 +167,7 @@ fail: static void anv_physical_device_finish(struct anv_physical_device *device) { + anv_finish_wsi(device); ralloc_free(device->compiler); } @@ -159,11 +176,13 @@ static const VkExtensionProperties global_extensions[] = { .extensionName = VK_KHR_SURFACE_EXTENSION_NAME, .specVersion = 25, }, +#ifdef VK_USE_PLATFORM_XCB_KHR { .extensionName = VK_KHR_XCB_SURFACE_EXTENSION_NAME, .specVersion = 5, }, -#ifdef HAVE_WAYLAND_PLATFORM +#endif +#ifdef VK_USE_PLATFORM_WAYLAND_KHR { .extensionName = VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, .specVersion = 4, @@ -223,7 +242,7 @@ VkResult anv_CreateInstance( } if (VK_MAKE_VERSION(1, 0, 0) > client_version || - client_version > VK_MAKE_VERSION(1, 0, 3)) { + client_version > VK_MAKE_VERSION(1, 0, 0xfff)) { return vk_errorf(VK_ERROR_INCOMPATIBLE_DRIVER, "Client requested version %d.%d.%d", VK_VERSION_MAJOR(client_version), @@ -259,14 +278,10 @@ VkResult anv_CreateInstance( instance->apiVersion = client_version; instance->physicalDeviceCount = -1; - memset(instance->wsi, 0, sizeof(instance->wsi)); - _mesa_locale_init(); VG(VALGRIND_CREATE_MEMPOOL(instance, 0, false)); - anv_init_wsi(instance); - *pInstance = anv_instance_to_handle(instance); return VK_SUCCESS; @@ -284,8 +299,6 @@ void anv_DestroyInstance( anv_physical_device_finish(&instance->physicalDevice); } - anv_finish_wsi(instance); - VG(VALGRIND_DESTROY_MEMPOOL(instance)); _mesa_locale_fini(); @@ -302,8 +315,15 @@ VkResult anv_EnumeratePhysicalDevices( VkResult result; if (instance->physicalDeviceCount < 0) { - result = anv_physical_device_init(&instance->physicalDevice, - instance, "/dev/dri/renderD128"); + char path[20]; + for (unsigned i = 0; i < 8; i++) { + snprintf(path, sizeof(path), "/dev/dri/renderD%d", 128 + i); + result = anv_physical_device_init(&instance->physicalDevice, + instance, path); + if (result == VK_SUCCESS) + break; + } + if (result == VK_ERROR_INCOMPATIBLE_DRIVER) { instance->physicalDeviceCount = 0; } else if (result == VK_SUCCESS) { @@ -352,7 +372,7 @@ void anv_GetPhysicalDeviceFeatures( .robustBufferAccess = true, .fullDrawIndexUint32 = true, .imageCubeArray = false, - .independentBlend = pdevice->info->gen >= 8, + .independentBlend = true, .geometryShader = true, .tessellationShader = false, .sampleRateShading = false, @@ -360,7 +380,7 @@ void anv_GetPhysicalDeviceFeatures( .logicOp = true, .multiDrawIndirect = false, .drawIndirectFirstInstance = false, - .depthClamp = false, + .depthClamp = true, .depthBiasClamp = false, .fillModeNonSolid = true, .depthBounds = false, @@ -369,15 +389,15 @@ void anv_GetPhysicalDeviceFeatures( .alphaToOne = true, .multiViewport = true, .samplerAnisotropy = false, /* FINISHME */ - .textureCompressionETC2 = true, - .textureCompressionASTC_LDR = true, + .textureCompressionETC2 = pdevice->info->gen >= 8 || + pdevice->info->is_baytrail, + .textureCompressionASTC_LDR = pdevice->info->gen >= 9, /* FINISHME CHV */ .textureCompressionBC = true, .occlusionQueryPrecise = true, .pipelineStatisticsQuery = false, - .vertexPipelineStoresAndAtomics = pdevice->info->gen >= 8, .fragmentStoresAndAtomics = true, .shaderTessellationAndGeometryPointSize = true, - .shaderImageGatherExtended = true, + .shaderImageGatherExtended = false, .shaderStorageImageExtendedFormats = false, .shaderStorageImageMultisample = false, .shaderUniformBufferArrayDynamicIndexing = true, @@ -395,13 +415,18 @@ void anv_GetPhysicalDeviceFeatures( .variableMultisampleRate = false, .inheritedQueries = false, }; + + /* We can't do image stores in vec4 shaders */ + pFeatures->vertexPipelineStoresAndAtomics = + pdevice->compiler->scalar_stage[MESA_SHADER_VERTEX] && + pdevice->compiler->scalar_stage[MESA_SHADER_GEOMETRY]; } void anv_device_get_cache_uuid(void *uuid) { memset(uuid, 0, VK_UUID_SIZE); - snprintf(uuid, VK_UUID_SIZE, "anv-%s", MESA_GIT_SHA1 + 4); + snprintf(uuid, VK_UUID_SIZE, "anv-%s", ANV_TIMESTAMP); } void anv_GetPhysicalDeviceProperties( @@ -411,10 +436,12 @@ void anv_GetPhysicalDeviceProperties( ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice); const struct brw_device_info *devinfo = pdevice->info; - anv_finishme("Get correct values for VkPhysicalDeviceLimits"); - const float time_stamp_base = devinfo->gen >= 9 ? 83.333 : 80.0; + /* See assertions made when programming the buffer surface state. */ + const uint32_t max_raw_buffer_sz = devinfo->gen >= 7 ? + (1ul << 30) : (1ul << 27); + VkSampleCountFlags sample_counts = isl_device_get_sample_counts(&pdevice->isl_dev); @@ -425,8 +452,8 @@ void anv_GetPhysicalDeviceProperties( .maxImageDimensionCube = (1 << 14), .maxImageArrayLayers = (1 << 11), .maxTexelBufferElements = 128 * 1024 * 1024, - .maxUniformBufferRange = UINT32_MAX, - .maxStorageBufferRange = UINT32_MAX, + .maxUniformBufferRange = (1ul << 27), + .maxStorageBufferRange = max_raw_buffer_sz, .maxPushConstantsSize = MAX_PUSH_CONSTANTS_SIZE, .maxMemoryAllocationCount = UINT32_MAX, .maxSamplerAllocationCount = 64 * 1024, @@ -487,7 +514,7 @@ void anv_GetPhysicalDeviceProperties( .maxSamplerAnisotropy = 16, .maxViewports = MAX_VIEWPORTS, .maxViewportDimensions = { (1 << 14), (1 << 14) }, - .viewportBoundsRange = { -16384.0, 16384.0 }, + .viewportBoundsRange = { INT16_MIN, INT16_MAX }, .viewportSubPixelBits = 13, /* We take a float? */ .minMemoryMapAlignment = 4096, /* A page */ .minTexelBufferOffsetAlignment = 1, @@ -532,7 +559,7 @@ void anv_GetPhysicalDeviceProperties( }; *pProperties = (VkPhysicalDeviceProperties) { - .apiVersion = VK_MAKE_VERSION(1, 0, 2), + .apiVersion = VK_MAKE_VERSION(1, 0, 5), .driverVersion = 1, .vendorID = 0x8086, .deviceID = pdevice->chipset_id, @@ -833,6 +860,9 @@ VkResult anv_CreateDevice( */ device->can_chain_batches = device->info.gen >= 8; + device->robust_buffer_access = pCreateInfo->pEnabledFeatures && + pCreateInfo->pEnabledFeatures->robustBufferAccess; + pthread_mutex_init(&device->mutex, NULL); anv_bo_pool_init(&device->batch_bo_pool, device); @@ -852,7 +882,7 @@ VkResult anv_CreateDevice( anv_bo_init_new(&device->workaround_bo, device, 1024); - anv_block_pool_init(&device->scratch_block_pool, device, 0x10000); + anv_scratch_pool_init(device, &device->scratch_pool); anv_queue_init(device, &device->queue); @@ -921,7 +951,7 @@ void anv_DestroyDevice( anv_block_pool_finish(&device->instruction_block_pool); anv_state_pool_finish(&device->surface_state_pool); anv_block_pool_finish(&device->surface_state_block_pool); - anv_block_pool_finish(&device->scratch_block_pool); + anv_scratch_pool_finish(device, &device->scratch_pool); close(device->fd); @@ -1066,8 +1096,8 @@ VkResult anv_DeviceWaitIdle( batch.start = batch.next = cmds; batch.end = (void *) cmds + sizeof(cmds); - anv_batch_emit(&batch, GEN7_MI_BATCH_BUFFER_END); - anv_batch_emit(&batch, GEN7_MI_NOOP); + anv_batch_emit(&batch, GEN7_MI_BATCH_BUFFER_END, bbe); + anv_batch_emit(&batch, GEN7_MI_NOOP, noop); return anv_device_submit_simple_batch(device, &batch); } @@ -1408,8 +1438,8 @@ VkResult anv_CreateFence( const uint32_t batch_offset = align_u32(sizeof(*fence), CACHELINE_SIZE); batch.next = batch.start = fence->bo.map + batch_offset; batch.end = fence->bo.map + fence->bo.size; - anv_batch_emit(&batch, GEN7_MI_BATCH_BUFFER_END); - anv_batch_emit(&batch, GEN7_MI_NOOP); + anv_batch_emit(&batch, GEN7_MI_BATCH_BUFFER_END, bbe); + anv_batch_emit(&batch, GEN7_MI_NOOP, noop); if (!device->info.has_llc) { assert(((uintptr_t) batch.start & CACHELINE_MASK) == 0);