softpipe: allow softpipe to set shader params depending on runtime llvm (v3)
authorDave Airlie <airlied@redhat.com>
Thu, 5 Jan 2012 14:25:04 +0000 (14:25 +0000)
committerDave Airlie <airlied@redhat.com>
Wed, 11 Jan 2012 07:13:27 +0000 (07:13 +0000)
If draw isn't using llvm we can support vertex texture and integers,
These will be fixed up later, but for now allow this check to happen
at run-time.

v2: since 3e22c7a25321554a32fa6254485912fd53deff3a we can ask draw for a non-llvm
context. Just track if ask and set the vars accordingly. This probably isn't perfect but should cover the cases we care about.

v3: use debug option, restructure to store in screen, as suggested by Jakob.

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/softpipe/sp_context.c
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/drivers/softpipe/sp_screen.h

index e533e5a82439300a530e919688e0cff8d393d8fb..abe0507b1acf148524164458533eee5583c1aaf5 100644 (file)
@@ -50,7 +50,7 @@
 #include "sp_tex_tile_cache.h"
 #include "sp_texture.h"
 #include "sp_query.h"
-
+#include "sp_screen.h"
 
 
 /**
@@ -230,6 +230,7 @@ struct pipe_context *
 softpipe_create_context( struct pipe_screen *screen,
                         void *priv )
 {
+   struct softpipe_screen *sp_screen = softpipe_screen(screen);
    struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context);
    uint i;
 
@@ -304,7 +305,7 @@ softpipe_create_context( struct pipe_screen *screen,
    /*
     * Create drawing context and plug our rendering stage into it.
     */
-   if (debug_get_bool_option("SOFTPIPE_USE_LLVM", FALSE))
+   if (sp_screen->using_llvm)
       softpipe->draw = draw_create(&softpipe->pipe);
    else
       softpipe->draw = draw_create_no_llvm(&softpipe->pipe);
index 982af6b380892e6d99ad36c03792f164ba0a9344..35521b64ab1221bbd6419866353cf64560ad9d2d 100644 (file)
@@ -45,6 +45,7 @@
 #include "sp_fence.h"
 #include "sp_public.h"
 
+DEBUG_GET_ONCE_BOOL_OPTION(use_llvm, "SOFTPIPE_USE_LLVM", FALSE);
 
 static const char *
 softpipe_get_vendor(struct pipe_screen *screen)
@@ -135,6 +136,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
 static int
 softpipe_get_shader_param(struct pipe_screen *screen, unsigned shader, enum pipe_shader_cap param)
 {
+   struct softpipe_screen *sp_screen = softpipe_screen(screen);
    switch(shader)
    {
    case PIPE_SHADER_FRAGMENT:
@@ -144,11 +146,17 @@ softpipe_get_shader_param(struct pipe_screen *screen, unsigned shader, enum pipe
       switch (param) {
       case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
 #ifdef HAVE_LLVM
-         /* Softpipe doesn't yet know how to tell draw/llvm about textures */
-         return 0;
-#else
+         if (sp_screen->use_llvm)
+            /* Softpipe doesn't yet know how to tell draw/llvm about textures */
+            return 0;
+#endif
          return PIPE_MAX_VERTEX_SAMPLERS;
+      case PIPE_SHADER_CAP_INTEGERS:
+#ifdef HAVE_LLVM /* gallivm doesn't support integers yet */
+         if (sp_screen->use_llvm)
+            return 0;
 #endif
+         /* fallthrough */
       default:
          return draw_get_shader_param(shader, param);
       }
@@ -326,6 +334,8 @@ softpipe_create_screen(struct sw_winsys *winsys)
    screen->base.context_create = softpipe_create_context;
    screen->base.flush_frontbuffer = softpipe_flush_frontbuffer;
 
+   screen->using_llvm = debug_get_option_use_llvm();
+
    util_format_s3tc_init();
 
    softpipe_init_screen_texture_funcs(&screen->base);
index f741454c9e5f472578baa43a25db8aa93fa3d4a3..2cac81641a0100f2fbf3f0d106e6585ce6eb5bd3 100644 (file)
@@ -45,12 +45,10 @@ struct softpipe_screen {
    /* Increments whenever textures are modified.  Contexts can track
     * this.
     */
-   unsigned timestamp;          
+   unsigned timestamp;
+   boolean using_llvm;
 };
 
-
-
-
 static INLINE struct softpipe_screen *
 softpipe_screen( struct pipe_screen *pipe )
 {