Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
SkSL::WGSLCodeGenerator Class Reference
Inheritance diagram for SkSL::WGSLCodeGenerator:
SkSL::CodeGenerator

Classes

class  LValue
 
class  PointerLValue
 
struct  ProgramRequirements
 
class  SwizzleLValue
 
class  VectorComponentLValue
 

Public Types

enum class  Builtin {
  kVertexIndex , kInstanceIndex , kPosition , kLastFragColor ,
  kFrontFacing , kSampleIndex , kFragDepth , kSampleMaskIn ,
  kSampleMask , kLocalInvocationId , kLocalInvocationIndex , kGlobalInvocationId ,
  kWorkgroupId , kNumWorkgroups
}
 
enum class  Delimiter { kComma , kSemicolon , kNone }
 

Public Member Functions

 WGSLCodeGenerator (const Context *context, const ShaderCaps *caps, const Program *program, OutputStream *out)
 
bool generateCode () override
 
- Public Member Functions inherited from SkSL::CodeGenerator
 CodeGenerator (const Context *context, const ShaderCaps *caps, const Program *program, OutputStream *stream)
 
virtual ~CodeGenerator ()=default
 
OutputStreamoutputStream ()
 
void setOutputStream (OutputStream *output)
 

Additional Inherited Members

- Protected Attributes inherited from SkSL::CodeGenerator
const ProgramfProgram
 
Context fContext
 
const ShaderCapsfCaps
 
OutputStreamfOut
 
- Static Protected Attributes inherited from SkSL::CodeGenerator
static constexpr float kSharpenTexturesBias = -.475f
 

Detailed Description

Definition at line 118 of file SkSLWGSLCodeGenerator.cpp.

Member Enumeration Documentation

◆ Builtin

Enumerator
kVertexIndex 
kInstanceIndex 
kPosition 
kLastFragColor 
kFrontFacing 
kSampleIndex 
kFragDepth 
kSampleMaskIn 
kSampleMask 
kLocalInvocationId 
kLocalInvocationIndex 
kGlobalInvocationId 
kWorkgroupId 
kNumWorkgroups 

Definition at line 121 of file SkSLWGSLCodeGenerator.cpp.

◆ Delimiter

Enumerator
kComma 
kSemicolon 
kNone 

Definition at line 148 of file SkSLWGSLCodeGenerator.cpp.

Constructor & Destructor Documentation

◆ WGSLCodeGenerator()

SkSL::WGSLCodeGenerator::WGSLCodeGenerator ( const Context context,
const ShaderCaps caps,
const Program program,
OutputStream out 
)
inline

Definition at line 166 of file SkSLWGSLCodeGenerator.cpp.

170 : INHERITED(context, caps, program, out) {}

Member Function Documentation

◆ generateCode()

bool SkSL::WGSLCodeGenerator::generateCode ( )
overridevirtual

Implements SkSL::CodeGenerator.

Definition at line 1252 of file SkSLWGSLCodeGenerator.cpp.

1252 {
1253 // The resources of a WGSL program are structured in the following way:
1254 // - Stage attribute inputs and outputs are bundled inside synthetic structs called
1255 // VSIn/VSOut/FSIn/FSOut/CSIn.
1256 // - All uniform and storage type resources are declared in global scope.
1257 this->preprocessProgram();
1258
1259 {
1260 AutoOutputStream outputToHeader(this, &fHeader, &fIndentation);
1261 this->writeEnables();
1262 this->writeStageInputStruct();
1263 this->writeStageOutputStruct();
1264 this->writeUniformsAndBuffers();
1265 this->writeNonBlockUniformsForTests();
1266 }
1267 StringStream body;
1268 {
1269 // Emit the program body.
1270 AutoOutputStream outputToBody(this, &body, &fIndentation);
1271 const FunctionDefinition* mainFunc = nullptr;
1272 for (const ProgramElement* e : fProgram.elements()) {
1273 this->writeProgramElement(*e);
1274
1275 if (e->is<FunctionDefinition>()) {
1276 const FunctionDefinition& func = e->as<FunctionDefinition>();
1277 if (func.declaration().isMain()) {
1278 mainFunc = &func;
1279 }
1280 }
1281 }
1282
1283 // At the bottom of the program body, emit the entrypoint function.
1284 // The entrypoint relies on state that has been collected while we emitted the rest of the
1285 // program, so it's important to do it last to make sure we don't miss anything.
1286 if (mainFunc) {
1287 this->writeEntryPoint(*mainFunc);
1288 }
1289 }
1290
1291 write_stringstream(fHeader, *fOut);
1292 write_stringstream(body, *fOut);
1293
1294 this->writeUniformPolyfills();
1295
1296 return fContext.fErrors->errorCount() == 0;
1297}
const Program & fProgram
ErrorReporter * fErrors
Definition SkSLContext.h:36
void write_stringstream(const StringStream &s, OutputStream &out)
Definition SkSLUtil.cpp:41

The documentation for this class was generated from the following file: