Add renderer readback command contract
This commit is contained in:
@@ -174,6 +174,34 @@ pp::foundation::Status RecordingCommandContext::draw() noexcept
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
pp::foundation::Status RecordingCommandContext::read_texture(
|
||||
ITexture2D& texture,
|
||||
ReadbackRegion region,
|
||||
IReadbackBuffer& destination) noexcept
|
||||
{
|
||||
if (in_render_pass_) {
|
||||
return pp::foundation::Status::invalid_argument("readback must be outside a render pass");
|
||||
}
|
||||
|
||||
const auto desc = texture.desc();
|
||||
const auto bytes = readback_byte_size(desc, region);
|
||||
if (!bytes) {
|
||||
return bytes.status();
|
||||
}
|
||||
|
||||
if (destination.size_bytes() < bytes.value()) {
|
||||
return pp::foundation::Status::out_of_range("readback buffer is too small");
|
||||
}
|
||||
|
||||
push_command(commands_, RecordedRenderCommand {
|
||||
.kind = RecordedRenderCommandKind::read_texture,
|
||||
.texture_desc = desc,
|
||||
.readback_region = region,
|
||||
.readback_bytes = bytes.value(),
|
||||
});
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
void RecordingCommandContext::end_render_pass() noexcept
|
||||
{
|
||||
if (!in_render_pass_) {
|
||||
@@ -251,6 +279,8 @@ const char* recorded_render_command_kind_name(RecordedRenderCommandKind kind) no
|
||||
return "bind_mesh";
|
||||
case RecordedRenderCommandKind::draw:
|
||||
return "draw";
|
||||
case RecordedRenderCommandKind::read_texture:
|
||||
return "read_texture";
|
||||
case RecordedRenderCommandKind::end_render_pass:
|
||||
return "end_render_pass";
|
||||
case RecordedRenderCommandKind::trace_marker:
|
||||
|
||||
Reference in New Issue
Block a user