While the renderer process runs, the adapter makes the client's render targets itself and the renderer process draws frames into them: texture targets are drawn with like any texture, and a pixmap target's frame is read back through the channel into its Pixmap (protocol version 4: BeginFrame names its target, CreateRenderTarget, Channel::readSize and the -read event). Frames into render targets are drawn even while the window is hidden. The client uses pixmap targets for snapshots (outfit pictures, photos), checked to look right. The render target interfaces are declared from IMVU's vtables. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
fa883892db
commit
6e4fe589e5
18 files changed
+523
-58
No files matched your search
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "t5de/imvu/shared_ptr.hpp"
|
||||
#include "t5de/imvu/types.hpp"
|
||||
|
||||
namespace t5de::imvu {
|
||||
@@ -39,8 +40,36 @@ public:
|
||||
virtual Pixmap* read(Pixmap* result) const = 0;
|
||||
};
|
||||
|
||||
class PiRenderTarget;
|
||||
class PiPixmapRenderTarget;
|
||||
class PiTextureRenderTarget;
|
||||
// What frames can be drawn into besides the window (PiRenderEngine::beginRendering). IMVU's Direct3D engine returns
|
||||
// each as a pointer into its own object (single inheritance from these, so the PiRenderTarget pointer is the same).
|
||||
class PiRenderTarget {
|
||||
public:
|
||||
virtual ~PiRenderTarget() = default;
|
||||
};
|
||||
|
||||
// Drawn into, then read: after each frame drawn into it, getPixmap() has its pixels (IMVU's engine copies them at the
|
||||
// end of the frame). Used for snapshots: outfit pictures, the photo widget.
|
||||
class PiPixmapRenderTarget : public PiRenderTarget {
|
||||
public:
|
||||
// Constructs a copy of the pixels in result (a Pixmap returned by value).
|
||||
virtual Pixmap* getPixmap(Pixmap* result) const = 0;
|
||||
};
|
||||
|
||||
// The part of the texture the target covers, in texture coordinates. IMVU's Direct3D engine always returns 0, 0, 1, 1.
|
||||
struct TextureArea {
|
||||
float left;
|
||||
float top;
|
||||
float right;
|
||||
float bottom;
|
||||
};
|
||||
|
||||
// Drawn into, then drawn with as a texture.
|
||||
class PiTextureRenderTarget : public PiRenderTarget {
|
||||
public:
|
||||
// Constructs the area in result (returned by value).
|
||||
virtual TextureArea* area(TextureArea* result) const = 0;
|
||||
// Constructs, in result, a new texture object for what's been drawn (a shared pointer returned by value).
|
||||
virtual SharedPtr<PiRenderTexture>* texture(SharedPtr<PiRenderTexture>* result) const = 0;
|
||||
};
|
||||
|
||||
} // namespace t5de::imvu
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
namespace t5de::protocol {
|
||||
|
||||
inline constexpr std::uint32_t version = 3;
|
||||
inline constexpr std::uint32_t version = 4;
|
||||
|
||||
// Which part of the client's 3D view the renderer process draws. Full is the default; the others are for comparing
|
||||
// with the client's renderer, which then draws the whole view under the renderer process's window.
|
||||
@@ -22,6 +22,11 @@ enum class View : std::uint32_t {
|
||||
// argument: this header, then `capacity` bytes of data. The adapter sends the command stream (commands.hpp) through
|
||||
// it in chunks: it waits for the event "<name>-consumed", writes a chunk and sets "<name>-ready"; the renderer
|
||||
// process copies the chunk out and sets "<name>-consumed" (both auto-reset; consumed starts set).
|
||||
//
|
||||
// A frame drawn into a render target can ask for its pixels back (BeginFrame::readBack): having sent it, the adapter
|
||||
// waits for "<name>-read" (auto-reset), which the renderer process sets once it has drawn the frame and written the
|
||||
// pixels into the data area (readSize bytes: rows packed, 0xAARRGGBB; 0 if it couldn't). The adapter sends nothing
|
||||
// meanwhile, so the data area is free.
|
||||
struct Channel {
|
||||
std::uint32_t version;
|
||||
std::uint32_t closing; // nonzero: the engine is gone, the renderer process should exit
|
||||
@@ -34,7 +39,7 @@ struct Channel {
|
||||
// Set by the renderer process while its window covers the whole 3D view and it's presenting frames: the client's
|
||||
// renderer then needn't draw (the adapter skips its draws; it draws again as soon as this is cleared).
|
||||
std::uint32_t covering;
|
||||
std::uint32_t reserved;
|
||||
std::uint32_t readSize;
|
||||
};
|
||||
|
||||
static_assert(sizeof(Channel) == 48, "same layout in 32-bit and 64-bit builds");
|
||||
@@ -44,5 +49,6 @@ inline constexpr std::uint32_t channelCapacity = 16 * 1024 * 1024;
|
||||
|
||||
inline constexpr wchar_t readyEventSuffix[] = L"-ready";
|
||||
inline constexpr wchar_t consumedEventSuffix[] = L"-consumed";
|
||||
inline constexpr wchar_t readEventSuffix[] = L"-read";
|
||||
|
||||
} // namespace t5de::protocol
|
||||
@@ -33,6 +33,7 @@ enum class Op : std::uint16_t {
|
||||
DrawTriangles,
|
||||
DrawArrays,
|
||||
DrawPointSprites,
|
||||
CreateRenderTarget,
|
||||
};
|
||||
|
||||
struct Header {
|
||||
@@ -44,9 +45,15 @@ struct Header {
|
||||
// Colors are 0xAARRGGBB. Resource ids are the adapter's, per engine; 0 means none.
|
||||
|
||||
struct BeginFrame {
|
||||
std::uint32_t offscreen; // drawn into a render target, not the window: nothing to show
|
||||
// The render target drawn into (CreateRenderTarget's id), 0 for the window, or foreignTarget.
|
||||
std::uint32_t target;
|
||||
std::uint32_t readBack; // at the end of the frame, send the render target's pixels back (channel.hpp)
|
||||
};
|
||||
|
||||
// A frame drawn into a render target of the client renderer's own (made while the renderer process wasn't running):
|
||||
// the client renderer draws it, the renderer process only follows its changes.
|
||||
inline constexpr std::uint32_t foreignTarget = 0xffffffff;
|
||||
|
||||
struct EndFrame {
|
||||
std::uint64_t sentAt; // the adapter's QueryPerformanceCounter (the same clock in every process)
|
||||
};
|
||||
@@ -131,6 +138,13 @@ struct DestroyTexture {
|
||||
std::uint32_t id;
|
||||
};
|
||||
|
||||
// A texture frames can be drawn into (BeginFrame), and drawn with like any other; destroyed with DestroyTexture.
|
||||
struct CreateRenderTarget {
|
||||
std::uint32_t id;
|
||||
std::uint32_t width;
|
||||
std::uint32_t height;
|
||||
};
|
||||
|
||||
enum class BufferKind : std::uint32_t {
|
||||
Index, // 16-bit indices
|
||||
Vertex, // positions and normals (3 floats), texture coordinates (2 floats) or colors (0xAARRGGBB)
|
||||
|
||||
Reference in new issue
Block a user