aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2017-09-01 09:40:30 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-01 14:10:57 +0000
commitb280d4e3c49980b3410fd4ed62fd27807ce68338 (patch)
tree152b75efe2283ca5548a2aa7011b2595eb520198
parentd74f3f2c0b03552b0ef60dc3fbf9e98d4ab754a2 (diff)
Fix up and clarify use of maxMipLevel in Vulkan
Bug: skia: Change-Id: I5b31e0c74be8f650e97c448b1029a2277dfee978 Reviewed-on: https://skia-review.googlesource.com/41844 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
-rw-r--r--src/gpu/vk/GrVkResourceProvider.cpp6
-rw-r--r--src/gpu/vk/GrVkResourceProvider.h2
-rw-r--r--src/gpu/vk/GrVkSampler.cpp14
-rw-r--r--src/gpu/vk/GrVkSampler.h4
-rw-r--r--src/gpu/vk/GrVkTexture.cpp3
5 files changed, 15 insertions, 14 deletions
diff --git a/src/gpu/vk/GrVkResourceProvider.cpp b/src/gpu/vk/GrVkResourceProvider.cpp
index 0f4b2a9f34..cfce75f1ca 100644
--- a/src/gpu/vk/GrVkResourceProvider.cpp
+++ b/src/gpu/vk/GrVkResourceProvider.cpp
@@ -166,10 +166,10 @@ GrVkDescriptorPool* GrVkResourceProvider::findOrCreateCompatibleDescriptorPool(
}
GrVkSampler* GrVkResourceProvider::findOrCreateCompatibleSampler(const GrSamplerParams& params,
- uint32_t mipLevels) {
- GrVkSampler* sampler = fSamplers.find(GrVkSampler::GenerateKey(params, mipLevels));
+ uint32_t maxMipLevel) {
+ GrVkSampler* sampler = fSamplers.find(GrVkSampler::GenerateKey(params, maxMipLevel));
if (!sampler) {
- sampler = GrVkSampler::Create(fGpu, params, mipLevels);
+ sampler = GrVkSampler::Create(fGpu, params, maxMipLevel);
fSamplers.add(sampler);
}
SkASSERT(sampler);
diff --git a/src/gpu/vk/GrVkResourceProvider.h b/src/gpu/vk/GrVkResourceProvider.h
index 5940681e8c..ba11c8db52 100644
--- a/src/gpu/vk/GrVkResourceProvider.h
+++ b/src/gpu/vk/GrVkResourceProvider.h
@@ -98,7 +98,7 @@ public:
// Finds or creates a compatible GrVkSampler based on the GrSamplerParams.
// The refcount is incremented and a pointer returned.
- GrVkSampler* findOrCreateCompatibleSampler(const GrSamplerParams&, uint32_t mipLevels);
+ GrVkSampler* findOrCreateCompatibleSampler(const GrSamplerParams&, uint32_t maxMipLevel);
sk_sp<GrVkPipelineState> findOrCreateCompatiblePipelineState(const GrPipeline&,
const GrPrimitiveProcessor&,
diff --git a/src/gpu/vk/GrVkSampler.cpp b/src/gpu/vk/GrVkSampler.cpp
index 39016344c7..740c14b4de 100644
--- a/src/gpu/vk/GrVkSampler.cpp
+++ b/src/gpu/vk/GrVkSampler.cpp
@@ -23,7 +23,7 @@ static inline VkSamplerAddressMode tile_to_vk_sampler_address(SkShader::TileMode
}
GrVkSampler* GrVkSampler::Create(const GrVkGpu* gpu, const GrSamplerParams& params,
- uint32_t mipLevels) {
+ uint32_t maxMipLevel) {
static VkFilter vkMinFilterModes[] = {
VK_FILTER_NEAREST,
VK_FILTER_LINEAR,
@@ -57,8 +57,8 @@ GrVkSampler* GrVkSampler::Create(const GrVkGpu* gpu, const GrSamplerParams& para
// 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 = GrSamplerParams::kMipMap_FilterMode == params.filterMode() && mipLevels > 1;
- createInfo.maxLod = !useMipMaps ? 0.0f : (float)(mipLevels);
+ bool useMipMaps = GrSamplerParams::kMipMap_FilterMode == params.filterMode() && maxMipLevel > 0;
+ createInfo.maxLod = !useMipMaps ? 0.0f : (float)(maxMipLevel);
createInfo.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
createInfo.unnormalizedCoordinates = VK_FALSE;
@@ -68,7 +68,7 @@ GrVkSampler* GrVkSampler::Create(const GrVkGpu* gpu, const GrSamplerParams& para
nullptr,
&sampler));
- return new GrVkSampler(sampler, GenerateKey(params, mipLevels));
+ return new GrVkSampler(sampler, GenerateKey(params, maxMipLevel));
}
void GrVkSampler::freeGPUData(const GrVkGpu* gpu) const {
@@ -76,7 +76,7 @@ void GrVkSampler::freeGPUData(const GrVkGpu* gpu) const {
GR_VK_CALL(gpu->vkInterface(), DestroySampler(gpu->device(), fSampler, nullptr));
}
-uint16_t GrVkSampler::GenerateKey(const GrSamplerParams& params, uint32_t mipLevels) {
+uint16_t GrVkSampler::GenerateKey(const GrSamplerParams& params, uint32_t maxMipLevel) {
const int kTileModeXShift = 2;
const int kTileModeYShift = 4;
const int kMipLevelShift = 6;
@@ -89,8 +89,8 @@ uint16_t GrVkSampler::GenerateKey(const GrSamplerParams& params, uint32_t mipLev
GR_STATIC_ASSERT(SkShader::kTileModeCount <= 4);
key |= (params.getTileModeY() << kTileModeYShift);
- SkASSERT(mipLevels < 1024);
- key |= (mipLevels << kMipLevelShift);
+ SkASSERT(maxMipLevel < 1024);
+ key |= (maxMipLevel << kMipLevelShift);
return key;
}
diff --git a/src/gpu/vk/GrVkSampler.h b/src/gpu/vk/GrVkSampler.h
index 963060239f..a413ea826a 100644
--- a/src/gpu/vk/GrVkSampler.h
+++ b/src/gpu/vk/GrVkSampler.h
@@ -18,12 +18,12 @@ class GrVkGpu;
class GrVkSampler : public GrVkResource {
public:
- static GrVkSampler* Create(const GrVkGpu* gpu, const GrSamplerParams&, uint32_t mipLevels);
+ static GrVkSampler* Create(const GrVkGpu* gpu, const GrSamplerParams&, uint32_t maxMipLevel);
VkSampler sampler() const { return fSampler; }
// Helpers for hashing GrVkSampler
- static uint16_t GenerateKey(const GrSamplerParams&, uint32_t mipLevels);
+ static uint16_t GenerateKey(const GrSamplerParams&, uint32_t maxMipLevel);
static const uint16_t& GetKey(const GrVkSampler& sampler) { return sampler.fKey; }
static uint32_t Hash(const uint16_t& key) { return key; }
diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp
index 90de6be9a7..ce1d4875d6 100644
--- a/src/gpu/vk/GrVkTexture.cpp
+++ b/src/gpu/vk/GrVkTexture.cpp
@@ -239,7 +239,8 @@ bool GrVkTexture::reallocForMipmap(GrVkGpu* gpu, uint32_t mipLevels) {
this->setNewResource(info.fImage, info.fAlloc, info.fImageTiling);
fTextureView = textureView;
fInfo = info;
- this->texturePriv().setMaxMipMapLevel(mipLevels);
+ // SetMaxMipMapLevel stores the max level not the number of levels
+ this->texturePriv().setMaxMipMapLevel(mipLevels-1);
return true;
}