lp_build_blend_aos(LLVMBuilderRef builder,
const struct pipe_blend_state *blend,
struct lp_type type,
+ unsigned rt,
LLVMValueRef src,
LLVMValueRef dst,
LLVMValueRef const_,
lp_build_blend_soa(LLVMBuilderRef builder,
const struct pipe_blend_state *blend,
struct lp_type type,
+ unsigned rt,
LLVMValueRef src[4],
LLVMValueRef dst[4],
LLVMValueRef const_[4],
lp_build_blend_aos(LLVMBuilderRef builder,
const struct pipe_blend_state *blend,
struct lp_type type,
+ unsigned rt,
LLVMValueRef src,
LLVMValueRef dst,
LLVMValueRef const_,
LLVMValueRef src_term;
LLVMValueRef dst_term;
- /* FIXME */
- assert(blend->independent_blend_enable == 0);
- assert(blend->rt[0].colormask == 0xf);
+ /* FIXME: color masking not implemented yet */
+ assert(blend->rt[rt].colormask == 0xf);
- if(!blend->rt[0].blend_enable)
+ if(!blend->rt[rt].blend_enable)
return src;
/* It makes no sense to blend unless values are normalized */
* combinations it is possible to reorder the operations and therefore saving
* some instructions. */
- src_term = lp_build_blend_factor(&bld, src, blend->rt[0].rgb_src_factor,
- blend->rt[0].alpha_src_factor, alpha_swizzle);
- dst_term = lp_build_blend_factor(&bld, dst, blend->rt[0].rgb_dst_factor,
- blend->rt[0].alpha_dst_factor, alpha_swizzle);
+ src_term = lp_build_blend_factor(&bld, src, blend->rt[rt].rgb_src_factor,
+ blend->rt[rt].alpha_src_factor, alpha_swizzle);
+ dst_term = lp_build_blend_factor(&bld, dst, blend->rt[rt].rgb_dst_factor,
+ blend->rt[rt].alpha_dst_factor, alpha_swizzle);
lp_build_name(src_term, "src_term");
lp_build_name(dst_term, "dst_term");
- if(blend->rt[0].rgb_func == blend->rt[0].alpha_func) {
- return lp_build_blend_func(&bld.base, blend->rt[0].rgb_func, src_term, dst_term);
+ if(blend->rt[rt].rgb_func == blend->rt[rt].alpha_func) {
+ return lp_build_blend_func(&bld.base, blend->rt[rt].rgb_func, src_term, dst_term);
}
else {
/* Seperate RGB / A functions */
LLVMValueRef rgb;
LLVMValueRef alpha;
- rgb = lp_build_blend_func(&bld.base, blend->rt[0].rgb_func, src_term, dst_term);
- alpha = lp_build_blend_func(&bld.base, blend->rt[0].alpha_func, src_term, dst_term);
+ rgb = lp_build_blend_func(&bld.base, blend->rt[rt].rgb_func, src_term, dst_term);
+ alpha = lp_build_blend_func(&bld.base, blend->rt[rt].alpha_func, src_term, dst_term);
return lp_build_blend_swizzle(&bld, rgb, alpha, LP_BUILD_BLEND_SWIZZLE_RGBA, alpha_swizzle);
}
/**
* Generate blend code in SOA mode.
+ * \param rt render target index (to index the blend / colormask state)
* \param src src/fragment color
* \param dst dst/framebuffer color
* \param con constant blend color
lp_build_blend_soa(LLVMBuilderRef builder,
const struct pipe_blend_state *blend,
struct lp_type type,
+ unsigned rt,
LLVMValueRef src[4],
LLVMValueRef dst[4],
LLVMValueRef con[4],
struct lp_build_blend_soa_context bld;
unsigned i, j, k;
+ assert(rt < PIPE_MAX_COLOR_BUFS);
+
/* Setup build context */
memset(&bld, 0, sizeof bld);
lp_build_context_init(&bld.base, builder, type);
for (i = 0; i < 4; ++i) {
/* only compute blending for the color channels enabled for writing */
- if (blend->rt[0].colormask & (1 << i)) {
+ if (blend->rt[rt].colormask & (1 << i)) {
if (blend->logicop_enable) {
if(!type.floating) {
res[i] = lp_build_logicop(builder, blend->logicop_func, src[i], dst[i]);
else
res[i] = dst[i];
}
- else if (blend->rt[0].blend_enable) {
- unsigned src_factor = i < 3 ? blend->rt[0].rgb_src_factor : blend->rt[0].alpha_src_factor;
- unsigned dst_factor = i < 3 ? blend->rt[0].rgb_dst_factor : blend->rt[0].alpha_dst_factor;
- unsigned func = i < 3 ? blend->rt[0].rgb_func : blend->rt[0].alpha_func;
+ else if (blend->rt[rt].blend_enable) {
+ unsigned src_factor = i < 3 ? blend->rt[rt].rgb_src_factor : blend->rt[rt].alpha_src_factor;
+ unsigned dst_factor = i < 3 ? blend->rt[rt].rgb_dst_factor : blend->rt[rt].alpha_dst_factor;
+ unsigned func = i < 3 ? blend->rt[rt].rgb_func : blend->rt[rt].alpha_func;
boolean func_commutative = lp_build_blend_func_commutative(func);
/* It makes no sense to blend unless values are normalized */
/* See if this function has been previously applied */
for(j = 0; j < i; ++j) {
- unsigned prev_func = j < 3 ? blend->rt[0].rgb_func : blend->rt[0].alpha_func;
+ unsigned prev_func = j < 3 ? blend->rt[rt].rgb_func : blend->rt[rt].alpha_func;
unsigned func_reverse = lp_build_blend_func_reverse(func, prev_func);
if((!func_reverse &&
consts_ptr, interp->pos, interp->inputs,
outputs, sampler, &shader->info);
+ /* loop over fragment shader outputs/results */
for (attrib = 0; attrib < shader->info.num_outputs; ++attrib) {
for(chan = 0; chan < NUM_CHANNELS; ++chan) {
if(outputs[attrib][chan]) {
/**
* Generate color blending and color output.
+ * \param rt the render target index (to index blend, colormask state)
+ * \param type the pixel color type
+ * \param context_ptr pointer to the runtime JIT context
+ * \param mask execution mask (active fragment/pixel mask)
+ * \param src colors from the fragment shader
+ * \param dst_ptr the destination color buffer pointer
*/
static void
generate_blend(const struct pipe_blend_state *blend,
+ unsigned rt,
LLVMBuilderRef builder,
struct lp_type type,
LLVMValueRef context_ptr,
const_ptr = LLVMBuildBitCast(builder, const_ptr,
LLVMPointerType(vec_type, 0), "");
+ /* load constant blend color and colors from the dest color buffer */
for(chan = 0; chan < 4; ++chan) {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), chan, 0);
con[chan] = LLVMBuildLoad(builder, LLVMBuildGEP(builder, const_ptr, &index, 1, ""), "");
lp_build_name(dst[chan], "dst.%c", "rgba"[chan]);
}
- lp_build_blend_soa(builder, blend, type, src, dst, con, res);
+ /* do blend */
+ lp_build_blend_soa(builder, blend, type, rt, src, dst, con, res);
+ /* store results to color buffer */
for(chan = 0; chan < 4; ++chan) {
- if(blend->rt[0].colormask & (1 << chan)) {
+ if(blend->rt[rt].colormask & (1 << chan)) {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), chan, 0);
lp_build_name(res[chan], "res.%c", "rgba"[chan]);
res[chan] = lp_build_select(&bld, mask, res[chan], dst[chan]);
LLVMValueRef fs_mask[LP_MAX_VECTOR_LENGTH];
LLVMValueRef fs_out_color[PIPE_MAX_COLOR_BUFS][NUM_CHANNELS][LP_MAX_VECTOR_LENGTH];
LLVMValueRef blend_mask;
- LLVMValueRef blend_in_color[NUM_CHANNELS];
LLVMValueRef function;
LLVMValueRef facing;
unsigned num_fs;
lp_build_name(a0_ptr, "a0");
lp_build_name(dadx_ptr, "dadx");
lp_build_name(dady_ptr, "dady");
- lp_build_name(color_ptr_ptr, "color_ptr");
+ lp_build_name(color_ptr_ptr, "color_ptr_ptr");
lp_build_name(depth_ptr, "depth");
lp_build_name(c0, "c0");
lp_build_name(c1, "c1");
for(cbuf = 0; cbuf < key->nr_cbufs; cbuf++) {
LLVMValueRef color_ptr;
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), cbuf, 0);
+ LLVMValueRef blend_in_color[NUM_CHANNELS];
+ unsigned rt;
/*
* Convert the fs's output color and mask to fit to the blending type.
"");
lp_build_name(color_ptr, "color_ptr%d", cbuf);
+ /* which blend/colormask state to use */
+ rt = key->blend.independent_blend_enable ? cbuf : 0;
+
/*
* Blending.
*/
generate_blend(&key->blend,
+ rt,
builder,
blend_type,
context_ptr,
LLVMValueRef res_ptr;
LLVMBasicBlockRef block;
LLVMBuilderRef builder;
+ const unsigned rt = 0;
vec_type = lp_build_vec_type(type);
dst = LLVMBuildLoad(builder, dst_ptr, "dst");
con = LLVMBuildLoad(builder, const_ptr, "const");
- res = lp_build_blend_aos(builder, blend, type, src, dst, con, 3);
+ res = lp_build_blend_aos(builder, blend, type, rt, src, dst, con, 3);
lp_build_name(res, "res");
lp_build_name(dst[i], "dst.%c", "rgba"[i]);
}
- lp_build_blend_soa(builder, blend, type, src, dst, con, res);
+ lp_build_blend_soa(builder, blend, type, rt, src, dst, con, res);
for(i = 0; i < 4; ++i) {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);