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

Side by Side Diff: bench/GLBench.cpp

Issue 2408053002: 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 | « bench/GLBench.h ('k') | bench/GLInstancedArraysBench.cpp » ('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 2015 Google Inc. 2 * Copyright 2015 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 "GLBench.h" 8 #include "GLBench.h"
9 9
10 #if SK_SUPPORT_GPU 10 #if SK_SUPPORT_GPU
11 #include "GrGpu.h" 11 #include "GrGpu.h"
12 #include "GrTest.h" 12 #include "GrTest.h"
13 #include "gl/GrGLContext.h" 13 #include "gl/GrGLContext.h"
14 #include "gl/builders/GrGLShaderStringBuilder.h"
15 #include "SkSLCompiler.h"
16 #include <stdio.h> 14 #include <stdio.h>
17 #include <string>
18 15
19 const GrGLContext* GLBench::getGLContext(SkCanvas* canvas) { 16 const GrGLContext* GLBench::getGLContext(SkCanvas* canvas) {
20 // This bench exclusively tests GL calls directly 17 // This bench exclusively tests GL calls directly
21 if (nullptr == canvas->getGrContext()) { 18 if (nullptr == canvas->getGrContext()) {
22 return nullptr; 19 return nullptr;
23 } 20 }
24 GrContext* context = canvas->getGrContext(); 21 GrContext* context = canvas->getGrContext();
25 GrGpu* gpu = context->getGpu(); 22 GrGpu* gpu = context->getGpu();
26 if (!gpu) { 23 if (!gpu) {
27 SkDebugf("Couldn't get Gr gpu."); 24 SkDebugf("Couldn't get Gr gpu.");
(...skipping 29 matching lines...) Expand all
57 54
58 void GLBench::onDraw(int loops, SkCanvas* canvas) { 55 void GLBench::onDraw(int loops, SkCanvas* canvas) {
59 const GrGLContext* ctx = this->getGLContext(canvas); 56 const GrGLContext* ctx = this->getGLContext(canvas);
60 if (!ctx) { 57 if (!ctx) {
61 return; 58 return;
62 } 59 }
63 this->glDraw(loops, ctx); 60 this->glDraw(loops, ctx);
64 canvas->getGrContext()->resetContext(); 61 canvas->getGrContext()->resetContext();
65 } 62 }
66 63
67 GrGLuint GLBench::CompileShader(const GrGLContext* context, const char* sksl, Gr GLenum type) { 64 GrGLuint GLBench::CompileShader(const GrGLInterface* gl, const char* shaderSrc, GrGLenum type) {
68 const GrGLInterface* gl = context->interface();
69 std::string glsl;
70 bool result = context->compiler()->toGLSL(type == GR_GL_VERTEX_SHADER
71 ? SkSL::Prog ram::kVertex_Kind
72 : SkSL::Prog ram::kFragment_Kind,
73 std::string(sksl),
74 GrGLSkSLCapsForContext(*context),
75 &glsl);
76 if (!result) {
77 SkDebugf("SkSL compilation failed:\n%s\n%s\n", sksl,
78 context->compiler()->errorText().c_str());
79 }
80 GrGLuint shader; 65 GrGLuint shader;
81 // Create the shader object 66 // Create the shader object
82 GR_GL_CALL_RET(gl, shader, CreateShader(type)); 67 GR_GL_CALL_RET(gl, shader, CreateShader(type));
83 68
84 // Load the shader source 69 // Load the shader source
85 const char* glslPtr = glsl.c_str(); 70 GR_GL_CALL(gl, ShaderSource(shader, 1, &shaderSrc, nullptr));
86 GR_GL_CALL(gl, ShaderSource(shader, 1, (const char**) &glslPtr, nullptr));
87 71
88 // Compile the shader 72 // Compile the shader
89 GR_GL_CALL(gl, CompileShader(shader)); 73 GR_GL_CALL(gl, CompileShader(shader));
90 74
91 // Check for compile time errors 75 // Check for compile time errors
92 GrGLint success = GR_GL_INIT_ZERO; 76 GrGLint success = GR_GL_INIT_ZERO;
93 GrGLchar infoLog[512]; 77 GrGLchar infoLog[512];
94 GR_GL_CALL(gl, GetShaderiv(shader, GR_GL_COMPILE_STATUS, &success)); 78 GR_GL_CALL(gl, GetShaderiv(shader, GR_GL_COMPILE_STATUS, &success));
95 if (!success) { 79 if (!success) {
96 GR_GL_CALL(gl, GetShaderInfoLog(shader, 512, nullptr, infoLog)); 80 GR_GL_CALL(gl, GetShaderInfoLog(shader, 512, nullptr, infoLog));
97 SkDebugf("ERROR::SHADER::COMPLIATION_FAILED: %s\n", infoLog); 81 SkDebugf("ERROR::SHADER::COMPLIATION_FAILED: %s\n", infoLog);
98 } 82 }
99 83
100 return shader; 84 return shader;
101 } 85 }
102 86
103 GrGLuint GLBench::CreateProgram(const GrGLContext* context, const char* vshader, 87 GrGLuint GLBench::CreateProgram(const GrGLInterface* gl, const char* vshader, co nst char* fshader) {
104 const char* fshader) { 88
105 const GrGLInterface* gl = context->interface(); 89 GrGLuint vertexShader = CompileShader(gl, vshader, GR_GL_VERTEX_SHADER);
106 GrGLuint vertexShader = CompileShader(context, vshader, GR_GL_VERTEX_SHADER) ; 90 GrGLuint fragmentShader = CompileShader(gl, fshader, GR_GL_FRAGMENT_SHADER);
107 GrGLuint fragmentShader = CompileShader(context, fshader, GR_GL_FRAGMENT_SHA DER);
108 91
109 GrGLuint shaderProgram; 92 GrGLuint shaderProgram;
110 GR_GL_CALL_RET(gl, shaderProgram, CreateProgram()); 93 GR_GL_CALL_RET(gl, shaderProgram, CreateProgram());
111 GR_GL_CALL(gl, AttachShader(shaderProgram, vertexShader)); 94 GR_GL_CALL(gl, AttachShader(shaderProgram, vertexShader));
112 GR_GL_CALL(gl, AttachShader(shaderProgram, fragmentShader)); 95 GR_GL_CALL(gl, AttachShader(shaderProgram, fragmentShader));
113 GR_GL_CALL(gl, LinkProgram(shaderProgram)); 96 GR_GL_CALL(gl, LinkProgram(shaderProgram));
114 97
115 // Check for linking errors 98 // Check for linking errors
116 GrGLint success = GR_GL_INIT_ZERO; 99 GrGLint success = GR_GL_INIT_ZERO;
117 GrGLchar infoLog[512]; 100 GrGLchar infoLog[512];
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 bm.setPixels(readback.get()); 166 bm.setPixels(readback.get());
184 167
185 if (!SkImageEncoder::EncodeFile(filename, bm, SkImageEncoder::kPNG_Type, 100 )) { 168 if (!SkImageEncoder::EncodeFile(filename, bm, SkImageEncoder::kPNG_Type, 100 )) {
186 SkDebugf("------ failed to encode %s\n", filename); 169 SkDebugf("------ failed to encode %s\n", filename);
187 remove(filename); // remove any partial file 170 remove(filename); // remove any partial file
188 return; 171 return;
189 } 172 }
190 } 173 }
191 174
192 #endif 175 #endif
OLDNEW
« no previous file with comments | « bench/GLBench.h ('k') | bench/GLInstancedArraysBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698