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

Unified Diff: bench/GLBench.cpp

Issue 2288033003: Turned on SkSL->GLSL compiler (Closed)
Patch Set: changed <iostream> to <ostream> 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « bench/GLBench.h ('k') | bench/GLInstancedArraysBench.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/GLBench.cpp
diff --git a/bench/GLBench.cpp b/bench/GLBench.cpp
index 8cf41c205665100d173201a0925bd8fe4a154b0a..b6975508cfe7335b4bc4e5743348b181d80aaf50 100644
--- a/bench/GLBench.cpp
+++ b/bench/GLBench.cpp
@@ -11,7 +11,10 @@
#include "GrGpu.h"
#include "GrTest.h"
#include "gl/GrGLContext.h"
+#include "gl/builders/GrGLShaderStringBuilder.h"
+#include "SkSLCompiler.h"
#include <stdio.h>
+#include <string>
const GrGLContext* GLBench::getGLContext(SkCanvas* canvas) {
// This bench exclusively tests GL calls directly
@@ -61,13 +64,26 @@ void GLBench::onDraw(int loops, SkCanvas* canvas) {
canvas->getGrContext()->resetContext();
}
-GrGLuint GLBench::CompileShader(const GrGLInterface* gl, const char* shaderSrc, GrGLenum type) {
+GrGLuint GLBench::CompileShader(const GrGLContext* context, const char* sksl, GrGLenum type) {
+ const GrGLInterface* gl = context->interface();
+ std::string glsl;
+ bool result = context->compiler()->toGLSL(type == GR_GL_VERTEX_SHADER
+ ? SkSL::Program::kVertex_Kind
+ : SkSL::Program::kFragment_Kind,
+ std::string(sksl),
+ GrGLSkSLCapsForContext(*context),
+ &glsl);
+ if (!result) {
+ SkDebugf("SkSL compilation failed:\n%s\n%s\n", sksl,
+ context->compiler()->errorText().c_str());
+ }
GrGLuint shader;
// Create the shader object
GR_GL_CALL_RET(gl, shader, CreateShader(type));
// Load the shader source
- GR_GL_CALL(gl, ShaderSource(shader, 1, &shaderSrc, nullptr));
+ const char* glslPtr = glsl.c_str();
+ GR_GL_CALL(gl, ShaderSource(shader, 1, (const char**) &glslPtr, nullptr));
// Compile the shader
GR_GL_CALL(gl, CompileShader(shader));
@@ -84,10 +100,11 @@ GrGLuint GLBench::CompileShader(const GrGLInterface* gl, const char* shaderSrc,
return shader;
}
-GrGLuint GLBench::CreateProgram(const GrGLInterface* gl, const char* vshader, const char* fshader) {
-
- GrGLuint vertexShader = CompileShader(gl, vshader, GR_GL_VERTEX_SHADER);
- GrGLuint fragmentShader = CompileShader(gl, fshader, GR_GL_FRAGMENT_SHADER);
+GrGLuint GLBench::CreateProgram(const GrGLContext* context, const char* vshader,
+ const char* fshader) {
+ const GrGLInterface* gl = context->interface();
+ GrGLuint vertexShader = CompileShader(context, vshader, GR_GL_VERTEX_SHADER);
+ GrGLuint fragmentShader = CompileShader(context, fshader, GR_GL_FRAGMENT_SHADER);
GrGLuint shaderProgram;
GR_GL_CALL_RET(gl, shaderProgram, CreateProgram());
« 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