r600g: Use the actual Evergreen functions to query format support on Evergreen.
authorHenri Verbeet <hverbeet@gmail.com>
Mon, 4 Jul 2011 23:58:46 +0000 (01:58 +0200)
committerHenri Verbeet <hverbeet@gmail.com>
Mon, 4 Jul 2011 23:58:46 +0000 (01:58 +0200)
Signed-off-by: Henri Verbeet <hverbeet@gmail.com>
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_formats.h
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_state_inlines.h

index dc182611482c0d99d7e7cbb0a1bca27083e45d85..18d54cc1e268bf9c981f3ede801646c8b807979a 100644 (file)
 #include "r600_pipe.h"
 #include "eg_state_inlines.h"
 
+boolean evergreen_is_format_supported(struct pipe_screen *screen,
+                                     enum pipe_format format,
+                                     enum pipe_texture_target target,
+                                     unsigned sample_count,
+                                     unsigned usage)
+{
+       unsigned retval = 0;
+
+       if (target >= PIPE_MAX_TEXTURE_TYPES) {
+               R600_ERR("r600: unsupported texture type %d\n", target);
+               return FALSE;
+       }
+
+       if (!util_format_is_supported(format, usage))
+               return FALSE;
+
+       /* Multisample */
+       if (sample_count > 1)
+               return FALSE;
+
+       if ((usage & PIPE_BIND_SAMPLER_VIEW) &&
+           r600_is_sampler_format_supported(screen, format)) {
+               retval |= PIPE_BIND_SAMPLER_VIEW;
+       }
+
+       if ((usage & (PIPE_BIND_RENDER_TARGET |
+                     PIPE_BIND_DISPLAY_TARGET |
+                     PIPE_BIND_SCANOUT |
+                     PIPE_BIND_SHARED)) &&
+           r600_is_colorbuffer_format_supported(format)) {
+               retval |= usage &
+                         (PIPE_BIND_RENDER_TARGET |
+                          PIPE_BIND_DISPLAY_TARGET |
+                          PIPE_BIND_SCANOUT |
+                          PIPE_BIND_SHARED);
+       }
+
+       if ((usage & PIPE_BIND_DEPTH_STENCIL) &&
+           r600_is_zs_format_supported(format)) {
+               retval |= PIPE_BIND_DEPTH_STENCIL;
+       }
+
+       if ((usage & PIPE_BIND_VERTEX_BUFFER) &&
+           r600_is_vertex_format_supported(format)) {
+               retval |= PIPE_BIND_VERTEX_BUFFER;
+       }
+
+       if (usage & PIPE_BIND_TRANSFER_READ)
+               retval |= PIPE_BIND_TRANSFER_READ;
+       if (usage & PIPE_BIND_TRANSFER_WRITE)
+               retval |= PIPE_BIND_TRANSFER_WRITE;
+
+       return retval == usage;
+}
+
 static void evergreen_set_blend_color(struct pipe_context *ctx,
                                        const struct pipe_blend_color *state)
 {
index ae0bc432ad23b3e77e04fa5568204ef3bf261f4e..1c1089d89d2d2b52454edd9afaedc7e9ee783eac 100644 (file)
@@ -81,4 +81,36 @@ static INLINE unsigned r600_endian_swap(unsigned size)
        }
 }
 
+static INLINE bool r600_is_vertex_format_supported(enum pipe_format format)
+{
+       const struct util_format_description *desc = util_format_description(format);
+       unsigned i;
+
+       if (!desc)
+               return false;
+
+       /* Find the first non-VOID channel. */
+       for (i = 0; i < 4; i++) {
+               if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID)
+                       break;
+       }
+       if (i == 4)
+               return false;
+
+       /* No fixed, no double. */
+       if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN ||
+           desc->channel[i].type == UTIL_FORMAT_TYPE_FIXED ||
+           (desc->channel[i].size == 64 &&
+            desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT))
+               return false;
+
+       /* No scaled/norm formats with 32 bits per channel. */
+       if (desc->channel[i].size == 32 &&
+           (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED ||
+            desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED))
+               return false;
+
+       return true;
+}
+
 #endif
index ac41449a30117f03dc61ec54b8b8f10e25258fb9..d512268f63fb848feff57e053c423359eed3bb5e 100644 (file)
@@ -45,7 +45,6 @@
 #include "r600_resource.h"
 #include "r600_shader.h"
 #include "r600_pipe.h"
