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 1673093002: Use noperspective interpolation for 2D draws (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fName -> fVsOut Created 4 years, 10 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/GrGLCaps.cpp ('k') | src/gpu/gl/GrGLVaryingHandler.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 "GrGLGLSL.h" 9 #include "GrGLGLSL.h"
10 #include "GrGLStencilAttachment.h" 10 #include "GrGLStencilAttachment.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 278 }
279 279
280 if (0 != fPLSSetupProgram.fProgram) { 280 if (0 != fPLSSetupProgram.fProgram) {
281 GL_CALL(DeleteProgram(fPLSSetupProgram.fProgram)); 281 GL_CALL(DeleteProgram(fPLSSetupProgram.fProgram));
282 } 282 }
283 283
284 delete fProgramCache; 284 delete fProgramCache;
285 } 285 }
286 286
287 void GrGLGpu::createPLSSetupProgram() { 287 void GrGLGpu::createPLSSetupProgram() {
288 const char* version = this->glCaps().glslCaps()->versionDeclString(); 288 const GrGLSLCaps* glslCaps = this->glCaps().glslCaps();
289 const char* version = glslCaps->versionDeclString();
289 290
290 GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttribute _TypeModifier); 291 GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttribute _TypeModifier);
291 GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType, 292 GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType,
292 GrShaderVar::kUniform_TypeModifier); 293 GrShaderVar::kUniform_TypeModifier);
293 GrGLSLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, GrShaderVar::kUnifo rm_TypeModifier); 294 GrGLSLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, GrShaderVar::kUnifo rm_TypeModifier);
294 GrGLSLShaderVar uTexture("u_texture", kSampler2D_GrSLType, GrShaderVar::kUni form_TypeModifier); 295 GrGLSLShaderVar uTexture("u_texture", kSampler2D_GrSLType, GrShaderVar::kUni form_TypeModifier);
295 GrGLSLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, GrShaderVar::kVaryi ngOut_TypeModifier); 296 GrGLSLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, GrShaderVar::kVaryi ngOut_TypeModifier);
296 297
297 SkString vshaderTxt(version); 298 SkString vshaderTxt(version);
298 aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); 299 if (glslCaps->noperspectiveInterpolationSupport()) {
300 if (const char* extension = glslCaps->noperspectiveInterpolationExtensio nString()) {
301 vshaderTxt.appendf("#extension %s : require\n", extension);
302 }
303 vTexCoord.addModifier("noperspective");
304 }
305 aVertex.appendDecl(glslCaps, &vshaderTxt);
299 vshaderTxt.append(";"); 306 vshaderTxt.append(";");
300 uTexCoordXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); 307 uTexCoordXform.appendDecl(glslCaps, &vshaderTxt);
301 vshaderTxt.append(";"); 308 vshaderTxt.append(";");
302 uPosXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); 309 uPosXform.appendDecl(glslCaps, &vshaderTxt);
303 vshaderTxt.append(";"); 310 vshaderTxt.append(";");
304 vTexCoord.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); 311 vTexCoord.appendDecl(glslCaps, &vshaderTxt);
305 vshaderTxt.append(";"); 312 vshaderTxt.append(";");
306 313
307 vshaderTxt.append( 314 vshaderTxt.append(
308 "// PLS Setup Program VS\n" 315 "// PLS Setup Program VS\n"
309 "void main() {" 316 "void main() {"
310 " gl_Position.xy = a_vertex * u_posXform.xy + u_posXform.zw;" 317 " gl_Position.xy = a_vertex * u_posXform.xy + u_posXform.zw;"
311 " gl_Position.zw = vec2(0, 1);" 318 " gl_Position.zw = vec2(0, 1);"
312 "}" 319 "}"
313 ); 320 );
314 321
315 SkString fshaderTxt(version); 322 SkString fshaderTxt(version);
323 if (glslCaps->noperspectiveInterpolationSupport()) {
324 if (const char* extension = glslCaps->noperspectiveInterpolationExtensio nString()) {
325 fshaderTxt.appendf("#extension %s : require\n", extension);
326 }
327 }
316 fshaderTxt.append("#extension "); 328 fshaderTxt.append("#extension ");
317 fshaderTxt.append(this->glCaps().glslCaps()->fbFetchExtensionString()); 329 fshaderTxt.append(glslCaps->fbFetchExtensionString());
318 fshaderTxt.append(" : require\n"); 330 fshaderTxt.append(" : require\n");
319 fshaderTxt.append("#extension GL_EXT_shader_pixel_local_storage : require\n" ); 331 fshaderTxt.append("#extension GL_EXT_shader_pixel_local_storage : require\n" );
320 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, 332 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCa ps, &fshaderTxt);
321 *this->glCaps().glslCaps(),
322 &fshaderTxt);
323 vTexCoord.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); 333 vTexCoord.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier);
324 vTexCoord.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); 334 vTexCoord.appendDecl(glslCaps, &fshaderTxt);
325 fshaderTxt.append(";"); 335 fshaderTxt.append(";");
326 uTexture.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); 336 uTexture.appendDecl(glslCaps, &fshaderTxt);
327 fshaderTxt.append(";"); 337 fshaderTxt.append(";");
328 338
329 fshaderTxt.appendf( 339 fshaderTxt.appendf(
330 "// PLS Setup Program FS\n" 340 "// PLS Setup Program FS\n"
331 GR_GL_PLS_PATH_DATA_DECL 341 GR_GL_PLS_PATH_DATA_DECL
332 "void main() {\n" 342 "void main() {\n"
333 " " GR_GL_PLS_DSTCOLOR_NAME " = gl_LastFragColorARM;\n" 343 " " GR_GL_PLS_DSTCOLOR_NAME " = gl_LastFragColorARM;\n"
334 " pls.windings = ivec4(0, 0, 0, 0);\n" 344 " pls.windings = ivec4(0, 0, 0, 0);\n"
335 "}" 345 "}"
336 ); 346 );
(...skipping 2879 matching lines...) Expand 10 before | Expand all | Expand 10 after
3216 return this->copySurfaceAsBlitFramebuffer(dst, src, srcRect, dstPoint); 3226 return this->copySurfaceAsBlitFramebuffer(dst, src, srcRect, dstPoint);
3217 } 3227 }
3218 3228
3219 return false; 3229 return false;
3220 } 3230 }
3221 3231
3222 void GrGLGpu::createCopyPrograms() { 3232 void GrGLGpu::createCopyPrograms() {
3223 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { 3233 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) {
3224 fCopyPrograms[i].fProgram = 0; 3234 fCopyPrograms[i].fProgram = 0;
3225 } 3235 }
3226 const char* version = this->glCaps().glslCaps()->versionDeclString(); 3236 const GrGLSLCaps* glslCaps = this->glCaps().glslCaps();
3237 const char* version = glslCaps->versionDeclString();
3227 static const GrSLType kSamplerTypes[3] = { kSampler2D_GrSLType, kSamplerExte rnal_GrSLType, 3238 static const GrSLType kSamplerTypes[3] = { kSampler2D_GrSLType, kSamplerExte rnal_GrSLType,
3228 kSampler2DRect_GrSLType }; 3239 kSampler2DRect_GrSLType };
3229 SkASSERT(3 == SK_ARRAY_COUNT(fCopyPrograms)); 3240 SkASSERT(3 == SK_ARRAY_COUNT(fCopyPrograms));
3230 for (int i = 0; i < 3; ++i) { 3241 for (int i = 0; i < 3; ++i) {
3231 if (kSamplerExternal_GrSLType == kSamplerTypes[i] && 3242 if (kSamplerExternal_GrSLType == kSamplerTypes[i] &&
3232 !this->glCaps().externalTextureSupport()) { 3243 !this->glCaps().externalTextureSupport()) {
3233 continue; 3244 continue;
3234 } 3245 }
3235 if (kSampler2DRect_GrSLType == kSamplerTypes[i] && 3246 if (kSampler2DRect_GrSLType == kSamplerTypes[i] &&
3236 !this->glCaps().rectangleTextureSupport()) { 3247 !this->glCaps().rectangleTextureSupport()) {
3237 continue; 3248 continue;
3238 } 3249 }
3239 GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttri bute_TypeModifier); 3250 GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttri bute_TypeModifier);
3240 GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType, 3251 GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType,
3241 GrShaderVar::kUniform_TypeModifier); 3252 GrShaderVar::kUniform_TypeModifier);
3242 GrGLSLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, 3253 GrGLSLShaderVar uPosXform("u_posXform", kVec4f_GrSLType,
3243 GrShaderVar::kUniform_TypeModifier); 3254 GrShaderVar::kUniform_TypeModifier);
3244 GrGLSLShaderVar uTexture("u_texture", kSamplerTypes[i], 3255 GrGLSLShaderVar uTexture("u_texture", kSamplerTypes[i],
3245 GrShaderVar::kUniform_TypeModifier); 3256 GrShaderVar::kUniform_TypeModifier);
3246 GrGLSLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, 3257 GrGLSLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType,
3247 GrShaderVar::kVaryingOut_TypeModifier); 3258 GrShaderVar::kVaryingOut_TypeModifier);
3248 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, 3259 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType,
3249 GrShaderVar::kOut_TypeModifier); 3260 GrShaderVar::kOut_TypeModifier);
3250 3261
3251 SkString vshaderTxt(version); 3262 SkString vshaderTxt(version);
3252 aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); 3263 if (glslCaps->noperspectiveInterpolationSupport()) {
3264 if (const char* extension = glslCaps->noperspectiveInterpolationExte nsionString()) {
3265 vshaderTxt.appendf("#extension %s : require\n", extension);
3266 }
3267 vTexCoord.addModifier("noperspective");
3268 }
3269
3270 aVertex.appendDecl(glslCaps, &vshaderTxt);
3253 vshaderTxt.append(";"); 3271 vshaderTxt.append(";");
3254 uTexCoordXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); 3272 uTexCoordXform.appendDecl(glslCaps, &vshaderTxt);
3255 vshaderTxt.append(";"); 3273 vshaderTxt.append(";");
3256 uPosXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); 3274 uPosXform.appendDecl(glslCaps, &vshaderTxt);
3257 vshaderTxt.append(";"); 3275 vshaderTxt.append(";");
3258 vTexCoord.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); 3276 vTexCoord.appendDecl(glslCaps, &vshaderTxt);
3259 vshaderTxt.append(";"); 3277 vshaderTxt.append(";");
3260 3278
3261 vshaderTxt.append( 3279 vshaderTxt.append(
3262 "// Copy Program VS\n" 3280 "// Copy Program VS\n"
3263 "void main() {" 3281 "void main() {"
3264 " v_texCoord = a_vertex.xy * u_texCoordXform.xy + u_texCoordXform.z w;" 3282 " v_texCoord = a_vertex.xy * u_texCoordXform.xy + u_texCoordXform.z w;"
3265 " gl_Position.xy = a_vertex * u_posXform.xy + u_posXform.zw;" 3283 " gl_Position.xy = a_vertex * u_posXform.xy + u_posXform.zw;"
3266 " gl_Position.zw = vec2(0, 1);" 3284 " gl_Position.zw = vec2(0, 1);"
3267 "}" 3285 "}"
3268 ); 3286 );
3269 3287
3270 SkString fshaderTxt(version); 3288 SkString fshaderTxt(version);
3289 if (glslCaps->noperspectiveInterpolationSupport()) {
3290 if (const char* extension = glslCaps->noperspectiveInterpolationExte nsionString()) {
3291 fshaderTxt.appendf("#extension %s : require\n", extension);
3292 }
3293 }
3271 if (kSamplerTypes[i] == kSamplerExternal_GrSLType) { 3294 if (kSamplerTypes[i] == kSamplerExternal_GrSLType) {
3272 fshaderTxt.appendf("#extension %s : require\n", 3295 fshaderTxt.appendf("#extension %s : require\n",
3273 this->glCaps().glslCaps()->externalTextureExtensi onString()); 3296 glslCaps->externalTextureExtensionString());
3274 } 3297 }
3275 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, 3298 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *gl slCaps,
3276 *this->glCaps().glslCaps(),
3277 &fshaderTxt); 3299 &fshaderTxt);
3278 vTexCoord.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); 3300 vTexCoord.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier);
3279 vTexCoord.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); 3301 vTexCoord.appendDecl(glslCaps, &fshaderTxt);
3280 fshaderTxt.append(";"); 3302 fshaderTxt.append(";");
3281 uTexture.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); 3303 uTexture.appendDecl(glslCaps, &fshaderTxt);
3282 fshaderTxt.append(";"); 3304 fshaderTxt.append(";");
3283 const char* fsOutName; 3305 const char* fsOutName;
3284 if (this->glCaps().glslCaps()->mustDeclareFragmentShaderOutput()) { 3306 if (glslCaps->mustDeclareFragmentShaderOutput()) {
3285 oFragColor.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); 3307 oFragColor.appendDecl(glslCaps, &fshaderTxt);
3286 fshaderTxt.append(";"); 3308 fshaderTxt.append(";");
3287 fsOutName = oFragColor.c_str(); 3309 fsOutName = oFragColor.c_str();
3288 } else { 3310 } else {
3289 fsOutName = "gl_FragColor"; 3311 fsOutName = "gl_FragColor";
3290 } 3312 }
3291 fshaderTxt.appendf( 3313 fshaderTxt.appendf(
3292 "// Copy Program FS\n" 3314 "// Copy Program FS\n"
3293 "void main() {" 3315 "void main() {"
3294 " %s = %s(u_texture, v_texCoord);" 3316 " %s = %s(u_texture, v_texCoord);"
3295 "}", 3317 "}",
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
3843 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || 3865 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() ||
3844 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { 3866 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) {
3845 copyParams->fFilter = GrTextureParams::kNone_FilterMode; 3867 copyParams->fFilter = GrTextureParams::kNone_FilterMode;
3846 copyParams->fWidth = texture->width(); 3868 copyParams->fWidth = texture->width();
3847 copyParams->fHeight = texture->height(); 3869 copyParams->fHeight = texture->height();
3848 return true; 3870 return true;
3849 } 3871 }
3850 } 3872 }
3851 return false; 3873 return false;
3852 } 3874 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLCaps.cpp ('k') | src/gpu/gl/GrGLVaryingHandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698