render: remove alpha request option

This commit is contained in:
itsmattkc
2022-07-20 23:14:16 -07:00
parent 752f073136
commit 5ea97f7a64
22 changed files with 32 additions and 113 deletions
@@ -53,13 +53,6 @@ ShaderCode CrossDissolveTransition::GetShaderCode(const ShaderRequest &request)
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/crossdissolve.frag"), QString());
}
void CrossDissolveTransition::ShaderJobEvent(const NodeValueRow &value, ShaderJob &job) const
{
Q_UNUSED(value)
job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn);
}
void CrossDissolveTransition::SampleJobEvent(const SampleBuffer &from_samples, const SampleBuffer &to_samples, SampleBuffer &out_samples, double time_in) const
{
for (int i=0; i<out_samples.sample_count(); i++) {
@@ -43,8 +43,6 @@ public:
virtual ShaderCode GetShaderCode(const ShaderRequest &request) const override;
protected:
virtual void ShaderJobEvent(const NodeValueRow &value, ShaderJob& job) const override;
virtual void SampleJobEvent(const SampleBuffer &from_samples, const SampleBuffer &to_samples, SampleBuffer &out_samples, double time_in) const override;
};
@@ -71,7 +71,6 @@ void CornerPinDistortNode::Value(const NodeValueRow &value, const NodeGlobals &g
{
ShaderJob job;
job.Insert(value);
job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn);
job.Insert(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, globals.resolution(), this));
// Convert slider values to their pixel values and then convert to clip space (-1.0 ... 1.0) for overriding the
@@ -79,7 +79,6 @@ void CropDistortNode::Value(const NodeValueRow &value, const NodeGlobals &global
{
ShaderJob job;
job.Insert(value);
job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn);
job.SetWillChangeImageSize(false);
if (TexturePtr texture = job.Get(kTextureInput).toTexture()) {
-1
View File
@@ -80,7 +80,6 @@ void MaskDistortNode::Value(const NodeValueRow &value, const NodeGlobals &global
feather.Insert(BlurFilterNode::kRadiusInput, NodeValue(NodeValue::kFloat, value[kFeatherInput].toDouble(), this));
feather.SetIterations(2, BlurFilterNode::kTextureInput);
feather.Insert(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, globals.resolution(), this));
feather.SetAlphaChannelRequired(ShaderJob::kAlphaForceOn);
merge.Insert(QStringLiteral("tex_b"), NodeValue(NodeValue::kTexture, feather, this));
} else {
@@ -103,10 +103,6 @@ void TransformDistortNode::Value(const NodeValueRow &value, const NodeGlobals &g
job.Insert(QStringLiteral("ove_mvpmat"), NodeValue(NodeValue::kMatrix, real_matrix, this));
job.SetInterpolation(QStringLiteral("ove_maintex"), static_cast<Texture::Interpolation>(value[kInterpolationInput].toInt()));
// FIXME: This should be optimized, we can use matrix math to determine if this operation will
// end up with gaps in the screen that will require an alpha channel.
job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn);
table->Push(NodeValue::kTexture, QVariant::fromValue(job), this);
pushed_job = true;
@@ -52,7 +52,6 @@ void OpacityEffect::Value(const NodeValueRow &value, const NodeGlobals &globals,
// If there's no texture, no need to run an operation
if (job.Get(kTextureInput).toTexture()) {
if (!qFuzzyCompare(job.Get(kValueInput).toDouble(), 1.0)) {
job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn);
table->Push(NodeValue::kTexture, QVariant::fromValue(job), this);
} else {
// 1.0 float is a no-op, so just push the texture
-5
View File
@@ -159,11 +159,6 @@ void BlurFilterNode::Value(const NodeValueRow &value, const NodeGlobals &globals
}
if (can_push_job) {
// If we're not repeating pixels, expect an alpha channel to appear
if (!job.Get(kRepeatEdgePixelsInput).toBool()) {
job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn);
}
table->Push(NodeValue::kTexture, QVariant::fromValue(job), this);
} else {
// If we're not performing the blur job, just push the texture
-1
View File
@@ -95,7 +95,6 @@ GenerateJob PolygonGenerator::GetGenerateJob(const NodeValueRow &value) const
job.Insert(value);
job.SetRequestedFormat(VideoParams::kFormatFloat32);
job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn);
return job;
}
-1
View File
@@ -76,7 +76,6 @@ void ShapeNode::Value(const NodeValueRow &value, const NodeGlobals &globals, Nod
job.Insert(value);
job.Insert(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, globals.resolution(), this));
job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn);
job.SetShaderID(QStringLiteral("shape"));
PushMergableJob(value, QVariant::fromValue(job), table);
-1
View File
@@ -94,7 +94,6 @@ void TextGeneratorV1::Value(const NodeValueRow &value, const NodeGlobals &global
{
GenerateJob job;
job.Insert(value);
job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn);
if (!job.Get(kTextInput).toString().isEmpty()) {
table->Push(NodeValue::kTexture, QVariant::fromValue(job), this);
-1
View File
@@ -97,7 +97,6 @@ void TextGeneratorV2::Value(const NodeValueRow &value, const NodeGlobals &global
{
GenerateJob job;
job.Insert(value);
job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn);
job.SetRequestedFormat(VideoParams::kFormatFloat32);
if (!job.Get(kTextInput).toString().isEmpty()) {
-1
View File
@@ -98,7 +98,6 @@ void TextGeneratorV3::Value(const NodeValueRow &value, const NodeGlobals &global
{
GenerateJob job;
job.Insert(value);
job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn);
job.SetRequestedFormat(VideoParams::kFormatUnsigned8);
if (value[kUseArgsInput].toBool()) {
-1
View File
@@ -132,7 +132,6 @@ void ChromaKeyNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
ColorTransformJob job;
job.Insert(value);
job.SetAlphaChannelRequired(ColorTransformJob::kAlphaForceOn);
job.SetColorProcessor(processor());
job.SetInputTexture(value[kTextureInput].toTexture());
job.SetNeedsCustomShader(this);
@@ -95,7 +95,6 @@ void ColorDifferenceKeyNode::Value(const NodeValueRow &value, const NodeGlobals
{
ShaderJob job;
job.Insert(value);
job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn);
// If there's no texture, no need to run an operation
if (job.Get(kTextureInput).toTexture()) {
-3
View File
@@ -372,9 +372,6 @@ void MathNodeBase::ValueInternal(Operation operation, Pairing pairing, const QSt
// Replace with adjusted matrix
job.Insert(val_a.type() == NodeValue::kTexture ? param_b_in : param_a_in,
NodeValue(NodeValue::kMatrix, adjusted_matrix, this));
// It's likely an alpha channel will result from this operation
job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn);
}
}
-6
View File
@@ -90,12 +90,6 @@ void MergeNode::Value(const NodeValueRow &value, const NodeGlobals &globals, Nod
// We only have a base texture, no need to alpha over
table->Push(job.Get(kBaseIn));
} else {
// We have both textures, push the job
if (base_tex->channel_count() < VideoParams::kRGBAChannelCount) {
// Base has no alpha, therefore this merge operation will not add an alpha channel
job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOff);
}
table->Push(NodeValue::kTexture, QVariant::fromValue(job), this);
}
}
-28
View File
@@ -168,34 +168,6 @@ NodeGlobals NodeTraverser::GenerateGlobals(const VideoParams &params, const Time
int NodeTraverser::GetChannelCountFromJob(const GenerateJob &job)
{
int max_channel_count = 0;
// Find maximum channel count
for (auto it=job.GetValues().cbegin(); it!=job.GetValues().cend(); it++) {
if (it.value().type() == NodeValue::kTexture) {
if (TexturePtr tex = it.value().toTexture()) {
max_channel_count = qMax(max_channel_count, tex->channel_count());
}
}
}
if (max_channel_count == 0) {
max_channel_count = VideoParams::kRGBChannelCount;
}
switch (job.GetAlphaChannelRequired()) {
case GenerateJob::kAlphaForceOn:
return VideoParams::kRGBAChannelCount;
case GenerateJob::kAlphaForceOff:
if (max_channel_count >= 1 && max_channel_count < VideoParams::kRGBChannelCount) {
return max_channel_count;
} else {
return VideoParams::kRGBChannelCount;
}
case GenerateJob::kAlphaAuto:
return max_channel_count;
}
// Default fallback, should never get here
return VideoParams::kRGBAChannelCount;
}