In Vulkan, use 1000 for maxLod instead of maxMipLevel when using mips.
This has the side effect of making samplers in Vulkan only dependent on
the sampler state and not the texture size.
Bug: skia:
Change-Id: I03ccc2c2faead4a1e10b9dd1e5d5885a9d672cc5
Reviewed-on: https://skia-review.googlesource.com/c/173103
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/vk/GrVkSampler.cpp b/src/gpu/vk/GrVkSampler.cpp
index d0ffcc1..2104cb5 100644
--- a/src/gpu/vk/GrVkSampler.cpp
+++ b/src/gpu/vk/GrVkSampler.cpp
@@ -23,8 +23,7 @@
return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
}
-GrVkSampler* GrVkSampler::Create(const GrVkGpu* gpu, const GrSamplerState& samplerState,
- uint32_t maxMipLevel) {
+GrVkSampler* GrVkSampler::Create(const GrVkGpu* gpu, const GrSamplerState& samplerState) {
static VkFilter vkMinFilterModes[] = {
VK_FILTER_NEAREST,
VK_FILTER_LINEAR,
@@ -58,8 +57,8 @@
// level mip). If the filters weren't the same we could set min = 0 and max = 0.25 to force
// the minFilter on mip level 0.
createInfo.minLod = 0.0f;
- bool useMipMaps = GrSamplerState::Filter::kMipMap == samplerState.filter() && maxMipLevel > 0;
- createInfo.maxLod = !useMipMaps ? 0.0f : (float)(maxMipLevel);
+ bool useMipMaps = GrSamplerState::Filter::kMipMap == samplerState.filter();
+ createInfo.maxLod = !useMipMaps ? 0.0f : 10000.0f;
createInfo.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
createInfo.unnormalizedCoordinates = VK_FALSE;
@@ -69,7 +68,7 @@
nullptr,
&sampler));
- return new GrVkSampler(sampler, GenerateKey(samplerState, maxMipLevel));
+ return new GrVkSampler(sampler, GenerateKey(samplerState));
}
void GrVkSampler::freeGPUData(const GrVkGpu* gpu) const {
@@ -77,22 +76,18 @@
GR_VK_CALL(gpu->vkInterface(), DestroySampler(gpu->device(), fSampler, nullptr));
}
-uint16_t GrVkSampler::GenerateKey(const GrSamplerState& samplerState, uint32_t maxMipLevel) {
+uint8_t GrVkSampler::GenerateKey(const GrSamplerState& samplerState) {
const int kTileModeXShift = 2;
const int kTileModeYShift = 4;
- const int kMipLevelShift = 6;
SkASSERT(static_cast<int>(samplerState.filter()) <= 3);
- uint16_t key = static_cast<uint16_t>(samplerState.filter());
+ uint8_t key = static_cast<uint8_t>(samplerState.filter());
- SkASSERT(static_cast<int>(samplerState.wrapModeX()) <= 4);
- key |= (static_cast<uint16_t>(samplerState.wrapModeX()) << kTileModeXShift);
+ SkASSERT(static_cast<int>(samplerState.wrapModeX()) <= 3);
+ key |= (static_cast<uint8_t>(samplerState.wrapModeX()) << kTileModeXShift);
- SkASSERT(static_cast<int>(samplerState.wrapModeY()) <= 4);
- key |= (static_cast<uint16_t>(samplerState.wrapModeY()) << kTileModeYShift);
-
- SkASSERT(maxMipLevel < 1024);
- key |= (maxMipLevel << kMipLevelShift);
+ SkASSERT(static_cast<int>(samplerState.wrapModeY()) <= 3);
+ key |= (static_cast<uint8_t>(samplerState.wrapModeY()) << kTileModeYShift);
return key;
}