2 * Copyright © 2015 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30 #include "anv_private.h"
31 #include "mesa/main/git_sha1.h"
32 #include "util/strtod.h"
34 #include "gen7_pack.h"
36 struct anv_dispatch_table dtable
;
39 compiler_debug_log(void *data
, const char *fmt
, ...)
43 compiler_perf_log(void *data
, const char *fmt
, ...)
48 if (unlikely(INTEL_DEBUG
& DEBUG_PERF
))
49 vfprintf(stderr
, fmt
, args
);
55 anv_physical_device_init(struct anv_physical_device
*device
,
56 struct anv_instance
*instance
,
62 fd
= open(path
, O_RDWR
| O_CLOEXEC
);
64 return vk_errorf(VK_ERROR_INITIALIZATION_FAILED
,
65 "failed to open %s: %m", path
);
67 device
->_loader_data
.loaderMagic
= ICD_LOADER_MAGIC
;
68 device
->instance
= instance
;
71 device
->chipset_id
= anv_gem_get_param(fd
, I915_PARAM_CHIPSET_ID
);
72 if (!device
->chipset_id
) {
73 result
= vk_errorf(VK_ERROR_INITIALIZATION_FAILED
,
74 "failed to get chipset id: %m");
78 device
->name
= brw_get_device_name(device
->chipset_id
);
79 device
->info
= brw_get_device_info(device
->chipset_id
);
81 result
= vk_errorf(VK_ERROR_INITIALIZATION_FAILED
,
82 "failed to get device info");
86 if (device
->info
->is_haswell
) {
87 fprintf(stderr
, "WARNING: Haswell Vulkan support is incomplete\n");
88 } else if (device
->info
->gen
== 7 && !device
->info
->is_baytrail
) {
89 fprintf(stderr
, "WARNING: Ivy Bridge Vulkan support is incomplete\n");
90 } else if (device
->info
->gen
== 9) {
91 fprintf(stderr
, "WARNING: Skylake Vulkan support is incomplete\n");
92 } else if (device
->info
->gen
== 8 && !device
->info
->is_cherryview
) {
93 /* Broadwell is as fully supported as anything */
95 result
= vk_errorf(VK_ERROR_INCOMPATIBLE_DRIVER
,
96 "Vulkan not yet supported on %s", device
->name
);
100 if (anv_gem_get_aperture(fd
, &device
->aperture_size
) == -1) {
101 result
= vk_errorf(VK_ERROR_INITIALIZATION_FAILED
,
102 "failed to get aperture size: %m");
106 if (!anv_gem_get_param(fd
, I915_PARAM_HAS_WAIT_TIMEOUT
)) {
107 result
= vk_errorf(VK_ERROR_INITIALIZATION_FAILED
,
108 "kernel missing gem wait");
112 if (!anv_gem_get_param(fd
, I915_PARAM_HAS_EXECBUF2
)) {
113 result
= vk_errorf(VK_ERROR_INITIALIZATION_FAILED
,
114 "kernel missing execbuf2");
118 if (!anv_gem_get_param(fd
, I915_PARAM_HAS_LLC
)) {
119 result
= vk_errorf(VK_ERROR_INITIALIZATION_FAILED
,
126 brw_process_intel_debug_variable();
128 device
->compiler
= brw_compiler_create(NULL
, device
->info
);
129 if (device
->compiler
== NULL
) {
130 result
= vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
133 device
->compiler
->shader_debug_log
= compiler_debug_log
;
134 device
->compiler
->shader_perf_log
= compiler_perf_log
;
136 isl_device_init(&device
->isl_dev
, device
->info
);
146 anv_physical_device_finish(struct anv_physical_device
*device
)
148 ralloc_free(device
->compiler
);
151 static const VkExtensionProperties global_extensions
[] = {
153 .extensionName
= VK_EXT_KHR_SWAPCHAIN_EXTENSION_NAME
,
158 static const VkExtensionProperties device_extensions
[] = {
160 .extensionName
= VK_EXT_KHR_DEVICE_SWAPCHAIN_EXTENSION_NAME
,
166 default_alloc_func(void *pUserData
, size_t size
, size_t align
,
167 VkSystemAllocationScope allocationScope
)
173 default_realloc_func(void *pUserData
, void *pOriginal
, size_t size
,
174 size_t align
, VkSystemAllocationScope allocationScope
)
176 return realloc(pOriginal
, size
);
180 default_free_func(void *pUserData
, void *pMemory
)
185 static const VkAllocationCallbacks default_alloc
= {
187 .pfnAllocation
= default_alloc_func
,
188 .pfnReallocation
= default_realloc_func
,
189 .pfnFree
= default_free_func
,
192 VkResult
anv_CreateInstance(
193 const VkInstanceCreateInfo
* pCreateInfo
,
194 const VkAllocationCallbacks
* pAllocator
,
195 VkInstance
* pInstance
)
197 struct anv_instance
*instance
;
199 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO
);
201 if (pCreateInfo
->pApplicationInfo
->apiVersion
!= VK_MAKE_VERSION(0, 170, 2))
202 return vk_error(VK_ERROR_INCOMPATIBLE_DRIVER
);
204 for (uint32_t i
= 0; i
< pCreateInfo
->enabledExtensionNameCount
; i
++) {
206 for (uint32_t j
= 0; j
< ARRAY_SIZE(global_extensions
); j
++) {
207 if (strcmp(pCreateInfo
->ppEnabledExtensionNames
[i
],
208 global_extensions
[j
].extensionName
) == 0) {
214 return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT
);
217 instance
= anv_alloc2(&default_alloc
, pAllocator
, sizeof(*instance
), 8,
218 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
220 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
222 instance
->_loader_data
.loaderMagic
= ICD_LOADER_MAGIC
;
225 instance
->alloc
= *pAllocator
;
227 instance
->alloc
= default_alloc
;
229 instance
->apiVersion
= pCreateInfo
->pApplicationInfo
->apiVersion
;
230 instance
->physicalDeviceCount
= -1;
234 VG(VALGRIND_CREATE_MEMPOOL(instance
, 0, false));
236 anv_init_wsi(instance
);
238 *pInstance
= anv_instance_to_handle(instance
);
243 void anv_DestroyInstance(
244 VkInstance _instance
,
245 const VkAllocationCallbacks
* pAllocator
)
247 ANV_FROM_HANDLE(anv_instance
, instance
, _instance
);
249 if (instance
->physicalDeviceCount
> 0) {
250 /* We support at most one physical device. */
251 assert(instance
->physicalDeviceCount
== 1);
252 anv_physical_device_finish(&instance
->physicalDevice
);
255 anv_finish_wsi(instance
);
257 VG(VALGRIND_DESTROY_MEMPOOL(instance
));
261 anv_free(&instance
->alloc
, instance
);
264 VkResult
anv_EnumeratePhysicalDevices(
265 VkInstance _instance
,
266 uint32_t* pPhysicalDeviceCount
,
267 VkPhysicalDevice
* pPhysicalDevices
)
269 ANV_FROM_HANDLE(anv_instance
, instance
, _instance
);
272 if (instance
->physicalDeviceCount
< 0) {
273 result
= anv_physical_device_init(&instance
->physicalDevice
,
274 instance
, "/dev/dri/renderD128");
275 if (result
== VK_ERROR_INCOMPATIBLE_DRIVER
) {
276 instance
->physicalDeviceCount
= 0;
277 } else if (result
== VK_SUCCESS
) {
278 instance
->physicalDeviceCount
= 1;
284 /* pPhysicalDeviceCount is an out parameter if pPhysicalDevices is NULL;
285 * otherwise it's an inout parameter.
287 * The Vulkan spec (git aaed022) says:
289 * pPhysicalDeviceCount is a pointer to an unsigned integer variable
290 * that is initialized with the number of devices the application is
291 * prepared to receive handles to. pname:pPhysicalDevices is pointer to
292 * an array of at least this many VkPhysicalDevice handles [...].
294 * Upon success, if pPhysicalDevices is NULL, vkEnumeratePhysicalDevices
295 * overwrites the contents of the variable pointed to by
296 * pPhysicalDeviceCount with the number of physical devices in in the
297 * instance; otherwise, vkEnumeratePhysicalDevices overwrites
298 * pPhysicalDeviceCount with the number of physical handles written to
301 if (!pPhysicalDevices
) {
302 *pPhysicalDeviceCount
= instance
->physicalDeviceCount
;
303 } else if (*pPhysicalDeviceCount
>= 1) {
304 pPhysicalDevices
[0] = anv_physical_device_to_handle(&instance
->physicalDevice
);
305 *pPhysicalDeviceCount
= 1;
307 *pPhysicalDeviceCount
= 0;
313 void anv_GetPhysicalDeviceFeatures(
314 VkPhysicalDevice physicalDevice
,
315 VkPhysicalDeviceFeatures
* pFeatures
)
317 anv_finishme("Get correct values for PhysicalDeviceFeatures");
319 *pFeatures
= (VkPhysicalDeviceFeatures
) {
320 .robustBufferAccess
= false,
321 .fullDrawIndexUint32
= false,
322 .imageCubeArray
= false,
323 .independentBlend
= false,
324 .geometryShader
= true,
325 .tessellationShader
= false,
326 .sampleRateShading
= false,
327 .dualSrcBlend
= true,
329 .multiDrawIndirect
= true,
331 .depthBiasClamp
= false,
332 .fillModeNonSolid
= true,
333 .depthBounds
= false,
337 .multiViewport
= true,
338 .samplerAnisotropy
= false, /* FINISHME */
339 .textureCompressionETC2
= true,
340 .textureCompressionASTC_LDR
= true,
341 .textureCompressionBC
= true,
342 .occlusionQueryPrecise
= false, /* FINISHME */
343 .pipelineStatisticsQuery
= true,
344 .vertexPipelineStoresAndAtomics
= false,
345 .fragmentStoresAndAtomics
= true,
346 .shaderTessellationAndGeometryPointSize
= true,
347 .shaderImageGatherExtended
= true,
348 .shaderStorageImageExtendedFormats
= false,
349 .shaderStorageImageMultisample
= false,
350 .shaderUniformBufferArrayDynamicIndexing
= true,
351 .shaderSampledImageArrayDynamicIndexing
= false,
352 .shaderStorageBufferArrayDynamicIndexing
= false,
353 .shaderStorageImageArrayDynamicIndexing
= false,
354 .shaderStorageImageReadWithoutFormat
= false,
355 .shaderStorageImageWriteWithoutFormat
= true,
356 .shaderClipDistance
= false,
357 .shaderCullDistance
= false,
358 .shaderFloat64
= false,
359 .shaderInt64
= false,
360 .shaderInt16
= false,
362 .variableMultisampleRate
= false,
366 void anv_GetPhysicalDeviceProperties(
367 VkPhysicalDevice physicalDevice
,
368 VkPhysicalDeviceProperties
* pProperties
)
370 ANV_FROM_HANDLE(anv_physical_device
, pdevice
, physicalDevice
);
371 const struct brw_device_info
*devinfo
= pdevice
->info
;
373 anv_finishme("Get correct values for VkPhysicalDeviceLimits");
375 VkSampleCountFlags sample_counts
=
376 VK_SAMPLE_COUNT_1_BIT
|
377 VK_SAMPLE_COUNT_2_BIT
|
378 VK_SAMPLE_COUNT_4_BIT
|
379 VK_SAMPLE_COUNT_8_BIT
;
381 VkPhysicalDeviceLimits limits
= {
382 .maxImageDimension1D
= (1 << 14),
383 .maxImageDimension2D
= (1 << 14),
384 .maxImageDimension3D
= (1 << 10),
385 .maxImageDimensionCube
= (1 << 14),
386 .maxImageArrayLayers
= (1 << 10),
387 .maxTexelBufferElements
= (1 << 14),
388 .maxUniformBufferRange
= UINT32_MAX
,
389 .maxStorageBufferRange
= UINT32_MAX
,
390 .maxPushConstantsSize
= MAX_PUSH_CONSTANTS_SIZE
,
391 .maxMemoryAllocationCount
= UINT32_MAX
,
392 .maxSamplerAllocationCount
= UINT32_MAX
,
393 .bufferImageGranularity
= 64, /* A cache line */
394 .sparseAddressSpaceSize
= 0,
395 .maxBoundDescriptorSets
= MAX_SETS
,
396 .maxPerStageDescriptorSamplers
= 64,
397 .maxPerStageDescriptorUniformBuffers
= 64,
398 .maxPerStageDescriptorStorageBuffers
= 64,
399 .maxPerStageDescriptorSampledImages
= 64,
400 .maxPerStageDescriptorStorageImages
= 64,
401 .maxPerStageDescriptorInputAttachments
= 64,
402 .maxPerStageResources
= 128,
403 .maxDescriptorSetSamplers
= 256,
404 .maxDescriptorSetUniformBuffers
= 256,
405 .maxDescriptorSetUniformBuffersDynamic
= 256,
406 .maxDescriptorSetStorageBuffers
= 256,
407 .maxDescriptorSetStorageBuffersDynamic
= 256,
408 .maxDescriptorSetSampledImages
= 256,
409 .maxDescriptorSetStorageImages
= 256,
410 .maxDescriptorSetInputAttachments
= 256,
411 .maxVertexInputAttributes
= 32,
412 .maxVertexInputBindings
= 32,
413 .maxVertexInputAttributeOffset
= 256,
414 .maxVertexInputBindingStride
= 256,
415 .maxVertexOutputComponents
= 32,
416 .maxTessellationGenerationLevel
= 0,
417 .maxTessellationPatchSize
= 0,
418 .maxTessellationControlPerVertexInputComponents
= 0,
419 .maxTessellationControlPerVertexOutputComponents
= 0,
420 .maxTessellationControlPerPatchOutputComponents
= 0,
421 .maxTessellationControlTotalOutputComponents
= 0,
422 .maxTessellationEvaluationInputComponents
= 0,
423 .maxTessellationEvaluationOutputComponents
= 0,
424 .maxGeometryShaderInvocations
= 6,
425 .maxGeometryInputComponents
= 16,
426 .maxGeometryOutputComponents
= 16,
427 .maxGeometryOutputVertices
= 16,
428 .maxGeometryTotalOutputComponents
= 16,
429 .maxFragmentInputComponents
= 16,
430 .maxFragmentOutputAttachments
= 8,
431 .maxFragmentDualSrcAttachments
= 2,
432 .maxFragmentCombinedOutputResources
= 8,
433 .maxComputeSharedMemorySize
= 1024,
434 .maxComputeWorkGroupCount
= {
435 16 * devinfo
->max_cs_threads
,
436 16 * devinfo
->max_cs_threads
,
437 16 * devinfo
->max_cs_threads
,
439 .maxComputeWorkGroupInvocations
= 16 * devinfo
->max_cs_threads
,
440 .maxComputeWorkGroupSize
= {
441 16 * devinfo
->max_cs_threads
,
442 16 * devinfo
->max_cs_threads
,
443 16 * devinfo
->max_cs_threads
,
445 .subPixelPrecisionBits
= 4 /* FIXME */,
446 .subTexelPrecisionBits
= 4 /* FIXME */,
447 .mipmapPrecisionBits
= 4 /* FIXME */,
448 .maxDrawIndexedIndexValue
= UINT32_MAX
,
449 .maxDrawIndirectCount
= UINT32_MAX
,
450 .maxSamplerLodBias
= 16,
451 .maxSamplerAnisotropy
= 16,
452 .maxViewports
= MAX_VIEWPORTS
,
453 .maxViewportDimensions
= { (1 << 14), (1 << 14) },
454 .viewportBoundsRange
= { -1.0, 1.0 }, /* FIXME */
455 .viewportSubPixelBits
= 13, /* We take a float? */
456 .minMemoryMapAlignment
= 64, /* A cache line */
457 .minTexelBufferOffsetAlignment
= 1,
458 .minUniformBufferOffsetAlignment
= 1,
459 .minStorageBufferOffsetAlignment
= 1,
460 .minTexelOffset
= 0, /* FIXME */
461 .maxTexelOffset
= 0, /* FIXME */
462 .minTexelGatherOffset
= 0, /* FIXME */
463 .maxTexelGatherOffset
= 0, /* FIXME */
464 .minInterpolationOffset
= 0, /* FIXME */
465 .maxInterpolationOffset
= 0, /* FIXME */
466 .subPixelInterpolationOffsetBits
= 0, /* FIXME */
467 .maxFramebufferWidth
= (1 << 14),
468 .maxFramebufferHeight
= (1 << 14),
469 .maxFramebufferLayers
= (1 << 10),
470 .framebufferColorSampleCounts
= sample_counts
,
471 .framebufferDepthSampleCounts
= sample_counts
,
472 .framebufferStencilSampleCounts
= sample_counts
,
473 .framebufferNoAttachmentsSampleCounts
= sample_counts
,
474 .maxColorAttachments
= MAX_RTS
,
475 .sampledImageColorSampleCounts
= sample_counts
,
476 .sampledImageIntegerSampleCounts
= VK_SAMPLE_COUNT_1_BIT
,
477 .sampledImageDepthSampleCounts
= sample_counts
,
478 .sampledImageStencilSampleCounts
= sample_counts
,
479 .storageImageSampleCounts
= VK_SAMPLE_COUNT_1_BIT
,
480 .maxSampleMaskWords
= 1,
481 .timestampPeriod
= 80.0 / (1000 * 1000 * 1000),
482 .maxClipDistances
= 0 /* FIXME */,
483 .maxCullDistances
= 0 /* FIXME */,
484 .maxCombinedClipAndCullDistances
= 0 /* FIXME */,
485 .discreteQueuePriorities
= 1,
486 .pointSizeRange
= { 0.125, 255.875 },
487 .lineWidthRange
= { 0.0, 7.9921875 },
488 .pointSizeGranularity
= (1.0 / 8.0),
489 .lineWidthGranularity
= (1.0 / 128.0),
490 .strictLines
= false, /* FINISHME */
491 .standardSampleLocations
= true, /* FINISHME */
492 .optimalBufferCopyOffsetAlignment
= 128,
493 .optimalBufferCopyRowPitchAlignment
= 128,
494 .nonCoherentAtomSize
= 64,
497 *pProperties
= (VkPhysicalDeviceProperties
) {
498 .apiVersion
= VK_MAKE_VERSION(0, 170, 2),
501 .deviceID
= pdevice
->chipset_id
,
502 .deviceType
= VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU
,
504 .sparseProperties
= {0}, /* Broadwell doesn't do sparse. */
507 strcpy(pProperties
->deviceName
, pdevice
->name
);
508 snprintf((char *)pProperties
->pipelineCacheUUID
, VK_UUID_SIZE
,
509 "anv-%s", MESA_GIT_SHA1
+ 4);
512 void anv_GetPhysicalDeviceQueueFamilyProperties(
513 VkPhysicalDevice physicalDevice
,
515 VkQueueFamilyProperties
* pQueueFamilyProperties
)
517 if (pQueueFamilyProperties
== NULL
) {
522 assert(*pCount
>= 1);
524 *pQueueFamilyProperties
= (VkQueueFamilyProperties
) {
525 .queueFlags
= VK_QUEUE_GRAPHICS_BIT
|
526 VK_QUEUE_COMPUTE_BIT
|
527 VK_QUEUE_TRANSFER_BIT
,
529 .timestampValidBits
= 0, /* XXX: Real value here */
530 .minImageTransferGranularity
= (VkExtent3D
) { 1, 1, 1 },
534 void anv_GetPhysicalDeviceMemoryProperties(
535 VkPhysicalDevice physicalDevice
,
536 VkPhysicalDeviceMemoryProperties
* pMemoryProperties
)
538 ANV_FROM_HANDLE(anv_physical_device
, physical_device
, physicalDevice
);
539 VkDeviceSize heap_size
;
541 /* Reserve some wiggle room for the driver by exposing only 75% of the
542 * aperture to the heap.
544 heap_size
= 3 * physical_device
->aperture_size
/ 4;
546 /* The property flags below are valid only for llc platforms. */
547 pMemoryProperties
->memoryTypeCount
= 1;
548 pMemoryProperties
->memoryTypes
[0] = (VkMemoryType
) {
549 .propertyFlags
= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
|
550 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
|
551 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
|
552 VK_MEMORY_PROPERTY_HOST_CACHED_BIT
,
556 pMemoryProperties
->memoryHeapCount
= 1;
557 pMemoryProperties
->memoryHeaps
[0] = (VkMemoryHeap
) {
559 .flags
= VK_MEMORY_HEAP_DEVICE_LOCAL_BIT
,
563 PFN_vkVoidFunction
anv_GetInstanceProcAddr(
567 return anv_lookup_entrypoint(pName
);
570 PFN_vkVoidFunction
anv_GetDeviceProcAddr(
574 return anv_lookup_entrypoint(pName
);
578 anv_queue_init(struct anv_device
*device
, struct anv_queue
*queue
)
580 queue
->_loader_data
.loaderMagic
= ICD_LOADER_MAGIC
;
581 queue
->device
= device
;
582 queue
->pool
= &device
->surface_state_pool
;
588 anv_queue_finish(struct anv_queue
*queue
)
593 anv_device_init_border_colors(struct anv_device
*device
)
595 static const VkClearColorValue border_colors
[] = {
596 [VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK
] = { .float32
= { 0.0, 0.0, 0.0, 0.0 } },
597 [VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK
] = { .float32
= { 0.0, 0.0, 0.0, 1.0 } },
598 [VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE
] = { .float32
= { 1.0, 1.0, 1.0, 1.0 } },
599 [VK_BORDER_COLOR_INT_TRANSPARENT_BLACK
] = { .uint32
= { 0, 0, 0, 0 } },
600 [VK_BORDER_COLOR_INT_OPAQUE_BLACK
] = { .uint32
= { 0, 0, 0, 1 } },
601 [VK_BORDER_COLOR_INT_OPAQUE_WHITE
] = { .uint32
= { 1, 1, 1, 1 } },
604 device
->border_colors
=
605 anv_state_pool_alloc(&device
->dynamic_state_pool
,
606 sizeof(border_colors
), 32);
607 memcpy(device
->border_colors
.map
, border_colors
, sizeof(border_colors
));
610 VkResult
anv_CreateDevice(
611 VkPhysicalDevice physicalDevice
,
612 const VkDeviceCreateInfo
* pCreateInfo
,
613 const VkAllocationCallbacks
* pAllocator
,
616 ANV_FROM_HANDLE(anv_physical_device
, physical_device
, physicalDevice
);
617 struct anv_device
*device
;
619 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO
);
621 for (uint32_t i
= 0; i
< pCreateInfo
->enabledExtensionNameCount
; i
++) {
623 for (uint32_t j
= 0; j
< ARRAY_SIZE(device_extensions
); j
++) {
624 if (strcmp(pCreateInfo
->ppEnabledExtensionNames
[i
],
625 device_extensions
[j
].extensionName
) == 0) {
631 return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT
);
634 anv_set_dispatch_devinfo(physical_device
->info
);
636 device
= anv_alloc2(&physical_device
->instance
->alloc
, pAllocator
,
638 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
640 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
642 device
->_loader_data
.loaderMagic
= ICD_LOADER_MAGIC
;
643 device
->instance
= physical_device
->instance
;
646 device
->alloc
= *pAllocator
;
648 device
->alloc
= physical_device
->instance
->alloc
;
650 /* XXX(chadv): Can we dup() physicalDevice->fd here? */
651 device
->fd
= open(physical_device
->path
, O_RDWR
| O_CLOEXEC
);
652 if (device
->fd
== -1)
655 device
->context_id
= anv_gem_create_context(device
);
656 if (device
->context_id
== -1)
659 pthread_mutex_init(&device
->mutex
, NULL
);
661 anv_bo_pool_init(&device
->batch_bo_pool
, device
, ANV_CMD_BUFFER_BATCH_SIZE
);
663 anv_block_pool_init(&device
->dynamic_state_block_pool
, device
, 2048);
665 anv_state_pool_init(&device
->dynamic_state_pool
,
666 &device
->dynamic_state_block_pool
);
668 anv_block_pool_init(&device
->instruction_block_pool
, device
, 4096);
669 anv_block_pool_init(&device
->surface_state_block_pool
, device
, 4096);
671 anv_state_pool_init(&device
->surface_state_pool
,
672 &device
->surface_state_block_pool
);
674 anv_bo_init_new(&device
->workaround_bo
, device
, 1024);
676 anv_block_pool_init(&device
->scratch_block_pool
, device
, 0x10000);
678 device
->info
= *physical_device
->info
;
679 device
->isl_dev
= physical_device
->isl_dev
;
681 anv_queue_init(device
, &device
->queue
);
683 anv_device_init_meta(device
);
685 anv_device_init_border_colors(device
);
687 *pDevice
= anv_device_to_handle(device
);
694 anv_free(&device
->alloc
, device
);
696 return vk_error(VK_ERROR_INITIALIZATION_FAILED
);
699 void anv_DestroyDevice(
701 const VkAllocationCallbacks
* pAllocator
)
703 ANV_FROM_HANDLE(anv_device
, device
, _device
);
705 anv_queue_finish(&device
->queue
);
707 anv_device_finish_meta(device
);
710 /* We only need to free these to prevent valgrind errors. The backing
711 * BO will go away in a couple of lines so we don't actually leak.
713 anv_state_pool_free(&device
->dynamic_state_pool
, device
->border_colors
);
716 anv_gem_munmap(device
->workaround_bo
.map
, device
->workaround_bo
.size
);
717 anv_gem_close(device
, device
->workaround_bo
.gem_handle
);
719 anv_bo_pool_finish(&device
->batch_bo_pool
);
720 anv_state_pool_finish(&device
->dynamic_state_pool
);
721 anv_block_pool_finish(&device
->dynamic_state_block_pool
);
722 anv_block_pool_finish(&device
->instruction_block_pool
);
723 anv_state_pool_finish(&device
->surface_state_pool
);
724 anv_block_pool_finish(&device
->surface_state_block_pool
);
725 anv_block_pool_finish(&device
->scratch_block_pool
);
729 anv_free(&device
->alloc
, device
);
732 VkResult
anv_EnumerateInstanceExtensionProperties(
733 const char* pLayerName
,
734 uint32_t* pPropertyCount
,
735 VkExtensionProperties
* pProperties
)
737 if (pProperties
== NULL
) {
738 *pPropertyCount
= ARRAY_SIZE(global_extensions
);
742 assert(*pPropertyCount
>= ARRAY_SIZE(global_extensions
));
744 *pPropertyCount
= ARRAY_SIZE(global_extensions
);
745 memcpy(pProperties
, global_extensions
, sizeof(global_extensions
));
750 VkResult
anv_EnumerateDeviceExtensionProperties(
751 VkPhysicalDevice physicalDevice
,
752 const char* pLayerName
,
753 uint32_t* pPropertyCount
,
754 VkExtensionProperties
* pProperties
)
756 if (pProperties
== NULL
) {
757 *pPropertyCount
= ARRAY_SIZE(device_extensions
);
761 assert(*pPropertyCount
>= ARRAY_SIZE(device_extensions
));
763 *pPropertyCount
= ARRAY_SIZE(device_extensions
);
764 memcpy(pProperties
, device_extensions
, sizeof(device_extensions
));
769 VkResult
anv_EnumerateInstanceLayerProperties(
770 uint32_t* pPropertyCount
,
771 VkLayerProperties
* pProperties
)
773 if (pProperties
== NULL
) {
778 /* None supported at this time */
779 return vk_error(VK_ERROR_LAYER_NOT_PRESENT
);
782 VkResult
anv_EnumerateDeviceLayerProperties(
783 VkPhysicalDevice physicalDevice
,
784 uint32_t* pPropertyCount
,
785 VkLayerProperties
* pProperties
)
787 if (pProperties
== NULL
) {
792 /* None supported at this time */
793 return vk_error(VK_ERROR_LAYER_NOT_PRESENT
);
796 void anv_GetDeviceQueue(
798 uint32_t queueNodeIndex
,
802 ANV_FROM_HANDLE(anv_device
, device
, _device
);
804 assert(queueIndex
== 0);
806 *pQueue
= anv_queue_to_handle(&device
->queue
);
809 VkResult
anv_QueueSubmit(
811 uint32_t submitCount
,
812 const VkSubmitInfo
* pSubmits
,
815 ANV_FROM_HANDLE(anv_queue
, queue
, _queue
);
816 ANV_FROM_HANDLE(anv_fence
, fence
, _fence
);
817 struct anv_device
*device
= queue
->device
;
820 for (uint32_t i
= 0; i
< submitCount
; i
++) {
821 for (uint32_t j
= 0; j
< pSubmits
[i
].commandBufferCount
; j
++) {
822 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
,
823 pSubmits
[i
].pCommandBuffers
[j
]);
824 assert(cmd_buffer
->level
== VK_COMMAND_BUFFER_LEVEL_PRIMARY
);
826 ret
= anv_gem_execbuffer(device
, &cmd_buffer
->execbuf2
.execbuf
);
828 /* We don't know the real error. */
829 return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY
,
830 "execbuf2 failed: %m");
834 ret
= anv_gem_execbuffer(device
, &fence
->execbuf
);
836 /* We don't know the real error. */
837 return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY
,
838 "execbuf2 failed: %m");
842 for (uint32_t k
= 0; k
< cmd_buffer
->execbuf2
.bo_count
; k
++)
843 cmd_buffer
->execbuf2
.bos
[k
]->offset
= cmd_buffer
->execbuf2
.objects
[k
].offset
;
850 VkResult
anv_QueueWaitIdle(
853 ANV_FROM_HANDLE(anv_queue
, queue
, _queue
);
855 return ANV_CALL(DeviceWaitIdle
)(anv_device_to_handle(queue
->device
));
858 VkResult
anv_DeviceWaitIdle(
861 ANV_FROM_HANDLE(anv_device
, device
, _device
);
862 struct anv_state state
;
863 struct anv_batch batch
;
864 struct drm_i915_gem_execbuffer2 execbuf
;
865 struct drm_i915_gem_exec_object2 exec2_objects
[1];
866 struct anv_bo
*bo
= NULL
;
871 state
= anv_state_pool_alloc(&device
->dynamic_state_pool
, 32, 32);
872 bo
= &device
->dynamic_state_pool
.block_pool
->bo
;
873 batch
.start
= batch
.next
= state
.map
;
874 batch
.end
= state
.map
+ 32;
875 anv_batch_emit(&batch
, GEN7_MI_BATCH_BUFFER_END
);
876 anv_batch_emit(&batch
, GEN7_MI_NOOP
);
878 exec2_objects
[0].handle
= bo
->gem_handle
;
879 exec2_objects
[0].relocation_count
= 0;
880 exec2_objects
[0].relocs_ptr
= 0;
881 exec2_objects
[0].alignment
= 0;
882 exec2_objects
[0].offset
= bo
->offset
;
883 exec2_objects
[0].flags
= 0;
884 exec2_objects
[0].rsvd1
= 0;
885 exec2_objects
[0].rsvd2
= 0;
887 execbuf
.buffers_ptr
= (uintptr_t) exec2_objects
;
888 execbuf
.buffer_count
= 1;
889 execbuf
.batch_start_offset
= state
.offset
;
890 execbuf
.batch_len
= batch
.next
- state
.map
;
891 execbuf
.cliprects_ptr
= 0;
892 execbuf
.num_cliprects
= 0;
897 I915_EXEC_HANDLE_LUT
| I915_EXEC_NO_RELOC
| I915_EXEC_RENDER
;
898 execbuf
.rsvd1
= device
->context_id
;
901 ret
= anv_gem_execbuffer(device
, &execbuf
);
903 /* We don't know the real error. */
904 result
= vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY
, "execbuf2 failed: %m");
909 ret
= anv_gem_wait(device
, bo
->gem_handle
, &timeout
);
911 /* We don't know the real error. */
912 result
= vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY
, "execbuf2 failed: %m");
916 anv_state_pool_free(&device
->dynamic_state_pool
, state
);
921 anv_state_pool_free(&device
->dynamic_state_pool
, state
);
927 anv_bo_init_new(struct anv_bo
*bo
, struct anv_device
*device
, uint64_t size
)
929 bo
->gem_handle
= anv_gem_create(device
, size
);
931 return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY
);
941 VkResult
anv_AllocateMemory(
943 const VkMemoryAllocateInfo
* pAllocateInfo
,
944 const VkAllocationCallbacks
* pAllocator
,
945 VkDeviceMemory
* pMem
)
947 ANV_FROM_HANDLE(anv_device
, device
, _device
);
948 struct anv_device_memory
*mem
;
951 assert(pAllocateInfo
->sType
== VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO
);
953 /* We support exactly one memory heap. */
954 assert(pAllocateInfo
->memoryTypeIndex
== 0);
956 /* FINISHME: Fail if allocation request exceeds heap size. */
958 mem
= anv_alloc2(&device
->alloc
, pAllocator
, sizeof(*mem
), 8,
959 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
961 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
963 result
= anv_bo_init_new(&mem
->bo
, device
, pAllocateInfo
->allocationSize
);
964 if (result
!= VK_SUCCESS
)
967 *pMem
= anv_device_memory_to_handle(mem
);
972 anv_free2(&device
->alloc
, pAllocator
, mem
);
980 const VkAllocationCallbacks
* pAllocator
)
982 ANV_FROM_HANDLE(anv_device
, device
, _device
);
983 ANV_FROM_HANDLE(anv_device_memory
, mem
, _mem
);
986 anv_gem_munmap(mem
->bo
.map
, mem
->bo
.size
);
988 if (mem
->bo
.gem_handle
!= 0)
989 anv_gem_close(device
, mem
->bo
.gem_handle
);
991 anv_free2(&device
->alloc
, pAllocator
, mem
);
994 VkResult
anv_MapMemory(
996 VkDeviceMemory _memory
,
999 VkMemoryMapFlags flags
,
1002 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1003 ANV_FROM_HANDLE(anv_device_memory
, mem
, _memory
);
1005 /* FIXME: Is this supposed to be thread safe? Since vkUnmapMemory() only
1006 * takes a VkDeviceMemory pointer, it seems like only one map of the memory
1007 * at a time is valid. We could just mmap up front and return an offset
1008 * pointer here, but that may exhaust virtual memory on 32 bit
1011 mem
->map
= anv_gem_mmap(device
, mem
->bo
.gem_handle
, offset
, size
);
1012 mem
->map_size
= size
;
1019 void anv_UnmapMemory(
1021 VkDeviceMemory _memory
)
1023 ANV_FROM_HANDLE(anv_device_memory
, mem
, _memory
);
1025 anv_gem_munmap(mem
->map
, mem
->map_size
);
1028 VkResult
anv_FlushMappedMemoryRanges(
1030 uint32_t memoryRangeCount
,
1031 const VkMappedMemoryRange
* pMemoryRanges
)
1033 /* clflush here for !llc platforms */
1038 VkResult
anv_InvalidateMappedMemoryRanges(
1040 uint32_t memoryRangeCount
,
1041 const VkMappedMemoryRange
* pMemoryRanges
)
1043 return anv_FlushMappedMemoryRanges(device
, memoryRangeCount
, pMemoryRanges
);
1046 void anv_GetBufferMemoryRequirements(
1049 VkMemoryRequirements
* pMemoryRequirements
)
1051 ANV_FROM_HANDLE(anv_buffer
, buffer
, _buffer
);
1053 /* The Vulkan spec (git aaed022) says:
1055 * memoryTypeBits is a bitfield and contains one bit set for every
1056 * supported memory type for the resource. The bit `1<<i` is set if and
1057 * only if the memory type `i` in the VkPhysicalDeviceMemoryProperties
1058 * structure for the physical device is supported.
1060 * We support exactly one memory type.
1062 pMemoryRequirements
->memoryTypeBits
= 1;
1064 pMemoryRequirements
->size
= buffer
->size
;
1065 pMemoryRequirements
->alignment
= 16;
1068 void anv_GetImageMemoryRequirements(
1071 VkMemoryRequirements
* pMemoryRequirements
)
1073 ANV_FROM_HANDLE(anv_image
, image
, _image
);
1075 /* The Vulkan spec (git aaed022) says:
1077 * memoryTypeBits is a bitfield and contains one bit set for every
1078 * supported memory type for the resource. The bit `1<<i` is set if and
1079 * only if the memory type `i` in the VkPhysicalDeviceMemoryProperties
1080 * structure for the physical device is supported.
1082 * We support exactly one memory type.
1084 pMemoryRequirements
->memoryTypeBits
= 1;
1086 pMemoryRequirements
->size
= image
->size
;
1087 pMemoryRequirements
->alignment
= image
->alignment
;
1090 void anv_GetImageSparseMemoryRequirements(
1093 uint32_t* pSparseMemoryRequirementCount
,
1094 VkSparseImageMemoryRequirements
* pSparseMemoryRequirements
)
1099 void anv_GetDeviceMemoryCommitment(
1101 VkDeviceMemory memory
,
1102 VkDeviceSize
* pCommittedMemoryInBytes
)
1104 *pCommittedMemoryInBytes
= 0;
1107 VkResult
anv_BindBufferMemory(
1110 VkDeviceMemory _memory
,
1111 VkDeviceSize memoryOffset
)
1113 ANV_FROM_HANDLE(anv_device_memory
, mem
, _memory
);
1114 ANV_FROM_HANDLE(anv_buffer
, buffer
, _buffer
);
1116 buffer
->bo
= &mem
->bo
;
1117 buffer
->offset
= memoryOffset
;
1122 VkResult
anv_BindImageMemory(
1125 VkDeviceMemory _memory
,
1126 VkDeviceSize memoryOffset
)
1128 ANV_FROM_HANDLE(anv_device_memory
, mem
, _memory
);
1129 ANV_FROM_HANDLE(anv_image
, image
, _image
);
1131 image
->bo
= &mem
->bo
;
1132 image
->offset
= memoryOffset
;
1137 VkResult
anv_QueueBindSparse(
1139 uint32_t bindInfoCount
,
1140 const VkBindSparseInfo
* pBindInfo
,
1143 stub_return(VK_ERROR_INCOMPATIBLE_DRIVER
);
1146 VkResult
anv_CreateFence(
1148 const VkFenceCreateInfo
* pCreateInfo
,
1149 const VkAllocationCallbacks
* pAllocator
,
1152 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1153 struct anv_fence
*fence
;
1154 struct anv_batch batch
;
1157 const uint32_t fence_size
= 128;
1159 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_FENCE_CREATE_INFO
);
1161 fence
= anv_alloc2(&device
->alloc
, pAllocator
, sizeof(*fence
), 8,
1162 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
1164 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
1166 result
= anv_bo_init_new(&fence
->bo
, device
, fence_size
);
1167 if (result
!= VK_SUCCESS
)
1171 anv_gem_mmap(device
, fence
->bo
.gem_handle
, 0, fence
->bo
.size
);
1172 batch
.next
= batch
.start
= fence
->bo
.map
;
1173 batch
.end
= fence
->bo
.map
+ fence
->bo
.size
;
1174 anv_batch_emit(&batch
, GEN7_MI_BATCH_BUFFER_END
);
1175 anv_batch_emit(&batch
, GEN7_MI_NOOP
);
1177 fence
->exec2_objects
[0].handle
= fence
->bo
.gem_handle
;
1178 fence
->exec2_objects
[0].relocation_count
= 0;
1179 fence
->exec2_objects
[0].relocs_ptr
= 0;
1180 fence
->exec2_objects
[0].alignment
= 0;
1181 fence
->exec2_objects
[0].offset
= fence
->bo
.offset
;
1182 fence
->exec2_objects
[0].flags
= 0;
1183 fence
->exec2_objects
[0].rsvd1
= 0;
1184 fence
->exec2_objects
[0].rsvd2
= 0;
1186 fence
->execbuf
.buffers_ptr
= (uintptr_t) fence
->exec2_objects
;
1187 fence
->execbuf
.buffer_count
= 1;
1188 fence
->execbuf
.batch_start_offset
= 0;
1189 fence
->execbuf
.batch_len
= batch
.next
- fence
->bo
.map
;
1190 fence
->execbuf
.cliprects_ptr
= 0;
1191 fence
->execbuf
.num_cliprects
= 0;
1192 fence
->execbuf
.DR1
= 0;
1193 fence
->execbuf
.DR4
= 0;
1195 fence
->execbuf
.flags
=
1196 I915_EXEC_HANDLE_LUT
| I915_EXEC_NO_RELOC
| I915_EXEC_RENDER
;
1197 fence
->execbuf
.rsvd1
= device
->context_id
;
1198 fence
->execbuf
.rsvd2
= 0;
1200 *pFence
= anv_fence_to_handle(fence
);
1205 anv_free2(&device
->alloc
, pAllocator
, fence
);
1210 void anv_DestroyFence(
1213 const VkAllocationCallbacks
* pAllocator
)
1215 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1216 ANV_FROM_HANDLE(anv_fence
, fence
, _fence
);
1218 anv_gem_munmap(fence
->bo
.map
, fence
->bo
.size
);
1219 anv_gem_close(device
, fence
->bo
.gem_handle
);
1220 anv_free2(&device
->alloc
, pAllocator
, fence
);
1223 VkResult
anv_ResetFences(
1225 uint32_t fenceCount
,
1226 const VkFence
* pFences
)
1228 for (uint32_t i
= 0; i
< fenceCount
; i
++) {
1229 ANV_FROM_HANDLE(anv_fence
, fence
, pFences
[i
]);
1230 fence
->ready
= false;
1236 VkResult
anv_GetFenceStatus(
1240 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1241 ANV_FROM_HANDLE(anv_fence
, fence
, _fence
);
1248 ret
= anv_gem_wait(device
, fence
->bo
.gem_handle
, &t
);
1250 fence
->ready
= true;
1254 return VK_NOT_READY
;
1257 VkResult
anv_WaitForFences(
1259 uint32_t fenceCount
,
1260 const VkFence
* pFences
,
1264 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1266 /* DRM_IOCTL_I915_GEM_WAIT uses a signed 64 bit timeout and is supposed
1267 * to block indefinitely timeouts <= 0. Unfortunately, this was broken
1268 * for a couple of kernel releases. Since there's no way to know
1269 * whether or not the kernel we're using is one of the broken ones, the
1270 * best we can do is to clamp the timeout to INT64_MAX. This limits the
1271 * maximum timeout from 584 years to 292 years - likely not a big deal.
1273 if (timeout
> INT64_MAX
)
1274 timeout
= INT64_MAX
;
1276 int64_t t
= timeout
;
1278 /* FIXME: handle !waitAll */
1280 for (uint32_t i
= 0; i
< fenceCount
; i
++) {
1281 ANV_FROM_HANDLE(anv_fence
, fence
, pFences
[i
]);
1282 int ret
= anv_gem_wait(device
, fence
->bo
.gem_handle
, &t
);
1283 if (ret
== -1 && errno
== ETIME
) {
1285 } else if (ret
== -1) {
1286 /* We don't know the real error. */
1287 return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY
,
1288 "gem wait failed: %m");
1295 // Queue semaphore functions
1297 VkResult
anv_CreateSemaphore(
1299 const VkSemaphoreCreateInfo
* pCreateInfo
,
1300 const VkAllocationCallbacks
* pAllocator
,
1301 VkSemaphore
* pSemaphore
)
1303 *pSemaphore
= (VkSemaphore
)1;
1304 stub_return(VK_SUCCESS
);
1307 void anv_DestroySemaphore(
1309 VkSemaphore semaphore
,
1310 const VkAllocationCallbacks
* pAllocator
)
1317 VkResult
anv_CreateEvent(
1319 const VkEventCreateInfo
* pCreateInfo
,
1320 const VkAllocationCallbacks
* pAllocator
,
1323 stub_return(VK_ERROR_INCOMPATIBLE_DRIVER
);
1326 void anv_DestroyEvent(
1329 const VkAllocationCallbacks
* pAllocator
)
1334 VkResult
anv_GetEventStatus(
1338 stub_return(VK_ERROR_INCOMPATIBLE_DRIVER
);
1341 VkResult
anv_SetEvent(
1345 stub_return(VK_ERROR_INCOMPATIBLE_DRIVER
);
1348 VkResult
anv_ResetEvent(
1352 stub_return(VK_ERROR_INCOMPATIBLE_DRIVER
);
1357 VkResult
anv_CreateBuffer(
1359 const VkBufferCreateInfo
* pCreateInfo
,
1360 const VkAllocationCallbacks
* pAllocator
,
1363 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1364 struct anv_buffer
*buffer
;
1366 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO
);
1368 buffer
= anv_alloc2(&device
->alloc
, pAllocator
, sizeof(*buffer
), 8,
1369 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
1371 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
1373 buffer
->size
= pCreateInfo
->size
;
1377 *pBuffer
= anv_buffer_to_handle(buffer
);
1382 void anv_DestroyBuffer(
1385 const VkAllocationCallbacks
* pAllocator
)
1387 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1388 ANV_FROM_HANDLE(anv_buffer
, buffer
, _buffer
);
1390 anv_free2(&device
->alloc
, pAllocator
, buffer
);
1394 anv_fill_buffer_surface_state(struct anv_device
*device
, void *state
,
1395 const struct anv_format
*format
,
1396 uint32_t offset
, uint32_t range
, uint32_t stride
)
1398 switch (device
->info
.gen
) {
1400 if (device
->info
.is_haswell
)
1401 gen75_fill_buffer_surface_state(state
, format
, offset
, range
, stride
);
1403 gen7_fill_buffer_surface_state(state
, format
, offset
, range
, stride
);
1406 gen8_fill_buffer_surface_state(state
, format
, offset
, range
, stride
);
1409 gen9_fill_buffer_surface_state(state
, format
, offset
, range
, stride
);
1412 unreachable("unsupported gen\n");
1416 VkResult
anv_CreateBufferView(
1418 const VkBufferViewCreateInfo
* pCreateInfo
,
1419 const VkAllocationCallbacks
* pAllocator
,
1420 VkBufferView
* pView
)
1422 stub_return(VK_ERROR_INCOMPATIBLE_DRIVER
);
1425 void anv_DestroyBufferView(
1427 VkBufferView _bview
,
1428 const VkAllocationCallbacks
* pAllocator
)
1433 void anv_DestroySampler(
1436 const VkAllocationCallbacks
* pAllocator
)
1438 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1439 ANV_FROM_HANDLE(anv_sampler
, sampler
, _sampler
);
1441 anv_free2(&device
->alloc
, pAllocator
, sampler
);
1444 VkResult
anv_CreateFramebuffer(
1446 const VkFramebufferCreateInfo
* pCreateInfo
,
1447 const VkAllocationCallbacks
* pAllocator
,
1448 VkFramebuffer
* pFramebuffer
)
1450 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1451 struct anv_framebuffer
*framebuffer
;
1453 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO
);
1455 size_t size
= sizeof(*framebuffer
) +
1456 sizeof(struct anv_image_view
*) * pCreateInfo
->attachmentCount
;
1457 framebuffer
= anv_alloc2(&device
->alloc
, pAllocator
, size
, 8,
1458 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
1459 if (framebuffer
== NULL
)
1460 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
1462 framebuffer
->attachment_count
= pCreateInfo
->attachmentCount
;
1463 for (uint32_t i
= 0; i
< pCreateInfo
->attachmentCount
; i
++) {
1464 VkImageView _iview
= pCreateInfo
->pAttachments
[i
];
1465 framebuffer
->attachments
[i
] = anv_image_view_from_handle(_iview
);
1468 framebuffer
->width
= pCreateInfo
->width
;
1469 framebuffer
->height
= pCreateInfo
->height
;
1470 framebuffer
->layers
= pCreateInfo
->layers
;
1472 *pFramebuffer
= anv_framebuffer_to_handle(framebuffer
);
1477 void anv_DestroyFramebuffer(
1480 const VkAllocationCallbacks
* pAllocator
)
1482 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1483 ANV_FROM_HANDLE(anv_framebuffer
, fb
, _fb
);
1485 anv_free2(&device
->alloc
, pAllocator
, fb
);
1488 void vkCmdDbgMarkerBegin(
1489 VkCommandBuffer commandBuffer
,
1490 const char* pMarker
)
1491 __attribute__ ((visibility ("default")));
1493 void vkCmdDbgMarkerEnd(
1494 VkCommandBuffer commandBuffer
)
1495 __attribute__ ((visibility ("default")));
1497 void vkCmdDbgMarkerBegin(
1498 VkCommandBuffer commandBuffer
,
1499 const char* pMarker
)
1503 void vkCmdDbgMarkerEnd(
1504 VkCommandBuffer commandBuffer
)