Fixed trigger
All checks were successful
CI / React UI Build (push) Successful in 10s
CI / Native Windows Build And Tests (push) Successful in 2m57s
CI / Windows Release Package (push) Has been skipped

This commit is contained in:
Aiden
2026-05-12 18:11:43 +10:00
parent 5fb4607d8c
commit 6e32941675
5 changed files with 49 additions and 4 deletions

View File

@@ -112,8 +112,8 @@ std::vector<unsigned char> BuildRuntimeShaderGlobalParamsStd140(
case ShaderParameterType::Text:
break;
case ShaderParameterType::Trigger:
AppendStd140Int(buffer, 0);
AppendStd140Float(buffer, -1000000.0f);
AppendStd140Int(buffer, value.numberValues.empty() ? 0 : static_cast<int>(value.numberValues[0]));
AppendStd140Float(buffer, value.numberValues.size() > 1 ? static_cast<float>(value.numberValues[1]) : -1000000.0f);
break;
}
}

View File

@@ -3,6 +3,7 @@
#include "RuntimeParameterUtils.h"
#include <algorithm>
#include <chrono>
#include <utility>
namespace RenderCadenceCompositor
@@ -156,8 +157,18 @@ bool RuntimeLayerModel::UpdateParameter(const std::string& layerId, const std::s
}
ShaderParameterValue normalizedValue;
if (!NormalizeAndValidateParameterValue(*definition, value, normalizedValue, error))
if (definition->type == ShaderParameterType::Trigger)
{
const auto currentIt = layer->parameterValues.find(parameterId);
const double previousCount = currentIt == layer->parameterValues.end() || currentIt->second.numberValues.empty()
? 0.0
: currentIt->second.numberValues.front();
normalizedValue.numberValues = { previousCount + 1.0, RuntimeElapsedSeconds() };
}
else if (!NormalizeAndValidateParameterValue(*definition, value, normalizedValue, error))
{
return false;
}
layer->parameterValues[parameterId] = normalizedValue;
if (layer->renderReady)
@@ -360,4 +371,9 @@ RuntimeLayerReadModel RuntimeLayerModel::ToReadModel(const Layer& layer)
readModel.parameterValues = layer.parameterValues;
return readModel;
}
double RuntimeLayerModel::RuntimeElapsedSeconds() const
{
return std::chrono::duration_cast<std::chrono::duration<double>>(std::chrono::steady_clock::now() - mStartTime).count();
}
}

View File

@@ -4,6 +4,7 @@
#include "RuntimeShaderArtifact.h"
#include "SupportedShaderCatalog.h"
#include <chrono>
#include <cstdint>
#include <map>
#include <string>
@@ -91,8 +92,10 @@ private:
static const ShaderParameterDefinition* FindParameterDefinition(const Layer& layer, const std::string& parameterId);
std::string AllocateLayerId();
static RuntimeLayerReadModel ToReadModel(const Layer& layer);
double RuntimeElapsedSeconds() const;
std::vector<Layer> mLayers;
uint64_t mNextLayerNumber = 1;
std::chrono::steady_clock::time_point mStartTime = std::chrono::steady_clock::now();
};
}