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" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 createInfo.minFilter = vkMinFilterModes[params.filterMode()]; | 45 createInfo.minFilter = vkMinFilterModes[params.filterMode()]; |
46 createInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | 46 createInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
47 createInfo.addressModeU = tile_to_vk_sampler_address(params.getTileModeX()); | 47 createInfo.addressModeU = tile_to_vk_sampler_address(params.getTileModeX()); |
48 createInfo.addressModeV = tile_to_vk_sampler_address(params.getTileModeY()); | 48 createInfo.addressModeV = tile_to_vk_sampler_address(params.getTileModeY()); |
49 createInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; // Shouldn'
t matter | 49 createInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; // Shouldn'
t matter |
50 createInfo.mipLodBias = 0.0f; | 50 createInfo.mipLodBias = 0.0f; |
51 createInfo.anisotropyEnable = VK_FALSE; | 51 createInfo.anisotropyEnable = VK_FALSE; |
52 createInfo.maxAnisotropy = 1.0f; | 52 createInfo.maxAnisotropy = 1.0f; |
53 createInfo.compareEnable = VK_FALSE; | 53 createInfo.compareEnable = VK_FALSE; |
54 createInfo.compareOp = VK_COMPARE_OP_NEVER; | 54 createInfo.compareOp = VK_COMPARE_OP_NEVER; |
| 55 // Vulkan doesn't have a direct mapping of GL's nearest or linear filters fo
r minFilter since |
| 56 // there is always a mipmapMode. To get the same effect as GL we can set min
Lod = maxLod = 0.0. |
| 57 // This works since our min and mag filters are the same (this forces us to
use mag on the 0 |
| 58 // level mip). If the filters weren't the same we could set min = 0 and max
= 0.25 to force |
| 59 // the minFilter on mip level 0. |
55 createInfo.minLod = 0.0f; | 60 createInfo.minLod = 0.0f; |
56 createInfo.maxLod = 0.0f; | 61 createInfo.maxLod = 0.0f; |
57 createInfo.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK; | 62 createInfo.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK; |
58 createInfo.unnormalizedCoordinates = VK_FALSE; | 63 createInfo.unnormalizedCoordinates = VK_FALSE; |
59 | 64 |
60 VkSampler sampler; | 65 VkSampler sampler; |
61 GR_VK_CALL_ERRCHECK(gpu->vkInterface(), CreateSampler(gpu->device(), | 66 GR_VK_CALL_ERRCHECK(gpu->vkInterface(), CreateSampler(gpu->device(), |
62 &createInfo, | 67 &createInfo, |
63 nullptr, | 68 nullptr, |
64 &sampler)); | 69 &sampler)); |
(...skipping 11 matching lines...) Expand all Loading... |
76 uint8_t key = params.filterMode(); | 81 uint8_t key = params.filterMode(); |
77 | 82 |
78 SkASSERT(params.filterMode() <= 3); | 83 SkASSERT(params.filterMode() <= 3); |
79 key |= (params.getTileModeX() << 2); | 84 key |= (params.getTileModeX() << 2); |
80 | 85 |
81 GR_STATIC_ASSERT(SkShader::kTileModeCount <= 4); | 86 GR_STATIC_ASSERT(SkShader::kTileModeCount <= 4); |
82 key |= (params.getTileModeY() << 4); | 87 key |= (params.getTileModeY() << 4); |
83 | 88 |
84 return key; | 89 return key; |
85 } | 90 } |
OLD | NEW |