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

Function on_update_texture

examples/08-texture_replace/texture_replace_addon.cpp:93–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91 return false;
92}
93static bool on_update_texture(device *device, const subresource_data &data, resource dst, uint32_t dst_subresource, const subresource_box *dst_box)
94{
95 if (dst_subresource != 0)
96 return false; // Ignore updates to mipmap levels other than the base level
97
98 const resource_desc dest_desc = device->get_resource_desc(dst);
99 if (!filter_texture(device, dest_desc, dst_box))
100 return false;
101
102 subresource_data new_data = data;
103 if (load_texture_image(dest_desc, new_data, s_data_to_delete))
104 {
105 // Update texture with the new data
106 device->update_texture_region(new_data, dst, dst_subresource, dst_box);
107
108 // Free the memory allocated via the 'load_texture_image' call above
109 s_data_to_delete.clear();
110
111 return true; // Texture was already updated now, so skip the original update command from the application
112 }
113
114 return false;
115}
116
117// Keep track of current resource between 'map_resource' and 'unmap_resource' event invocations
118// It's also thread-local, for similar reasons as 's_data_to_delete' above, just that the two events that could interact with multiple threads here are 'map_texture_region' and 'unmap_texture_region'.

Callers

nothing calls this directly

Calls 5

load_texture_imageFunction · 0.85
filter_textureFunction · 0.70
get_resource_descMethod · 0.45
update_texture_regionMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected