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()); |