mesa/soft/llvmpipe: add fake MSAA support
authorDave Airlie <airlied@gmail.com>
Wed, 27 Nov 2013 09:47:51 +0000 (19:47 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 2 Apr 2014 02:12:04 +0000 (12:12 +1000)
This adds a gallium cap that allows us to fake GL3.0 by
not exposing MSAA on sw rendering.
It also forces the extra extensions needed for GL3.2.

Signed-off-by: Dave Airlie <airlied@redhat.com>
15 files changed:
src/gallium/drivers/freedreno/freedreno_screen.c
src/gallium/drivers/i915/i915_screen.c
src/gallium/drivers/ilo/ilo_screen.c
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/nouveau/nv30/nv30_screen.c
src/gallium/drivers/nouveau/nv50/nv50_screen.c
src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/radeonsi/si_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/main/mtypes.h
src/mesa/main/version.c
src/mesa/state_tracker/st_extensions.c

index 228ed1868c52e246244074e8f71677132e34634d..4f0675fc84a510adf7e76fa2d4e576f9ab1d396a 100644 (file)
@@ -206,6 +206,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
        case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS:
        case PIPE_CAP_TEXTURE_GATHER_SM5:
         case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
+        case PIPE_CAP_FAKE_SW_MSAA:
                return 0;
 
        /* Stream output. */
index 88b190b4009a0b6efef22c21c0329e221100dab6..0f8ba30b992cfa30f010840bcee0c92e03cab836 100644 (file)
@@ -218,6 +218,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
    case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER:
    case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS:
    case PIPE_CAP_TEXTURE_GATHER_SM5:
+   case PIPE_CAP_FAKE_SW_MSAA:
       return 0;
 
    case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
index 4a046628d62cdc7b6b7c5ef272c3549f0d845e73..131c9f22caa3d9b763b6a40ba6da2944e6cf5d58 100644 (file)
@@ -436,6 +436,7 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS:
    case PIPE_CAP_TEXTURE_GATHER_SM5:
    case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
+   case PIPE_CAP_FAKE_SW_MSAA:
       return 0;
 
    default:
index fe06e34f67568ace0e3172c3744c4db145e2d17e..766e433b96870e386edbffe68a8b236619e9735c 100644 (file)
@@ -239,6 +239,8 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_GATHER_SM5:
    case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
       return 0;
+   case PIPE_CAP_FAKE_SW_MSAA:
+       return 1;
    }
    /* should only get here on unhandled cases */
    debug_printf("Unexpected PIPE_CAP %d query\n", param);
index 5378913884fa6bc16c74d7ce81dbdc669b8bf35c..2439218f341c2b5f4c7ec34366ad1c6ec65773e1 100644 (file)
@@ -131,6 +131,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS:
    case PIPE_CAP_TEXTURE_GATHER_SM5:
    case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
+   case PIPE_CAP_FAKE_SW_MSAA:
       return 0;
    case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
    case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
index e8c7fe3cc24f69f2781e9365f9d683e732d8de43..fd5d488bf247967d7a081e82c3af35cc9c76df75 100644 (file)
@@ -195,6 +195,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_TGSI_VS_LAYER:
    case PIPE_CAP_TEXTURE_GATHER_SM5:
    case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
+   case PIPE_CAP_FAKE_SW_MSAA:
       return 0;
    case PIPE_CAP_MAX_VIEWPORTS:
       return NV50_MAX_VIEWPORTS;
index 04f30886a09d2dedf74b16b11d7ee6774856d134..a9f11bc5ada289d32e9ea5bbfb82f1043cb64c2f 100644 (file)
@@ -177,6 +177,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS:
    case PIPE_CAP_TEXTURE_GATHER_SM5:
    case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
+   case PIPE_CAP_FAKE_SW_MSAA:
       return 0;
    case PIPE_CAP_MAX_VIEWPORTS:
       return 1;
index 982e18d47a2ad0cf667223e8d37722c58d79a910..2ba459157548de56930932423ca4ab2d49add79f 100644 (file)
@@ -333,6 +333,9 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_TGSI_TEXCOORD:
                return 0;
 
