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_UNSUPPORTED
,
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_UNSUPPORTED
) {
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 .dualSourceBlend
= true,
329 .multiDrawIndirect
= true,
331 .depthBiasClamp
= false,
332 .fillModeNonSolid
= true,
333 .depthBounds
= false,
336 .textureCompressionETC2
= true,
337 .textureCompressionASTC_LDR
= true,
338 .textureCompressionBC
= true,
339 .occlusionQueryNonConservative
= false, /* FINISHME */
340 .pipelineStatisticsQuery
= true,
341 .vertexSideEffects
= false,
342 .tessellationSideEffects
= false,
343 .geometrySideEffects
= false,
344 .fragmentSideEffects
= false,
345 .shaderTessellationPointSize
= false,
346 .shaderGeometryPointSize
= true,
347 .shaderImageGatherExtended
= true,
348 .shaderStorageImageExtendedFormats
= false,
349 .shaderStorageImageMultisample
= false,
350 .shaderUniformBufferArrayDynamicIndexing
= true,
351 .shaderSampledImageArrayDynamicIndexing
= false,
352 .shaderStorageBufferArrayDynamicIndexing
= false,
353 .shaderStorageImageArrayDynamicIndexing
= false,
354 .shaderClipDistance
= false,
355 .shaderCullDistance
= false,
356 .shaderFloat64
= false,
357 .shaderInt64
= false,
358 .shaderInt16
= false,
363 void anv_GetPhysicalDeviceProperties(
364 VkPhysicalDevice physicalDevice
,
365 VkPhysicalDeviceProperties
* pProperties
)
367 ANV_FROM_HANDLE(anv_physical_device
, pdevice
, physicalDevice
);
368 const struct brw_device_info
*devinfo
= pdevice
->info
;
370 anv_finishme("Get correct values for VkPhysicalDeviceLimits");
372 VkPhysicalDeviceLimits limits
= {
373 .maxImageDimension1D
= (1 << 14),
374 .maxImageDimension2D
= (1 << 14),
375 .maxImageDimension3D
= (1 << 10),
376 .maxImageDimensionCube
= (1 << 14),
377 .maxImageArrayLayers
= (1 << 10),
379 /* Broadwell supports 1, 2, 4, and 8 samples. */
382 .maxTexelBufferSize
= (1 << 14),
383 .maxUniformBufferSize
= UINT32_MAX
,
384 .maxStorageBufferSize
= UINT32_MAX
,
385 .maxPushConstantsSize
= MAX_PUSH_CONSTANTS_SIZE
,
386 .maxMemoryAllocationCount
= UINT32_MAX
,
387 .bufferImageGranularity
= 64, /* A cache line */
388 .sparseAddressSpaceSize
= 0,
389 .maxBoundDescriptorSets
= MAX_SETS
,
390 .maxDescriptorSets
= UINT32_MAX
,
391 .maxPerStageDescriptorSamplers
= 64,
392 .maxPerStageDescriptorUniformBuffers
= 64,
393 .maxPerStageDescriptorStorageBuffers
= 64,
394 .maxPerStageDescriptorSampledImages
= 64,
395 .maxPerStageDescriptorStorageImages
= 64,
396 .maxDescriptorSetSamplers
= 256,
397 .maxDescriptorSetUniformBuffers
= 256,
398 .maxDescriptorSetUniformBuffersDynamic
= 256,
399 .maxDescriptorSetStorageBuffers
= 256,
400 .maxDescriptorSetStorageBuffersDynamic
= 256,
401 .maxDescriptorSetSampledImages
= 256,
402 .maxDescriptorSetStorageImages
= 256,
403 .maxVertexInputAttributes
= 32,
404 .maxVertexInputBindings
= 32,
405 .maxVertexInputAttributeOffset
= 256,
406 .maxVertexInputBindingStride
= 256,
407 .maxVertexOutputComponents
= 32,
408 .maxTessGenLevel
= 0,
409 .maxTessPatchSize
= 0,
410 .maxTessControlPerVertexInputComponents
= 0,
411 .maxTessControlPerVertexOutputComponents
= 0,
412 .maxTessControlPerPatchOutputComponents
= 0,
413 .maxTessControlTotalOutputComponents
= 0,
414 .maxTessEvaluationInputComponents
= 0,
415 .maxTessEvaluationOutputComponents
= 0,
416 .maxGeometryShaderInvocations
= 6,
417 .maxGeometryInputComponents
= 16,
418 .maxGeometryOutputComponents
= 16,
419 .maxGeometryOutputVertices
= 16,
420 .maxGeometryTotalOutputComponents
= 16,
421 .maxFragmentInputComponents
= 16,
422 .maxFragmentOutputBuffers
= 8,
423 .maxFragmentDualSourceBuffers
= 2,
424 .maxFragmentCombinedOutputResources
= 8,
425 .maxComputeSharedMemorySize
= 1024,
426 .maxComputeWorkGroupCount
= {
427 16 * devinfo
->max_cs_threads
,
428 16 * devinfo
->max_cs_threads
,
429 16 * devinfo
->max_cs_threads
,
431 .maxComputeWorkGroupInvocations
= 16 * devinfo
->max_cs_threads
,
432 .maxComputeWorkGroupSize
= {
433 16 * devinfo
->max_cs_threads
,
434 16 * devinfo
->max_cs_threads
,
435 16 * devinfo
->max_cs_threads
,
437 .subPixelPrecisionBits
= 4 /* FIXME */,
438 .subTexelPrecisionBits
= 4 /* FIXME */,
439 .mipmapPrecisionBits
= 4 /* FIXME */,
440 .maxDrawIndexedIndexValue
= UINT32_MAX
,
441 .maxDrawIndirectInstanceCount
= UINT32_MAX
,
442 .primitiveRestartForPatches
= UINT32_MAX
,
443 .maxSamplerLodBias
= 16,
444 .maxSamplerAnisotropy
= 16,
445 .maxViewports
= MAX_VIEWPORTS
,
446 .maxViewportDimensions
= { (1 << 14), (1 << 14) },
447 .viewportBoundsRange
= { -1.0, 1.0 }, /* FIXME */
448 .viewportSubPixelBits
= 13, /* We take a float? */
449 .minMemoryMapAlignment
= 64, /* A cache line */
450 .minTexelBufferOffsetAlignment
= 1,
451 .minUniformBufferOffsetAlignment
= 1,
452 .minStorageBufferOffsetAlignment
= 1,
453 .minTexelOffset
= 0, /* FIXME */
454 .maxTexelOffset
= 0, /* FIXME */
455 .minTexelGatherOffset
= 0, /* FIXME */
456 .maxTexelGatherOffset
= 0, /* FIXME */
457 .minInterpolationOffset
= 0, /* FIXME */
458 .maxInterpolationOffset
= 0, /* FIXME */
459 .subPixelInterpolationOffsetBits
= 0, /* FIXME */
460 .maxFramebufferWidth
= (1 << 14),
461 .maxFramebufferHeight
= (1 << 14),
462 .maxFramebufferLayers
= (1 << 10),
463 .maxFramebufferColorSamples
= 8,
464 .maxFramebufferDepthSamples
= 8,
465 .maxFramebufferStencilSamples
= 8,
466 .maxColorAttachments
= MAX_RTS
,
467 .maxSampledImageColorSamples
= 8,
468 .maxSampledImageDepthSamples
= 8,
469 .maxSampledImageIntegerSamples
= 1,
470 .maxStorageImageSamples
= 1,
471 .maxSampleMaskWords
= 1,
472 .timestampFrequency
= 1000 * 1000 * 1000 / 80,
473 .maxClipDistances
= 0 /* FIXME */,
474 .maxCullDistances
= 0 /* FIXME */,
475 .maxCombinedClipAndCullDistances
= 0 /* FIXME */,
476 .pointSizeRange
= { 0.125, 255.875 },
477 .lineWidthRange
= { 0.0, 7.9921875 },
478 .pointSizeGranularity
= (1.0 / 8.0),
479 .lineWidthGranularity
= (1.0 / 128.0),
482 *pProperties
= (VkPhysicalDeviceProperties
) {
483 .apiVersion
= VK_MAKE_VERSION(0, 170, 2),
486 .deviceID
= pdevice
->chipset_id
,
487 .deviceType
= VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU
,
489 .sparseProperties
= {0}, /* Broadwell doesn't do sparse. */
492 strcpy(pProperties
->deviceName
, pdevice
->name
);
493 snprintf((char *)pProperties
->pipelineCacheUUID
, VK_UUID_SIZE
,
494 "anv-%s", MESA_GIT_SHA1
+ 4);
497 void anv_GetPhysicalDeviceQueueFamilyProperties(
498 VkPhysicalDevice physicalDevice
,
500 VkQueueFamilyProperties
* pQueueFamilyProperties
)
502 if (pQueueFamilyProperties
== NULL
) {
507 assert(*pCount
>= 1);
509 *pQueueFamilyProperties
= (VkQueueFamilyProperties
) {
510 .queueFlags
= VK_QUEUE_GRAPHICS_BIT
|
511 VK_QUEUE_COMPUTE_BIT
|
512 VK_QUEUE_TRANSFER_BIT
,
514 .supportsTimestamps
= true,
518 void anv_GetPhysicalDeviceMemoryProperties(
519 VkPhysicalDevice physicalDevice
,
520 VkPhysicalDeviceMemoryProperties
* pMemoryProperties
)
522 ANV_FROM_HANDLE(anv_physical_device
, physical_device
, physicalDevice
);
523 VkDeviceSize heap_size
;
525 /* Reserve some wiggle room for the driver by exposing only 75% of the
526 * aperture to the heap.
528 heap_size
= 3 * physical_device
->aperture_size
/ 4;
530 /* The property flags below are valid only for llc platforms. */
531 pMemoryProperties
->memoryTypeCount
= 1;
532 pMemoryProperties
->memoryTypes
[0] = (VkMemoryType
) {
533 .propertyFlags
= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
,
537 pMemoryProperties
->memoryHeapCount
= 1;
538 pMemoryProperties
->memoryHeaps
[0] = (VkMemoryHeap
) {
540 .flags
= VK_MEMORY_HEAP_HOST_LOCAL_BIT
,
544 PFN_vkVoidFunction
anv_GetInstanceProcAddr(
548 return anv_lookup_entrypoint(pName
);
551 PFN_vkVoidFunction
anv_GetDeviceProcAddr(
555 return anv_lookup_entrypoint(pName
);
559 anv_queue_init(struct anv_device
*device
, struct anv_queue
*queue
)
561 queue
->_loader_data
.loaderMagic
= ICD_LOADER_MAGIC
;
562 queue
->device
= device
;
563 queue
->pool
= &device
->surface_state_pool
;
569 anv_queue_finish(struct anv_queue
*queue
)
574 anv_device_init_border_colors(struct anv_device
*device
)
576 static const VkClearColorValue border_colors
[] = {
577 [VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK
] = { .float32
= { 0.0, 0.0, 0.0, 0.0 } },
578 [VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK
] = { .float32
= { 0.0, 0.0, 0.0, 1.0 } },
579 [VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE
] = { .float32
= { 1.0, 1.0, 1.0, 1.0 } },
580 [VK_BORDER_COLOR_INT_TRANSPARENT_BLACK
] = { .uint32
= { 0, 0, 0, 0 } },
581 [VK_BORDER_COLOR_INT_OPAQUE_BLACK
] = { .uint32
= { 0, 0, 0, 1 } },
582 [VK_BORDER_COLOR_INT_OPAQUE_WHITE
] = { .uint32
= { 1, 1, 1, 1 } },
585 device
->border_colors
=
586 anv_state_pool_alloc(&device
->dynamic_state_pool
,
587 sizeof(border_colors
), 32);
588 memcpy(device
->border_colors
.map
, border_colors
, sizeof(border_colors
));
591 VkResult
anv_CreateDevice(
592 VkPhysicalDevice physicalDevice
,
593 const VkDeviceCreateInfo
* pCreateInfo
,
594 const VkAllocationCallbacks
* pAllocator
,
597 ANV_FROM_HANDLE(anv_physical_device
, physical_device
, physicalDevice
);
598 struct anv_device
*device
;
600 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO
);
602 for (uint32_t i
= 0; i
< pCreateInfo
->enabledExtensionNameCount
; i
++) {
604 for (uint32_t j
= 0; j
< ARRAY_SIZE(device_extensions
); j
++) {
605 if (strcmp(pCreateInfo
->ppEnabledExtensionNames
[i
],
606 device_extensions
[j
].extensionName
) == 0) {
612 return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT
);
615 anv_set_dispatch_devinfo(physical_device
->info
);
617 device
= anv_alloc2(&physical_device
->instance
->alloc
, pAllocator
,
619 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
621 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
623 device
->_loader_data
.loaderMagic
= ICD_LOADER_MAGIC
;
624 device
->instance
= physical_device
->instance
;
627 device
->alloc
= *pAllocator
;
629 device
->alloc
= physical_device
->instance
->alloc
;
631 /* XXX(chadv): Can we dup() physicalDevice->fd here? */
632 device
->fd
= open(physical_device
->path
, O_RDWR
| O_CLOEXEC
);
633 if (device
->fd
== -1)
636 device
->context_id
= anv_gem_create_context(device
);
637 if (device
->context_id
== -1)
640 pthread_mutex_init(&device
->mutex
, NULL
);
642 anv_bo_pool_init(&device
->batch_bo_pool
, device
, ANV_CMD_BUFFER_BATCH_SIZE
);
644 anv_block_pool_init(&device
->dynamic_state_block_pool
, device
, 2048);
646 anv_state_pool_init(&device
->dynamic_state_pool
,
647 &device
->dynamic_state_block_pool
);
649 anv_block_pool_init(&device
->instruction_block_pool
, device
, 4096);
650 anv_block_pool_init(&device
->surface_state_block_pool
, device
, 4096);
652 anv_state_pool_init(&device
->surface_state_pool
,
653 &device
->surface_state_block_pool
);
655 anv_bo_init_new(&device
->workaround_bo
, device
, 1024);
657 anv_block_pool_init(&device
->scratch_block_pool
, device
, 0x10000);
659 device
->info
= *physical_device
->info
;
660 device
->isl_dev
= physical_device
->isl_dev
;
662 anv_queue_init(device
, &device
->queue
);
664 anv_device_init_meta(device
);
666 anv_device_init_border_colors(device
);
668 *pDevice
= anv_device_to_handle(device
);
675 anv_free(&device
->alloc
, device
);
677 return vk_error(VK_ERROR_INITIALIZATION_FAILED
);
680 void anv_DestroyDevice(
682 const VkAllocationCallbacks
* pAllocator
)
684 ANV_FROM_HANDLE(anv_device
, device
, _device
);
686 anv_queue_finish(&device
->queue
);
688 anv_device_finish_meta(device
);
691 /* We only need to free these to prevent valgrind errors. The backing
692 * BO will go away in a couple of lines so we don't actually leak.
694 anv_state_pool_free(&device
->dynamic_state_pool
, device
->border_colors
);
697 anv_gem_munmap(device
->workaround_bo
.map
, device
->workaround_bo
.size
);
698 anv_gem_close(device
, device
->workaround_bo
.gem_handle
);
700 anv_bo_pool_finish(&device
->batch_bo_pool
);
701 anv_state_pool_finish(&device
->dynamic_state_pool
);
702 anv_block_pool_finish(&device
->dynamic_state_block_pool
);
703 anv_block_pool_finish(&device
->instruction_block_pool
);
704 anv_state_pool_finish(&device
->surface_state_pool
);
705 anv_block_pool_finish(&device
->surface_state_block_pool
);
706 anv_block_pool_finish(&device
->scratch_block_pool
);
710 anv_free(&device
->alloc
, device
);
713 VkResult
anv_EnumerateInstanceExtensionProperties(
714 const char* pLayerName
,
715 uint32_t* pPropertyCount
,
716 VkExtensionProperties
* pProperties
)
718 if (pProperties
== NULL
) {
719 *pPropertyCount
= ARRAY_SIZE(global_extensions
);
723 assert(*pPropertyCount
>= ARRAY_SIZE(global_extensions
));
725 *pPropertyCount
= ARRAY_SIZE(global_extensions
);
726 memcpy(pProperties
, global_extensions
, sizeof(global_extensions
));
731 VkResult
anv_EnumerateDeviceExtensionProperties(
732 VkPhysicalDevice physicalDevice
,
733 const char* pLayerName
,
734 uint32_t* pPropertyCount
,
735 VkExtensionProperties
* pProperties
)
737 if (pProperties
== NULL
) {
738 *pPropertyCount
= ARRAY_SIZE(device_extensions
);
742 assert(*pPropertyCount
>= ARRAY_SIZE(device_extensions
));
744 *pPropertyCount
= ARRAY_SIZE(device_extensions
);
745 memcpy(pProperties
, device_extensions
, sizeof(device_extensions
));
750 VkResult
anv_EnumerateInstanceLayerProperties(
751 uint32_t* pPropertyCount
,
752 VkLayerProperties
* pProperties
)
754 if (pProperties
== NULL
) {
759 /* None supported at this time */
760 return vk_error(VK_ERROR_LAYER_NOT_PRESENT
);
763 VkResult
anv_EnumerateDeviceLayerProperties(
764 VkPhysicalDevice physicalDevice
,
765 uint32_t* pPropertyCount
,
766 VkLayerProperties
* pProperties
)
768 if (pProperties
== NULL
) {
773 /* None supported at this time */
774 return vk_error(VK_ERROR_LAYER_NOT_PRESENT
);
777 void anv_GetDeviceQueue(
779 uint32_t queueNodeIndex
,
783 ANV_FROM_HANDLE(anv_device
, device
, _device
);
785 assert(queueIndex
== 0);
787 *pQueue
= anv_queue_to_handle(&device
->queue
);
790 VkResult
anv_QueueSubmit(
792 uint32_t commandBufferCount
,
793 const VkCommandBuffer
* pCommandBuffers
,
796 ANV_FROM_HANDLE(anv_queue
, queue
, _queue
);
797 ANV_FROM_HANDLE(anv_fence
, fence
, _fence
);
798 struct anv_device
*device
= queue
->device
;
801 for (uint32_t i
= 0; i
< commandBufferCount
; i
++) {
802 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, pCommandBuffers
[i
]);
804 assert(cmd_buffer
->level
== VK_COMMAND_BUFFER_LEVEL_PRIMARY
);
806 ret
= anv_gem_execbuffer(device
, &cmd_buffer
->execbuf2
.execbuf
);
808 /* We don't know the real error. */
809 return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY
,
810 "execbuf2 failed: %m");
814 ret
= anv_gem_execbuffer(device
, &fence
->execbuf
);
816 /* We don't know the real error. */
817 return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY
,
818 "execbuf2 failed: %m");
822 for (uint32_t i
= 0; i
< cmd_buffer
->execbuf2
.bo_count
; i
++)
823 cmd_buffer
->execbuf2
.bos
[i
]->offset
= cmd_buffer
->execbuf2
.objects
[i
].offset
;
829 VkResult
anv_QueueWaitIdle(
832 ANV_FROM_HANDLE(anv_queue
, queue
, _queue
);
834 return ANV_CALL(DeviceWaitIdle
)(anv_device_to_handle(queue
->device
));
837 VkResult
anv_DeviceWaitIdle(
840 ANV_FROM_HANDLE(anv_device
, device
, _device
);
841 struct anv_state state
;
842 struct anv_batch batch
;
843 struct drm_i915_gem_execbuffer2 execbuf
;
844 struct drm_i915_gem_exec_object2 exec2_objects
[1];
845 struct anv_bo
*bo
= NULL
;
850 state
= anv_state_pool_alloc(&device
->dynamic_state_pool
, 32, 32);
851 bo
= &device
->dynamic_state_pool
.block_pool
->bo
;
852 batch
.start
= batch
.next
= state
.map
;
853 batch
.end
= state
.map
+ 32;
854 anv_batch_emit(&batch
, GEN7_MI_BATCH_BUFFER_END
);
855 anv_batch_emit(&batch
, GEN7_MI_NOOP
);
857 exec2_objects
[0].handle
= bo
->gem_handle
;
858 exec2_objects
[0].relocation_count
= 0;
859 exec2_objects
[0].relocs_ptr
= 0;
860 exec2_objects
[0].alignment
= 0;
861 exec2_objects
[0].offset
= bo
->offset
;
862 exec2_objects
[0].flags
= 0;
863 exec2_objects
[0].rsvd1
= 0;
864 exec2_objects
[0].rsvd2
= 0;
866 execbuf
.buffers_ptr
= (uintptr_t) exec2_objects
;
867 execbuf
.buffer_count
= 1;
868 execbuf
.batch_start_offset
= state
.offset
;
869 execbuf
.batch_len
= batch
.next
- state
.map
;
870 execbuf
.cliprects_ptr
= 0;
871 execbuf
.num_cliprects
= 0;
876 I915_EXEC_HANDLE_LUT
| I915_EXEC_NO_RELOC
| I915_EXEC_RENDER
;
877 execbuf
.rsvd1
= device
->context_id
;
880 ret
= anv_gem_execbuffer(device
, &execbuf
);
882 /* We don't know the real error. */
883 result
= vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY
, "execbuf2 failed: %m");
888 ret
= anv_gem_wait(device
, bo
->gem_handle
, &timeout
);
890 /* We don't know the real error. */
891 result
= vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY
, "execbuf2 failed: %m");
895 anv_state_pool_free(&device
->dynamic_state_pool
, state
);
900 anv_state_pool_free(&device
->dynamic_state_pool
, state
);
906 anv_bo_init_new(struct anv_bo
*bo
, struct anv_device
*device
, uint64_t size
)
908 bo
->gem_handle
= anv_gem_create(device
, size
);
910 return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY
);
920 VkResult
anv_AllocateMemory(
922 const VkMemoryAllocateInfo
* pAllocateInfo
,
923 const VkAllocationCallbacks
* pAllocator
,
924 VkDeviceMemory
* pMem
)
926 ANV_FROM_HANDLE(anv_device
, device
, _device
);
927 struct anv_device_memory
*mem
;
930 assert(pAllocateInfo
->sType
== VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO
);
932 /* We support exactly one memory heap. */
933 assert(pAllocateInfo
->memoryTypeIndex
== 0);
935 /* FINISHME: Fail if allocation request exceeds heap size. */
937 mem
= anv_alloc2(&device
->alloc
, pAllocator
, sizeof(*mem
), 8,
938 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
940 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
942 result
= anv_bo_init_new(&mem
->bo
, device
, pAllocateInfo
->allocationSize
);
943 if (result
!= VK_SUCCESS
)
946 *pMem
= anv_device_memory_to_handle(mem
);
951 anv_free2(&device
->alloc
, pAllocator
, mem
);
959 const VkAllocationCallbacks
* pAllocator
)
961 ANV_FROM_HANDLE(anv_device
, device
, _device
);
962 ANV_FROM_HANDLE(anv_device_memory
, mem
, _mem
);
965 anv_gem_munmap(mem
->bo
.map
, mem
->bo
.size
);
967 if (mem
->bo
.gem_handle
!= 0)
968 anv_gem_close(device
, mem
->bo
.gem_handle
);
970 anv_free2(&device
->alloc
, pAllocator
, mem
);
973 VkResult
anv_MapMemory(
975 VkDeviceMemory _memory
,
978 VkMemoryMapFlags flags
,
981 ANV_FROM_HANDLE(anv_device
, device
, _device
);
982 ANV_FROM_HANDLE(anv_device_memory
, mem
, _memory
);
984 /* FIXME: Is this supposed to be thread safe? Since vkUnmapMemory() only
985 * takes a VkDeviceMemory pointer, it seems like only one map of the memory
986 * at a time is valid. We could just mmap up front and return an offset
987 * pointer here, but that may exhaust virtual memory on 32 bit
990 mem
->map
= anv_gem_mmap(device
, mem
->bo
.gem_handle
, offset
, size
);
991 mem
->map_size
= size
;
998 void anv_UnmapMemory(
1000 VkDeviceMemory _memory
)
1002 ANV_FROM_HANDLE(anv_device_memory
, mem
, _memory
);
1004 anv_gem_munmap(mem
->map
, mem
->map_size
);
1007 VkResult
anv_FlushMappedMemoryRanges(
1009 uint32_t memoryRangeCount
,
1010 const VkMappedMemoryRange
* pMemoryRanges
)
1012 /* clflush here for !llc platforms */
1017 VkResult
anv_InvalidateMappedMemoryRanges(
1019 uint32_t memoryRangeCount
,
1020 const VkMappedMemoryRange
* pMemoryRanges
)
1022 return anv_FlushMappedMemoryRanges(device
, memoryRangeCount
, pMemoryRanges
);
1025 void anv_GetBufferMemoryRequirements(
1028 VkMemoryRequirements
* pMemoryRequirements
)
1030 ANV_FROM_HANDLE(anv_buffer
, buffer
, _buffer
);
1032 /* The Vulkan spec (git aaed022) says:
1034 * memoryTypeBits is a bitfield and contains one bit set for every
1035 * supported memory type for the resource. The bit `1<<i` is set if and
1036 * only if the memory type `i` in the VkPhysicalDeviceMemoryProperties
1037 * structure for the physical device is supported.
1039 * We support exactly one memory type.
1041 pMemoryRequirements
->memoryTypeBits
= 1;
1043 pMemoryRequirements
->size
= buffer
->size
;
1044 pMemoryRequirements
->alignment
= 16;
1047 void anv_GetImageMemoryRequirements(
1050 VkMemoryRequirements
* pMemoryRequirements
)
1052 ANV_FROM_HANDLE(anv_image
, image
, _image
);
1054 /* The Vulkan spec (git aaed022) says:
1056 * memoryTypeBits is a bitfield and contains one bit set for every
1057 * supported memory type for the resource. The bit `1<<i` is set if and
1058 * only if the memory type `i` in the VkPhysicalDeviceMemoryProperties
1059 * structure for the physical device is supported.
1061 * We support exactly one memory type.
1063 pMemoryRequirements
->memoryTypeBits
= 1;
1065 pMemoryRequirements
->size
= image
->size
;
1066 pMemoryRequirements
->alignment
= image
->alignment
;
1069 void anv_GetImageSparseMemoryRequirements(
1072 uint32_t* pNumRequirements
,
1073 VkSparseImageMemoryRequirements
* pSparseMemoryRequirements
)
1078 void anv_GetDeviceMemoryCommitment(
1080 VkDeviceMemory memory
,
1081 VkDeviceSize
* pCommittedMemoryInBytes
)
1083 *pCommittedMemoryInBytes
= 0;
1086 VkResult
anv_BindBufferMemory(
1089 VkDeviceMemory _memory
,
1090 VkDeviceSize memoryOffset
)
1092 ANV_FROM_HANDLE(anv_device_memory
, mem
, _memory
);
1093 ANV_FROM_HANDLE(anv_buffer
, buffer
, _buffer
);
1095 buffer
->bo
= &mem
->bo
;
1096 buffer
->offset
= memoryOffset
;
1101 VkResult
anv_BindImageMemory(
1104 VkDeviceMemory _memory
,
1105 VkDeviceSize memoryOffset
)
1107 ANV_FROM_HANDLE(anv_device_memory
, mem
, _memory
);
1108 ANV_FROM_HANDLE(anv_image
, image
, _image
);
1110 image
->bo
= &mem
->bo
;
1111 image
->offset
= memoryOffset
;
1116 VkResult
anv_QueueBindSparse(
1118 uint32_t bindInfoCount
,
1119 const VkBindSparseInfo
* pBindInfo
,
1122 stub_return(VK_UNSUPPORTED
);
1125 VkResult
anv_CreateFence(
1127 const VkFenceCreateInfo
* pCreateInfo
,
1128 const VkAllocationCallbacks
* pAllocator
,
1131 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1132 struct anv_fence
*fence
;
1133 struct anv_batch batch
;
1136 const uint32_t fence_size
= 128;
1138 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_FENCE_CREATE_INFO
);
1140 fence
= anv_alloc2(&device
->alloc
, pAllocator
, sizeof(*fence
), 8,
1141 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
1143 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
1145 result
= anv_bo_init_new(&fence
->bo
, device
, fence_size
);
1146 if (result
!= VK_SUCCESS
)
1150 anv_gem_mmap(device
, fence
->bo
.gem_handle
, 0, fence
->bo
.size
);
1151 batch
.next
= batch
.start
= fence
->bo
.map
;
1152 batch
.end
= fence
->bo
.map
+ fence
->bo
.size
;
1153 anv_batch_emit(&batch
, GEN7_MI_BATCH_BUFFER_END
);
1154 anv_batch_emit(&batch
, GEN7_MI_NOOP
);
1156 fence
->exec2_objects
[0].handle
= fence
->bo
.gem_handle
;
1157 fence
->exec2_objects
[0].relocation_count
= 0;
1158 fence
->exec2_objects
[0].relocs_ptr
= 0;
1159 fence
->exec2_objects
[0].alignment
= 0;
1160 fence
->exec2_objects
[0].offset
= fence
->bo
.offset
;
1161 fence
->exec2_objects
[0].flags
= 0;
1162 fence
->exec2_objects
[0].rsvd1
= 0;
1163 fence
->exec2_objects
[0].rsvd2
= 0;
1165 fence
->execbuf
.buffers_ptr
= (uintptr_t) fence
->exec2_objects
;
1166 fence
->execbuf
.buffer_count
= 1;
1167 fence
->execbuf
.batch_start_offset
= 0;
1168 fence
->execbuf
.batch_len
= batch
.next
- fence
->bo
.map
;
1169 fence
->execbuf
.cliprects_ptr
= 0;
1170 fence
->execbuf
.num_cliprects
= 0;
1171 fence
->execbuf
.DR1
= 0;
1172 fence
->execbuf
.DR4
= 0;
1174 fence
->execbuf
.flags
=
1175 I915_EXEC_HANDLE_LUT
| I915_EXEC_NO_RELOC
| I915_EXEC_RENDER
;
1176 fence
->execbuf
.rsvd1
= device
->context_id
;
1177 fence
->execbuf
.rsvd2
= 0;
1179 *pFence
= anv_fence_to_handle(fence
);
1184 anv_free2(&device
->alloc
, pAllocator
, fence
);
1189 void anv_DestroyFence(
1192 const VkAllocationCallbacks
* pAllocator
)
1194 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1195 ANV_FROM_HANDLE(anv_fence
, fence
, _fence
);
1197 anv_gem_munmap(fence
->bo
.map
, fence
->bo
.size
);
1198 anv_gem_close(device
, fence
->bo
.gem_handle
);
1199 anv_free2(&device
->alloc
, pAllocator
, fence
);
1202 VkResult
anv_ResetFences(
1204 uint32_t fenceCount
,
1205 const VkFence
* pFences
)
1207 for (uint32_t i
= 0; i
< fenceCount
; i
++) {
1208 ANV_FROM_HANDLE(anv_fence
, fence
, pFences
[i
]);
1209 fence
->ready
= false;
1215 VkResult
anv_GetFenceStatus(
1219 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1220 ANV_FROM_HANDLE(anv_fence
, fence
, _fence
);
1227 ret
= anv_gem_wait(device
, fence
->bo
.gem_handle
, &t
);
1229 fence
->ready
= true;
1233 return VK_NOT_READY
;
1236 VkResult
anv_WaitForFences(
1238 uint32_t fenceCount
,
1239 const VkFence
* pFences
,
1243 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1245 /* DRM_IOCTL_I915_GEM_WAIT uses a signed 64 bit timeout and is supposed
1246 * to block indefinitely timeouts <= 0. Unfortunately, this was broken
1247 * for a couple of kernel releases. Since there's no way to know
1248 * whether or not the kernel we're using is one of the broken ones, the
1249 * best we can do is to clamp the timeout to INT64_MAX. This limits the
1250 * maximum timeout from 584 years to 292 years - likely not a big deal.
1252 if (timeout
> INT64_MAX
)
1253 timeout
= INT64_MAX
;
1255 int64_t t
= timeout
;
1257 /* FIXME: handle !waitAll */
1259 for (uint32_t i
= 0; i
< fenceCount
; i
++) {
1260 ANV_FROM_HANDLE(anv_fence
, fence
, pFences
[i
]);
1261 int ret
= anv_gem_wait(device
, fence
->bo
.gem_handle
, &t
);
1262 if (ret
== -1 && errno
== ETIME
) {
1264 } else if (ret
== -1) {
1265 /* We don't know the real error. */
1266 return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY
,
1267 "gem wait failed: %m");
1274 // Queue semaphore functions
1276 VkResult
anv_CreateSemaphore(
1278 const VkSemaphoreCreateInfo
* pCreateInfo
,
1279 const VkAllocationCallbacks
* pAllocator
,
1280 VkSemaphore
* pSemaphore
)
1282 *pSemaphore
= (VkSemaphore
)1;
1283 stub_return(VK_SUCCESS
);
1286 void anv_DestroySemaphore(
1288 VkSemaphore semaphore
,
1289 const VkAllocationCallbacks
* pAllocator
)
1294 VkResult
anv_QueueSignalSemaphore(
1296 VkSemaphore semaphore
)
1298 stub_return(VK_UNSUPPORTED
);
1301 VkResult
anv_QueueWaitSemaphore(
1303 VkSemaphore semaphore
)
1305 stub_return(VK_UNSUPPORTED
);
1310 VkResult
anv_CreateEvent(
1312 const VkEventCreateInfo
* pCreateInfo
,
1313 const VkAllocationCallbacks
* pAllocator
,
1316 stub_return(VK_UNSUPPORTED
);
1319 void anv_DestroyEvent(
1322 const VkAllocationCallbacks
* pAllocator
)
1327 VkResult
anv_GetEventStatus(
1331 stub_return(VK_UNSUPPORTED
);
1334 VkResult
anv_SetEvent(
1338 stub_return(VK_UNSUPPORTED
);
1341 VkResult
anv_ResetEvent(
1345 stub_return(VK_UNSUPPORTED
);
1350 VkResult
anv_CreateBuffer(
1352 const VkBufferCreateInfo
* pCreateInfo
,
1353 const VkAllocationCallbacks
* pAllocator
,
1356 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1357 struct anv_buffer
*buffer
;
1359 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO
);
1361 buffer
= anv_alloc2(&device
->alloc
, pAllocator
, sizeof(*buffer
), 8,
1362 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
1364 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
1366 buffer
->size
= pCreateInfo
->size
;
1370 *pBuffer
= anv_buffer_to_handle(buffer
);
1375 void anv_DestroyBuffer(
1378 const VkAllocationCallbacks
* pAllocator
)
1380 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1381 ANV_FROM_HANDLE(anv_buffer
, buffer
, _buffer
);
1383 anv_free2(&device
->alloc
, pAllocator
, buffer
);
1387 anv_fill_buffer_surface_state(struct anv_device
*device
, void *state
,
1388 const struct anv_format
*format
,
1389 uint32_t offset
, uint32_t range
, uint32_t stride
)
1391 switch (device
->info
.gen
) {
1393 if (device
->info
.is_haswell
)
1394 gen75_fill_buffer_surface_state(state
, format
, offset
, range
, stride
);
1396 gen7_fill_buffer_surface_state(state
, format
, offset
, range
, stride
);
1399 gen8_fill_buffer_surface_state(state
, format
, offset
, range
, stride
);
1402 gen9_fill_buffer_surface_state(state
, format
, offset
, range
, stride
);
1405 unreachable("unsupported gen\n");
1409 VkResult
anv_CreateBufferView(
1411 const VkBufferViewCreateInfo
* pCreateInfo
,
1412 const VkAllocationCallbacks
* pAllocator
,
1413 VkBufferView
* pView
)
1415 stub_return(VK_UNSUPPORTED
);
1418 void anv_DestroyBufferView(
1420 VkBufferView _bview
,
1421 const VkAllocationCallbacks
* pAllocator
)
1426 void anv_DestroySampler(
1429 const VkAllocationCallbacks
* pAllocator
)
1431 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1432 ANV_FROM_HANDLE(anv_sampler
, sampler
, _sampler
);
1434 anv_free2(&device
->alloc
, pAllocator
, sampler
);
1437 VkResult
anv_CreateFramebuffer(
1439 const VkFramebufferCreateInfo
* pCreateInfo
,
1440 const VkAllocationCallbacks
* pAllocator
,
1441 VkFramebuffer
* pFramebuffer
)
1443 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1444 struct anv_framebuffer
*framebuffer
;
1446 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO
);
1448 size_t size
= sizeof(*framebuffer
) +
1449 sizeof(struct anv_image_view
*) * pCreateInfo
->attachmentCount
;
1450 framebuffer
= anv_alloc2(&device
->alloc
, pAllocator
, size
, 8,
1451 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
1452 if (framebuffer
== NULL
)
1453 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
1455 framebuffer
->attachment_count
= pCreateInfo
->attachmentCount
;
1456 for (uint32_t i
= 0; i
< pCreateInfo
->attachmentCount
; i
++) {
1457 VkImageView _iview
= pCreateInfo
->pAttachments
[i
];
1458 framebuffer
->attachments
[i
] = anv_image_view_from_handle(_iview
);
1461 framebuffer
->width
= pCreateInfo
->width
;
1462 framebuffer
->height
= pCreateInfo
->height
;
1463 framebuffer
->layers
= pCreateInfo
->layers
;
1465 *pFramebuffer
= anv_framebuffer_to_handle(framebuffer
);
1470 void anv_DestroyFramebuffer(
1473 const VkAllocationCallbacks
* pAllocator
)
1475 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1476 ANV_FROM_HANDLE(anv_framebuffer
, fb
, _fb
);
1478 anv_free2(&device
->alloc
, pAllocator
, fb
);
1481 void vkCmdDbgMarkerBegin(
1482 VkCommandBuffer commandBuffer
,
1483 const char* pMarker
)
1484 __attribute__ ((visibility ("default")));
1486 void vkCmdDbgMarkerEnd(
1487 VkCommandBuffer commandBuffer
)
1488 __attribute__ ((visibility ("default")));
1490 void vkCmdDbgMarkerBegin(
1491 VkCommandBuffer commandBuffer
,
1492 const char* pMarker
)
1496 void vkCmdDbgMarkerEnd(
1497 VkCommandBuffer commandBuffer
)