[Mesa-dev] [PATCH v2 1/5] mesa: Add core support for EXT_multisampled_render_to_texture2

Marek Olšák maraeo at gmail.com
Tue Dec 4 22:48:29 UTC 2018


On Thu, Nov 29, 2018 at 7:50 PM Kristian Høgsberg <hoegsberg at gmail.com>
wrote:

> On Tue, Nov 6, 2018 at 3:03 PM Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> >
> > On Tue, Nov 6, 2018 at 5:18 PM Kristian H. Kristensen
> > <hoegsberg at gmail.com> wrote:
> > >
> > > This also turns on EXT_multisampled_render_to_texture which is a
> > > subset of EXT_multisampled_render_to_texture2, allowing only
> > > COLOR_ATTACHMENT0.
> >
> > You also enable the texture2 variant as well, no?
>
> Yes, I'll update the subject.
>
> >
> > >
> > > Signed-off-by: Kristian H. Kristensen <hoegsberg at chromium.org>
> > > ---
> > >  .../EXT_multisampled_render_to_texture.xml    | 34 ++++++++++++++
> > >  src/mapi/glapi/gen/Makefile.am                |  1 +
> > >  src/mapi/glapi/gen/gl_API.xml                 |  2 +
> > >  src/mapi/glapi/gen/meson.build                |  1 +
> > >  src/mesa/drivers/common/meta.c                |  2 +-
> > >  src/mesa/main/extensions_table.h              |  2 +
> > >  src/mesa/main/fbobject.c                      | 45 +++++++++++++------
> > >  src/mesa/main/fbobject.h                      |  8 +++-
> > >  src/mesa/main/mtypes.h                        |  2 +
> > >  9 files changed, 81 insertions(+), 16 deletions(-)
> > >  create mode 100644
> src/mapi/glapi/gen/EXT_multisampled_render_to_texture.xml
> > >
> > > diff --git a/src/mapi/glapi/gen/EXT_multisampled_render_to_texture.xml
> b/src/mapi/glapi/gen/EXT_multisampled_render_to_texture.xml
> > > new file mode 100644
> > > index 00000000000..cf44e6976f0
> > > --- /dev/null
> > > +++ b/src/mapi/glapi/gen/EXT_multisampled_render_to_texture.xml
> > > @@ -0,0 +1,34 @@
> > > +<?xml version="1.0"?>
> > > +<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
> > > +
> > > +<OpenGLAPI>
> > > +
> > > +<category name="GL_EXT_multisampled_render_to_texture" number="106">
> > > +
> > > +    <enum name="RENDERBUFFER_SAMPLES_EXT"
>  value="0x8CAB"/>
> > > +    <enum name="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT"
>  value="0x8D56"/>
> > > +    <enum name="MAX_SAMPLES_EXT"
> value="0x8D57"/>
> > > +    <enum name="FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT"
> value="0x8D6C"/>
> >
> > I don't see any logic to enable retrieving these (*_SAMPLES_EXT), so I
> > think this implementation is slightly incomplete.
>
> Will add.
>
> > > +
> > > +<!-- Already defined in FramebufferTexture2DMultisampleEXT
> >
> > I think you meant to say something else here...
>
> Oh yea, this is a bit of a circular reference, isn't it... updated to
> EXT_framebuffer_object.xml
>
> > > +    <function name="RenderbufferStorageMultisampleEXT" es2="2.0">
> > > +        <param name="target" type="GLenum"/>
> > > +       <param name="samples" type="GLsizei"/>
> > > +        <param name="internalformat" type="GLenum"/>
> > > +        <param name="width" type="GLsizei"/>
> > > +       <param name="height" type="GLsizei"/>
> > > +    </function>
> > > +-->
> > > +
> > > +    <function name="FramebufferTexture2DMultisampleEXT" es2="2.0">
> > > +        <param name="target" type="GLenum"/>
> > > +        <param name="attachment" type="GLenum"/>
> > > +        <param name="textarget" type="GLenum"/>
> > > +        <param name="texture" type="GLuint"/>
> > > +        <param name="level" type="GLint"/>
> > > +        <param name="samples" type="GLsizei"/>
> > > +    </function>
> > > +
> > > +</category>
> > > +
> > > +</OpenGLAPI>
> > > diff --git a/src/mapi/glapi/gen/Makefile.am
> b/src/mapi/glapi/gen/Makefile.am
> > > index 6e0ee1e1687..40538b0ff2e 100644
> > > --- a/src/mapi/glapi/gen/Makefile.am
> > > +++ b/src/mapi/glapi/gen/Makefile.am
> > > @@ -200,6 +200,7 @@ API_XML = \
> > >         EXT_external_objects_fd.xml \
> > >         EXT_framebuffer_object.xml \
> > >         EXT_gpu_shader4.xml \
> > > +       EXT_multisampled_render_to_texture.xml \
> > >         EXT_packed_depth_stencil.xml \
> > >         EXT_provoking_vertex.xml \
> > >         EXT_separate_shader_objects.xml \
> > > diff --git a/src/mapi/glapi/gen/gl_API.xml
> b/src/mapi/glapi/gen/gl_API.xml
> > > index aae9a5835db..ee4d13f1f06 100644
> > > --- a/src/mapi/glapi/gen/gl_API.xml
> > > +++ b/src/mapi/glapi/gen/gl_API.xml
> > > @@ -8166,6 +8166,8 @@
> > >
> > >  <xi:include href="ARB_robustness.xml" xmlns:xi="
> http://www.w3.org/2001/XInclude"/>
> > >
> > > +<xi:include href="EXT_multisampled_render_to_texture.xml" xmlns:xi="
> http://www.w3.org/2001/XInclude"/>
> > > +
> > >  <xi:include href="ARB_base_instance.xml" xmlns:xi="
> http://www.w3.org/2001/XInclude"/>
> > >
> > >  <category name="GL_ARB_transform_feedback_instanced" number="109">
> > > diff --git a/src/mapi/glapi/gen/meson.build
> b/src/mapi/glapi/gen/meson.build
> > > index f494e9707b6..8cc163b2989 100644
> > > --- a/src/mapi/glapi/gen/meson.build
> > > +++ b/src/mapi/glapi/gen/meson.build
> > > @@ -107,6 +107,7 @@ api_xml_files = files(
> > >    'EXT_external_objects_fd.xml',
> > >    'EXT_framebuffer_object.xml',
> > >    'EXT_gpu_shader4.xml',
> > > +  'EXT_multisampled_render_to_texture.xml',
> > >    'EXT_packed_depth_stencil.xml',
> > >    'EXT_provoking_vertex.xml',
> > >    'EXT_separate_shader_objects.xml',
> > > diff --git a/src/mesa/drivers/common/meta.c
> b/src/mesa/drivers/common/meta.c
> > > index 4392c4bbd88..3515e312023 100644
> > > --- a/src/mesa/drivers/common/meta.c
> > > +++ b/src/mesa/drivers/common/meta.c
> > > @@ -127,7 +127,7 @@ _mesa_meta_framebuffer_texture_image(struct
> gl_context *ctx,
> > >     assert(att);
> > >
> > >     _mesa_framebuffer_texture(ctx, fb, attachment, att, texObj,
> texTarget,
> > > -                             level, layer, false);
> > > +                             level, att->NumSamples, layer, false);
> > >  }
> > >
> > >  static struct gl_shader *
> > > diff --git a/src/mesa/main/extensions_table.h
> b/src/mesa/main/extensions_table.h
> > > index a516a1b17f8..f13b8b6a21a 100644
> > > --- a/src/mesa/main/extensions_table.h
> > > +++ b/src/mesa/main/extensions_table.h
> > > @@ -241,6 +241,8 @@ EXT(EXT_map_buffer_range                    ,
> ARB_map_buffer_range
> > >  EXT(EXT_memory_object                       , EXT_memory_object
>                 , GLL, GLC,  x , ES2, 2017)
> > >  EXT(EXT_memory_object_fd                    , EXT_memory_object_fd
>                , GLL, GLC,  x , ES2, 2017)
> > >  EXT(EXT_multi_draw_arrays                   , dummy_true
>                , GLL,  x , ES1, ES2, 1999)
> > > +EXT(EXT_multisampled_render_to_texture      ,
> EXT_multisampled_render_to_texture     ,  x ,  x ,  x , ES2, 2016)
> > > +EXT(EXT_multisampled_render_to_texture2     ,
> EXT_multisampled_render_to_texture     ,  x ,  x ,  x , ES2, 2016)
> > >  EXT(EXT_occlusion_query_boolean             , ARB_occlusion_query
>                 ,  x ,  x ,  x , ES2, 2001)
> > >  EXT(EXT_packed_depth_stencil                , dummy_true
>                , GLL, GLC,  x ,  x , 2005)
> > >  EXT(EXT_packed_float                        , EXT_packed_float
>                , GLL, GLC,  x ,  x , 2004)
> > > diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
> > > index c3dded6b928..d270dbb1648 100644
> > > --- a/src/mesa/main/fbobject.c
> > > +++ b/src/mesa/main/fbobject.c
> > > @@ -497,8 +497,8 @@ set_texture_attachment(struct gl_context *ctx,
> > >                         struct gl_framebuffer *fb,
> > >                         struct gl_renderbuffer_attachment *att,
> > >                         struct gl_texture_object *texObj,
> > > -                       GLenum texTarget, GLuint level, GLuint layer,
> > > -                       GLboolean layered)
> > > +                       GLenum texTarget, GLuint level, GLsizei
> samples,
> > > +                       GLuint layer, GLboolean layered)
> > >  {
> > >     struct gl_renderbuffer *rb = att->Renderbuffer;
> > >
> > > @@ -520,6 +520,7 @@ set_texture_attachment(struct gl_context *ctx,
> > >
> > >     /* always update these fields */
> > >     att->TextureLevel = level;
> > > +   att->NumSamples = samples;
> > >     att->CubeMapFace = _mesa_tex_target_to_face(texTarget);
> > >     att->Zoffset = layer;
> > >     att->Layered = layered;
> > > @@ -1084,8 +1085,11 @@ _mesa_test_framebuffer_completeness(struct
> gl_context *ctx,
> > >              return;
> > >           }
> > >
> > > -         attNumSamples = texImg->NumSamples;
> > > -         attNumStorageSamples = texImg->NumSamples;
> > > +         if (att->NumSamples > 0)
> > > +            attNumSamples = att->NumSamples;
> > > +         else
> > > +            attNumSamples = texImg->NumSamples;
> > > +         attNumStorageSamples = attNumSamples;
> >
> > Do you want attNumStorageSamples to be attNumSamples here, or
> > texImg->NumSamples? Not sure what this affects...
>
> I don't know how or if at all this extension is supposed to interact
> with AMD_framebuffer_multisample_advanced. The checks further down
> require sample counts for all color attachments to match and storage
> sample counts for all color attachments to match. The
> EXT_multisampled_render_to_texture extension allows for texture color
> attachments to be either fully multisampled or non-multisampled as
> long as their attachment sample count are all the same. For that to
> work right, we must consider the attachment sample count both the
> sample count and the storage sample count.
>

AMD_framebuffer_multisample_advanced is true MSAA that is extended.
EXT_multisampled_render_to_texture is just 1xAA with oversampling during
rasterization and shading, and the flush to memory averages the samples.
It's a little more advanced than the overrasterization supported by AMD
GCN, which is not exposed in GL.

Marek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20181204/6698c3da/attachment-0001.html>


More information about the mesa-dev mailing list