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

Side by Side Diff: src/gpu/GrProgramDesc.cpp

Issue 2318523006: Merge GrGLSLProgramDesc into GrProgramDesc (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update comments Created 4 years, 3 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/GrProgramDesc.h ('k') | src/gpu/gl/GrGLGpuProgramCache.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 2016 Google Inc. 2 * Copyright 2016 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 #include "GrGLSLProgramDesc.h" 7 #include "GrProgramDesc.h"
8 8
9 #include "GrProcessor.h" 9 #include "GrProcessor.h"
10 #include "GrPipeline.h" 10 #include "GrPipeline.h"
11 #include "GrRenderTargetPriv.h" 11 #include "GrRenderTargetPriv.h"
12 #include "SkChecksum.h" 12 #include "SkChecksum.h"
13 #include "glsl/GrGLSLFragmentProcessor.h" 13 #include "glsl/GrGLSLFragmentProcessor.h"
14 #include "glsl/GrGLSLFragmentShaderBuilder.h" 14 #include "glsl/GrGLSLFragmentShaderBuilder.h"
15 #include "glsl/GrGLSLCaps.h" 15 #include "glsl/GrGLSLCaps.h"
16 16
17 static uint16_t sampler_key(GrSLType samplerType, GrPixelConfig config, GrShader Flags visibility, 17 static uint16_t sampler_key(GrSLType samplerType, GrPixelConfig config, GrShader Flags visibility,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 return false; 97 return false;
98 } 98 }
99 } 99 }
100 100
101 fp.getGLSLProcessorKey(glslCaps, b); 101 fp.getGLSLProcessorKey(glslCaps, b);
102 102
103 return gen_meta_key(fp, glslCaps, primProc.getTransformKey(fp.coordTransform s(), 103 return gen_meta_key(fp, glslCaps, primProc.getTransformKey(fp.coordTransform s(),
104 fp.numTransformsE xclChildren()), b); 104 fp.numTransformsE xclChildren()), b);
105 } 105 }
106 106
107 bool GrGLSLProgramDescBuilder::Build(GrProgramDesc* desc, 107 bool GrProgramDesc::Build(GrProgramDesc* desc,
108 const GrPrimitiveProcessor& primProc, 108 const GrPrimitiveProcessor& primProc,
109 const GrPipeline& pipeline, 109 const GrPipeline& pipeline,
110 const GrGLSLCaps& glslCaps) { 110 const GrGLSLCaps& glslCaps) {
111 // The descriptor is used as a cache key. Thus when a field of the 111 // The descriptor is used as a cache key. Thus when a field of the
112 // descriptor will not affect program generation (because of the attribute 112 // descriptor will not affect program generation (because of the attribute
113 // bindings in use or other descriptor field settings) it should be set 113 // bindings in use or other descriptor field settings) it should be set
114 // to a canonical value to avoid duplicate programs with different keys. 114 // to a canonical value to avoid duplicate programs with different keys.
115 115
116 GrGLSLProgramDesc* glDesc = (GrGLSLProgramDesc*)desc;
117
118 GR_STATIC_ASSERT(0 == kProcessorKeysOffset % sizeof(uint32_t)); 116 GR_STATIC_ASSERT(0 == kProcessorKeysOffset % sizeof(uint32_t));
119 // Make room for everything up to the effect keys. 117 // Make room for everything up to the effect keys.
120 glDesc->key().reset(); 118 desc->key().reset();
121 glDesc->key().push_back_n(kProcessorKeysOffset); 119 desc->key().push_back_n(kProcessorKeysOffset);
122 120
123 GrProcessorKeyBuilder b(&glDesc->key()); 121 GrProcessorKeyBuilder b(&desc->key());
124 122
125 primProc.getGLSLProcessorKey(glslCaps, &b); 123 primProc.getGLSLProcessorKey(glslCaps, &b);
126 if (!gen_meta_key(primProc, glslCaps, 0, &b)) { 124 if (!gen_meta_key(primProc, glslCaps, 0, &b)) {
127 glDesc->key().reset(); 125 desc->key().reset();
128 return false; 126 return false;
129 } 127 }
130 GrProcessor::RequiredFeatures requiredFeatures = primProc.requiredFeatures() ; 128 GrProcessor::RequiredFeatures requiredFeatures = primProc.requiredFeatures() ;
131 129
132 for (int i = 0; i < pipeline.numFragmentProcessors(); ++i) { 130 for (int i = 0; i < pipeline.numFragmentProcessors(); ++i) {
133 const GrFragmentProcessor& fp = pipeline.getFragmentProcessor(i); 131 const GrFragmentProcessor& fp = pipeline.getFragmentProcessor(i);
134 if (!gen_frag_proc_and_meta_keys(primProc, fp, glslCaps, &b)) { 132 if (!gen_frag_proc_and_meta_keys(primProc, fp, glslCaps, &b)) {
135 glDesc->key().reset(); 133 desc->key().reset();
136 return false; 134 return false;
137 } 135 }
138 requiredFeatures |= fp.requiredFeatures(); 136 requiredFeatures |= fp.requiredFeatures();
139 } 137 }
140 138
141 const GrXferProcessor& xp = pipeline.getXferProcessor(); 139 const GrXferProcessor& xp = pipeline.getXferProcessor();
142 xp.getGLSLProcessorKey(glslCaps, &b); 140 xp.getGLSLProcessorKey(glslCaps, &b);
143 if (!gen_meta_key(xp, glslCaps, 0, &b)) { 141 if (!gen_meta_key(xp, glslCaps, 0, &b)) {
144 glDesc->key().reset(); 142 desc->key().reset();
145 return false; 143 return false;
146 } 144 }
147 requiredFeatures |= xp.requiredFeatures(); 145 requiredFeatures |= xp.requiredFeatures();
148 146
149 // --------DO NOT MOVE HEADER ABOVE THIS LINE------------------------------- ------------------- 147 // --------DO NOT MOVE HEADER ABOVE THIS LINE------------------------------- -------------------
150 // Because header is a pointer into the dynamic array, we can't push any new data into the key 148 // Because header is a pointer into the dynamic array, we can't push any new data into the key
151 // below here. 149 // below here.
152 KeyHeader* header = glDesc->atOffset<KeyHeader, kHeaderOffset>(); 150 KeyHeader* header = desc->atOffset<KeyHeader, kHeaderOffset>();
153 151
154 // make sure any padding in the header is zeroed. 152 // make sure any padding in the header is zeroed.
155 memset(header, 0, kHeaderSize); 153 memset(header, 0, kHeaderSize);
156 154
157 GrRenderTarget* rt = pipeline.getRenderTarget(); 155 GrRenderTarget* rt = pipeline.getRenderTarget();
158 156
159 if (requiredFeatures & (GrProcessor::kFragmentPosition_RequiredFeature | 157 if (requiredFeatures & (GrProcessor::kFragmentPosition_RequiredFeature |
160 GrProcessor::kSampleLocations_RequiredFeature)) { 158 GrProcessor::kSampleLocations_RequiredFeature)) {
161 header->fSurfaceOriginKey = GrGLSLFragmentShaderBuilder::KeyForSurfaceOr igin(rt->origin()); 159 header->fSurfaceOriginKey = GrGLSLFragmentShaderBuilder::KeyForSurfaceOr igin(rt->origin());
162 } else { 160 } else {
(...skipping 12 matching lines...) Expand all
175 173
176 if (pipeline.ignoresCoverage()) { 174 if (pipeline.ignoresCoverage()) {
177 header->fIgnoresCoverage = 1; 175 header->fIgnoresCoverage = 1;
178 } else { 176 } else {
179 header->fIgnoresCoverage = 0; 177 header->fIgnoresCoverage = 0;
180 } 178 }
181 179
182 header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters(); 180 header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters();
183 header->fColorEffectCnt = pipeline.numColorFragmentProcessors(); 181 header->fColorEffectCnt = pipeline.numColorFragmentProcessors();
184 header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors(); 182 header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors();
185 glDesc->finalize();
186 return true; 183 return true;
187 } 184 }
OLDNEW
« no previous file with comments | « src/gpu/GrProgramDesc.h ('k') | src/gpu/gl/GrGLGpuProgramCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698