OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 | 7 |
8 | 8 |
9 #include "GrGLSLCaps.h" | 9 #include "GrGLSLCaps.h" |
10 | 10 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 r.appendf("Buffer texture support: %s\n", (fBufferTextureSupport ? "YES" : "
NO")); | 85 r.appendf("Buffer texture support: %s\n", (fBufferTextureSupport ? "YES" : "
NO")); |
86 r.appendf("Max VS Samplers: %d\n", fMaxVertexSamplers); | 86 r.appendf("Max VS Samplers: %d\n", fMaxVertexSamplers); |
87 r.appendf("Max GS Samplers: %d\n", fMaxGeometrySamplers); | 87 r.appendf("Max GS Samplers: %d\n", fMaxGeometrySamplers); |
88 r.appendf("Max FS Samplers: %d\n", fMaxFragmentSamplers); | 88 r.appendf("Max FS Samplers: %d\n", fMaxFragmentSamplers); |
89 r.appendf("Max Combined Samplers: %d\n", fMaxFragmentSamplers); | 89 r.appendf("Max Combined Samplers: %d\n", fMaxFragmentSamplers); |
90 r.appendf("Advanced blend equation interaction: %s\n", | 90 r.appendf("Advanced blend equation interaction: %s\n", |
91 kAdvBlendEqInteractionStr[fAdvBlendEqInteraction]); | 91 kAdvBlendEqInteractionStr[fAdvBlendEqInteraction]); |
92 return r; | 92 return r; |
93 } | 93 } |
94 | 94 |
| 95 void GrGLSLCaps::initSamplerPrecisionTable() { |
| 96 // Determine the largest precision qualifiers that are effectively the same
as lowp/mediump. |
| 97 // e.g. if lowp == mediump, then use mediump instead of lowp. |
| 98 GrSLPrecision effectiveMediumP[kGrShaderTypeCount]; |
| 99 GrSLPrecision effectiveLowP[kGrShaderTypeCount]; |
| 100 for (int s = 0; s < kGrShaderTypeCount; ++s) { |
| 101 const PrecisionInfo* info = fFloatPrecisions[s]; |
| 102 effectiveMediumP[s] = info[kHigh_GrSLPrecision] == info[kMedium_GrSLPrec
ision] ? |
| 103 kHigh_GrSLPrecision : kMedium_GrSLPrecision; |
| 104 effectiveLowP[s] = info[kMedium_GrSLPrecision] == info[kLow_GrSLPrecisio
n] ? |
| 105 effectiveMediumP[s] : kLow_GrSLPrecision; |
| 106 } |
| 107 |
| 108 // Determine which precision qualifiers should be used with samplers. |
| 109 for (int visibility = 0; visibility < (1 << kGrShaderTypeCount); ++visibilit
y) { |
| 110 GrSLPrecision mediump = kHigh_GrSLPrecision; |
| 111 GrSLPrecision lowp = kHigh_GrSLPrecision; |
| 112 for (int s = 0; s < kGrShaderTypeCount; ++s) { |
| 113 if (visibility & (1 << s)) { |
| 114 mediump = SkTMin(mediump, effectiveMediumP[s]); |
| 115 lowp = SkTMin(lowp, effectiveLowP[s]); |
| 116 } |
| 117 |
| 118 GR_STATIC_ASSERT(0 == kLow_GrSLPrecision); |
| 119 GR_STATIC_ASSERT(1 == kMedium_GrSLPrecision); |
| 120 GR_STATIC_ASSERT(2 == kHigh_GrSLPrecision); |
| 121 |
| 122 GR_STATIC_ASSERT((1 << kVertex_GrShaderType) == kVertex_GrShaderFlag
); |
| 123 GR_STATIC_ASSERT((1 << kGeometry_GrShaderType) == kGeometry_GrShader
Flag); |
| 124 GR_STATIC_ASSERT((1 << kFragment_GrShaderType) == kFragment_GrShader
Flag); |
| 125 GR_STATIC_ASSERT(3 == kGrShaderTypeCount); |
| 126 } |
| 127 |
| 128 uint8_t* table = fSamplerPrecisions[visibility]; |
| 129 table[kUnknown_GrPixelConfig] = kDefault_GrSLPrecision; |
| 130 table[kAlpha_8_GrPixelConfig] = lowp; |
| 131 table[kIndex_8_GrPixelConfig] = lowp; |
| 132 table[kRGB_565_GrPixelConfig] = lowp; |
| 133 table[kRGBA_4444_GrPixelConfig] = lowp; |
| 134 table[kRGBA_8888_GrPixelConfig] = lowp; |
| 135 table[kBGRA_8888_GrPixelConfig] = lowp; |
| 136 table[kSRGBA_8888_GrPixelConfig] = lowp; |
| 137 table[kSBGRA_8888_GrPixelConfig] = lowp; |
| 138 table[kETC1_GrPixelConfig] = lowp; |
| 139 table[kLATC_GrPixelConfig] = lowp; |
| 140 table[kR11_EAC_GrPixelConfig] = lowp; |
| 141 table[kASTC_12x12_GrPixelConfig] = lowp; |
| 142 table[kRGBA_float_GrPixelConfig] = kHigh_GrSLPrecision; |
| 143 table[kAlpha_half_GrPixelConfig] = mediump; |
| 144 table[kRGBA_half_GrPixelConfig] = mediump; |
| 145 |
| 146 GR_STATIC_ASSERT(16 == kGrPixelConfigCnt); |
| 147 } |
| 148 } |
| 149 |
95 void GrGLSLCaps::onApplyOptionsOverrides(const GrContextOptions& options) { | 150 void GrGLSLCaps::onApplyOptionsOverrides(const GrContextOptions& options) { |
96 } | 151 } |
OLD | NEW |