diff options
author | Brian Salomon <bsalomon@google.com> | 2018-07-31 13:53:11 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-31 18:16:11 +0000 |
commit | e782f8472f61a5a553c57fef788ad4405844887b (patch) | |
tree | c987b012c7b7db78ce0764a46c9281c23409eb07 /src/gpu/vk/GrVkPipelineState.cpp | |
parent | 990ec990a66aab06bfa18aa16a5e3960a4b34118 (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/GrVkPipelineState.cpp')
-rw-r--r-- | src/gpu/vk/GrVkPipelineState.cpp | 53 |
1 files changed, 21 insertions, 32 deletions
diff --git a/src/gpu/vk/GrVkPipelineState.cpp b/src/gpu/vk/GrVkPipelineState.cpp index 9080128bef..8870f41e86 100644 --- a/src/gpu/vk/GrVkPipelineState.cpp +++ b/src/gpu/vk/GrVkPipelineState.cpp @@ -165,19 +165,6 @@ void GrVkPipelineState::abandonGPUResources() { } } -static void append_texture_bindings( - const GrResourceIOProcessor& processor, - SkTArray<const GrResourceIOProcessor::TextureSampler*>* textureBindings) { - if (int numTextureSamplers = processor.numTextureSamplers()) { - const GrResourceIOProcessor::TextureSampler** bindings = - textureBindings->push_back_n(numTextureSamplers); - int i = 0; - do { - bindings[i] = &processor.textureSampler(i); - } while (++i < numTextureSamplers); - } -} - void GrVkPipelineState::setData(GrVkGpu* gpu, const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline) { @@ -187,11 +174,16 @@ void GrVkPipelineState::setData(GrVkGpu* gpu, this->setRenderTargetState(pipeline.proxy()); - SkSTArray<8, const GrResourceIOProcessor::TextureSampler*> textureBindings; + SkAutoSTMalloc<8, SamplerBindings> samplerBindings(fNumSamplers); + int currTextureBinding = 0; fGeometryProcessor->setData(fDataManager, primProc, GrFragmentProcessor::CoordTransformIter(pipeline)); - append_texture_bindings(primProc, &textureBindings); + for (int i = 0; i < primProc.numTextureSamplers(); ++i) { + const auto& sampler = primProc.textureSampler(i); + samplerBindings[currTextureBinding++] = {sampler.samplerState(), + static_cast<GrVkTexture*>(sampler.peekTexture())}; + } GrFragmentProcessor::Iter iter(pipeline); GrGLSLFragmentProcessor::Iter glslIter(fFragmentProcessors.get(), fFragmentProcessorCnt); @@ -199,7 +191,11 @@ void GrVkPipelineState::setData(GrVkGpu* gpu, GrGLSLFragmentProcessor* glslFP = glslIter.next(); while (fp && glslFP) { glslFP->setData(fDataManager, *fp); - append_texture_bindings(*fp, &textureBindings); + for (int i = 0; i < fp->numTextureSamplers(); ++i) { + const auto& sampler = fp->textureSampler(i); + samplerBindings[currTextureBinding++] = + {sampler.samplerState(), static_cast<GrVkTexture*>(sampler.peekTexture())}; + } fp = iter.next(); glslFP = glslIter.next(); } @@ -212,16 +208,14 @@ void GrVkPipelineState::setData(GrVkGpu* gpu, fXferProcessor->setData(fDataManager, pipeline.getXferProcessor(), dstTexture, offset); } - GrResourceProvider* resourceProvider = gpu->getContext()->contextPriv().resourceProvider(); - - GrResourceIOProcessor::TextureSampler dstTextureSampler; if (GrTextureProxy* dstTextureProxy = pipeline.dstTextureProxy()) { - dstTextureSampler.reset(sk_ref_sp(dstTextureProxy)); - SkAssertResult(dstTextureSampler.instantiate(resourceProvider)); - textureBindings.push_back(&dstTextureSampler); + samplerBindings[currTextureBinding++] = + {GrSamplerState::ClampNearest(), + static_cast<GrVkTexture*>(dstTextureProxy->priv().peekTexture())}; } // Get new descriptor sets + SkASSERT(fNumSamplers == currTextureBinding); if (fNumSamplers) { if (fSamplerDescriptorSet) { fSamplerDescriptorSet->recycle(gpu); @@ -229,7 +223,7 @@ void GrVkPipelineState::setData(GrVkGpu* gpu, fSamplerDescriptorSet = gpu->resourceProvider().getSamplerDescriptorSet(fSamplerDSHandle); int samplerDSIdx = GrVkUniformHandler::kSamplerDescSet; fDescriptorSets[samplerDSIdx] = fSamplerDescriptorSet->descriptorSet(); - this->writeSamplers(gpu, textureBindings); + this->writeSamplers(gpu, samplerBindings.get()); } if (fGeometryUniformBuffer || fFragmentUniformBuffer) { @@ -307,15 +301,10 @@ void GrVkPipelineState::writeUniformBuffers(const GrVkGpu* gpu) { } } -void GrVkPipelineState::writeSamplers( - GrVkGpu* gpu, - const SkTArray<const GrResourceIOProcessor::TextureSampler*>& textureBindings) { - SkASSERT(fNumSamplers == textureBindings.count()); - - for (int i = 0; i < textureBindings.count(); ++i) { - GrSamplerState state = textureBindings[i]->samplerState(); - - GrVkTexture* texture = static_cast<GrVkTexture*>(textureBindings[i]->peekTexture()); +void GrVkPipelineState::writeSamplers(GrVkGpu* gpu, const SamplerBindings bindings[]) { + for (int i = 0; i < fNumSamplers; ++i) { + const GrSamplerState& state = bindings[i].fState; + GrVkTexture* texture = bindings[i].fTexture; fSamplers.push(gpu->resourceProvider().findOrCreateCompatibleSampler( state, texture->texturePriv().maxMipMapLevel())); |