OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrVkProgramDesc.h" | 7 #include "GrVkProgramDesc.h" |
8 | 8 |
9 //#include "GrVkProcessor.h" | 9 //#include "GrVkProcessor.h" |
10 #include "GrProcessor.h" | 10 #include "GrProcessor.h" |
11 #include "GrPipeline.h" | 11 #include "GrPipeline.h" |
12 #include "GrRenderTargetPriv.h" | 12 #include "GrRenderTargetPriv.h" |
13 #include "GrVkGpu.h" | 13 #include "GrVkGpu.h" |
14 #include "GrVkUtil.h" | 14 #include "GrVkUtil.h" |
15 #include "SkChecksum.h" | 15 #include "SkChecksum.h" |
16 #include "glsl/GrGLSLFragmentProcessor.h" | 16 #include "glsl/GrGLSLFragmentProcessor.h" |
17 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 17 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
18 #include "glsl/GrGLSLCaps.h" | 18 #include "glsl/GrGLSLCaps.h" |
19 | 19 |
20 #include "shaderc/shaderc.h" | 20 #include "shaderc/shaderc.h" |
21 | 21 |
22 static void add_texture_key(GrProcessorKeyBuilder* b, const GrProcessor& proc, | 22 static void add_texture_key(GrProcessorKeyBuilder* b, const GrProcessor& proc, |
23 const GrGLSLCaps& caps) { | 23 const GrGLSLCaps& caps) { |
24 int numTextures = proc.numTextures(); | 24 int numTextures = proc.numTextures(); |
25 // Need two bytes per key (swizzle and target). | 25 // Need two bytes per key (swizzle, sampler type, and precision). |
26 int word32Count = (proc.numTextures() + 1) / 2; | 26 int word32Count = (proc.numTextures() + 1) / 2; |
27 if (0 == word32Count) { | 27 if (0 == word32Count) { |
28 return; | 28 return; |
29 } | 29 } |
30 uint16_t* k16 = SkTCast<uint16_t*>(b->add32n(word32Count)); | 30 uint16_t* k16 = SkTCast<uint16_t*>(b->add32n(word32Count)); |
31 for (int i = 0; i < numTextures; ++i) { | 31 for (int i = 0; i < numTextures; ++i) { |
32 const GrTextureAccess& access = proc.textureAccess(i); | 32 const GrTextureAccess& access = proc.textureAccess(i); |
33 GrTexture* texture = access.getTexture(); | 33 GrTexture* texture = access.getTexture(); |
34 k16[i] = SkToU16(caps.configTextureSwizzle(texture->config()).asKey()); | 34 k16[i] = SkToU16(caps.configTextureSwizzle(texture->config()).asKey() | |
| 35 (caps.samplerPrecision(texture->config(), access.getVis
ibility()) << 8)); |
35 } | 36 } |
36 // zero the last 16 bits if the number of textures is odd. | 37 // zero the last 16 bits if the number of textures is odd. |
37 if (numTextures & 0x1) { | 38 if (numTextures & 0x1) { |
38 k16[numTextures] = 0; | 39 k16[numTextures] = 0; |
39 } | 40 } |
40 } | 41 } |
41 | 42 |
42 /** | 43 /** |
43 * A function which emits a meta key into the key builder. This is required beca
use shader code may | 44 * A function which emits a meta key into the key builder. This is required beca
use shader code may |
44 * be dependent on properties of the effect that the effect itself doesn't use | 45 * be dependent on properties of the effect that the effect itself doesn't use |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 } else { | 160 } else { |
160 header->fIgnoresCoverage = 0; | 161 header->fIgnoresCoverage = 0; |
161 } | 162 } |
162 | 163 |
163 header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters(); | 164 header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters(); |
164 header->fColorEffectCnt = pipeline.numColorFragmentProcessors(); | 165 header->fColorEffectCnt = pipeline.numColorFragmentProcessors(); |
165 header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors(); | 166 header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors(); |
166 vkDesc->finalize(); | 167 vkDesc->finalize(); |
167 return true; | 168 return true; |
168 } | 169 } |
OLD | NEW |