Added version number to dehydrated SkSL files
This will allow us to catch cases where the dehydrated files were not regenerated, and also provides a degree of future proofing. Change-Id: I0e7d0e0d83099b78fc5d36c5c5fc1846d8bec467 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/499383 Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
parent
03e7350111
commit
e86e325fbf
@ -592,11 +592,11 @@ void Dehydrator::write(const std::vector<std::unique_ptr<ProgramElement>>& eleme
|
||||
}
|
||||
|
||||
void Dehydrator::finish(OutputStream& out) {
|
||||
out.write16(Rehydrator::kVersion);
|
||||
String stringBuffer = fStringBuffer.str();
|
||||
String commandBuffer = fBody.str();
|
||||
|
||||
out.write16(fStringBuffer.str().size());
|
||||
fStringBufferStart = 2;
|
||||
fStringBufferStart = 4;
|
||||
out.writeString(stringBuffer);
|
||||
fCommandStart = fStringBufferStart + stringBuffer.size();
|
||||
out.writeString(commandBuffer);
|
||||
|
@ -32,6 +32,7 @@ class SymbolTable;
|
||||
|
||||
// The file has the structure:
|
||||
//
|
||||
// uint16 version
|
||||
// uint16 total string length
|
||||
// string data
|
||||
// symboltable
|
||||
|
@ -79,12 +79,16 @@ Rehydrator::Rehydrator(const Context* context, std::shared_ptr<SymbolTable> sym
|
||||
const uint8_t* src, size_t length)
|
||||
: fContext(*context)
|
||||
, fSymbolTable(std::move(symbolTable))
|
||||
, fStart(src)
|
||||
SkDEBUGCODE(, fEnd(fStart + length)) {
|
||||
SkDEBUGCODE(, fEnd(src + length)) {
|
||||
SkASSERT(fSymbolTable);
|
||||
SkASSERT(fSymbolTable->isBuiltin());
|
||||
// skip past string data
|
||||
fIP = fStart;
|
||||
fIP = src;
|
||||
uint16_t version = this->readU16();
|
||||
(void)version;
|
||||
SkASSERTF(version == kVersion, "Dehydrated file is an unsupported version (current version is "
|
||||
"%d, found version %d)", kVersion, version);
|
||||
fStringStart = fIP;
|
||||
// skip over string data
|
||||
fIP += this->readU16();
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,8 @@ class Type;
|
||||
*/
|
||||
class Rehydrator {
|
||||
public:
|
||||
static constexpr uint16_t kVersion = 1;
|
||||
|
||||
enum Command {
|
||||
// uint16 id, Type componentType, uint8 count
|
||||
kArrayType_Command,
|
||||
@ -180,8 +182,8 @@ private:
|
||||
|
||||
skstd::string_view readString() {
|
||||
uint16_t offset = this->readU16();
|
||||
uint8_t length = *(uint8_t*) (fStart + offset);
|
||||
const char* chars = (const char*) fStart + offset + 1;
|
||||
uint8_t length = *(uint8_t*) (fStringStart + offset);
|
||||
const char* chars = (const char*) fStringStart + offset + 1;
|
||||
return skstd::string_view(chars, length);
|
||||
}
|
||||
|
||||
@ -223,7 +225,7 @@ private:
|
||||
std::shared_ptr<SymbolTable> fSymbolTable;
|
||||
std::vector<const Symbol*> fSymbols;
|
||||
|
||||
const uint8_t* fStart;
|
||||
const uint8_t* fStringStart;
|
||||
const uint8_t* fIP;
|
||||
SkDEBUGCODE(const uint8_t* fEnd;)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
static uint8_t SKSL_INCLUDE_sksl_frag[] = {96,0,
|
||||
static uint8_t SKSL_INCLUDE_sksl_frag[] = {1,0,96,0,
|
||||
12,115,107,95,70,114,97,103,67,111,111,114,100,
|
||||
6,102,108,111,97,116,52,
|
||||
12,115,107,95,67,108,111,99,107,119,105,115,101,
|
||||
|
@ -1,4 +1,4 @@
|
||||
static uint8_t SKSL_INCLUDE_sksl_gpu[] = {189,8,
|
||||
static uint8_t SKSL_INCLUDE_sksl_gpu[] = {1,0,189,8,
|
||||
7,100,101,103,114,101,101,115,
|
||||
8,36,103,101,110,84,121,112,101,
|
||||
7,114,97,100,105,97,110,115,
|
||||
|
@ -1,4 +1,4 @@
|
||||
static uint8_t SKSL_INCLUDE_sksl_public[] = {227,3,
|
||||
static uint8_t SKSL_INCLUDE_sksl_public[] = {1,0,227,3,
|
||||
7,100,101,103,114,101,101,115,
|
||||
8,36,103,101,110,84,121,112,101,
|
||||
7,114,97,100,105,97,110,115,
|
||||
|
@ -1,4 +1,4 @@
|
||||
static uint8_t SKSL_INCLUDE_sksl_rt_shader[] = {20,0,
|
||||
static uint8_t SKSL_INCLUDE_sksl_rt_shader[] = {1,0,20,0,
|
||||
12,115,107,95,70,114,97,103,67,111,111,114,100,
|
||||
6,102,108,111,97,116,52,
|
||||
47,1,0,
|
||||
|
@ -1,4 +1,4 @@
|
||||
static uint8_t SKSL_INCLUDE_sksl_vert[] = {82,0,
|
||||
static uint8_t SKSL_INCLUDE_sksl_vert[] = {1,0,82,0,
|
||||
12,115,107,95,80,101,114,86,101,114,116,101,120,
|
||||
11,115,107,95,80,111,115,105,116,105,111,110,
|
||||
6,102,108,111,97,116,52,
|
||||
|
Loading…
Reference in New Issue
Block a user