Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/sksl/SkSLSPIRVCodeGenerator.cpp

Issue 2372773002: Revert of Turned on SkSL->GLSL compiler (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/sksl/SkSLSPIRVCodeGenerator.h ('k') | src/sksl/SkSLUtil.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkSLSPIRVCodeGenerator.h" 8 #include "SkSLSPIRVCodeGenerator.h"
9 9
10 #include "string.h" 10 #include "string.h"
11 11
12 #include "GLSL.std.450.h" 12 #include "GLSL.std.450.h"
13 13
14 #include "ir/SkSLExpressionStatement.h" 14 #include "ir/SkSLExpressionStatement.h"
15 #include "ir/SkSLExtension.h" 15 #include "ir/SkSLExtension.h"
16 #include "ir/SkSLIndexExpression.h" 16 #include "ir/SkSLIndexExpression.h"
17 #include "ir/SkSLVariableReference.h" 17 #include "ir/SkSLVariableReference.h"
18 #include "SkSLCompiler.h"
19 18
20 namespace SkSL { 19 namespace SkSL {
21 20
22 #define SPIRV_DEBUG 0 21 #define SPIRV_DEBUG 0
23 22
24 static const int32_t SKSL_MAGIC = 0x0; // FIXME: we should probably register a magic number 23 static const int32_t SKSL_MAGIC = 0x0; // FIXME: we should probably register a magic number
25 24
26 void SPIRVCodeGenerator::setupIntrinsics() { 25 void SPIRVCodeGenerator::setupIntrinsics() {
27 #define ALL_GLSL(x) std::make_tuple(kGLSL_STD_450_IntrinsicKind, GLSLstd450 ## x , GLSLstd450 ## x, \ 26 #define ALL_GLSL(x) std::make_tuple(kGLSL_STD_450_IntrinsicKind, GLSLstd450 ## x , GLSLstd450 ## x, \
28 GLSLstd450 ## x, GLSLstd450 ## x) 27 GLSLstd450 ## x, GLSLstd450 ## x)
(...skipping 2286 matching lines...) Expand 10 before | Expand all | Expand 10 after
2315 fDecorationBuffer); 2314 fDecorationBuffer);
2316 } 2315 }
2317 if (layout.fIndex >= 0) { 2316 if (layout.fIndex >= 0) {
2318 this->writeInstruction(SpvOpDecorate, target, SpvDecorationIndex, layout .fIndex, 2317 this->writeInstruction(SpvOpDecorate, target, SpvDecorationIndex, layout .fIndex,
2319 fDecorationBuffer); 2318 fDecorationBuffer);
2320 } 2319 }
2321 if (layout.fSet >= 0) { 2320 if (layout.fSet >= 0) {
2322 this->writeInstruction(SpvOpDecorate, target, SpvDecorationDescriptorSet , layout.fSet, 2321 this->writeInstruction(SpvOpDecorate, target, SpvDecorationDescriptorSet , layout.fSet,
2323 fDecorationBuffer); 2322 fDecorationBuffer);
2324 } 2323 }
2325 if (layout.fBuiltin >= 0 && layout.fBuiltin != SK_FRAGCOLOR_BUILTIN) { 2324 if (layout.fBuiltin >= 0) {
2326 this->writeInstruction(SpvOpDecorate, target, SpvDecorationBuiltIn, layo ut.fBuiltin, 2325 this->writeInstruction(SpvOpDecorate, target, SpvDecorationBuiltIn, layo ut.fBuiltin,
2327 fDecorationBuffer); 2326 fDecorationBuffer);
2328 } 2327 }
2329 } 2328 }
2330 2329
2331 void SPIRVCodeGenerator::writeLayout(const Layout& layout, SpvId target, int mem ber) { 2330 void SPIRVCodeGenerator::writeLayout(const Layout& layout, SpvId target, int mem ber) {
2332 if (layout.fLocation >= 0) { 2331 if (layout.fLocation >= 0) {
2333 this->writeInstruction(SpvOpMemberDecorate, target, member, SpvDecoratio nLocation, 2332 this->writeInstruction(SpvOpMemberDecorate, target, member, SpvDecoratio nLocation,
2334 layout.fLocation, fDecorationBuffer); 2333 layout.fLocation, fDecorationBuffer);
2335 } 2334 }
(...skipping 21 matching lines...) Expand all
2357 this->writeInstruction(SpvOpDecorate, type, SpvDecorationBlock, fDecorationB uffer); 2356 this->writeInstruction(SpvOpDecorate, type, SpvDecorationBlock, fDecorationB uffer);
2358 SpvStorageClass_ storageClass = get_storage_class(intf.fVariable.fModifiers) ; 2357 SpvStorageClass_ storageClass = get_storage_class(intf.fVariable.fModifiers) ;
2359 SpvId ptrType = this->nextId(); 2358 SpvId ptrType = this->nextId();
2360 this->writeInstruction(SpvOpTypePointer, ptrType, storageClass, type, fConst antBuffer); 2359 this->writeInstruction(SpvOpTypePointer, ptrType, storageClass, type, fConst antBuffer);
2361 this->writeInstruction(SpvOpVariable, ptrType, result, storageClass, fConsta ntBuffer); 2360 this->writeInstruction(SpvOpVariable, ptrType, result, storageClass, fConsta ntBuffer);
2362 this->writeLayout(intf.fVariable.fModifiers.fLayout, result); 2361 this->writeLayout(intf.fVariable.fModifiers.fLayout, result);
2363 fVariableMap[&intf.fVariable] = result; 2362 fVariableMap[&intf.fVariable] = result;
2364 return result; 2363 return result;
2365 } 2364 }
2366 2365
2367 #define BUILTIN_IGNORE 9999 2366 void SPIRVCodeGenerator::writeGlobalVars(const VarDeclarations& decl, std::ostre am& out) {
2368 void SPIRVCodeGenerator::writeGlobalVars(Program::Kind kind, const VarDeclaratio ns& decl,
2369 std::ostream& out) {
2370 for (size_t i = 0; i < decl.fVars.size(); i++) { 2367 for (size_t i = 0; i < decl.fVars.size(); i++) {
2371 const VarDeclaration& varDecl = decl.fVars[i]; 2368 const VarDeclaration& varDecl = decl.fVars[i];
2372 const Variable* var = varDecl.fVar; 2369 const Variable* var = varDecl.fVar;
2373 if (var->fModifiers.fLayout.fBuiltin == BUILTIN_IGNORE) {
2374 continue;
2375 }
2376 if (var->fModifiers.fLayout.fBuiltin == SK_FRAGCOLOR_BUILTIN &&
2377 kind != Program::kFragment_Kind) {
2378 continue;
2379 }
2380 if (!var->fIsReadFrom && !var->fIsWrittenTo && 2370 if (!var->fIsReadFrom && !var->fIsWrittenTo &&
2381 !(var->fModifiers.fFlags & (Modifiers::kIn_Flag | 2371 !(var->fModifiers.fFlags & (Modifiers::kIn_Flag |
2382 Modifiers::kOut_Flag | 2372 Modifiers::kOut_Flag |
2383 Modifiers::kUniform_Flag))) { 2373 Modifiers::kUniform_Flag))) {
2384 // variable is dead and not an input / output var (the Vulkan debug layers complain if 2374 // variable is dead and not an input / output var (the Vulkan debug layers complain if
2385 // we elide an interface var, even if it's dead) 2375 // we elide an interface var, even if it's dead)
2386 continue; 2376 continue;
2387 } 2377 }
2388 SpvStorageClass_ storageClass; 2378 SpvStorageClass_ storageClass;
2389 if (var->fModifiers.fFlags & Modifiers::kIn_Flag) { 2379 if (var->fModifiers.fFlags & Modifiers::kIn_Flag) {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2565 InterfaceBlock& intf = (InterfaceBlock&) *program.fElements[i]; 2555 InterfaceBlock& intf = (InterfaceBlock&) *program.fElements[i];
2566 SpvId id = this->writeInterfaceBlock(intf); 2556 SpvId id = this->writeInterfaceBlock(intf);
2567 if ((intf.fVariable.fModifiers.fFlags & Modifiers::kIn_Flag) || 2557 if ((intf.fVariable.fModifiers.fFlags & Modifiers::kIn_Flag) ||
2568 (intf.fVariable.fModifiers.fFlags & Modifiers::kOut_Flag)) { 2558 (intf.fVariable.fModifiers.fFlags & Modifiers::kOut_Flag)) {
2569 interfaceVars.push_back(id); 2559 interfaceVars.push_back(id);
2570 } 2560 }
2571 } 2561 }
2572 } 2562 }
2573 for (size_t i = 0; i < program.fElements.size(); i++) { 2563 for (size_t i = 0; i < program.fElements.size(); i++) {
2574 if (program.fElements[i]->fKind == ProgramElement::kVar_Kind) { 2564 if (program.fElements[i]->fKind == ProgramElement::kVar_Kind) {
2575 this->writeGlobalVars(program.fKind, ((VarDeclarations&) *program.fE lements[i]), 2565 this->writeGlobalVars(((VarDeclarations&) *program.fElements[i]), bo dy);
2576 body);
2577 } 2566 }
2578 } 2567 }
2579 for (size_t i = 0; i < program.fElements.size(); i++) { 2568 for (size_t i = 0; i < program.fElements.size(); i++) {
2580 if (program.fElements[i]->fKind == ProgramElement::kFunction_Kind) { 2569 if (program.fElements[i]->fKind == ProgramElement::kFunction_Kind) {
2581 this->writeFunction(((FunctionDefinition&) *program.fElements[i]), b ody); 2570 this->writeFunction(((FunctionDefinition&) *program.fElements[i]), b ody);
2582 } 2571 }
2583 } 2572 }
2584 const FunctionDeclaration* main = nullptr; 2573 const FunctionDeclaration* main = nullptr;
2585 for (auto entry : fFunctionMap) { 2574 for (auto entry : fFunctionMap) {
2586 if (entry.first->fName == "main") { 2575 if (entry.first->fName == "main") {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2640 this->writeWord(SpvVersion, out); 2629 this->writeWord(SpvVersion, out);
2641 this->writeWord(SKSL_MAGIC, out); 2630 this->writeWord(SKSL_MAGIC, out);
2642 std::stringstream buffer; 2631 std::stringstream buffer;
2643 this->writeInstructions(program, buffer); 2632 this->writeInstructions(program, buffer);
2644 this->writeWord(fIdCount, out); 2633 this->writeWord(fIdCount, out);
2645 this->writeWord(0, out); // reserved, always zero 2634 this->writeWord(0, out); // reserved, always zero
2646 out << buffer.str(); 2635 out << buffer.str();
2647 } 2636 }
2648 2637
2649 } 2638 }
OLDNEW
« no previous file with comments | « src/sksl/SkSLSPIRVCodeGenerator.h ('k') | src/sksl/SkSLUtil.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698