Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
gpu_pass.hpp
Go to the documentation of this file.
1#pragma once
2
51
56
57#include <array>
58#include <chrono>
59#include <cstddef>
60#include <cstdint>
61#include <memory>
62#include <optional>
63#include <string>
64#include <string_view>
65#include <vector>
66
67namespace pulp::canvas {
68class Canvas;
69}
70
71namespace pulp::render {
72
73namespace detail {
74struct GpuDeviceState;
75struct GpuTextureState;
76struct GpuBufferState;
77struct GpuSamplerState;
78struct GpuShaderModuleState;
79struct GpuRenderPipelineState;
80struct GpuComputePipelineState;
81struct GpuBindGroupState;
82struct GpuTargetState;
83struct GpuFrameState;
84struct GpuSubmissionState;
85struct GpuAccess;
86} // namespace detail
87
88// ── Errors ───────────────────────────────────────────────────────────────
89
90struct GpuError {
105
107 std::string message;
109 std::vector<WgslDiagnostic> diagnostics;
110
112 std::string describe() const;
113};
114
115std::string_view gpu_error_kind_name(GpuError::Kind kind);
116
117template <typename T> using GpuResult = runtime::Result<T, GpuError>;
120
121// ── Flags ────────────────────────────────────────────────────────────────
122
124enum class GpuTextureUsage : std::uint32_t {
125 none = 0,
126 copy_src = 1u << 0,
127 copy_dst = 1u << 1,
128 sampled = 1u << 2,
129 storage = 1u << 3,
130 render_target = 1u << 4,
131};
132
134enum class GpuBufferUsage : std::uint32_t {
135 none = 0,
136 map_read = 1u << 0,
137 map_write = 1u << 1,
138 copy_src = 1u << 2,
139 copy_dst = 1u << 3,
140 index = 1u << 4,
141 vertex = 1u << 5,
142 uniform = 1u << 6,
143 storage = 1u << 7,
144};
145
147 return static_cast<GpuTextureUsage>(static_cast<std::uint32_t>(a) |
148 static_cast<std::uint32_t>(b));
149}
150constexpr bool has_usage(GpuTextureUsage set, GpuTextureUsage bit) {
151 return (static_cast<std::uint32_t>(set) & static_cast<std::uint32_t>(bit)) != 0;
152}
154 return static_cast<GpuBufferUsage>(static_cast<std::uint32_t>(a) |
155 static_cast<std::uint32_t>(b));
156}
157constexpr bool has_usage(GpuBufferUsage set, GpuBufferUsage bit) {
158 return (static_cast<std::uint32_t>(set) & static_cast<std::uint32_t>(bit)) != 0;
159}
160
161// ── Resources ────────────────────────────────────────────────────────────
162
174
176 public:
177 GpuTexture() = default;
178 bool valid() const noexcept;
179 std::uint32_t width() const noexcept;
180 std::uint32_t height() const noexcept;
181 GpuFormat format() const noexcept;
182 GpuTextureUsage usage() const noexcept;
183 std::uint32_t sample_count() const noexcept;
184
185 private:
186 friend struct detail::GpuAccess;
187 std::shared_ptr<detail::GpuTextureState> state_;
188};
189
195
197 public:
198 GpuBuffer() = default;
199 bool valid() const noexcept;
200 std::uint64_t size() const noexcept;
201 GpuBufferUsage usage() const noexcept;
202
203 private:
204 friend struct detail::GpuAccess;
205 std::shared_ptr<detail::GpuBufferState> state_;
206};
207
210 bool linear = true;
212 bool repeat = false;
213 std::string label;
214};
215
217 public:
218 GpuSampler() = default;
219 bool valid() const noexcept;
220
221 private:
222 friend struct detail::GpuAccess;
223 std::shared_ptr<detail::GpuSamplerState> state_;
224};
225
230 public:
231 GpuShaderModule() = default;
232 bool valid() const noexcept;
233 const std::vector<WgslDiagnostic>& warnings() const noexcept;
234
235 private:
236 friend struct detail::GpuAccess;
237 std::shared_ptr<detail::GpuShaderModuleState> state_;
238};
239
240// ── Pipelines ────────────────────────────────────────────────────────────
241
251
257
259 std::uint64_t stride = 0;
260 bool per_instance = false;
261 std::vector<GpuVertexAttribute> attributes;
262};
263
264enum class GpuBlend : std::uint8_t {
273};
274
282
283enum class GpuCullMode : std::uint8_t { none, front, back };
284
295
300
306
309 std::string vertex_entry = "vs_main";
311 std::optional<GpuShaderModule> fragment_module;
312 std::string fragment_entry = "fs_main";
313 std::vector<GpuVertexBufferLayout> vertex_buffers;
314 std::vector<GpuColorTargetDesc> color_targets{GpuColorTargetDesc{}};
315 std::optional<GpuDepthStateDesc> depth;
318 std::uint32_t sample_count = 1;
319 std::string label;
320};
321
323 public:
324 GpuRenderPipeline() = default;
325 bool valid() const noexcept;
326
327 private:
328 friend struct detail::GpuAccess;
329 std::shared_ptr<detail::GpuRenderPipelineState> state_;
330};
331
334 std::string entry = "main";
335 std::string label;
336};
337
339 public:
341 bool valid() const noexcept;
342
343 private:
344 friend struct detail::GpuAccess;
345 std::shared_ptr<detail::GpuComputePipelineState> state_;
346};
347
350 enum class Kind : std::uint8_t { buffer, texture, sampler };
351
352 std::uint32_t binding = 0;
355 std::uint64_t offset = 0;
357 std::uint64_t size = 0;
360
361 static GpuBinding of(std::uint32_t binding, GpuBuffer buffer, std::uint64_t offset = 0,
362 std::uint64_t size = 0);
363 static GpuBinding of(std::uint32_t binding, GpuTexture texture);
364 static GpuBinding of(std::uint32_t binding, GpuSampler sampler);
365};
366
368 public:
369 GpuBindGroup() = default;
370 bool valid() const noexcept;
371
372 private:
373 friend struct detail::GpuAccess;
374 std::shared_ptr<detail::GpuBindGroupState> state_;
375};
376
377// ── Offscreen target ────────────────────────────────────────────────────
378
380 std::uint32_t width = 0;
381 std::uint32_t height = 0;
384 std::optional<GpuFormat> depth_format;
385 std::string label;
386};
387
389struct GpuPixels {
390 std::vector<std::uint8_t> bytes;
391 std::uint32_t width = 0;
392 std::uint32_t height = 0;
393 std::uint32_t bytes_per_pixel = 0;
395
399 std::array<std::uint8_t, 4> rgba8_at(std::uint32_t x, std::uint32_t y) const;
400};
401
406 public:
407 GpuTarget() = default;
408 bool valid() const noexcept;
409 std::uint32_t width() const noexcept;
410 std::uint32_t height() const noexcept;
412 std::optional<GpuTexture> depth() const;
413
418 read_pixels(std::chrono::milliseconds timeout = std::chrono::milliseconds(2000)) const;
419
420 private:
421 friend struct detail::GpuAccess;
422 std::shared_ptr<detail::GpuTargetState> state_;
423};
424
425// ── Device ──────────────────────────────────────────────────────────────
426
429 public:
430 GpuDevice() = default;
431
437
438 bool valid() const noexcept;
440 bool is_lost() const;
442
449 std::string_view label = {}) const;
454 std::uint32_t group,
455 const std::vector<GpuBinding>& bindings) const;
457 std::uint32_t group,
458 const std::vector<GpuBinding>& bindings) const;
460
463 GpuStatus write_buffer(const GpuBuffer& buffer, std::uint64_t offset, const void* data,
464 std::size_t size) const;
465
467 void process_events() const;
468
469 private:
470 friend struct detail::GpuAccess;
471 std::shared_ptr<detail::GpuDeviceState> state_;
472};
473
474// ── Recording ───────────────────────────────────────────────────────────
475
479 std::optional<std::array<float, 4>> clear;
481 std::optional<GpuTexture> resolve;
482};
483
485 std::vector<GpuColorAttachment> colors;
486 std::optional<GpuTexture> depth;
488 std::optional<float> depth_clear = 1.0f;
489 std::string label;
490
493 const GpuTarget& target,
494 std::optional<std::array<float, 4>> clear = std::array<float, 4>{0.0f, 0.0f, 0.0f, 0.0f});
495};
496
497class GpuFrame;
498
503 public:
505 GpuRenderPass& operator=(GpuRenderPass&&) noexcept;
506 GpuRenderPass(const GpuRenderPass&) = delete;
507 GpuRenderPass& operator=(const GpuRenderPass&) = delete;
509
510 bool valid() const noexcept;
511 void set_pipeline(const GpuRenderPipeline& pipeline);
512 void set_bind_group(std::uint32_t index, const GpuBindGroup& group);
513 void set_vertex_buffer(std::uint32_t slot, const GpuBuffer& buffer, std::uint64_t offset = 0);
515 void set_index_buffer(const GpuBuffer& buffer, bool uint32_indices = true,
516 std::uint64_t offset = 0);
517 void set_viewport(float x, float y, float width, float height, float min_depth = 0.0f,
518 float max_depth = 1.0f);
519 void set_scissor(std::uint32_t x, std::uint32_t y, std::uint32_t width, std::uint32_t height);
520 void draw(std::uint32_t vertex_count, std::uint32_t instance_count = 1,
521 std::uint32_t first_vertex = 0, std::uint32_t first_instance = 0);
522 void draw_indexed(std::uint32_t index_count, std::uint32_t instance_count = 1,
523 std::uint32_t first_index = 0, std::int32_t base_vertex = 0,
524 std::uint32_t first_instance = 0);
525 void end();
526
527 private:
528 friend class GpuFrame;
529 struct Impl;
530 explicit GpuRenderPass(std::unique_ptr<Impl> impl);
531 std::unique_ptr<Impl> impl_;
532};
533
536 public:
538 GpuComputePass& operator=(GpuComputePass&&) noexcept;
540 GpuComputePass& operator=(const GpuComputePass&) = delete;
542
543 bool valid() const noexcept;
544 void set_pipeline(const GpuComputePipeline& pipeline);
545 void set_bind_group(std::uint32_t index, const GpuBindGroup& group);
546 void dispatch(std::uint32_t x, std::uint32_t y = 1, std::uint32_t z = 1);
547 void end();
548
549 private:
550 friend class GpuFrame;
551 struct Impl;
552 explicit GpuComputePass(std::unique_ptr<Impl> impl);
553 std::unique_ptr<Impl> impl_;
554};
555
556enum class GpuSubmissionStatus : std::uint8_t { pending, succeeded, failed };
557
561 public:
562 GpuSubmission() = default;
568 GpuSubmissionStatus wait(std::chrono::milliseconds timeout) const;
570 std::optional<GpuError> error() const;
571
572 private:
573 friend struct detail::GpuAccess;
574 std::shared_ptr<detail::GpuSubmissionState> state_;
575};
576
586class GpuFrame {
587 public:
588 explicit GpuFrame(const GpuDevice& device, std::string_view label = {});
589 GpuFrame(GpuFrame&&) noexcept;
590 GpuFrame& operator=(GpuFrame&&) = delete;
591 GpuFrame(const GpuFrame&) = delete;
592 GpuFrame& operator=(const GpuFrame&) = delete;
594
596 GpuComputePass compute_pass(std::string_view label = {});
597
602 bool submitted() const noexcept;
603
604 private:
605 std::shared_ptr<detail::GpuFrameState> state_;
606};
607
608// ── Compositing ─────────────────────────────────────────────────────────
609
625GpuStatus draw_gpu_texture(canvas::Canvas& canvas, const GpuTexture& texture, float x, float y,
626 float w, float h);
627
628} // namespace pulp::render
Definition canvas.hpp:240
Definition gpu_pass.hpp:367
bool valid() const noexcept
friend struct detail::GpuAccess
Definition gpu_pass.hpp:373
Definition gpu_pass.hpp:196
std::uint64_t size() const noexcept
friend struct detail::GpuAccess
Definition gpu_pass.hpp:204
bool valid() const noexcept
GpuBufferUsage usage() const noexcept
An open compute pass. Same rules as GpuRenderPass.
Definition gpu_pass.hpp:535
friend class GpuFrame
Definition gpu_pass.hpp:550
GpuComputePass(GpuComputePass &&) noexcept
void set_bind_group(std::uint32_t index, const GpuBindGroup &group)
bool valid() const noexcept
void set_pipeline(const GpuComputePipeline &pipeline)
void dispatch(std::uint32_t x, std::uint32_t y=1, std::uint32_t z=1)
Definition gpu_pass.hpp:338
friend struct detail::GpuAccess
Definition gpu_pass.hpp:344
bool valid() const noexcept
Typed handle to the device a GpuSurface owns. Copies share it.
Definition gpu_pass.hpp:428
GpuStatus write_buffer(const GpuBuffer &buffer, std::uint64_t offset, const void *data, std::size_t size) const
Queue a buffer write.
const GpuDeviceCapabilities & capabilities() const
static GpuResult< GpuDevice > from_surface(GpuSurface &surface)
Wrap the surface's device, queue and instance.
GpuResult< GpuTexture > create_texture(const GpuTextureDesc &desc) const
GpuResult< GpuShaderModule > create_shader_module(std::string_view wgsl, std::string_view label={}) const
Compile WGSL.
bool is_lost() const
True once Dawn reports the device lost. Non-blocking.
GpuResult< GpuComputePipeline > create_compute_pipeline(const GpuComputePipelineDesc &desc) const
GpuResult< GpuBindGroup > create_bind_group(const GpuComputePipeline &pipeline, std::uint32_t group, const std::vector< GpuBinding > &bindings) const
GpuResult< GpuTarget > create_target(const GpuTargetDesc &desc) const
bool valid() const noexcept
GpuResult< GpuBindGroup > create_bind_group(const GpuRenderPipeline &pipeline, std::uint32_t group, const std::vector< GpuBinding > &bindings) const
Bind group group of a pipeline's automatic layout.
GpuResult< GpuBuffer > create_buffer(const GpuBufferDesc &desc) const
GpuResult< GpuSampler > create_sampler(const GpuSamplerDesc &desc={}) const
GpuResult< GpuRenderPipeline > create_render_pipeline(const GpuRenderPipelineDesc &desc) const
void process_events() const
Run pending Dawn callbacks once (submission status, readback).
GpuFrame(const GpuDevice &device, std::string_view label={})
bool submitted() const noexcept
GpuComputePass compute_pass(std::string_view label={})
GpuFrame(GpuFrame &&) noexcept
GpuResult< GpuSubmission > submit()
Finish the encoder and submit it.
GpuRenderPass render_pass(const GpuRenderPassDesc &desc)
An open render pass.
Definition gpu_pass.hpp:502
friend class GpuFrame
Definition gpu_pass.hpp:528
void set_viewport(float x, float y, float width, float height, float min_depth=0.0f, float max_depth=1.0f)
void set_vertex_buffer(std::uint32_t slot, const GpuBuffer &buffer, std::uint64_t offset=0)
void set_bind_group(std::uint32_t index, const GpuBindGroup &group)
void set_pipeline(const GpuRenderPipeline &pipeline)
void set_index_buffer(const GpuBuffer &buffer, bool uint32_indices=true, std::uint64_t offset=0)
32-bit indices when uint32_indices, 16-bit otherwise.
void draw(std::uint32_t vertex_count, std::uint32_t instance_count=1, std::uint32_t first_vertex=0, std::uint32_t first_instance=0)
bool valid() const noexcept
void draw_indexed(std::uint32_t index_count, std::uint32_t instance_count=1, std::uint32_t first_index=0, std::int32_t base_vertex=0, std::uint32_t first_instance=0)
GpuRenderPass(GpuRenderPass &&) noexcept
void set_scissor(std::uint32_t x, std::uint32_t y, std::uint32_t width, std::uint32_t height)
Definition gpu_pass.hpp:322
friend struct detail::GpuAccess
Definition gpu_pass.hpp:328
bool valid() const noexcept
Definition gpu_pass.hpp:216
friend struct detail::GpuAccess
Definition gpu_pass.hpp:222
bool valid() const noexcept
A compiled WGSL module.
Definition gpu_pass.hpp:229
bool valid() const noexcept
friend struct detail::GpuAccess
Definition gpu_pass.hpp:236
const std::vector< WgslDiagnostic > & warnings() const noexcept
std::optional< GpuError > error() const
The failure, once status() is failed.
GpuSubmissionStatus wait(std::chrono::milliseconds timeout) const
Run callbacks until terminal or timeout; pending on timeout.
GpuSubmissionStatus poll() const
Run pending callbacks once, then report.
GpuSubmissionStatus status() const
Current status without running callbacks.
Abstract GPU surface — a presentable rendering target backed by a native window/view.
Definition gpu_surface.hpp:112
Offscreen color target (and optional depth) with CPU readback.
Definition gpu_pass.hpp:405
std::uint32_t height() const noexcept
std::optional< GpuTexture > depth() const
GpuTexture color() const
friend struct detail::GpuAccess
Definition gpu_pass.hpp:421
bool valid() const noexcept
GpuResult< GpuPixels > read_pixels(std::chrono::milliseconds timeout=std::chrono::milliseconds(2000)) const
Copy the color texture to the CPU and wait for it (blocking, not for the audio thread).
std::uint32_t width() const noexcept
Definition gpu_pass.hpp:175
bool valid() const noexcept
friend struct detail::GpuAccess
Definition gpu_pass.hpp:186
GpuTextureUsage usage() const noexcept
std::uint32_t sample_count() const noexcept
std::uint32_t width() const noexcept
std::uint32_t height() const noexcept
GpuFormat format() const noexcept
Result<T, E> — either holds a T or an E, never both.
Definition result.hpp:76
What the shared Dawn device can render, as plain data.
Definition affine_transform.hpp:24
Definition gpu_pass.hpp:73
Definition gpu_fwd.hpp:31
GpuBlend
Definition gpu_pass.hpp:264
@ premultiplied
Premultiplied alpha: src + dst * (1 - a). Skia composites premultiplied.
Definition gpu_pass.hpp:270
@ alpha
Straight alpha: src * a + dst * (1 - a).
Definition gpu_pass.hpp:268
@ additive
src + dst.
Definition gpu_pass.hpp:272
@ replace
Write the fragment color as is.
Definition gpu_pass.hpp:266
constexpr bool has_usage(GpuTextureUsage set, GpuTextureUsage bit)
Definition gpu_pass.hpp:150
GpuPrimitiveTopology
Definition gpu_pass.hpp:275
@ triangle_strip
Definition gpu_pass.hpp:277
@ line_list
Definition gpu_pass.hpp:278
@ line_strip
Definition gpu_pass.hpp:279
@ point_list
Definition gpu_pass.hpp:280
@ triangle_list
Definition gpu_pass.hpp:276
GpuVertexFormat
Definition gpu_pass.hpp:242
@ float32x3
Definition gpu_pass.hpp:245
@ float32x4
Definition gpu_pass.hpp:246
@ uint32
Definition gpu_pass.hpp:247
@ float32x2
Definition gpu_pass.hpp:244
@ float32
Definition gpu_pass.hpp:243
@ unorm8x4
Definition gpu_pass.hpp:249
@ sint32
Definition gpu_pass.hpp:248
@ none
Definition gpu_capabilities.hpp:157
GpuTextureUsage
Texture usage bits. Values match WebGPU's GPUTextureUsage.
Definition gpu_pass.hpp:124
@ sampled
Definition gpu_pass.hpp:128
@ copy_src
Definition gpu_pass.hpp:126
@ render_target
Definition gpu_pass.hpp:130
@ storage
Definition gpu_pass.hpp:129
@ copy_dst
Definition gpu_pass.hpp:127
GpuCompare
Definition gpu_pass.hpp:285
@ equal
Definition gpu_pass.hpp:291
@ greater_equal
Definition gpu_pass.hpp:290
@ less_equal
Definition gpu_pass.hpp:288
@ greater
Definition gpu_pass.hpp:289
@ not_equal
Definition gpu_pass.hpp:292
@ never
Definition gpu_pass.hpp:286
@ less
Definition gpu_pass.hpp:287
@ always
Definition gpu_pass.hpp:293
GpuBufferUsage
Buffer usage bits. Values match WebGPU's GPUBufferUsage.
Definition gpu_pass.hpp:134
@ vertex
Definition gpu_pass.hpp:141
@ map_write
Definition gpu_pass.hpp:137
@ index
Definition gpu_pass.hpp:140
@ uniform
Definition gpu_pass.hpp:142
@ map_read
Definition gpu_pass.hpp:136
@ copy_dst
Definition gpu_pass.hpp:139
runtime::Result< T, GpuError > GpuResult
Definition gpu_pass.hpp:117
constexpr GpuTextureUsage operator|(GpuTextureUsage a, GpuTextureUsage b)
Definition gpu_pass.hpp:146
GpuSubmissionStatus
Definition gpu_pass.hpp:556
@ pending
Definition gpu_pass.hpp:556
@ succeeded
Definition gpu_pass.hpp:556
std::string_view gpu_error_kind_name(GpuError::Kind kind)
GpuFormat
Texture formats the typed GPU API accepts.
Definition gpu_capabilities.hpp:20
@ undefined
Definition gpu_capabilities.hpp:21
@ depth24_plus
Definition gpu_capabilities.hpp:39
@ rgba8_unorm
Definition gpu_capabilities.hpp:24
GpuStatus draw_gpu_texture(canvas::Canvas &canvas, const GpuTexture &texture, float x, float y, float w, float h)
Draw texture into the canvas rectangle (x, y, w, h).
GpuCullMode
Definition gpu_pass.hpp:283
@ none
Definition gpu_pass.hpp:283
@ back
Definition gpu_pass.hpp:283
@ front
Definition gpu_pass.hpp:283
runtime::Result< void, GpuError > GpuStatus
Success is a default-constructed value.
Definition gpu_pass.hpp:119
STL namespace.
Result<T, E> — success / failure union for fallible operations.
One entry of a bind group: a buffer range, a texture or a sampler.
Definition gpu_pass.hpp:349
static GpuBinding of(std::uint32_t binding, GpuBuffer buffer, std::uint64_t offset=0, std::uint64_t size=0)
static GpuBinding of(std::uint32_t binding, GpuSampler sampler)
static GpuBinding of(std::uint32_t binding, GpuTexture texture)
GpuSampler sampler
Definition gpu_pass.hpp:359
GpuBuffer buffer
Definition gpu_pass.hpp:354
Kind
Definition gpu_pass.hpp:350
@ buffer
Definition gpu_pass.hpp:350
std::uint32_t binding
Definition gpu_pass.hpp:352
GpuTexture texture
Definition gpu_pass.hpp:358
Kind kind
Definition gpu_pass.hpp:353
std::uint64_t offset
Definition gpu_pass.hpp:355
std::uint64_t size
0 binds from offset to the end of the buffer.
Definition gpu_pass.hpp:357
Definition gpu_pass.hpp:190
GpuBufferUsage usage
Definition gpu_pass.hpp:192
std::string label
Definition gpu_pass.hpp:193
std::uint64_t size
Definition gpu_pass.hpp:191
Definition gpu_pass.hpp:476
std::optional< GpuTexture > resolve
Resolve a multisampled texture into this single-sample texture.
Definition gpu_pass.hpp:481
GpuTexture texture
Definition gpu_pass.hpp:477
std::optional< std::array< float, 4 > > clear
Clear to this RGBA before drawing; load the existing contents when unset.
Definition gpu_pass.hpp:479
Definition gpu_pass.hpp:296
GpuBlend blend
Definition gpu_pass.hpp:298
GpuFormat format
Definition gpu_pass.hpp:297
Definition gpu_pass.hpp:332
std::string label
Definition gpu_pass.hpp:335
std::string entry
Definition gpu_pass.hpp:334
GpuShaderModule module
Definition gpu_pass.hpp:333
Definition gpu_pass.hpp:301
GpuFormat format
Definition gpu_pass.hpp:302
GpuCompare compare
Definition gpu_pass.hpp:304
bool write
Definition gpu_pass.hpp:303
Rendering capabilities of the shared device.
Definition gpu_capabilities.hpp:109
Definition gpu_pass.hpp:90
std::string message
Definition gpu_pass.hpp:107
Kind kind
Definition gpu_pass.hpp:106
Kind
Definition gpu_pass.hpp:91
@ device_lost
Definition gpu_pass.hpp:102
@ out_of_memory
Definition gpu_pass.hpp:100
@ unavailable
No device, or this build has no Dawn.
Definition gpu_pass.hpp:93
@ shader_compilation
WGSL failed to compile; diagnostics holds the messages.
Definition gpu_pass.hpp:97
@ timeout
Definition gpu_pass.hpp:103
@ validation
Dawn validation rejected the call.
Definition gpu_pass.hpp:99
@ internal
Definition gpu_pass.hpp:101
@ invalid_argument
A descriptor or call the API rejects before reaching Dawn.
Definition gpu_pass.hpp:95
std::string describe() const
kind: message, followed by one formatted diagnostic per line.
std::vector< WgslDiagnostic > diagnostics
Compiler messages for shader_compilation (and any warnings).
Definition gpu_pass.hpp:109
Tightly packed pixels read back from a target, rows top to bottom.
Definition gpu_pass.hpp:389
std::uint32_t height
Definition gpu_pass.hpp:392
GpuFormat format
Definition gpu_pass.hpp:394
std::uint32_t width
Definition gpu_pass.hpp:391
std::vector< std::uint8_t > bytes
Definition gpu_pass.hpp:390
std::array< std::uint8_t, 4 > rgba8_at(std::uint32_t x, std::uint32_t y) const
The texel at (x, y) as RGBA bytes.
std::uint32_t bytes_per_pixel
Definition gpu_pass.hpp:393
Definition gpu_pass.hpp:484
std::string label
Definition gpu_pass.hpp:489
std::vector< GpuColorAttachment > colors
Definition gpu_pass.hpp:485
std::optional< GpuTexture > depth
Definition gpu_pass.hpp:486
static GpuRenderPassDesc for_target(const GpuTarget &target, std::optional< std::array< float, 4 > > clear=std::array< float, 4 >{0.0f, 0.0f, 0.0f, 0.0f})
The target's color (cleared to clear) and its depth, if any.
std::optional< float > depth_clear
Clear depth to this value; load when unset.
Definition gpu_pass.hpp:488
Definition gpu_pass.hpp:307
std::vector< GpuVertexBufferLayout > vertex_buffers
Definition gpu_pass.hpp:313
GpuCullMode cull
Definition gpu_pass.hpp:317
std::uint32_t sample_count
Definition gpu_pass.hpp:318
std::optional< GpuDepthStateDesc > depth
Definition gpu_pass.hpp:315
std::vector< GpuColorTargetDesc > color_targets
Definition gpu_pass.hpp:314
GpuShaderModule module
Definition gpu_pass.hpp:308
std::string label
Definition gpu_pass.hpp:319
std::optional< GpuShaderModule > fragment_module
Defaults to module when unset.
Definition gpu_pass.hpp:311
std::string fragment_entry
Definition gpu_pass.hpp:312
GpuPrimitiveTopology topology
Definition gpu_pass.hpp:316
std::string vertex_entry
Definition gpu_pass.hpp:309
Definition gpu_pass.hpp:208
std::string label
Definition gpu_pass.hpp:213
bool linear
Linear filtering when true, nearest when false.
Definition gpu_pass.hpp:210
bool repeat
Repeat addressing when true, clamp-to-edge when false.
Definition gpu_pass.hpp:212
Definition gpu_pass.hpp:379
GpuFormat color_format
Definition gpu_pass.hpp:382
std::string label
Definition gpu_pass.hpp:385
std::uint32_t width
Definition gpu_pass.hpp:380
std::optional< GpuFormat > depth_format
A depth attachment of this format when set.
Definition gpu_pass.hpp:384
std::uint32_t height
Definition gpu_pass.hpp:381
Definition gpu_pass.hpp:163
std::uint32_t sample_count
1, or 4 for a multisampled attachment (see GpuDeviceCapabilities).
Definition gpu_pass.hpp:171
std::uint32_t width
Definition gpu_pass.hpp:164
GpuFormat format
Definition gpu_pass.hpp:166
std::string label
Definition gpu_pass.hpp:172
GpuTextureUsage usage
The default suits a pass output that is composited and read back.
Definition gpu_pass.hpp:168
std::uint32_t height
Definition gpu_pass.hpp:165
Definition gpu_pass.hpp:252
std::uint32_t location
Definition gpu_pass.hpp:255
GpuVertexFormat format
Definition gpu_pass.hpp:253
std::uint64_t offset
Definition gpu_pass.hpp:254
Definition gpu_pass.hpp:258
std::uint64_t stride
Definition gpu_pass.hpp:259
std::vector< GpuVertexAttribute > attributes
Definition gpu_pass.hpp:261
bool per_instance
Definition gpu_pass.hpp:260
Definition wgsl_diagnostics.hpp:19
WGSL compiler messages as data.