diff options
Diffstat (limited to 'src/gpu/GrProcessor.cpp')
-rw-r--r-- | src/gpu/GrProcessor.cpp | 52 |
1 files changed, 47 insertions, 5 deletions
diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp index 1e100e41fa..f4f7ccb138 100644 --- a/src/gpu/GrProcessor.cpp +++ b/src/gpu/GrProcessor.cpp @@ -122,7 +122,12 @@ void GrProcessor::addTextureSampler(const TextureSampler* access) { void GrProcessor::addBufferAccess(const BufferAccess* access) { fBufferAccesses.push_back(access); - this->addGpuResource(access->getProgramBuffer()); + this->addGpuResource(access->programBuffer()); +} + +void GrProcessor::addImageStorageAccess(const ImageStorageAccess* access) { + fImageStorageAccesses.push_back(access); + this->addGpuResource(access->programTexture()); } void* GrProcessor::operator new(size_t size) { @@ -133,9 +138,10 @@ void GrProcessor::operator delete(void* target) { return MemoryPoolAccessor().pool()->release(target); } -bool GrProcessor::hasSameSamplers(const GrProcessor& that) const { +bool GrProcessor::hasSameSamplersAndAccesses(const GrProcessor &that) const { if (this->numTextureSamplers() != that.numTextureSamplers() || - this->numBuffers() != that.numBuffers()) { + this->numBuffers() != that.numBuffers() || + this->numImageStorages() != that.numImageStorages()) { return false; } for (int i = 0; i < this->numTextureSamplers(); ++i) { @@ -148,6 +154,11 @@ bool GrProcessor::hasSameSamplers(const GrProcessor& that) const { return false; } } + for (int i = 0; i < this->numImageStorages(); ++i) { + if (this->imageStorageAccess(i) != that.imageStorageAccess(i)) { + return false; + } + } return true; } @@ -189,6 +200,37 @@ void GrProcessor::TextureSampler::reset(GrTexture* texture, /////////////////////////////////////////////////////////////////////////////////////////////////// +GrProcessor::ImageStorageAccess::ImageStorageAccess(sk_sp<GrTexture> texture, GrIOType ioType, + GrSLMemoryModel memoryModel, + GrSLRestrict restrict, + GrShaderFlags visibility) { + SkASSERT(texture); + fTexture.set(texture.release(), ioType); + fMemoryModel = memoryModel; + fRestrict = restrict; + fVisibility = visibility; + // We currently infer this from the config. However, we could allow the client to specify + // a format that is different but compatible with the config. + switch (fTexture.get()->config()) { + case kRGBA_8888_GrPixelConfig: + fFormat = GrImageStorageFormat::kRGBA8; + break; + case kRGBA_8888_sint_GrPixelConfig: + fFormat = GrImageStorageFormat::kRGBA8i; + break; + case kRGBA_half_GrPixelConfig: + fFormat = GrImageStorageFormat::kRGBA16f; + break; + case kRGBA_float_GrPixelConfig: + fFormat = GrImageStorageFormat::kRGBA32f; + break; + default: + SkFAIL("Config is not (yet) supported as image storage."); + break; + } +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// + // Initial static variable from GrXPFactory -int32_t GrXPFactory::gCurrXPFClassID = - GrXPFactory::kIllegalXPFClassID; +int32_t GrXPFactory::gCurrXPFClassID = GrXPFactory::kIllegalXPFClassID; |