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 .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_DEVICE_LOCAL_BIT
|
534 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
|
535 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
|
536 VK_MEMORY_PROPERTY_HOST_CACHED_BIT
,
540 pMemoryProperties
->memoryHeapCount
= 1;
541 pMemoryProperties
->memoryHeaps
[0] = (VkMemoryHeap
) {
543 .flags
= VK_MEMORY_HEAP_DEVICE_LOCAL_BIT
,
547 PFN_vkVoidFunction
anv_GetInstanceProcAddr(
551 return anv_lookup_entrypoint(pName
);
554 PFN_vkVoidFunction
anv_GetDeviceProcAddr(
558 return anv_lookup_entrypoint(pName
);
562 anv_queue_init(struct anv_device
*device
, struct anv_queue
*queue
)
564 queue
->_loader_data
.loaderMagic
= ICD_LOADER_MAGIC
;
565 queue
->device
= device
;
566 queue
->pool
= &device
->surface_state_pool
;
572 anv_queue_finish(struct anv_queue
*queue
)
577 anv_device_init_border_colors(struct anv_device
*device
)
579 static const VkClearColorValue border_colors
[] = {
580 [VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK
] = { .float32
= { 0.0, 0.0, 0.0, 0.0 } },
581 [VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK
] = { .float32
= { 0.0, 0.0, 0.0, 1.0 } },
582 [VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE
] = { .float32
= { 1.0, 1.0, 1.0, 1.0 } },
583 [VK_BORDER_COLOR_INT_TRANSPARENT_BLACK
] = { .uint32
= { 0, 0, 0, 0 } },
584 [VK_BORDER_COLOR_INT_OPAQUE_BLACK
] = { .uint32
= { 0, 0, 0, 1 } },
585 [VK_BORDER_COLOR_INT_OPAQUE_WHITE
] = { .uint32
= { 1, 1, 1, 1 } },
588 device
->border_colors
=
589 anv_state_pool_alloc(&device
->dynamic_state_pool
,
590 sizeof(border_colors
), 32);
591 memcpy(device
->border_colors
.map
, border_colors
, sizeof(border_colors
));
594 VkResult
anv_CreateDevice(
595 VkPhysicalDevice physicalDevice
,
596 const VkDeviceCreateInfo
* pCreateInfo
,
597 const VkAllocationCallbacks
* pAllocator
,
600 ANV_FROM_HANDLE(anv_physical_device
, physical_device
, physicalDevice
);
601 struct anv_device
*device
;
603 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO
);
605 for (uint32_t i
= 0; i
< pCreateInfo
->enabledExtensionNameCount
; i
++) {
607 for (uint32_t j
= 0; j
< ARRAY_SIZE(device_extensions
); j
++) {
608 if (strcmp(pCreateInfo
->ppEnabledExtensionNames
[i
],
609 device_extensions
[j
].extensionName
) == 0) {
615 return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT
);
618 anv_set_dispatch_devinfo(physical_device
->info
);
620 device
= anv_alloc2(&physical_device
->instance
->alloc
, pAllocator
,
622 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
624 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
626 device
->_loader_data
.loaderMagic
= ICD_LOADER_MAGIC
;
627 device
->instance
= physical_device
->instance
;
630 device
->alloc
= *pAllocator
;
632 device
->alloc
= physical_device
->instance
->alloc
;
634 /* XXX(chadv): Can we dup() physicalDevice->fd here? */
635 device
->fd
= open(physical_device
->path
, O_RDWR
| O_CLOEXEC
);
636 if (device
->fd
== -1)
639 device
->context_id
= anv_gem_create_context(device
);
640 if (device
->context_id
== -1)
643 pthread_mutex_init(&device
->mutex
, NULL
);
645 anv_bo_pool_init(&device
->batch_bo_pool
, device
, ANV_CMD_BUFFER_BATCH_SIZE
);
647 anv_block_pool_init(&device
->dynamic_state_block_pool
, device
, 2048);
649 anv_state_pool_init(&device
->dynamic_state_pool
,
650 &device
->dynamic_state_block_pool
);
652 anv_block_pool_init(&device
->instruction_block_pool
, device
, 4096);
653 anv_block_pool_init(&device
->surface_state_block_pool
, device
, 4096);
655 anv_state_pool_init(&device
->surface_state_pool
,
656 &device
->surface_state_block_pool
);
658 anv_bo_init_new(&device
->workaround_bo
, device
, 1024);
660 anv_block_pool_init(&device
->scratch_block_pool
, device
, 0x10000);
662 device
->info
= *physical_device
->info
;
663 device
->isl_dev
= physical_device
->isl_dev
;
665 anv_queue_init(device
, &device
->queue
);
667 anv_device_init_meta(device
);
669 anv_device_init_border_colors(device
);
671 *pDevice
= anv_device_to_handle(device
);
678 anv_free(&device
->alloc
, device
);
680 return vk_error(VK_ERROR_INITIALIZATION_FAILED
);
683 void anv_DestroyDevice(
685 const VkAllocationCallbacks
* pAllocator
)
687 ANV_FROM_HANDLE(anv_device
, device
, _device
);
689 anv_queue_finish(&device
->queue
);
691 anv_device_finish_meta(device
);
694 /* We only need to free these to prevent valgrind errors. The backing
695 * BO will go away in a couple of lines so we don't actually leak.
697 anv_state_pool_free(&device
->dynamic_state_pool
, device
->border_colors
);
700 anv_gem_munmap(device
->workaround_bo
.map
, device
->workaround_bo
.size
);
701 anv_gem_close(device
, device
->workaround_bo
.gem_handle
);
703 anv_bo_pool_finish(&device
->batch_bo_pool
);
704 anv_state_pool_finish(&device
->dynamic_state_pool
);
705 anv_block_pool_finish(&device
->dynamic_state_block_pool
);
706 anv_block_pool_finish(&device
->instruction_block_pool
);
707 anv_state_pool_finish(&device
->surface_state_pool
);
708 anv_block_pool_finish(&device
->surface_state_block_pool
);
709 anv_block_pool_finish(&device
->scratch_block_pool
);
713 anv_free(&device
->alloc
, device
);
716 VkResult
anv_EnumerateInstanceExtensionProperties(
717 const char* pLayerName
,
718 uint32_t* pPropertyCount
,
719 VkExtensionProperties
* pProperties
)
721 if (pProperties
== NULL
) {
722 *pPropertyCount
= ARRAY_SIZE(global_extensions
);
726 assert(*pPropertyCount
>= ARRAY_SIZE(global_extensions
));
728 *pPropertyCount
= ARRAY_SIZE(global_extensions
);
729 memcpy(pProperties
, global_extensions
, sizeof(global_extensions
));
734 VkResult
anv_EnumerateDeviceExtensionProperties(
735 VkPhysicalDevice physicalDevice
,
736 const char* pLayerName
,
737 uint32_t* pPropertyCount
,
738 VkExtensionProperties
* pProperties
)
740 if (pProperties
== NULL
) {
741 *pPropertyCount
= ARRAY_SIZE(device_extensions
);
745 assert(*pPropertyCount
>= ARRAY_SIZE(device_extensions
));
747 *pPropertyCount
= ARRAY_SIZE(device_extensions
);
748 memcpy(pProperties
, device_extensions
, sizeof(device_extensions
));
753 VkResult
anv_EnumerateInstanceLayerProperties(
754 uint32_t* pPropertyCount
,
755 VkLayerProperties
* pProperties
)
757 if (pProperties
== NULL
) {
762 /* None supported at this time */
763 return vk_error(VK_ERROR_LAYER_NOT_PRESENT
);
766 VkResult
anv_EnumerateDeviceLayerProperties(
767 VkPhysicalDevice physicalDevice
,
768 uint32_t* pPropertyCount
,
769 VkLayerProperties
* pProperties
)
771 if (pProperties
== NULL
) {
776 /* None supported at this time */
777 return vk_error(VK_ERROR_LAYER_NOT_PRESENT
);
780 void anv_GetDeviceQueue(
782 uint32_t queueNodeIndex
,
786 ANV_FROM_HANDLE(anv_device
, device
, _device
);
788 assert(queueIndex
== 0);
790 *pQueue
= anv_queue_to_handle(&device
->queue
);
793 VkResult
anv_QueueSubmit(
795 uint32_t commandBufferCount
,
796 const VkCommandBuffer
* pCommandBuffers
,
799 ANV_FROM_HANDLE(anv_queue
, queue
, _queue
);
800 ANV_FROM_HANDLE(anv_fence
, fence
, _fence
);
801 struct anv_device
*device
= queue
->device
;
804 for (uint32_t i
= 0; i
< commandBufferCount
; i
++) {
805 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, pCommandBuffers
[i
]);
807 assert(cmd_buffer
->level
== VK_COMMAND_BUFFER_LEVEL_PRIMARY
);
809 ret
= anv_gem_execbuffer(device
, &cmd_buffer
->execbuf2
.execbuf
);
811 /* We don't know the real error. */
812 return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY
,
813 "execbuf2 failed: %m");
817 ret
= anv_gem_execbuffer(device
, &fence
->execbuf
);
819 /* We don't know the real error. */
820 return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY
,
821 "execbuf2 failed: %m");
825 for (uint32_t i
= 0; i
< cmd_buffer
->execbuf2
.bo_count
; i
++)
826 cmd_buffer
->execbuf2
.bos
[i
]->offset
= cmd_buffer
->execbuf2
.objects
[i
].offset
;
832 VkResult
anv_QueueWaitIdle(
835 ANV_FROM_HANDLE(anv_queue
, queue
, _queue
);
837 return ANV_CALL(DeviceWaitIdle
)(anv_device_to_handle(queue
->device
));
840 VkResult
anv_DeviceWaitIdle(
843 ANV_FROM_HANDLE(anv_device
, device
, _device
);
844 struct anv_state state
;
845 struct anv_batch batch
;
846 struct drm_i915_gem_execbuffer2 execbuf
;
847 struct drm_i915_gem_exec_object2 exec2_objects
[1];
848 struct anv_bo
*bo
= NULL
;
853 state
= anv_state_pool_alloc(&device
->dynamic_state_pool
, 32, 32);
854 bo
= &device
->dynamic_state_pool
.block_pool
->bo
;
855 batch
.start
= batch
.next
= state
.map
;
856 batch
.end
= state
.map
+ 32;
857 anv_batch_emit(&batch
, GEN7_MI_BATCH_BUFFER_END
);
858 anv_batch_emit(&batch
, GEN7_MI_NOOP
);
860 exec2_objects
[0].handle
= bo
->gem_handle
;
861 exec2_objects
[0].relocation_count
= 0;
862 exec2_objects
[0].relocs_ptr
= 0;
863 exec2_objects
[0].alignment
= 0;
864 exec2_objects
[0].offset
= bo
->offset
;
865 exec2_objects
[0].flags
= 0;
866 exec2_objects
[0].rsvd1
= 0;
867 exec2_objects
[0].rsvd2
= 0;
869 execbuf
.buffers_ptr
= (uintptr_t) exec2_objects
;
870 execbuf
.buffer_count
= 1;
871 execbuf
.batch_start_offset
= state
.offset
;
872 execbuf
.batch_len
= batch
.next
- state
.map
;
873 execbuf
.cliprects_ptr
= 0;
874 execbuf
.num_cliprects
= 0;
879 I915_EXEC_HANDLE_LUT
| I915_EXEC_NO_RELOC
| I915_EXEC_RENDER
;
880 execbuf
.rsvd1
= device
->context_id
;
883 ret
= anv_gem_execbuffer(device
, &execbuf
);
885 /* We don't know the real error. */
886 result
= vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY
, "execbuf2 failed: %m");
891 ret
= anv_gem_wait(device
, bo
->gem_handle
, &timeout
);
893 /* We don't know the real error. */
894 result
= vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY
, "execbuf2 failed: %m");
898 anv_state_pool_free(&device
->dynamic_state_pool
, state
);
903 anv_state_pool_free(&device
->dynamic_state_pool
, state
);
909 anv_bo_init_new(struct anv_bo
*bo
, struct anv_device
*device
, uint64_t size
)
911 bo
->gem_handle
= anv_gem_create(device
, size
);
913 return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY
);
923 VkResult
anv_AllocateMemory(
925 const VkMemoryAllocateInfo
* pAllocateInfo
,
926 const VkAllocationCallbacks
* pAllocator
,
927 VkDeviceMemory
* pMem
)
929 ANV_FROM_HANDLE(anv_device
, device
, _device
);
930 struct anv_device_memory
*mem
;
933 assert(pAllocateInfo
->sType
== VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO
);
935 /* We support exactly one memory heap. */
936 assert(pAllocateInfo
->memoryTypeIndex
== 0);
938 /* FINISHME: Fail if allocation request exceeds heap size. */
940 mem
= anv_alloc2(&device
->alloc
, pAllocator
, sizeof(*mem
), 8,
941 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
943 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
945 result
= anv_bo_init_new(&mem
->bo
, device
, pAllocateInfo
->allocationSize
);
946 if (result
!= VK_SUCCESS
)
949 *pMem
= anv_device_memory_to_handle(mem
);
954 anv_free2(&device
->alloc
, pAllocator
, mem
);
962 const VkAllocationCallbacks
* pAllocator
)
964 ANV_FROM_HANDLE(anv_device
, device
, _device
);
965 ANV_FROM_HANDLE(anv_device_memory
, mem
, _mem
);
968 anv_gem_munmap(mem
->bo
.map
, mem
->bo
.size
);
970 if (mem
->bo
.gem_handle
!= 0)
971 anv_gem_close(device
, mem
->bo
.gem_handle
);
973 anv_free2(&device
->alloc
, pAllocator
, mem
);
976 VkResult
anv_MapMemory(
978 VkDeviceMemory _memory
,
981 VkMemoryMapFlags flags
,
984 ANV_FROM_HANDLE(anv_device
, device
, _device
);
985 ANV_FROM_HANDLE(anv_device_memory
, mem
, _memory
);
987 /* FIXME: Is this supposed to be thread safe? Since vkUnmapMemory() only
988 * takes a VkDeviceMemory pointer, it seems like only one map of the memory
989 * at a time is valid. We could just mmap up front and return an offset
990 * pointer here, but that may exhaust virtual memory on 32 bit
993 mem
->map
= anv_gem_mmap(device
, mem
->bo
.gem_handle
, offset
, size
);
994 mem
->map_size
= size
;
1001 void anv_UnmapMemory(
1003 VkDeviceMemory _memory
)
1005 ANV_FROM_HANDLE(anv_device_memory
, mem
, _memory
);
1007 anv_gem_munmap(mem
->map
, mem
->map_size
);
1010 VkResult
anv_FlushMappedMemoryRanges(
1012 uint32_t memoryRangeCount
,
1013 const VkMappedMemoryRange
* pMemoryRanges
)
1015 /* clflush here for !llc platforms */
1020 VkResult
anv_InvalidateMappedMemoryRanges(
1022 uint32_t memoryRangeCount
,
1023 const VkMappedMemoryRange
* pMemoryRanges
)
1025 return anv_FlushMappedMemoryRanges(device
, memoryRangeCount
, pMemoryRanges
);
1028 void anv_GetBufferMemoryRequirements(
1031 VkMemoryRequirements
* pMemoryRequirements
)
1033 ANV_FROM_HANDLE(anv_buffer
, buffer
, _buffer
);
1035 /* The Vulkan spec (git aaed022) says:
1037 * memoryTypeBits is a bitfield and contains one bit set for every
1038 * supported memory type for the resource. The bit `1<<i` is set if and
1039 * only if the memory type `i` in the VkPhysicalDeviceMemoryProperties
1040 * structure for the physical device is supported.
1042 * We support exactly one memory type.
1044 pMemoryRequirements
->memoryTypeBits
= 1;
1046 pMemoryRequirements
->size
= buffer
->size
;
1047 pMemoryRequirements
->alignment
= 16;
1050 void anv_GetImageMemoryRequirements(
1053 VkMemoryRequirements
* pMemoryRequirements
)
1055 ANV_FROM_HANDLE(anv_image
, image
, _image
);
1057 /* The Vulkan spec (git aaed022) says:
1059 * memoryTypeBits is a bitfield and contains one bit set for every
1060 * supported memory type for the resource. The bit `1<<i` is set if and
1061 * only if the memory type `i` in the VkPhysicalDeviceMemoryProperties
1062 * structure for the physical device is supported.
1064 * We support exactly one memory type.
1066 pMemoryRequirements
->memoryTypeBits
= 1;
1068 pMemoryRequirements
->size
= image
->size
;
1069 pMemoryRequirements
->alignment
= image
->alignment
;
1072 void anv_GetImageSparseMemoryRequirements(
1075 uint32_t* pSparseMemoryRequirementCount
,
1076 VkSparseImageMemoryRequirements
* pSparseMemoryRequirements
)
1081 void anv_GetDeviceMemoryCommitment(
1083 VkDeviceMemory memory
,
1084 VkDeviceSize
* pCommittedMemoryInBytes
)
1086 *pCommittedMemoryInBytes
= 0;
1089 VkResult
anv_BindBufferMemory(
1092 VkDeviceMemory _memory
,
1093 VkDeviceSize memoryOffset
)
1095 ANV_FROM_HANDLE(anv_device_memory
, mem
, _memory
);
1096 ANV_FROM_HANDLE(anv_buffer
, buffer
, _buffer
);
1098 buffer
->bo
= &mem
->bo
;
1099 buffer
->offset
= memoryOffset
;
1104 VkResult
anv_BindImageMemory(
1107 VkDeviceMemory _memory
,
1108 VkDeviceSize memoryOffset
)
1110 ANV_FROM_HANDLE(anv_device_memory
, mem
, _memory
);
1111 ANV_FROM_HANDLE(anv_image
, image
, _image
);
1113 image
->bo
= &mem
->bo
;
1114 image
->offset
= memoryOffset
;
1119 VkResult
anv_QueueBindSparse(
1121 uint32_t bindInfoCount
,
1122 const VkBindSparseInfo
* pBindInfo
,
1125 stub_return(VK_ERROR_INCOMPATIBLE_DRIVER
);
1128 VkResult
anv_CreateFence(
1130 const VkFenceCreateInfo
* pCreateInfo
,
1131 const VkAllocationCallbacks
* pAllocator
,
1134 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1135 struct anv_fence
*fence
;
1136 struct anv_batch batch
;
1139 const uint32_t fence_size
= 128;
1141 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_FENCE_CREATE_INFO
);
1143 fence
= anv_alloc2(&device
->alloc
, pAllocator
, sizeof(*fence
), 8,
1144 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
1146 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
1148 result
= anv_bo_init_new(&fence
->bo
, device
, fence_size
);
1149 if (result
!= VK_SUCCESS
)
1153 anv_gem_mmap(device
, fence
->bo
.gem_handle
, 0, fence
->bo
.size
);
1154 batch
.next
= batch
.start
= fence
->bo
.map
;
1155 batch
.end
= fence
->bo
.map
+ fence
->bo
.size
;
1156 anv_batch_emit(&batch
, GEN7_MI_BATCH_BUFFER_END
);
1157 anv_batch_emit(&batch
, GEN7_MI_NOOP
);
1159 fence
->exec2_objects
[0].handle
= fence
->bo
.gem_handle
;
1160 fence
->exec2_objects
[0].relocation_count
= 0;
1161 fence
->exec2_objects
[0].relocs_ptr
= 0;
1162 fence
->exec2_objects
[0].alignment
= 0;
1163 fence
->exec2_objects
[0].offset
= fence
->bo
.offset
;
1164 fence
->exec2_objects
[0].flags
= 0;
1165 fence
->exec2_objects
[0].rsvd1
= 0;
1166 fence
->exec2_objects
[0].rsvd2
= 0;
1168 fence
->execbuf
.buffers_ptr
= (uintptr_t) fence
->exec2_objects
;
1169 fence
->execbuf
.buffer_count
= 1;
1170 fence
->execbuf
.batch_start_offset
= 0;
1171 fence
->execbuf
.batch_len
= batch
.next
- fence
->bo
.map
;
1172 fence
->execbuf
.cliprects_ptr
= 0;
1173 fence
->execbuf
.num_cliprects
= 0;
1174 fence
->execbuf
.DR1
= 0;
1175 fence
->execbuf
.DR4
= 0;
1177 fence
->execbuf
.flags
=
1178 I915_EXEC_HANDLE_LUT
| I915_EXEC_NO_RELOC
| I915_EXEC_RENDER
;
1179 fence
->execbuf
.rsvd1
= device
->context_id
;
1180 fence
->execbuf
.rsvd2
= 0;
1182 *pFence
= anv_fence_to_handle(fence
);
1187 anv_free2(&device
->alloc
, pAllocator
, fence
);
1192 void anv_DestroyFence(
1195 const VkAllocationCallbacks
* pAllocator
)
1197 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1198 ANV_FROM_HANDLE(anv_fence
, fence
, _fence
);
1200 anv_gem_munmap(fence
->bo
.map
, fence
->bo
.size
);
1201 anv_gem_close(device
, fence
->bo
.gem_handle
);
1202 anv_free2(&device
->alloc
, pAllocator
, fence
);
1205 VkResult
anv_ResetFences(
1207 uint32_t fenceCount
,
1208 const VkFence
* pFences
)
1210 for (uint32_t i
= 0; i
< fenceCount
; i
++) {
1211 ANV_FROM_HANDLE(anv_fence
, fence
, pFences
[i
]);
1212 fence
->ready
= false;
1218 VkResult
anv_GetFenceStatus(
1222 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1223 ANV_FROM_HANDLE(anv_fence
, fence
, _fence
);
1230 ret
= anv_gem_wait(device
, fence
->bo
.gem_handle
, &t
);
1232 fence
->ready
= true;
1236 return VK_NOT_READY
;
1239 VkResult
anv_WaitForFences(
1241 uint32_t fenceCount
,
1242 const VkFence
* pFences
,
1246 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1248 /* DRM_IOCTL_I915_GEM_WAIT uses a signed 64 bit timeout and is supposed
1249 * to block indefinitely timeouts <= 0. Unfortunately, this was broken
1250 * for a couple of kernel releases. Since there's no way to know
1251 * whether or not the kernel we're using is one of the broken ones, the
1252 * best we can do is to clamp the timeout to INT64_MAX. This limits the
1253 * maximum timeout from 584 years to 292 years - likely not a big deal.
1255 if (timeout
> INT64_MAX
)
1256 timeout
= INT64_MAX
;
1258 int64_t t
= timeout
;
1260 /* FIXME: handle !waitAll */
1262 for (uint32_t i
= 0; i
< fenceCount
; i
++) {
1263 ANV_FROM_HANDLE(anv_fence
, fence
, pFences
[i
]);
1264 int ret
= anv_gem_wait(device
, fence
->bo
.gem_handle
, &t
);
1265 if (ret
== -1 && errno
== ETIME
) {
1267 } else if (ret
== -1) {
1268 /* We don't know the real error. */
1269 return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY
,
1270 "gem wait failed: %m");
1277 // Queue semaphore functions
1279 VkResult
anv_CreateSemaphore(
1281 const VkSemaphoreCreateInfo
* pCreateInfo
,
1282 const VkAllocationCallbacks
* pAllocator
,
1283 VkSemaphore
* pSemaphore
)
1285 *pSemaphore
= (VkSemaphore
)1;
1286 stub_return(VK_SUCCESS
);
1289 void anv_DestroySemaphore(
1291 VkSemaphore semaphore
,
1292 const VkAllocationCallbacks
* pAllocator
)
1299 VkResult
anv_CreateEvent(
1301 const VkEventCreateInfo
* pCreateInfo
,
1302 const VkAllocationCallbacks
* pAllocator
,
1305 stub_return(VK_ERROR_INCOMPATIBLE_DRIVER
);
1308 void anv_DestroyEvent(
1311 const VkAllocationCallbacks
* pAllocator
)
1316 VkResult
anv_GetEventStatus(
1320 stub_return(VK_ERROR_INCOMPATIBLE_DRIVER
);
1323 VkResult
anv_SetEvent(
1327 stub_return(VK_ERROR_INCOMPATIBLE_DRIVER
);
1330 VkResult
anv_ResetEvent(
1334 stub_return(VK_ERROR_INCOMPATIBLE_DRIVER
);
1339 VkResult
anv_CreateBuffer(
1341 const VkBufferCreateInfo
* pCreateInfo
,
1342 const VkAllocationCallbacks
* pAllocator
,
1345 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1346 struct anv_buffer
*buffer
;
1348 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO
);
1350 buffer
= anv_alloc2(&device
->alloc
, pAllocator
, sizeof(*buffer
), 8,
1351 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
1353 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
1355 buffer
->size
= pCreateInfo
->size
;
1359 *pBuffer
= anv_buffer_to_handle(buffer
);
1364 void anv_DestroyBuffer(
1367 const VkAllocationCallbacks
* pAllocator
)
1369 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1370 ANV_FROM_HANDLE(anv_buffer
, buffer
, _buffer
);
1372 anv_free2(&device
->alloc
, pAllocator
, buffer
);
1376 anv_fill_buffer_surface_state(struct anv_device
*device
, void *state
,
1377 const struct anv_format
*format
,
1378 uint32_t offset
, uint32_t range
, uint32_t stride
)
1380 switch (device
->info
.gen
) {
1382 if (device
->info
.is_haswell
)
1383 gen75_fill_buffer_surface_state(state
, format
, offset
, range
, stride
);
1385 gen7_fill_buffer_surface_state(state
, format
, offset
, range
, stride
);
1388 gen8_fill_buffer_surface_state(state
, format
, offset
, range
, stride
);
1391 gen9_fill_buffer_surface_state(state
, format
, offset
, range
, stride
);
1394 unreachable("unsupported gen\n");
1398 VkResult
anv_CreateBufferView(
1400 const VkBufferViewCreateInfo
* pCreateInfo
,
1401 const VkAllocationCallbacks
* pAllocator
,
1402 VkBufferView
* pView
)
1404 stub_return(VK_ERROR_INCOMPATIBLE_DRIVER
);
1407 void anv_DestroyBufferView(
1409 VkBufferView _bview
,
1410 const VkAllocationCallbacks
* pAllocator
)
1415 void anv_DestroySampler(
1418 const VkAllocationCallbacks
* pAllocator
)
1420 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1421 ANV_FROM_HANDLE(anv_sampler
, sampler
, _sampler
);
1423 anv_free2(&device
->alloc
, pAllocator
, sampler
);
1426 VkResult
anv_CreateFramebuffer(
1428 const VkFramebufferCreateInfo
* pCreateInfo
,
1429 const VkAllocationCallbacks
* pAllocator
,
1430 VkFramebuffer
* pFramebuffer
)
1432 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1433 struct anv_framebuffer
*framebuffer
;
1435 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO
);
1437 size_t size
= sizeof(*framebuffer
) +
1438 sizeof(struct anv_image_view
*) * pCreateInfo
->attachmentCount
;
1439 framebuffer
= anv_alloc2(&device
->alloc
, pAllocator
, size
, 8,
1440 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
1441 if (framebuffer
== NULL
)
1442 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
1444 framebuffer
->attachment_count
= pCreateInfo
->attachmentCount
;
1445 for (uint32_t i
= 0; i
< pCreateInfo
->attachmentCount
; i
++) {
1446 VkImageView _iview
= pCreateInfo
->pAttachments
[i
];
1447 framebuffer
->attachments
[i
] = anv_image_view_from_handle(_iview
);
1450 framebuffer
->width
= pCreateInfo
->width
;
1451 framebuffer
->height
= pCreateInfo
->height
;
1452 framebuffer
->layers
= pCreateInfo
->layers
;
1454 *pFramebuffer
= anv_framebuffer_to_handle(framebuffer
);
1459 void anv_DestroyFramebuffer(
1462 const VkAllocationCallbacks
* pAllocator
)
1464 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1465 ANV_FROM_HANDLE(anv_framebuffer
, fb
, _fb
);
1467 anv_free2(&device
->alloc
, pAllocator
, fb
);
1470 void vkCmdDbgMarkerBegin(
1471 VkCommandBuffer commandBuffer
,
1472 const char* pMarker
)
1473 __attribute__ ((visibility ("default")));
1475 void vkCmdDbgMarkerEnd(
1476 VkCommandBuffer commandBuffer
)
1477 __attribute__ ((visibility ("default")));
1479 void vkCmdDbgMarkerBegin(
1480 VkCommandBuffer commandBuffer
,
1481 const char* pMarker
)
1485 void vkCmdDbgMarkerEnd(
1486 VkCommandBuffer commandBuffer
)