Add renderer texture transition contract

This commit is contained in:
2026-06-02 17:13:44 +02:00
parent 56cb9eaacb
commit 18617cdbd2
9 changed files with 432 additions and 8 deletions

View File

@@ -2313,6 +2313,15 @@ int record_render(int argc, char** argv)
}
auto& context = device.immediate_context();
const auto transition_upload_status = context.transition_texture(
*texture.value(),
pp::renderer::TextureState::undefined,
pp::renderer::TextureState::upload_destination);
if (!transition_upload_status.ok()) {
print_error("record-render", transition_upload_status.message);
return 2;
}
const auto upload_status = context.upload_texture(
*texture.value(),
pp::renderer::ReadbackRegion {
@@ -2327,12 +2336,39 @@ int record_render(int argc, char** argv)
return 2;
}
const auto transition_shader_read_status = context.transition_texture(
*texture.value(),
pp::renderer::TextureState::upload_destination,
pp::renderer::TextureState::shader_read);
if (!transition_shader_read_status.ok()) {
print_error("record-render", transition_shader_read_status.message);
return 2;
}
const auto transition_mip_destination_status = context.transition_texture(
*mip_texture.value(),
pp::renderer::TextureState::undefined,
pp::renderer::TextureState::copy_destination);
if (!transition_mip_destination_status.ok()) {
print_error("record-render", transition_mip_destination_status.message);
return 2;
}
const auto mipmap_status = context.generate_mipmaps(*mip_texture.value());
if (!mipmap_status.ok()) {
print_error("record-render", mipmap_status.message);
return 2;
}
const auto transition_mip_shader_read_status = context.transition_texture(
*mip_texture.value(),
pp::renderer::TextureState::copy_destination,
pp::renderer::TextureState::shader_read);
if (!transition_mip_shader_read_status.ok()) {
print_error("record-render", transition_mip_shader_read_status.message);
return 2;
}
const auto begin_status = context.begin_render_pass(
*target.value(),
pp::renderer::RenderPassDesc {
@@ -2497,6 +2533,9 @@ int record_render(int argc, char** argv)
std::size_t bind_sampler_commands = 0;
std::size_t upload_commands = 0;
std::size_t mipmap_commands = 0;
std::size_t transition_commands = 0;
std::size_t transition_to_upload = 0;
std::size_t transition_to_shader_read = 0;
std::size_t copy_commands = 0;
std::size_t readback_commands = 0;
std::size_t capture_commands = 0;
@@ -2567,6 +2606,15 @@ int record_render(int argc, char** argv)
count_label(command.texture_desc.debug_name);
mipmap_levels += command.generated_mip_levels;
mipmap_bytes += command.generated_mip_bytes;
} else if (command.kind == pp::renderer::RecordedRenderCommandKind::transition_texture) {
++transition_commands;
count_label(command.texture_desc.debug_name);
if (command.after_state == pp::renderer::TextureState::upload_destination) {
++transition_to_upload;
}
if (command.after_state == pp::renderer::TextureState::shader_read) {
++transition_to_shader_read;
}
} else if (command.kind == pp::renderer::RecordedRenderCommandKind::upload_texture) {
++upload_commands;
count_label(command.texture_desc.debug_name);
@@ -2627,6 +2675,9 @@ int record_render(int argc, char** argv)
<< ",\"mipmapCommands\":" << mipmap_commands
<< ",\"mipmapLevels\":" << mipmap_levels
<< ",\"mipmapBytes\":" << mipmap_bytes
<< ",\"transitionCommands\":" << transition_commands
<< ",\"transitionToUpload\":" << transition_to_upload
<< ",\"transitionToShaderRead\":" << transition_to_shader_read
<< ",\"copyCommands\":" << copy_commands
<< ",\"copySourceBytes\":" << copy_source_bytes
<< ",\"copyDestinationBytes\":" << copy_destination_bytes