Store push constants setting in persistent cache.

When generating the SkSL for a given shader we've already made some
decisions about whether to use push constants or not. However, the
SkSL->SPIR-V generator needs to know this in case it adds a uniform
(namely RTHeight).

Change-Id: Id8767924fff4e01227aca5f6fd6f8d5386e357bc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/378321
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
Jim Van Verth 2021-03-02 13:24:53 -05:00 committed by Skia Commit-Bot
parent 6cac02f5c7
commit 35906e0115

View File

@ -28,7 +28,7 @@ struct ShaderMetadata {
};
// Increment this whenever the serialization format of cached shaders changes
static constexpr int kCurrentVersion = 2;
static constexpr int kCurrentVersion = 3;
static inline sk_sp<SkData> PackCachedShaders(SkFourByteTag shaderType,
const SkSL::String shaders[],
@ -53,6 +53,7 @@ static inline sk_sp<SkData> PackCachedShaders(SkFourByteTag shaderType,
writer.writeBool(meta->fSettings->fFlipY);
writer.writeBool(meta->fSettings->fFragColorIsInOut);
writer.writeBool(meta->fSettings->fForceHighPrecision);
writer.writeBool(meta->fSettings->fUsePushConstants);
}
writer.writeInt(meta->fAttributeNames.count());
@ -99,6 +100,7 @@ static inline bool UnpackCachedShaders(SkReadBuffer* reader,
meta->fSettings->fFlipY = reader->readBool();
meta->fSettings->fFragColorIsInOut = reader->readBool();
meta->fSettings->fForceHighPrecision = reader->readBool();
meta->fSettings->fUsePushConstants = reader->readBool();
}
meta->fAttributeNames.resize(reader->readInt());