freedreno: add is_a3xx()/is_a4xx() helpers
authorRob Clark <robclark@freedesktop.org>
Fri, 12 Dec 2014 23:51:36 +0000 (18:51 -0500)
committerRob Clark <robclark@freedesktop.org>
Sat, 13 Dec 2014 20:09:37 +0000 (15:09 -0500)
A bunch of open-coded 'gpu_id > 300's seems like it will eventually
cause problems with future generations.  There were already a few minor
problems with caps for features that still need additional work on a4xx.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/gallium/drivers/freedreno/freedreno_gmem.c
src/gallium/drivers/freedreno/freedreno_screen.c
src/gallium/drivers/freedreno/freedreno_screen.h

index 392c547c1372d26a6a0922c9c893672d4ae8b12a..4040d1f76152f6862188cdb9d639020394ee561c 100644 (file)
@@ -69,7 +69,9 @@
 
 static uint32_t bin_width(struct fd_context *ctx)
 {
-       if (ctx->screen->gpu_id >= 300)
+       if (is_a4xx(ctx->screen))
+               return 1024;
+       if (is_a3xx(ctx->screen))
                return 992;
        return 512;
 }
index ce105b8786b90722feaa5c7529b0b128d72d1267..19379a8b02418c7838335b3f68a4835ffd470d68 100644 (file)
@@ -193,13 +193,13 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
 
        case PIPE_CAP_SM3:
        case PIPE_CAP_PRIMITIVE_RESTART:
-               return (screen->gpu_id >= 300) ? 1 : 0;
+               return is_a3xx(screen) || is_a4xx(screen);
 
        case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT:
                return 256;
 
        case PIPE_CAP_GLSL_FEATURE_LEVEL:
-               return ((screen->gpu_id >= 300) && glsl130) ? 130 : 120;
+               return ((is_a3xx(screen) || is_a4xx(screen)) && glsl130) ? 130 : 120;
 
        /* Unsupported features. */
        case PIPE_CAP_INDEP_BLEND_ENABLE:
@@ -257,7 +257,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
                return 11;
 
        case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS:
-               return (screen->gpu_id >= 300) ? 256 : 0;
+               return (is_a3xx(screen) || is_a4xx(screen)) ? 256 : 0;
 
        /* Render targets. */
        case PIPE_CAP_MAX_RENDER_TARGETS:
@@ -268,7 +268,10 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
        case PIPE_CAP_QUERY_TIMESTAMP:
                return 0;
        case PIPE_CAP_OCCLUSION_QUERY:
-               return (screen->gpu_id >= 300) ? 1 : 0;
+               /* TODO still missing on a4xx, but we lie to get gl2..
+                * it's not a feature, it's a bug!
+                */
+               return is_a3xx(screen) || is_a4xx(screen);
 
        case PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET:
        case PIPE_CAP_MIN_TEXEL_OFFSET:
@@ -362,7 +365,7 @@ fd_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader,
                 * split between VS and FS.  Use lower limit of 256 to
                 * avoid getting into impossible situations:
                 */
-               return ((screen->gpu_id >= 300) ? 256 : 64) * sizeof(float[4]);
+               return ((is_a3xx(screen) || is_a4xx(screen)) ? 256 : 64) * sizeof(float[4]);
        case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
                return 1;
        case PIPE_SHADER_CAP_MAX_PREDS:
@@ -382,8 +385,11 @@ fd_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader,
        case PIPE_SHADER_CAP_INTEGERS:
                /* we should be able to support this on a3xx, but not
                 * implemented yet:
+                *
+                * TODO looks like a4xx will require some additional
+                * work for integer varying fetch..
                 */
-               return ((screen->gpu_id >= 300) && glsl130) ? 1 : 0;
+               return (is_a3xx(screen) && glsl130) ? 1 : 0;
        case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
        case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS:
                return 16;
index 4bfa74466c9c057c2067360017250e918826f88c..e1c554c0538fb9c0f973d69984654069be278490 100644 (file)
@@ -76,4 +76,16 @@ is_a3xx_p0(struct fd_screen *screen)
        return (screen->chip_id & 0xff0000ff) == 0x03000000;
 }
 
+static inline boolean
+is_a3xx(struct fd_screen *screen)
+{
+       return (screen->gpu_id >= 300) && (screen->gpu_id < 400);
+}
+
+static inline boolean
+is_a4xx(struct fd_screen *screen)
+{
+       return (screen->gpu_id >= 400) && (screen->gpu_id < 500);
+}
+
 #endif /* FREEDRENO_SCREEN_H_ */