gallium: change comments to remove 'state tracker'
[mesa.git] / src / gallium / include / pipe / p_screen.h
index b6623d1dd71e71de264014e84b83f497f008f5bd..a4b07c8ee251bc7985957f541a4ec238af00a1c7 100644 (file)
@@ -60,7 +60,7 @@ struct pipe_box;
 struct pipe_memory_info;
 struct disk_cache;
 struct driOptionCache;
-
+struct u_transfer_helper;
 
 /**
  * Gallium screen/adapter context.  Basically everything
@@ -68,6 +68,12 @@ struct driOptionCache;
  * context.
  */
 struct pipe_screen {
+
+   /**
+    * For drivers using u_transfer_helper:
+    */
+   struct u_transfer_helper *transfer_helper;
+
    void (*destroy)( struct pipe_screen * );
 
    const char *(*get_name)( struct pipe_screen * );
@@ -125,6 +131,17 @@ struct pipe_screen {
                            enum pipe_compute_cap param,
                            void *ret);
 
+   /**
+    * Get the sample pixel grid's size. This function requires
+    * PIPE_CAP_PROGRAMMABLE_SAMPLE_LOCATIONS to be callable.
+    *
+    * \param sample_count - total number of samples
+    * \param out_width - the width of the pixel grid
+    * \param out_height - the height of the pixel grid
+    */
+   void (*get_sample_pixel_grid)(struct pipe_screen *, unsigned sample_count,
+                                 unsigned *out_width, unsigned *out_height);
+
    /**
     * Query a timestamp in nanoseconds. The returned value should match
     * PIPE_QUERY_TIMESTAMP. This function returns immediately and doesn't
@@ -147,28 +164,29 @@ struct pipe_screen {
     * drawing surface.
     * \param bindings  bitmask of PIPE_BIND_*
     */
-   boolean (*is_format_supported)( struct pipe_screen *,
-                                   enum pipe_format format,
-                                   enum pipe_texture_target target,
-                                   unsigned sample_count,
-                                   unsigned bindings );
+   bool (*is_format_supported)( struct pipe_screen *,
+                                enum pipe_format format,
+                                enum pipe_texture_target target,
+                                unsigned sample_count,
+                                unsigned storage_sample_count,
+                                unsigned bindings );
 
    /**
     * Check if the given pipe_format is supported as output for this codec/profile.
     * \param profile  profile to check, may also be PIPE_VIDEO_PROFILE_UNKNOWN
     */
-   boolean (*is_video_format_supported)( struct pipe_screen *,
-                                         enum pipe_format format,
-                                         enum pipe_video_profile profile,
-                                         enum pipe_video_entrypoint entrypoint );
+   bool (*is_video_format_supported)( struct pipe_screen *,
+                                      enum pipe_format format,
+                                      enum pipe_video_profile profile,
+                                      enum pipe_video_entrypoint entrypoint );
 
    /**
     * Check if we can actually create the given resource (test the dimension,
     * overall size, etc).  Used to implement proxy textures.
     * \return TRUE if size is OK, FALSE if too large.
     */
-   boolean (*can_create_resource)(struct pipe_screen *screen,
-                                  const struct pipe_resource *templat);
+   bool (*can_create_resource)(struct pipe_screen *screen,
+                               const struct pipe_resource *templat);
 
    /**
     * Create a new texture object, using the given template info.
@@ -185,7 +203,7 @@ struct pipe_screen {
     * another process by first creating a pipe texture and then calling
     * resource_get_handle.
     *
-    * NOTE: in the case of DRM_API_HANDLE_TYPE_FD handles, the caller
+    * NOTE: in the case of WINSYS_HANDLE_TYPE_FD handles, the caller
     * retains ownership of the FD.  (This is consistent with
     * EGL_EXT_image_dma_buf_import)
     *
@@ -204,6 +222,23 @@ struct pipe_screen {
                                                        const struct pipe_resource *t,
                                                        void *user_memory);
 
+   /**
+    * Unlike pipe_resource::bind, which describes what gallium frontends want,
+    * resources can have much greater capabilities in practice, often implied
+    * by the tiling layout or memory placement. This function allows querying
+    * whether a capability is supported beyond what was requested by state
+    * trackers. It's also useful for querying capabilities of imported
+    * resources where the capabilities are unknown at first.
+    *
+    * Only these flags are allowed:
+    * - PIPE_BIND_SCANOUT
+    * - PIPE_BIND_CURSOR
+    * - PIPE_BIND_LINEAR
+    */
+   bool (*check_resource_capability)(struct pipe_screen *screen,
+                                     struct pipe_resource *resource,
+                                     unsigned bind);
+
    /**
     * Get a winsys_handle from a texture. Some platforms/winsys requires
     * that the texture is created with a special usage flag like
@@ -215,17 +250,45 @@ struct pipe_screen {
     * the resource into a format compatible for sharing. The use case is
     * OpenGL-OpenCL interop. The context parameter is allowed to be NULL.
     *
-    * NOTE: in the case of DRM_API_HANDLE_TYPE_FD handles, the caller
+    * NOTE: in the case of WINSYS_HANDLE_TYPE_FD handles, the caller
     * takes ownership of the FD.  (This is consistent with
     * EGL_MESA_image_dma_buf_export)
     *
     * \param usage  A combination of PIPE_HANDLE_USAGE_* flags.
     */
-   boolean (*resource_get_handle)(struct pipe_screen *,
-                                  struct pipe_context *context,
-                                 struct pipe_resource *tex,
-                                 struct winsys_handle *handle,
-                                 unsigned usage);
+   bool (*resource_get_handle)(struct pipe_screen *,
+                               struct pipe_context *context,
+                               struct pipe_resource *tex,
+                               struct winsys_handle *handle,
+                               unsigned usage);
+
+   /**
+    * Get info for the given pipe resource without the need to get a
+    * winsys_handle.
+    *
+    * The context parameter can optionally be used to flush the resource and
+    * the context to make sure the resource is coherent with whatever user
+    * will use it. Some drivers may also use the context to convert
+    * the resource into a format compatible for sharing. The context parameter
+    * is allowed to be NULL.
+    */
+   bool (*resource_get_param)(struct pipe_screen *screen,
+                              struct pipe_context *context,
+                              struct pipe_resource *resource,
+                              unsigned plane,
+                              unsigned layer,
+                              enum pipe_resource_param param,
+                              unsigned handle_usage,
+                              uint64_t *value);
+
+   /**
+    * Get stride and offset for the given pipe resource without the need to get
+    * a winsys_handle.
+    */
+   void (*resource_get_info)(struct pipe_screen *screen,
+                             struct pipe_resource *resource,
+                             unsigned *stride,
+                             unsigned *offset);
 
    /**
     * Mark the resource as changed so derived internal resources will be
@@ -270,10 +333,10 @@ struct pipe_screen {
     *
     * \param timeout  in nanoseconds (may be PIPE_TIMEOUT_INFINITE).
     */
-   boolean (*fence_finish)(struct pipe_screen *screen,
-                           struct pipe_context *ctx,
-                           struct pipe_fence_handle *fence,
-                           uint64_t timeout);
+   bool (*fence_finish)(struct pipe_screen *screen,
+                        struct pipe_context *ctx,
+                        struct pipe_fence_handle *fence,
+                        uint64_t timeout);
 
    /**
     * For fences created with PIPE_FLUSH_FENCE_FD (exported fd) or
@@ -358,6 +421,96 @@ struct pipe_screen {
                                   enum pipe_format format, int max,
                                   uint64_t *modifiers,
                                   unsigned int *external_only, int *count);
+
+   /**
+    * Create a memory object from a winsys handle
+    *
+    * The underlying memory is most often allocated in by a foregin API.
+    * Then the underlying memory object is then exported through interfaces
+    * compatible with EXT_external_resources.
+    *
+    * Note: For WINSYS_HANDLE_TYPE_FD handles, the caller retains ownership
+    * of the fd.
+    *
+    * \param handle  A handle representing the memory object to import
+    */
+   struct pipe_memory_object *(*memobj_create_from_handle)(struct pipe_screen *screen,
+                                                           struct winsys_handle *handle,
+                                                           bool dedicated);
+
+   /**
+    * Destroy a memory object
+    *
+    * \param memobj  The memory object to destroy
+    */
+   void (*memobj_destroy)(struct pipe_screen *screen,
+                          struct pipe_memory_object *memobj);
+
+   /**
+    * Create a texture from a memory object
+    *
+    * \param t       texture template
+    * \param memobj  The memory object used to back the texture
+    */
+   struct pipe_resource * (*resource_from_memobj)(struct pipe_screen *screen,
+                                                  const struct pipe_resource *t,
+                                                  struct pipe_memory_object *memobj,
+                                                  uint64_t offset);
+
+   /**
+    * Fill @uuid with a unique driver identifier
+    *
+    * \param uuid    pointer to a memory region of PIPE_UUID_SIZE bytes
+    */
+   void (*get_driver_uuid)(struct pipe_screen *screen, char *uuid);
+
+   /**
+    * Fill @uuid with a unique device identifier
+    *
+    * \param uuid    pointer to a memory region of PIPE_UUID_SIZE bytes
+    */
+   void (*get_device_uuid)(struct pipe_screen *screen, char *uuid);
+
+   /**
+    * Set the maximum number of parallel shader compiler threads.
+    */
+   void (*set_max_shader_compiler_threads)(struct pipe_screen *screen,
+                                           unsigned max_threads);
+
+   /**
+    * Return whether parallel shader compilation has finished.
+    */
+   bool (*is_parallel_shader_compilation_finished)(struct pipe_screen *screen,
+                                                   void *shader,
+                                                   unsigned shader_type);
+
+   /**
+    * Set the damage region (called when KHR_partial_update() is invoked).
+    * This function is passed an array of rectangles encoding the damage area.
+    * rects are using the bottom-left origin convention.
+    * nrects = 0 means 'reset the damage region'. What 'reset' implies is HW
+    * specific. For tile-based renderers, the damage extent is typically set
+    * to cover the whole resource with no damage rect (or a 0-size damage
+    * rect). This way, the existing resource content is reloaded into the
+    * local tile buffer for every tile thus making partial tile update
+    * possible. For HW operating in immediate mode, this reset operation is
+    * likely to be a NOOP.
+    */
+   void (*set_damage_region)(struct pipe_screen *screen,
+                             struct pipe_resource *resource,
+                             unsigned int nrects,
+                             const struct pipe_box *rects);
+
+   /**
+    * Run driver-specific NIR lowering and optimization passes.
+    *
+    * gallium frontends should call this before passing shaders to drivers,
+    * and ideally also before shader caching.
+    *
+    * \param optimize  Whether the input shader hasn't been optimized and
+    *                  should be.
+    */
+   void (*finalize_nir)(struct pipe_screen *screen, void *nir, bool optimize);
 };