[Mesa-dev] [PATCH 2/6] gallium: add interface and state tracker support for GL_AMD_pinned_memory

Marek Olšák maraeo at gmail.com
Mon Feb 16 13:25:29 PST 2015


On Thu, Feb 12, 2015 at 3:11 PM, Roland Scheidegger <sroland at vmware.com> wrote:
> Am 11.02.2015 um 21:18 schrieb Marek Olšák:
>> From: Marek Olšák <marek.olsak at amd.com>
>>
>> ---
>>  src/gallium/docs/source/screen.rst             |  5 +++++
>>  src/gallium/drivers/i915/i915_screen.c         |  1 +
>>  src/gallium/drivers/ilo/ilo_screen.c           |  1 +
>>  src/gallium/drivers/llvmpipe/lp_screen.c       |  1 +
>>  src/gallium/drivers/nouveau/nv30/nv30_screen.c |  1 +
>>  src/gallium/drivers/nouveau/nv50/nv50_screen.c |  1 +
>>  src/gallium/drivers/nouveau/nvc0/nvc0_screen.c |  1 +
>>  src/gallium/drivers/r300/r300_screen.c         |  1 +
>>  src/gallium/drivers/softpipe/sp_screen.c       |  1 +
>>  src/gallium/drivers/svga/svga_screen.c         |  1 +
>>  src/gallium/drivers/vc4/vc4_screen.c           |  1 +
>>  src/gallium/include/pipe/p_defines.h           |  1 +
>>  src/gallium/include/pipe/p_screen.h            |  8 ++++++++
>>  src/mesa/state_tracker/st_cb_bufferobjects.c   | 18 +++++++++++++-----
>>  src/mesa/state_tracker/st_extensions.c         |  1 +
>>  15 files changed, 38 insertions(+), 5 deletions(-)
>>
>> diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst
>> index aa519d2..313980a 100644
>> --- a/src/gallium/docs/source/screen.rst
>> +++ b/src/gallium/docs/source/screen.rst
>> @@ -246,6 +246,11 @@ The integer capabilities:
>>  * ``PIPE_CAP_MULTISAMPLE_Z_RESOLVE``: Whether the driver supports blitting
>>    a multisampled depth buffer into a single-sampled texture (or depth buffer).
>>    Only the first sampled should be copied.
>> +* ``PIPE_CAP_RESOURCE_FROM_USER_MEMORY``: Whether the driver can create
>> +  a pipe_resource where an already-existing piece of (malloc'd) user memory
>> +  is used as its backing storage. In other words, whether the driver can map
>> +  existing user memory into the device address space for direct device access.
>> +  The create function is pipe_screen::resource_from_user_memory.
> I think this is only really guaranteed to work if addresses and sizes
> are page-aligned. If so could that be mentioned here?

Yes, I'll add that.

>
>
>
>>
>>
>>  .. _pipe_capf:
>> diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c
>> index d2199a2..6c35fc8 100644
>> --- a/src/gallium/drivers/i915/i915_screen.c
>> +++ b/src/gallium/drivers/i915/i915_screen.c
>> @@ -231,6 +231,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
>>     case PIPE_CAP_VERTEXID_NOBASE:
>>     case PIPE_CAP_POLYGON_OFFSET_CLAMP:
>>     case PIPE_CAP_MULTISAMPLE_Z_RESOLVE:
>> +   case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
>>        return 0;
>>
>>     case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
>> diff --git a/src/gallium/drivers/ilo/ilo_screen.c b/src/gallium/drivers/ilo/ilo_screen.c
>> index 6e9e723..0182b7f 100644
>> --- a/src/gallium/drivers/ilo/ilo_screen.c
>> +++ b/src/gallium/drivers/ilo/ilo_screen.c
>> @@ -473,6 +473,7 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap param)
>>     case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
>>     case PIPE_CAP_SAMPLER_VIEW_TARGET:
>>     case PIPE_CAP_MULTISAMPLE_Z_RESOLVE:
>> +   case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
>>        return 0;
>>
>>     case PIPE_CAP_VENDOR_ID:
>> diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
>> index 31c65df..8b6e66e 100644
>> --- a/src/gallium/drivers/llvmpipe/lp_screen.c
>> +++ b/src/gallium/drivers/llvmpipe/lp_screen.c
>> @@ -288,6 +288,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
>>     case PIPE_CAP_POLYGON_OFFSET_CLAMP:
>>        return 1;
>>     case PIPE_CAP_MULTISAMPLE_Z_RESOLVE:
>> +   case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
>>        return 0;
>>     }
>>     /* should only get here on unhandled cases */
>> diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>> index 9c183f2..247ecbb 100644
>> --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>> +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>> @@ -160,6 +160,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>     case PIPE_CAP_VERTEXID_NOBASE:
>>     case PIPE_CAP_POLYGON_OFFSET_CLAMP:
>>     case PIPE_CAP_MULTISAMPLE_Z_RESOLVE:
>> +   case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
>>        return 0;
>>
>>     case PIPE_CAP_VENDOR_ID:
>> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>> index b79c237..729fc04 100644
>> --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>> +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>> @@ -208,6 +208,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>     case PIPE_CAP_DRAW_INDIRECT:
>>     case PIPE_CAP_VERTEXID_NOBASE:
>>     case PIPE_CAP_MULTISAMPLE_Z_RESOLVE: /* potentially supported on some hw */
>> +   case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
>>        return 0;
>>
>>     case PIPE_CAP_VENDOR_ID:
>> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>> index 4e53ca4..956905c 100644
>> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>> @@ -192,6 +192,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>     case PIPE_CAP_FAKE_SW_MSAA:
>>     case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
>>     case PIPE_CAP_VERTEXID_NOBASE:
>> +   case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
>>        return 0;
>>
>>     case PIPE_CAP_VENDOR_ID:
>> diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
>> index e6b826d..77b5dbf 100644
>> --- a/src/gallium/drivers/r300/r300_screen.c
>> +++ b/src/gallium/drivers/r300/r300_screen.c
>> @@ -184,6 +184,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
>>          case PIPE_CAP_VERTEXID_NOBASE:
>>          case PIPE_CAP_POLYGON_OFFSET_CLAMP:
>>          case PIPE_CAP_MULTISAMPLE_Z_RESOLVE:
>> +        case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
>>              return 0;
>>
>>          /* SWTCL-only features. */
>> diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
>> index 365fc0a..bae1367 100644
>> --- a/src/gallium/drivers/softpipe/sp_screen.c
>> +++ b/src/gallium/drivers/softpipe/sp_screen.c
>> @@ -236,6 +236,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
>>     case PIPE_CAP_POLYGON_OFFSET_CLAMP:
>>        return 0;
>>     case PIPE_CAP_MULTISAMPLE_Z_RESOLVE:
>> +   case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
>>        return 0;
>>     }
>>     /* should only get here on unhandled cases */
>> diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c
>> index 0156001..4f2969c 100644
>> --- a/src/gallium/drivers/svga/svga_screen.c
>> +++ b/src/gallium/drivers/svga/svga_screen.c
>> @@ -307,6 +307,7 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
>>        /* XXX: Query the host ? */
>>        return 1;
>>     case PIPE_CAP_UMA:
>> +   case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
>>        return 0;
>>     }
>>
>> diff --git a/src/gallium/drivers/vc4/vc4_screen.c b/src/gallium/drivers/vc4/vc4_screen.c
>> index 29637fb..1fe25c9 100644
>> --- a/src/gallium/drivers/vc4/vc4_screen.c
>> +++ b/src/gallium/drivers/vc4/vc4_screen.c
>> @@ -172,6 +172,7 @@ vc4_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>          case PIPE_CAP_VERTEXID_NOBASE:
>>          case PIPE_CAP_POLYGON_OFFSET_CLAMP:
>>          case PIPE_CAP_MULTISAMPLE_Z_RESOLVE:
>> +        case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
>>                  return 0;
>>
>>                  /* Stream output. */
>> diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
>> index 192af63..bdf527c 100644
>> --- a/src/gallium/include/pipe/p_defines.h
>> +++ b/src/gallium/include/pipe/p_defines.h
>> @@ -575,6 +575,7 @@ enum pipe_cap {
>>     PIPE_CAP_VERTEXID_NOBASE = 112,
>>     PIPE_CAP_POLYGON_OFFSET_CLAMP = 113,
>>     PIPE_CAP_MULTISAMPLE_Z_RESOLVE = 114,
>> +   PIPE_CAP_RESOURCE_FROM_USER_MEMORY = 115,
>>  };
>>
>>  #define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 (1 << 0)
>> diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
>> index cf958d2..6b151a2 100644
>> --- a/src/gallium/include/pipe/p_screen.h
>> +++ b/src/gallium/include/pipe/p_screen.h
>> @@ -164,6 +164,14 @@ struct pipe_screen {
>>                                                 struct winsys_handle *handle);
>>
>>     /**
>> +    * Create a resource from user memory. This maps the user memory into
>> +    * the device address space.
>> +    */
>> +   struct pipe_resource * (*resource_from_user_memory)(struct pipe_screen *,
>> +                                               const struct pipe_resource *templat,
>> +                                               void *user_memory);
> The indentation here is wrong (though it's true that the surrounding
> code also got it wrong...)

The surrounding code seems okay except for heavy use of tabs. I can
fix the indentation, but it will be over 80 characters per line. Is
that okay with you?

Marek


More information about the mesa-dev mailing list