[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

mesa: Changes to 'upstream-experimental'



 docs/relnotes-7.7.1.html                                 |    1 
 src/gallium/drivers/llvmpipe/lp_bld_arit.c               |   11 -
 src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c           |    2 
 src/gallium/drivers/llvmpipe/lp_debug.h                  |   71 ++++++
 src/gallium/drivers/llvmpipe/lp_draw_arrays.c            |    8 
 src/gallium/drivers/llvmpipe/lp_jit.c                    |    2 
 src/gallium/drivers/llvmpipe/lp_screen.c                 |   80 +++++++
 src/gallium/drivers/llvmpipe/lp_state_blend.c            |   18 +
 src/gallium/drivers/llvmpipe/lp_state_fs.c               |  156 ++++++++-------
 src/gallium/drivers/llvmpipe/lp_state_rasterizer.c       |    9 
 src/gallium/drivers/llvmpipe/lp_state_surface.c          |    2 
 src/gallium/drivers/llvmpipe/lp_state_vs.c               |   13 -
 src/gallium/drivers/softpipe/sp_state_blend.c            |    5 
 src/gallium/drivers/softpipe/sp_state_fs.c               |   11 -
 src/gallium/drivers/softpipe/sp_state_rasterizer.c       |    9 
 src/gallium/drivers/softpipe/sp_state_surface.c          |    2 
 src/gallium/drivers/svga/svga_context.c                  |    1 
 src/gallium/drivers/svga/svga_context.h                  |    4 
 src/gallium/drivers/svga/svga_pipe_blend.c               |    7 
 src/gallium/drivers/svga/svga_pipe_draw.c                |    3 
 src/gallium/drivers/svga/svga_screen_buffer.c            |   62 +++++
 src/gallium/drivers/svga/svga_screen_texture.c           |    4 
 src/gallium/drivers/svga/svga_state_fs.c                 |  126 +++---------
 src/gallium/drivers/svga/svga_tgsi.h                     |    1 
 src/gallium/drivers/svga/svga_tgsi_decl_sm30.c           |   15 +
 src/gallium/drivers/svga/svga_tgsi_insn.c                |   34 ++-
 src/gallium/state_trackers/python/retrace/interpreter.py |    2 
 src/gallium/state_trackers/xorg/xorg_crtc.c              |    4 
 src/gallium/state_trackers/xorg/xorg_driver.c            |    4 
 src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h          |   43 ----
 src/glx/x11/dri2_glx.c                                   |   13 -
 src/mesa/drivers/dri/r600/r600_context.c                 |   16 -
 src/mesa/drivers/dri/r600/r600_tex.h                     |    2 
 src/mesa/drivers/dri/r600/r700_assembler.c               |   15 -
 src/mesa/drivers/windows/gdi/mesa.def                    |    4 
 src/mesa/drivers/windows/gdi/wmesa.c                     |   12 -
 src/mesa/main/api_validate.c                             |    9 
 src/mesa/main/context.c                                  |    4 
 src/mesa/shader/slang/slang_preprocess.c                 |   32 ++-
 src/mesa/state_tracker/st_draw.c                         |    3 
 src/mesa/tnl/t_draw.c                                    |    3 
 src/mesa/vbo/vbo_exec_array.c                            |   32 +--
 windows/VC8/mesa/gdi/gdi.vcproj                          |    8 
 windows/VC8/mesa/mesa/mesa.vcproj                        |   12 -
 44 files changed, 544 insertions(+), 331 deletions(-)

New commits:
commit f5145a6ec3e9086988ab8ec004276f845fecc3d9
Author: Jakob Bornecrantz <jakob@vmware.com>
Date:   Fri Jan 29 17:11:36 2010 +0100

    vmware/core: Remove old ioctl structs not used
    
    Leftover that was never used in this driver

diff --git a/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h b/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h
index 2be7e12..681d6b5 100644
--- a/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h
+++ b/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h
@@ -87,49 +87,6 @@ struct drm_vmw_getparam_arg {
 
 /*************************************************************************/
 /**
- * DRM_VMW_EXTENSION - Query device extensions.
- */
-
-/**
- * struct drm_vmw_extension_rep
- *
- * @exists: The queried extension exists.
- * @driver_ioctl_offset: Ioctl number of the first ioctl in the extension.
- * @driver_sarea_offset: Offset to any space in the DRI SAREA
- * used by the extension.
- * @major: Major version number of the extension.
- * @minor: Minor version number of the extension.
- * @pl: Patch level version number of the extension.
- *
- * Output argument to the DRM_VMW_EXTENSION Ioctl.
- */
-
-struct drm_vmw_extension_rep {
-	int32_t exists;
-	uint32_t driver_ioctl_offset;
-	uint32_t driver_sarea_offset;
-	uint32_t major;
-	uint32_t minor;
-	uint32_t pl;
-	uint32_t pad64;
-};
-
-/**
- * union drm_vmw_extension_arg
- *
- * @extension - Ascii name of the extension to be queried. //In
- * @rep - Reply as defined above. //Out
- *
- * Argument to the DRM_VMW_EXTENSION Ioctl.
- */
-
-union drm_vmw_extension_arg {
-	char extension[DRM_VMW_EXT_NAME_LEN];
-	struct drm_vmw_extension_rep rep;
-};
-
-/*************************************************************************/
-/**
  * DRM_VMW_CREATE_CONTEXT - Create a host context.
  *
  * Allocates a device unique context id, and queues a create context command

commit ddedfe12d41808c3caa77649e3a9a6c4c6253d69
Author: José Fonseca <jfonseca@vmware.com>
Date:   Thu Jan 28 20:51:52 2010 +0000

    svga: Actually call fence_reference in texture downloads.

diff --git a/src/gallium/drivers/svga/svga_screen_texture.c b/src/gallium/drivers/svga/svga_screen_texture.c
index 9ad4eda..c381988 100644
--- a/src/gallium/drivers/svga/svga_screen_texture.c
+++ b/src/gallium/drivers/svga/svga_screen_texture.c
@@ -203,7 +203,7 @@ svga_transfer_dma(struct svga_transfer *st,
       if(transfer == SVGA3D_READ_HOST_VRAM) {
          svga_screen_flush(screen, &fence);
          sws->fence_finish(sws, fence, 0);
-         //sws->fence_reference(sws, &fence, NULL);
+         sws->fence_reference(sws, &fence, NULL);
       }
    }
    else {
@@ -232,7 +232,7 @@ svga_transfer_dma(struct svga_transfer *st,
             if(y) {
                svga_screen_flush(screen, &fence);
                sws->fence_finish(sws, fence, 0);
-               //sws->fence_reference(sws, &fence, NULL);
+               sws->fence_reference(sws, &fence, NULL);
             }
 
             hw = sws->buffer_map(sws, st->hwbuf, PIPE_BUFFER_USAGE_CPU_WRITE);

commit cb5447f79ca03d29407e8db84166f5bddd8d4c59
Author: Brian Paul <brianp@vmware.com>
Date:   Fri Jan 29 08:26:23 2010 -0700

    glsl: fix preprocessor bug involving //-style comments in macro definitions
    
    See comments for details.

diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c
index e9a24cc..ba40bad 100644
--- a/src/mesa/shader/slang/slang_preprocess.c
+++ b/src/mesa/shader/slang/slang_preprocess.c
@@ -914,6 +914,35 @@ parse_if (slang_string *output, const byte *prod, GLuint *pi, GLint *result, pp_
 #define PRAGMA_PARAM     1
 
 
+/**
+ * Return the length of the given string, stopping at any C++-style comments.
+ * This step fixes bugs with macro definitions such as:
+ *   #define PI 3.14159 // this is pi
+ * The preprocessor includes the comment in the definition of PI so
+ * when we plug in PI somewhere, we get the comment too.
+ * This function effectively strips of the // comment from the given string.
+ * It might also be possible to fix this in the preprocessor grammar.
+ * This bug is not present in the new Mesa 7.8 preprocessor.
+ */
+static int
+strlen_without_comments(const char *s)
+{
+   char pred = 0;
+   int len = 0;
+   while (*s) {
+      if (*s == '/' && pred == '/') {
+         return len - 1;
+      }
+      pred = *s;
+      s++;
+      len++;
+   }
+   return len;
+}
+
+
+
+
 static GLboolean
 preprocess_source (slang_string *output, const char *source,
                    grammar pid, grammar eid,
@@ -1055,11 +1084,12 @@ preprocess_source (slang_string *output, const char *source,
                if (state.cond.top->effective) {
                   slang_string replacement;
                   expand_state es;
+                  int idlen2 = strlen_without_comments((char*)id);
 
                   pp_annotate (output, ") %s", id);
 
                   slang_string_init(&replacement);
-                  slang_string_pushs(&replacement, id, idlen);
+                  slang_string_pushs(&replacement, id, idlen2);
 
                   /* Expand macro replacement. */
                   es.output = &symbol->replacement;

commit 9fd3c74724e557bc6ecc851d8552615ab3becfe2
Author: Brian Paul <brianp@vmware.com>
Date:   Thu Jan 28 13:05:36 2010 -0700

    tnl: check that state is validated before drawing

diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c
index 9a888ce..b0e31c0 100644
--- a/src/mesa/tnl/t_draw.c
+++ b/src/mesa/tnl/t_draw.c
@@ -394,6 +394,9 @@ void _tnl_draw_prims( GLcontext *ctx,
    GLuint max_basevertex = prim->basevertex;
    GLuint i;
 
+   /* Mesa core state should have been validated already */
+   assert(ctx->NewState == 0x0);
+
    for (i = 1; i < nr_prims; i++)
       max_basevertex = MAX2(max_basevertex, prim[i].basevertex);
 

commit 4d1234e22242529c8d85f5ef0cf826af41a91570
Author: Brian Paul <brianp@vmware.com>
Date:   Thu Jan 28 13:05:23 2010 -0700

    st/mesa: check that state is validated before drawing

diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 5c6af11..d3b22db 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -569,6 +569,9 @@ st_draw_vbo(GLcontext *ctx,
    /* sanity check for pointer arithmetic below */
    assert(sizeof(arrays[0]->Ptr[0]) == 1);
 
+   /* Mesa core state should have been validated already */
+   assert(ctx->NewState == 0x0);
+
    st_validate_state(ctx->st);
 
    /* must get these after state validation! */

commit 3cba779e16935f7c3a0bfd8af48bd5e015068e96
Author: Brian Paul <brianp@vmware.com>
Date:   Thu Jan 28 13:04:16 2010 -0700

    vbo: fix missing state validation bugs
    
    Commit 2708ddfb06a36d8568e2aa130bf1f7d551fcd309 caused a few regressions.
    We need to check/validate state after calling bind_arrays() because
    it might set the _NEW_ARRAYS flag if the varying VP inputs change.
    
    The symptom of this problem was some attribute arrays being ignored
    (or interpreted as constant-valued) in glDrawRangeElements or
    glMultiDrawElements.
    
    A follow-on patch will add some additional asserts to try to catch
    this kind of thing in the future.

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index fdd6b02..d08976c 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -443,6 +443,13 @@ recalculate_input_bindings(GLcontext *ctx)
 }
 
 
+/**
+ * Examine the enabled vertex arrays to set the exec->array.inputs[] values.
+ * These will point to the arrays to actually use for drawing.  Some will
+ * be user-provided arrays, other will be zero-stride const-valued arrays.
+ * Note that this might set the _NEW_ARRAY dirty flag so state validation
+ * must be done after this call.
+ */
 static void
 bind_arrays(GLcontext *ctx)
 {
@@ -484,9 +491,6 @@ vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count)
 
    FLUSH_CURRENT( ctx, 0 );
 
-   if (ctx->NewState)
-      _mesa_update_state( ctx );
-      
    if (!_mesa_valid_to_render(ctx, "glDrawArrays")) {
       return;
    }
@@ -600,18 +604,16 @@ vbo_validated_drawrangeelements(GLcontext *ctx, GLenum mode,
 
    FLUSH_CURRENT( ctx, 0 );
 
-   if (ctx->NewState)
-      _mesa_update_state( ctx );
-
    if (!_mesa_valid_to_render(ctx, "glDraw[Range]Elements")) {
       return;
    }
 
+   bind_arrays( ctx );
+
+   /* check for dirty state again */
    if (ctx->NewState)
       _mesa_update_state( ctx );
 
-   bind_arrays( ctx );
-
    ib.count = count;
    ib.type = type;
    ib.obj = ctx->Array.ElementArrayBufferObj;
@@ -848,16 +850,10 @@ vbo_validated_multidrawelements(GLcontext *ctx, GLenum mode,
 
    FLUSH_CURRENT( ctx, 0 );
 
-   if (ctx->NewState)
-      _mesa_update_state( ctx );
-
    if (!_mesa_valid_to_render(ctx, "glMultiDrawElements")) {
       return;
    }
 
-   if (ctx->NewState)
-      _mesa_update_state( ctx );
-
    prim = _mesa_calloc(primcount * sizeof(*prim));
    if (prim == NULL) {
       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMultiDrawElements");
@@ -869,6 +865,10 @@ vbo_validated_multidrawelements(GLcontext *ctx, GLenum mode,
     */
    bind_arrays( ctx );
 
+   /* check for dirty state again */
+   if (ctx->NewState)
+      _mesa_update_state( ctx );
+
    switch (type) {
    case GL_UNSIGNED_INT:
       index_type_size = 4;

commit 23eda89ec89e2bd5bc26077bd56e8d6b5d4040d4
Author: Brian Paul <brianp@vmware.com>
Date:   Thu Jan 28 13:02:40 2010 -0700

    mesa: do state validation in _mesa_valid_to_render()
    
    ...rather than checking/validating before all the calls to
    _mesa_valid_to_render() and valid_to_render().
    
    The next patch will actually fix some bugs...

diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index e71e5a6..013048b 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -190,9 +190,6 @@ _mesa_validate_DrawElements(GLcontext *ctx,
       return GL_FALSE;
    }
 
-   if (ctx->NewState)
-      _mesa_update_state(ctx);
-
    if (!check_valid_to_render(ctx, "glDrawElements"))
       return GL_FALSE;
 
@@ -254,9 +251,6 @@ _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode,
       return GL_FALSE;
    }
 
-   if (ctx->NewState)
-      _mesa_update_state(ctx);
-
    if (!check_valid_to_render(ctx, "glDrawRangeElements"))
       return GL_FALSE;
 
@@ -304,9 +298,6 @@ _mesa_validate_DrawArrays(GLcontext *ctx,
       return GL_FALSE;
    }
 
-   if (ctx->NewState)
-      _mesa_update_state(ctx);
-
    if (!check_valid_to_render(ctx, "glDrawArrays"))
       return GL_FALSE;
 
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 87eae96..f5d9a30 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1580,6 +1580,10 @@ _mesa_set_mvp_with_dp4( GLcontext *ctx,
 GLboolean
 _mesa_valid_to_render(GLcontext *ctx, const char *where)
 {
+   /* This depends on having up to date derived state (shaders) */
+   if (ctx->NewState)
+      _mesa_update_state(ctx);
+
    if (ctx->Shader.CurrentProgram) {
       /* using shaders */
       if (!ctx->Shader.CurrentProgram->LinkStatus) {

commit 6e68898b05dc957dc6cb92d2ff060589e5936650
Author: José Fonseca <jfonseca@vmware.com>
Date:   Sat Dec 26 21:05:31 2009 +0000

    softpipe: Flush draw module when fragment pipeline state changes.

diff --git a/src/gallium/drivers/softpipe/sp_state_blend.c b/src/gallium/drivers/softpipe/sp_state_blend.c
index efed082..95ab323 100644
--- a/src/gallium/drivers/softpipe/sp_state_blend.c
+++ b/src/gallium/drivers/softpipe/sp_state_blend.c
@@ -29,6 +29,7 @@
  */
 
 #include "util/u_memory.h"
+#include "draw/draw_context.h"
 #include "sp_context.h"
 #include "sp_state.h"
 
@@ -45,6 +46,8 @@ void softpipe_bind_blend_state( struct pipe_context *pipe,
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
 
+   draw_flush(softpipe->draw);
+
    softpipe->blend = (struct pipe_blend_state *)blend;
 
    softpipe->dirty |= SP_NEW_BLEND;
@@ -62,6 +65,8 @@ void softpipe_set_blend_color( struct pipe_context *pipe,
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
 
+   draw_flush(softpipe->draw);
+
    softpipe->blend_color = *blend_color;
 
    softpipe->dirty |= SP_NEW_BLEND;
diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c
index b41f7e8..8ea48ed 100644
--- a/src/gallium/drivers/softpipe/sp_state_fs.c
+++ b/src/gallium/drivers/softpipe/sp_state_fs.c
@@ -69,7 +69,14 @@ softpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
 
-   softpipe->fs = (struct sp_fragment_shader *) fs;
+   draw_flush(softpipe->draw);
+
+   if (softpipe->fs == fs)
+      return;
+
+   draw_flush(softpipe->draw);
+
+   softpipe->fs = fs;
 
    softpipe->dirty |= SP_NEW_FS;
 }
@@ -159,6 +166,8 @@ softpipe_set_constant_buffer(struct pipe_context *pipe,
    assert(shader < PIPE_SHADER_TYPES);
    assert(index == 0);
 
+   draw_flush(softpipe->draw);
+
    /* note: reference counting */
    pipe_buffer_reference(&softpipe->constants[shader].buffer,
 			 buf ? buf->buffer : NULL);
diff --git a/src/gallium/drivers/softpipe/sp_state_rasterizer.c b/src/gallium/drivers/softpipe/sp_state_rasterizer.c
index 87b7219..a5b0033 100644
--- a/src/gallium/drivers/softpipe/sp_state_rasterizer.c
+++ b/src/gallium/drivers/softpipe/sp_state_rasterizer.c
@@ -41,14 +41,17 @@ softpipe_create_rasterizer_state(struct pipe_context *pipe,
 }
 
 void softpipe_bind_rasterizer_state(struct pipe_context *pipe,
-                                    void *setup)
+                                    void *rasterizer)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
 
+   if (softpipe->rasterizer == rasterizer)
+      return;
+
    /* pass-through to draw module */
-   draw_set_rasterizer_state(softpipe->draw, setup);
+   draw_set_rasterizer_state(softpipe->draw, rasterizer);
 
-   softpipe->rasterizer = (struct pipe_rasterizer_state *)setup;
+   softpipe->rasterizer = rasterizer;
 
    softpipe->dirty |= SP_NEW_RASTERIZER;
 }

commit 1befcd5a2ae8588f8d17d2ecea19dd4daccddb00
Author: José Fonseca <jfonseca@vmware.com>
Date:   Sat Dec 26 11:01:05 2009 +0000

    softpipe: Flush draw module before switching framebuffer.
    
    Otherwise geometry might end up in the wrong rendertarget.

diff --git a/src/gallium/drivers/softpipe/sp_state_surface.c b/src/gallium/drivers/softpipe/sp_state_surface.c
index 794a922..d29b6ae 100644
--- a/src/gallium/drivers/softpipe/sp_state_surface.c
+++ b/src/gallium/drivers/softpipe/sp_state_surface.c
@@ -48,6 +48,8 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe,
    struct softpipe_context *sp = softpipe_context(pipe);
    uint i;
 
+   draw_flush(sp->draw);
+
    for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
       /* check if changing cbuf */
       if (sp->framebuffer.cbufs[i] != fb->cbufs[i]) {

commit 12ba3559785fa276b3b4b6fa06cfe551b87aecc3
Author: José Fonseca <jfonseca@vmware.com>
Date:   Mon Nov 23 11:21:11 2009 +0000

    llvmpipe: Use assert instead of abort. Only verify functions on debug builds.

diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c
index b5aa7d6..7e019d4 100644
--- a/src/gallium/drivers/llvmpipe/lp_jit.c
+++ b/src/gallium/drivers/llvmpipe/lp_jit.c
@@ -166,7 +166,7 @@ lp_jit_screen_init(struct llvmpipe_screen *screen)
    if (LLVMCreateJITCompiler(&screen->engine, screen->provider, 1, &error)) {
       _debug_printf("%s\n", error);
       LLVMDisposeMessage(error);
-      abort();
+      assert(0);
    }
 
    screen->target = LLVMGetExecutionEngineTargetData(screen->engine);
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 48ec5e1..2b6965d 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -620,10 +620,12 @@ generate_fragment(struct llvmpipe_context *lp,
     * Translate the LLVM IR into machine code.
     */
 
+#ifdef DEBUG
    if(LLVMVerifyFunction(variant->function, LLVMPrintMessageAction)) {
       LLVMDumpValue(variant->function);
-      abort();
+      assert(0);
    }
+#endif
 
    LLVMRunFunctionPassManager(screen->pass, variant->function);
 

commit a0907a645f7d832e7c53d14c2ed88080b456a1a5
Author: José Fonseca <jfonseca@vmware.com>
Date:   Sun Nov 15 06:46:48 2009 -0800

    llvmpipe: Fix memory leak.

diff --git a/src/gallium/drivers/llvmpipe/lp_state_vs.c b/src/gallium/drivers/llvmpipe/lp_state_vs.c
index 0e9bc1d..884e387 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_vs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_vs.c
@@ -96,5 +96,6 @@ llvmpipe_delete_vs_state(struct pipe_context *pipe, void *vs)
       (struct lp_vertex_shader *)vs;
 
    draw_delete_vertex_shader(llvmpipe->draw, state->draw_data);
+   FREE( (void *)state->shader.tokens );
    FREE( state );
 }

commit 1acf7a09e762e6d8a26c8f0d919f5efa6df6e71f
Author: José Fonseca <jfonseca@vmware.com>
Date:   Tue Nov 10 17:52:53 2009 -0800

    llvmpipe: Use the generic conversion routine for depths.
    
    This allows for z32f depth format to work correctly.

diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 696657e..48ec5e1 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -147,6 +147,20 @@ generate_depth(LLVMBuilderRef builder,
    format_desc = util_format_description(key->zsbuf_format);
    assert(format_desc);
 
+   /*
+    * Depths are expected to be between 0 and 1, even if they are stored in
+    * floats. Setting these bits here will ensure that the lp_build_conv() call
+    * below won't try to unnecessarily clamp the incoming values.
+    */
+   if(src_type.floating) {
+      src_type.sign = FALSE;
+      src_type.norm = TRUE;
+   }
+   else {
+      assert(!src_type.sign);
+      assert(src_type.norm);
+   }
+
    /* Pick the depth type. */
    dst_type = lp_depth_type(format_desc, src_type.width*src_type.length);
 
@@ -154,14 +168,11 @@ generate_depth(LLVMBuilderRef builder,
    assert(dst_type.width == src_type.width);
    assert(dst_type.length == src_type.length);
 
-#if 1
-   src = lp_build_clamped_float_to_unsigned_norm(builder,
-                                                 src_type,
-                                                 dst_type.width,
-                                                 src);
-#else
    lp_build_conv(builder, src_type, dst_type, &src, 1, &src, 1);
-#endif
+
+   dst_ptr = LLVMBuildBitCast(builder,
+                              dst_ptr,
+                              LLVMPointerType(lp_build_vec_type(dst_type), 0), "");
 
    lp_build_depth_test(builder,
                        &key->depth,

commit 14dc02a1b2c52cf02b7f89885b61f42575834958
Author: José Fonseca <jfonseca@vmware.com>
Date:   Tue Nov 10 17:51:06 2009 -0800

    llvmpipe: Be more conservative with the supported formats.
    
    We'll likely support much more formats, but doing this allows to run
    more testsuites without immediately hit assertion failures.

diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
index 87fddbd..190dad0 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -27,6 +27,7 @@
 
 
 #include "util/u_memory.h"
+#include "util/u_format.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_screen.h"
 
@@ -149,17 +150,17 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen,
 {
    struct llvmpipe_screen *screen = llvmpipe_screen(_screen);
    struct llvmpipe_winsys *winsys = screen->winsys;
+   const struct util_format_description *format_desc;
+
+   format_desc = util_format_description(format);
+   if(!format_desc)
+      return FALSE;
 
    assert(target == PIPE_TEXTURE_1D ||
           target == PIPE_TEXTURE_2D ||
           target == PIPE_TEXTURE_3D ||
           target == PIPE_TEXTURE_CUBE);
 
-   if(format == PIPE_FORMAT_Z16_UNORM)
-      return FALSE;
-   if(format == PIPE_FORMAT_S8_UNORM)
-      return FALSE;
-
    switch(format) {
    case PIPE_FORMAT_DXT1_RGB:
    case PIPE_FORMAT_DXT1_RGBA:
@@ -170,8 +171,51 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen,
       break;
    }
 
-   if(tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET)
-      return winsys->is_displaytarget_format_supported(winsys, format);
+   if(tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) {
+      if(format_desc->block.width != 1 ||
+         format_desc->block.height != 1)
+         return FALSE;
+
+      if(format_desc->layout != UTIL_FORMAT_LAYOUT_SCALAR &&
+         format_desc->layout != UTIL_FORMAT_LAYOUT_ARITH &&
+         format_desc->layout != UTIL_FORMAT_LAYOUT_ARRAY)
+         return FALSE;
+
+      if(format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB &&
+         format_desc->colorspace != UTIL_FORMAT_COLORSPACE_SRGB)
+         return FALSE;
+   }
+
+   if(tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) {
+      if(!winsys->is_displaytarget_format_supported(winsys, format))
+         return FALSE;
+   }
+
+   if(tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) {
+      if(format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS)
+         return FALSE;
+
+      /* FIXME: Temporary restriction. See lp_state_fs.c. */
+      if(format_desc->block.bits != 32)
+         return FALSE;
+   }
+
+   /* FIXME: Temporary restrictions. See lp_bld_sample_soa.c */
+   if(tex_usage & PIPE_TEXTURE_USAGE_SAMPLER) {
+      if(format_desc->block.width != 1 ||
+         format_desc->block.height != 1)
+         return FALSE;
+
+      if(format_desc->layout != UTIL_FORMAT_LAYOUT_SCALAR &&
+         format_desc->layout != UTIL_FORMAT_LAYOUT_ARITH &&
+         format_desc->layout != UTIL_FORMAT_LAYOUT_ARRAY)
+         return FALSE;
+
+      if(format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB &&
+         format_desc->colorspace != UTIL_FORMAT_COLORSPACE_SRGB &&
+         format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS)
+         return FALSE;
+   }
 
    return TRUE;
 }

commit 88cf87bd5633c0e8155e4226fc49ab36f1abc335
Author: José Fonseca <jfonseca@vmware.com>
Date:   Mon Dec 28 22:52:41 2009 +0000

    llvmpipe: Unmapping vertex/index buffers does NOT flush draw module anymore.
    
    Not since 6094e79f4e3350d123c7532b1c73faa60834a62d.
    
    Drivers now need to flush draw module explicitely (which explains why
    all those previous commits adding draw_flushes calls were necessary).
    
    This is a good thing, but it's tricky to get this right in face of user buffers
    (it's not even clear who has the responsibility to flush when a user buffer
    is seen -- statetracker or pipe driver), so just force flush (temporarily)
    since it's not a bottleneck now.

diff --git a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
index a43e438..e539e71 100644
--- a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
+++ b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
@@ -101,7 +101,7 @@ llvmpipe_draw_range_elements(struct pipe_context *pipe,
    draw_arrays(draw, mode, start, count);
 
    /*
-    * unmap vertex/index buffers - will cause draw module to flush
+    * unmap vertex/index buffers
     */
    for (i = 0; i < lp->num_vertex_buffers; i++) {
       draw_set_mapped_vertex_buffer(draw, i, NULL);
@@ -110,6 +110,12 @@ llvmpipe_draw_range_elements(struct pipe_context *pipe,
       draw_set_mapped_element_buffer(draw, 0, NULL);
    }
 
+   /*
+    * TODO: Flush only when a user vertex/index buffer is present
+    * (or even better, modify draw module to do this
+    * internally when this condition is seen?)
+    */
+   draw_flush(draw);
 
    /* Note: leave drawing surfaces mapped */
 

commit 31b3420688dbf7fc2282f0d1fe13e51fe9e1f9b6
Author: José Fonseca <jfonseca@vmware.com>
Date:   Sat Dec 26 15:21:16 2009 +0000

    llvmpipe: Treat state changes systematically.
    
    That is:
    - check for no op
    - update/flush draw module
    - update bound state and mark it as dirty
    
    In particular flushing the draw module is important since it may contain
    unflushed primitives which would otherwise be draw with wrong state.

diff --git a/src/gallium/drivers/llvmpipe/lp_state_blend.c b/src/gallium/drivers/llvmpipe/lp_state_blend.c
index b2e75d3..a94cd05 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_blend.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_blend.c
@@ -34,6 +34,7 @@
 #include "util/u_memory.h"
 #include "util/u_math.h"
 #include "util/u_debug_dump.h"
+#include "draw/draw_context.h"
 #include "lp_screen.h"
 #include "lp_context.h"
 #include "lp_state.h"
@@ -51,6 +52,11 @@ void llvmpipe_bind_blend_state( struct pipe_context *pipe,
 {
    struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
 
+   if (llvmpipe->blend == blend)
+      return;
+
+   draw_flush(llvmpipe->draw);
+
    llvmpipe->blend = blend;
 
    llvmpipe->dirty |= LP_NEW_BLEND;
@@ -69,6 +75,11 @@ void llvmpipe_set_blend_color( struct pipe_context *pipe,
    struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
    unsigned i, j;
 
+   if(memcmp(&llvmpipe->blend_color, blend_color, sizeof *blend_color) == 0)
+      return;
+
+   draw_flush(llvmpipe->draw);
+
    memcpy(&llvmpipe->blend_color, blend_color, sizeof *blend_color);
 
    if(!llvmpipe->jit_context.blend_color)
@@ -99,7 +110,12 @@ llvmpipe_bind_depth_stencil_state(struct pipe_context *pipe,
 {
    struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
 
-   llvmpipe->depth_stencil = (const struct pipe_depth_stencil_alpha_state *)depth_stencil;
+   if (llvmpipe->depth_stencil == depth_stencil)
+      return;
+
+   draw_flush(llvmpipe->draw);
+
+   llvmpipe->depth_stencil = depth_stencil;
 
    if(llvmpipe->depth_stencil)
       llvmpipe->jit_context.alpha_ref_value = llvmpipe->depth_stencil->alpha.ref_value;
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 45a1ca8..696657e 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -658,7 +658,12 @@ llvmpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
 {
    struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
 
-   llvmpipe->fs = (struct lp_fragment_shader *) fs;
+   if (llvmpipe->fs == fs)
+      return;
+
+   draw_flush(llvmpipe->draw);
+
+   llvmpipe->fs = fs;
 
    llvmpipe->dirty |= LP_NEW_FS;
 }
@@ -709,8 +714,7 @@ llvmpipe_set_constant_buffer(struct pipe_context *pipe,
    assert(shader < PIPE_SHADER_TYPES);
    assert(index == 0);
 
-   if(shader == PIPE_SHADER_VERTEX)
-      draw_flush(llvmpipe->draw);
+   draw_flush(llvmpipe->draw);
 
    /* note: reference counting */
    pipe_buffer_reference(&llvmpipe->constants[shader].buffer, buffer);
diff --git a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
index 4561c6b..aa3b5a3 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
@@ -41,14 +41,17 @@ llvmpipe_create_rasterizer_state(struct pipe_context *pipe,
 }
 
 void llvmpipe_bind_rasterizer_state(struct pipe_context *pipe,
-                                    void *setup)
+                                    void *rasterizer)
 {
    struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
 
+   if (llvmpipe->rasterizer == rasterizer)
+      return;
+
    /* pass-through to draw module */
-   draw_set_rasterizer_state(llvmpipe->draw, setup);
+   draw_set_rasterizer_state(llvmpipe->draw, rasterizer);
 
-   llvmpipe->rasterizer = (struct pipe_rasterizer_state *)setup;
+   llvmpipe->rasterizer = rasterizer;
 
    llvmpipe->dirty |= LP_NEW_RASTERIZER;
 }
diff --git a/src/gallium/drivers/llvmpipe/lp_state_vs.c b/src/gallium/drivers/llvmpipe/lp_state_vs.c
index 15c3029..0e9bc1d 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_vs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_vs.c
@@ -70,14 +70,18 @@ fail:
 
 
 void
-llvmpipe_bind_vs_state(struct pipe_context *pipe, void *vs)
+llvmpipe_bind_vs_state(struct pipe_context *pipe, void *_vs)
 {
    struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
+   const struct lp_vertex_shader *vs = (const struct lp_vertex_shader *)_vs;
 
-   llvmpipe->vs = (const struct lp_vertex_shader *)vs;
+   if (llvmpipe->vs == vs)
+      return;
 
-   draw_bind_vertex_shader(llvmpipe->draw,
-                           (llvmpipe->vs ? llvmpipe->vs->draw_data : NULL));
+   draw_bind_vertex_shader(llvmpipe->draw, 
+                           vs ? vs->draw_data : NULL);
+
+   llvmpipe->vs = vs;
 
    llvmpipe->dirty |= LP_NEW_VS;
 }

commit 4e95983fa832cf0808ccab64e9fbfb0fcdde8049
Author: José Fonseca <jfonseca@vmware.com>
Date:   Sat Dec 26 11:00:42 2009 +0000

    llvmpipe: Flush draw module before switching framebuffer.
    
    Otherwise geometry will end up in the wrong rendertarget.

diff --git a/src/gallium/drivers/llvmpipe/lp_state_surface.c b/src/gallium/drivers/llvmpipe/lp_state_surface.c
index 9f74585..4eb4597 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_surface.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_surface.c
@@ -48,6 +48,8 @@ llvmpipe_set_framebuffer_state(struct pipe_context *pipe,
    struct llvmpipe_context *lp = llvmpipe_context(pipe);
    uint i;
 
+   draw_flush(lp->draw);
+
    for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
       /* check if changing cbuf */
       if (lp->framebuffer.cbufs[i] != fb->cbufs[i]) {

commit 4e506eac8f11a23249a46265b796c4764d9d045e
Author: José Fonseca <jfonseca@vmware.com>
Date:   Wed Dec 16 15:06:02 2009 +0000

    llvmpipe: add LP_DEBUG env var
    
    Cherry-picked from dec35d04aeb398eef159aaf8cde5e0d04622b811.

diff --git a/src/gallium/drivers/llvmpipe/lp_debug.h b/src/gallium/drivers/llvmpipe/lp_debug.h
new file mode 100644
index 0000000..74b2757
--- /dev/null
+++ b/src/gallium/drivers/llvmpipe/lp_debug.h
@@ -0,0 +1,71 @@
+/**************************************************************************
+ * 
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **************************************************************************/
+
+
+#ifndef LP_DEBUG_H
+#define LP_DEBUG_H
+
+#include "pipe/p_compiler.h"
+#include "util/u_debug.h"
+
+extern void
+st_print_current(void);
+
+
+#define DEBUG_PIPE      0x1
+#define DEBUG_TGSI      0x2
+#define DEBUG_TEX       0x4
+#define DEBUG_ASM       0x8
+#define DEBUG_SETUP     0x10
+#define DEBUG_RAST      0x20
+#define DEBUG_QUERY     0x40
+#define DEBUG_SCREEN    0x80
+#define DEBUG_JIT       0x100
+
+#ifdef DEBUG
+extern int LP_DEBUG;
+#else
+#define LP_DEBUG 0
+#endif
+


Reply to: