aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/vk/GrVkGpuCommandBuffer.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-07-31 13:53:11 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-31 18:16:11 +0000
commite782f8472f61a5a553c57fef788ad4405844887b (patch)
treec987b012c7b7db78ce0764a46c9281c23409eb07 /src/gpu/vk/GrVkGpuCommandBuffer.cpp
parent990ec990a66aab06bfa18aa16a5e3960a4b34118 (diff)
Remove GrResourceIOProcessor.
Fold its functionality into GrPrimitiveProcessor and GrFragmentProcessor. Make each have its own TextureSampler nested class. Currently the only difference is that fragment processors lose the ability to inject their samplers into the vertex shader. However, this facilitates refactoring GrPrimitiveProcessor's TextureSampler class such that the textures are specified separately from the TextureSampler. Bug: skia: Change-Id: I1e590187e7a6ae79ee3147155d397fcdcf5e4619 Reviewed-on: https://skia-review.googlesource.com/142814 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/vk/GrVkGpuCommandBuffer.cpp')
-rw-r--r--src/gpu/vk/GrVkGpuCommandBuffer.cpp54
1 files changed, 27 insertions, 27 deletions
diff --git a/src/gpu/vk/GrVkGpuCommandBuffer.cpp b/src/gpu/vk/GrVkGpuCommandBuffer.cpp
index d58a8b5ff7..013c1d7815 100644
--- a/src/gpu/vk/GrVkGpuCommandBuffer.cpp
+++ b/src/gpu/vk/GrVkGpuCommandBuffer.cpp
@@ -608,31 +608,6 @@ GrVkPipelineState* GrVkGpuRTCommandBuffer::prepareDrawState(
return pipelineState;
}
-static void prepare_sampled_images(const GrResourceIOProcessor& processor,
- SkTArray<GrVkImage*>* sampledImages,
- GrVkGpu* gpu) {
- for (int i = 0; i < processor.numTextureSamplers(); ++i) {
- const GrResourceIOProcessor::TextureSampler& sampler = processor.textureSampler(i);
- GrVkTexture* vkTexture = static_cast<GrVkTexture*>(sampler.peekTexture());
-
- // We may need to resolve the texture first if it is also a render target
- GrVkRenderTarget* texRT = static_cast<GrVkRenderTarget*>(vkTexture->asRenderTarget());
- if (texRT) {
- gpu->onResolveRenderTarget(texRT);
- }
-
- // Check if we need to regenerate any mip maps
- if (GrSamplerState::Filter::kMipMap == sampler.samplerState().filter() &&
- (vkTexture->width() != 1 || vkTexture->height() != 1)) {
- SkASSERT(vkTexture->texturePriv().mipMapped() == GrMipMapped::kYes);
- if (vkTexture->texturePriv().mipMapsAreDirty()) {
- gpu->regenerateMipMapLevels(vkTexture);
- }
- }
- sampledImages->push_back(vkTexture);
- }
-}
-
void GrVkGpuRTCommandBuffer::onDraw(const GrPrimitiveProcessor& primProc,
const GrPipeline& pipeline,
const GrPipeline::FixedDynamicState* fixedDynamicState,
@@ -648,10 +623,35 @@ void GrVkGpuRTCommandBuffer::onDraw(const GrPrimitiveProcessor& primProc,
CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo];
- prepare_sampled_images(primProc, &cbInfo.fSampledImages, fGpu);
+ auto prepareSampledImage = [&](GrTexture* texture, GrSamplerState::Filter filter) {
+ GrVkTexture* vkTexture = static_cast<GrVkTexture*>(texture);
+ // We may need to resolve the texture first if it is also a render target
+ GrVkRenderTarget* texRT = static_cast<GrVkRenderTarget*>(vkTexture->asRenderTarget());
+ if (texRT) {
+ fGpu->onResolveRenderTarget(texRT);
+ }
+
+ // Check if we need to regenerate any mip maps
+ if (GrSamplerState::Filter::kMipMap == filter &&
+ (vkTexture->width() != 1 || vkTexture->height() != 1)) {
+ SkASSERT(vkTexture->texturePriv().mipMapped() == GrMipMapped::kYes);
+ if (vkTexture->texturePriv().mipMapsAreDirty()) {
+ fGpu->regenerateMipMapLevels(vkTexture);
+ }
+ }
+ cbInfo.fSampledImages.push_back(vkTexture);
+ };
+
+ for (int i = 0; i < primProc.numTextureSamplers(); ++i) {
+ const GrPrimitiveProcessor::TextureSampler& sampler = primProc.textureSampler(i);
+ prepareSampledImage(sampler.peekTexture(), sampler.samplerState().filter());
+ }
GrFragmentProcessor::Iter iter(pipeline);
while (const GrFragmentProcessor* fp = iter.next()) {
- prepare_sampled_images(*fp, &cbInfo.fSampledImages, fGpu);
+ for (int i = 0; i < fp->numTextureSamplers(); ++i) {
+ const GrFragmentProcessor::TextureSampler& sampler = fp->textureSampler(i);
+ prepareSampledImage(sampler.peekTexture(), sampler.samplerState().filter());
+ }
}
if (GrTexture* dstTexture = pipeline.peekDstTexture()) {
cbInfo.fSampledImages.push_back(static_cast<GrVkTexture*>(dstTexture));