Path: blob/21.2-virgl/src/gallium/include/pipe/p_context.h
4566 views
/**************************************************************************1*2* Copyright 2007 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627#ifndef PIPE_CONTEXT_H28#define PIPE_CONTEXT_H2930#include "p_compiler.h"31#include "p_format.h"32#include "p_video_enums.h"33#include "p_defines.h"34#include <stdio.h>3536#ifdef __cplusplus37extern "C" {38#endif394041struct pipe_blend_color;42struct pipe_blend_state;43struct pipe_blit_info;44struct pipe_box;45struct pipe_clip_state;46struct pipe_constant_buffer;47struct pipe_debug_callback;48struct pipe_depth_stencil_alpha_state;49struct pipe_device_reset_callback;50struct pipe_draw_info;51struct pipe_draw_indirect_info;52struct pipe_draw_start_count_bias;53struct pipe_grid_info;54struct pipe_fence_handle;55struct pipe_framebuffer_state;56struct pipe_image_view;57struct pipe_query;58struct pipe_poly_stipple;59struct pipe_rasterizer_state;60struct pipe_resolve_info;61struct pipe_resource;62struct pipe_sampler_state;63struct pipe_sampler_view;64struct pipe_scissor_state;65struct pipe_shader_buffer;66struct pipe_shader_state;67struct pipe_stencil_ref;68struct pipe_stream_output_target;69struct pipe_surface;70struct pipe_transfer;71struct pipe_vertex_buffer;72struct pipe_vertex_element;73struct pipe_video_buffer;74struct pipe_video_codec;75struct pipe_viewport_state;76struct pipe_compute_state;77union pipe_color_union;78union pipe_query_result;79struct u_log_context;80struct u_upload_mgr;8182/**83* Gallium rendering context. Basically:84* - state setting functions85* - VBO drawing functions86* - surface functions87*/88struct pipe_context {89struct pipe_screen *screen;9091void *priv; /**< context private data (for DRI for example) */92void *draw; /**< private, for draw module (temporary?) */9394/**95* Stream uploaders created by the driver. All drivers, gallium frontends, and96* modules should use them.97*98* Use u_upload_alloc or u_upload_data as many times as you want.99* Once you are done, use u_upload_unmap.100*/101struct u_upload_mgr *stream_uploader; /* everything but shader constants */102struct u_upload_mgr *const_uploader; /* shader constants only */103104void (*destroy)( struct pipe_context * );105106/**107* VBO drawing108*/109/*@{*/110/**111* Multi draw.112*113* For indirect multi draws, num_draws is 1 and indirect->draw_count114* is used instead.115*116* Caps:117* - Always supported: Direct multi draws118* - PIPE_CAP_MULTI_DRAW_INDIRECT: Indirect multi draws119* - PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS: Indirect draw count120*121* Differences against glMultiDraw and glMultiMode:122* - "info->mode" and "draws->index_bias" are always constant due to the lack123* of hardware support and CPU performance concerns. Only start and count124* vary.125* - if "info->increment_draw_id" is false, draw_id doesn't change between126* draws127*128* Direct multi draws are also generated by u_threaded_context, which looks129* ahead in gallium command buffers and merges single draws.130*131* \param pipe context132* \param info draw info133* \param drawid_offset offset to add for drawid param of each draw134* \param indirect indirect multi draws135* \param draws array of (start, count) pairs for direct draws136* \param num_draws number of direct draws; 1 for indirect multi draws137*/138void (*draw_vbo)(struct pipe_context *pipe,139const struct pipe_draw_info *info,140unsigned drawid_offset,141const struct pipe_draw_indirect_info *indirect,142const struct pipe_draw_start_count_bias *draws,143unsigned num_draws);144/*@}*/145146/**147* Predicate subsequent rendering on occlusion query result148* \param query the query predicate, or NULL if no predicate149* \param condition whether to skip on FALSE or TRUE query results150* \param mode one of PIPE_RENDER_COND_x151*/152void (*render_condition)( struct pipe_context *pipe,153struct pipe_query *query,154bool condition,155enum pipe_render_cond_flag mode );156157/**158* Predicate subsequent rendering on a value in a buffer159* \param buffer The buffer to query for the value160* \param offset Offset in the buffer to query 32-bit161* \param condition whether to skip on FALSE or TRUE query results162*/163void (*render_condition_mem)( struct pipe_context *pipe,164struct pipe_resource *buffer,165uint32_t offset,166bool condition );167/**168* Query objects169*/170/*@{*/171struct pipe_query *(*create_query)( struct pipe_context *pipe,172unsigned query_type,173unsigned index );174175/**176* Create a query object that queries all given query types simultaneously.177*178* This can only be used for those query types for which179* get_driver_query_info indicates that it must be used. Only one batch180* query object may be active at a time.181*182* There may be additional constraints on which query types can be used183* together, in particular those that are implied by184* get_driver_query_group_info.185*186* \param num_queries the number of query types187* \param query_types array of \p num_queries query types188* \return a query object, or NULL on error.189*/190struct pipe_query *(*create_batch_query)( struct pipe_context *pipe,191unsigned num_queries,192unsigned *query_types );193194void (*destroy_query)(struct pipe_context *pipe,195struct pipe_query *q);196197bool (*begin_query)(struct pipe_context *pipe, struct pipe_query *q);198bool (*end_query)(struct pipe_context *pipe, struct pipe_query *q);199200/**201* Get results of a query.202* \param wait if true, this query will block until the result is ready203* \return TRUE if results are ready, FALSE otherwise204*/205bool (*get_query_result)(struct pipe_context *pipe,206struct pipe_query *q,207bool wait,208union pipe_query_result *result);209210/**211* Get results of a query, storing into resource. Note that this may not212* be used with batch queries.213*214* \param wait if true, this query will block until the result is ready215* \param result_type the type of the value being stored:216* \param index for queries that return multiple pieces of data, which217* item of that data to store (e.g. for218* PIPE_QUERY_PIPELINE_STATISTICS).219* When the index is -1, instead of the value of the query220* the driver should instead write a 1 or 0 to the appropriate221* location with 1 meaning that the query result is available.222*/223void (*get_query_result_resource)(struct pipe_context *pipe,224struct pipe_query *q,225bool wait,226enum pipe_query_value_type result_type,227int index,228struct pipe_resource *resource,229unsigned offset);230231/**232* Set whether all current non-driver queries except TIME_ELAPSED are233* active or paused.234*/235void (*set_active_query_state)(struct pipe_context *pipe, bool enable);236237/**238* INTEL Performance Query239*/240/*@{*/241242unsigned (*init_intel_perf_query_info)(struct pipe_context *pipe);243244void (*get_intel_perf_query_info)(struct pipe_context *pipe,245unsigned query_index,246const char **name,247uint32_t *data_size,248uint32_t *n_counters,249uint32_t *n_active);250251void (*get_intel_perf_query_counter_info)(struct pipe_context *pipe,252unsigned query_index,253unsigned counter_index,254const char **name,255const char **desc,256uint32_t *offset,257uint32_t *data_size,258uint32_t *type_enum,259uint32_t *data_type_enum,260uint64_t *raw_max);261262struct pipe_query *(*new_intel_perf_query_obj)(struct pipe_context *pipe,263unsigned query_index);264265bool (*begin_intel_perf_query)(struct pipe_context *pipe, struct pipe_query *q);266267void (*end_intel_perf_query)(struct pipe_context *pipe, struct pipe_query *q);268269void (*delete_intel_perf_query)(struct pipe_context *pipe, struct pipe_query *q);270271void (*wait_intel_perf_query)(struct pipe_context *pipe, struct pipe_query *q);272273bool (*is_intel_perf_query_ready)(struct pipe_context *pipe, struct pipe_query *q);274275bool (*get_intel_perf_query_data)(struct pipe_context *pipe,276struct pipe_query *q,277size_t data_size,278uint32_t *data,279uint32_t *bytes_written);280281/*@}*/282283/**284* State functions (create/bind/destroy state objects)285*/286/*@{*/287void * (*create_blend_state)(struct pipe_context *,288const struct pipe_blend_state *);289void (*bind_blend_state)(struct pipe_context *, void *);290void (*delete_blend_state)(struct pipe_context *, void *);291292void * (*create_sampler_state)(struct pipe_context *,293const struct pipe_sampler_state *);294void (*bind_sampler_states)(struct pipe_context *,295enum pipe_shader_type shader,296unsigned start_slot, unsigned num_samplers,297void **samplers);298void (*delete_sampler_state)(struct pipe_context *, void *);299300void * (*create_rasterizer_state)(struct pipe_context *,301const struct pipe_rasterizer_state *);302void (*bind_rasterizer_state)(struct pipe_context *, void *);303void (*delete_rasterizer_state)(struct pipe_context *, void *);304305void * (*create_depth_stencil_alpha_state)(struct pipe_context *,306const struct pipe_depth_stencil_alpha_state *);307void (*bind_depth_stencil_alpha_state)(struct pipe_context *, void *);308void (*delete_depth_stencil_alpha_state)(struct pipe_context *, void *);309310void * (*create_fs_state)(struct pipe_context *,311const struct pipe_shader_state *);312void (*bind_fs_state)(struct pipe_context *, void *);313void (*delete_fs_state)(struct pipe_context *, void *);314315void * (*create_vs_state)(struct pipe_context *,316const struct pipe_shader_state *);317void (*bind_vs_state)(struct pipe_context *, void *);318void (*delete_vs_state)(struct pipe_context *, void *);319320void * (*create_gs_state)(struct pipe_context *,321const struct pipe_shader_state *);322void (*bind_gs_state)(struct pipe_context *, void *);323void (*delete_gs_state)(struct pipe_context *, void *);324325void * (*create_tcs_state)(struct pipe_context *,326const struct pipe_shader_state *);327void (*bind_tcs_state)(struct pipe_context *, void *);328void (*delete_tcs_state)(struct pipe_context *, void *);329330void * (*create_tes_state)(struct pipe_context *,331const struct pipe_shader_state *);332void (*bind_tes_state)(struct pipe_context *, void *);333void (*delete_tes_state)(struct pipe_context *, void *);334335void * (*create_vertex_elements_state)(struct pipe_context *,336unsigned num_elements,337const struct pipe_vertex_element *);338void (*bind_vertex_elements_state)(struct pipe_context *, void *);339void (*delete_vertex_elements_state)(struct pipe_context *, void *);340341/*@}*/342343/**344* Parameter-like state (or properties)345*/346/*@{*/347void (*set_blend_color)( struct pipe_context *,348const struct pipe_blend_color * );349350void (*set_stencil_ref)( struct pipe_context *,351const struct pipe_stencil_ref ref);352353void (*set_sample_mask)( struct pipe_context *,354unsigned sample_mask );355356void (*set_min_samples)( struct pipe_context *,357unsigned min_samples );358359void (*set_clip_state)( struct pipe_context *,360const struct pipe_clip_state * );361362/**363* Set constant buffer364*365* \param shader Shader stage366* \param index Buffer binding slot index within a shader stage367* \param take_ownership The callee takes ownership of the buffer reference.368* (the callee shouldn't increment the ref count)369* \param buf Constant buffer parameters370*/371void (*set_constant_buffer)( struct pipe_context *,372enum pipe_shader_type shader, uint index,373bool take_ownership,374const struct pipe_constant_buffer *buf );375376/**377* Set inlinable constants for constant buffer 0.378*379* These are constants that the driver would like to inline in the IR380* of the current shader and recompile it. Drivers can determine which381* constants they prefer to inline in finalize_nir and store that382* information in shader_info::*inlinable_uniform*. When the state tracker383* or frontend uploads constants to a constant buffer, it can pass384* inlinable constants separately via this call.385*386* Any set_constant_buffer call invalidates this state, so this function387* must be called after it. Binding a shader also invalidates this state.388*389* There is no PIPE_CAP for this. Drivers shouldn't set the shader_info390* fields if they don't want this or if they don't implement this.391*/392void (*set_inlinable_constants)( struct pipe_context *,393enum pipe_shader_type shader,394uint num_values, uint32_t *values );395396void (*set_framebuffer_state)( struct pipe_context *,397const struct pipe_framebuffer_state * );398399/**400* Set the sample locations used during rasterization. When NULL or sized401* zero, the default locations are used.402*403* Note that get_sample_position() still returns the default locations.404*405* The samples are accessed with406* locations[(pixel_y*grid_w+pixel_x)*ms+i],407* where:408* ms = the sample count409* grid_w = the pixel grid width for the sample count410* grid_w = the pixel grid height for the sample count411* pixel_x = the window x coordinate modulo grid_w412* pixel_y = the window y coordinate modulo grid_w413* i = the sample index414* This gives a result with the x coordinate as the low 4 bits and the y415* coordinate as the high 4 bits. For each coordinate 0 is the left or top416* edge of the pixel's rectangle and 16 (not 15) is the right or bottom edge.417*418* Out of bounds accesses are return undefined values.419*420* The pixel grid is used to vary sample locations across pixels and its421* size can be queried with get_sample_pixel_grid().422*/423void (*set_sample_locations)( struct pipe_context *,424size_t size, const uint8_t *locations );425426void (*set_polygon_stipple)( struct pipe_context *,427const struct pipe_poly_stipple * );428429void (*set_scissor_states)( struct pipe_context *,430unsigned start_slot,431unsigned num_scissors,432const struct pipe_scissor_state * );433434void (*set_window_rectangles)( struct pipe_context *,435bool include,436unsigned num_rectangles,437const struct pipe_scissor_state * );438439void (*set_viewport_states)( struct pipe_context *,440unsigned start_slot,441unsigned num_viewports,442const struct pipe_viewport_state *);443444void (*set_sampler_views)(struct pipe_context *,445enum pipe_shader_type shader,446unsigned start_slot, unsigned num_views,447unsigned unbind_num_trailing_slots,448struct pipe_sampler_view **views);449450void (*set_tess_state)(struct pipe_context *,451const float default_outer_level[4],452const float default_inner_level[2]);453454/**455* Sets the debug callback. If the pointer is null, then no callback is456* set, otherwise a copy of the data should be made.457*/458void (*set_debug_callback)(struct pipe_context *,459const struct pipe_debug_callback *);460461/**462* Bind an array of shader buffers that will be used by a shader.463* Any buffers that were previously bound to the specified range464* will be unbound.465*466* \param shader selects shader stage467* \param start_slot first buffer slot to bind.468* \param count number of consecutive buffers to bind.469* \param buffers array of pointers to the buffers to bind, it470* should contain at least \a count elements471* unless it's NULL, in which case no buffers will472* be bound.473* \param writable_bitmask If bit i is not set, buffers[i] will only be474* used with loads. If unsure, set to ~0.475*/476void (*set_shader_buffers)(struct pipe_context *,477enum pipe_shader_type shader,478unsigned start_slot, unsigned count,479const struct pipe_shader_buffer *buffers,480unsigned writable_bitmask);481482/**483* Bind an array of hw atomic buffers for use by all shaders.484* And buffers that were previously bound to the specified range485* will be unbound.486*487* \param start_slot first buffer slot to bind.488* \param count number of consecutive buffers to bind.489* \param buffers array of pointers to the buffers to bind, it490* should contain at least \a count elements491* unless it's NULL, in which case no buffers will492* be bound.493*/494void (*set_hw_atomic_buffers)(struct pipe_context *,495unsigned start_slot, unsigned count,496const struct pipe_shader_buffer *buffers);497498/**499* Bind an array of images that will be used by a shader.500* Any images that were previously bound to the specified range501* will be unbound.502*503* \param shader selects shader stage504* \param start_slot first image slot to bind.505* \param count number of consecutive images to bind.506* \param unbind_num_trailing_slots number of images to unbind after507* the bound slot508* \param buffers array of the images to bind, it509* should contain at least \a count elements510* unless it's NULL, in which case no images will511* be bound.512*/513void (*set_shader_images)(struct pipe_context *,514enum pipe_shader_type shader,515unsigned start_slot, unsigned count,516unsigned unbind_num_trailing_slots,517const struct pipe_image_view *images);518519/**520* Bind an array of vertex buffers to the specified slots.521*522* \param start_slot first vertex buffer slot523* \param count number of consecutive vertex buffers to bind.524* \param unbind_num_trailing_slots unbind slots after the bound slots525* \param take_ownership the caller holds buffer references and they526* should be taken over by the callee. This means527* that drivers shouldn't increment reference counts.528* \param buffers array of the buffers to bind529*/530void (*set_vertex_buffers)( struct pipe_context *,531unsigned start_slot,532unsigned num_buffers,533unsigned unbind_num_trailing_slots,534bool take_ownership,535const struct pipe_vertex_buffer * );536537/*@}*/538539/**540* Stream output functions.541*/542/*@{*/543544struct pipe_stream_output_target *(*create_stream_output_target)(545struct pipe_context *,546struct pipe_resource *,547unsigned buffer_offset,548unsigned buffer_size);549550void (*stream_output_target_destroy)(struct pipe_context *,551struct pipe_stream_output_target *);552553void (*set_stream_output_targets)(struct pipe_context *,554unsigned num_targets,555struct pipe_stream_output_target **targets,556const unsigned *offsets);557558uint32_t (*stream_output_target_offset)(struct pipe_stream_output_target *target);559560/*@}*/561562563/**564* INTEL_blackhole_render565*/566/*@{*/567568void (*set_frontend_noop)(struct pipe_context *,569bool enable);570571/*@}*/572573574/**575* Resource functions for blit-like functionality576*577* If a driver supports multisampling, blit must implement color resolve.578*/579/*@{*/580581/**582* Copy a block of pixels from one resource to another.583* The resource must be of the same format.584* Resources with nr_samples > 1 are not allowed.585*/586void (*resource_copy_region)(struct pipe_context *pipe,587struct pipe_resource *dst,588unsigned dst_level,589unsigned dstx, unsigned dsty, unsigned dstz,590struct pipe_resource *src,591unsigned src_level,592const struct pipe_box *src_box);593594/* Optimal hardware path for blitting pixels.595* Scaling, format conversion, up- and downsampling (resolve) are allowed.596*/597void (*blit)(struct pipe_context *pipe,598const struct pipe_blit_info *info);599600/*@}*/601602/**603* Clear the specified set of currently bound buffers to specified values.604* The entire buffers are cleared (no scissor, no colormask, etc).605*606* \param buffers bitfield of PIPE_CLEAR_* values.607* \param scissor_state the scissored region to clear608* \param color pointer to a union of fiu array for each of r, g, b, a.609* \param depth depth clear value in [0,1].610* \param stencil stencil clear value611*/612void (*clear)(struct pipe_context *pipe,613unsigned buffers,614const struct pipe_scissor_state *scissor_state,615const union pipe_color_union *color,616double depth,617unsigned stencil);618619/**620* Clear a color rendertarget surface.621* \param color pointer to an union of fiu array for each of r, g, b, a.622*/623void (*clear_render_target)(struct pipe_context *pipe,624struct pipe_surface *dst,625const union pipe_color_union *color,626unsigned dstx, unsigned dsty,627unsigned width, unsigned height,628bool render_condition_enabled);629630/**631* Clear a depth-stencil surface.632* \param clear_flags bitfield of PIPE_CLEAR_DEPTH/STENCIL values.633* \param depth depth clear value in [0,1].634* \param stencil stencil clear value635*/636void (*clear_depth_stencil)(struct pipe_context *pipe,637struct pipe_surface *dst,638unsigned clear_flags,639double depth,640unsigned stencil,641unsigned dstx, unsigned dsty,642unsigned width, unsigned height,643bool render_condition_enabled);644645/**646* Clear the texture with the specified texel. Not guaranteed to be a647* renderable format. Data provided in the resource's format.648*/649void (*clear_texture)(struct pipe_context *pipe,650struct pipe_resource *res,651unsigned level,652const struct pipe_box *box,653const void *data);654655/**656* Clear a buffer. Runs a memset over the specified region with the element657* value passed in through clear_value of size clear_value_size.658*/659void (*clear_buffer)(struct pipe_context *pipe,660struct pipe_resource *res,661unsigned offset,662unsigned size,663const void *clear_value,664int clear_value_size);665666/**667* If a depth buffer is rendered with different sample location state than668* what is current at the time of reading, the values may differ because669* depth buffer compression can depend the sample locations.670*671* This function is a hint to decompress the current depth buffer to avoid672* such problems.673*/674void (*evaluate_depth_buffer)(struct pipe_context *pipe);675676/**677* Flush draw commands.678*679* This guarantees that the new fence (if any) will finish in finite time,680* unless PIPE_FLUSH_DEFERRED is used.681*682* Subsequent operations on other contexts of the same screen are guaranteed683* to execute after the flushed commands, unless PIPE_FLUSH_ASYNC is used.684*685* NOTE: use screen->fence_reference() (or equivalent) to transfer686* new fence ref to **fence, to ensure that previous fence is unref'd687*688* \param fence if not NULL, an old fence to unref and transfer a689* new fence reference to690* \param flags bitfield of enum pipe_flush_flags values.691*/692void (*flush)(struct pipe_context *pipe,693struct pipe_fence_handle **fence,694unsigned flags);695696/**697* Create a fence from a fd.698*699* This is used for importing a foreign/external fence fd.700*701* \param fence if not NULL, an old fence to unref and transfer a702* new fence reference to703* \param fd fd representing the fence object704* \param type indicates which fence types backs fd705*/706void (*create_fence_fd)(struct pipe_context *pipe,707struct pipe_fence_handle **fence,708int fd,709enum pipe_fd_type type);710711/**712* Insert commands to have GPU wait for fence to be signaled.713*/714void (*fence_server_sync)(struct pipe_context *pipe,715struct pipe_fence_handle *fence);716717/**718* Insert commands to have the GPU signal a fence.719*/720void (*fence_server_signal)(struct pipe_context *pipe,721struct pipe_fence_handle *fence);722723/**724* Create a view on a texture to be used by a shader stage.725*/726struct pipe_sampler_view * (*create_sampler_view)(struct pipe_context *ctx,727struct pipe_resource *texture,728const struct pipe_sampler_view *templat);729730/**731* Destroy a view on a texture.732*733* \param ctx the current context734* \param view the view to be destroyed735*736* \note The current context may not be the context in which the view was737* created (view->context). However, the caller must guarantee that738* the context which created the view is still alive.739*/740void (*sampler_view_destroy)(struct pipe_context *ctx,741struct pipe_sampler_view *view);742743744/**745* Get a surface which is a "view" into a resource, used by746* render target / depth stencil stages.747*/748struct pipe_surface *(*create_surface)(struct pipe_context *ctx,749struct pipe_resource *resource,750const struct pipe_surface *templat);751752void (*surface_destroy)(struct pipe_context *ctx,753struct pipe_surface *);754755756/**757* Map a resource.758*759* Transfers are (by default) context-private and allow uploads to be760* interleaved with rendering.761*762* out_transfer will contain the transfer object that must be passed763* to all the other transfer functions. It also contains useful764* information (like texture strides for texture_map).765*/766void *(*buffer_map)(struct pipe_context *,767struct pipe_resource *resource,768unsigned level,769unsigned usage, /* a combination of PIPE_MAP_x */770const struct pipe_box *,771struct pipe_transfer **out_transfer);772773/* If transfer was created with WRITE|FLUSH_EXPLICIT, only the774* regions specified with this call are guaranteed to be written to775* the resource.776*/777void (*transfer_flush_region)( struct pipe_context *,778struct pipe_transfer *transfer,779const struct pipe_box *);780781void (*buffer_unmap)(struct pipe_context *,782struct pipe_transfer *transfer);783784void *(*texture_map)(struct pipe_context *,785struct pipe_resource *resource,786unsigned level,787unsigned usage, /* a combination of PIPE_MAP_x */788const struct pipe_box *,789struct pipe_transfer **out_transfer);790791void (*texture_unmap)(struct pipe_context *,792struct pipe_transfer *transfer);793794/* One-shot transfer operation with data supplied in a user795* pointer.796*/797void (*buffer_subdata)(struct pipe_context *,798struct pipe_resource *,799unsigned usage, /* a combination of PIPE_MAP_x */800unsigned offset,801unsigned size,802const void *data);803804void (*texture_subdata)(struct pipe_context *,805struct pipe_resource *,806unsigned level,807unsigned usage, /* a combination of PIPE_MAP_x */808const struct pipe_box *,809const void *data,810unsigned stride,811unsigned layer_stride);812813/**814* Flush any pending framebuffer writes and invalidate texture caches.815*/816void (*texture_barrier)(struct pipe_context *, unsigned flags);817818/**819* Flush caches according to flags.820*/821void (*memory_barrier)(struct pipe_context *, unsigned flags);822823/**824* Change the commitment status of a part of the given resource, which must825* have been created with the PIPE_RESOURCE_FLAG_SPARSE bit.826*827* \param level The texture level whose commitment should be changed.828* \param box The region of the resource whose commitment should be changed.829* \param commit Whether memory should be committed or un-committed.830*831* \return false if out of memory, true on success.832*/833bool (*resource_commit)(struct pipe_context *, struct pipe_resource *,834unsigned level, struct pipe_box *box, bool commit);835836/**837* Creates a video codec for a specific video format/profile838*/839struct pipe_video_codec *(*create_video_codec)( struct pipe_context *context,840const struct pipe_video_codec *templat );841842/**843* Creates a video buffer as decoding target844*/845struct pipe_video_buffer *(*create_video_buffer)( struct pipe_context *context,846const struct pipe_video_buffer *templat );847848/**849* Compute kernel execution850*/851/*@{*/852/**853* Define the compute program and parameters to be used by854* pipe_context::launch_grid.855*/856void *(*create_compute_state)(struct pipe_context *context,857const struct pipe_compute_state *);858void (*bind_compute_state)(struct pipe_context *, void *);859void (*delete_compute_state)(struct pipe_context *, void *);860861/**862* Bind an array of shader resources that will be used by the863* compute program. Any resources that were previously bound to864* the specified range will be unbound after this call.865*866* \param start first resource to bind.867* \param count number of consecutive resources to bind.868* \param resources array of pointers to the resources to bind, it869* should contain at least \a count elements870* unless it's NULL, in which case no new871* resources will be bound.872*/873void (*set_compute_resources)(struct pipe_context *,874unsigned start, unsigned count,875struct pipe_surface **resources);876877/**878* Bind an array of buffers to be mapped into the address space of879* the GLOBAL resource. Any buffers that were previously bound880* between [first, first + count - 1] are unbound after this call.881*882* \param first first buffer to map.883* \param count number of consecutive buffers to map.884* \param resources array of pointers to the buffers to map, it885* should contain at least \a count elements886* unless it's NULL, in which case no new887* resources will be bound.888* \param handles array of pointers to the memory locations that889* will be updated with the address each buffer890* will be mapped to. The base memory address of891* each of the buffers will be added to the value892* pointed to by its corresponding handle to form893* the final address argument. It should contain894* at least \a count elements, unless \a895* resources is NULL in which case \a handles896* should be NULL as well.897*898* Note that the driver isn't required to make any guarantees about899* the contents of the \a handles array being valid anytime except900* during the subsequent calls to pipe_context::launch_grid. This901* means that the only sensible location handles[i] may point to is902* somewhere within the INPUT buffer itself. This is so to903* accommodate implementations that lack virtual memory but904* nevertheless migrate buffers on the fly, leading to resource905* base addresses that change on each kernel invocation or are906* unknown to the pipe driver.907*/908void (*set_global_binding)(struct pipe_context *context,909unsigned first, unsigned count,910struct pipe_resource **resources,911uint32_t **handles);912913/**914* Launch the compute kernel starting from instruction \a pc of the915* currently bound compute program.916*/917void (*launch_grid)(struct pipe_context *context,918const struct pipe_grid_info *info);919/*@}*/920921/**922* SVM (Share Virtual Memory) helpers923*/924/*@{*/925/**926* Migrate range of virtual address to device or host memory.927*928* \param to_device - true if the virtual memory is migrated to the device929* false if the virtual memory is migrated to the host930* \param migrate_content - whether the content should be migrated as well931*/932void (*svm_migrate)(struct pipe_context *context, unsigned num_ptrs,933const void* const* ptrs, const size_t *sizes,934bool to_device, bool migrate_content);935/*@}*/936937/**938* Get the default sample position for an individual sample point.939*940* \param sample_count - total number of samples941* \param sample_index - sample to get the position values for942* \param out_value - return value of 2 floats for x and y position for943* requested sample.944*/945void (*get_sample_position)(struct pipe_context *context,946unsigned sample_count,947unsigned sample_index,948float *out_value);949950/**951* Query a timestamp in nanoseconds. This is completely equivalent to952* pipe_screen::get_timestamp() but takes a context handle for drivers953* that require a context.954*/955uint64_t (*get_timestamp)(struct pipe_context *);956957/**958* Flush the resource cache, so that the resource can be used959* by an external client. Possible usage:960* - flushing a resource before presenting it on the screen961* - flushing a resource if some other process or device wants to use it962* This shouldn't be used to flush caches if the resource is only managed963* by a single pipe_screen and is not shared with another process.964* (i.e. you shouldn't use it to flush caches explicitly if you want to e.g.965* use the resource for texturing)966*/967void (*flush_resource)(struct pipe_context *ctx,968struct pipe_resource *resource);969970/**971* Invalidate the contents of the resource. This is used to972*973* (1) implement EGL's semantic of undefined depth/stencil974* contents after a swapbuffers. This allows a tiled renderer (for975* example) to not store the depth buffer.976*977* (2) implement GL's InvalidateBufferData. For backwards compatibility,978* you must only rely on the usability for this purpose when979* PIPE_CAP_INVALIDATE_BUFFER is enabled.980*/981void (*invalidate_resource)(struct pipe_context *ctx,982struct pipe_resource *resource);983984/**985* Return information about unexpected device resets.986*/987enum pipe_reset_status (*get_device_reset_status)(struct pipe_context *ctx);988989/**990* Sets the reset status callback. If the pointer is null, then no callback991* is set, otherwise a copy of the data should be made.992*/993void (*set_device_reset_callback)(struct pipe_context *ctx,994const struct pipe_device_reset_callback *cb);995996/**997* Dump driver-specific debug information into a stream. This is998* used by debugging tools.999*1000* \param ctx pipe context1001* \param stream where the output should be written to1002* \param flags a mask of PIPE_DUMP_* flags1003*/1004void (*dump_debug_state)(struct pipe_context *ctx, FILE *stream,1005unsigned flags);10061007/**1008* Set the log context to which the driver should write internal debug logs1009* (internal states, command streams).1010*1011* The caller must ensure that the log context is destroyed and reset to1012* NULL before the pipe context is destroyed, and that log context functions1013* are only called from the driver thread.1014*1015* \param ctx pipe context1016* \param log logging context1017*/1018void (*set_log_context)(struct pipe_context *ctx, struct u_log_context *log);10191020/**1021* Emit string marker in cmdstream1022*/1023void (*emit_string_marker)(struct pipe_context *ctx,1024const char *string,1025int len);10261027/**1028* Generate mipmap.1029* \return TRUE if mipmap generation succeeds, FALSE otherwise1030*/1031bool (*generate_mipmap)(struct pipe_context *ctx,1032struct pipe_resource *resource,1033enum pipe_format format,1034unsigned base_level,1035unsigned last_level,1036unsigned first_layer,1037unsigned last_layer);10381039/**1040* Create a 64-bit texture handle.1041*1042* \param ctx pipe context1043* \param view pipe sampler view object1044* \param state pipe sampler state template1045* \return a 64-bit texture handle if success, 0 otherwise1046*/1047uint64_t (*create_texture_handle)(struct pipe_context *ctx,1048struct pipe_sampler_view *view,1049const struct pipe_sampler_state *state);10501051/**1052* Delete a texture handle.1053*1054* \param ctx pipe context1055* \param handle 64-bit texture handle1056*/1057void (*delete_texture_handle)(struct pipe_context *ctx, uint64_t handle);10581059/**1060* Make a texture handle resident.1061*1062* \param ctx pipe context1063* \param handle 64-bit texture handle1064* \param resident TRUE for resident, FALSE otherwise1065*/1066void (*make_texture_handle_resident)(struct pipe_context *ctx,1067uint64_t handle, bool resident);10681069/**1070* Create a 64-bit image handle.1071*1072* \param ctx pipe context1073* \param image pipe image view template1074* \return a 64-bit image handle if success, 0 otherwise1075*/1076uint64_t (*create_image_handle)(struct pipe_context *ctx,1077const struct pipe_image_view *image);10781079/**1080* Delete an image handle.1081*1082* \param ctx pipe context1083* \param handle 64-bit image handle1084*/1085void (*delete_image_handle)(struct pipe_context *ctx, uint64_t handle);10861087/**1088* Make an image handle resident.1089*1090* \param ctx pipe context1091* \param handle 64-bit image handle1092* \param access GL_READ_ONLY, GL_WRITE_ONLY or GL_READ_WRITE1093* \param resident TRUE for resident, FALSE otherwise1094*/1095void (*make_image_handle_resident)(struct pipe_context *ctx, uint64_t handle,1096unsigned access, bool resident);10971098/**1099* Call the given function from the driver thread.1100*1101* This is set by threaded contexts for use by debugging wrappers.1102*1103* \param asap if true, run the callback immediately if there are no pending1104* commands to be processed by the driver thread1105*/1106void (*callback)(struct pipe_context *ctx, void (*fn)(void *), void *data,1107bool asap);11081109/**1110* Set a context parameter See enum pipe_context_param for more details.1111*/1112void (*set_context_param)(struct pipe_context *ctx,1113enum pipe_context_param param,1114unsigned value);11151116/**1117* Creates a video buffer as decoding target, with modifiers.1118*/1119struct pipe_video_buffer *(*create_video_buffer_with_modifiers)(struct pipe_context *context,1120const struct pipe_video_buffer *templat,1121const uint64_t *modifiers,1122unsigned int modifiers_count);1123};112411251126#ifdef __cplusplus1127}1128#endif11291130#endif /* PIPE_CONTEXT_H */113111321133