| 53 | } |
| 54 | |
| 55 | static bool on_copy_texture(command_list *cmd_list, resource source, uint32_t source_subresource, const subresource_box *, resource dest, uint32_t dest_subresource, const subresource_box *dest_box, filter_mode) |
| 56 | { |
| 57 | if (source_subresource != 0 || source_subresource != dest_subresource) |
| 58 | return false; // Ignore copies to mipmap levels other than the base level |
| 59 | |
| 60 | device *const device = cmd_list->get_device(); |
| 61 | |
| 62 | const resource_desc source_desc = device->get_resource_desc(source); |
| 63 | if (source_desc.heap != memory_heap::cpu_to_gpu) |
| 64 | return false; // Ignore copies that are not from a buffer in host memory |
| 65 | |
| 66 | const resource_desc dest_desc = device->get_resource_desc(dest); |
| 67 | if (!filter_texture(device, dest_desc, dest_box)) |
| 68 | return false; |
| 69 | |
| 70 | bool replace = false; |
| 71 | |
| 72 | subresource_data new_data; |
| 73 | if (device->map_texture_region(source, source_subresource, nullptr, map_access::read_only, &new_data)) |
| 74 | { |
| 75 | replace = load_texture_image(dest_desc, new_data, s_data_to_delete); |
| 76 | |
| 77 | device->unmap_texture_region(source, source_subresource); |
| 78 | } |
| 79 | |
| 80 | if (replace) |
| 81 | { |
| 82 | // Update texture with the new data |
| 83 | device->update_texture_region(new_data, dest, dest_subresource, dest_box); |
| 84 | |
| 85 | // Free the memory allocated via the 'load_texture_image' call above |
| 86 | s_data_to_delete.clear(); |
| 87 | |
| 88 | return true; // Texture was already updated now, so skip the original copy command from the application |
| 89 | } |
| 90 | |
| 91 | return false; |
| 92 | } |
| 93 | static 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) |
nothing calls this directly
no test coverage detected