I attempted to process the result of the previous draw in the game and then apply it to the subsequent draw. First, I created a new resource, and then copied the original resource to the new one via copy_texture_region. After that, I intended to replace the resource in the subsequent draw by updating the descriptor table, but I found that nothing happened.
Some key code:
copy source and create SRV:
resource res;
resource view srv;
resource_view_desc srvDesc = {};
resource_desc desc = origindesc;
desc.texture.width = (desc.texture.width +1)/2;
desc.heap = memory_heap::gpu_only;
desc.usage = resource_usage::copy_dest | resource_usage::shader_resource | resource_usage::render_target | resource_usage::copy_source;
cmd_list->barrier(originalres, resource_usage::shader_resource_pixel, resource_usage::copy_source);
cmd_list->barrier(res, resource_usage::general, resource_usage::copy_dest);
for (uint32_t level = 0;level < origindesc.texture.levels; ++level)
{
uint32t mipWidth = std::max(1u, desc.texture.width >> level);
uint32_t mipHeight = std::max(1u, desc.texture.height >> level);
subresource_box box={};
box.left=0;
box.top =0;
box.front =0;
box.right = (mipWidth +1)/2;
box.bottom = mipHeight;
box.back =1;
cmd_list->copy_texture_region(originalres, level, &sourceBoxLeft, res, level, nullptr, filter_mode::min_mag_mip_point);
}
cmd_list->barrier(res, resource_usage::copy_dest, resource_usage::general);
cmd_list->barrier(originalres, resource_usage::copy_source, resource_usage::shader resource_pixel);
resource_view_desc srvDesc = 0;
srvDesc.type = resource_view_type::texture_2d;
srvDesc.format = originaldesc.texture.format;
srvDesc.texture.first_level = 0;
srvDesc.texture.level_count = originaldesc.texture.levels;
srvDesc.texture.first_layer = 0;
srvDesc.texture.layer_count = 1;
device->create_resource_view(res, resource_usage::shader_resource, srvDesc, &srv)
In draw:
descriptor_table_update update ={};
update.type = descriptor_type::shader_resource_view;
update.table = repl.table;
update.binding = repl.binding;
update.array_offset = 0;
update.count =1;
update.descriptors = &srv;
if (update.table.handle != 0 && update.descriptors != nullptr)
{
commandList->get_device()->update_descriptor_tables(1, &update);
}
Last edit: 1 day 9 hours ago by mashroom33.
Please Log in or Create an account to join the conversation.