#include "src/gpu/graphite/dawn/DawnResourceProvider.h"
#include "include/gpu/graphite/BackendTexture.h"
#include "include/gpu/graphite/TextureInfo.h"
#include "include/gpu/graphite/dawn/DawnTypes.h"
#include "include/private/base/SkAlign.h"
#include "src/gpu/graphite/ComputePipeline.h"
#include "src/gpu/graphite/RenderPassDesc.h"
#include "src/gpu/graphite/dawn/DawnBuffer.h"
#include "src/gpu/graphite/dawn/DawnComputePipeline.h"
#include "src/gpu/graphite/dawn/DawnErrorChecker.h"
#include "src/gpu/graphite/dawn/DawnGraphicsPipeline.h"
#include "src/gpu/graphite/dawn/DawnGraphiteTypesPriv.h"
#include "src/gpu/graphite/dawn/DawnSampler.h"
#include "src/gpu/graphite/dawn/DawnSharedContext.h"
#include "src/gpu/graphite/dawn/DawnTexture.h"
#include "src/sksl/SkSLCompiler.h"
namespace skgpu::graphite {
namespace {
constexpr int kBufferBindingSizeAlignment = …;
constexpr int kMaxNumberOfCachedBufferBindGroups = …;
constexpr int kMaxNumberOfCachedTextureBindGroups = …;
wgpu::ShaderModule create_shader_module(const wgpu::Device& device, const char* source) { … }
wgpu::RenderPipeline create_blit_render_pipeline(const DawnSharedContext* sharedContext,
const char* label,
wgpu::ShaderModule vsModule,
wgpu::ShaderModule fsModule,
wgpu::TextureFormat renderPassColorFormat,
wgpu::TextureFormat renderPassDepthStencilFormat,
int numSamples) { … }
template <size_t NumEntries>
using BindGroupKey = typename DawnResourceProvider::BindGroupKey<NumEntries>;
using UniformBindGroupKey = BindGroupKey<DawnResourceProvider::kNumUniformEntries>;
UniformBindGroupKey make_ubo_bind_group_key(
const std::array<std::pair<const DawnBuffer*, uint32_t>,
DawnResourceProvider::kNumUniformEntries>& boundBuffersAndSizes) { … }
BindGroupKey<1> make_texture_bind_group_key(const DawnSampler* sampler,
const DawnTexture* texture) { … }
}
DawnResourceProvider::DawnResourceProvider(SharedContext* sharedContext,
SingleOwner* singleOwner,
uint32_t recorderID,
size_t resourceBudget)
: … { … }
DawnResourceProvider::~DawnResourceProvider() = default;
wgpu::RenderPipeline DawnResourceProvider::findOrCreateBlitWithDrawPipeline(
const RenderPassDesc& renderPassDesc) { … }
sk_sp<Texture> DawnResourceProvider::onCreateWrappedTexture(const BackendTexture& texture) { … }
sk_sp<DawnTexture> DawnResourceProvider::findOrCreateDiscardableMSAALoadTexture(
SkISize dimensions, const TextureInfo& msaaInfo) { … }
sk_sp<GraphicsPipeline> DawnResourceProvider::createGraphicsPipeline(
const RuntimeEffectDictionary* runtimeDict,
const GraphicsPipelineDesc& pipelineDesc,
const RenderPassDesc& renderPassDesc) { … }
sk_sp<ComputePipeline> DawnResourceProvider::createComputePipeline(
const ComputePipelineDesc& desc) { … }
sk_sp<Texture> DawnResourceProvider::createTexture(SkISize dimensions,
const TextureInfo& info,
skgpu::Budgeted budgeted) { … }
sk_sp<Buffer> DawnResourceProvider::createBuffer(size_t size,
BufferType type,
AccessPattern accessPattern) { … }
sk_sp<Sampler> DawnResourceProvider::createSampler(const SamplerDesc& samplerDesc) { … }
BackendTexture DawnResourceProvider::onCreateBackendTexture(SkISize dimensions,
const TextureInfo& info) { … }
void DawnResourceProvider::onDeleteBackendTexture(const BackendTexture& texture) { … }
DawnSharedContext* DawnResourceProvider::dawnSharedContext() const { … }
sk_sp<DawnBuffer> DawnResourceProvider::findOrCreateDawnBuffer(size_t size,
BufferType type,
AccessPattern accessPattern,
std::string_view label) { … }
const wgpu::BindGroupLayout& DawnResourceProvider::getOrCreateUniformBuffersBindGroupLayout() { … }
const wgpu::BindGroupLayout&
DawnResourceProvider::getOrCreateSingleTextureSamplerBindGroupLayout() { … }
const wgpu::Buffer& DawnResourceProvider::getOrCreateNullBuffer() { … }
const wgpu::BindGroup& DawnResourceProvider::findOrCreateUniformBuffersBindGroup(
const std::array<std::pair<const DawnBuffer*, uint32_t>, kNumUniformEntries>&
boundBuffersAndSizes) { … }
const wgpu::BindGroup& DawnResourceProvider::findOrCreateSingleTextureSamplerBindGroup(
const DawnSampler* sampler, const DawnTexture* texture) { … }
}