|
602 | 602 | bool clear_stencil = (ds_index != RDD::AttachmentReference::UNUSED && pass.attachments[ds_index].shouldClear(subpass, true)); |
603 | 603 |
|
604 | 604 | uint32_t color_count = subpass.color_references.size(); |
605 | | - uint32_t clear_count = color_count + (clear_depth || clear_stencil ? 1 : 0); |
606 | | - if (clear_count == 0) { |
| 605 | + uint32_t clears_size = color_count + (clear_depth || clear_stencil ? 1 : 0); |
| 606 | + if (clears_size == 0) { |
607 | 607 | return; |
608 | 608 | } |
609 | 609 |
|
610 | | - RDD::AttachmentClear *clears = ALLOCA_ARRAY(RDD::AttachmentClear, clear_count); |
611 | | - uint32_t clears_idx = 0; |
| 610 | + RDD::AttachmentClear *clears = ALLOCA_ARRAY(RDD::AttachmentClear, clears_size); |
| 611 | + uint32_t clears_count = 0; |
612 | 612 |
|
613 | 613 | for (uint32_t i = 0; i < color_count; i++) { |
614 | 614 | uint32_t idx = subpass.color_references[i].attachment; |
615 | 615 | if (idx != RDD::AttachmentReference::UNUSED && pass.attachments[idx].shouldClear(subpass, false)) { |
616 | | - clears[clears_idx++] = { .aspect = RDD::TEXTURE_ASPECT_COLOR_BIT, .color_attachment = idx, .value = render.clear_values[idx] }; |
| 616 | + clears[clears_count++] = { .aspect = RDD::TEXTURE_ASPECT_COLOR_BIT, .color_attachment = idx, .value = render.clear_values[idx] }; |
617 | 617 | } |
618 | 618 | } |
619 | 619 |
|
|
627 | 627 | bits.set_flag(RDD::TEXTURE_ASPECT_STENCIL_BIT); |
628 | 628 | } |
629 | 629 |
|
630 | | - clears[clears_idx++] = { .aspect = bits, .color_attachment = ds_index, .value = render.clear_values[ds_index] }; |
| 630 | + clears[clears_count++] = { .aspect = bits, .color_attachment = ds_index, .value = render.clear_values[ds_index] }; |
631 | 631 | } |
632 | 632 |
|
633 | | - render_clear_attachments(VectorView(clears, clear_count), { render.render_area }); |
| 633 | + if (clears_count == 0) { |
| 634 | + return; |
| 635 | + } |
| 636 | + |
| 637 | + render_clear_attachments(VectorView(clears, clears_count), { render.render_area }); |
634 | 638 | } |
635 | 639 |
|
636 | 640 | void MDCommandBuffer::render_next_subpass() { |
|
0 commit comments