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