The adapter records everything the client draws (state, transforms, lights, fog, textures and buffers) as a command stream, sent in chunks through the shared memory channel, while IMVU's Direct3D renderer still draws the whole view. The renderer process draws it with Diligent, with shaders reproducing IMVU's Direct3D 9 fixed-function setup, over the right half of the 3D view to compare. It skips to the newest frame when it falls behind, and logs its errors and frame times. Co-Authored-By: Claude Opus 5.5 <[email protected]>
92 lines
3.1 KiB
C++
92 lines
3.1 KiB
C++
#pragma once
|
|
// The textures and buffers the adapter's engine hands to the client: each wraps the client renderer's own (which the
|
|
// client renderer still draws with) and mirrors it, by id, to the renderer process. The client deletes them through
|
|
// their virtual destructors.
|
|
|
|
#include <cstdint>
|
|
#include <memory>
|
|
|
|
#include "recorder.hpp"
|
|
#include "t5de/imvu/resources.hpp"
|
|
|
|
namespace t5de {
|
|
|
|
class Texture final : public imvu::PiRenderTexture {
|
|
public:
|
|
Texture(imvu::PiRenderTexture* inner, std::shared_ptr<Recorder> recorder, std::uint32_t id);
|
|
~Texture() override;
|
|
|
|
imvu::Vec2i size() const override;
|
|
void updateRegions(const imvu::Pixmap& pixmap, const imvu::CompoundRegion& regions) override;
|
|
void update(const imvu::Pixmap& pixmap) override;
|
|
imvu::Pixmap* read(imvu::Pixmap* result) const override;
|
|
|
|
[[nodiscard]] imvu::PiRenderTexture* inner() const { return inner_; }
|
|
[[nodiscard]] std::uint32_t id() const { return id_; }
|
|
|
|
private:
|
|
imvu::PiRenderTexture* inner_;
|
|
std::shared_ptr<Recorder> recorder_;
|
|
std::uint32_t id_;
|
|
};
|
|
|
|
class IndexBuffer final : public imvu::PiInternalIndexBuffer {
|
|
public:
|
|
IndexBuffer(imvu::PiInternalIndexBuffer* inner, std::shared_ptr<Recorder> recorder, std::uint32_t id);
|
|
~IndexBuffer() override;
|
|
|
|
[[nodiscard]] imvu::PiInternalIndexBuffer* inner() const { return inner_; }
|
|
[[nodiscard]] std::uint32_t id() const { return id_; }
|
|
|
|
private:
|
|
imvu::PiInternalIndexBuffer* inner_;
|
|
std::shared_ptr<Recorder> recorder_;
|
|
std::uint32_t id_;
|
|
};
|
|
|
|
class VertexBuffer final : public imvu::PiInternalVertexBuffer {
|
|
public:
|
|
VertexBuffer(imvu::PiInternalVertexBuffer* inner, std::shared_ptr<Recorder> recorder, std::uint32_t id);
|
|
~VertexBuffer() override;
|
|
|
|
void update(const void* data, std::uint32_t stride, std::uint32_t elementSize,
|
|
std::uint32_t elementCount) override;
|
|
void unknown2() override;
|
|
|
|
[[nodiscard]] imvu::PiInternalVertexBuffer* inner() const { return inner_; }
|
|
[[nodiscard]] std::uint32_t id() const { return id_; }
|
|
|
|
private:
|
|
imvu::PiInternalVertexBuffer* inner_;
|
|
std::shared_ptr<Recorder> recorder_;
|
|
std::uint32_t id_;
|
|
};
|
|
|
|
// The client renderer's object and our id for something the engine made; null and 0 for null.
|
|
inline imvu::PiRenderTexture* inner(imvu::PiRenderTexture* texture)
|
|
{
|
|
return texture != nullptr ? static_cast<Texture*>(texture)->inner() : nullptr;
|
|
}
|
|
inline std::uint32_t id(imvu::PiRenderTexture* texture)
|
|
{
|
|
return texture != nullptr ? static_cast<Texture*>(texture)->id() : 0;
|
|
}
|
|
inline imvu::PiInternalIndexBuffer* inner(imvu::PiInternalIndexBuffer* buffer)
|
|
{
|
|
return buffer != nullptr ? static_cast<IndexBuffer*>(buffer)->inner() : nullptr;
|
|
}
|
|
inline std::uint32_t id(imvu::PiInternalIndexBuffer* buffer)
|
|
{
|
|
return buffer != nullptr ? static_cast<IndexBuffer*>(buffer)->id() : 0;
|
|
}
|
|
inline imvu::PiInternalVertexBuffer* inner(imvu::PiInternalVertexBuffer* buffer)
|
|
{
|
|
return buffer != nullptr ? static_cast<VertexBuffer*>(buffer)->inner() : nullptr;
|
|
}
|
|
inline std::uint32_t id(imvu::PiInternalVertexBuffer* buffer)
|
|
{
|
|
return buffer != nullptr ? static_cast<VertexBuffer*>(buffer)->id() : 0;
|
|
}
|
|
|
|
} // namespace t5de
|