st/mesa: allow R8 to not be exposed as renderable by driver
authorIlia Mirkin <imirkin@alum.mit.edu>
Mon, 18 May 2020 18:00:58 +0000 (14:00 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Sun, 5 Jul 2020 04:24:04 +0000 (00:24 -0400)
A3xx GPUs support RG8 and RGBA8, but not R8 for rendering. Add RG8 as
fallbacks for integer formats, and require a renderable format to be
picked for all R8 variants.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5748>

src/mesa/state_tracker/st_format.c

index 22da741472a8b4536dc0044632be133b7eb57993..c84dd7b324df6d6fa8d4a0b302e850da1af91da8 100644 (file)
@@ -910,7 +910,7 @@ static const struct format_mapping format_map[] = {
    },
    {
      { GL_R8I, GL_RED_INTEGER_EXT, 0},
-     { PIPE_FORMAT_R8_SINT, 0},
+     { PIPE_FORMAT_R8_SINT, PIPE_FORMAT_R8G8_SINT, 0},
    },
    {
      { GL_R16I, 0},
@@ -922,7 +922,7 @@ static const struct format_mapping format_map[] = {
    },
   {
      { GL_R8UI, 0},
-     { PIPE_FORMAT_R8_UINT, 0},
+     { PIPE_FORMAT_R8_UINT, PIPE_FORMAT_R8G8_UINT, 0},
    },
    {
      { GL_R16UI, 0},
@@ -1281,7 +1281,11 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target,
             internalFormat == GL_RGB16F ||
             internalFormat == GL_RGBA16F ||
             internalFormat == GL_RGB32F ||
-            internalFormat == GL_RGBA32F)
+            internalFormat == GL_RGBA32F ||
+            internalFormat == GL_RED ||
+            internalFormat == GL_RED_SNORM ||
+            internalFormat == GL_R8I ||
+            internalFormat == GL_R8UI)
       bindings |= PIPE_BIND_RENDER_TARGET;
 
    /* GLES allows the driver to choose any format which matches