diff options
Diffstat (limited to 'src/gallium/drivers/llvmpipe')
-rw-r--r-- | src/gallium/drivers/llvmpipe/.gitignore | 4 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_jit.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_scene.c | 1 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_setup.c | 1 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_fs.c | 55 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_surface.c | 1 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_surface.c | 1 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_tex_sample.c | 11 |
8 files changed, 68 insertions, 10 deletions
diff --git a/src/gallium/drivers/llvmpipe/.gitignore b/src/gallium/drivers/llvmpipe/.gitignore index 257b72d7b2b..a1b6f56e0d2 100644 --- a/src/gallium/drivers/llvmpipe/.gitignore +++ b/src/gallium/drivers/llvmpipe/.gitignore @@ -1 +1,5 @@ lp_tile_soa.c +lp_test_blend +lp_test_conv +lp_test_format +lp_test_printf diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index 466a2f54fbe..30e206a2b42 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -185,6 +185,8 @@ lp_jit_screen_init(struct llvmpipe_screen *screen) /* These are the passes currently listed in llvm-c/Transforms/Scalar.h, * but there are more on SVN. */ /* TODO: Add more passes */ + LLVMAddCFGSimplificationPass(screen->pass); + LLVMAddPromoteMemoryToRegisterPass(screen->pass); LLVMAddConstantPropagationPass(screen->pass); if(util_cpu_caps.has_sse4_1) { /* FIXME: There is a bug in this pass, whereby the combination of fptosi @@ -193,9 +195,7 @@ lp_jit_screen_init(struct llvmpipe_screen *screen) */ LLVMAddInstructionCombiningPass(screen->pass); } - LLVMAddPromoteMemoryToRegisterPass(screen->pass); LLVMAddGVNPass(screen->pass); - LLVMAddCFGSimplificationPass(screen->pass); } lp_jit_init_globals(screen); diff --git a/src/gallium/drivers/llvmpipe/lp_scene.c b/src/gallium/drivers/llvmpipe/lp_scene.c index 1482a777ff8..887f2dbad91 100644 --- a/src/gallium/drivers/llvmpipe/lp_scene.c +++ b/src/gallium/drivers/llvmpipe/lp_scene.c @@ -25,6 +25,7 @@ * **************************************************************************/ +#include "util/u_framebuffer.h" #include "util/u_math.h" #include "util/u_memory.h" #include "util/u_inlines.h" diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 21509560084..1a2cd55b164 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -33,6 +33,7 @@ */ #include "pipe/p_defines.h" +#include "util/u_framebuffer.h" #include "util/u_inlines.h" #include "util/u_memory.h" #include "util/u_pack_color.h" diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 965777b6411..5f861d6ca4d 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -618,7 +618,6 @@ generate_fragment(struct llvmpipe_context *lp, struct lp_type fs_type; struct lp_type blend_type; LLVMTypeRef fs_elem_type; - LLVMTypeRef fs_vec_type; LLVMTypeRef fs_int_vec_type; LLVMTypeRef blend_vec_type; LLVMTypeRef arg_types[15]; @@ -675,7 +674,6 @@ generate_fragment(struct llvmpipe_context *lp, */ fs_elem_type = lp_build_elem_type(fs_type); - fs_vec_type = lp_build_vec_type(fs_type); fs_int_vec_type = lp_build_int_vec_type(fs_type); blend_vec_type = lp_build_vec_type(blend_type); @@ -1064,6 +1062,34 @@ llvmpipe_set_constant_buffer(struct pipe_context *pipe, /** + * Return the blend factor equivalent to a destination alpha of one. + */ +static INLINE unsigned +force_dst_alpha_one(unsigned factor, boolean alpha) +{ + switch(factor) { + case PIPE_BLENDFACTOR_DST_ALPHA: + return PIPE_BLENDFACTOR_ONE; + case PIPE_BLENDFACTOR_INV_DST_ALPHA: + return PIPE_BLENDFACTOR_ZERO; + case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE: + return PIPE_BLENDFACTOR_ZERO; + } + + if (alpha) { + switch(factor) { + case PIPE_BLENDFACTOR_DST_COLOR: + return PIPE_BLENDFACTOR_ONE; + case PIPE_BLENDFACTOR_INV_DST_COLOR: + return PIPE_BLENDFACTOR_ZERO; + } + } + + return factor; +} + + +/** * We need to generate several variants of the fragment pipeline to match * all the combinations of the contributing state atoms. * @@ -1104,6 +1130,7 @@ make_variant_key(struct llvmpipe_context *lp, key->nr_cbufs = lp->framebuffer.nr_cbufs; for (i = 0; i < lp->framebuffer.nr_cbufs; i++) { + struct pipe_rt_blend_state *blend_rt = &key->blend.rt[i]; const struct util_format_description *format_desc; unsigned chan; @@ -1111,7 +1138,7 @@ make_variant_key(struct llvmpipe_context *lp, assert(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB || format_desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB); - key->blend.rt[i].colormask = lp->blend->rt[i].colormask; + blend_rt->colormask = lp->blend->rt[i].colormask; /* mask out color channels not present in the color buffer. * Should be simple to incorporate per-cbuf writemasks: @@ -1120,7 +1147,27 @@ make_variant_key(struct llvmpipe_context *lp, enum util_format_swizzle swizzle = format_desc->swizzle[chan]; if(swizzle > UTIL_FORMAT_SWIZZLE_W) - key->blend.rt[i].colormask &= ~(1 << chan); + blend_rt->colormask &= ~(1 << chan); + } + + /* + * Our swizzled render tiles always have an alpha channel, but the linear + * render target format often does not, so force here the dst alpha to be + * one. + * + * This is not a mere optimization. Wrong results will be produced if the + * dst alpha is used, the dst format does not have alpha, and the previous + * rendering was not flushed from the swizzled to linear buffer. For + * example, NonPowTwo DCT. + * + * TODO: This should be generalized to all channels for better + * performance, but only alpha causes correctness issues. + */ + if (format_desc->swizzle[3] > UTIL_FORMAT_SWIZZLE_W) { + blend_rt->rgb_src_factor = force_dst_alpha_one(blend_rt->rgb_src_factor, FALSE); + blend_rt->rgb_dst_factor = force_dst_alpha_one(blend_rt->rgb_dst_factor, FALSE); + blend_rt->alpha_src_factor = force_dst_alpha_one(blend_rt->alpha_src_factor, TRUE); + blend_rt->alpha_dst_factor = force_dst_alpha_one(blend_rt->alpha_dst_factor, TRUE); } } diff --git a/src/gallium/drivers/llvmpipe/lp_state_surface.c b/src/gallium/drivers/llvmpipe/lp_state_surface.c index 63b8f27b39c..4b135aaf8ba 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_surface.c +++ b/src/gallium/drivers/llvmpipe/lp_state_surface.c @@ -30,6 +30,7 @@ #include "pipe/p_state.h" #include "util/u_inlines.h" +#include "util/u_framebuffer.h" #include "util/u_surface.h" #include "lp_context.h" #include "lp_scene.h" diff --git a/src/gallium/drivers/llvmpipe/lp_surface.c b/src/gallium/drivers/llvmpipe/lp_surface.c index 8bd83f576f4..245171120dd 100644 --- a/src/gallium/drivers/llvmpipe/lp_surface.c +++ b/src/gallium/drivers/llvmpipe/lp_surface.c @@ -26,6 +26,7 @@ **************************************************************************/ #include "util/u_rect.h" +#include "util/u_surface.h" #include "lp_context.h" #include "lp_flush.h" #include "lp_limits.h" diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample.c b/src/gallium/drivers/llvmpipe/lp_tex_sample.c index 74b7393e4ec..d3a9d39f616 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample.c +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample.c @@ -170,7 +170,10 @@ lp_llvm_sampler_soa_emit_fetch_texel(struct lp_build_sampler_soa *base, unsigned unit, unsigned num_coords, const LLVMValueRef *coords, - LLVMValueRef lodbias, + const LLVMValueRef *ddx, + const LLVMValueRef *ddy, + LLVMValueRef lod_bias, /* optional */ + LLVMValueRef explicit_lod, /* optional */ LLVMValueRef *texel) { struct lp_llvm_sampler_soa *sampler = (struct lp_llvm_sampler_soa *)base; @@ -182,9 +185,9 @@ lp_llvm_sampler_soa_emit_fetch_texel(struct lp_build_sampler_soa *base, &sampler->dynamic_state.base, type, unit, - num_coords, - coords, - lodbias, + num_coords, coords, + ddx, ddy, + lod_bias, explicit_lod, texel); } |