Add a SkVMDebugTrace flag to ProgramSettings.

When this is enabled, the SkVM code generator will emit trace
instructions for debugging purposes. (The trace instructions are a work
in progress, so at present, the flag doesn't do anything meaningful.)

Change-Id: Ia7d66840d915b1a7e531a3069e641c840bb9c0eb
Bug: skia:12614
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/467764
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2021-11-04 17:38:35 -04:00 committed by SkCQ
parent 78bfb85be7
commit afa75bc522
4 changed files with 10 additions and 1 deletions

View File

@ -1,3 +1,5 @@
/*#pragma settings SkVMDebugTrace*/
uniform half4 colorRed, colorGreen;
// Should return 5

View File

@ -527,7 +527,7 @@ bool Compiler::optimize(LoadedModule& module) {
bool Compiler::optimize(Program& program) {
// The optimizer only needs to run when it is enabled.
if (!program.fConfig->fSettings.fOptimize) {
if (!program.fConfig->fSettings.fOptimize || program.fConfig->fSettings.fSkVMDebugTrace) {
return true;
}

View File

@ -215,6 +215,9 @@ static bool detect_shader_settings(const SkSL::String& text,
if (settingsText.consumeSuffix(" Sharpen")) {
settings->fSharpenTextures = true;
}
if (settingsText.consumeSuffix(" SkVMDebugTrace")) {
settings->fSkVMDebugTrace = true;
}
if (settingsText.empty()) {
break;

View File

@ -40,6 +40,10 @@ struct ProgramSettings {
// At present, zero is always used by our backends.
int fDefaultUniformSet = 0;
int fDefaultUniformBinding = 0;
// Enables debug trace instructions in SkVM output. Trace instructions are used by the SkSL
// debugger to map from SkVM-compiled output back into the original SkSL source. This setting
// does nothing when rendering on an actual GPU.
bool fSkVMDebugTrace = false;
// Enables the SkSL optimizer.
bool fOptimize = true;
// (Requires fOptimize = true) Removes any uncalled functions other than main(). Note that a