50 lines
1.8 KiB
C++
50 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include "RuntimeStore.h"
|
|
|
|
#include <cstdint>
|
|
#include <mutex>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
struct RuntimeSnapshotVersions
|
|
{
|
|
uint64_t renderStateVersion = 0;
|
|
uint64_t parameterStateVersion = 0;
|
|
};
|
|
|
|
struct RuntimeRenderStateSnapshot
|
|
{
|
|
RuntimeSnapshotVersions versions;
|
|
unsigned outputWidth = 0;
|
|
unsigned outputHeight = 0;
|
|
std::vector<RuntimeRenderState> states;
|
|
};
|
|
|
|
class RuntimeSnapshotProvider
|
|
{
|
|
public:
|
|
explicit RuntimeSnapshotProvider(RuntimeStore& runtimeStore);
|
|
|
|
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);
|
|
|
|
RuntimeStore& mRuntimeStore;
|
|
mutable std::mutex mPublishedSnapshotMutex;
|
|
mutable bool mHasPublishedRenderStateSnapshot = false;
|
|
mutable RuntimeRenderStateSnapshot mPublishedRenderStateSnapshot;
|
|
};
|