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/gl/GrGLProgramDesc.cpp

Issue 1593643002: Fix GL texture target program key (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: return uint8_t Created 4 years, 11 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 | « no previous file | no next file » | 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 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 "GrProcessor.h" 9 #include "GrProcessor.h"
10 #include "GrPipeline.h" 10 #include "GrPipeline.h"
11 #include "SkChecksum.h" 11 #include "SkChecksum.h"
12 #include "gl/GrGLDefines.h" 12 #include "gl/GrGLDefines.h"
13 #include "gl/GrGLTexture.h" 13 #include "gl/GrGLTexture.h"
14 #include "gl/GrGLTypes.h" 14 #include "gl/GrGLTypes.h"
15 #include "glsl/GrGLSLFragmentProcessor.h" 15 #include "glsl/GrGLSLFragmentProcessor.h"
16 #include "glsl/GrGLSLFragmentShaderBuilder.h" 16 #include "glsl/GrGLSLFragmentShaderBuilder.h"
17 #include "glsl/GrGLSLCaps.h" 17 #include "glsl/GrGLSLCaps.h"
18 18
19 static uint16_t texture_target_key(GrGLenum target) { 19 static uint8_t texture_target_key(GrGLenum target) {
20 SkASSERT((uint32_t)target < SK_MaxU16); 20 switch (target) {
21 return target; 21 case GR_GL_TEXTURE_2D:
22 return 0;
23 case GR_GL_TEXTURE_EXTERNAL:
24 return 1;
25 case GR_GL_TEXTURE_RECTANGLE:
26 return 2;
27 default:
28 SkFAIL("Unexpected texture target.");
29 return 0;
30 }
22 } 31 }
23 32
24 static void add_texture_key(GrProcessorKeyBuilder* b, const GrProcessor& proc, 33 static void add_texture_key(GrProcessorKeyBuilder* b, const GrProcessor& proc,
25 const GrGLSLCaps& caps) { 34 const GrGLSLCaps& caps) {
26 int numTextures = proc.numTextures(); 35 int numTextures = proc.numTextures();
27 // Need two bytes per key (swizzle and target). 36 // Need two bytes per key (swizzle and target).
28 int word32Count = (proc.numTextures() + 1) / 2; 37 int word32Count = (proc.numTextures() + 1) / 2;
29 if (0 == word32Count) { 38 if (0 == word32Count) {
30 return; 39 return;
31 } 40 }
32 uint16_t* k16 = SkTCast<uint16_t*>(b->add32n(word32Count)); 41 uint16_t* k16 = SkTCast<uint16_t*>(b->add32n(word32Count));
33 for (int i = 0; i < numTextures; ++i) { 42 for (int i = 0; i < numTextures; ++i) {
34 const GrTextureAccess& access = proc.textureAccess(i); 43 const GrTextureAccess& access = proc.textureAccess(i);
35 GrGLTexture* texture = static_cast<GrGLTexture*>(access.getTexture()); 44 GrGLTexture* texture = static_cast<GrGLTexture*>(access.getTexture());
36 k16[i] = caps.configTextureSwizzle(texture->config()).asKey() | 45 k16[i] = SkToU16(caps.configTextureSwizzle(texture->config()).asKey() |
37 (texture_target_key(texture->target()) << 16); 46 (texture_target_key(texture->target()) << 8));
38 } 47 }
39 // zero the last 16 bits if the number of textures is odd. 48 // zero the last 16 bits if the number of textures is odd.
40 if (numTextures & 0x1) { 49 if (numTextures & 0x1) {
41 k16[numTextures] = 0; 50 k16[numTextures] = 0;
42 } 51 }
43 } 52 }
44 53
45 /** 54 /**
46 * A function which emits a meta key into the key builder. This is required bec ause shader code may 55 * A function which emits a meta key into the key builder. This is required bec ause shader code may
47 * be dependent on properties of the effect that the effect itself doesn't use 56 * be dependent on properties of the effect that the effect itself doesn't use
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } else { 159 } else {
151 header->fIgnoresCoverage = 0; 160 header->fIgnoresCoverage = 0;
152 } 161 }
153 162
154 header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters(); 163 header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters();
155 header->fColorEffectCnt = pipeline.numColorFragmentProcessors(); 164 header->fColorEffectCnt = pipeline.numColorFragmentProcessors();
156 header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors(); 165 header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors();
157 glDesc->finalize(); 166 glDesc->finalize();
158 return true; 167 return true;
159 } 168 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698