New mesh shader limits (#8507)

* Initial commit

* Other initial changes

* Updated shader snapshots

* Added new HLSL limitation

* Moved error to global variable error

* Added docs to per_primitive

* Added a little bit more docs here and there in IR

* Adding validation to ensure that task shaders have a task payload

* Updated spec to reflect the change to payload variables

* Updated the mesh shading spec because it was goofy

* some doc tweaks

* Tried to clarify docs a little

* Tried to update spec

* Removed a warning

* Addressed comment about docs mistake

* Review in progress

- Extensive revisions to `docs/api-specs/mesh_shading.md`.

- Doc comments.

- Ensure `Module` stays at the bottom of `ir/mod.rs`.

- Avoid a clone.

- Rename some arguments to be more specific.

- Minor readability tweaks.

* mesh_shading.md: more tweaks

* Ran cargo fmt

* Small tweaks

* [naga] Move definition of `ShaderStage::compute_like` to `proc`.

Move the definition of `naga::ShaderStage::compute_like` from
`naga::ir` into `naga::proc`. We generally want ot keep methods out of
`naga::ir`, since the IR itself is complicated enough already.

* Replace TODO comment with followup issue.

* Update analyzer.rs

Co-authored-by: Jim Blandy <jimb@red-bean.com>

* Removed stuff in accordance with Jim's recommendation

* minor changes for readability

* Pull mesh shader output type validation out into its own function.

* doc fixes

* remove duplicated task payload validation

* Quick little changes

* Another quick fix

* Quick fix

* Removed unnecessary TODO statement

* A

* Tried to be more expressive

* Made functions only work in mesh shader entry points

* Various validation fix attempts

* Undid capabilities resize

* WGSL PR is up :)

* Update naga/src/ir/mod.rs

Co-authored-by: Erich Gubler <erichdongubler@gmail.com>

* Update naga/src/front/wgsl/error.rs

Co-authored-by: Erich Gubler <erichdongubler@gmail.com>

* Update naga/src/ir/mod.rs

Co-authored-by: Erich Gubler <erichdongubler@gmail.com>

* Other Erich suggestion

* Updated docs & validation for some builtins

* Added some docs & removed contentious "// TODO"

* Fixed bad validation, formatted mesh shader wgsl

* Rewrote the IR and parser significantly

* Improved validation slightly, remvoed obselete crap, fixed bug in compaction, made clippy happy

* Added changelog entry

* Made parser respect enable extension

* Updated mesh shader spec

* Cleaned up the mesh shader analyzer function

* Updated changelog

* Updated validation from spv-write

* Slight tweaks

* Added capabilitiy thing blah blah blah

* Fixed compaction & clean stuff up

* Fixed compaction and such pt 2

* Paved the way for primitive-index stuff

* Little bit of cleanup

* Added new features/capabilities for point primitives and added snapshots for stuff

* Updated spec to rename something

* Updated some limits stuff

* Made some improvements

* Fixed doctests & webgpu stuff

* Fixed experimental features stuff

* A little more scaffolding

* Added some initial validation

* Added per primitive validation

* Improved per primitive validation

* Added some more validation

* Fixed primitive index validation

* Updated the spec

* Updated comments on some limits

* Made some fixes

* Fixed new validation rule for task payload size

* Update wgpu-core/src/validation.rs

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>

* Update wgpu-core/src/validation.rs

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>

* A small tweak to mesh shader recommended minimums

* Addressed 2 comments

* A few more comments addressed with limits

* Addressed more comments

* Update wgpu-core/src/validation.rs

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>

* Split up error

* Addressed another comment by changing workgroup size validation

* Final comment addressed

* Update wgpu-info/src/human.rs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update wgpu-core/src/validation.rs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update wgpu-info/src/human.rs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fixed compilation and added some new test functions

---------

Co-authored-by: SupaMaggie70Incorporated <85136135+SupaMaggie70Incorporated@users.noreply.github.com>
Co-authored-by: Jim Blandy <jimb@red-bean.com>
Co-authored-by: Erich Gubler <erichdongubler@gmail.com>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2025-12-17 05:13:27 +00:00
1 parent f1b79b1c30
commit 952d653835
15 files changed
+1098 -337

No files matched your search

