Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: src/gpu/vk/GrVkSampler.cpp

Issue 1916563002: Add automatic generation of mipmaps to Vulkan (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/vk/GrVkSampler.h ('k') | src/gpu/vk/GrVkStencilAttachment.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/vk/GrVkSampler.cpp
diff --git a/src/gpu/vk/GrVkSampler.cpp b/src/gpu/vk/GrVkSampler.cpp
index 75c2ee80d6bd7e1993ac406d8375a9510753e76c..904a8b71ad9815e15fce642e2388e98a8f4f476d 100644
--- a/src/gpu/vk/GrVkSampler.cpp
+++ b/src/gpu/vk/GrVkSampler.cpp
@@ -23,7 +23,8 @@ static inline VkSamplerAddressMode tile_to_vk_sampler_address(SkShader::TileMode
return gWrapModes[tm];
}
-GrVkSampler* GrVkSampler::Create(const GrVkGpu* gpu, const GrTextureParams& params) {
+GrVkSampler* GrVkSampler::Create(const GrVkGpu* gpu, const GrTextureParams& params,
+ uint32_t mipLevels) {
static VkFilter vkMinFilterModes[] = {
VK_FILTER_NEAREST,
@@ -58,7 +59,7 @@ GrVkSampler* GrVkSampler::Create(const GrVkGpu* gpu, const GrTextureParams& 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;
- createInfo.maxLod = 0.0f;
+ createInfo.maxLod = (mipLevels == 1) ? 0.0f : (float)(mipLevels);
createInfo.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
createInfo.unnormalizedCoordinates = VK_FALSE;
@@ -68,7 +69,7 @@ GrVkSampler* GrVkSampler::Create(const GrVkGpu* gpu, const GrTextureParams& para
nullptr,
&sampler));
- return new GrVkSampler(sampler, GenerateKey(params));
+ return new GrVkSampler(sampler, GenerateKey(params, mipLevels));
}
void GrVkSampler::freeGPUData(const GrVkGpu* gpu) const {
@@ -76,15 +77,21 @@ void GrVkSampler::freeGPUData(const GrVkGpu* gpu) const {
GR_VK_CALL(gpu->vkInterface(), DestroySampler(gpu->device(), fSampler, nullptr));
}
-uint8_t GrVkSampler::GenerateKey(const GrTextureParams& params) {
+uint16_t GrVkSampler::GenerateKey(const GrTextureParams& params, uint32_t mipLevels) {
+ const int kTileModeXShift = 2;
+ const int kTileModeYShift = 4;
+ const int kMipLevelShift = 6;
- uint8_t key = params.filterMode();
+ uint16_t key = params.filterMode();
SkASSERT(params.filterMode() <= 3);
- key |= (params.getTileModeX() << 2);
+ key |= (params.getTileModeX() << kTileModeXShift);
GR_STATIC_ASSERT(SkShader::kTileModeCount <= 4);
- key |= (params.getTileModeY() << 4);
+ key |= (params.getTileModeY() << kTileModeYShift);
+
+ SkASSERT(mipLevels < 1024);
+ key |= (mipLevels << kMipLevelShift);
return key;
}
« no previous file with comments | « src/gpu/vk/GrVkSampler.h ('k') | src/gpu/vk/GrVkStencilAttachment.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698