Files
video-shader-toys/apps/LoopThroughWithOpenGLCompositing/runtime/RuntimeSnapshotProvider.h
Aiden 5cbdbd6813
Some checks failed
CI / React UI Build (push) Successful in 11s
CI / Native Windows Build And Tests (push) Successful in 2m48s
CI / Windows Release Package (push) Has been cancelled
Pass 3
2026-05-11 02:06:17 +10:00

43 lines
1.7 KiB
C++

#pragma once
#include "RenderSnapshotBuilder.h"
#include <mutex>
#include <string>
#include <vector>
struct RuntimeRenderStateSnapshot
{
RuntimeSnapshotVersions versions;
unsigned outputWidth = 0;
unsigned outputHeight = 0;
std::vector<RuntimeRenderState> states;
};
class RuntimeSnapshotProvider
{
public:
explicit RuntimeSnapshotProvider(RenderSnapshotBuilder& renderSnapshotBuilder);
bool BuildLayerPassFragmentShaderSources(const std::string& layerId, std::vector<ShaderPassBuildSource>& passSources, std::string& error) const;
unsigned GetMaxTemporalHistoryFrames() const;
RuntimeSnapshotVersions GetVersions() const;
void AdvanceFrame();
RuntimeRenderStateSnapshot PublishRenderStateSnapshot(unsigned outputWidth, unsigned outputHeight) const;
bool TryPublishRenderStateSnapshot(unsigned outputWidth, unsigned outputHeight, RuntimeRenderStateSnapshot& snapshot) const;
bool TryRefreshPublishedSnapshotParameters(RuntimeRenderStateSnapshot& snapshot) const;
void RefreshDynamicRenderStateFields(std::vector<RuntimeRenderState>& states) const;
private:
bool TryGetPublishedRenderStateSnapshot(unsigned outputWidth, unsigned outputHeight,
const RuntimeSnapshotVersions& versions, RuntimeRenderStateSnapshot& snapshot) const;
void StorePublishedRenderStateSnapshot(const RuntimeRenderStateSnapshot& snapshot) const;
static bool SnapshotMatches(const RuntimeRenderStateSnapshot& snapshot, unsigned outputWidth, unsigned outputHeight,
const RuntimeSnapshotVersions& versions);
RenderSnapshotBuilder& mRenderSnapshotBuilder;
mutable std::mutex mPublishedSnapshotMutex;
mutable bool mHasPublishedRenderStateSnapshot = false;
mutable RuntimeRenderStateSnapshot mPublishedRenderStateSnapshot;
};