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/gpu/gl/GrGLGpu.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 unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLContext.cpp ('k') | src/gpu/gl/builders/GrGLShaderStringBuilder.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 2011 Google Inc. 2 * Copyright 2011 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 "GrGLGpu.h" 8 #include "GrGLGpu.h"
9 #include "GrGLBuffer.h" 9 #include "GrGLBuffer.h"
10 #include "GrGLGLSL.h" 10 #include "GrGLGLSL.h"
(...skipping 3772 matching lines...) Expand 10 before | Expand all | Expand 10 after
3783 fshaderTxt.appendf("#extension %s : require\n", 3783 fshaderTxt.appendf("#extension %s : require\n",
3784 glslCaps->externalTextureExtensionString()); 3784 glslCaps->externalTextureExtensionString());
3785 } 3785 }
3786 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCa ps, 3786 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCa ps,
3787 &fshaderTxt); 3787 &fshaderTxt);
3788 vTexCoord.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); 3788 vTexCoord.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier);
3789 vTexCoord.appendDecl(glslCaps, &fshaderTxt); 3789 vTexCoord.appendDecl(glslCaps, &fshaderTxt);
3790 fshaderTxt.append(";"); 3790 fshaderTxt.append(";");
3791 uTexture.appendDecl(glslCaps, &fshaderTxt); 3791 uTexture.appendDecl(glslCaps, &fshaderTxt);
3792 fshaderTxt.append(";"); 3792 fshaderTxt.append(";");
3793 const char* fsOutName;
3794 if (glslCaps->mustDeclareFragmentShaderOutput()) {
3795 oFragColor.appendDecl(glslCaps, &fshaderTxt);
3796 fshaderTxt.append(";");
3797 fsOutName = oFragColor.c_str();
3798 } else {
3799 fsOutName = "gl_FragColor";
3800 }
3801 fshaderTxt.appendf( 3793 fshaderTxt.appendf(
3802 "// Copy Program FS\n" 3794 "// Copy Program FS\n"
3803 "void main() {" 3795 "void main() {"
3804 " %s = %s(u_texture, v_texCoord);" 3796 " sk_FragColor = %s(u_texture, v_texCoord);"
3805 "}", 3797 "}",
3806 fsOutName,
3807 GrGLSLTexture2DFunctionName(kVec2f_GrSLType, kSamplerTypes[progIdx], thi s->glslGeneration()) 3798 GrGLSLTexture2DFunctionName(kVec2f_GrSLType, kSamplerTypes[progIdx], thi s->glslGeneration())
3808 ); 3799 );
3809 3800
3810 const char* str; 3801 const char* str;
3811 GrGLint length; 3802 GrGLint length;
3812 3803
3813 str = vshaderTxt.c_str(); 3804 str = vshaderTxt.c_str();
3814 length = SkToInt(vshaderTxt.size()); 3805 length = SkToInt(vshaderTxt.size());
3815 GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fCopyPrograms[pro gIdx].fProgram, 3806 GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fCopyPrograms[pro gIdx].fProgram,
3816 GR_GL_VERTEX_SHADER, &str, &le ngth, 1, 3807 GR_GL_VERTEX_SHADER, &str, &le ngth, 1,
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
3929 } 3920 }
3930 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCa ps, 3921 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCa ps,
3931 &fshaderTxt); 3922 &fshaderTxt);
3932 for (int i = 0; i < numTaps; ++i) { 3923 for (int i = 0; i < numTaps; ++i) {
3933 vTexCoords[i].setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); 3924 vTexCoords[i].setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier);
3934 vTexCoords[i].appendDecl(glslCaps, &fshaderTxt); 3925 vTexCoords[i].appendDecl(glslCaps, &fshaderTxt);
3935 fshaderTxt.append(";"); 3926 fshaderTxt.append(";");
3936 } 3927 }
3937 uTexture.appendDecl(glslCaps, &fshaderTxt); 3928 uTexture.appendDecl(glslCaps, &fshaderTxt);
3938 fshaderTxt.append(";"); 3929 fshaderTxt.append(";");
3939 const char* fsOutName;
3940 if (glslCaps->mustDeclareFragmentShaderOutput()) {
3941 oFragColor.appendDecl(glslCaps, &fshaderTxt);
3942 fshaderTxt.append(";");
3943 fsOutName = oFragColor.c_str();
3944 } else {
3945 fsOutName = "gl_FragColor";
3946 }
3947 const char* sampleFunction = GrGLSLTexture2DFunctionName(kVec2f_GrSLType, 3930 const char* sampleFunction = GrGLSLTexture2DFunctionName(kVec2f_GrSLType,
3948 kTexture2DSampler_G rSLType, 3931 kTexture2DSampler_G rSLType,
3949 this->glslGeneratio n()); 3932 this->glslGeneratio n());
3950 fshaderTxt.append( 3933 fshaderTxt.append(
3951 "// Mipmap Program FS\n" 3934 "// Mipmap Program FS\n"
3952 "void main() {" 3935 "void main() {"
3953 ); 3936 );
3954 3937
3955 if (oddWidth && oddHeight) { 3938 if (oddWidth && oddHeight) {
3956 fshaderTxt.appendf( 3939 fshaderTxt.appendf(
3957 " %s = (%s(u_texture, v_texCoord0) + %s(u_texture, v_texCoord1) + " 3940 " sk_FragColor = (%s(u_texture, v_texCoord0) + %s(u_texture, v_texC oord1) + "
3958 " %s(u_texture, v_texCoord2) + %s(u_texture, v_texCoord3)) * 0.25;", 3941 " %s(u_texture, v_texCoord2) + %s(u_texture, v_texC oord3)) * 0.25;",
3959 fsOutName, sampleFunction, sampleFunction, sampleFunction, sampleFun ction 3942 sampleFunction, sampleFunction, sampleFunction, sampleFunction
3960 ); 3943 );
3961 } else if (oddWidth || oddHeight) { 3944 } else if (oddWidth || oddHeight) {
3962 fshaderTxt.appendf( 3945 fshaderTxt.appendf(
3963 " %s = (%s(u_texture, v_texCoord0) + %s(u_texture, v_texCoord1)) * 0.5;", 3946 " sk_FragColor = (%s(u_texture, v_texCoord0) + %s(u_texture, v_texC oord1)) * 0.5;",
3964 fsOutName, sampleFunction, sampleFunction 3947 sampleFunction, sampleFunction
3965 ); 3948 );
3966 } else { 3949 } else {
3967 fshaderTxt.appendf( 3950 fshaderTxt.appendf(
3968 " %s = %s(u_texture, v_texCoord0);", 3951 " sk_FragColor = %s(u_texture, v_texCoord0);",
3969 fsOutName, sampleFunction 3952 sampleFunction
3970 ); 3953 );
3971 } 3954 }
3972 3955
3973 fshaderTxt.append("}"); 3956 fshaderTxt.append("}");
3974 3957
3975 const char* str; 3958 const char* str;
3976 GrGLint length; 3959 GrGLint length;
3977 3960
3978 str = vshaderTxt.c_str(); 3961 str = vshaderTxt.c_str();
3979 length = SkToInt(vshaderTxt.size()); 3962 length = SkToInt(vshaderTxt.size());
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
4046 ); 4029 );
4047 4030
4048 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut _TypeModifier); 4031 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut _TypeModifier);
4049 4032
4050 SkString fshaderTxt(version); 4033 SkString fshaderTxt(version);
4051 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, 4034 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision,
4052 *this->glCaps().glslCaps(), 4035 *this->glCaps().glslCaps(),
4053 &fshaderTxt); 4036 &fshaderTxt);
4054 uColor.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); 4037 uColor.appendDecl(this->glCaps().glslCaps(), &fshaderTxt);
4055 fshaderTxt.append(";"); 4038 fshaderTxt.append(";");
4056 const char* fsOutName;
4057 if (this->glCaps().glslCaps()->mustDeclareFragmentShaderOutput()) {
4058 oFragColor.appendDecl(this->glCaps().glslCaps(), &fshaderTxt);
4059 fshaderTxt.append(";");
4060 fsOutName = oFragColor.c_str();
4061 } else {
4062 fsOutName = "gl_FragColor";
4063 }
4064 fshaderTxt.appendf( 4039 fshaderTxt.appendf(
4065 "// Write Rect Program FS\n" 4040 "// Write Rect Program FS\n"
4066 "void main() {" 4041 "void main() {"
4067 " %s = %s;" 4042 " sk_FragColor = %s;"
4068 "}", 4043 "}",
4069 fsOutName,
4070 uColor.c_str() 4044 uColor.c_str()
4071 ); 4045 );
4072 4046
4073 const char* str; 4047 const char* str;
4074 GrGLint length; 4048 GrGLint length;
4075 4049
4076 str = vshaderTxt.c_str(); 4050 str = vshaderTxt.c_str();
4077 length = SkToInt(vshaderTxt.size()); 4051 length = SkToInt(vshaderTxt.size());
4078 GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fWireRectProgram. fProgram, 4052 GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fWireRectProgram. fProgram,
4079 GR_GL_VERTEX_SHADER, &str, &le ngth, 1, 4053 GR_GL_VERTEX_SHADER, &str, &le ngth, 1,
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
4703 4677
4704 bool GrGLGpu::waitFence(GrFence fence, uint64_t timeout) const { 4678 bool GrGLGpu::waitFence(GrFence fence, uint64_t timeout) const {
4705 GrGLenum result; 4679 GrGLenum result;
4706 GL_CALL_RET(result, ClientWaitSync((GrGLsync)fence, GR_GL_SYNC_FLUSH_COMMAND S_BIT, timeout)); 4680 GL_CALL_RET(result, ClientWaitSync((GrGLsync)fence, GR_GL_SYNC_FLUSH_COMMAND S_BIT, timeout));
4707 return (GR_GL_CONDITION_SATISFIED == result); 4681 return (GR_GL_CONDITION_SATISFIED == result);
4708 } 4682 }
4709 4683
4710 void GrGLGpu::deleteFence(GrFence fence) const { 4684 void GrGLGpu::deleteFence(GrFence fence) const {
4711 GL_CALL(DeleteSync((GrGLsync)fence)); 4685 GL_CALL(DeleteSync((GrGLsync)fence));
4712 } 4686 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLContext.cpp ('k') | src/gpu/gl/builders/GrGLShaderStringBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698