MCPcopy Create free account
hub / github.com/crosire/reshade / on_begin_render_effects

Function on_begin_render_effects

examples/09-depth/generic_depth_addon.cpp:932–1128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

930}
931
932static void on_begin_render_effects(effect_runtime *runtime, command_list *cmd_list, resource_view, resource_view)
933{
934 device *const device = runtime->get_device();
935 generic_depth_device_data *const device_data = device->get_private_data<generic_depth_device_data>();
936
937 if (device_data == nullptr)
938 return;
939
940 auto &data = *runtime->get_private_data<generic_depth_data>();
941
942 resource selected_depth_stencil = { 0 };
943 const depth_stencil_resource *selected_depth_stencil_info = nullptr;
944
945 uint32_t frame_width, frame_height;
946 runtime->get_screenshot_width_and_height(&frame_width, &frame_height);
947
948 std::shared_lock<std::shared_mutex> lock(s_mutex);
949 const std::unordered_map<resource, depth_stencil_resource, resource_hash> current_depth_stencil_resources = device_data->depth_stencil_resources;
950 // Unlock before calling into device below, since device may hold a lock itself and that then can deadlock another thread that calls into 'on_destroy_resource' from the device holding that lock
951 lock.unlock();
952
953 for (auto &[depth_stencil, info] : current_depth_stencil_resources)
954 {
955 if (info.last_frame_stats.total.drawcalls == 0 || (info.last_frame_stats.total.vertices <= 3 && info.last_frame_stats.total.drawcalls_indirect == 0))
956 continue; // Skip unused
957
958 if (info.last_used_in_frame < device_data->frame_index || device_data->frame_index <= (info.first_used_in_frame + 1))
959 continue; // Skip resources not used this frame or those that only just appeared for the first time
960
961 if (info.desc.texture.samples > 1 && !device->check_capability(device_caps::resolve_depth_stencil))
962 continue; // Ignore multisampled textures, since they would need to be resolved first
963
964 if (s_format_filtering != 0 && !check_depth_format(info.desc.texture.format))
965 continue;
966 if (s_aspect_ratio_heuristic != aspect_ratio_heuristic::none && !check_aspect_ratio(static_cast<float>(info.desc.texture.width), static_cast<float>(info.desc.texture.height), static_cast<float>(frame_width), static_cast<float>(frame_height)))
967 continue; // Not a good fit
968
969 if (selected_depth_stencil.handle == 0 ||
970 info.last_frame_stats.total > selected_depth_stencil_info->last_frame_stats.total)
971 {
972 selected_depth_stencil = depth_stencil;
973 selected_depth_stencil_info = &info;
974 }
975 }
976
977 if (data.override_depth_stencil != 0)
978 {
979 const auto it = current_depth_stencil_resources.find(data.override_depth_stencil);
980 if (it != current_depth_stencil_resources.end())
981 {
982 selected_depth_stencil = it->first;
983 selected_depth_stencil_info = &it->second;
984 }
985 }
986
987 const resource_view prev_shader_resource = data.selected_shader_resource;
988
989 if (selected_depth_stencil != 0) do

Callers

nothing calls this directly

Calls 15

check_depth_formatFunction · 0.85
check_aspect_ratioFunction · 0.85
format_to_default_typedFunction · 0.85
get_config_valueFunction · 0.85
update_effect_runtimeFunction · 0.85
lockMethod · 0.80
get_deviceMethod · 0.45
check_capabilityMethod · 0.45
get_apiMethod · 0.45
create_resource_viewMethod · 0.45
barrierMethod · 0.45

Tested by

no test coverage detected