[Mesa-dev] [PATCH 2/4] gallium: extend resource_resolve to accommodate BlitFramebuffer

Christoph Bumiller e0425955 at student.tuwien.ac.at
Tue Aug 2 11:55:45 PDT 2011


On 08/02/2011 07:20 PM, Roland Scheidegger wrote:
> Since noone else chimed in and said it's not a good idea I won't hold you up :-).
> I'd like to see a little more documentation though what it can (e.g. depth "resolve" especially what it actually should do) and can't do in context.rst. Speaking of what it can't do since you built this for framebuffer_blit how do you specify the filtering, especially since depth/stencil presumably only will do nearest, but you want to be able to do color with linear (though you should be able to do nearest as well?). If that's implied somehow it needs to be mentioned somewhere.

Right, I'll improve the documentation.

As for filtering, depth/stencil always implies nearest (will mention that).

For colour, GL spec (for D3D it's clear anyway) states "if the source
and destination dimensions are identical, no filtering is applied." -
That condition holds for unextended (non-scaled) multisample resolve and
seems to make the filter parameter non-applicable.
Instead, just the line "converted to a single sample" (however well you
can I suppose) applies.
The nv blob seems to agree, the results of resolve with NEAREST and
LINEAR look equal with it.

For scaled resolve, the filter parameter *must* be either
SCALED_RESOLVE_FASTEST_EXT or SCALED_RESOLVE_NICEST_EXT (others are not
allowed), the interpretation of which is more or less up to the driver.
So, we could add a niceness hint to the resolve info, but it's not
strictly necessary.

> Also, I'm not sure if it wouldn't be nicer to specify all the "scaling" parameters in the destination, instead of some in the source (the x/y flips). Not sure though I guess if there's precedent somewhere for either way it might be nice to do the same but it probably is fine either way.
> 
I put the scaling (actually just the flipping) in the source because I
can directly use dst.xy01 for my scissor rectangle then (which outlines
the destination region).

It's really just personal preference, if someone were to use dst.xy01
for inverted viewport parameters they'd probably prefer flipping in dst.

I'm deactivating the viewport transform and flipping the non-normalized
texture coordinates instead ...

Visualize a fixed destination region, then that you cut out some source,
turn it around and stretch it, then sticking it where you want it :-)

