Add renderer texture upload contract
This commit is contained in:
@@ -2223,6 +2223,12 @@ int record_render(int argc, char** argv)
|
||||
});
|
||||
pp::renderer::RecordingReadbackBuffer readback_buffer(
|
||||
static_cast<std::uint64_t>(args.width) * args.height * 4U);
|
||||
const std::array<std::byte, 4> upload_pixel {
|
||||
std::byte { 0xff },
|
||||
std::byte { 0x00 },
|
||||
std::byte { 0xff },
|
||||
std::byte { 0xff },
|
||||
};
|
||||
pp::renderer::RecordingShaderProgram shader("pano-cli-record-render");
|
||||
pp::renderer::RecordingMesh mesh(pp::renderer::MeshDesc {
|
||||
.vertex_count = 3,
|
||||
@@ -2232,6 +2238,20 @@ int record_render(int argc, char** argv)
|
||||
|
||||
device.trace()->marker("renderer", "pano_cli_record_render");
|
||||
auto& context = device.immediate_context();
|
||||
const auto upload_status = context.upload_texture(
|
||||
texture,
|
||||
pp::renderer::ReadbackRegion {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
},
|
||||
upload_pixel);
|
||||
if (!upload_status.ok()) {
|
||||
print_error("record-render", upload_status.message);
|
||||
return 2;
|
||||
}
|
||||
|
||||
const auto begin_status = context.begin_render_pass(
|
||||
target,
|
||||
pp::renderer::ClearColor { .r = 0.0F, .g = 0.0F, .b = 0.0F, .a = 1.0F });
|
||||
@@ -2286,15 +2306,20 @@ int record_render(int argc, char** argv)
|
||||
}
|
||||
|
||||
std::size_t draw_commands = 0;
|
||||
std::size_t upload_commands = 0;
|
||||
std::size_t readback_commands = 0;
|
||||
std::size_t capture_commands = 0;
|
||||
std::size_t trace_markers = 0;
|
||||
std::uint64_t upload_bytes = 0;
|
||||
std::uint64_t readback_bytes = 0;
|
||||
std::uint64_t capture_bytes = 0;
|
||||
const auto commands = device.commands();
|
||||
for (const auto& command : commands) {
|
||||
if (command.kind == pp::renderer::RecordedRenderCommandKind::draw) {
|
||||
++draw_commands;
|
||||
} else if (command.kind == pp::renderer::RecordedRenderCommandKind::upload_texture) {
|
||||
++upload_commands;
|
||||
upload_bytes += command.upload_bytes;
|
||||
} else if (command.kind == pp::renderer::RecordedRenderCommandKind::read_texture) {
|
||||
++readback_commands;
|
||||
readback_bytes += command.readback_bytes;
|
||||
@@ -2313,6 +2338,8 @@ int record_render(int argc, char** argv)
|
||||
<< ",\"format\":\"rgba8\"}"
|
||||
<< ",\"commands\":" << commands.size()
|
||||
<< ",\"drawCommands\":" << draw_commands
|
||||
<< ",\"uploadCommands\":" << upload_commands
|
||||
<< ",\"uploadBytes\":" << upload_bytes
|
||||
<< ",\"readbackCommands\":" << readback_commands
|
||||
<< ",\"readbackBytes\":" << readback_bytes
|
||||
<< ",\"captureCommands\":" << capture_commands
|
||||
|
||||
Reference in New Issue
Block a user