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/vk/GrVkProgramDesc.cpp

Issue 1846963004: Infer sampler precision from pixel config (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comments Created 4 years, 8 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
« src/gpu/vk/GrVkCaps.cpp ('K') | « src/gpu/vk/GrVkCaps.cpp ('k') | 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 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 uint8_t precision_key_nonzero_2_bits(GrShaderType shaderType, GrSLPrecisi on precision,
23 const GrShaderCaps& caps) {
24 return 1 + caps.effectiveFloatPrecision(shaderType, precision);
25
26 GR_STATIC_ASSERT(1 + kLast_GrSLPrecision < (1 << 2));
27 }
28
22 static void add_texture_key(GrProcessorKeyBuilder* b, const GrProcessor& proc, 29 static void add_texture_key(GrProcessorKeyBuilder* b, const GrProcessor& proc,
23 const GrGLSLCaps& caps) { 30 const GrGLSLCaps& caps) {
24 int numTextures = proc.numTextures(); 31 int numTextures = proc.numTextures();
25 // Need two bytes per key (swizzle and target). 32 // Need two bytes per key (swizzle, sampler type, and precision).
26 int word32Count = (proc.numTextures() + 1) / 2; 33 int word32Count = (proc.numTextures() + 1) / 2;
27 if (0 == word32Count) { 34 if (0 == word32Count) {
28 return; 35 return;
29 } 36 }
30 uint16_t* k16 = SkTCast<uint16_t*>(b->add32n(word32Count)); 37 uint16_t* k16 = SkTCast<uint16_t*>(b->add32n(word32Count));
31 for (int i = 0; i < numTextures; ++i) { 38 for (int i = 0; i < numTextures; ++i) {
32 const GrTextureAccess& access = proc.textureAccess(i); 39 const GrTextureAccess& access = proc.textureAccess(i);
33 GrTexture* texture = access.getTexture(); 40 GrTexture* texture = access.getTexture();
34 k16[i] = SkToU16(caps.configTextureSwizzle(texture->config()).asKey()); 41 k16[i] = SkToU16(caps.configTextureSwizzle(texture->config()).asKey());
42 if (caps.usesPrecisionModifiers()) {
43 GrSLPrecision p = GrPixelConfigPrecision(texture->config());
44 if (access.getVisibility() & kFragment_GrShaderFlag) {
45 k16[i] |= precision_key_nonzero_2_bits(kFragment_GrShaderType, p , caps) << 12;
46 }
47 if (access.getVisibility() & (kVertex_GrShaderFlag | kGeometry_GrSha derFlag)) {
48 SkASSERT(precision_key_nonzero_2_bits(kVertex_GrShaderType, p, c aps) ==
49 precision_key_nonzero_2_bits(kGeometry_GrShaderType, p, caps));
50 k16[i] |= precision_key_nonzero_2_bits(kVertex_GrShaderType, p, caps) << 14;
51 }
52 }
35 } 53 }
36 // zero the last 16 bits if the number of textures is odd. 54 // zero the last 16 bits if the number of textures is odd.
37 if (numTextures & 0x1) { 55 if (numTextures & 0x1) {
38 k16[numTextures] = 0; 56 k16[numTextures] = 0;
39 } 57 }
40 } 58 }
41 59
42 /** 60 /**
43 * A function which emits a meta key into the key builder. This is required beca use shader code may 61 * 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 62 * 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
159 } else { 177 } else {
160 header->fIgnoresCoverage = 0; 178 header->fIgnoresCoverage = 0;
161 } 179 }
162 180
163 header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters(); 181 header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters();
164 header->fColorEffectCnt = pipeline.numColorFragmentProcessors(); 182 header->fColorEffectCnt = pipeline.numColorFragmentProcessors();
165 header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors(); 183 header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors();
166 vkDesc->finalize(); 184 vkDesc->finalize();
167 return true; 185 return true;
168 } 186 }
OLDNEW
« src/gpu/vk/GrVkCaps.cpp ('K') | « src/gpu/vk/GrVkCaps.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698