#include "program/prog_instruction.h"
#include "program/prog_statevars.h"
#include "util/bitscan.h"
+#include "builtin_functions.h"
+#include "main/mtypes.h"
using namespace ir_builder;
f.emit(assign(dst_alpha, swizzle_w(fb)));
f.emit(if_tree(equal(dst_alpha, imm1(0)),
assign(dst_rgb, imm3(0)),
- assign(dst_rgb, div(swizzle_xyz(fb), dst_alpha))));
+ assign(dst_rgb, csel(equal(swizzle_xyz(fb),
+ swizzle(fb, SWIZZLE_WWWW, 3)),
+ imm3(1),
+ div(swizzle_xyz(fb), dst_alpha)))));
f.emit(assign(src_alpha, swizzle_w(src)));
f.emit(if_tree(equal(src_alpha, imm1(0)),
assign(src_rgb, imm3(0)),
- assign(src_rgb, div(swizzle_xyz(src), src_alpha))));
+ assign(src_rgb, csel(equal(swizzle_xyz(src),
+ swizzle(src, SWIZZLE_WWWW, 3)),
+ imm3(1),
+ div(swizzle_xyz(src), src_alpha)))));
ir_variable *factor = f.make_temp(glsl_type::vec3_type, "__blend_factor");
}
bool
-lower_blend_equation_advanced(struct gl_linked_shader *sh)
+lower_blend_equation_advanced(struct gl_linked_shader *sh, bool coherent)
{
- if (sh->info.BlendSupport == 0)
+ if (sh->Program->sh.fs.BlendSupport == 0)
return false;
/* Lower early returns in main() so there's a single exit point
fb->data.location = FRAG_RESULT_DATA0;
fb->data.read_only = 1;
fb->data.fb_fetch_output = 1;
+ fb->data.memory_coherent = coherent;
fb->data.how_declared = ir_var_hidden;
ir_variable *mode = new(mem_ctx) ir_variable(glsl_type::uint_type,
ir_factory f(&main->body, mem_ctx);
ir_variable *result_dest =
- calc_blend_result(f, mode, fb, blend_source, sh->info.BlendSupport);
+ calc_blend_result(f, mode, fb, blend_source,
+ sh->Program->sh.fs.BlendSupport);
/* Copy the result back to the original values. It would be simpler
* to demote the program's output variables, and create a new vec4