+       case PIPE_CAP_FAKE_SW_MSAA:
+               return 0;
+
        case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE:
                return MIN2(rscreen->b.info.vram_size, 0xFFFFFFFF);
 
index 401bf6a8689ab505d6881054928e0c31d94a0bcf..7c741b7e2ad6f75af08a360fe6b348f962124afd 100644 (file)
@@ -290,6 +290,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS:
        case PIPE_CAP_TEXTURE_GATHER_SM5:
        case PIPE_CAP_TGSI_TEXCOORD:
+       case PIPE_CAP_FAKE_SW_MSAA:
                return 0;
 
        case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
index 71f4c4f6090003f4b9eb7e0d14bd8bcae77344ba..c3bb74c4960c310c2182eb6e7a892f49ca21b931 100644 (file)
@@ -189,6 +189,8 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_GATHER_SM5:
    case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
       return 0;
+   case PIPE_CAP_FAKE_SW_MSAA:
+      return 1;
    }
    /* should only get here on unhandled cases */
    debug_printf("Unexpected PIPE_CAP %d query\n", param);
index 0d50e6184ea02266d7f171aa6c499439837804ae..5c5b47302ff4e3e3c375b881256a2a01b8958f2f 100644 (file)
@@ -269,6 +269,7 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS:
    case PIPE_CAP_TEXTURE_GATHER_SM5:
    case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
+   case PIPE_CAP_FAKE_SW_MSAA:
       return 0;
    case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
       return 64;
index a220de0404803c8ee3e4d80945f1f60b7ee84bae..8c092c2e619c5c521a6bc70ecea636c603b8c369 100644 (file)
@@ -551,7 +551,8 @@ enum pipe_cap {
    PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS = 89,
    PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS = 90,
    PIPE_CAP_TEXTURE_GATHER_SM5 = 91,
-   PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT = 92
+   PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT = 92,
+   PIPE_CAP_FAKE_SW_MSAA = 93
 };
 
 #define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 (1 << 0)
index 15c0a5931b35157931edea5fc9b0e17f9225f0d3..4d014d1ee3ab147e5b616345f99769ff3a4d18b4 100644 (file)
@@ -3471,6 +3471,8 @@ struct gl_constants
    /** GL_ARB_gpu_shader5 */
    GLfloat MinFragmentInterpolationOffset;
    GLfloat MaxFragmentInterpolationOffset;
+
+   GLboolean FakeSWMSAA;
 };
 
 
index 1c0bedf4bb2b3f18a047784bea73eca5768baea0..b7cc50fc146f15b5f33b053a8d090debee2ccf0a 100644 (file)
@@ -228,7 +228,7 @@ compute_version(struct gl_context *ctx)
                               ctx->Extensions.EXT_texture_sRGB);
    const GLboolean ver_3_0 = (ver_2_1 &&
                               ctx->Const.GLSLVersion >= 130 &&
-                              ctx->Const.MaxSamples >= 4 &&
+                              (ctx->Const.MaxSamples >= 4 || ctx->Const.FakeSWMSAA) &&
                               (ctx->API == API_OPENGL_CORE ||
                                ctx->Extensions.ARB_color_buffer_float) &&
                               ctx->Extensions.ARB_depth_buffer_float &&
index 18ddd4e471a1574cd259ba36cf84224bbaa5bdbe..a83a70886245de54e18368378c6056492e749820 100644 (file)
@@ -728,6 +728,13 @@ void st_init_extensions(struct st_context *st)
       ctx->Extensions.EXT_framebuffer_multisample_blit_scaled = GL_TRUE;
    }
 
+   if (ctx->Const.MaxSamples == 0 && screen->get_param(screen, PIPE_CAP_FAKE_SW_MSAA)) {
+       ctx->Const.FakeSWMSAA = GL_TRUE;
+        ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE;
+        ctx->Extensions.EXT_framebuffer_multisample_blit_scaled = GL_TRUE;
+        ctx->Extensions.ARB_texture_multisample = GL_TRUE;
+   }
+
    if (ctx->Const.MaxDualSourceDrawBuffers > 0 &&
        !st->options.disable_blend_func_extended)
       ctx->Extensions.ARB_blend_func_extended = GL_TRUE;