OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 #include "GrVkSampler.h" | 8 #include "GrVkSampler.h" |
9 | 9 |
10 #include "GrTextureAccess.h" | 10 #include "GrTextureAccess.h" |
11 #include "GrVkGpu.h" | 11 #include "GrVkGpu.h" |
12 | 12 |
13 static inline VkSamplerAddressMode tile_to_vk_sampler_address(SkShader::TileMode
tm) { | 13 static inline VkSamplerAddressMode tile_to_vk_sampler_address(SkShader::TileMode
tm) { |
14 static const VkSamplerAddressMode gWrapModes[] = { | 14 static const VkSamplerAddressMode gWrapModes[] = { |
15 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, | 15 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, |
16 VK_SAMPLER_ADDRESS_MODE_REPEAT, | 16 VK_SAMPLER_ADDRESS_MODE_REPEAT, |
17 VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT | 17 VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT |
18 }; | 18 }; |
19 GR_STATIC_ASSERT(SkShader::kTileModeCount == SK_ARRAY_COUNT(gWrapModes)); | 19 GR_STATIC_ASSERT(SkShader::kTileModeCount == SK_ARRAY_COUNT(gWrapModes)); |
20 GR_STATIC_ASSERT(0 == SkShader::kClamp_TileMode); | 20 GR_STATIC_ASSERT(0 == SkShader::kClamp_TileMode); |
21 GR_STATIC_ASSERT(1 == SkShader::kRepeat_TileMode); | 21 GR_STATIC_ASSERT(1 == SkShader::kRepeat_TileMode); |
22 GR_STATIC_ASSERT(2 == SkShader::kMirror_TileMode); | 22 GR_STATIC_ASSERT(2 == SkShader::kMirror_TileMode); |
23 return gWrapModes[tm]; | 23 return gWrapModes[tm]; |
24 } | 24 } |
25 | 25 |
26 GrVkSampler* GrVkSampler::Create(const GrVkGpu* gpu, const GrTextureParams& para
ms, | 26 GrVkSampler* GrVkSampler::Create(const GrVkGpu* gpu, const GrTextureParams& para
ms, |
27 uint32_t mipLevels) { | 27 uint32_t mipLevels) { |
28 | 28 |
29 static VkFilter vkMinFilterModes[] = { | 29 static VkFilter vkMinFilterModes[] = { |
30 VK_FILTER_NEAREST, | 30 VK_FILTER_NEAREST, |
31 VK_FILTER_LINEAR, | 31 VK_FILTER_LINEAR, |
32 VK_FILTER_LINEAR | 32 VK_FILTER_LINEAR |
33 }; | 33 }; |
34 static VkFilter vkMagFilterModes[] = { | 34 static VkFilter vkMagFilterModes[] = { |
35 VK_FILTER_NEAREST, | 35 VK_FILTER_NEAREST, |
36 VK_FILTER_LINEAR, | 36 VK_FILTER_LINEAR, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 key |= (params.getTileModeX() << kTileModeXShift); | 88 key |= (params.getTileModeX() << kTileModeXShift); |
89 | 89 |
90 GR_STATIC_ASSERT(SkShader::kTileModeCount <= 4); | 90 GR_STATIC_ASSERT(SkShader::kTileModeCount <= 4); |
91 key |= (params.getTileModeY() << kTileModeYShift); | 91 key |= (params.getTileModeY() << kTileModeYShift); |
92 | 92 |
93 SkASSERT(mipLevels < 1024); | 93 SkASSERT(mipLevels < 1024); |
94 key |= (mipLevels << kMipLevelShift); | 94 key |= (mipLevels << kMipLevelShift); |
95 | 95 |
96 return key; | 96 return key; |
97 } | 97 } |
OLD | NEW |