gallium,st/mesa: don't use blit-based transfers with software rasterizers
authorMarek Olšák <maraeo@gmail.com>
Thu, 14 Mar 2013 16:18:43 +0000 (17:18 +0100)
committerMarek Olšák <maraeo@gmail.com>
Sat, 23 Mar 2013 12:19:16 +0000 (13:19 +0100)
The blit-based paths for TexImage, GetTexImage, and ReadPixels aren't very
fast with software rasterizer. Now Gallium drivers have the ability to turn
them off.

Reviewed-by: Brian Paul <brianp@vmware.com>
Tested-by: Brian Paul <brianp@vmware.com>
15 files changed:
src/gallium/docs/source/screen.rst
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/nv30/nv30_screen.c
src/gallium/drivers/nv50/nv50_screen.c
src/gallium/drivers/nvc0/nvc0_screen.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/radeonsi/radeonsi_pipe.c
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/drivers/svga/svga_screen.c
src/gallium/include/pipe/p_defines.h
src/mesa/state_tracker/st_cb_readpixels.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_context.c
src/mesa/state_tracker/st_context.h

index 0550a30714a535d93a7e63ce8241747fad68e6df..9b8704904ab8f7f11a18b01466f8079d8bd8603b 100644 (file)
@@ -145,6 +145,10 @@ The integer capabilities:
   TEXCOORD semantic.
   Also, TGSI_SEMANTIC_PCOORD becomes available, which labels a fragment shader
   input that will always be replaced with sprite coordinates.
+* ``PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER``: Whether it is preferable
+  to use a blit to implement a texture transfer which needs format conversions
+  and swizzling in state trackers. Generally, all hardware drivers with
+  dedicated memory should return 1 and all software rasterizers should return 0.
 
 
 .. _pipe_capf:
index 6760db0b38f171b6d077b021794f1c9fb611102f..e8c6ab1f8064dcad68fcc5d18d27e4962d6f0367 100644 (file)
@@ -222,6 +222,8 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
       return 1;
    case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT:
       return 1;
+   case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER:
+      return 0;
    }
    /* should only get here on unhandled cases */
    debug_printf("Unexpected PIPE_CAP %d query\n", param);
index e17ee76fbd19d911d34a13c293ae6d3204b63522..4084869dba8dbe6dce56964a2e9d60de1a8dde50 100644 (file)
@@ -126,6 +126,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
    case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
    case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
+   case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER:
       return 1;
    default:
       debug_printf("unknown param %d\n", param);
index fb29b2290c241d975b1c2cbf8f4424c5fd7aec94..0a20ae3e924224eb871a094331baa55e04a0d860 100644 (file)
@@ -187,6 +187,8 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_TGSI_TEXCOORD:
    case PIPE_CAP_TEXTURE_MULTISAMPLE:
       return 0;
+   case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER:
+      return 1;
    default:
       NOUVEAU_ERR("unknown PIPE_CAP %d\n", param);
       return 0;
index 73cf0af4d1d679371820eeb8de8cf73382bf9c74..b6cf2ca8a1fc797ee88a5c70d53bdb14deffba73 100644 (file)
@@ -179,6 +179,8 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
       return 0;
    case PIPE_CAP_COMPUTE:
       return (class_3d >= NVE4_3D_CLASS) ? 1 : 0;
+   case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER:
+      return 1;
    default:
       NOUVEAU_ERR("unknown PIPE_CAP %d\n", param);
       return 0;
index 46fb869cb7285f7566304e606ca0d2200fde1bf0..bd16c3b76b11e511286c4a17e59f006205dd580e 100644 (file)
@@ -106,6 +106,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
         case PIPE_CAP_USER_INDEX_BUFFERS:
         case PIPE_CAP_USER_CONSTANT_BUFFERS:
         case PIPE_CAP_DEPTH_CLIP_DISABLE: /* XXX implemented, but breaks Regnum Online */
+        case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER:
             return 1;
 
         case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
index 7a84f3d5c6ed7baabad150a5b78772ae2a4c4826..81448d49ee965ef80f0849ecb5d4bfdeb35b34c5 100644 (file)
@@ -564,6 +564,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_START_INSTANCE:
        case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
        case PIPE_CAP_TEXTURE_BUFFER_OBJECTS:
