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

Side by Side Diff: src/gpu/gl/GrGLProgramDesc.cpp

Issue 1431433003: Move shader compiling to ProgramBuilder and various ShaderBuilder cleanups. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 "GrGLProgramDesc.h" 7 #include "GrGLProgramDesc.h"
8 8
9 #include "GrGLFragmentProcessor.h" 9 #include "GrGLFragmentProcessor.h"
10 #include "GrProcessor.h" 10 #include "GrProcessor.h"
11 #include "GrGLGpu.h" 11 #include "GrGLGpu.h"
12 #include "GrPipeline.h" 12 #include "GrPipeline.h"
13 #include "SkChecksum.h" 13 #include "SkChecksum.h"
14 #include "gl/builders/GrGLFragmentShaderBuilder.h" 14 #include "gl/builders/GrGLFragmentShaderBuilder.h"
15 15
16 /** 16 /**
17 * Do we need to either map r,g,b->a or a->r. configComponentMask indicates whic h channels are 17 * Do we need to either map r,g,b->a or a->r. configComponentMask indicates whic h channels are
18 * present in the texture's config. swizzleComponentMask indicates the channels present in the 18 * present in the texture's config. swizzleComponentMask indicates the channels present in the
19 * shader swizzle. 19 * shader swizzle.
20 */ 20 */
21 static bool swizzle_requires_alpha_remapping(const GrGLCaps& caps, 21 static bool swizzle_requires_alpha_remapping(const GrGLSLCaps& caps,
22 uint32_t configComponentMask, 22 uint32_t configComponentMask,
23 uint32_t swizzleComponentMask) { 23 uint32_t swizzleComponentMask) {
24 if (caps.textureSwizzleSupport()) { 24 if (caps.textureSwizzleSupport()) {
25 // Any remapping is handled using texture swizzling not shader modificat ions. 25 // Any remapping is handled using texture swizzling not shader modificat ions.
26 return false; 26 return false;
27 } 27 }
28 // check if the texture is alpha-only 28 // check if the texture is alpha-only
29 if (kA_GrColorComponentFlag == configComponentMask) { 29 if (kA_GrColorComponentFlag == configComponentMask) {
30 if (caps.textureRedSupport() && (kA_GrColorComponentFlag & swizzleCompon entMask)) { 30 if (caps.textureRedSupport() && (kA_GrColorComponentFlag & swizzleCompon entMask)) {
31 // we must map the swizzle 'a's to 'r'. 31 // we must map the swizzle 'a's to 'r'.
32 return true; 32 return true;
33 } 33 }
34 if (kRGB_GrColorComponentFlags & swizzleComponentMask) { 34 if (kRGB_GrColorComponentFlags & swizzleComponentMask) {
35 // The 'r', 'g', and/or 'b's must be mapped to 'a' according to our semantics that 35 // The 'r', 'g', and/or 'b's must be mapped to 'a' according to our semantics that
36 // alpha-only textures smear alpha across all four channels when rea d. 36 // alpha-only textures smear alpha across all four channels when rea d.
37 return true; 37 return true;
38 } 38 }
39 } 39 }
40 return false; 40 return false;
41 } 41 }
42 42
43 static uint32_t gen_texture_key(const GrProcessor& proc, const GrGLCaps& caps) { 43 static uint32_t gen_texture_key(const GrProcessor& proc, const GrGLCaps& caps) {
44 uint32_t key = 0; 44 uint32_t key = 0;
45 int numTextures = proc.numTextures(); 45 int numTextures = proc.numTextures();
46 for (int t = 0; t < numTextures; ++t) { 46 for (int t = 0; t < numTextures; ++t) {
47 const GrTextureAccess& access = proc.textureAccess(t); 47 const GrTextureAccess& access = proc.textureAccess(t);
48 uint32_t configComponentMask = GrPixelConfigComponentMask(access.getText ure()->config()); 48 uint32_t configComponentMask = GrPixelConfigComponentMask(access.getText ure()->config());
49 if (swizzle_requires_alpha_remapping(caps, configComponentMask, access.s wizzleMask())) { 49 if (swizzle_requires_alpha_remapping(*caps.glslCaps(),
50 configComponentMask,
51 access.swizzleMask())) {
50 key |= 1 << t; 52 key |= 1 << t;
51 } 53 }
52 } 54 }
53 return key; 55 return key;
54 } 56 }
55 57
56 /** 58 /**
57 * A function which emits a meta key into the key builder. This is required bec ause shader code may 59 * A function which emits a meta key into the key builder. This is required bec ause shader code may
58 * be dependent on properties of the effect that the effect itself doesn't use 60 * be dependent on properties of the effect that the effect itself doesn't use
59 * in its key (e.g. the pixel format of textures used). So we create a meta-key for 61 * in its key (e.g. the pixel format of textures used). So we create a meta-key for
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // --------DO NOT MOVE HEADER ABOVE THIS LINE------------------------------- ------------------- 154 // --------DO NOT MOVE HEADER ABOVE THIS LINE------------------------------- -------------------
153 // Because header is a pointer into the dynamic array, we can't push any new data into the key 155 // Because header is a pointer into the dynamic array, we can't push any new data into the key
154 // below here. 156 // below here.
155 KeyHeader* header = glDesc->atOffset<KeyHeader, kHeaderOffset>(); 157 KeyHeader* header = glDesc->atOffset<KeyHeader, kHeaderOffset>();
156 158
157 // make sure any padding in the header is zeroed. 159 // make sure any padding in the header is zeroed.
158 memset(header, 0, kHeaderSize); 160 memset(header, 0, kHeaderSize);
159 161
160 if (pipeline.readsFragPosition()) { 162 if (pipeline.readsFragPosition()) {
161 header->fFragPosKey = 163 header->fFragPosKey =
162 GrGLFragmentShaderBuilder::KeyForFragmentPosition(pipeline.getRe nderTarget(), 164 GrGLFragmentShaderBuilder::KeyForFragmentPosition(pipeline.getRe nderTarget());
163 gpu->glCaps()) ;
164 } else { 165 } else {
165 header->fFragPosKey = 0; 166 header->fFragPosKey = 0;
166 } 167 }
167 header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters(); 168 header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters();
168 header->fColorEffectCnt = pipeline.numColorFragmentProcessors(); 169 header->fColorEffectCnt = pipeline.numColorFragmentProcessors();
169 header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors(); 170 header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors();
170 glDesc->finalize(); 171 glDesc->finalize();
171 return true; 172 return true;
172 } 173 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698