The renderer becomes two programs: the adapter (t5deRenderEngine.dll, 32-bit, in IMVU's process) and a 64-bit renderer process (t5de-renderer.exe) drawing with Diligent Engine, fetched with FetchContent and pinned. For now a spike: the adapter starts the renderer process for each engine and signals each frame through a shared memory channel, and the renderer process draws a box into a child window in the client's 3D view. Co-Authored-By: Claude Opus 5.5 <[email protected]>
77 lines
4.1 KiB
C++
77 lines
4.1 KiB
C++
#pragma once
|
|
// A renderer that forwards every call to another one (IMVU's Direct3D engine) and logs what a frame is made of: proof
|
|
// that our declaration of the interface matches IMVU's, and a way to see how the client draws.
|
|
|
|
#include <array>
|
|
#include <cstdint>
|
|
#include <memory>
|
|
|
|
#include "renderer_process.hpp"
|
|
#include "t5de/imvu/render_engine.hpp"
|
|
|
|
namespace t5de {
|
|
|
|
class PassthroughEngine final : public imvu::PiRenderEngine {
|
|
public:
|
|
// renderer may be null.
|
|
PassthroughEngine(imvu::SharedPtr<imvu::PiRenderEngine> inner, std::unique_ptr<RendererProcess> renderer);
|
|
~PassthroughEngine() override;
|
|
|
|
void resizeFrameBuffer(imvu::Vec2i size) override;
|
|
void enable2dFrameBuffer() override;
|
|
void clear(std::uint32_t flags, imvu::Color color) override;
|
|
void setProjection(imvu::Vec2i viewport, const imvu::Mat4f& projection) override;
|
|
void setModelSpace(const imvu::Transform& model) override;
|
|
void setViewSpace(const imvu::Transform& view) override;
|
|
void setTextures(imvu::PiRenderTexture* texture0, imvu::PiRenderTexture* texture1) override;
|
|
void setDepthTestingOn(bool on) override;
|
|
void setDepthWritingOn(bool on) override;
|
|
void setBlendMode(imvu::RenderBlendMode mode) override;
|
|
void setAlphaTestingOn(bool on) override;
|
|
void setAlphaTestValue(float value) override;
|
|
void setBlendingOn(bool on) override;
|
|
void setBackFaceCullingOn(bool on) override;
|
|
void setNormalInvertingOn(bool on) override;
|
|
void setLightingOn(bool on) override;
|
|
void setLightProperties(std::uint32_t index, const imvu::LightProperties& light) override;
|
|
void setFogOn(bool on) override;
|
|
void setFogAttributes(float start, float end, imvu::Color color) override;
|
|
void setTextureTransformMatrixIdentity(std::uint32_t stage) override;
|
|
void setTextureTransformMatrix(std::uint32_t stage, const imvu::TextureTransform& transform) override;
|
|
void setEnvironmentAmbient(imvu::Color color) override;
|
|
imvu::PiRenderTexture* newRenderTexture(const imvu::Pixmap& pixmap, std::uint32_t flags) override;
|
|
imvu::PiInternalIndexBuffer* newIndexBuffer(std::uint32_t count, const std::uint16_t* indices) override;
|
|
imvu::PiInternalVertexBuffer* newStaticVertexBuffer(const void* data, std::uint32_t stride,
|
|
std::uint32_t elementSize,
|
|
std::uint32_t elementCount) override;
|
|
imvu::PiInternalVertexBuffer* newDynamicVertexBuffer(std::uint32_t elementSize,
|
|
std::uint32_t elementCount) override;
|
|
imvu::SharedPtr<imvu::PiPixmapRenderTarget> newPixmapRenderTarget(imvu::Vec2i size) override;
|
|
imvu::SharedPtr<imvu::PiTextureRenderTarget> newTextureRenderTarget(imvu::Vec2i size) override;
|
|
void beginRendering(imvu::PiRenderTarget* target) override;
|
|
void endRendering() override;
|
|
void drawTriangles(imvu::PiInternalIndexBuffer* indices, imvu::PiInternalVertexBuffer* positions,
|
|
imvu::PiInternalVertexBuffer* normals, imvu::PiInternalVertexBuffer* texCoords,
|
|
imvu::PiInternalVertexBuffer* colors) override;
|
|
void drawLine(imvu::Vec3f from, imvu::Vec3f to, std::uint32_t color) override;
|
|
void drawPointSprites(const imvu::PointSpriteVector& sprites) override;
|
|
void drawTrianglesFromMemory(std::uint32_t vertexCount, std::uint32_t indexCount, const std::uint16_t* indices,
|
|
const imvu::VertexAttributeArray<imvu::Vec3f>& positions,
|
|
const imvu::VertexAttributeArray<imvu::Vec3f>& normals,
|
|
const imvu::VertexAttributeArray<imvu::Vec2f>& texCoords,
|
|
const imvu::VertexAttributeArray<imvu::Color>& colors) override;
|
|
|
|
// The interface's methods, by vtable slot (slot 0, the destructor, isn't counted).
|
|
static constexpr std::size_t slots = 35;
|
|
|
|
private:
|
|
void count(std::size_t slot);
|
|
|
|
imvu::SharedPtr<imvu::PiRenderEngine> inner_;
|
|
std::unique_ptr<RendererProcess> renderer_;
|
|
std::array<std::uint32_t, slots> calls_{};
|
|
std::uint64_t frames_ = 0;
|
|
};
|
|
|
|
} // namespace t5de
|