#include "src/gpu/graphite/ResourceProvider.h"
#include "include/core/SkSamplingOptions.h"
#include "include/core/SkTileMode.h"
#include "include/gpu/graphite/BackendTexture.h"
#include "src/core/SkTraceEvent.h"
#include "src/gpu/graphite/Buffer.h"
#include "src/gpu/graphite/Caps.h"
#include "src/gpu/graphite/CommandBuffer.h"
#include "src/gpu/graphite/ComputePipeline.h"
#include "src/gpu/graphite/ContextPriv.h"
#include "src/gpu/graphite/ContextUtils.h"
#include "src/gpu/graphite/GlobalCache.h"
#include "src/gpu/graphite/GraphicsPipeline.h"
#include "src/gpu/graphite/GraphicsPipelineDesc.h"
#include "src/gpu/graphite/Log.h"
#include "src/gpu/graphite/RenderPassDesc.h"
#include "src/gpu/graphite/RendererProvider.h"
#include "src/gpu/graphite/ResourceCache.h"
#include "src/gpu/graphite/Sampler.h"
#include "src/gpu/graphite/SharedContext.h"
#include "src/gpu/graphite/Texture.h"
#include "src/sksl/SkSLCompiler.h"
namespace skgpu::graphite {
[[maybe_unused]] static std::string to_str(const SharedContext* ctx,
const GraphicsPipelineDesc& gpDesc,
const RenderPassDesc& rpDesc) { … }
ResourceProvider::ResourceProvider(SharedContext* sharedContext,\
SingleOwner* singleOwner,
uint32_t recorderID,
size_t resourceBudget)
: … { … }
ResourceProvider::~ResourceProvider() { … }
sk_sp<GraphicsPipeline> ResourceProvider::findOrCreateGraphicsPipeline(
const RuntimeEffectDictionary* runtimeDict,
const GraphicsPipelineDesc& pipelineDesc,
const RenderPassDesc& renderPassDesc) { … }
sk_sp<ComputePipeline> ResourceProvider::findOrCreateComputePipeline(
const ComputePipelineDesc& pipelineDesc) { … }
sk_sp<Texture> ResourceProvider::findOrCreateScratchTexture(SkISize dimensions,
const TextureInfo& info,
std::string_view label,
skgpu::Budgeted budgeted) { … }
sk_sp<Texture> ResourceProvider::findOrCreateDepthStencilAttachment(SkISize dimensions,
const TextureInfo& info) { … }
sk_sp<Texture> ResourceProvider::findOrCreateDiscardableMSAAAttachment(SkISize dimensions,
const TextureInfo& info) { … }
sk_sp<Texture> ResourceProvider::findOrCreateTextureWithKey(SkISize dimensions,
const TextureInfo& info,
const GraphiteResourceKey& key,
std::string_view label,
skgpu::Budgeted budgeted) { … }
sk_sp<Texture> ResourceProvider::createWrappedTexture(const BackendTexture& backendTexture,
std::string_view label) { … }
sk_sp<Sampler> ResourceProvider::findOrCreateCompatibleSampler(const SamplerDesc& samplerDesc) { … }
sk_sp<Buffer> ResourceProvider::findOrCreateBuffer(size_t size,
BufferType type,
AccessPattern accessPattern,
std::string_view label) { … }
namespace {
bool dimensions_are_valid(const int maxTextureSize, const SkISize& dimensions) { … }
}
BackendTexture ResourceProvider::createBackendTexture(SkISize dimensions, const TextureInfo& info) { … }
#ifdef SK_BUILD_FOR_ANDROID
BackendTexture ResourceProvider::createBackendTexture(AHardwareBuffer* hardwareBuffer,
bool isRenderable,
bool isProtectedContent,
SkISize dimensions,
bool fromAndroidWindow) const {
if (!dimensions_are_valid(fSharedContext->caps()->maxTextureSize(), dimensions)) {
return {};
}
return this->onCreateBackendTexture(hardwareBuffer,
isRenderable,
isProtectedContent,
dimensions,
fromAndroidWindow);
}
BackendTexture ResourceProvider::onCreateBackendTexture(AHardwareBuffer*,
bool isRenderable,
bool isProtectedContent,
SkISize dimensions,
bool fromAndroidWindow) const {
return {};
}
#endif
void ResourceProvider::deleteBackendTexture(const BackendTexture& texture) { … }
void ResourceProvider::freeGpuResources() { … }
void ResourceProvider::purgeResourcesNotUsedSince(StdSteadyClock::time_point purgeTime) { … }
}