[Mesa-dev] st/mesa: improve ARB_texture_stencil8 support

Submitted by Marek Olšák on April 5, 2015, 11:42 a.m.

Details

Message ID 1428234142-6172-1-git-send-email-maraeo@gmail.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Marek Olšák April 5, 2015, 11:42 a.m.
From: Marek Olšák <marek.olsak@amd.com>

1) Try selecting X24S8 and S8X24 first.
2) Make sure depth-stencil formats are always renderable.

r600g and radeonsi don't support S8 for rendering. Actually, they don't even
support X24S8 and S8X24, but we can fix that later.
---
 src/mesa/state_tracker/st_format.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 72dbf3b..26c7da4 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -1167,8 +1167,8 @@  static const struct format_mapping format_map[] = {
       { GL_STENCIL_INDEX, GL_STENCIL_INDEX1_EXT, GL_STENCIL_INDEX4_EXT,
         GL_STENCIL_INDEX8_EXT, GL_STENCIL_INDEX16_EXT, 0 },
       {
-         PIPE_FORMAT_S8_UINT, PIPE_FORMAT_Z24_UNORM_S8_UINT,
-         PIPE_FORMAT_S8_UINT_Z24_UNORM, 0
+         PIPE_FORMAT_S8_UINT, PIPE_FORMAT_X24S8_UINT, PIPE_FORMAT_S8X24_UINT,
+         PIPE_FORMAT_Z24_UNORM_S8_UINT, PIPE_FORMAT_S8_UINT_Z24_UNORM, 0
       }
    },
 
@@ -1942,11 +1942,6 @@  st_ChooseTextureFormat(struct gl_context *ctx, GLenum target,
                        GLint internalFormat,
                        GLenum format, GLenum type)
 {
-   const boolean want_renderable =
-      internalFormat == 3 || internalFormat == 4 ||
-      internalFormat == GL_RGB || internalFormat == GL_RGBA ||
-      internalFormat == GL_RGB8 || internalFormat == GL_RGBA8 ||
-      internalFormat == GL_BGRA;
    struct st_context *st = st_context(ctx);
    enum pipe_format pFormat;
    unsigned bindings;
@@ -1962,15 +1957,17 @@  st_ChooseTextureFormat(struct gl_context *ctx, GLenum target,
    }
 
    /* GL textures may wind up being render targets, but we don't know
-    * that in advance.  Specify potential render target flags now.
+    * that in advance.  Specify potential render target flags for formats
+    * that we know should always be renderable.
     */
    bindings = PIPE_BIND_SAMPLER_VIEW;
-   if (want_renderable) {
-      if (_mesa_is_depth_or_stencil_format(internalFormat))
-	 bindings |= PIPE_BIND_DEPTH_STENCIL;
-      else
-	 bindings |= PIPE_BIND_RENDER_TARGET;
-   }
+   if (_mesa_is_depth_or_stencil_format(internalFormat))
+      bindings |= PIPE_BIND_DEPTH_STENCIL;
+   else if (internalFormat == 3 || internalFormat == 4 ||
+            internalFormat == GL_RGB || internalFormat == GL_RGBA ||
+            internalFormat == GL_RGB8 || internalFormat == GL_RGBA8 ||
+            internalFormat == GL_BGRA)
+      bindings |= PIPE_BIND_RENDER_TARGET;
 
    /* GLES allows the driver to choose any format which matches
     * the format+type combo, because GLES only supports unsized internal

Comments

On 5 April 2015 at 21:42, Marek Olšák <maraeo@gmail.com> wrote:
> From: Marek Olšák <marek.olsak@amd.com>
>
> 1) Try selecting X24S8 and S8X24 first.
> 2) Make sure depth-stencil formats are always renderable.

Does any hw support S8 for rendering at all do you know? (anyone else)

I'd assume you'd want to use S8 if you had texture and render for it
since it would take up less memory, but I suppose we can cross that
bridge when we get to it.

Dave.
On Sun, Apr 5, 2015 at 11:00 PM, Dave Airlie <airlied@gmail.com> wrote:
> On 5 April 2015 at 21:42, Marek Olšák <maraeo@gmail.com> wrote:
>> From: Marek Olšák <marek.olsak@amd.com>
>>
>> 1) Try selecting X24S8 and S8X24 first.
>> 2) Make sure depth-stencil formats are always renderable.
>
> Does any hw support S8 for rendering at all do you know? (anyone else)
>
> I'd assume you'd want to use S8 if you had texture and render for it
> since it would take up less memory, but I suppose we can cross that
> bridge when we get to it.

FWIW I think that Adreno 3xx and 4xx should be able to do S8-only
rendering. I haven't tried it, but it does keep the stencil totally
separate for Z32 + S8 though (separate pointers to diff gmem locations
and all that).

  -ilia
Evergreen and later chips support S8, but there are limitations: if
you want to bind a separate depth buffer to it, it must have the same
tiling parameters except for the tile split (that's the only one that
can be different) and HTILE must be disabled. Not really worth
implementing.

S8 without a depth buffer can be supported easily. Just set the depth
format to "invalid".

Marek

On Mon, Apr 6, 2015 at 5:00 AM, Dave Airlie <airlied@gmail.com> wrote:
> On 5 April 2015 at 21:42, Marek Olšák <maraeo@gmail.com> wrote:
>> From: Marek Olšák <marek.olsak@amd.com>
>>
>> 1) Try selecting X24S8 and S8X24 first.
>> 2) Make sure depth-stencil formats are always renderable.
>
> Does any hw support S8 for rendering at all do you know? (anyone else)
>
> I'd assume you'd want to use S8 if you had texture and render for it
> since it would take up less memory, but I suppose we can cross that
> bridge when we get to it.
>
> Dave.