Files
t5de-renderer/adapter/recorder.hpp
T
dhkatzandClaude Opus 5.5 2d9da249fa
CI / build (push) Failing after 0s
Draw the whole 3D view in place of the client's renderer
The full view is now the default. While the renderer process covers the whole
view (Channel::covering, set after each frame it presents), the adapter skips
the client's renderer's clears and draws, decided per frame; the client's
renderer still gets state and resources, and draws again as soon as the
renderer process stops covering the view.

The client's window no longer gets WS_CLIPCHILDREN: the client draws when its
window gets WM_PAINT, which a window entirely covered by clipped children never
gets (it fell to about one frame a second). The flip model swap chain shows
above the client's drawing anyway.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 18:14:17 -07:00

63 lines
2.4 KiB
C++

#pragma once
// Records what the client draws as commands (include/t5de/protocol/commands.hpp) and sends them to the renderer
// process. Shared by an engine and the resources it creates (which can outlive it); once the renderer process is
// gone, it records nothing.
#include <cstdint>
#include <memory>
#include "renderer_process.hpp"
#include "t5de/imvu/types.hpp"
#include "t5de/protocol/commands.hpp"
namespace t5de {
class Recorder {
public:
explicit Recorder(std::unique_ptr<RendererProcess> process);
[[nodiscard]] bool active() const { return process_ && process_->alive(); }
// Whether the renderer process draws the whole 3D view, so the client's renderer needn't.
[[nodiscard]] bool covering() const { return process_ && process_->covering(); }
// Records a command (if active); returns its payload to fill, or null.
template <class Body>
std::byte* add(protocol::Op op, const Body& body, std::size_t payloadSize = 0)
{
if (!active()) {
return nullptr;
}
std::byte* payload = writer_.add(op, body, payloadSize);
return payload;
}
// Sends what's recorded: at the end of each frame, and between frames when a lot is waiting (resources).
void flush(bool endsFrame);
void flushIfLarge();
std::uint32_t createTexture(const imvu::Pixmap& pixmap, std::uint32_t flags);
void updateTexture(std::uint32_t id, const imvu::Pixmap& pixmap);
void destroyTexture(std::uint32_t id);
// Copies count elements of elementSize bytes, stride bytes apart (0: packed), from data (null: none yet).
std::uint32_t createBuffer(protocol::BufferKind kind, const void* data, std::uint32_t stride,
std::uint32_t elementSize, std::uint32_t count);
void updateBuffer(std::uint32_t id, const void* data, std::uint32_t stride, std::uint32_t elementSize,
std::uint32_t count);
void destroyBuffer(std::uint32_t id);
private:
void addPixels(protocol::Op op, std::uint32_t id, const imvu::Pixmap& pixmap, std::uint32_t flags);
std::unique_ptr<RendererProcess> process_;
protocol::Writer writer_;
std::uint32_t nextId_ = 1;
};
// Copies count elements of elementSize bytes, stride bytes apart (0: packed), into destination, packed.
void pack(std::byte* destination, const void* source, std::uint32_t stride, std::uint32_t elementSize,
std::uint32_t count);
} // namespace t5de