Commit Graph
1504 Commits
Author SHA1 Message Date
VecvecandConnor Fitzgerald 9e744954f7 [wgpu-core] Ray tracing pipelines (#10144)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2026-11-05 19:20:32 +00:00
MichaëlandMichaël DM 11c1f4b12c Add Features::UNRESTRICTED_BYTES_PER_ROW (#10619)
Co-authored-by: Michaël DM <micode@micorp.fr>
2026-10-30 15:33:16 +00:00
Teodor Tanasoaia a979c33dcd Return SubmissionIndex only if submissions succeed (#10218) 2026-10-27 13:16:23 +00:00
Jim Blandy ad5a70aea1 [core] Validate shader stages after applying pipeline overrides.
The WebGPU specification requires pipeline creation to validate
properties of shader stages, like workgroup sizes, that may depend on
the values of pipeline-overridable constants. Previously, wgpu-core
validated stages using an `Interface` built from the module before
overrides were applied, with results contrary to spec. Override
processing was then carried out by `wgpu_hal`, after all validation
had supposedly been taken care of.

This commit has `create_shader_module` save the validated Naga module
instead of creating a `wgpu_hal` shader module. At pipeline creation
time, `StageCompiler::compile` now applies the stage's override values
with `process_overrides`, validates the stage using an `Interface`
built from the result, and, if that validation succeeds, returns a
`CompiledStage` holding the `wgpu_hal` `ShaderModule` created from it.
Dropping the `CompiledStage` destroys that module once the pipeline
has been created.

Since the override values have already been applied, we pass
`wgpu_hal` empty sets of constants for these modules.

Since the `naga::back::pipeline_constants` module is now used by
`wgpu_core` rather than `wgpu_hal` backends, it can't be conditionally
available based on Naga's backend features. Include it
unconditionally.

This change removes `Interface::finalize_entry_point_name`, since we
no longer build an `Interface` at shader module creation. Instead, we
choose entry points from the `naga::Module` directly.

Add new tests: `tests/tests/wgpu-validation/api/overrides.rs`

Fixes #9774.
2026-10-26 23:42:33 +00:00
Jim Blandy e136c379cb [core] Validate pipeline stages with a shared StageCompiler helper.
Introduce `StageCompiler`, in the new `wgpu_core::device::stage_compiler`
module, which performs the per-stage work that
`create_compute_pipeline_or_error_inner` and
`create_render_pipeline_or_error_inner` previously repeated for each
stage: checking the shader module's validity and device, choosing
the entry point, checking the stage against the module's interface,
and tracking which stages were validated.

`StageCompiler::compile` returns a `CompiledStage`, which borrows the
module the stage should use, and records the entry point name. From
this we can build a `hal::ProgrammableStage` to use when creating the
hal pipeline.

Have `StageCompiler::compile` reject a passthrough stage immediately
if the pipeline's layout is being derived. `ImplicitLayoutError::Passthrough`
now names only that stage, rather than every passthrough stage in the
pipeline.

Remove `ImplicitLayoutError::ReflectionError`, along with the check
that reported it. The condition it was concerned with, deriving a
layout from a stage we couldn't reflect, is already rejected as
`ImplicitLayoutError::Passthrough`. The only way left to reach it was
a bug: for mesh pipelines without a fragment stage, it expected the
last stage to be a vertex stage, and so rejected them incorrectly.

In this commit, `StageCompiler` only does validation, but by the end
of this pull request, it will be compiling shader modules. Having its
name overstate its role for one commit seems clearer than introducing
everything in one commit and renaming it in the next. The comments,
however, are accurate in each commit.

This commit also changes compute pipelines to report errors in the
same way as render pipelines: an invalid shader module is now reported
as a `CreatePipelineError::Stage` error, and the shader module is
checked after the pipeline layout, not before.
2026-10-26 23:42:33 +00:00
Jim Blandy 78917c587b [core] Introduce validation::PipelineResources.
Gather the state that `Interface::check_stage` accumulates across all
of a pipeline's stages (the bind group layouts, minimum binding sizes,
and immediate data usage) into a new `PipelineResources` struct, which
`check_stage` takes by `&mut`.

Remove `immediates` from `StageIo`, so that `StageIo` holds only the
information one stage passes to the next.

Use `layout` to refer to the `BindingLayoutSource`, not `layouts`,
since that value describes a single pipeline layout. In the derived
case, it does hold an array of bind group layouts, but that is only
one variant; the value's name should make sense regardless which
variant is present.
2026-10-26 23:42:33 +00:00
Jim Blandy 6c6fb05421 [core] create_render_pipeline_or_error_inner: Tidy temporary vars.
In `wgpu_core/src/device/resource.rs`, in the function
`Device::create_render_pipeline_or_error_inner`, remove the leading
`_` from the following local variables' names, and simply leave them
uninitialized in their declaration:

- `_vertex_entry_point_name`
- `_task_entry_point_name`
- `_mesh_entry_point_name`

Rust is smart enough to see that these are always initialized before
they are used, and thus don't need to be initialized at their
declaration.
2026-10-26 23:42:33 +00:00
Jim Blandy 4f4581fdff [core] Combine ShaderModuleState with ShaderMetaData.
In `wgpu_core::pipeline`, delete `ShaderMetaData` and turn
`ShaderModuleState` into the equivalent enum, giving both the
`NagaModule` and `Passthrough` variants their own `raw` field.

Arrange for uses of `ShaderModuleState` to extract the raw `wgpu_hal`
module in the `match` expression that handles the two variants.

In isolation, this change looks like mere rearrangement, not a
cleanup, but hopefully either way it's easy to see that it has no
effect on behavior. Subsequent commits will remove `raw` from the
`NagaModule` variant; this refactor will allow that to affect only the
`NagaModule` `match` arms, leaving the passthrough code unaffected.
2026-10-26 23:42:33 +00:00
Jim Blandy 00583c146b [core] Move ShaderMetaData, PassthroughInterface to pipeline.rs.
Move the definitions of `ShaderMetaData` and `PassthroughInterface`
from `wgpu_core::validation`, which does not use them, to
`wgpu_core::pipeline`, where they are used in `ShaderModuleState`, and
created.
2026-10-26 23:42:33 +00:00
Jim Blandy 48b67d4826 [core] Refactor ShaderMetaData use sites to use match.
Slightly reorder the sites that consume `ShaderMetaData` values, so
that the code for the `NagaModule` and `Passthrough` cases can be
gathered into `match` statements.
2026-10-26 23:42:33 +00:00
Jim Blandy 69863648a8 [core] Turn ShaderMetaData into a Naga-vs.-passthrough enum.
Rename the `ShaderMetaData::Interface` variant to `NagaModule`,
and make it a struct-like variant.

Delete `ShaderMetaData::interface`, and update its call sites to use a
`match` expression directly on the enum instead. This makes the use
sites clearer, by making it apparent which style of module we're
processing.
2026-10-26 23:42:33 +00:00
sagudev a8cfdef04e [core] Support passing MapMode as (potentially invalid) bitflags
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-10-26 18:49:57 +00:00
sagudev 4e98175c04 [core] Destruct BufferMappingOperation into mode and callback arguments
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-10-26 18:49:57 +00:00
JMS55 2edafa5240 Record 1 barrier for N Queue::write_buffer/texture calls by deferring to submit time (#10319) 2026-10-25 11:57:55 +00:00
Jim Blandy 3050396df2 [core] Combine Create{Compute,Render}PipelineError. (#10569) 2026-10-20 19:51:32 +00:00
Andy Leiserson 0342e2fba5 fix(core): Check same-device for external texture planes (#10636) 2026-10-20 16:56:33 +00:00
Andy Leiserson eb4678dd08 refactor(naga): Expose indices of ExternalTextureParams members 2026-10-13 19:34:06 +00:00
sagudev f4455f178d get_mapped_range return Mapping which holds the BufferState lock
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-10-08 11:08:30 +00:00
Connor Fitzgerald 8d16ec493b fix(core): implement Send and Sync for Device manually
Every resource holds an `Arc<Device>`, so evaluating their auto traits
used to walk all of `Device`. This exceeded the default recursion limit
on nightly for `wgpu::CoreCommandEncoder`.
2026-10-05 15:05:01 +00:00
Sam fcd059f423 Move MapMode into wgpu-types and use it instead of HostMap in wgpu-core (#10474)
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-09-28 11:15:27 +00:00
Patrik NilssonandConnor Fitzgerald 3ea8d8c6ef perf(core): Inline small bind group descriptor storage (#10188)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2026-09-24 05:54:36 +00:00
Andy Leiserson dea6925ee1 Release BLAS_COMPACTION_STATE before acquiring QUEUE_LIFE_TRACKER 2026-09-18 19:56:30 +00:00
Erich Gubler 81e38d86f4 fix: emit NeedsInitializedMemory for create_external_texture_binding 2026-09-18 11:04:22 +00:00
Erich Gubler 5086e107a2 fix: emit NeedsInitializedMemory for create_external_texture_binding_from_view (#10276) 2026-09-17 11:53:59 +00:00
sagudev d78940969e vendor BindGroupLayoutEntry into wgc and allow specifying more/none binding types
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-09-17 10:18:50 +00:00
Sam 91fe2f9593 Implement unconfigure in wgc and use it for configure (#10296)
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-09-11 13:46:04 +02:00
Andy Leiserson f3982866be refactor(core): Replace StagingBuffer::write with write_exact 2026-09-08 15:07:15 -07:00
Andy Leiserson fb93139671 feat: Support zero-size vertex and index buffer bindings
Fixes #3170
2026-09-08 15:07:15 -07:00
Andy Leiserson ea0afc6216 refactor: Parameterize type of hal::BufferBinding::size; resolve sizes in core
For storage and uniform buffer bindings, the size is a `wgt::BufferSize`
(`NonZeroU64`). For vertex and index buffer bindings, the size is a 
`wgt::BufferAddress` (regular `u64`).

Temporarily breaks some zero-size vertex/index binding cases that worked
before (end of buffer); will be resolved in an immediate follow-up
commit that fully implements zero-size vertex/index binding support.
2026-09-08 15:07:15 -07:00
Sam c268540bee [core] public *_pipeline_or_error methods return invalid pipeline on lost device (#10260) 2026-09-04 12:53:20 +00:00
sagudev bdea80afac Move error handling of create_shader_module into wgc
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-09-04 13:38:23 +02:00
sagudev 31f1b0cd81 Move compilation_info into wgc
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-09-04 13:38:23 +02:00
Andy Leiserson b56be0cf55 fix(core): Drop internals of Device in the correct order (#10243) 2026-09-03 11:11:30 -07:00
Helgev e6af9e9641 Fix stale poll() doc comments referring to a bool return value
Device::poll (both the public wgpu API and the wgpu-core internal
version), the internal maintain() helper, and Global::device_poll
still described their return value as a plain true/false, left over
from before they returned Result<PollStatus, PollError>. Point readers
at PollStatus/PollError (and UserClosures for maintain's closures)
instead of restating semantics that duplicate their own docs.
2026-09-02 09:31:04 -07:00
Sam 9035f605b7 [core] Log shader translation error and beg for bug reports (#10241)
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-09-02 15:26:30 +02:00
Andy Leiserson 818586c4d1 fix(core): Clean up resources after failed initialization (#10160) 2026-09-01 14:54:46 -07:00
Sam 7db2bd022a Move erroring of create_render_pipeline into wgc (#10227)
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-09-01 18:41:49 +02:00
Andy Leiserson 55c7f91ef6 chore(core): Add comments on bind group init actions (#10224) 2026-09-01 06:20:18 -04:00
Sam 000cc9699f Move erroring of create_query_set into wgc (#10217)
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-08-31 19:00:20 +00:00
Sam 443fca8097 Move erroring from create_bind_group_layout into wgc (#10215)
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-08-31 20:21:46 +02:00
Sam 6008736585 Move erroring of create_buffer into wgc (#10214)
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-08-31 18:59:34 +02:00
Sam eb0150579d Move erroring of create_texture and implement missing validation (#10165)
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-08-31 09:47:48 +00:00
Sam 78fa6152cc Revert part of #10115 by removing result from create_render_bundle_encoder and reimpl content validation in deno (#10179) 2026-08-31 10:21:22 +02:00
07132f4440 Implement texture-component-swizzle (#9553)
Co-authored-by: Inner Daemons <85136135+inner-daemons@users.noreply.github.com>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2026-08-30 03:49:16 -04:00
Robin Cramer 855ead0745 Added cleared field to create_texture_from_hal (#10076) 2026-08-29 18:44:36 -04:00
Zac Harrold 1098476cd0 wgpu-core: use wgpu-sync for atomics 2026-08-28 20:37:31 -04:00
AdrianEddy a148f96e20 feat(webgl): Add ability to interop with external textures (#9834) 2026-08-28 21:18:35 +00:00
Luo ZhihaoandConnor Fitzgerald 4d749308e6 Fix separate depth stencil read-only state (#9763)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2026-08-28 15:31:26 +00:00
Andy Leiserson ca76233ed9 fix(core): Add missing DISCARD_HAL_LABELS checks in ray tracing (#10123) 2026-08-27 06:24:10 -04:00
Marc Stampfli 8c87a72876 fix(core): deadlock between Queue::compact_blas and Queue::submit (#10118) 2026-08-25 23:12:05 +00:00