+61
View File
@@ -41,6 +41,20 @@ fn ts_main() -> @builtin(mesh_task_size) vec3<u32> {
return vec3(1, 1, 1);
}
// This tests if we can properly write a task shader that is divergent
@task
@payload(taskPayload)
@workgroup_size(2)
fn ts_divergent(@builtin(local_invocation_index) thread_id: u32) -> @builtin(mesh_task_size) vec3<u32> {
if thread_id == 0 {
taskPayload.colorMask = vec4(1.0, 1.0, 0.0, 1.0);
taskPayload.visible = true;
return vec3(1, 1, 1);
}
// Only the first thread's value is taken
return vec3(2,2,2);
}
struct MeshOutput {
@builtin(vertices) vertices: array<VertexOutput, 3>,
@builtin(primitives) primitives: array<PrimitiveOutput, 1>,
@@ -72,6 +86,53 @@ fn ms_main() {
mesh_output.primitives[0].colorMask = vec4<f32>(1.0, 0.0, 1.0, 1.0);
}
@mesh(mesh_output)
@workgroup_size(1)
fn ms_no_ts() {
mesh_output.vertex_count = 3;
mesh_output.primitive_count = 1;
workgroupData = 2.0;
mesh_output.vertices[0].position = positions[0];
mesh_output.vertices[0].color = colors[0];
mesh_output.vertices[1].position = positions[1];
mesh_output.vertices[1].color = colors[1];
mesh_output.vertices[2].position = positions[2];
mesh_output.vertices[2].color = colors[2];
mesh_output.primitives[0].indices = vec3<u32>(0, 1, 2);
mesh_output.primitives[0].cull = false;
mesh_output.primitives[0].colorMask = vec4<f32>(1.0, 0.0, 1.0, 1.0);
}
// See ts_divergent comment
@mesh(mesh_output)
@workgroup_size(1)
fn ms_divergent(@builtin(local_invocation_index) thread_id: u32) {
if thread_id == 0 {
mesh_output.vertex_count = 3;
mesh_output.primitive_count = 1;
workgroupData = 2.0;
mesh_output.vertices[0].position = positions[0];
mesh_output.vertices[0].color = colors[0];
mesh_output.vertices[1].position = positions[1];
mesh_output.vertices[1].color = colors[1];
mesh_output.vertices[2].position = positions[2];
mesh_output.vertices[2].color = colors[2];
mesh_output.primitives[0].indices = vec3<u32>(0, 1, 2);
mesh_output.primitives[0].cull = false;
mesh_output.primitives[0].colorMask = vec4<f32>(1.0, 0.0, 1.0, 1.0);
// "Early" return
return;
}
}
@fragment
fn fs_main(vertex: VertexOutput, primitive: PrimitiveInput) -> @location(0) vec4<f32> {
return vertex.color * primitive.colorMask;
+540 -201
View File
@@ -1,32 +1,65 @@
; SPIR-V
; Version: 1.4
; Generator: rspirv
; Bound: 190
; Bound: 384
OpCapability Shader
OpCapability MeshShadingEXT
OpExtension "SPV_EXT_mesh_shader"
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint TaskEXT %24 "ts_main" %17 %19 %33
OpEntryPoint MeshEXT %78 "ms_main" %17 %54 %64 %68 %71 %74 %77 %19 %21 %90
OpEntryPoint Fragment %185 "fs_main" %176 %179 %182 %184
OpEntryPoint TaskEXT %57 "ts_divergent" %54 %17
OpEntryPoint MeshEXT %95 "ms_main" %17 %72 %81 %85 %88 %91 %94 %19 %21 %107
OpEntryPoint MeshEXT %214 "ms_no_ts" %192 %200 %204 %207 %210 %213 %19 %21 %217
OpEntryPoint MeshEXT %301 "ms_divergent" %279 %287 %291 %294 %297 %300 %19 %21 %303
OpEntryPoint Fragment %379 "fs_main" %370 %373 %376 %378
OpExecutionMode %24 LocalSize 1 1 1
OpExecutionMode %78 LocalSize 1 1 1
OpExecutionMode %78 OutputTrianglesNV
OpExecutionMode %78 OutputVertices 3
OpExecutionMode %78 OutputPrimitivesNV 1
OpExecutionMode %185 OriginUpperLeft
OpDecorate %54 BuiltIn LocalInvocationIndex
OpMemberDecorate %61 0 BuiltIn Position
OpDecorate %61 Block
OpMemberDecorate %65 0 BuiltIn CullPrimitiveEXT
OpMemberDecorate %65 0 PerPrimitiveNV
OpDecorate %65 Block
OpDecorate %68 PerPrimitiveNV
OpDecorate %71 Location 0
OpDecorate %74 BuiltIn PrimitiveTriangleIndicesEXT
OpDecorate %77 Location 1
OpDecorate %77 PerPrimitiveNV
OpExecutionMode %57 LocalSize 2 1 1
OpExecutionMode %95 LocalSize 1 1 1
OpExecutionMode %95 OutputTrianglesNV
OpExecutionMode %95 OutputVertices 3
OpExecutionMode %95 OutputPrimitivesNV 1
OpExecutionMode %214 LocalSize 1 1 1
OpExecutionMode %214 OutputTrianglesNV
OpExecutionMode %214 OutputVertices 3
OpExecutionMode %214 OutputPrimitivesNV 1
OpExecutionMode %301 LocalSize 1 1 1
OpExecutionMode %301 OutputTrianglesNV
OpExecutionMode %301 OutputVertices 3
OpExecutionMode %301 OutputPrimitivesNV 1
OpExecutionMode %379 OriginUpperLeft
OpDecorate %72 BuiltIn LocalInvocationIndex
OpMemberDecorate %78 0 BuiltIn Position
OpDecorate %78 Block
OpMemberDecorate %82 0 BuiltIn CullPrimitiveEXT
OpMemberDecorate %82 0 PerPrimitiveNV
OpDecorate %82 Block
OpDecorate %85 PerPrimitiveNV
OpDecorate %88 Location 0
OpDecorate %91 BuiltIn PrimitiveTriangleIndicesEXT
OpDecorate %94 Location 1
OpDecorate %94 PerPrimitiveNV
OpDecorate %192 BuiltIn LocalInvocationIndex
OpMemberDecorate %197 0 BuiltIn Position
OpDecorate %197 Block
OpMemberDecorate %201 0 BuiltIn CullPrimitiveEXT
OpMemberDecorate %201 0 PerPrimitiveNV
OpDecorate %201 Block
OpDecorate %204 PerPrimitiveNV
OpDecorate %207 Location 0
OpDecorate %210 BuiltIn PrimitiveTriangleIndicesEXT
OpDecorate %213 Location 1
OpDecorate %213 PerPrimitiveNV
OpMemberDecorate %284 0 BuiltIn Position
OpDecorate %284 Block
OpMemberDecorate %288 0 BuiltIn CullPrimitiveEXT
OpMemberDecorate %288 0 PerPrimitiveNV
OpDecorate %288 Block
OpDecorate %291 PerPrimitiveNV
OpDecorate %294 Location 0
OpDecorate %297 BuiltIn PrimitiveTriangleIndicesEXT
OpDecorate %300 Location 1
OpDecorate %300 PerPrimitiveNV
OpMemberDecorate %6 0 Offset 0
OpMemberDecorate %6 1 Offset 16
OpMemberDecorate %7 0 Offset 0
@@ -42,12 +75,16 @@ OpMemberDecorate %16 1 Offset 96
OpMemberDecorate %16 2 Offset 128
OpMemberDecorate %16 3 Offset 132
OpDecorate %33 BuiltIn LocalInvocationId
OpDecorate %90 BuiltIn LocalInvocationId
OpDecorate %176 BuiltIn FragCoord
OpDecorate %179 Location 0
OpDecorate %182 Location 1
OpDecorate %182 PerPrimitiveNV
OpDecorate %184 Location 0
OpDecorate %54 BuiltIn LocalInvocationIndex
OpDecorate %107 BuiltIn LocalInvocationId
OpDecorate %217 BuiltIn LocalInvocationId
OpDecorate %279 BuiltIn LocalInvocationIndex
OpDecorate %303 BuiltIn LocalInvocationId
OpDecorate %370 BuiltIn FragCoord
OpDecorate %373 Location 0
OpDecorate %376 Location 1
OpDecorate %376 PerPrimitiveNV
OpDecorate %378 Location 0
%2 = OpTypeVoid
%3 = OpTypeFloat 32
%4 = OpTypeVector %3 4
@@ -87,51 +124,92 @@ OpDecorate %184 Location 0
%48 = OpTypePointer TaskPayloadWorkgroupEXT %5
%55 = OpTypePointer Input %8
%54 = OpVariable %55 Input
%59 = OpTypePointer Function %8
%61 = OpTypeStruct %4
%62 = OpTypeArray %61 %13
%63 = OpTypePointer Output %62
%64 = OpVariable %63 Output
%65 = OpTypeStruct %5
%66 = OpTypeArray %65 %15
%67 = OpTypePointer Output %66
%68 = OpVariable %67 Output
%69 = OpTypeArray %4 %13
%70 = OpTypePointer Output %69
%71 = OpVariable %70 Output
%72 = OpTypeArray %9 %15
%73 = OpTypePointer Output %72
%74 = OpVariable %73 Output
%75 = OpTypeArray %4 %15
%76 = OpTypePointer Output %75
%77 = OpVariable %76 Output
%79 = OpConstant %3 2
%80 = OpConstantComposite %4 %27 %26 %27 %26
%81 = OpConstant %3 -1
%82 = OpConstantComposite %4 %81 %81 %27 %26
%83 = OpConstantComposite %4 %27 %27 %26 %26
%84 = OpConstantComposite %4 %26 %81 %27 %26
%85 = OpConstantComposite %4 %26 %27 %27 %26
%86 = OpConstantComposite %9 %46 %15 %42
%87 = OpConstantComposite %4 %26 %27 %26 %26
%89 = OpConstantNull %16
%90 = OpVariable %34 Input
%97 = OpTypePointer Workgroup %8
%100 = OpTypePointer Workgroup %12
%101 = OpTypePointer Workgroup %7
%102 = OpTypePointer Workgroup %4
%118 = OpTypePointer Workgroup %14
%119 = OpTypePointer Workgroup %10
%120 = OpTypePointer Workgroup %9
%122 = OpTypePointer Workgroup %5
%144 = OpTypePointer Output %4
%159 = OpTypePointer Output %9
%163 = OpTypePointer Output %5
%177 = OpTypePointer Input %4
%176 = OpVariable %177 Input
%179 = OpVariable %177 Input
%182 = OpVariable %177 Input
%184 = OpVariable %144 Output
%58 = OpConstantComposite %9 %42 %42 %42
%72 = OpVariable %55 Input
%76 = OpTypePointer Function %8
%78 = OpTypeStruct %4
%79 = OpTypeArray %78 %13
%80 = OpTypePointer Output %79
%81 = OpVariable %80 Output
%82 = OpTypeStruct %5
%83 = OpTypeArray %82 %15
%84 = OpTypePointer Output %83
%85 = OpVariable %84 Output
%86 = OpTypeArray %4 %13
%87 = OpTypePointer Output %86
%88 = OpVariable %87 Output
%89 = OpTypeArray %9 %15
%90 = OpTypePointer Output %89
%91 = OpVariable %90 Output
%92 = OpTypeArray %4 %15
%93 = OpTypePointer Output %92
%94 = OpVariable %93 Output
%96 = OpConstant %3 2
%97 = OpConstantComposite %4 %27 %26 %27 %26
%98 = OpConstant %3 -1
%99 = OpConstantComposite %4 %98 %98 %27 %26
%100 = OpConstantComposite %4 %27 %27 %26 %26
%101 = OpConstantComposite %4 %26 %98 %27 %26
%102 = OpConstantComposite %4 %26 %27 %27 %26
%103 = OpConstantComposite %9 %46 %15 %42
%104 = OpConstantComposite %4 %26 %27 %26 %26
%106 = OpConstantNull %16
%107 = OpVariable %34 Input
%114 = OpTypePointer Workgroup %8
%117 = OpTypePointer Workgroup %12
%118 = OpTypePointer Workgroup %7
%119 = OpTypePointer Workgroup %4
%135 = OpTypePointer Workgroup %14
%136 = OpTypePointer Workgroup %10
%137 = OpTypePointer Workgroup %9
%139 = OpTypePointer Workgroup %5
%161 = OpTypePointer Output %4
%176 = OpTypePointer Output %9
%180 = OpTypePointer Output %5
%192 = OpVariable %55 Input
%197 = OpTypeStruct %4
%198 = OpTypeArray %197 %13
%199 = OpTypePointer Output %198
%200 = OpVariable %199 Output
%201 = OpTypeStruct %5
%202 = OpTypeArray %201 %15
%203 = OpTypePointer Output %202
%204 = OpVariable %203 Output
%205 = OpTypeArray %4 %13
%206 = OpTypePointer Output %205
%207 = OpVariable %206 Output
%208 = OpTypeArray %9 %15
%209 = OpTypePointer Output %208
%210 = OpVariable %209 Output
%211 = OpTypeArray %4 %15
%212 = OpTypePointer Output %211
%213 = OpVariable %212 Output
%215 = OpConstantFalse %5
%217 = OpVariable %34 Input
%279 = OpVariable %55 Input
%284 = OpTypeStruct %4
%285 = OpTypeArray %284 %13
%286 = OpTypePointer Output %285
%287 = OpVariable %286 Output
%288 = OpTypeStruct %5
%289 = OpTypeArray %288 %15
%290 = OpTypePointer Output %289
%291 = OpVariable %290 Output
%292 = OpTypeArray %4 %13
%293 = OpTypePointer Output %292
%294 = OpVariable %293 Output
%295 = OpTypeArray %9 %15
%296 = OpTypePointer Output %295
%297 = OpVariable %296 Output
%298 = OpTypeArray %4 %15
%299 = OpTypePointer Output %298
%300 = OpVariable %299 Output
%303 = OpVariable %34 Input
%371 = OpTypePointer Input %4
%370 = OpVariable %371 Input
%373 = OpVariable %371 Input
%376 = OpVariable %371 Input
%378 = OpVariable %161 Output
%24 = OpFunction %2 None %25
%23 = OpLabel
OpBranch %31
@@ -159,144 +237,405 @@ OpControlBarrier %42 %42 %43
%52 = OpCompositeExtract %8 %30 2
OpEmitMeshTasksEXT %50 %51 %52 %17
OpFunctionEnd
%78 = OpFunction %2 None %25
%57 = OpFunction %2 None %25
%53 = OpLabel
%57 = OpVariable %59 Function
%58 = OpVariable %59 Function
%56 = OpLoad %8 %54
OpBranch %88
%88 = OpLabel
%91 = OpLoad %9 %90
%92 = OpIEqual %37 %91 %36
%93 = OpAll %5 %92
OpSelectionMerge %94 None
OpBranchConditional %93 %95 %94
%95 = OpLabel
OpBranch %59
%59 = OpLabel
%60 = OpIEqual %5 %56 %46
OpSelectionMerge %61 None
OpBranchConditional %60 %62 %61
%62 = OpLabel
%63 = OpAccessChain %45 %17 %46
OpStore %63 %28
%64 = OpAccessChain %48 %17 %15
OpStore %64 %29
OpControlBarrier %42 %42 %43
%65 = OpCompositeExtract %8 %30 0
%66 = OpCompositeExtract %8 %30 1
%67 = OpCompositeExtract %8 %30 2
OpEmitMeshTasksEXT %65 %66 %67 %17
%61 = OpLabel
OpControlBarrier %42 %42 %43
%68 = OpCompositeExtract %8 %58 0
%69 = OpCompositeExtract %8 %58 1
%70 = OpCompositeExtract %8 %58 2
OpEmitMeshTasksEXT %68 %69 %70 %17
OpFunctionEnd
%95 = OpFunction %2 None %25
%71 = OpLabel
%74 = OpVariable %76 Function
%75 = OpVariable %76 Function
%73 = OpLoad %8 %72
OpBranch %105
%105 = OpLabel
%108 = OpLoad %9 %107
%109 = OpIEqual %37 %108 %36
%110 = OpAll %5 %109
OpSelectionMerge %111 None
OpBranchConditional %110 %112 %111
%112 = OpLabel
OpStore %19 %32
OpStore %21 %89
OpBranch %94
%94 = OpLabel
OpStore %21 %106
OpBranch %111
%111 = OpLabel
OpControlBarrier %42 %42 %43
OpBranch %96
%96 = OpLabel
%98 = OpAccessChain %97 %21 %42
OpStore %98 %13
%99 = OpAccessChain %97 %21 %13
OpStore %99 %15
OpStore %19 %79
%103 = OpAccessChain %102 %21 %46 %46 %46
OpStore %103 %80
%104 = OpAccessChain %45 %17 %46
%105 = OpLoad %4 %104
%106 = OpFMul %4 %80 %105
%107 = OpAccessChain %102 %21 %46 %46 %15
OpStore %107 %106
%108 = OpAccessChain %102 %21 %46 %15 %46
OpStore %108 %82
%109 = OpAccessChain %45 %17 %46
%110 = OpLoad %4 %109
%111 = OpFMul %4 %83 %110
%112 = OpAccessChain %102 %21 %46 %15 %15
OpStore %112 %111
%113 = OpAccessChain %102 %21 %46 %42 %46
OpStore %113 %84
%114 = OpAccessChain %45 %17 %46
%115 = OpLoad %4 %114
%116 = OpFMul %4 %85 %115
%117 = OpAccessChain %102 %21 %46 %42 %15
OpStore %117 %116
%121 = OpAccessChain %120 %21 %15 %46 %46
OpStore %121 %86
%123 = OpAccessChain %48 %17 %15
%124 = OpLoad %5 %123
%125 = OpLogicalNot %5 %124
%126 = OpAccessChain %122 %21 %15 %46 %15
OpStore %126 %125
%127 = OpAccessChain %102 %21 %15 %46 %42
OpStore %127 %87
OpBranch %60
%60 = OpLabel
OpControlBarrier %42 %42 %43
%128 = OpAccessChain %97 %21 %42
%129 = OpLoad %8 %128
%130 = OpExtInst %8 %1 UMin %129 %13
%131 = OpAccessChain %97 %21 %13
%132 = OpLoad %8 %131
%133 = OpExtInst %8 %1 UMin %132 %15
%134 = OpAccessChain %100 %21 %46
%135 = OpAccessChain %118 %21 %15
OpControlBarrier %42 %42 %43
OpSetMeshOutputsEXT %130 %133
OpStore %57 %56
OpBranch %136
%136 = OpLabel
OpLoopMerge %138 %149 None
OpBranch %148
%148 = OpLabel
%151 = OpLoad %8 %57
%152 = OpULessThan %5 %151 %130
OpBranchConditional %152 %150 %138
%150 = OpLabel
%140 = OpLoad %8 %57
%141 = OpAccessChain %102 %134 %140 %46
%142 = OpLoad %4 %141
%143 = OpAccessChain %144 %64 %140 %46
OpBranch %113
%113 = OpLabel
%115 = OpAccessChain %114 %21 %42
OpStore %115 %13
%116 = OpAccessChain %114 %21 %13
OpStore %116 %15
OpStore %19 %96
%120 = OpAccessChain %119 %21 %46 %46 %46
OpStore %120 %97
%121 = OpAccessChain %45 %17 %46
%122 = OpLoad %4 %121
%123 = OpFMul %4 %97 %122
%124 = OpAccessChain %119 %21 %46 %46 %15
OpStore %124 %123
%125 = OpAccessChain %119 %21 %46 %15 %46
OpStore %125 %99
%126 = OpAccessChain %45 %17 %46
%127 = OpLoad %4 %126
%128 = OpFMul %4 %100 %127
%129 = OpAccessChain %119 %21 %46 %15 %15
OpStore %129 %128
%130 = OpAccessChain %119 %21 %46 %42 %46
OpStore %130 %101
%131 = OpAccessChain %45 %17 %46
%132 = OpLoad %4 %131
%133 = OpFMul %4 %102 %132
%134 = OpAccessChain %119 %21 %46 %42 %15
OpStore %134 %133
%138 = OpAccessChain %137 %21 %15 %46 %46
OpStore %138 %103
%140 = OpAccessChain %48 %17 %15
%141 = OpLoad %5 %140
%142 = OpLogicalNot %5 %141
%143 = OpAccessChain %139 %21 %15 %46 %15
OpStore %143 %142
%145 = OpAccessChain %102 %134 %140 %15
%146 = OpLoad %4 %145
%147 = OpAccessChain %144 %71 %140
OpStore %147 %146
OpBranch %149
%149 = OpLabel
%153 = OpLoad %8 %57
%154 = OpIAdd %8 %153 %15
OpStore %57 %154
OpBranch %136
%138 = OpLabel
OpStore %58 %56
OpBranch %137
%137 = OpLabel
OpLoopMerge %139 %168 None
OpBranch %167
%144 = OpAccessChain %119 %21 %15 %46 %42
OpStore %144 %104
OpBranch %77
%77 = OpLabel
OpControlBarrier %42 %42 %43
%145 = OpAccessChain %114 %21 %42
%146 = OpLoad %8 %145
%147 = OpExtInst %8 %1 UMin %146 %13
%148 = OpAccessChain %114 %21 %13
%149 = OpLoad %8 %148
%150 = OpExtInst %8 %1 UMin %149 %15
%151 = OpAccessChain %117 %21 %46
%152 = OpAccessChain %135 %21 %15
OpControlBarrier %42 %42 %43
OpSetMeshOutputsEXT %147 %150
OpStore %74 %73
OpBranch %153
%153 = OpLabel
OpLoopMerge %155 %166 None
OpBranch %165
%165 = OpLabel
%168 = OpLoad %8 %74
%169 = OpULessThan %5 %168 %147
OpBranchConditional %169 %167 %155
%167 = OpLabel
%170 = OpLoad %8 %58
%171 = OpULessThan %5 %170 %133
OpBranchConditional %171 %169 %139
%169 = OpLabel
%155 = OpLoad %8 %58
%156 = OpAccessChain %120 %135 %155 %46
%157 = OpLoad %9 %156
%158 = OpAccessChain %159 %74 %155
OpStore %158 %157
%160 = OpAccessChain %122 %135 %155 %15
%161 = OpLoad %5 %160
%162 = OpAccessChain %163 %68 %155 %46
OpStore %162 %161
%164 = OpAccessChain %102 %135 %155 %42
%165 = OpLoad %4 %164
%166 = OpAccessChain %144 %77 %155
OpStore %166 %165
OpBranch %168
%168 = OpLabel
%172 = OpLoad %8 %58
%173 = OpIAdd %8 %172 %15
OpStore %58 %173
OpBranch %137
%139 = OpLabel
%157 = OpLoad %8 %74
%158 = OpAccessChain %119 %151 %157 %46
%159 = OpLoad %4 %158
%160 = OpAccessChain %161 %81 %157 %46
OpStore %160 %159
%162 = OpAccessChain %119 %151 %157 %15
%163 = OpLoad %4 %162
%164 = OpAccessChain %161 %88 %157
OpStore %164 %163
OpBranch %166
%166 = OpLabel
%170 = OpLoad %8 %74
%171 = OpIAdd %8 %170 %15
OpStore %74 %171
OpBranch %153
%155 = OpLabel
OpStore %75 %73
OpBranch %154
%154 = OpLabel
OpLoopMerge %156 %185 None
OpBranch %184
%184 = OpLabel
%187 = OpLoad %8 %75
%188 = OpULessThan %5 %187 %150
OpBranchConditional %188 %186 %156
%186 = OpLabel
%172 = OpLoad %8 %75
%173 = OpAccessChain %137 %152 %172 %46
%174 = OpLoad %9 %173
%175 = OpAccessChain %176 %91 %172
OpStore %175 %174
%177 = OpAccessChain %139 %152 %172 %15
%178 = OpLoad %5 %177
%179 = OpAccessChain %180 %85 %172 %46
OpStore %179 %178
%181 = OpAccessChain %119 %152 %172 %42
%182 = OpLoad %4 %181
%183 = OpAccessChain %161 %94 %172
OpStore %183 %182
OpBranch %185
%185 = OpLabel
%189 = OpLoad %8 %75
%190 = OpIAdd %8 %189 %15
OpStore %75 %190
OpBranch %154
%156 = OpLabel
OpReturn
OpFunctionEnd
%185 = OpFunction %2 None %25
%174 = OpLabel
%178 = OpLoad %4 %176
%180 = OpLoad %4 %179
%175 = OpCompositeConstruct %7 %178 %180
%183 = OpLoad %4 %182
%181 = OpCompositeConstruct %11 %183
OpBranch %186
%186 = OpLabel
%187 = OpCompositeExtract %4 %175 1
%188 = OpCompositeExtract %4 %181 0
%189 = OpFMul %4 %187 %188
OpStore %184 %189
%214 = OpFunction %2 None %25
%191 = OpLabel
%194 = OpVariable %76 Function
%195 = OpVariable %76 Function
%193 = OpLoad %8 %192
OpBranch %216
%216 = OpLabel
%218 = OpLoad %9 %217
%219 = OpIEqual %37 %218 %36
%220 = OpAll %5 %219
OpSelectionMerge %221 None
OpBranchConditional %220 %222 %221
%222 = OpLabel
OpStore %19 %32
OpStore %21 %106
OpBranch %221
%221 = OpLabel
OpControlBarrier %42 %42 %43
OpBranch %223
%223 = OpLabel
%224 = OpAccessChain %114 %21 %42
OpStore %224 %13
%225 = OpAccessChain %114 %21 %13
OpStore %225 %15
OpStore %19 %96
%226 = OpAccessChain %119 %21 %46 %46 %46
OpStore %226 %97
%227 = OpAccessChain %119 %21 %46 %46 %15
OpStore %227 %97
%228 = OpAccessChain %119 %21 %46 %15 %46
OpStore %228 %99
%229 = OpAccessChain %119 %21 %46 %15 %15
OpStore %229 %100
%230 = OpAccessChain %119 %21 %46 %42 %46
OpStore %230 %101
%231 = OpAccessChain %119 %21 %46 %42 %15
OpStore %231 %102
%232 = OpAccessChain %137 %21 %15 %46 %46
OpStore %232 %103
%233 = OpAccessChain %139 %21 %15 %46 %15
OpStore %233 %215
%234 = OpAccessChain %119 %21 %15 %46 %42
OpStore %234 %104
OpBranch %196
%196 = OpLabel
OpControlBarrier %42 %42 %43
%235 = OpAccessChain %114 %21 %42
%236 = OpLoad %8 %235
%237 = OpExtInst %8 %1 UMin %236 %13
%238 = OpAccessChain %114 %21 %13
%239 = OpLoad %8 %238
%240 = OpExtInst %8 %1 UMin %239 %15
%241 = OpAccessChain %117 %21 %46
%242 = OpAccessChain %135 %21 %15
OpControlBarrier %42 %42 %43
OpSetMeshOutputsEXT %237 %240
OpStore %194 %193
OpBranch %243
%243 = OpLabel
OpLoopMerge %245 %255 None
OpBranch %254
%254 = OpLabel
%257 = OpLoad %8 %194
%258 = OpULessThan %5 %257 %237
OpBranchConditional %258 %256 %245
%256 = OpLabel
%247 = OpLoad %8 %194
%248 = OpAccessChain %119 %241 %247 %46
%249 = OpLoad %4 %248
%250 = OpAccessChain %161 %200 %247 %46
OpStore %250 %249
%251 = OpAccessChain %119 %241 %247 %15
%252 = OpLoad %4 %251
%253 = OpAccessChain %161 %207 %247
OpStore %253 %252
OpBranch %255
%255 = OpLabel
%259 = OpLoad %8 %194
%260 = OpIAdd %8 %259 %15
OpStore %194 %260
OpBranch %243
%245 = OpLabel
OpStore %195 %193
OpBranch %244
%244 = OpLabel
OpLoopMerge %246 %272 None
OpBranch %271
%271 = OpLabel
%274 = OpLoad %8 %195
%275 = OpULessThan %5 %274 %240
OpBranchConditional %275 %273 %246
%273 = OpLabel
%261 = OpLoad %8 %195
%262 = OpAccessChain %137 %242 %261 %46
%263 = OpLoad %9 %262
%264 = OpAccessChain %176 %210 %261
OpStore %264 %263
%265 = OpAccessChain %139 %242 %261 %15
%266 = OpLoad %5 %265
%267 = OpAccessChain %180 %204 %261 %46
OpStore %267 %266
%268 = OpAccessChain %119 %242 %261 %42
%269 = OpLoad %4 %268
%270 = OpAccessChain %161 %213 %261
OpStore %270 %269
OpBranch %272
%272 = OpLabel
%276 = OpLoad %8 %195
%277 = OpIAdd %8 %276 %15
OpStore %195 %277
OpBranch %244
%246 = OpLabel
OpReturn
OpFunctionEnd
%301 = OpFunction %2 None %25
%278 = OpLabel
%281 = OpVariable %76 Function
%282 = OpVariable %76 Function
%280 = OpLoad %8 %279
OpBranch %302
%302 = OpLabel
%304 = OpLoad %9 %303
%305 = OpIEqual %37 %304 %36
%306 = OpAll %5 %305
OpSelectionMerge %307 None
OpBranchConditional %306 %308 %307
%308 = OpLabel
OpStore %19 %32
OpStore %21 %106
OpBranch %307
%307 = OpLabel
OpControlBarrier %42 %42 %43
OpBranch %309
%309 = OpLabel
%310 = OpIEqual %5 %280 %46
OpSelectionMerge %311 None
OpBranchConditional %310 %312 %313
%312 = OpLabel
%314 = OpAccessChain %114 %21 %42
OpStore %314 %13
%315 = OpAccessChain %114 %21 %13
OpStore %315 %15
OpStore %19 %96
%316 = OpAccessChain %119 %21 %46 %46 %46
OpStore %316 %97
%317 = OpAccessChain %119 %21 %46 %46 %15
OpStore %317 %97
%318 = OpAccessChain %119 %21 %46 %15 %46
OpStore %318 %99
%319 = OpAccessChain %119 %21 %46 %15 %15
OpStore %319 %100
%320 = OpAccessChain %119 %21 %46 %42 %46
OpStore %320 %101
%321 = OpAccessChain %119 %21 %46 %42 %15
OpStore %321 %102
%322 = OpAccessChain %137 %21 %15 %46 %46
OpStore %322 %103
%323 = OpAccessChain %139 %21 %15 %46 %15
OpStore %323 %215
%324 = OpAccessChain %119 %21 %15 %46 %42
OpStore %324 %104
OpBranch %283
%313 = OpLabel
OpBranch %283
%311 = OpLabel
OpReturn
%283 = OpLabel
OpControlBarrier %42 %42 %43
%325 = OpAccessChain %114 %21 %42
%326 = OpLoad %8 %325
%327 = OpExtInst %8 %1 UMin %326 %13
%328 = OpAccessChain %114 %21 %13
%329 = OpLoad %8 %328
%330 = OpExtInst %8 %1 UMin %329 %15
%331 = OpAccessChain %117 %21 %46
%332 = OpAccessChain %135 %21 %15
OpControlBarrier %42 %42 %43
OpSetMeshOutputsEXT %327 %330
OpStore %281 %280
OpBranch %333
%333 = OpLabel
OpLoopMerge %335 %345 None
OpBranch %344
%344 = OpLabel
%347 = OpLoad %8 %281
%348 = OpULessThan %5 %347 %327
OpBranchConditional %348 %346 %335
%346 = OpLabel
%337 = OpLoad %8 %281
%338 = OpAccessChain %119 %331 %337 %46
%339 = OpLoad %4 %338
%340 = OpAccessChain %161 %287 %337 %46
OpStore %340 %339
%341 = OpAccessChain %119 %331 %337 %15
%342 = OpLoad %4 %341
%343 = OpAccessChain %161 %294 %337
OpStore %343 %342
OpBranch %345
%345 = OpLabel
%349 = OpLoad %8 %281
%350 = OpIAdd %8 %349 %15
OpStore %281 %350
OpBranch %333
%335 = OpLabel
OpStore %282 %280
OpBranch %334
%334 = OpLabel
OpLoopMerge %336 %362 None
OpBranch %361
%361 = OpLabel
%364 = OpLoad %8 %282
%365 = OpULessThan %5 %364 %330
OpBranchConditional %365 %363 %336
%363 = OpLabel
%351 = OpLoad %8 %282
%352 = OpAccessChain %137 %332 %351 %46
%353 = OpLoad %9 %352
%354 = OpAccessChain %176 %297 %351
OpStore %354 %353
%355 = OpAccessChain %139 %332 %351 %15
%356 = OpLoad %5 %355
%357 = OpAccessChain %180 %291 %351 %46
OpStore %357 %356
%358 = OpAccessChain %119 %332 %351 %42
%359 = OpLoad %4 %358
%360 = OpAccessChain %161 %300 %351
OpStore %360 %359
OpBranch %362
%362 = OpLabel
%366 = OpLoad %8 %282
%367 = OpIAdd %8 %366 %15
OpStore %282 %367
OpBranch %334
%336 = OpLabel
OpReturn
OpFunctionEnd
%379 = OpFunction %2 None %25
%368 = OpLabel
%372 = OpLoad %4 %370
%374 = OpLoad %4 %373
%369 = OpCompositeConstruct %7 %372 %374
%377 = OpLoad %4 %376
%375 = OpCompositeConstruct %11 %377
OpBranch %380
%380 = OpLabel
%381 = OpCompositeExtract %4 %369 1
%382 = OpCompositeExtract %4 %375 0
%383 = OpFMul %4 %381 %382
OpStore %378 %383
OpReturn
OpFunctionEnd
+2 -2
View File
@@ -790,8 +790,8 @@ fn draw_mesh_tasks(
) -> Result<(), RenderBundleErrorInner> {
state.is_ready()?;
let groups_size_limit = state.device.limits.max_task_workgroups_per_dimension;
let max_groups = state.device.limits.max_task_workgroup_total_count;
let groups_size_limit = state.device.limits.max_task_mesh_workgroups_per_dimension;
let max_groups = state.device.limits.max_task_mesh_workgroup_total_count;
if group_count_x > groups_size_limit
|| group_count_y > groups_size_limit
|| group_count_z > groups_size_limit
+7 -2
View File
@@ -2726,8 +2726,13 @@ fn draw_mesh_tasks(
.base
.device
.limits
.max_task_workgroups_per_dimension;
let max_groups = state.pass.base.device.limits.max_task_workgroup_total_count;
.max_task_mesh_workgroups_per_dimension;
let max_groups = state
.pass
.base
.device
.limits
.max_task_mesh_workgroup_total_count;
if group_count_x > groups_size_limit
|| group_count_y > groups_size_limit
|| group_count_z > groups_size_limit
+14 -16
View File
@@ -3983,7 +3983,7 @@ impl Device {
self.require_features(wgt::Features::VERTEX_ATTRIBUTE_64BIT)?;
}
let previous = io.insert(
let previous = io.varyings.insert(
attribute.shader_location,
validation::InterfaceVar::vertex_attribute(attribute.format),
);
@@ -4370,20 +4370,18 @@ impl Device {
)
.map_err(stage_err)?;
if validated_stages == wgt::ShaderStages::VERTEX {
if let Some(ref interface) = shader_module.interface {
io = interface
.check_stage(
&mut binding_layout_source,
&mut shader_binding_sizes,
&fragment_entry_point_name,
stage,
io,
desc.depth_stencil.as_ref().map(|d| d.depth_compare),
)
.map_err(stage_err)?;
validated_stages |= stage;
}
if let Some(ref interface) = shader_module.interface {
io = interface
.check_stage(
&mut binding_layout_source,
&mut shader_binding_sizes,
&fragment_entry_point_name,
stage,
io,
desc.depth_stencil.as_ref().map(|d| d.depth_compare),
)
.map_err(stage_err)?;
validated_stages |= stage;
}
if let Some(ref interface) = shader_module.interface {
@@ -4419,7 +4417,7 @@ impl Device {
}
if validated_stages.contains(wgt::ShaderStages::FRAGMENT) {
for (i, output) in io.iter() {
for (i, output) in io.varyings.iter() {
match color_targets.get(*i as usize) {
Some(Some(state)) => {
validation::check_texture_format(state.format, &output.ty).map_err(
+219 -35
View File
@@ -129,6 +129,7 @@ pub struct InterfaceVar {
pub ty: NumericType,
interpolation: Option<naga::Interpolation>,
sampling: Option<naga::Sampling>,
per_primitive: bool,
}
impl InterfaceVar {
@@ -137,6 +138,7 @@ impl InterfaceVar {
ty: NumericType::from_vertex_format(format),
interpolation: None,
sampling: None,
per_primitive: false,
}
}
}
@@ -164,6 +166,12 @@ struct SpecializationConstant {
ty: NumericType,
}
#[derive(Debug)]
struct EntryPointMeshInfo {
max_vertices: u32,
max_primitives: u32,
}
#[derive(Debug, Default)]
struct EntryPoint {
inputs: Vec<Varying>,
@@ -174,6 +182,8 @@ struct EntryPoint {
sampling_pairs: FastHashSet<(naga::Handle<Resource>, naga::Handle<Resource>)>,
workgroup_size: [u32; 3],
dual_source_blending: bool,
task_payload_size: Option<u32>,
mesh_info: Option<EntryPointMeshInfo>,
}
#[derive(Debug)]
@@ -260,6 +270,8 @@ pub enum InputError {
InterpolationMismatch(Option<naga::Interpolation>),
#[error("Input sampling doesn't match provided {0:?}")]
SamplingMismatch(Option<naga::Sampling>),
#[error("Pipeline input has per_primitive={pipeline_input}, but shader expects per_primitive={shader}")]
WrongPerPrimitive { pipeline_input: bool, shader: bool },
}
impl WebGpuError for InputError {
@@ -273,13 +285,16 @@ impl WebGpuError for InputError {
#[non_exhaustive]
pub enum StageError {
#[error(
"Shader entry point's workgroup size {current:?} ({current_total} total invocations) must be less or equal to the per-dimension limit {limit:?} and the total invocation limit {total}"
"Shader entry point's workgroup size {current:?} ({current_total} total invocations) must be less or equal to the per-dimension
limit `Limits::{per_dimension_limit}` of {limit:?} and the total invocation limit `Limits::{total_limit}` of {total}"
)]
InvalidWorkgroupSize {
current: [u32; 3],
current_total: u32,
limit: [u32; 3],
total: u32,
per_dimension_limit: &'static str,
total_limit: &'static str,
},
#[error("Shader uses {used} inter-stage components above the limit of {limit}")]
TooManyVaryings { used: u32, limit: u32 },
@@ -321,6 +336,23 @@ pub enum StageError {
var: InterfaceVar,
limit: u32,
},
#[error("Mesh shaders are limited to {limit} output vertices by `Limits::max_mesh_output_vertices`, but the shader has a maximum number of {value}")]
TooManyMeshVertices { limit: u32, value: u32 },
#[error("Mesh shaders are limited to {limit} output primitives by `Limits::max_mesh_output_primitives`, but the shader has a maximum number of {value}")]
TooManyMeshPrimitives { limit: u32, value: u32 },
#[error("Mesh or task shaders are limited to {limit} bytes of task payload by `Limits::max_task_payload_size`, but the shader has a task payload of size {value}")]
TaskPayloadTooLarge { limit: u32, value: u32 },
#[error("Mesh shader's task payload has size ({shader:?}), which doesn't match the payload declared in the task stage ({input:?})")]
TaskPayloadMustMatch {
input: Option<u32>,
shader: Option<u32>,
},
#[error("Primitive index can only be used in a fragment shader if the preceding shader was a vertex shader or a mesh shader that writes to primitive index.")]
InvalidPrimitiveIndex,
#[error("If a mesh shader writes to primitive index, it must be read by the fragment shader.")]
MissingPrimitiveIndex,
#[error("DrawId cannot be used in the same pipeline as a task shader")]
DrawIdError,
}
impl WebGpuError for StageError {
@@ -343,7 +375,14 @@ impl WebGpuError for StageError {
| Self::MissingEntryPoint(..)
| Self::NoEntryPointFound
| Self::MultipleEntryPointsFound
| Self::ColorAttachmentLocationTooLarge { .. } => return ErrorType::Validation,
| Self::ColorAttachmentLocationTooLarge { .. }
| Self::TooManyMeshVertices { .. }
| Self::TooManyMeshPrimitives { .. }
| Self::TaskPayloadTooLarge { .. }
| Self::TaskPayloadMustMatch { .. }
| Self::InvalidPrimitiveIndex
| Self::MissingPrimitiveIndex
| Self::DrawIdError => return ErrorType::Validation,
};
e.webgpu_error_type()
}
@@ -916,7 +955,18 @@ impl<'a> BindingLayoutSource<'a> {
}
}
pub type StageIo = FastHashMap<wgt::ShaderLocation, InterfaceVar>;
#[derive(Debug, Clone, Default)]
pub struct StageIo {
pub varyings: FastHashMap<wgt::ShaderLocation, InterfaceVar>,
/// This must match between mesh & task shaders
pub task_payload_size: Option<u32>,
/// Fragment shaders cannot input primitive index on mesh shaders that don't output it on DX12.
/// Therefore, we track between shader stages if primitive index is written (or if vertex shader
/// is used).
///
/// This is Some if it was a mesh shader.
pub primitive_index: Option<bool>,
}
impl Interface {
fn populate(
@@ -964,13 +1014,15 @@ impl Interface {
location,
interpolation,
sampling,
.. // second_blend_source
per_primitive,
blend_src: _,
}) => Varying::Local {
location,
iv: InterfaceVar {
ty: numeric_ty,
interpolation,
sampling,
per_primitive,
},
},
Some(&naga::Binding::BuiltIn(built_in)) => Varying::BuiltIn(built_in),
@@ -1058,6 +1110,32 @@ impl Interface {
ep.dual_source_blending = info.dual_source_blending;
ep.workgroup_size = entry_point.workgroup_size;
if let Some(task_payload) = entry_point.task_payload {
ep.task_payload_size = Some(
module.types[module.global_variables[task_payload].ty]
.inner
.size(module.to_ctx()),
);
}
if let Some(ref mesh_info) = entry_point.mesh_info {
ep.mesh_info = Some(EntryPointMeshInfo {
max_vertices: mesh_info.max_vertices,
max_primitives: mesh_info.max_primitives,
});
Self::populate(
&mut ep.outputs,
None,
mesh_info.vertex_output_type,
&module.types,
);
Self::populate(
&mut ep.outputs,
None,
mesh_info.primitive_output_type,
&module.types,
);
}
entry_points.insert((entry_point.stage, entry_point.name.clone()), ep);
}
@@ -1118,7 +1196,7 @@ impl Interface {
Some(some) => some,
None => return Err(StageError::MissingEntryPoint(pair.1)),
};
let (_stage, entry_point_name) = pair;
let (_, entry_point_name) = pair;
// check resources visibility
for &handle in entry_point.resources.iter() {
@@ -1242,47 +1320,85 @@ impl Interface {
// check workgroup size limits
if shader_stage.compute_like() {
let max_workgroup_size_limits = [
self.limits.max_compute_workgroup_size_x,
self.limits.max_compute_workgroup_size_y,
self.limits.max_compute_workgroup_size_z,
];
let (
max_workgroup_size_limits,
max_workgroup_size_total,
per_dimension_limit,
total_limit,
) = match shader_stage {
naga::ShaderStage::Compute => (
[
self.limits.max_compute_workgroup_size_x,
self.limits.max_compute_workgroup_size_y,
self.limits.max_compute_workgroup_size_z,
],
self.limits.max_compute_invocations_per_workgroup,
"max_compute_workgroup_size_*",
"max_compute_invocations_per_workgroup",
),
naga::ShaderStage::Task => (
[
self.limits.max_task_invocations_per_dimension,
self.limits.max_task_invocations_per_dimension,
self.limits.max_task_invocations_per_dimension,
],
self.limits.max_task_invocations_per_workgroup,
"max_task_invocations_per_dimension",
"max_task_invocations_per_workgroup",
),
naga::ShaderStage::Mesh => (
[
self.limits.max_mesh_invocations_per_dimension,
self.limits.max_mesh_invocations_per_dimension,
self.limits.max_mesh_invocations_per_dimension,
],
self.limits.max_mesh_invocations_per_workgroup,
"max_mesh_invocations_per_dimension",
"max_mesh_invocations_per_workgroup",
),
_ => unreachable!(),
};
let total_invocations = entry_point.workgroup_size.iter().product::<u32>();
if entry_point.workgroup_size.contains(&0)
|| total_invocations > self.limits.max_compute_invocations_per_workgroup
|| entry_point.workgroup_size[0] > max_workgroup_size_limits[0]
let workgroup_size_is_zero = entry_point.workgroup_size.contains(&0);
let too_many_invocations = total_invocations > max_workgroup_size_total;
let dimension_too_large = entry_point.workgroup_size[0] > max_workgroup_size_limits[0]
|| entry_point.workgroup_size[1] > max_workgroup_size_limits[1]
|| entry_point.workgroup_size[2] > max_workgroup_size_limits[2]
{
|| entry_point.workgroup_size[2] > max_workgroup_size_limits[2];
if workgroup_size_is_zero || too_many_invocations || dimension_too_large {
return Err(StageError::InvalidWorkgroupSize {
current: entry_point.workgroup_size,
current_total: total_invocations,
limit: max_workgroup_size_limits,
total: self.limits.max_compute_invocations_per_workgroup,
total: max_workgroup_size_total,
per_dimension_limit,
total_limit,
});
}
}
let mut inter_stage_components = 0;
let mut this_stage_primitive_index = false;
let mut has_draw_id = false;
// check inputs compatibility
for input in entry_point.inputs.iter() {
match *input {
Varying::Local { location, ref iv } => {
let result =
inputs
.get(&location)
.ok_or(InputError::Missing)
.and_then(|provided| {
let (compatible, num_components) = match shader_stage {
let result = inputs
.varyings
.get(&location)
.ok_or(InputError::Missing)
.and_then(|provided| {
let (compatible, num_components, per_primitive_correct) =
match shader_stage {
// For vertex attributes, there are defaults filled out
// by the driver if data is not provided.
naga::ShaderStage::Vertex => {
let is_compatible =
iv.ty.scalar.kind == provided.ty.scalar.kind;
// vertex inputs don't count towards inter-stage
(is_compatible, 0)
(is_compatible, 0, !iv.per_primitive)
}
naga::ShaderStage::Fragment => {
if iv.interpolation != provided.interpolation {
@@ -1298,20 +1414,24 @@ impl Interface {
(
iv.ty.is_subtype_of(&provided.ty),
iv.ty.dim.num_components(),
iv.per_primitive == provided.per_primitive,
)
}
naga::ShaderStage::Compute => (false, 0),
// TODO: add validation for these, see https://github.com/gfx-rs/wgpu/issues/8003
naga::ShaderStage::Task | naga::ShaderStage::Mesh => {
unreachable!()
}
// These can't have varying inputs
naga::ShaderStage::Compute
| naga::ShaderStage::Task
| naga::ShaderStage::Mesh => (false, 0, false),
};
if compatible {
Ok(num_components)
} else {
Err(InputError::WrongType(provided.ty))
}
});
if !compatible {
return Err(InputError::WrongType(provided.ty));
} else if !per_primitive_correct {
return Err(InputError::WrongPerPrimitive {
pipeline_input: provided.per_primitive,
shader: iv.per_primitive,
});
}
Ok(num_components)
});
match result {
Ok(num_components) => {
inter_stage_components += num_components;
@@ -1325,6 +1445,12 @@ impl Interface {
}
}
}
Varying::BuiltIn(naga::BuiltIn::PrimitiveIndex) => {
this_stage_primitive_index = true;
}
Varying::BuiltIn(naga::BuiltIn::DrawID) => {
has_draw_id = true;
}
Varying::BuiltIn(_) => {}
}
}
@@ -1387,6 +1513,56 @@ impl Interface {
});
}
if let Some(ref mesh_info) = entry_point.mesh_info {
if mesh_info.max_vertices > self.limits.max_mesh_output_vertices {
return Err(StageError::TooManyMeshVertices {
limit: self.limits.max_mesh_output_vertices,
value: mesh_info.max_vertices,
});
}
if mesh_info.max_primitives > self.limits.max_mesh_output_primitives {
return Err(StageError::TooManyMeshPrimitives {
limit: self.limits.max_mesh_output_primitives,
value: mesh_info.max_primitives,
});
}
}
if let Some(task_payload_size) = entry_point.task_payload_size {
if task_payload_size > self.limits.max_task_payload_size {
return Err(StageError::TaskPayloadTooLarge {
limit: self.limits.max_task_payload_size,
value: task_payload_size,
});
}
}
if shader_stage == naga::ShaderStage::Mesh
&& entry_point.task_payload_size != inputs.task_payload_size
{
return Err(StageError::TaskPayloadMustMatch {
input: inputs.task_payload_size,
shader: entry_point.task_payload_size,
});
}
// Fragment shader primitive index is treated like a varying
if shader_stage == naga::ShaderStage::Fragment
&& this_stage_primitive_index
&& inputs.primitive_index == Some(false)
{
return Err(StageError::InvalidPrimitiveIndex);
} else if shader_stage == naga::ShaderStage::Fragment
&& !this_stage_primitive_index
&& inputs.primitive_index == Some(true)
{
return Err(StageError::MissingPrimitiveIndex);
}
if shader_stage == naga::ShaderStage::Mesh
&& inputs.task_payload_size.is_some()
&& has_draw_id
{
return Err(StageError::DrawIdError);
}
let outputs = entry_point
.outputs
.iter()
@@ -1396,7 +1572,15 @@ impl Interface {
})
.collect();
Ok(outputs)
Ok(StageIo {
task_payload_size: entry_point.task_payload_size,
varyings: outputs,
primitive_index: if shader_stage == naga::ShaderStage::Mesh {
Some(this_stage_primitive_index)
} else {
None
},
})
}
pub fn fragment_uses_dual_source_blending(
+30 -6
View File
@@ -828,18 +828,42 @@ impl super::Adapter {
max_non_sampler_bindings: 1_000_000,
// Source: https://microsoft.github.io/DirectX-Specs/d3d/MeshShader.html#dispatchmesh-api
max_task_workgroup_total_count: 2u32.pow(22),
max_task_mesh_workgroup_total_count: if mesh_shader_supported {
2u32.pow(22)
} else {
0
},
// Technically it says "64k" but I highly doubt they want 65536 for compute and exactly 64,000 for task workgroups
max_task_workgroups_per_dimension:
Direct3D12::D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION,
// Multiview not supported by WGPU yet
max_task_mesh_workgroups_per_dimension: if mesh_shader_supported {
Direct3D12::D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION
} else {
0
},
// Assume this inherits from compute shaders
max_task_invocations_per_workgroup: if mesh_shader_supported {
Direct3D12::D3D12_CS_4_X_THREAD_GROUP_MAX_THREADS_PER_GROUP
} else {
0
},
max_task_invocations_per_dimension: if mesh_shader_supported {
Direct3D12::D3D12_CS_THREAD_GROUP_MAX_Z
} else {
0
},
// Source: https://microsoft.github.io/DirectX-Specs/d3d/MeshShader.html#amplification-shader-and-mesh-shader
max_mesh_invocations_per_workgroup: if mesh_shader_supported { 128 } else { 0 },
max_mesh_invocations_per_dimension: if mesh_shader_supported { 128 } else { 0 },
max_task_payload_size: if mesh_shader_supported { 16384 } else { 0 },
max_mesh_output_vertices: if mesh_shader_supported { 256 } else { 0 },
max_mesh_output_primitives: if mesh_shader_supported { 256 } else { 0 },
// Source: https://microsoft.github.io/DirectX-Specs/d3d/MeshShader.html#sv_rendertargetarrayindex-limitations-based-on-queryable-capability
max_mesh_output_layers: if mesh_shader_supported { 8 } else { 0 },
max_mesh_multiview_view_count: if mesh_shader_supported {
max_multiview_view_count
} else {
0
},
// This seems to be right, and I can't find anything to suggest it would be less than the 2048 provided here
max_mesh_output_layers: Direct3D12::D3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION,
max_blas_primitive_count: if supports_ray_tracing {
1 << 29 // 2^29
+10 -3
View File
@@ -802,10 +802,17 @@ impl super::Adapter {
max_buffer_size: i32::MAX as u64,
max_non_sampler_bindings: u32::MAX,
max_task_workgroup_total_count: 0,
max_task_workgroups_per_dimension: 0,
max_mesh_multiview_view_count: 0,
max_task_mesh_workgroup_total_count: 0,
max_task_mesh_workgroups_per_dimension: 0,
max_task_invocations_per_workgroup: 0,
max_task_invocations_per_dimension: 0,
max_mesh_invocations_per_workgroup: 0,
max_mesh_invocations_per_dimension: 0,
max_task_payload_size: 0,
max_mesh_output_vertices: 0,
max_mesh_output_primitives: 0,
max_mesh_output_layers: 0,
max_mesh_multiview_view_count: 0,
max_blas_primitive_count: 0,
max_blas_geometry_count: 0,
+25 -14
View File
@@ -590,6 +590,13 @@ impl super::PrivateCapabilities {
let is_virtual = device.name().to_lowercase().contains("virtual");
let mesh_shaders = family_check
&& (device.supports_family(MTLGPUFamily::Metal3)
|| device.supports_family(MTLGPUFamily::Apple7)
|| device.supports_family(MTLGPUFamily::Mac2))
// Mesh shaders don't work on virtual devices even if they should be supported. CI thing
&& !is_virtual;
let msl_version = if version.at_least((14, 0), (17, 0), (17, 0), (1, 0), os_type) {
MTLLanguageVersion::V3_1
} else if version.at_least((13, 0), (16, 0), (16, 0), (1, 0), os_type) {
@@ -955,13 +962,6 @@ impl super::PrivateCapabilities {
// https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=3
supports_memoryless_storage: metal4
|| (family_check && device.supports_family(MTLGPUFamily::Apple2)),
// https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=4
mesh_shaders: family_check
&& (device.supports_family(MTLGPUFamily::Metal3)
|| device.supports_family(MTLGPUFamily::Apple7)
|| device.supports_family(MTLGPUFamily::Mac2))
// Mesh shaders don't work on virtual devices even if they should be supported. CI thing
&& !is_virtual,
supported_vertex_amplification_factor: {
let mut factor = 1;
// https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=8
@@ -983,6 +983,10 @@ impl super::PrivateCapabilities {
}
factor as u32
},
// https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=4
mesh_shaders,
max_mesh_task_workgroup_count: if mesh_shaders { 1024 } else { 0 },
max_task_payload_size: if mesh_shaders { 16384 - 32 } else { 0 },
}
}
@@ -1138,7 +1142,6 @@ impl super::PrivateCapabilities {
.set(wgt::DownlevelFlags::ANISOTROPIC_FILTERING, true);
let base = wgt::Limits::default();
// Be careful adjusting limits here. The `AdapterShared` stores the
// original `PrivateCapabilities`, so code could accidentally use
// the wrong value.
@@ -1185,12 +1188,6 @@ impl super::PrivateCapabilities {
max_buffer_size: self.max_buffer_size,
max_non_sampler_bindings: u32::MAX,
// See https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf, Maximum threadgroups per mesh shader grid
max_task_workgroup_total_count: 1024,
max_task_workgroups_per_dimension: 1024,
max_mesh_multiview_view_count: 0,
max_mesh_output_layers: self.max_texture_layers as u32,
max_blas_primitive_count: 0, // When added: 2^28 from https://developer.apple.com/documentation/metal/mtlaccelerationstructureusage/extendedlimits
max_blas_geometry_count: 0, // When added: 2^24
max_tlas_instance_count: 0, // When added: 2^24
@@ -1207,6 +1204,20 @@ impl super::PrivateCapabilities {
} else {
0
},
// Should be not too large
max_task_mesh_workgroup_total_count: self.max_mesh_task_workgroup_count,
max_task_mesh_workgroups_per_dimension: self.max_mesh_task_workgroup_count,
max_task_invocations_per_workgroup: if self.mesh_shaders { 1024 } else { 0 },
max_task_invocations_per_dimension: if self.mesh_shaders { 1024 } else { 0 },
max_mesh_invocations_per_workgroup: if self.mesh_shaders { 1024 } else { 0 },
max_mesh_invocations_per_dimension: if self.mesh_shaders { 1024 } else { 0 },
// Using certain variables or debuggers can reduce the size by 32 bytes
max_task_payload_size: self.max_task_payload_size,
max_mesh_output_vertices: 256,
max_mesh_output_primitives: 256,
max_mesh_output_layers: self.max_texture_layers as u32,
max_mesh_multiview_view_count: 0,
};
// Since a bunch of the limits are duplicated between `Limits` and
+2
View File
@@ -316,6 +316,8 @@ struct PrivateCapabilities {
float_atomics: bool,
supports_shared_event: bool,
mesh_shaders: bool,
max_mesh_task_workgroup_count: u32,
max_task_payload_size: u32,
supported_vertex_amplification_factor: u32,
shader_barycentrics: bool,
supports_memoryless_storage: bool,
+10 -3
View File
@@ -195,10 +195,17 @@ pub const CAPABILITIES: crate::Capabilities = {
max_immediate_size: ALLOC_MAX_U32,
max_non_sampler_bindings: ALLOC_MAX_U32,
max_task_workgroup_total_count: ALLOC_MAX_U32,
max_task_workgroups_per_dimension: ALLOC_MAX_U32,
max_mesh_multiview_view_count: ALLOC_MAX_U32,
max_task_mesh_workgroup_total_count: ALLOC_MAX_U32,
max_task_mesh_workgroups_per_dimension: ALLOC_MAX_U32,
max_task_invocations_per_workgroup: ALLOC_MAX_U32,
max_task_invocations_per_dimension: ALLOC_MAX_U32,
max_mesh_invocations_per_workgroup: ALLOC_MAX_U32,
max_mesh_invocations_per_dimension: ALLOC_MAX_U32,
max_task_payload_size: ALLOC_MAX_U32,
max_mesh_output_vertices: ALLOC_MAX_U32,
max_mesh_output_primitives: ALLOC_MAX_U32,
max_mesh_output_layers: ALLOC_MAX_U32,
max_mesh_multiview_view_count: ALLOC_MAX_U32,
max_blas_primitive_count: ALLOC_MAX_U32,
max_blas_geometry_count: ALLOC_MAX_U32,
+46 -16
View File
@@ -1264,19 +1264,40 @@ impl PhysicalDeviceProperties {
.min(limits.max_compute_work_group_count[1])
.min(limits.max_compute_work_group_count[2]);
let (
max_task_workgroup_total_count,
max_task_workgroups_per_dimension,
max_mesh_multiview_view_count,
max_mesh_output_layers,
) = match self.mesh_shader {
Some(m) => (
m.max_task_work_group_total_count,
m.max_task_work_group_count.into_iter().min().unwrap(),
m.max_mesh_multiview_view_count,
m.max_mesh_output_layers,
),
None => (0, 0, 0, 0),
};
mut max_task_mesh_workgroup_total_count,
mut max_task_mesh_workgroups_per_dimension,
mut max_task_invocations_per_workgroup,
mut max_task_invocations_per_dimension,
mut max_mesh_invocations_per_workgroup,
mut max_mesh_invocations_per_dimension,
mut max_task_payload_size,
mut max_mesh_output_vertices,
mut max_mesh_output_primitives,
mut max_mesh_output_layers,
mut max_mesh_multiview_view_count,
) = Default::default();
if let Some(m) = self.mesh_shader {
max_task_mesh_workgroup_total_count = m
.max_task_work_group_total_count
.min(m.max_mesh_work_group_total_count);
max_task_mesh_workgroups_per_dimension = m
.max_task_work_group_count
.into_iter()
.chain(m.max_mesh_work_group_count)
.min()
.unwrap();
max_task_invocations_per_workgroup = m.max_task_work_group_invocations;
max_task_invocations_per_dimension =
m.max_task_work_group_size.into_iter().min().unwrap();
max_mesh_invocations_per_workgroup = m.max_mesh_work_group_invocations;
max_mesh_invocations_per_dimension =
m.max_mesh_work_group_size.into_iter().min().unwrap();
max_task_payload_size = m.max_task_payload_size;
max_mesh_output_vertices = m.max_mesh_output_vertices;
max_mesh_output_primitives = m.max_mesh_output_primitives;
max_mesh_output_layers = m.max_mesh_output_layers;
max_mesh_multiview_view_count = m.max_mesh_multiview_view_count;
}
// Prevent very large buffers on mesa and most android devices, and in all cases
// don't risk confusing JS by exceeding the range of a double.
@@ -1377,10 +1398,19 @@ impl PhysicalDeviceProperties {
max_buffer_size,
max_non_sampler_bindings: u32::MAX,
max_task_workgroup_total_count,
max_task_workgroups_per_dimension,
max_mesh_multiview_view_count,
max_task_mesh_workgroup_total_count,
max_task_mesh_workgroups_per_dimension,
max_task_invocations_per_workgroup,
max_task_invocations_per_dimension,
max_mesh_invocations_per_workgroup,
max_mesh_invocations_per_dimension,
max_task_payload_size,
max_mesh_output_vertices,
max_mesh_output_primitives,
max_mesh_output_layers,
max_mesh_multiview_view_count,
max_blas_primitive_count,
max_blas_geometry_count,
+21 -6
View File
@@ -178,10 +178,17 @@ fn print_adapter(output: &mut impl io::Write, report: &AdapterReport, idx: usize
max_immediate_size,
max_non_sampler_bindings,
max_task_workgroup_total_count,
max_task_workgroups_per_dimension,
max_mesh_multiview_view_count: max_mesh_multiview_count,
max_task_mesh_workgroup_total_count,
max_task_mesh_workgroups_per_dimension,
max_task_invocations_per_workgroup,
max_task_invocations_per_dimension,
max_mesh_invocations_per_workgroup,
max_mesh_invocations_per_dimension,
max_task_payload_size,
max_mesh_output_vertices,
max_mesh_output_primitives,
max_mesh_output_layers,
max_mesh_multiview_view_count,
max_blas_primitive_count,
max_blas_geometry_count,
@@ -224,10 +231,18 @@ fn print_adapter(output: &mut impl io::Write, report: &AdapterReport, idx: usize
writeln!(output, "\t\t Max Compute Workgroup Size Z: {max_compute_workgroup_size_z}")?;
writeln!(output, "\t\t Max Compute Workgroups Per Dimension: {max_compute_workgroups_per_dimension}")?;
writeln!(output, "\t\t Max Task Workgroup Total Count: {max_task_workgroup_total_count}")?;
writeln!(output, "\t\t Max Task Workgroups Per Dimension: {max_task_workgroups_per_dimension}")?;
writeln!(output, "\t\t Max Mesh Multiview View Count: {max_mesh_multiview_count}")?;
writeln!(output, "\t\t Max Task/Mesh Workgroup Total Count: {max_task_mesh_workgroup_total_count}")?;
writeln!(output, "\t\t Max Task/Mesh Workgroups Per Dimension: {max_task_mesh_workgroups_per_dimension}")?;
writeln!(output, "\t\t Max Task Invocations Per Workgroup: {max_task_invocations_per_workgroup}")?;
writeln!(output, "\t\t Max Task Invocations Per Dimension: {max_task_invocations_per_dimension}")?;
writeln!(output, "\t\t Max Mesh Invocations Per Workgroup: {max_mesh_invocations_per_workgroup}")?;
writeln!(output, "\t\t Max Mesh Invocations Per Dimension: {max_mesh_invocations_per_dimension}")?;
writeln!(output, "\t\t Max Task Payload Size: {max_task_payload_size}")?;
writeln!(output, "\t\t Max Mesh Output Vertices: {max_mesh_output_vertices}")?;
writeln!(output, "\t\t Max Mesh Output Primitives: {max_mesh_output_primitives}")?;
writeln!(output, "\t\t Max Mesh Output Layers: {max_mesh_output_layers}")?;
writeln!(output, "\t\t Max Mesh Multiview View Count: {max_mesh_multiview_view_count}")?;
writeln!(output, "\t\t Max BLAS Primitive count: {max_blas_primitive_count}")?;
writeln!(output, "\t\t Max BLAS Geometry count: {max_blas_geometry_count}")?;
+96 -31
View File
@@ -59,10 +59,18 @@ macro_rules! with_limits {
$macro_name!(max_immediate_size, Ordering::Less);
$macro_name!(max_non_sampler_bindings, Ordering::Less);
$macro_name!(max_task_workgroup_total_count, Ordering::Less);
$macro_name!(max_task_workgroups_per_dimension, Ordering::Less);
$macro_name!(max_mesh_multiview_view_count, Ordering::Less);
$macro_name!(max_task_mesh_workgroup_total_count, Ordering::Less);
$macro_name!(max_task_mesh_workgroups_per_dimension, Ordering::Less);
$macro_name!(max_task_invocations_per_workgroup, Ordering::Less);
$macro_name!(max_task_invocations_per_dimension, Ordering::Less);
$macro_name!(max_mesh_invocations_per_workgroup, Ordering::Less);
$macro_name!(max_mesh_invocations_per_dimension, Ordering::Less);
$macro_name!(max_task_payload_size, Ordering::Less);
$macro_name!(max_mesh_output_vertices, Ordering::Less);
$macro_name!(max_mesh_output_primitives, Ordering::Less);
$macro_name!(max_mesh_output_layers, Ordering::Less);
$macro_name!(max_mesh_multiview_view_count, Ordering::Less);
$macro_name!(max_blas_primitive_count, Ordering::Less);
$macro_name!(max_blas_geometry_count, Ordering::Less);
@@ -232,14 +240,33 @@ pub struct Limits {
/// to create many bind groups at the cost of a large up-front allocation at device creation.
pub max_non_sampler_bindings: u32,
/// The maximum total value of x*y*z for a given `draw_mesh_tasks` command
pub max_task_workgroup_total_count: u32,
/// The maximum total value for a `RenderPass::draw_mesh_tasks(x, y, z)` operation or the
/// `@builtin(mesh_task_size)` returned from a task shader. Higher is "better".
pub max_task_mesh_workgroup_total_count: u32,
/// The maximum value for each dimension of a `RenderPass::draw_mesh_tasks(x, y, z)` operation.
/// Defaults to 65535. Higher is "better".
pub max_task_workgroups_per_dimension: u32,
/// The maximum number of layers that can be output from a mesh shader
/// Also for task shader outputs. Higher is "better".
pub max_task_mesh_workgroups_per_dimension: u32,
// These are fundamentally different. It is very common for limits on mesh shaders to be much lower.
/// Maximum total number of invocations, or threads, per task shader workgroup. Higher is "better".
pub max_task_invocations_per_workgroup: u32,
/// The maximum value for each dimension of a task shader's workgroup size. Higher is "better".
pub max_task_invocations_per_dimension: u32,
/// Maximum total number of invocations, or threads, per mesh shader workgroup. Higher is "better".
pub max_mesh_invocations_per_workgroup: u32,
/// The maximum value for each dimension of a mesh shader's workgroup size. Higher is "better".
pub max_mesh_invocations_per_dimension: u32,
/// The maximum size of the payload passed from task to mesh shader. Higher is "better".
pub max_task_payload_size: u32,
/// The maximum number of vertices that a mesh shader may output. Higher is "better".
pub max_mesh_output_vertices: u32,
/// The maximum number of primitives that a mesh shader may output. Higher is "better".
pub max_mesh_output_primitives: u32,
/// The maximum number of layers that can be output from a mesh shader. Higher is "better".
/// See [#8509](https://github.com/gfx-rs/wgpu/issues/8509).
pub max_mesh_output_layers: u32,
/// The maximum number of views that can be used by a mesh shader in multiview rendering
/// The maximum number of views that can be used by a mesh shader in multiview rendering.
/// Higher is "better".
pub max_mesh_multiview_view_count: u32,
/// The maximum number of primitive (ex: triangles, aabbs) a BLAS is allowed to have. Requesting
@@ -311,10 +338,17 @@ impl Limits {
/// max_compute_workgroups_per_dimension: 65535,
/// max_immediate_size: 0,
/// max_non_sampler_bindings: 1_000_000,
/// max_task_workgroup_total_count: 0,
/// max_task_workgroups_per_dimension: 0,
/// max_mesh_multiview_view_count: 0,
/// max_task_mesh_workgroup_total_count: 0,
/// max_task_mesh_workgroups_per_dimension: 0,
/// max_task_invocations_per_workgroup: 0,
/// max_task_invocations_per_dimension: 0,
/// max_mesh_invocations_per_workgroup: 0,
/// max_mesh_invocations_per_dimension: 0,
/// max_task_payload_size: 0,
/// max_mesh_output_vertices: 0,
/// max_mesh_output_primitives: 0,
/// max_mesh_output_layers: 0,
/// max_mesh_multiview_view_count: 0,
/// max_blas_primitive_count: 0,
/// max_blas_geometry_count: 0,
/// max_tlas_instance_count: 0,
@@ -363,10 +397,17 @@ impl Limits {
max_immediate_size: 0,
max_non_sampler_bindings: 1_000_000,
max_task_workgroup_total_count: 0,
max_task_workgroups_per_dimension: 0,
max_mesh_multiview_view_count: 0,
max_task_mesh_workgroup_total_count: 0,
max_task_mesh_workgroups_per_dimension: 0,
max_task_invocations_per_workgroup: 0,
max_task_invocations_per_dimension: 0,
max_mesh_invocations_per_workgroup: 0,
max_mesh_invocations_per_dimension: 0,
max_task_payload_size: 0,
max_mesh_output_vertices: 0,
max_mesh_output_primitives: 0,
max_mesh_output_layers: 0,
max_mesh_multiview_view_count: 0,
max_blas_primitive_count: 0,
max_blas_geometry_count: 0,
@@ -418,10 +459,17 @@ impl Limits {
/// max_buffer_size: 256 << 20, // (256 MiB)
/// max_non_sampler_bindings: 1_000_000,
///
/// max_task_workgroup_total_count: 0,
/// max_task_workgroups_per_dimension: 0,
/// max_mesh_multiview_view_count: 0,
/// max_task_mesh_workgroup_total_count: 0,
/// max_task_mesh_workgroups_per_dimension: 0,
/// max_task_invocations_per_workgroup: 0,
/// max_task_invocations_per_dimension: 0,
/// max_mesh_invocations_per_workgroup: 0,
/// max_mesh_invocations_per_dimension: 0,
/// max_task_payload_size: 0,
/// max_mesh_output_vertices: 0,
/// max_mesh_output_primitives: 0,
/// max_mesh_output_layers: 0,
/// max_mesh_multiview_view_count: 0,
///
/// max_blas_primitive_count: 0,
/// max_blas_geometry_count: 0,
@@ -442,11 +490,6 @@ impl Limits {
max_color_attachments: 4,
// see: https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=7
max_compute_workgroup_storage_size: 16352,
max_task_workgroups_per_dimension: 0,
max_task_workgroup_total_count: 0,
max_mesh_multiview_view_count: 0,
max_mesh_output_layers: 0,
..Self::defaults()
}
}
@@ -493,10 +536,17 @@ impl Limits {
/// max_buffer_size: 256 << 20, // (256 MiB),
/// max_non_sampler_bindings: 1_000_000,
///
/// max_task_workgroup_total_count: 0,
/// max_task_workgroups_per_dimension: 0,
/// max_mesh_multiview_view_count: 0,
/// max_task_mesh_workgroup_total_count: 0,
/// max_task_mesh_workgroups_per_dimension: 0,
/// max_task_invocations_per_workgroup: 0,
/// max_task_invocations_per_dimension: 0,
/// max_mesh_invocations_per_workgroup: 0,
/// max_mesh_invocations_per_dimension: 0,
/// max_task_payload_size: 0,
/// max_mesh_output_vertices: 0,
/// max_mesh_output_primitives: 0,
/// max_mesh_output_layers: 0,
/// max_mesh_multiview_view_count: 0,
///
/// max_blas_primitive_count: 0,
/// max_blas_geometry_count: 0,
@@ -590,13 +640,28 @@ impl Limits {
#[must_use]
pub const fn using_recommended_minimum_mesh_shader_values(self) -> Self {
Self {
// This is a common limit for apple devices. It's not immediately clear why.
max_task_workgroup_total_count: 1024,
max_task_workgroups_per_dimension: 1024,
// This limitation comes from metal
max_task_mesh_workgroup_total_count: 1024,
// This is a DirectX limitation
max_task_mesh_workgroups_per_dimension: 256,
// Copied from compute limits, this is low enough that it should be sensible.
max_task_invocations_per_workgroup: 256,
max_task_invocations_per_dimension: 64,
// DX12 limitation, revisit for vulkan
max_mesh_invocations_per_workgroup: 128,
max_mesh_invocations_per_dimension: 128,
// Metal specifies this as its max
max_task_payload_size: 16384 - 32,
// DX12 limitation, revisit for vulkan
max_mesh_output_vertices: 256,
max_mesh_output_primitives: 256,
// llvmpipe once again requires this to be 8. An RTX 3060 supports well over 1024.
// Also DX12 vaguely suggests going over this is illegal in some cases.
max_mesh_output_layers: 8,
// llvmpipe reports 0 multiview count, which just means no multiview is allowed
max_mesh_multiview_view_count: 0,
// llvmpipe once again requires this to be <=8. An RTX 3060 supports well over 1024.
max_mesh_output_layers: 8,
..self
}
}
+15 -2
View File
@@ -822,8 +822,21 @@ fn map_wgt_limits(limits: webgpu_sys::GpuSupportedLimits) -> wgt::Limits {
max_non_sampler_bindings: wgt::Limits::default().max_non_sampler_bindings,
max_inter_stage_shader_components: wgt::Limits::default().max_inter_stage_shader_components,
max_task_workgroup_total_count: wgt::Limits::default().max_task_workgroup_total_count,
max_task_workgroups_per_dimension: wgt::Limits::default().max_task_workgroups_per_dimension,
max_task_mesh_workgroup_total_count: wgt::Limits::default()
.max_task_mesh_workgroup_total_count,
max_task_mesh_workgroups_per_dimension: wgt::Limits::default()
.max_task_mesh_workgroups_per_dimension,
max_task_invocations_per_workgroup: wgt::Limits::default()
.max_task_invocations_per_workgroup,
max_task_invocations_per_dimension: wgt::Limits::default()
.max_task_invocations_per_dimension,
max_mesh_invocations_per_workgroup: wgt::Limits::default()
.max_mesh_invocations_per_workgroup,
max_mesh_invocations_per_dimension: wgt::Limits::default()
.max_mesh_invocations_per_dimension,
max_task_payload_size: wgt::Limits::default().max_task_payload_size,
max_mesh_output_vertices: wgt::Limits::default().max_mesh_output_vertices,
max_mesh_output_primitives: wgt::Limits::default().max_mesh_output_primitives,
max_mesh_output_layers: wgt::Limits::default().max_mesh_output_layers,
max_mesh_multiview_view_count: wgt::Limits::default().max_mesh_multiview_view_count,