| 668 | } |
| 669 | |
| 670 | void reshade::runtime::update_texture_bindings(const char *semantic, api::resource_view srv, api::resource_view srv_srgb) |
| 671 | { |
| 672 | if (srv_srgb == 0) |
| 673 | srv_srgb = srv; |
| 674 | |
| 675 | if (srv != 0) |
| 676 | { |
| 677 | _texture_semantic_bindings[semantic] = { srv, srv_srgb }; |
| 678 | } |
| 679 | else |
| 680 | { |
| 681 | _texture_semantic_bindings.erase(semantic); |
| 682 | |
| 683 | // Overwrite with empty texture, since it is not valid to bind a zero handle |
| 684 | srv = srv_srgb = _empty_srv; |
| 685 | } |
| 686 | |
| 687 | // Update texture bindings |
| 688 | size_t num_bindings = 0; |
| 689 | for (const effect &effect_data : _effects) |
| 690 | { |
| 691 | if (!effect_data.compiled) |
| 692 | continue; |
| 693 | |
| 694 | num_bindings += effect_data.permutations[0].texture_semantic_to_binding.size(); |
| 695 | } |
| 696 | |
| 697 | num_bindings *= _effect_permutations.size(); |
| 698 | |
| 699 | std::vector<api::descriptor_table_update> descriptor_writes; |
| 700 | descriptor_writes.reserve(num_bindings); |
| 701 | std::vector<api::sampler_with_resource_view> sampler_descriptors(num_bindings); |
| 702 | |
| 703 | for (const effect &effect_data : _effects) |
| 704 | { |
| 705 | if (!effect_data.compiled) |
| 706 | continue; |
| 707 | |
| 708 | for (size_t permutation_index = 0; permutation_index < _effect_permutations.size(); ++permutation_index) |
| 709 | { |
| 710 | if (permutation_index >= effect_data.permutations.size()) |
| 711 | break; |
| 712 | |
| 713 | for (const effect::binding &binding : effect_data.permutations[permutation_index].texture_semantic_to_binding) |
| 714 | { |
| 715 | if (binding.semantic != semantic) |
| 716 | continue; |
| 717 | |
| 718 | api::descriptor_table_update &write = descriptor_writes.emplace_back(); |
| 719 | write.table = binding.table; |
| 720 | write.binding = binding.index; |
| 721 | write.count = 1; |
| 722 | |
| 723 | if (binding.sampler != 0) |
| 724 | { |
| 725 | write.type = api::descriptor_type::sampler_with_resource_view; |
| 726 | write.descriptors = &sampler_descriptors[--num_bindings]; |
| 727 |
no test coverage detected