1 /************************************************************************** 2 * 3 * Copyright 2007 VMware, Inc. 4 * All Rights Reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including 9 * without limitation the rights to use, copy, modify, merge, publish, 10 * distribute, sub license, and/or sell copies of the Software, and to 11 * permit persons to whom the Software is furnished to do so, subject to 12 * the following conditions: 13 * 14 * The above copyright notice and this permission notice (including the 15 * next paragraph) shall be included in all copies or substantial portions 16 * of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * 26 **************************************************************************/ 27 28 /** 29 * @file 30 * 31 * Screen, Adapter or GPU 32 * 33 * These are driver functions/facilities that are context independent. 34 */ 35 36 37 #ifndef P_SCREEN_H 38 #define P_SCREEN_H 39 40 41 #include "util/compiler.h" 42 #include "util/format/u_formats.h" 43 #include "pipe/p_defines.h" 44 #include "pipe/p_video_enums.h" 45 46 47 48 #ifdef __cplusplus 49 extern "C" { 50 #endif 51 52 53 /** Opaque types */ 54 struct winsys_handle; 55 struct pipe_fence_handle; 56 struct pipe_resource; 57 struct pipe_surface; 58 struct pipe_transfer; 59 struct pipe_box; 60 struct pipe_memory_info; 61 struct pipe_vertex_buffer; 62 struct pipe_vertex_element; 63 struct pipe_vertex_state; 64 struct disk_cache; 65 struct driOptionCache; 66 struct u_transfer_helper; 67 struct pipe_screen; 68 struct util_queue_fence; 69 70 typedef struct pipe_vertex_state * 71 (*pipe_create_vertex_state_func)(struct pipe_screen *screen, 72 struct pipe_vertex_buffer *buffer, 73 const struct pipe_vertex_element *elements, 74 unsigned num_elements, 75 struct pipe_resource *indexbuf, 76 uint32_t full_velem_mask); 77 typedef void (*pipe_vertex_state_destroy_func)(struct pipe_screen *screen, 78 struct pipe_vertex_state *); 79 typedef void (*pipe_driver_thread_func)(void *job, void *gdata, int thread_index); 80 81 82 83 /** 84 * Gallium screen/adapter context. Basically everything 85 * hardware-specific that doesn't actually require a rendering 86 * context. 87 */ 88 struct pipe_screen { 89 int refcnt; 90 void *winsys_priv; 91 92 /** 93 * Get the fd associated with the screen 94 * The fd returned is considered read-only, and in particular will not 95 * be close()d. It must remain valid for as long as the screen exists. 96 */ 97 int (*get_screen_fd)(struct pipe_screen *); 98 99 /** 100 * Atomically incremented by drivers to track the number of contexts. 101 * If it's 0, it can be assumed that contexts are not tracked. 102 * Used by some places to skip locking if num_contexts == 1. 103 */ 104 unsigned num_contexts; 105 106 /** 107 * For drivers using u_transfer_helper: 108 */ 109 struct u_transfer_helper *transfer_helper; 110 111 void (*destroy)(struct pipe_screen *); 112 113 const char *(*get_name)(struct pipe_screen *); 114 115 const char *(*get_vendor)(struct pipe_screen *); 116 117 /** 118 * Returns the device vendor. 119 * 120 * The returned value should return the actual device vendor/manufacturer, 121 * rather than a potentially generic driver string. 122 */ 123 const char *(*get_device_vendor)(struct pipe_screen *); 124 125 /** 126 * Returns the latest OpenCL CTS version passed 127 * 128 * The returned value should be the git tag used when passing conformance. 129 */ 130 const char *(*get_cl_cts_version)(struct pipe_screen *); 131 132 /** 133 * Query an integer-valued capability/parameter/limit 134 * \param param one of PIPE_CAP_x 135 */ 136 int (*get_param)(struct pipe_screen *, enum pipe_cap param); 137 138 /** 139 * Query a float-valued capability/parameter/limit 140 * \param param one of PIPE_CAP_x 141 */ 142 float (*get_paramf)(struct pipe_screen *, enum pipe_capf param); 143 144 /** 145 * Query a per-shader-stage integer-valued capability/parameter/limit 146 * \param param one of PIPE_CAP_x 147 */ 148 int (*get_shader_param)(struct pipe_screen *, enum pipe_shader_type shader, 149 enum pipe_shader_cap param); 150 151 /** 152 * Query an integer-valued capability/parameter/limit for a codec/profile 153 * \param param one of PIPE_VIDEO_CAP_x 154 */ 155 int (*get_video_param)(struct pipe_screen *, 156 enum pipe_video_profile profile, 157 enum pipe_video_entrypoint entrypoint, 158 enum pipe_video_cap param); 159 160 /** 161 * Query a compute-specific capability/parameter/limit. 162 * \param ir_type shader IR type for which the param applies, or don't care 163 * if the param is not shader related 164 * \param param one of PIPE_COMPUTE_CAP_x 165 * \param ret pointer to a preallocated buffer that will be 166 * initialized to the parameter value, or NULL. 167 * \return size in bytes of the parameter value that would be 168 * returned. 169 */ 170 int (*get_compute_param)(struct pipe_screen *, 171 enum pipe_shader_ir ir_type, 172 enum pipe_compute_cap param, 173 void *ret); 174 175 /** 176 * Get the sample pixel grid's size. This function requires 177 * PIPE_CAP_PROGRAMMABLE_SAMPLE_LOCATIONS to be callable. 178 * 179 * \param sample_count - total number of samples 180 * \param out_width - the width of the pixel grid 181 * \param out_height - the height of the pixel grid 182 */ 183 void (*get_sample_pixel_grid)(struct pipe_screen *, unsigned sample_count, 184 unsigned *out_width, unsigned *out_height); 185 186 /** 187 * Query a timestamp in nanoseconds. The returned value should match 188 * PIPE_QUERY_TIMESTAMP. This function returns immediately and doesn't 189 * wait for rendering to complete (which cannot be achieved with queries). 190 */ 191 uint64_t (*get_timestamp)(struct pipe_screen *); 192 193 /** 194 * Return an equivalent canonical format which has the same component sizes 195 * and swizzles as the original, and it is supported by the driver. Gallium 196 * already does a first canonicalization step (see get_canonical_format() 197 * on st_cb_copyimage.c) and it calls this function (if defined) to get an 198 * alternative format if the picked is not supported by the driver. 199 */ 200 enum pipe_format (*get_canonical_format)(struct pipe_screen *, 201 enum pipe_format format); 202 203 /** 204 * Create a context. 205 * 206 * \param screen pipe screen 207 * \param priv a pointer to set in pipe_context::priv 208 * \param flags a mask of PIPE_CONTEXT_* flags 209 */ 210 struct pipe_context * (*context_create)(struct pipe_screen *screen, 211 void *priv, unsigned flags); 212 213 /** 214 * Check if the given image copy will be faster on compute 215 * \param cpu If true, this is checking against CPU fallback, 216 * otherwise the copy will be on GFX 217 */ 218 bool (*is_compute_copy_faster)(struct pipe_screen *, 219 enum pipe_format src_format, 220 enum pipe_format dst_format, 221 unsigned width, 222 unsigned height, 223 unsigned depth, 224 bool cpu); 225 226 /** 227 * Check if the given pipe_format is supported as a texture or 228 * drawing surface. 229 * \param bindings bitmask of PIPE_BIND_* 230 */ 231 bool (*is_format_supported)(struct pipe_screen *, 232 enum pipe_format format, 233 enum pipe_texture_target target, 234 unsigned sample_count, 235 unsigned storage_sample_count, 236 unsigned bindings); 237 238 /** 239 * Check if the given pipe_format is supported as output for this 240 * codec/profile. 241 * \param profile profile to check, may also be PIPE_VIDEO_PROFILE_UNKNOWN 242 */ 243 bool (*is_video_format_supported)(struct pipe_screen *, 244 enum pipe_format format, 245 enum pipe_video_profile profile, 246 enum pipe_video_entrypoint entrypoint); 247 248 /** 249 * Check if we can actually create the given resource (test the dimension, 250 * overall size, etc). Used to implement proxy textures. 251 * \return TRUE if size is OK, FALSE if too large. 252 */ 253 bool (*can_create_resource)(struct pipe_screen *screen, 254 const struct pipe_resource *templat); 255 256 /** 257 * Create a new texture object, using the given template info. 258 */ 259 struct pipe_resource * (*resource_create)(struct pipe_screen *, 260 const struct pipe_resource *templat); 261 262 struct pipe_resource * (*resource_create_drawable)(struct pipe_screen *, 263 const struct pipe_resource *tmpl, 264 const void *loader_private); 265 266 struct pipe_resource * (*resource_create_front)(struct pipe_screen *, 267 const struct pipe_resource *templat, 268 const void *map_front_private); 269 270 /** 271 * Create a texture from a winsys_handle. The handle is often created in 272 * another process by first creating a pipe texture and then calling 273 * resource_get_handle. 274 * 275 * NOTE: in the case of WINSYS_HANDLE_TYPE_FD handles, the caller 276 * retains ownership of the FD. (This is consistent with 277 * EGL_EXT_image_dma_buf_import) 278 * 279 * \param usage A combination of PIPE_HANDLE_USAGE_* flags. 280 */ 281 struct pipe_resource * (*resource_from_handle)(struct pipe_screen *, 282 const struct pipe_resource *templat, 283 struct winsys_handle *handle, 284 unsigned usage); 285 286 /** 287 * Create a resource from user memory. This maps the user memory into 288 * the device address space. 289 */ 290 struct pipe_resource * (*resource_from_user_memory)(struct pipe_screen *, 291 const struct pipe_resource *t, 292 void *user_memory); 293 294 /** 295 * Unlike pipe_resource::bind, which describes what gallium frontends want, 296 * resources can have much greater capabilities in practice, often implied 297 * by the tiling layout or memory placement. This function allows querying 298 * whether a capability is supported beyond what was requested by state 299 * trackers. It's also useful for querying capabilities of imported 300 * resources where the capabilities are unknown at first. 301 * 302 * Only these flags are allowed: 303 * - PIPE_BIND_SCANOUT 304 * - PIPE_BIND_CURSOR 305 * - PIPE_BIND_LINEAR 306 */ 307 bool (*check_resource_capability)(struct pipe_screen *screen, 308 struct pipe_resource *resource, 309 unsigned bind); 310 311 /** 312 * Get a winsys_handle from a texture. Some platforms/winsys requires 313 * that the texture is created with a special usage flag like 314 * DISPLAYTARGET or PRIMARY. 315 * 316 * The context parameter can optionally be used to flush the resource and 317 * the context to make sure the resource is coherent with whatever user 318 * will use it. Some drivers may also use the context to convert 319 * the resource into a format compatible for sharing. The use case is 320 * OpenGL-OpenCL interop. The context parameter is allowed to be NULL. 321 * 322 * NOTE: for multi-planar resources (which may or may not have the planes 323 * chained through the pipe_resource next pointer) the frontend will 324 * always call this function with the first resource of the chain. It is 325 * the pipe drivers responsibility to walk the resources as needed when 326 * called with handle->plane != 0. 327 * 328 * NOTE: in the case of WINSYS_HANDLE_TYPE_FD handles, the caller 329 * takes ownership of the FD. (This is consistent with 330 * EGL_MESA_image_dma_buf_export) 331 * 332 * \param usage A combination of PIPE_HANDLE_USAGE_* flags. 333 */ 334 bool (*resource_get_handle)(struct pipe_screen *, 335 struct pipe_context *context, 336 struct pipe_resource *tex, 337 struct winsys_handle *handle, 338 unsigned usage); 339 340 /** 341 * Get info for the given pipe resource without the need to get a 342 * winsys_handle. 343 * 344 * The context parameter can optionally be used to flush the resource and 345 * the context to make sure the resource is coherent with whatever user 346 * will use it. Some drivers may also use the context to convert 347 * the resource into a format compatible for sharing. The context parameter 348 * is allowed to be NULL. 349 */ 350 bool (*resource_get_param)(struct pipe_screen *screen, 351 struct pipe_context *context, 352 struct pipe_resource *resource, 353 unsigned plane, 354 unsigned layer, 355 unsigned level, 356 enum pipe_resource_param param, 357 unsigned handle_usage, 358 uint64_t *value); 359 360 /** 361 * Get stride and offset for the given pipe resource without the need to get 362 * a winsys_handle. 363 */ 364 void (*resource_get_info)(struct pipe_screen *screen, 365 struct pipe_resource *resource, 366 unsigned *stride, 367 unsigned *offset); 368 369 /** 370 * Mark the resource as changed so derived internal resources will be 371 * recreated on next use. 372 * 373 * This is necessary when reimporting external images that can't be directly 374 * used as texture sampler source, to avoid sampling from old copies. 375 */ 376 void (*resource_changed)(struct pipe_screen *, struct pipe_resource *pt); 377 378 void (*resource_destroy)(struct pipe_screen *, 379 struct pipe_resource *pt); 380 381 382 /** 383 * Do any special operations to ensure frontbuffer contents are 384 * displayed, eg copy fake frontbuffer. 385 * \param winsys_drawable_handle an opaque handle that the calling context 386 * gets out-of-band 387 * \param subbox an optional sub region to flush 388 */ 389 void (*flush_frontbuffer)(struct pipe_screen *screen, 390 struct pipe_context *ctx, 391 struct pipe_resource *resource, 392 unsigned level, unsigned layer, 393 void *winsys_drawable_handle, 394 struct pipe_box *subbox); 395 396 /** Set ptr = fence, with reference counting */ 397 void (*fence_reference)(struct pipe_screen *screen, 398 struct pipe_fence_handle **ptr, 399 struct pipe_fence_handle *fence); 400 401 /** 402 * Wait for the fence to finish. 403 * 404 * If the fence was created with PIPE_FLUSH_DEFERRED, and the context is 405 * still unflushed, and the ctx parameter of fence_finish is equal to 406 * the context where the fence was created, fence_finish will flush 407 * the context prior to waiting for the fence. 408 * 409 * In all other cases, the ctx parameter has no effect. 410 * 411 * \param timeout in nanoseconds (may be OS_TIMEOUT_INFINITE). 412 */ 413 bool (*fence_finish)(struct pipe_screen *screen, 414 struct pipe_context *ctx, 415 struct pipe_fence_handle *fence, 416 uint64_t timeout); 417 418 /** 419 * For fences created with PIPE_FLUSH_FENCE_FD (exported fd) or 420 * by create_fence_fd() (imported fd), return the native fence fd 421 * associated with the fence. This may return -1 for fences 422 * created with PIPE_FLUSH_DEFERRED if the fence command has not 423 * been flushed yet. 424 */ 425 int (*fence_get_fd)(struct pipe_screen *screen, 426 struct pipe_fence_handle *fence); 427 428 /** 429 * Retrieves the Win32 shared handle from the fence. 430 * Note that Windows fences are pretty much all timeline semaphores, 431 * so a value is needed to denote the specific point on the timeline. 432 */ 433 void* (*fence_get_win32_handle)(struct pipe_screen *screen, 434 struct pipe_fence_handle *fence, 435 uint64_t *fence_value); 436 437 /** 438 * Create a fence from an Win32 handle. 439 * 440 * This is used for importing a foreign/external fence handle. 441 * 442 * \param fence if not NULL, an old fence to unref and transfer a 443 * new fence reference to 444 * \param handle opaque handle representing the fence object 445 * \param type indicates which fence types backs the handle 446 */ 447 void (*create_fence_win32)(struct pipe_screen *screen, 448 struct pipe_fence_handle **fence, 449 void *handle, 450 const void *name, 451 enum pipe_fd_type type); 452 453 /** 454 * Returns a driver-specific query. 455 * 456 * If \p info is NULL, the number of available queries is returned. 457 * Otherwise, the driver query at the specified \p index is returned 458 * in \p info. The function returns non-zero on success. 459 */ 460 int (*get_driver_query_info)(struct pipe_screen *screen, 461 unsigned index, 462 struct pipe_driver_query_info *info); 463 464 /** 465 * Returns a driver-specific query group. 466 * 467 * If \p info is NULL, the number of available groups is returned. 468 * Otherwise, the driver query group at the specified \p index is returned 469 * in \p info. The function returns non-zero on success. 470 */ 471 int (*get_driver_query_group_info)(struct pipe_screen *screen, 472 unsigned index, 473 struct pipe_driver_query_group_info *info); 474 475 /** 476 * Query information about memory usage. 477 */ 478 void (*query_memory_info)(struct pipe_screen *screen, 479 struct pipe_memory_info *info); 480 481 /** 482 * Get IR specific compiler options struct. For PIPE_SHADER_IR_NIR this 483 * returns a 'struct nir_shader_compiler_options'. Drivers reporting 484 * NIR as the preferred IR must implement this. 485 */ 486 const void *(*get_compiler_options)(struct pipe_screen *screen, 487 enum pipe_shader_ir ir, 488 enum pipe_shader_type shader); 489 490 /** 491 * Returns a pointer to a driver-specific on-disk shader cache. If the 492 * driver failed to create the cache or does not support an on-disk shader 493 * cache NULL is returned. The callback itself may also be NULL if the 494 * driver doesn't support an on-disk shader cache. 495 */ 496 struct disk_cache *(*get_disk_shader_cache)(struct pipe_screen *screen); 497 498 /** 499 * Create a new texture object from the given template info, taking 500 * format modifiers into account. \p modifiers specifies a list of format 501 * modifier tokens, as defined in drm_fourcc.h. The driver then picks the 502 * best modifier among these and creates the resource. \p count must 503 * contain the size of \p modifiers array. 504 * 505 * Returns NULL if an entry in \p modifiers is unsupported by the driver, 506 * or if only DRM_FORMAT_MOD_INVALID is provided. 507 */ 508 struct pipe_resource * (*resource_create_with_modifiers)( 509 struct pipe_screen *, 510 const struct pipe_resource *templat, 511 const uint64_t *modifiers, int count); 512 513 /** 514 * Get supported modifiers for a format. 515 * If \p max is 0, the total number of supported modifiers for the supplied 516 * format is returned in \p count, with no modification to \p modifiers. 517 * Otherwise, \p modifiers is filled with upto \p max supported modifier 518 * codes, and \p count with the number of modifiers copied. 519 * The \p external_only array is used to return whether the format and 520 * modifier combination can only be used with an external texture target. 521 */ 522 void (*query_dmabuf_modifiers)(struct pipe_screen *screen, 523 enum pipe_format format, int max, 524 uint64_t *modifiers, 525 unsigned int *external_only, int *count); 526 527 /** 528 * Create a memory object from a winsys handle 529 * 530 * The underlying memory is most often allocated in by a foregin API. 531 * Then the underlying memory object is then exported through interfaces 532 * compatible with EXT_external_resources. 533 * 534 * Note: For WINSYS_HANDLE_TYPE_FD handles, the caller retains ownership 535 * of the fd. 536 * 537 * \param handle A handle representing the memory object to import 538 */ 539 struct pipe_memory_object *(*memobj_create_from_handle)(struct pipe_screen *screen, 540 struct winsys_handle *handle, 541 bool dedicated); 542 543 /** 544 * Destroy a memory object 545 * 546 * \param memobj The memory object to destroy 547 */ 548 void (*memobj_destroy)(struct pipe_screen *screen, 549 struct pipe_memory_object *memobj); 550 551 /** 552 * Create a texture from a memory object 553 * 554 * \param t texture template 555 * \param memobj The memory object used to back the texture 556 */ 557 struct pipe_resource * (*resource_from_memobj)(struct pipe_screen *screen, 558 const struct pipe_resource *t, 559 struct pipe_memory_object *memobj, 560 uint64_t offset); 561 562 /** 563 * Fill @uuid with a unique driver identifier 564 * 565 * \param uuid pointer to a memory region of PIPE_UUID_SIZE bytes 566 */ 567 void (*get_driver_uuid)(struct pipe_screen *screen, char *uuid); 568 569 /** 570 * Fill @uuid with a unique device identifier 571 * 572 * \param uuid pointer to a memory region of PIPE_UUID_SIZE bytes 573 */ 574 void (*get_device_uuid)(struct pipe_screen *screen, char *uuid); 575 576 /** 577 * Fill @luid with the locally unique identifier of the context 578 * The LUID returned, paired together with the contexts node mask, 579 * allows matching the context to an IDXGIAdapter1 object 580 * 581 * \param luid pointer to a memory region of PIPE_LUID_SIZE bytes 582 */ 583 void (*get_device_luid)(struct pipe_screen *screen, char *luid); 584 585 /** 586 * Return the device node mask identifying the context 587 * Together with the contexts LUID, this allows matching 588 * the context to an IDXGIAdapter1 object. 589 * 590 * within a linked device adapter 591 */ 592 uint32_t (*get_device_node_mask)(struct pipe_screen *screen); 593 594 /** 595 * Set the maximum number of parallel shader compiler threads. 596 */ 597 void (*set_max_shader_compiler_threads)(struct pipe_screen *screen, 598 unsigned max_threads); 599 600 /** 601 * Return whether parallel shader compilation has finished. 602 */ 603 bool (*is_parallel_shader_compilation_finished)(struct pipe_screen *screen, 604 void *shader, 605 enum pipe_shader_type shader_type); 606 607 void (*driver_thread_add_job)(struct pipe_screen *screen, 608 void *job, 609 struct util_queue_fence *fence, 610 pipe_driver_thread_func execute, 611 pipe_driver_thread_func cleanup, 612 const size_t job_size); 613 614 /** 615 * Set the damage region (called when KHR_partial_update() is invoked). 616 * This function is passed an array of rectangles encoding the damage area. 617 * rects are using the bottom-left origin convention. 618 * nrects = 0 means 'reset the damage region'. What 'reset' implies is HW 619 * specific. For tile-based renderers, the damage extent is typically set 620 * to cover the whole resource with no damage rect (or a 0-size damage 621 * rect). This way, the existing resource content is reloaded into the 622 * local tile buffer for every tile thus making partial tile update 623 * possible. For HW operating in immediate mode, this reset operation is 624 * likely to be a NOOP. 625 */ 626 void (*set_damage_region)(struct pipe_screen *screen, 627 struct pipe_resource *resource, 628 unsigned int nrects, 629 const struct pipe_box *rects); 630 631 /** 632 * Run driver-specific NIR lowering and optimization passes. 633 * 634 * gallium frontends should call this before passing shaders to drivers, 635 * and ideally also before shader caching. 636 * 637 * The driver may return a non-NULL string to trigger GLSL link failure 638 * and logging of that message in the GLSL linker log. 639 */ 640 char *(*finalize_nir)(struct pipe_screen *screen, void *nir); 641 642 /*Separated memory/resource allocations interfaces for Vulkan */ 643 644 /** 645 * Create a resource, and retrieve the required size for it but don't 646 * allocate any backing memory. 647 */ 648 struct pipe_resource * (*resource_create_unbacked)(struct pipe_screen *, 649 const struct pipe_resource *templat, 650 uint64_t *size_required); 651 652 /** 653 * Allocate backing memory to be bound to resources. 654 */ 655 struct pipe_memory_allocation *(*allocate_memory)(struct pipe_screen *screen, 656 uint64_t size); 657 /** 658 * Free previously allocated backing memory. 659 */ 660 void (*free_memory)(struct pipe_screen *screen, 661 struct pipe_memory_allocation *); 662 663 /** 664 * Allocate fd-based memory to be bound to resources. 665 */ 666 struct pipe_memory_allocation *(*allocate_memory_fd)(struct pipe_screen *screen, 667 uint64_t size, 668 int *fd); 669 670 /** 671 * Import memory from an fd-handle. 672 */ 673 bool (*import_memory_fd)(struct pipe_screen *screen, 674 int fd, 675 struct pipe_memory_allocation **pmem, 676 uint64_t *size); 677 678 /** 679 * Free previously allocated fd-based memory. 680 */ 681 void (*free_memory_fd)(struct pipe_screen *screen, 682 struct pipe_memory_allocation *pmem); 683 684 /** 685 * Bind memory to a resource. 686 */ 687 bool (*resource_bind_backing)(struct pipe_screen *screen, 688 struct pipe_resource *pt, 689 struct pipe_memory_allocation *pmem, 690 uint64_t offset); 691 692 /** 693 * Map backing memory. 694 */ 695 void *(*map_memory)(struct pipe_screen *screen, 696 struct pipe_memory_allocation *pmem); 697 698 /** 699 * Unmap backing memory. 700 */ 701 void (*unmap_memory)(struct pipe_screen *screen, 702 struct pipe_memory_allocation *pmem); 703 704 /** 705 * Determine whether the screen supports the specified modifier 706 * 707 * Query whether the driver supports a \p modifier in combination with 708 * \p format. If \p external_only is not NULL, the value it points to will 709 * be set to 0 or a non-zero value to indicate whether the modifier and 710 * format combination is supported only with external, or also with non- 711 * external texture targets respectively. The \p external_only parameter is 712 * not used when the function returns false. 713 * 714 * \return true if the format+modifier pair is supported on \p screen, false 715 * otherwise. 716 */ 717 bool (*is_dmabuf_modifier_supported)(struct pipe_screen *screen, 718 uint64_t modifier, enum pipe_format, 719 bool *external_only); 720 721 /** 722 * Get the number of planes required for a given modifier/format pair. 723 * 724 * If not NULL, this function returns the number of planes needed to 725 * represent \p format in the layout specified by \p modifier, including 726 * any driver-specific auxiliary data planes. 727 * 728 * Must only be called on a modifier supported by the screen for the 729 * specified format. 730 * 731 * If NULL, no auxiliary planes are required for any modifier+format pairs 732 * supported by \p screen. Hence, the plane count can be derived directly 733 * from \p format. 734 * 735 * \return Number of planes needed to store image data in the layout defined 736 * by \p format and \p modifier. 737 */ 738 unsigned int (*get_dmabuf_modifier_planes)(struct pipe_screen *screen, 739 uint64_t modifier, 740 enum pipe_format format); 741 742 /** 743 * Get supported page sizes for sparse texture. 744 * 745 * \p size is the array size of \p x, \p y and \p z. 746 * 747 * \p offset sets an offset into the possible format page size array, 748 * used to pick a specific xyz size combination. 749 * 750 * \return Number of supported page sizes, 0 means not support. 751 */ 752 int (*get_sparse_texture_virtual_page_size)(struct pipe_screen *screen, 753 enum pipe_texture_target target, 754 bool multi_sample, 755 enum pipe_format format, 756 unsigned offset, unsigned size, 757 int *x, int *y, int *z); 758 759 /** 760 * Vertex state CSO functions for precomputing vertex and index buffer 761 * states for display lists. 762 */ 763 pipe_create_vertex_state_func create_vertex_state; 764 pipe_vertex_state_destroy_func vertex_state_destroy; 765 766 /** 767 * Update a timeline semaphore value stored within a driver fence object. 768 * Future waits and signals will use the new value. 769 */ 770 void (*set_fence_timeline_value)(struct pipe_screen *screen, 771 struct pipe_fence_handle *fence, 772 uint64_t value); 773 774 /** 775 * Get additional data for interop_query_device_info 776 * 777 * \p in_data_size is how much data was allocated by the caller 778 * \p data is the buffer to fill 779 * 780 * \return how much data was written 781 */ 782 uint32_t (*interop_query_device_info)(struct pipe_screen *screen, 783 uint32_t in_data_size, 784 void *data); 785 786 /** 787 * Get additional data for interop_export_object 788 * 789 * \p in_data_size is how much data was allocated by the caller 790 * \p data is the buffer to fill 791 * \p need_export_dmabuf can be set to false to prevent 792 * a following call to resource_get_handle, if the private 793 * data contains the exported data 794 * 795 * \return how much data was written 796 */ 797 uint32_t (*interop_export_object)(struct pipe_screen *screen, 798 struct pipe_resource *res, 799 uint32_t in_data_size, 800 void *data, 801 bool *need_export_dmabuf); 802 }; 803 804 805 /** 806 * Global configuration options for screen creation. 807 */ 808 struct pipe_screen_config { 809 struct driOptionCache *options; 810 const struct driOptionCache *options_info; 811 }; 812 813 814 #ifdef __cplusplus 815 } 816 #endif 817 818 #endif /* P_SCREEN_H */ 819