diff options
author | 2016-07-25 10:08:54 -0700 | |
---|---|---|
committer | 2016-07-25 10:08:54 -0700 | |
commit | d598f7981f34811e6f2a949207dc13638852f3f7 (patch) | |
tree | 83dd4cf4983f90125651a0ab380f4f71cb3e27f2 /src/sksl/SkSLSPIRVCodeGenerator.h | |
parent | d9ddad2952cdfd0809249abbd94a285abdb6b1d0 (diff) |
SkSL performance improvements (plus a couple of minor warning fixes)
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2131223002
Committed: https://skia.googlesource.com/skia/+/9fd67a1f53809f5eff1210dd107241b450c48acc
Review-Url: https://codereview.chromium.org/2131223002
Diffstat (limited to 'src/sksl/SkSLSPIRVCodeGenerator.h')
-rw-r--r-- | src/sksl/SkSLSPIRVCodeGenerator.h | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/sksl/SkSLSPIRVCodeGenerator.h b/src/sksl/SkSLSPIRVCodeGenerator.h index 885c6b8b70..a20ad9f40b 100644 --- a/src/sksl/SkSLSPIRVCodeGenerator.h +++ b/src/sksl/SkSLSPIRVCodeGenerator.h @@ -61,8 +61,9 @@ public: virtual void store(SpvId value, std::ostream& out) = 0; }; - SPIRVCodeGenerator() - : fCapabilities(1 << SpvCapabilityShader) + SPIRVCodeGenerator(const Context* context) + : fContext(*context) + , fCapabilities(1 << SpvCapabilityShader) , fIdCount(1) , fBoolTrue(0) , fBoolFalse(0) @@ -92,9 +93,9 @@ private: SpvId getType(const Type& type); - SpvId getFunctionType(std::shared_ptr<FunctionDeclaration> function); + SpvId getFunctionType(const FunctionDeclaration& function); - SpvId getPointerType(std::shared_ptr<Type> type, SpvStorageClass_ storageClass); + SpvId getPointerType(const Type& type, SpvStorageClass_ storageClass); std::vector<SpvId> getAccessChain(Expression& expr, std::ostream& out); @@ -108,11 +109,11 @@ private: SpvId writeInterfaceBlock(InterfaceBlock& intf); - SpvId writeFunctionStart(std::shared_ptr<FunctionDeclaration> f, std::ostream& out); + SpvId writeFunctionStart(const FunctionDeclaration& f, std::ostream& out); - SpvId writeFunctionDeclaration(std::shared_ptr<FunctionDeclaration> f, std::ostream& out); + SpvId writeFunctionDeclaration(const FunctionDeclaration& f, std::ostream& out); - SpvId writeFunction(FunctionDefinition& f, std::ostream& out); + SpvId writeFunction(const FunctionDefinition& f, std::ostream& out); void writeGlobalVars(VarDeclaration& v, std::ostream& out); @@ -227,14 +228,16 @@ private: int32_t word5, int32_t word6, int32_t word7, int32_t word8, std::ostream& out); + const Context& fContext; + uint64_t fCapabilities; SpvId fIdCount; SpvId fGLSLExtendedInstructions; typedef std::tuple<IntrinsicKind, int32_t, int32_t, int32_t, int32_t> Intrinsic; std::unordered_map<std::string, Intrinsic> fIntrinsicMap; - std::unordered_map<std::shared_ptr<FunctionDeclaration>, SpvId> fFunctionMap; - std::unordered_map<std::shared_ptr<Variable>, SpvId> fVariableMap; - std::unordered_map<std::shared_ptr<Variable>, int32_t> fInterfaceBlockMap; + std::unordered_map<const FunctionDeclaration*, SpvId> fFunctionMap; + std::unordered_map<const Variable*, SpvId> fVariableMap; + std::unordered_map<const Variable*, int32_t> fInterfaceBlockMap; std::unordered_map<std::string, SpvId> fTypeMap; std::stringstream fCapabilitiesBuffer; std::stringstream fGlobalInitializersBuffer; |