/* Create the blend variables */
nir_variable *c_src = nir_variable_create(shader, nir_var_shader_in, glsl_vector_type(GLSL_TYPE_FLOAT, 4), "gl_Color");
+ nir_variable *c_src1 = nir_variable_create(shader, nir_var_shader_in, glsl_vector_type(GLSL_TYPE_FLOAT, 4), "gl_Color1");
nir_variable *c_out = nir_variable_create(shader, nir_var_shader_out, glsl_vector_type(g, 4), "gl_FragColor");
c_src->data.location = VARYING_SLOT_COL0;
+ c_src1->data.location = VARYING_SLOT_VAR0;
c_out->data.location = FRAG_RESULT_COLOR;
+ c_src1->data.driver_location = 1;
+
/* Setup nir_builder */
nir_builder _b;
/* Setup inputs */
- nir_ssa_def *s_src = nir_load_var(b, c_src);
-
- if (T == nir_type_float16)
- s_src = nir_f2f16(b, s_src);
- else if (T == nir_type_int16)
- s_src = nir_i2i16(b, nir_iclamp(b, s_src, -32768, 32767));
- else if (T == nir_type_uint16)
- s_src = nir_u2u16(b, nir_umin(b, s_src, nir_imm_int(b, 65535)));
- else if (T == nir_type_int8)
- s_src = nir_i2i8(b, nir_iclamp(b, s_src, -128, 127));
- else if (T == nir_type_uint8)
- s_src = nir_u2u8(b, nir_umin(b, s_src, nir_imm_int(b, 255)));
+ nir_ssa_def *s_src[] = {nir_load_var(b, c_src), nir_load_var(b, c_src1)};
+
+ for (int i = 0; i < ARRAY_SIZE(s_src); ++i) {
+ if (T == nir_type_float16)
+ s_src[i] = nir_f2f16(b, s_src[i]);
+ else if (T == nir_type_int16)
+ s_src[i] = nir_i2i16(b, nir_iclamp(b, s_src[i], -32768, 32767));
+ else if (T == nir_type_uint16)
+ s_src[i] = nir_u2u16(b, nir_umin(b, s_src[i], nir_imm_int(b, 65535)));
+ else if (T == nir_type_int8)
+ s_src[i] = nir_i2i8(b, nir_iclamp(b, s_src[i], -128, 127));
+ else if (T == nir_type_uint8)
+ s_src[i] = nir_u2u8(b, nir_umin(b, s_src[i], nir_imm_int(b, 255)));
+ }
/* Build a trivial blend shader */
- nir_store_var(b, c_out, s_src, 0xFF);
+ nir_store_var(b, c_out, s_src[0], 0xFF);
nir_lower_blend_options options =
nir_make_options(cso, rt);
options.format = format;
+ options.src1 = s_src[1];
if (T == nir_type_float16)
options.half = true;
.rt_formats = {format}
};
- midgard_compile_shader_nir(shader, &program, true, rt, dev->gpu_id, false);
+ midgard_compile_shader_nir(shader, &program, true, rt, dev->gpu_id, false, false);
/* Allow us to patch later */
res.patch_index = program.blend_patch_offset;