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

Side by Side Diff: src/gpu/glsl/GrGLSL.h

Issue 2143143002: Add Texture2D and Sampler GrSLTypes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nits Created 4 years, 5 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/GrGLTexture.cpp ('k') | src/gpu/glsl/GrGLSLProgramBuilder.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 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 #ifndef GrGLSL_DEFINED 8 #ifndef GrGLSL_DEFINED
9 #define GrGLSL_DEFINED 9 #define GrGLSL_DEFINED
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 }; 51 };
52 52
53 bool GrGLSLSupportsNamedFragmentShaderOutputs(GrGLSLGeneration); 53 bool GrGLSLSupportsNamedFragmentShaderOutputs(GrGLSLGeneration);
54 54
55 /** 55 /**
56 * Gets the name of the function that should be used to sample a 2D texture. Coo rd type is used 56 * Gets the name of the function that should be used to sample a 2D texture. Coo rd type is used
57 * to indicate whether the texture is sampled using projective textured (kVec3f) or not (kVec2f). 57 * to indicate whether the texture is sampled using projective textured (kVec3f) or not (kVec2f).
58 */ 58 */
59 inline const char* GrGLSLTexture2DFunctionName(GrSLType coordType, GrSLType samp lerType, 59 inline const char* GrGLSLTexture2DFunctionName(GrSLType coordType, GrSLType samp lerType,
60 GrGLSLGeneration glslGen) { 60 GrGLSLGeneration glslGen) {
61 SkASSERT(GrSLTypeIs2DTextureType(samplerType)); 61 SkASSERT(GrSLTypeIs2DCombinedSamplerType(samplerType));
62 SkASSERT(kVec2f_GrSLType == coordType || kVec3f_GrSLType == coordType); 62 SkASSERT(kVec2f_GrSLType == coordType || kVec3f_GrSLType == coordType);
63 // GL_TEXTURE_RECTANGLE_ARB is written against OpenGL 2.0/GLSL 1.10. At that time there were 63 // GL_TEXTURE_RECTANGLE_ARB is written against OpenGL 2.0/GLSL 1.10. At that time there were
64 // separate texture*() functions. In OpenGL 3.0/GLSL 1.30 the different text ure*() functions 64 // separate texture*() functions. In OpenGL 3.0/GLSL 1.30 the different text ure*() functions
65 // were deprecated in favor or the unified texture() function. RECTANGLE tex tures became 65 // were deprecated in favor or the unified texture() function. RECTANGLE tex tures became
66 // standard in OpenGL 3.2/GLSL 1.50 and use texture(). It isn't completely c lear what function 66 // standard in OpenGL 3.2/GLSL 1.50 and use texture(). It isn't completely c lear what function
67 // should be used for RECTANGLE textures in GLSL versions >= 1.30 && < 1.50. We're going with 67 // should be used for RECTANGLE textures in GLSL versions >= 1.30 && < 1.50. We're going with
68 // using texture(). 68 // using texture().
69 if (glslGen >= k130_GrGLSLGeneration) { 69 if (glslGen >= k130_GrGLSLGeneration) {
70 return (kVec2f_GrSLType == coordType) ? "texture" : "textureProj"; 70 return (kVec2f_GrSLType == coordType) ? "texture" : "textureProj";
71 } 71 }
72 if (kVec2f_GrSLType == coordType) { 72 if (kVec2f_GrSLType == coordType) {
73 return (samplerType == kSampler2DRect_GrSLType) ? "texture2DRect" : "tex ture2D"; 73 return (samplerType == kTexture2DRectSampler_GrSLType) ? "texture2DRect" : "texture2D";
74 } else { 74 } else {
75 return (samplerType == kSampler2DRect_GrSLType) ? "texture2DRectProj" : "texture2DProj"; 75 return (samplerType == kTexture2DRectSampler_GrSLType) ? "texture2DRectP roj"
76 : "texture2DProj" ;
76 } 77 }
77 } 78 }
78 79
79 /** 80 /**
80 * Adds a line of GLSL code to declare the default precision for float types. 81 * Adds a line of GLSL code to declare the default precision for float types.
81 */ 82 */
82 void GrGLSLAppendDefaultFloatPrecisionDeclaration(GrSLPrecision, 83 void GrGLSLAppendDefaultFloatPrecisionDeclaration(GrSLPrecision,
83 const GrGLSLCaps& glslCaps, 84 const GrGLSLCaps& glslCaps,
84 SkString* out); 85 SkString* out);
85 86
(...skipping 28 matching lines...) Expand all
114 case kVec3f_GrSLType: 115 case kVec3f_GrSLType:
115 return "vec3"; 116 return "vec3";
116 case kVec4f_GrSLType: 117 case kVec4f_GrSLType:
117 return "vec4"; 118 return "vec4";
118 case kMat22f_GrSLType: 119 case kMat22f_GrSLType:
119 return "mat2"; 120 return "mat2";
120 case kMat33f_GrSLType: 121 case kMat33f_GrSLType:
121 return "mat3"; 122 return "mat3";
122 case kMat44f_GrSLType: 123 case kMat44f_GrSLType:
123 return "mat4"; 124 return "mat4";
124 case kSampler2D_GrSLType: 125 case kTexture2DSampler_GrSLType:
125 return "sampler2D"; 126 return "sampler2D";
126 case kSamplerExternal_GrSLType: 127 case kTextureExternalSampler_GrSLType:
127 return "samplerExternalOES"; 128 return "samplerExternalOES";
128 case kSampler2DRect_GrSLType: 129 case kTexture2DRectSampler_GrSLType:
129 return "sampler2DRect"; 130 return "sampler2DRect";
130 case kSamplerBuffer_GrSLType: 131 case kTextureBufferSampler_GrSLType:
131 return "samplerBuffer"; 132 return "samplerBuffer";
132 case kBool_GrSLType: 133 case kBool_GrSLType:
133 return "bool"; 134 return "bool";
134 case kInt_GrSLType: 135 case kInt_GrSLType:
135 return "int"; 136 return "int";
136 case kUint_GrSLType: 137 case kUint_GrSLType:
137 return "uint"; 138 return "uint";
139 case kTexture2D_GrSLType:
140 return "texture2D";
141 case kSampler_GrSLType:
142 return "sampler";
138 default: 143 default:
139 SkFAIL("Unknown shader var type."); 144 SkFAIL("Unknown shader var type.");
140 return ""; // suppress warning 145 return ""; // suppress warning
141 } 146 }
142 } 147 }
143 148
144 /** A generic base-class representing a GLSL expression. 149 /** A generic base-class representing a GLSL expression.
145 * The instance can be a variable name, expression or vecN(0) or vecN(1). Does s imple constant 150 * The instance can be a variable name, expression or vecN(0) or vecN(1). Does s imple constant
146 * folding with help of 1 and 0. 151 * folding with help of 1 and 0.
147 * 152 *
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 381
377 /** 382 /**
378 * Does an inplace mul, *=, of vec4VarName by mulFactor. 383 * Does an inplace mul, *=, of vec4VarName by mulFactor.
379 * A semicolon is added after the assignment. 384 * A semicolon is added after the assignment.
380 */ 385 */
381 void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSL Expr4& mulFactor); 386 void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSL Expr4& mulFactor);
382 387
383 #include "GrGLSL_impl.h" 388 #include "GrGLSL_impl.h"
384 389
385 #endif 390 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLTexture.cpp ('k') | src/gpu/glsl/GrGLSLProgramBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698