> Roland
> 
> 
>>
>> On 28.07.2011 15:59, Christoph Bumiller wrote:
>>> Resolve via glBlitFramebuffer allows resolving a sub-region of a
>>> renderbuffer to a different location in any mipmap level of some
>>> other texture, and, with a new extension, even scaling. Therefore,
>>> location and size parameters are needed.
>>>
>>> The mask parameter was added because resolving only depth or only
>>> stencil of a combined buffer is possible as well.
>>>
>>> Full information about the blit operation allows the drivers to
>>> take the most efficient path they possibly can.
>> So, if there are no objections anymore I'm just going to push this
>> small
>> series in a few days ...
>>
>> Since no other drivers implement multisampling at the moment it can't
>> break anything (except maybe closed source state trackers I don't
>> know
>> about).
>>
>>> ---
>>>  src/gallium/docs/source/context.rst  |    7 +++++--
>>>  src/gallium/include/pipe/p_context.h |    8 +++-----
>>>  src/gallium/include/pipe/p_defines.h |    4 ++++
>>>  src/gallium/include/pipe/p_state.h   |   28
>>>  ++++++++++++++++++++++++++++
>>>  4 files changed, 40 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/src/gallium/docs/source/context.rst
>>> b/src/gallium/docs/source/context.rst
>>> index 25a3245..7968f03 100644
>>> --- a/src/gallium/docs/source/context.rst
>>> +++ b/src/gallium/docs/source/context.rst
>>> @@ -329,8 +329,11 @@ textured quad blitter.. The source and
>>> destination may be the same resource,
>>>  but overlapping blits are not permitted.
>>>  
>>>  ``resource_resolve`` resolves a multisampled resource into a
>>>  non-multisampled
>>> -one. Formats and dimensions must match. This function must be
>>> present if a driver
>>> -supports multisampling.
>>> +one. Formats must match, and, if PIPE_CAP_SCALED_RESOLVE is not
>>> supported,
>>> +dimensions as well.
>>> +The source and destination resources and coordinates are described
>>> +by ``pipe_resolve_info``.
>>> +This function must be present if a driver supports multisampling.
>>>  
>>>  The interfaces to these calls are likely to change to make it
>>>  easier
>>>  for a driver to batch multiple blits with the same source and
>>> diff --git a/src/gallium/include/pipe/p_context.h
>>> b/src/gallium/include/pipe/p_context.h
>>> index 3f6d90d..da3ee87 100644
>>> --- a/src/gallium/include/pipe/p_context.h
>>> +++ b/src/gallium/include/pipe/p_context.h
>>> @@ -49,6 +49,7 @@ struct pipe_index_buffer;
>>>  struct pipe_query;
>>>  struct pipe_poly_stipple;
>>>  struct pipe_rasterizer_state;
>>> +struct pipe_resolve_info;
>>>  struct pipe_resource;
>>>  struct pipe_sampler_state;
>>>  struct pipe_sampler_view;
>>> @@ -268,13 +269,10 @@ struct pipe_context {
>>>  
>>>     /**
>>>      * Resolve a multisampled resource into a non-multisampled one.
>>> -    * Source and destination must have the same size and same
>>> format.
>>> +    * Source and destination must be of the same format.
>>>      */
>>>     void (*resource_resolve)(struct pipe_context *pipe,
>>> -                            struct pipe_resource *dst,
>>> -                            unsigned dst_layer,
>>> -                            struct pipe_resource *src,
>>> -                            unsigned src_layer);
>>> +                            const struct pipe_resolve_info *info);
>>>  
>>>     /*@}*/
>>>  
>>> diff --git a/src/gallium/include/pipe/p_defines.h
>>> b/src/gallium/include/pipe/p_defines.h
>>> index 79b8969..7ffdf97 100644
>>> --- a/src/gallium/include/pipe/p_defines.h
>>> +++ b/src/gallium/include/pipe/p_defines.h
>>> @@ -99,6 +99,9 @@ enum pipe_error {
>>>  #define PIPE_MASK_B  0x4
>>>  #define PIPE_MASK_A  0x8
>>>  #define PIPE_MASK_RGBA 0xf
>>> +#define PIPE_MASK_Z  0x10
>>> +#define PIPE_MASK_S  0x20
>>> +#define PIPE_MASK_ZS 0x30
>>>  
>>>  
>>>  /**
>>> @@ -468,6 +471,7 @@ enum pipe_cap {
>>>     PIPE_CAP_MIXED_COLORBUFFER_FORMATS = 46,
>>>     PIPE_CAP_SEAMLESS_CUBE_MAP = 47,
>>>     PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE = 48,
>>> +   PIPE_CAP_SCALED_RESOLVE = 49
>>>  };
>>>  
>>>  /* Shader caps not specific to any single stage */
>>> diff --git a/src/gallium/include/pipe/p_state.h
>>> b/src/gallium/include/pipe/p_state.h
>>> index d442c15..840b3ee 100644
>>> --- a/src/gallium/include/pipe/p_state.h
>>> +++ b/src/gallium/include/pipe/p_state.h
>>> @@ -483,6 +483,34 @@ struct pipe_draw_info
>>>  };
>>>  
>>>  
>>> +/**
>>> + * Information to describe a resource_resolve call.
>>> + */
>>> +struct pipe_resolve_info
>>> +{
>>> +   struct {
>>> +      struct pipe_resource *res;
>>> +      unsigned level;
>>> +      unsigned layer;
>>> +      int x0; /**< always left */
>>> +      int y0; /**< always top */
>>> +      int x1; /**< determines scale if PIPE_CAP_SCALED_RESOLVE is
>>> supported */
>>> +      int y1; /**< determines scale if PIPE_CAP_SCALED_RESOLVE is
>>> supported */
>>> +   } dst;
>>> +
>>> +   struct {
>>> +      struct pipe_resource *res;
>>> +      unsigned layer;
>>> +      int x0;
>>> +      int y0;
>>> +      int x1; /**< may be < x0 only if PIPE_CAP_SCALED_RESOLVE is
>>> supported */
>>> +      int y1; /**< may be < y1 even if PIPE_CAP_SCALED_RESOLVE not
>>> supported */
>>> +   } src;
>>> +
>>> +   unsigned mask; /**< PIPE_MASK_RGBA, Z, S or ZS */
>>> +};
>>> +
>>> +
>>>  #ifdef __cplusplus
>>>  }
>>>  #endif
>>
>>



More information about the mesa-dev mailing list