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

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

Issue 1765523002: Add a cache of GrVkSamplers in GrVkResourceProvider. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nits Created 4 years, 10 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') | no next file » | 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 4bba66268ba40964900e9b51ad8df6f820261c92..9938340a848e505e689b78b8b5eab436cd770846 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
return gWrapModes[tm];
}
-GrVkSampler* GrVkSampler::Create(const GrVkGpu* gpu, const GrTextureAccess& textureAccess) {
+GrVkSampler* GrVkSampler::Create(const GrVkGpu* gpu, const GrTextureParams& params) {
static VkFilter vkMinFilterModes[] = {
VK_FILTER_NEAREST,
@@ -36,8 +36,6 @@ GrVkSampler* GrVkSampler::Create(const GrVkGpu* gpu, const GrTextureAccess& text
VK_FILTER_LINEAR
};
- const GrTextureParams& params = textureAccess.getParams();
-
VkSamplerCreateInfo createInfo;
memset(&createInfo, 0, sizeof(VkSamplerCreateInfo));
createInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
@@ -65,10 +63,24 @@ GrVkSampler* GrVkSampler::Create(const GrVkGpu* gpu, const GrTextureAccess& text
nullptr,
&sampler));
- return new GrVkSampler(sampler);
+ return new GrVkSampler(sampler, GenerateKey(params));
}
void GrVkSampler::freeGPUData(const GrVkGpu* gpu) const {
SkASSERT(fSampler);
GR_VK_CALL(gpu->vkInterface(), DestroySampler(gpu->device(), fSampler, nullptr));
}
+
+uint8_t GrVkSampler::GenerateKey(const GrTextureParams& params) {
+
+ uint8_t key = params.filterMode();
+
+ SkASSERT(params.filterMode() <= 3);
+ key |= (params.getTileModeX() << 2);
+
+ GR_STATIC_ASSERT(SkShader::kTileModeCount <= 4);
+ key |= (params.getTileModeY() << 4);
+
+ return key;
+}
+
« no previous file with comments | « src/gpu/vk/GrVkSampler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698