-#include "r600_state_inlines.h"
 
 /*
  * pipe_context
@@ -506,60 +505,6 @@ static int r600_get_shader_param(struct pipe_screen* pscreen, unsigned shader, e
        }
 }
 
-static boolean r600_is_format_supported(struct pipe_screen* screen,
-                                       enum pipe_format format,
-                                       enum pipe_texture_target target,
-                                       unsigned sample_count,
-                                        unsigned usage)
-{
-       unsigned retval = 0;
-       if (target >= PIPE_MAX_TEXTURE_TYPES) {
-               R600_ERR("r600: unsupported texture type %d\n", target);
-               return FALSE;
-       }
-
-        if (!util_format_is_supported(format, usage))
-                return FALSE;
-
-       /* Multisample */
-       if (sample_count > 1)
-               return FALSE;
-
-       if ((usage & PIPE_BIND_SAMPLER_VIEW) &&
-           r600_is_sampler_format_supported(screen, format)) {
-               retval |= PIPE_BIND_SAMPLER_VIEW;
-       }
-
-       if ((usage & (PIPE_BIND_RENDER_TARGET |
-                       PIPE_BIND_DISPLAY_TARGET |
-                       PIPE_BIND_SCANOUT |
-                       PIPE_BIND_SHARED)) &&
-                       r600_is_colorbuffer_format_supported(format)) {
-               retval |= usage &
-                       (PIPE_BIND_RENDER_TARGET |
-                        PIPE_BIND_DISPLAY_TARGET |
-                        PIPE_BIND_SCANOUT |
-                        PIPE_BIND_SHARED);
-       }
-
-       if ((usage & PIPE_BIND_DEPTH_STENCIL) &&
-           r600_is_zs_format_supported(format)) {
-               retval |= PIPE_BIND_DEPTH_STENCIL;
-       }
-
-       if ((usage & PIPE_BIND_VERTEX_BUFFER) &&
-           r600_is_vertex_format_supported(format)) {
-               retval |= PIPE_BIND_VERTEX_BUFFER;
-       }
-
-       if (usage & PIPE_BIND_TRANSFER_READ)
-               retval |= PIPE_BIND_TRANSFER_READ;
-       if (usage & PIPE_BIND_TRANSFER_WRITE)
-               retval |= PIPE_BIND_TRANSFER_WRITE;
-
-       return retval == usage;
-}
-
 static void r600_destroy_screen(struct pipe_screen* pscreen)
 {
        struct r600_screen *rscreen = (struct r600_screen *)pscreen;
@@ -648,7 +593,11 @@ struct pipe_screen *r600_screen_create(struct radeon *radeon)
        rscreen->screen.get_param = r600_get_param;
        rscreen->screen.get_shader_param = r600_get_shader_param;
        rscreen->screen.get_paramf = r600_get_paramf;
-       rscreen->screen.is_format_supported = r600_is_format_supported;
+       if (r600_get_family_class(radeon) >= EVERGREEN) {
+               rscreen->screen.is_format_supported = evergreen_is_format_supported;
+       } else {
+               rscreen->screen.is_format_supported = r600_is_format_supported;
+       }
        rscreen->screen.context_create = r600_create_context;
        rscreen->screen.fence_reference = r600_fence_reference;
        rscreen->screen.fence_signalled = r600_fence_signalled;
index 2667c80bcefbf47c51952469e1255db4de06bbaa..c58c2f777430c2195e7551a928222a6dcf034ffa 100644 (file)
@@ -247,6 +247,11 @@ void evergreen_pipe_init_buffer_resource(struct r600_pipe_context *rctx,
 void evergreen_pipe_mod_buffer_resource(struct r600_pipe_resource_state *rstate,
                                        struct r600_resource *rbuffer,
                                        unsigned offset, unsigned stride);
+boolean evergreen_is_format_supported(struct pipe_screen *screen,
+                                     enum pipe_format format,
+                                     enum pipe_texture_target target,
+                                     unsigned sample_count,
+                                     unsigned usage);
 
 /* r600_blit.c */
 void r600_init_blit_functions(struct r600_pipe_context *rctx);
@@ -290,6 +295,11 @@ void r600_pipe_mod_buffer_resource(struct r600_pipe_resource_state *rstate,
                                   struct r600_resource *rbuffer,
                                   unsigned offset, unsigned stride);
 void r600_adjust_gprs(struct r600_pipe_context *rctx);
+boolean r600_is_format_supported(struct pipe_screen *screen,
+                                enum pipe_format format,
+                                enum pipe_texture_target target,
+                                unsigned sample_count,
+                                unsigned usage);
 
 /* r600_texture.c */
 void r600_init_screen_texture_functions(struct pipe_screen *screen);
index be07f5feff89928f1a3eb9192210f4d85e50dbc3..e329317b3ab6b7437726049cd136f81f35d403f7 100644 (file)
 #include "r600_pipe.h"
 #include "r600_state_inlines.h"
 
+boolean r600_is_format_supported(struct pipe_screen *screen,
+                                enum pipe_format format,
+                                enum pipe_texture_target target,
+                                unsigned sample_count,
+                                unsigned usage)
+{
+       unsigned retval = 0;
+
+       if (target >= PIPE_MAX_TEXTURE_TYPES) {
+               R600_ERR("r600: unsupported texture type %d\n", target);
+               return FALSE;
+       }
+
+       if (!util_format_is_supported(format, usage))
+               return FALSE;
+
+       /* Multisample */
+       if (sample_count > 1)
+               return FALSE;
+
+       if ((usage & PIPE_BIND_SAMPLER_VIEW) &&
+           r600_is_sampler_format_supported(screen, format)) {
+               retval |= PIPE_BIND_SAMPLER_VIEW;
+       }
+
+       if ((usage & (PIPE_BIND_RENDER_TARGET |
+                     PIPE_BIND_DISPLAY_TARGET |
+                     PIPE_BIND_SCANOUT |
+                     PIPE_BIND_SHARED)) &&
+           r600_is_colorbuffer_format_supported(format)) {
+               retval |= usage &
+                         (PIPE_BIND_RENDER_TARGET |
+                          PIPE_BIND_DISPLAY_TARGET |
+                          PIPE_BIND_SCANOUT |
+                          PIPE_BIND_SHARED);
+       }
+
+       if ((usage & PIPE_BIND_DEPTH_STENCIL) &&
+           r600_is_zs_format_supported(format)) {
+               retval |= PIPE_BIND_DEPTH_STENCIL;
+       }
+
+       if ((usage & PIPE_BIND_VERTEX_BUFFER) &&
+           r600_is_vertex_format_supported(format)) {
+               retval |= PIPE_BIND_VERTEX_BUFFER;
+       }
+
+       if (usage & PIPE_BIND_TRANSFER_READ)
+               retval |= PIPE_BIND_TRANSFER_READ;
+       if (usage & PIPE_BIND_TRANSFER_WRITE)
+               retval |= PIPE_BIND_TRANSFER_WRITE;
+
+       return retval == usage;
+}
+
 void r600_polygon_offset_update(struct r600_pipe_context *rctx)
 {
        struct r600_pipe_state state;
index 71852543e56f2b076e67b4137a66030aa9280de9..5615dc6dda33726df1c5b50209b1b789c6e48394 100644 (file)
@@ -576,36 +576,4 @@ static INLINE boolean r600_is_zs_format_supported(enum pipe_format format)
        return r600_translate_dbformat(format) != ~0;
 }
 
-static INLINE boolean r600_is_vertex_format_supported(enum pipe_format format)
-{
-       unsigned i;
-       const struct util_format_description *desc = util_format_description(format);
-       if (!desc)
-               return FALSE;
-
-       /* Find the first non-VOID channel. */
-       for (i = 0; i < 4; i++) {
-               if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID) {
-                       break;
-               }
-       }
-       if (i == 4)
-               return FALSE;
-
-       /* No fixed, no double. */
-       if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN ||
-           desc->channel[i].type == UTIL_FORMAT_TYPE_FIXED ||
-           (desc->channel[i].size == 64 &&
-            desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT))
-               return FALSE;
-
-       /* No scaled/norm formats with 32 bits per channel. */
-       if (desc->channel[i].size == 32 &&
-           (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED ||
-            desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED))
-               return FALSE;
-
-       return TRUE;
-}
-
 #endif