llvmpipe: remove unneeded draw_flush() call
[mesa.git] / src / gallium / drivers / llvmpipe / lp_state_fs.c
index 758dcef328f9d11f7634995de9f12f6aabbacfe8..5a8351bff678ed54dd42e9739a0c7fd82a8179c9 100644 (file)
@@ -1075,10 +1075,10 @@ convert_to_blend_type(struct gallivm_state *gallivm,
                       const struct util_format_description *src_fmt,
                       struct lp_type src_type,
                       struct lp_type dst_type,
-                      LLVMValueRef* src,
-                      unsigned num_srcs,
-                      LLVMValueRef* dst)
+                      LLVMValueRef* src, // and dst
+                      unsigned num_srcs)
 {
+   LLVMValueRef *dst = src;
    LLVMBuilderRef builder = gallivm->builder;
    struct lp_type blend_type;
    struct lp_type mem_type;
@@ -1086,8 +1086,6 @@ convert_to_blend_type(struct gallivm_state *gallivm,
    unsigned pixels = 16 / num_srcs;
    bool is_arith;
 
-   memcpy(dst, src, sizeof(LLVMValueRef) * num_srcs);
-
    lp_mem_type_from_format_desc(src_fmt, &mem_type);
    lp_blend_type_from_format_desc(src_fmt, &blend_type);
 
@@ -1177,10 +1175,10 @@ convert_from_blend_type(struct gallivm_state *gallivm,
                         const struct util_format_description *src_fmt,
                         struct lp_type src_type,
                         struct lp_type dst_type,
-                        LLVMValueRef* src,
-                        unsigned num_srcs,
-                        LLVMValueRef* dst)
+                        LLVMValueRef* src, // and dst
+                        unsigned num_srcs)
 {
+   LLVMValueRef* dst = src;
    unsigned i, j, k;
    struct lp_type mem_type;
    struct lp_type blend_type;
@@ -1188,8 +1186,6 @@ convert_from_blend_type(struct gallivm_state *gallivm,
    unsigned pixels = 16 / num_srcs;
    bool is_arith;
 
-   memcpy(dst, src, sizeof(LLVMValueRef) * num_srcs);
-
    lp_mem_type_from_format_desc(src_fmt, &mem_type);
    lp_blend_type_from_format_desc(src_fmt, &blend_type);
 
@@ -1341,7 +1337,12 @@ generate_unswizzled_blend(struct gallivm_state *gallivm,
    mask_type.length = fs_type.length;
 
    /* Compute the alignment of the destination pointer in bytes */
+#if 0
    dst_alignment = (block_width * out_format_desc->block.bits + 7)/(out_format_desc->block.width * 8);
+#else
+   /* FIXME -- currently we're fetching pixels one by one, instead of row by row */
+   dst_alignment = (1 * out_format_desc->block.bits + 7)/(out_format_desc->block.width * 8);
+#endif
    /* Force power-of-two alignment by extracting only the least-significant-bit */
    dst_alignment = 1 << (ffs(dst_alignment) - 1);
    /* Resource base and stride pointers are aligned to 16 bytes, so that's the maximum alignment we can guarantee */
@@ -1644,7 +1645,7 @@ generate_unswizzled_blend(struct gallivm_state *gallivm,
    /*
     * Blending
     */
-   convert_to_blend_type(gallivm, out_format_desc, dst_type, row_type, dst, src_count, dst);
+   convert_to_blend_type(gallivm, out_format_desc, dst_type, row_type, dst, src_count);
 
    for (i = 0; i < src_count; ++i) {
       dst[i] = lp_build_blend_aos(gallivm,
@@ -1662,7 +1663,7 @@ generate_unswizzled_blend(struct gallivm_state *gallivm,
                                   pad_inline ? 4 : dst_channels);
    }
 
-   convert_from_blend_type(gallivm, out_format_desc, row_type, dst_type, dst, src_count, dst);
+   convert_from_blend_type(gallivm, out_format_desc, row_type, dst_type, dst, src_count);
 
    /* Split the blend rows back to memory rows */
    if (dst_count > src_count) {
@@ -2311,8 +2312,6 @@ llvmpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
    if (llvmpipe->fs == fs)
       return;
 
-   draw_flush(llvmpipe->draw);
-
    llvmpipe->fs = (struct lp_fragment_shader *) fs;
 
    draw_bind_fragment_shader(llvmpipe->draw,
@@ -2407,32 +2406,32 @@ llvmpipe_set_constant_buffer(struct pipe_context *pipe,
 {
    struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
    struct pipe_resource *constants = cb ? cb->buffer : NULL;
-   unsigned size;
-   const void *data;
-
-   if (cb && cb->user_buffer) {
-      constants = llvmpipe_user_buffer_create(pipe->screen,
-                                              (void *) cb->user_buffer,
-                                              cb->buffer_size,
-                                              PIPE_BIND_CONSTANT_BUFFER);
-   }
-
-   size = constants ? constants->width0 : 0;
-   data = constants ? llvmpipe_resource_data(constants) : NULL;
 
    assert(shader < PIPE_SHADER_TYPES);
-   assert(index < PIPE_MAX_CONSTANT_BUFFERS);
+   assert(index < Elements(llvmpipe->constants[shader]));
 
-   if(llvmpipe->constants[shader][index] == constants)
-      return;
+   /* note: reference counting */
+   util_copy_constant_buffer(&llvmpipe->constants[shader][index], cb);
 
-   draw_flush(llvmpipe->draw);
+   if (shader == PIPE_SHADER_VERTEX ||
+       shader == PIPE_SHADER_GEOMETRY) {
+      /* Pass the constants to the 'draw' module */
+      const unsigned size = cb ? cb->buffer_size : 0;
+      const ubyte *data;
 
-   /* note: reference counting */
-   pipe_resource_reference(&llvmpipe->constants[shader][index], constants);
+      if (constants) {
+         data = (ubyte *) llvmpipe_resource_data(constants);
+      }
+      else if (cb && cb->user_buffer) {
+         data = (ubyte *) cb->user_buffer;
+      }
+      else {
+         data = NULL;
+      }
+
+      if (data)
+         data += cb->buffer_offset;
 
-   if(shader == PIPE_SHADER_VERTEX ||
-      shader == PIPE_SHADER_GEOMETRY) {
       draw_set_mapped_constant_buffer(llvmpipe->draw, shader,
                                       index, data, size);
    }
@@ -2497,7 +2496,7 @@ make_variant_key(struct llvmpipe_context *lp,
    /* alpha.ref_value is passed in jit_context */
 
    key->flatshade = lp->rasterizer->flatshade;
-   if (lp->active_query_count) {
+   if (lp->active_occlusion_query) {
       key->occlusion_count = TRUE;
    }