WebGpuEncoder constructor
WebGpuEncoder(
- WebGpuDevice _device,
- RenderPassDescriptor descriptor, {
- GPURenderPassTimestampWrites? timestampWrites,
Implementation
WebGpuEncoder(
this._device,
RenderPassDescriptor descriptor, {
GPURenderPassTimestampWrites? timestampWrites,
}) : _colorFormats = <String>[
for (final target in descriptor.colors)
gpuTextureFormat(target.texture.format)!,
],
_blends = <BlendState?>[for (final _ in descriptor.colors) null],
_depthFormat = descriptor.depth == null
? null
: gpuTextureFormat(descriptor.depth!.texture.format),
_sampleCount = descriptor.colors.isNotEmpty
? descriptor.colors.first.texture.sampleCount
: (descriptor.depth?.texture.sampleCount ?? 1) {
final colors = <GPURenderPassColorAttachment>[
for (final target in descriptor.colors) _colorAttachment(target),
];
final depth = descriptor.depth;
_encoder = _device.gpuDevice.createCommandEncoder();
final gpuDescriptor = depth == null
? GPURenderPassDescriptor(
colorAttachments: colors.toJS,
label: descriptor.label ?? 'flutter3d pass',
)
: GPURenderPassDescriptor.withDepth(
colorAttachments: colors.toJS,
depthStencilAttachment: _depthAttachment(depth),
label: descriptor.label ?? 'flutter3d pass',
);
// `H2`: only when the device is timing this pass; the member left out is
// "none", and a null would be refused.
if (timestampWrites != null) {
gpuDescriptor.timestampWrites = timestampWrites;
}
_pass = _encoder.beginRenderPass(gpuDescriptor);
}