+        case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER:
                return 1;
        case PIPE_CAP_TGSI_TEXCOORD:
                return 0;
index 859843867ce926d3ae787c4f614fd2051a7bfeae..672017a4ec7a877842768309f09586cc12a4c4b7 100644 (file)
@@ -329,6 +329,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_USER_CONSTANT_BUFFERS:
        case PIPE_CAP_START_INSTANCE:
        case PIPE_CAP_NPOT_TEXTURES:
+        case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER:
                return 1;
        case PIPE_CAP_TGSI_TEXCOORD:
                return 0;
index 937035e5511d461c01e31c6b2861dbc52b40f69d..0261c69197c4fa283a81895e3d697cd82ccbe22b 100644 (file)
@@ -174,6 +174,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT:
       return 0;
    case PIPE_CAP_TGSI_TEXCOORD:
+   case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER:
       return 0;
    }
    /* should only get here on unhandled cases */
index f0831b9f2fed7d80a23ff68de1ad8d51e2b08abe..0558a46c0aa49e98d5b365838082d7dcc7246921 100644 (file)
@@ -224,6 +224,9 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_GLSL_FEATURE_LEVEL:
       return 120;
 
+   case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER:
+      return 1;
+
    /* Unsupported features */
    case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION:
    case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
index 7f20b992a138197bcb7b2b7ac7fcf0fbeb3c8d8e..f59e78a1a9e6b02012014e473f146066e3caaf54 100644 (file)
@@ -499,7 +499,8 @@ enum pipe_cap {
    PIPE_CAP_CUBE_MAP_ARRAY = 76,
    PIPE_CAP_TEXTURE_BUFFER_OBJECTS = 77,
    PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT = 78,
-   PIPE_CAP_TGSI_TEXCOORD = 79
+   PIPE_CAP_TGSI_TEXCOORD = 79,
+   PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER = 80
 };
 
 /**
index b524738ae29f889bbf0f8e29eb43a5546c3e4329..bfed988701a7e1a2835280b6210ad731ff11194c 100644 (file)
@@ -83,6 +83,10 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y,
    st_validate_state(st);
    st_flush_bitmap_cache(st);
 
+   if (!st->prefer_blit_based_texture_transfer) {
+      goto fallback;
+   }
+
    /* This must be done after state validation. */
    src = strb->texture;
 
index 7307c6052c54a595b8edd9421283f70d16086131..94fbbf7bed88c82848af2fa1aed8a32e986a76f2 100644 (file)
@@ -608,6 +608,10 @@ st_TexSubImage(struct gl_context *ctx, GLuint dims,
    unsigned bind;
    GLubyte *map;
 
+   if (!st->prefer_blit_based_texture_transfer) {
+      goto fallback;
+   }
+
    if (!dst) {
       goto fallback;
    }
@@ -860,6 +864,10 @@ st_GetTexImage(struct gl_context * ctx,
    ubyte *map = NULL;
    boolean done = FALSE;
 
+   if (!st->prefer_blit_based_texture_transfer) {
+      goto fallback;
+   }
+
    if (!stImage->pt) {
       goto fallback;
    }
index e2d074d14a4b99e3a4bbc279a3f496fb4eabe817..cc87f2bb38d5c3cabeea0142c31a1ef152e2370d 100644 (file)
@@ -182,6 +182,8 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe,
    st->has_stencil_export =
       screen->get_param(screen, PIPE_CAP_SHADER_STENCIL_EXPORT);
    st->has_shader_model3 = screen->get_param(screen, PIPE_CAP_SM3);
+   st->prefer_blit_based_texture_transfer = screen->get_param(screen,
+                              PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER);
 
    st->needs_texcoord_semantic =
       screen->get_param(screen, PIPE_CAP_TGSI_TEXCOORD);
index c6c68adcfb21f9f08f538f2e3a4a475db1608537..8786a036ff4b8705a73d410bb0e220df5bea7423 100644 (file)
@@ -84,6 +84,7 @@ struct st_context
    boolean has_stencil_export; /**< can do shader stencil export? */
    boolean has_time_elapsed;
    boolean has_shader_model3;
+   boolean prefer_blit_based_texture_transfer;
 
    boolean needs_texcoord_semantic;