bool force_dual_color_blend:1;
bool coherent_fb_fetch:1;
+ uint8_t color_outputs_valid;
uint64_t input_slots_valid;
unsigned program_string_id;
GLenum alpha_test_func; /* < For Gen4/5 MRT alpha test */
/* XXX Vulkan doesn't appear to specify */
key->clamp_fragment_color = false;
- key->nr_color_regions = pipeline->subpass->color_count;
+ assert(pipeline->subpass->color_count <= MAX_RTS);
+ for (uint32_t i = 0; i < pipeline->subpass->color_count; i++) {
+ if (pipeline->subpass->color_attachments[i].attachment !=
+ VK_ATTACHMENT_UNUSED)
+ key->color_outputs_valid |= (1 << i);
+ }
+
+ key->nr_color_regions = _mesa_bitcount(key->color_outputs_valid);
key->replicate_alpha = key->nr_color_regions > 1 &&
info->pMultisampleState &&
continue;
const unsigned rt = var->data.location - FRAG_RESULT_DATA0;
- /* Out-of-bounds */
- if (rt >= key.nr_color_regions)
+ /* Unused or out-of-bounds */
+ if (rt >= MAX_RTS || !(key.color_outputs_valid & (1 << rt)))
continue;
const unsigned array_len =
continue;
const unsigned rt = var->data.location - FRAG_RESULT_DATA0;
- if (rt >= key.nr_color_regions) {
- /* Out-of-bounds, throw it away */
+ if (rt >= MAX_RTS || !(key.color_outputs_valid & (1 << rt))) {
+ /* Unused or out-of-bounds, throw it away */
deleted_output = true;
var->data.mode = nir_var_local;
exec_node_remove(&var->node);
* the key accordingly.
*/
key.nr_color_regions = num_rts;
+ key.color_outputs_valid = (1 << num_rts) - 1;
assert(num_rts <= max_rt);
map.surface_to_descriptor -= num_rts;