Re-added SkSL REHYDRATE flag

The REHYDRATE flag was removed at some point, but it was a useful means
of temporarily disabling rehydration for debugging and the like.

Change-Id: I28f7fbaed6003f384509f5848e8bbf4f06697bc9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/491440
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
Ethan Nicholas 2022-01-05 11:11:37 -05:00 committed by SkCQ
parent 576de89810
commit eb12454f57

View File

@ -57,13 +57,13 @@
#include "spirv-tools/libspirv.hpp"
#endif
#if defined(SKSL_STANDALONE)
// In standalone mode, we load the textual sksl source files. GN generates or copies these files
// to the skslc executable directory. The "data" in this mode is just the filename.
#define MODULE_DATA(name) MakeModulePath("sksl_" #name ".sksl")
#ifdef SKSL_STANDALONE
#define REHYDRATE 0
#else
#define REHYDRATE 1
#endif
#if REHYDRATE
// At runtime, we load the dehydrated sksl data files. The data is a (pointer, size) pair.
#include "src/sksl/generated/sksl_frag.dehydrated.sksl"
@ -75,6 +75,12 @@
#define MODULE_DATA(name) MakeModuleData(SKSL_INCLUDE_sksl_##name,\
SKSL_INCLUDE_sksl_##name##_LENGTH)
#else
// In standalone mode, we load the textual sksl source files. GN generates or copies these files
// to the skslc executable directory. The "data" in this mode is just the filename.
#define MODULE_DATA(name) MakeModulePath("sksl_" #name ".sksl")
#endif
namespace SkSL {
@ -324,7 +330,16 @@ LoadedModule Compiler::loadModule(ProgramKind kind,
Program::Settings settings;
settings.fReplaceSettings = !dehydrate;
#if defined(SKSL_STANDALONE)
#if REHYDRATE
ProgramConfig config;
config.fIsBuiltinCode = true;
config.fKind = kind;
config.fSettings = settings;
AutoProgramConfig autoConfig(fContext, &config);
SkASSERT(data.fData && (data.fSize != 0));
Rehydrator rehydrator(fContext.get(), base, data.fData, data.fSize);
LoadedModule result = { kind, rehydrator.symbolTable(), rehydrator.elements() };
#else
SkASSERT(this->errorCount() == 0);
SkASSERT(data.fPath);
std::ifstream in(data.fPath);
@ -340,15 +355,6 @@ LoadedModule Compiler::loadModule(ProgramKind kind,
printf("Unexpected errors: %s\n", this->fErrorText.c_str());
SkDEBUGFAILF("%s %s\n", data.fPath, this->fErrorText.c_str());
}
#else
ProgramConfig config;
config.fIsBuiltinCode = true;
config.fKind = kind;
config.fSettings = settings;
AutoProgramConfig autoConfig(fContext, &config);
SkASSERT(data.fData && (data.fSize != 0));
Rehydrator rehydrator(fContext.get(), base, data.fData, data.fSize);
LoadedModule result = { kind, rehydrator.symbolTable(), rehydrator.elements() };
#endif
return result;