78 {
79 auto [shaderModule, entryPointName] = compile_shader_module(
sharedContext, pipelineDesc);
80 if (!shaderModule) {
81 return nullptr;
82 }
83
85
86
87
88
89
90
91
93 std::vector<wgpu::BindGroupLayoutEntry> bindGroupLayoutEntries;
94 auto resources =
step->resources();
95
96
97 size_t resourceCount = 0;
98 for (const ComputeStep::ResourceDesc& r : resources) {
99 resourceCount++;
101 resourceCount++;
102 }
103 }
104
105 bindGroupLayoutEntries.reserve(resourceCount);
106 int declarationIndex = 0;
107 for (const ComputeStep::ResourceDesc& r : resources) {
108 bindGroupLayoutEntries.emplace_back();
109 uint32_t bindingIndex = bindGroupLayoutEntries.size() - 1;
110
111 wgpu::BindGroupLayoutEntry& entry = bindGroupLayoutEntries.back();
112 entry.binding = bindingIndex;
113 entry.visibility = wgpu::ShaderStage::Compute;
114 switch (r.fType) {
117 break;
120 entry.buffer.type = wgpu::BufferBindingType::Storage;
121 break;
123 entry.buffer.type = wgpu::BufferBindingType::ReadOnlyStorage;
124 break;
126 entry.texture.sampleType = wgpu::TextureSampleType::Float;
127 entry.texture.viewDimension = wgpu::TextureViewDimension::e2D;
128 break;
130 entry.storageTexture.access = wgpu::StorageTextureAccess::WriteOnly;
131 entry.storageTexture.viewDimension = wgpu::TextureViewDimension::e2D;
132
133 auto [_,
colorType] =
step->calculateTextureParameters(declarationIndex, r);
135 entry.storageTexture.format = textureInfo.dawnTextureSpec().getViewFormat();
136 break;
137 }
139 entry.sampler.type = wgpu::SamplerBindingType::Filtering;
140
141
142 bindGroupLayoutEntries.emplace_back();
143 wgpu::BindGroupLayoutEntry& texEntry = bindGroupLayoutEntries.back();
144 texEntry.binding = bindingIndex + 1;
145 texEntry.visibility = wgpu::ShaderStage::Compute;
146 texEntry.texture.sampleType = wgpu::TextureSampleType::Float;
147 texEntry.texture.viewDimension = wgpu::TextureViewDimension::e2D;
148 break;
149 }
150 }
151 declarationIndex++;
152 }
153
155
156
157 wgpu::BindGroupLayoutDescriptor bindGroupLayoutDesc;
158 bindGroupLayoutDesc.entryCount = bindGroupLayoutEntries.size();
159 bindGroupLayoutDesc.entries = bindGroupLayoutEntries.data();
160 wgpu::BindGroupLayout bindGroupLayout =
device.CreateBindGroupLayout(&bindGroupLayoutDesc);
161 if (!bindGroupLayout) {
162 return nullptr;
163 }
164
165 wgpu::PipelineLayoutDescriptor pipelineLayoutDesc;
167 pipelineLayoutDesc.label =
step->name();
168 }
169 pipelineLayoutDesc.bindGroupLayoutCount = 1;
170 pipelineLayoutDesc.bindGroupLayouts = &bindGroupLayout;
171 wgpu::PipelineLayout layout =
device.CreatePipelineLayout(&pipelineLayoutDesc);
172 if (!layout) {
173 return nullptr;
174 }
175
176 wgpu::ComputePipelineDescriptor descriptor;
177
178 descriptor.label =
step->name();
179 descriptor.compute.module = std::move(shaderModule);
180 descriptor.compute.entryPoint = entryPointName.c_str();
181 descriptor.layout = std::move(layout);
182
183 std::optional<DawnErrorChecker> errorChecker;
186 }
187 wgpu::ComputePipeline pipeline =
device.CreateComputePipeline(&descriptor);
190 return nullptr;
191 }
192
194 sharedContext, std::move(pipeline), std::move(bindGroupLayout)));
195}
static int step(int x, SkScalar min, SkScalar max)
static bool ComputeStep(const SkPoint &a, const SkPoint &b, SkScalar radius, SkPoint *step)
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
SkMeshSpecification::Uniform Uniform
const ResourceBindingRequirements & resourceBindingRequirements() const
virtual TextureInfo getDefaultStorageTextureInfo(SkColorType) const =0
bool setBackendLabels() const
@ kWriteOnlyStorageTexture
const SharedContext * sharedContext() const
const Caps * caps() const
bool fDistinctIndexRanges