[Mesa-dev,04/19] gallium: introduce memory object

Submitted by Andres Rodriguez on June 30, 2017, 11:02 p.m.

Details

Message ID 20170630230312.23213-5-andresx7@gmail.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Andres Rodriguez June 30, 2017, 11:02 p.m.
From: Dave Airlie <airlied@redhat.com>

---
 src/gallium/include/pipe/p_screen.h | 36 ++++++++++++++++++++++++++++++++++++
 src/gallium/include/pipe/p_state.h  |  2 ++
 2 files changed, 38 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
index 65e954a..929dc8f 100644
--- a/src/gallium/include/pipe/p_screen.h
+++ b/src/gallium/include/pipe/p_screen.h
@@ -357,6 +357,42 @@  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 DRM_API_HANDLE_TYPE_FD handles, ownership of the fd is
+    * transferred to the driver implementation. This is consistent with
+    * EXT_external_object_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);
+
+   /**
+    * 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);
+
 };
 
 
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 15be8cb..acbb73f 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -888,6 +888,8 @@  struct pipe_memory_info
    unsigned nr_device_memory_evictions; /**< # of evictions (monotonic counter) */
 };
 
+struct pipe_memory_object;
+
 #ifdef __cplusplus
 }
 #endif

Comments

On 01.07.2017 01:02, Andres Rodriguez wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> ---
>   src/gallium/include/pipe/p_screen.h | 36 ++++++++++++++++++++++++++++++++++++
>   src/gallium/include/pipe/p_state.h  |  2 ++
>   2 files changed, 38 insertions(+)
> 
> diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
> index 65e954a..929dc8f 100644
> --- a/src/gallium/include/pipe/p_screen.h
> +++ b/src/gallium/include/pipe/p_screen.h
> @@ -357,6 +357,42 @@ 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 DRM_API_HANDLE_TYPE_FD handles, ownership of the fd is
> +    * transferred to the driver implementation. This is consistent with
> +    * EXT_external_object_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);
> +
> +   /**
> +    * 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);
> +

Please add these to ddebug as well.

Cheers,
Nicolai


>   };
>   
>   
> diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
> index 15be8cb..acbb73f 100644
> --- a/src/gallium/include/pipe/p_state.h
> +++ b/src/gallium/include/pipe/p_state.h
> @@ -888,6 +888,8 @@ struct pipe_memory_info
>      unsigned nr_device_memory_evictions; /**< # of evictions (monotonic counter) */
>   };
>   
> +struct pipe_memory_object;
> +
>   #ifdef __cplusplus
>   }
>   #endif
>
On 2017-07-04 09:19 AM, Nicolai Hähnle wrote:
> On 01.07.2017 01:02, Andres Rodriguez wrote:
>> From: Dave Airlie <airlied@redhat.com>
>>
>> ---
>>   src/gallium/include/pipe/p_screen.h | 36 
>> ++++++++++++++++++++++++++++++++++++
>>   src/gallium/include/pipe/p_state.h  |  2 ++
>>   2 files changed, 38 insertions(+)
>>
>> diff --git a/src/gallium/include/pipe/p_screen.h 
>> b/src/gallium/include/pipe/p_screen.h
>> index 65e954a..929dc8f 100644
>> --- a/src/gallium/include/pipe/p_screen.h
>> +++ b/src/gallium/include/pipe/p_screen.h
>> @@ -357,6 +357,42 @@ 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 DRM_API_HANDLE_TYPE_FD handles, ownership of the fd is
>> +    * transferred to the driver implementation. This is consistent with
>> +    * EXT_external_object_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);
>> +
>> +   /**
>> +    * 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);
>> +
> 
> Please add these to ddebug as well.
> 

Thanks, will fix.

-Andres

> Cheers,
> Nicolai
> 
> 
>>   };
>> diff --git a/src/gallium/include/pipe/p_state.h 
>> b/src/gallium/include/pipe/p_state.h
>> index 15be8cb..acbb73f 100644
>> --- a/src/gallium/include/pipe/p_state.h
>> +++ b/src/gallium/include/pipe/p_state.h
>> @@ -888,6 +888,8 @@ struct pipe_memory_info
>>      unsigned nr_device_memory_evictions; /**< # of evictions 
>> (monotonic counter) */
>>   };
>> +struct pipe_memory_object;
>> +
>>   #ifdef __cplusplus
>>   }
>>   #endif
>>
> 
>