Draw particles, match the client's fog, and measure frame delay

Particles (point sprites) are drawn as instanced camera-facing squares sized like Direct3D 9's. Fog is by depth buffer value, as Direct3D 9 does with IMVU's projections. At most one frame is queued for display, frames carry the adapter's timestamp so the renderer process logs the delay to presenting, and the log's lines from several processes no longer mix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
dhkatzandClaude Opus 5.5 committed 2026-10-28 06:11:51 -07:00
1 parent 42fc55cb91
commit a04dba18c1
12 files changed
+293 -90

No files matched your search

+12 -2
View File
@@ -23,6 +23,9 @@ public:
// present).
bool execute(std::span<const std::byte> commands, int offsetX, bool draw);
// When the adapter sent the last frame carried out (QueryPerformanceCounter).
[[nodiscard]] std::uint64_t lastSentAt() const { return lastSentAt_; }
private:
struct Texture {
Diligent::RefCntAutoPtr<Diligent::ITexture> texture;
@@ -63,6 +66,7 @@ private:
float fogColor[4];
float fog[4];
float flags[4];
float viewport[4];
};
// What a draw needs from the state, as set by the client.
@@ -85,12 +89,16 @@ private:
void setState(const protocol::SetState& state);
void drawTriangles(const protocol::DrawTriangles& draw);
void drawArrays(const protocol::Command& command);
void drawPointSprites(const protocol::Command& command);
// Draws indexCount indices from index, with vertex streams (positions required, the others may be null).
void draw(Diligent::IBuffer* indices, std::uint32_t indexCount, Diligent::IBuffer* positions,
Diligent::IBuffer* normals, Diligent::IBuffer* texCoords, Diligent::IBuffer* colors);
Pipeline* pipeline(std::uint32_t streams, std::uint32_t textures);
const Shaders& shaders(std::uint32_t streams, std::uint32_t textures);
// The pipeline for the current state, with these vertex streams and textures, for triangles or particles.
Pipeline* pipeline(std::uint32_t streams, std::uint32_t textures, bool sprites);
const Shaders& shaders(std::uint32_t streams, std::uint32_t textures, bool sprites);
// Picks the pipeline for the current state and sets it up for a draw: constants, textures. Null if it can't.
Pipeline* prepare(std::uint32_t streams, bool sprites);
Diligent::ITextureView* textureView(std::uint32_t id);
Diligent::RefCntAutoPtr<Diligent::IRenderDevice> device_;
@@ -108,6 +116,8 @@ private:
State state_;
bool onscreen_ = false; // in a frame drawn into the window
bool draw_ = true;
std::uint64_t lastSentAt_ = 0;
int spritesLogged_ = 0;
int offsetX_ = 0;
};