diff --git a/.cargo/config.in b/.cargo/config.in index cae549949f06..2755c638b40a 100644 --- a/.cargo/config.in +++ b/.cargo/config.in @@ -292,7 +292,7 @@ wgpu ? rev = -a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +767ac03245ee937d3dc552edc13fe7ab0a860eec " ] git @@ -315,7 +315,7 @@ wgpu rev = " -a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +767ac03245ee937d3dc552edc13fe7ab0a860eec " replace - diff --git a/Cargo.lock b/Cargo.lock index 02503221eb5e..ce96768da4b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6686,9 +6686,9 @@ wgpu ? rev = -a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +767ac03245ee937d3dc552edc13fe7ab0a860eec # -a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +767ac03245ee937d3dc552edc13fe7ab0a860eec " dependencies = @@ -20906,9 +20906,9 @@ wgpu ? rev = -a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +767ac03245ee937d3dc552edc13fe7ab0a860eec # -a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +767ac03245ee937d3dc552edc13fe7ab0a860eec " dependencies = @@ -35406,9 +35406,9 @@ wgpu ? rev = -a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +767ac03245ee937d3dc552edc13fe7ab0a860eec # -a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +767ac03245ee937d3dc552edc13fe7ab0a860eec " dependencies = @@ -35521,9 +35521,9 @@ wgpu ? rev = -a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +767ac03245ee937d3dc552edc13fe7ab0a860eec # -a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +767ac03245ee937d3dc552edc13fe7ab0a860eec " dependencies = @@ -35694,9 +35694,9 @@ wgpu ? rev = -a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +767ac03245ee937d3dc552edc13fe7ab0a860eec # -a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +767ac03245ee937d3dc552edc13fe7ab0a860eec " dependencies = diff --git a/dom/webgpu/Adapter.cpp b/dom/webgpu/Adapter.cpp index 02cf5c41271c..b6b7c725629f 100644 --- a/dom/webgpu/Adapter.cpp +++ b/dom/webgpu/Adapter.cpp @@ -818,23 +818,12 @@ GPUFeatureName : Float32_filterable : -# -ifdef -WGPUFeatures_FLOAT32_FILTERABLE -# -error -fix -todo -# -endif return -Nothing +Some ( +WGPUFeatures_FLOAT32_FILTERABLE ) ; -/ -/ -TODO case dom : @@ -2970,7 +2959,7 @@ ffiDesc ; ffiDesc . -features +required_features = * MakeFeatureBits @@ -2982,7 +2971,7 @@ mRequiredFeatures ; ffiDesc . -limits +required_limits = deviceLimits ; @@ -3037,7 +3026,7 @@ request mId ffiDesc . -limits +required_limits ) ; for diff --git a/gfx/wgpu_bindings/Cargo.toml b/gfx/wgpu_bindings/Cargo.toml index aa993364075e..db5b4e3b4707 100644 --- a/gfx/wgpu_bindings/Cargo.toml +++ b/gfx/wgpu_bindings/Cargo.toml @@ -98,7 +98,7 @@ wgpu rev = " -a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +767ac03245ee937d3dc552edc13fe7ab0a860eec " # Note @@ -226,7 +226,7 @@ wgpu rev = " -a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +767ac03245ee937d3dc552edc13fe7ab0a860eec " features = @@ -288,7 +288,7 @@ wgpu rev = " -a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +767ac03245ee937d3dc552edc13fe7ab0a860eec " features = @@ -378,7 +378,7 @@ wgpu rev = " -a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +767ac03245ee937d3dc552edc13fe7ab0a860eec " features = @@ -419,7 +419,7 @@ wgpu rev = " -a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +767ac03245ee937d3dc552edc13fe7ab0a860eec " [ dependencies @@ -453,7 +453,7 @@ wgpu rev = " -a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +767ac03245ee937d3dc552edc13fe7ab0a860eec " [ target @@ -489,7 +489,7 @@ wgpu rev = " -a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +767ac03245ee937d3dc552edc13fe7ab0a860eec " [ target diff --git a/gfx/wgpu_bindings/moz.yaml b/gfx/wgpu_bindings/moz.yaml index 43a874a35843..36aa974d62ad 100644 --- a/gfx/wgpu_bindings/moz.yaml +++ b/gfx/wgpu_bindings/moz.yaml @@ -124,7 +124,7 @@ SSS release : commit -a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +767ac03245ee937d3dc552edc13fe7ab0a860eec # Revision to @@ -145,7 +145,7 @@ preferred ) revision : -a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +767ac03245ee937d3dc552edc13fe7ab0a860eec license : [ diff --git a/gfx/wgpu_bindings/src/client.rs b/gfx/wgpu_bindings/src/client.rs index e78d4e91e4cd..4c16132a8334 100644 --- a/gfx/wgpu_bindings/src/client.rs +++ b/gfx/wgpu_bindings/src/client.rs @@ -3613,6 +3613,9 @@ ptr ptr ) } +plane +: +None } ; let diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml index beb5e40a1578..6dda1dca7350 100644 --- a/supply-chain/audits.toml +++ b/supply-chain/audits.toml @@ -11381,6 +11381,56 @@ d3d12 who = " +Nicolas +Silva +< +nical +fastmail +. +com +> +" +criteria += +" +safe +- +to +- +deploy +" +delta += +" +0 +. +7 +. +0 +git +: +a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +- +> +0 +. +7 +. +0 +git +: +767ac03245ee937d3dc552edc13fe7ab0a860eec +" +[ +[ +audits +. +d3d12 +] +] +who += +" Teodor Tanasoaia < @@ -23997,6 +24047,56 @@ naga who = " +Nicolas +Silva +< +nical +fastmail +. +com +> +" +criteria += +" +safe +- +to +- +deploy +" +delta += +" +0 +. +14 +. +0 +git +: +a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +- +> +0 +. +14 +. +0 +git +: +767ac03245ee937d3dc552edc13fe7ab0a860eec +" +[ +[ +audits +. +naga +] +] +who += +" Teodor Tanasoaia < @@ -40416,6 +40516,58 @@ core who = " +Nicolas +Silva +< +nical +fastmail +. +com +> +" +criteria += +" +safe +- +to +- +deploy +" +delta += +" +0 +. +18 +. +0 +git +: +a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +- +> +0 +. +18 +. +0 +git +: +767ac03245ee937d3dc552edc13fe7ab0a860eec +" +[ +[ +audits +. +wgpu +- +core +] +] +who += +" Teodor Tanasoaia < @@ -41080,6 +41232,58 @@ hal who = " +Nicolas +Silva +< +nical +fastmail +. +com +> +" +criteria += +" +safe +- +to +- +deploy +" +delta += +" +0 +. +18 +. +0 +git +: +a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +- +> +0 +. +18 +. +0 +git +: +767ac03245ee937d3dc552edc13fe7ab0a860eec +" +[ +[ +audits +. +wgpu +- +hal +] +] +who += +" Teodor Tanasoaia < @@ -41744,6 +41948,58 @@ types who = " +Nicolas +Silva +< +nical +fastmail +. +com +> +" +criteria += +" +safe +- +to +- +deploy +" +delta += +" +0 +. +18 +. +0 +git +: +a820a3ffba468cbb87c2a7e7bbe37065ed5207ee +- +> +0 +. +18 +. +0 +git +: +767ac03245ee937d3dc552edc13fe7ab0a860eec +" +[ +[ +audits +. +wgpu +- +types +] +] +who += +" Teodor Tanasoaia < diff --git a/third_party/rust/d3d12/.cargo-checksum.json b/third_party/rust/d3d12/.cargo-checksum.json index 605686564c63..ec067fa0e889 100644 --- a/third_party/rust/d3d12/.cargo-checksum.json +++ b/third_party/rust/d3d12/.cargo-checksum.json @@ -62,7 +62,7 @@ rs " : " -beb49cf5a4e53e3e5b121ea7c3247fc8e74eaba67f1fb7dee3416174d5a9fa07 +8723f3b755b721e0dbb234bd604956c1b7922a2368231197495daa3fa6548e63 " " src diff --git a/third_party/rust/d3d12/src/command_list.rs b/third_party/rust/d3d12/src/command_list.rs index 2abea7a3b396..26a640fac23c 100644 --- a/third_party/rust/d3d12/src/command_list.rs +++ b/third_party/rust/d3d12/src/command_list.rs @@ -1180,10 +1180,10 @@ VertexCount num_instances : InstanceCount -start_vertex +first_vertex : VertexCount -start_instance +first_instance : InstanceCount ) @@ -1196,8 +1196,8 @@ DrawInstanced ( num_vertices num_instances -start_vertex -start_instance +first_vertex +first_instance ) ; } @@ -1214,13 +1214,13 @@ IndexCount num_instances : InstanceCount -start_index +first_index : IndexCount base_vertex : VertexOffset -start_instance +first_instance : InstanceCount ) @@ -1233,9 +1233,9 @@ DrawIndexedInstanced ( num_indices num_instances -start_index +first_index base_vertex -start_instance +first_instance ) ; } diff --git a/third_party/rust/naga/.cargo-checksum.json b/third_party/rust/naga/.cargo-checksum.json index 74f8931f6232..82e5d6df9d4b 100644 --- a/third_party/rust/naga/.cargo-checksum.json +++ b/third_party/rust/naga/.cargo-checksum.json @@ -32,7 +32,7 @@ toml " : " -26d629b351260272be0812654b139819b7648176e8414636e0780133aa9792e5 +5bd726a75d7177a43e517d27d412ac38879231f79795226ebcd0873ff1255fe9 " " README @@ -41,7 +41,7 @@ md " : " -a8209bed7462de253558ee8b197c0ce706d505243b2d23614f74464f1d62e15f +a76b47b656e7390265312709b62b357a4f39c7509ec9ebe0b133c5841a8ab60b " " benches @@ -93,7 +93,7 @@ rs " : " -c0988dd960f545c0706f701a5b143fc638330eb2bca6f6e5b9131651da1300be +90c6a6255d550e9d97a04d6b6660c1a7af8e2433dd9379dc1d527693fa56523b " " src @@ -108,7 +108,7 @@ rs " : " -fbc6dad7e0da457f682ee21f86f5b9ebf0b080d750e34e5600085e14f07ab1c1 +1546facbaddf696602102f32e47db7afc875f8ca3fbccc2122e0bcc45e022b53 " " src @@ -123,7 +123,7 @@ rs " : " -2501ebfcab34af68c6858053d04d92bae12d1a1b93349ccfbc56ec1978c90b73 +bba387392e3b9b22835d78a1db7d1490e7199cafcb347d54b22373b7b76b2900 " " src @@ -138,7 +138,7 @@ rs " : " -487dd2786ab6153c3fc8637ad11cd17dd7015400684ae4daa949b2dc0d9929be +5e40946f2d5ad6589dd2b0570d2c300dd96f92f0f954b829dc54a822de7774e8 " " src @@ -213,7 +213,7 @@ rs " : " -41a29d43b2d75bfd5b8d682d5a07be3fc1ff8a54cf4ba4aaa898889010e7200d +8e61501bae6982273a525734d3e446694d4bf7a081419ec312c32b354e89d3ef " " src @@ -286,7 +286,7 @@ rs " : " -63d7a4fbc0544662549f650af4e10e1ea2f3bb6b0587d0500a01e46cae376fc0 +9503df4ae10d1d7b6840cb68e2e2ff4f7ed8761b217faa99e6927d87da546071 " " src @@ -301,7 +301,7 @@ rs " : " -75fdfd576951f12c0d6da3d6167ae550d89dc50635f97a67cd375285fb441ad1 +976c0856d25dc0f54f4b5039b5e101088f32a92c373c7449682e9c8d64fc48c0 " " src @@ -331,7 +331,7 @@ rs " : " -d81d770645913fd57725237f6f96cc4d0a6674b7096fab7e620fb58dc0087e64 +5840a6d5cdffbf30cb20a76ddfdb468041fc6b687a476b3b2fc2553bda6f4af7 " " src @@ -451,7 +451,7 @@ rs " : " -a45c9357e097de1c225ea4a36f91a921f6c871140c15a98a2903e6975e46d59c +a76a73c0692162da24ab5508bc3ca70eb5e01367fe54472d100e237dbd594467 " " src @@ -481,7 +481,7 @@ rs " : " -27bb426c3726547b4799f1d77befb563bffa9b6086bfc81cb5a507454aedd8ba +f996c393aac339139eed8592b5fdd15fc786a49d3542985dc8ecb07f549a77ea " " src @@ -544,7 +544,7 @@ rs " : " -6b171f09fcd9423eecb2865fa854ed5cec725ff30dc572baaee68b3b24cef0eb +8abea7a8a9870d953fb628a32bac2bc15e87e077910cb95aa1f26e58a0a35c2a " " src @@ -818,7 +818,7 @@ rs " : " -e47355199f45cafed16818f73688cebf12a217493a770df7b091b9a5f3058216 +58c9cf3d570dff8cb68f2931faf5b18e875e510741bf035ec10b9ff6df27c5d8 " " src @@ -977,7 +977,7 @@ rs " : " -8b4887c1ede20efb3c1b885ca2a8848856553ac0b8ced26e1285082b620da39b +a2abfd483afe46e1e80d47568ea56c2d587de8dd6291739b03de788f37dada0e " " src @@ -1009,7 +1009,24 @@ rs " : " -1629d80fffc31859328388760fea8572a314152a38b166bde5d1285a33df0bb9 +48b2c1b0ef93345bc3cdbf1af29690cc128a4507f0b9d7d908a136f4c0fd48ca +" +" +src +/ +front +/ +wgsl +/ +lower +/ +conversion +. +rs +" +: +" +6d123e0148fc6d5b8df3d218ce1978a154d0edb86f65ca20fdc91bb4bf9475ce " " src @@ -1026,7 +1043,7 @@ rs " : " -054dfa8bb76d9f1ec07d0decb1ccd23d86cc55be005a26a1e223104478d4d359 +d1954f9845fd4fedbf688dbcff85310954eb69ac228a3e2a128bd5759ad8667d " " src @@ -1092,7 +1109,7 @@ rs " : " -a26d1c6f76b4883a4b79a617f9914eb3f4b05fbae4d4112606a9598d31a46b8e +bff1d0e3cd920b2e9342b521bed7483595556b90088dc0b22e1599900585ff8e " " src @@ -1126,7 +1143,7 @@ rs " : " -64fe5d5f6b1d6a6acf15f4cad3cda8045ad5d82efda179627f848aba9c47e605 +623423471a13cf9a45662ee3ac01554644ac544338c7493cfe6087549bab91f7 " " src @@ -1141,7 +1158,7 @@ rs " : " -ab26c5c82a21a4e8072fcdc8b3c47c3d6ac1d854047dd88db99e02aa67502e48 +39d0b44d0f073a7599c88b7c4efd1572886f3af074fa2015454623be313b297f " " src @@ -1156,7 +1173,7 @@ rs " : " -0ad5ab5662a8538fe238143ea288b8b52fa9f4ce52a3ea4c3ae6353bd9429eca +2e2e30d86b07f209b866e530d3a882803bf28b39ce379052561a749f628e8e28 " " src @@ -1193,7 +1210,7 @@ rs " : " -ea60e2bfa334456b1c2572ceacd14b6feb30759f8f06d1f0013c72c74b7de2e1 +c5d91c603ae310a7ef9ff8444898959a3dbbc32ba262cabb1fd5682823921d98 " " src @@ -1206,7 +1223,7 @@ rs " : " -3559cfdce73957eceb1589435aaf1a09514ea0bfd49d1a1092dd7e06f82e9af3 +0f55fb6f8310dee8dc021f27ab5c3c0ed896963f82150346fcdfbefc47b5e4a1 " " src @@ -1258,7 +1275,7 @@ rs " : " -96ade50eefb2541e59b30c7377d97fc5b10c0d03a4d0492541c4db79d1ecfb92 +e6ce6a376aa4e3584f0386fdbe95c7ea2a93abe19b03cc261b6152c8fca24842 " " src @@ -1347,7 +1364,7 @@ rs " : " -37b9b3ae31fe13d0ae73a53496adc6ce3cc3ae30e617090ffaf8a9cabacc0987 +1cdbd594dbdb33d8473d93c11112cf717e262bb8c35cee10b01db4322b2237d7 " " src @@ -1360,7 +1377,7 @@ rs " : " -9782913bb4d3df874ca976aa86b06bffd6c30401b8861440a9430203fef9852a +5ec31146aacf7daae689836ff3e2978f075f2cc62b3fd829d09c760a6e606501 " " src @@ -1412,7 +1429,7 @@ rs " : " -447d5004f18778dee31df0caa68e5a31351f3aeaec3e4e142107d32d0308cd55 +09e18bb9510dbb0cfb4a8ac054afee4c4f56063d614159ab5b956aa1e5850468 " } " diff --git a/third_party/rust/naga/Cargo.toml b/third_party/rust/naga/Cargo.toml index c835a2b849a8..3e39727e96db 100644 --- a/third_party/rust/naga/Cargo.toml +++ b/third_party/rust/naga/Cargo.toml @@ -168,6 +168,9 @@ target * " ] +autotests += +false description = " @@ -255,6 +258,27 @@ features true [ [ +test +] +] +name += +" +naga +- +test +" +path += +" +tests +/ +root +. +rs +" +[ +[ bench ] ] @@ -778,6 +802,9 @@ unicode - xid " +" +compact +" ] wgsl - diff --git a/third_party/rust/naga/README.md b/third_party/rust/naga/README.md index 4222d65587d0..82129859a76e 100644 --- a/third_party/rust/naga/README.md +++ b/third_party/rust/naga/README.md @@ -603,8 +603,7 @@ a CLI which allows -to -test +testing the conversion of diff --git a/third_party/rust/naga/src/back/glsl/features.rs b/third_party/rust/naga/src/back/glsl/features.rs index 341203ea9858..cd66eabf64e5 100644 --- a/third_party/rust/naga/src/back/glsl/features.rs +++ b/third_party/rust/naga/src/back/glsl/features.rs @@ -14,6 +14,16 @@ crate : : { +back +: +: +glsl +: +: +{ +Options +WriterFlags +} AddressSpace Binding Expression @@ -344,6 +354,37 @@ DUAL_SOURCE_BLENDING < 21 ; +/ +/ +/ +Instance +index +/ +/ +/ +/ +/ +/ +We +can +always +support +this +either +through +the +language +or +a +polyfill +const +INSTANCE_INDEX += +1 +< +< +22 +; } } / @@ -467,6 +508,48 @@ features / / Checks +if +the +list +of +features +[ +Features +] +contains +the +specified +[ +Features +] +pub +fn +contains +( +& +mut +self +features +: +Features +) +- +> +bool +{ +self +. +0 +. +contains +( +features +) +} +/ +/ +/ +Checks that all required @@ -1026,9 +1109,10 @@ write ( & self -version +options : -Version +& +Options mut out : @@ -1054,6 +1138,8 @@ COMPUTE_SHADER & & ! +options +. version . is_es @@ -1113,6 +1199,8 @@ BUFFER_STORAGE & & ! +options +. version . is_es @@ -1171,6 +1259,8 @@ DOUBLE_TYPE ) & & +options +. version < Version @@ -1233,6 +1323,8 @@ CUBE_TEXTURES_ARRAY ) { if +options +. version . is_es @@ -1279,6 +1371,8 @@ require } else if +options +. version < Version @@ -1342,6 +1436,8 @@ MULTISAMPLED_TEXTURE_ARRAYS ) & & +options +. version . is_es @@ -1400,6 +1496,8 @@ ARRAY_OF_ARRAYS ) & & +options +. version < Version @@ -1475,6 +1573,8 @@ FULL_IMAGE_FORMATS ) & & +options +. version . is_es @@ -1520,6 +1620,8 @@ require ; } if +options +. version < Version @@ -1583,6 +1685,8 @@ CONSERVATIVE_DEPTH ) { if +options +. version . is_es @@ -1628,6 +1732,8 @@ require ; } if +options +. version < Version @@ -1706,6 +1812,8 @@ CULL_DISTANCE ) & & +options +. version . is_es @@ -1764,6 +1872,8 @@ SAMPLE_VARIABLES ) & & +options +. version . is_es @@ -1835,6 +1945,8 @@ true . } = +options +. version { / @@ -1983,6 +2095,8 @@ TEXTURE_LEVELS ) & & +options +. version < Version @@ -2045,6 +2159,8 @@ DUAL_SOURCE_BLENDING ) & & +options +. version . is_es @@ -2087,6 +2203,69 @@ require ? ; } +if +self +. +0 +. +contains +( +Features +: +: +INSTANCE_INDEX +) +{ +if +options +. +writer_flags +. +contains +( +WriterFlags +: +: +DRAW_PARAMETERS +) +{ +/ +/ +https +: +/ +/ +registry +. +khronos +. +org +/ +OpenGL +/ +extensions +/ +ARB +/ +ARB_shader_draw_parameters +. +txt +writeln +! +( +out +" +# +extension +GL_ARB_shader_draw_parameters +: +require +" +) +? +; +} +} Ok ( ( @@ -3761,6 +3940,28 @@ Features MULTI_VIEW ) } +crate +: +: +BuiltIn +: +: +InstanceIndex += +> +{ +self +. +features +. +request +( +Features +: +: +INSTANCE_INDEX +) +} _ = > diff --git a/third_party/rust/naga/src/back/glsl/keywords.rs b/third_party/rust/naga/src/back/glsl/keywords.rs index b7928d803812..d6583bf7669d 100644 --- a/third_party/rust/naga/src/back/glsl/keywords.rs +++ b/third_party/rust/naga/src/back/glsl/keywords.rs @@ -2472,5 +2472,9 @@ super : : FREXP_FUNCTION +super +: +: +FIRST_INSTANCE_BINDING ] ; diff --git a/third_party/rust/naga/src/back/glsl/mod.rs b/third_party/rust/naga/src/back/glsl/mod.rs index 35497510bf72..0dec59e34a7e 100644 --- a/third_party/rust/naga/src/back/glsl/mod.rs +++ b/third_party/rust/naga/src/back/glsl/mod.rs @@ -610,6 +610,24 @@ naga_frexp ; / / +Must +match +code +in +glsl_built_in +pub +const +FIRST_INSTANCE_BINDING +: +& +str += +" +naga_vs_first_instance +" +; +/ +/ / Mapping between @@ -1870,6 +1888,31 @@ TEXTURE_SHADOW_LOD / / / +Supports +ARB_shader_draw_parameters +on +the +host +which +provides +/ +/ +/ +support +for +gl_BaseInstanceARB +gl_BaseVertexARB +and +gl_DrawIDARB +. +const +DRAW_PARAMETERS += +0x4 +; +/ +/ +/ Include unused global @@ -1919,7 +1962,7 @@ variables const INCLUDE_UNUSED_ITEMS = -0x4 +0x10 ; / / @@ -2031,7 +2074,7 @@ stages const FORCE_POINT_SIZE = -0x10 +0x20 ; } } @@ -3180,6 +3223,84 @@ ret / / / +Assorted +options +needed +for +generting +varyings +. +# +[ +derive +( +Clone +Copy +) +] +struct +VaryingOptions +{ +output +: +bool +targetting_webgl +: +bool +draw_parameters +: +bool +} +impl +VaryingOptions +{ +const +fn +from_writer_options +( +options +: +& +Options +output +: +bool +) +- +> +Self +{ +Self +{ +output +targetting_webgl +: +options +. +version +. +is_webgl +( +) +draw_parameters +: +options +. +writer_flags +. +contains +( +WriterFlags +: +: +DRAW_PARAMETERS +) +} +} +} +/ +/ +/ Helper wrapper used @@ -3275,12 +3396,9 @@ Binding stage : ShaderStage -output -: -bool -targetting_webgl +options : -bool +VaryingOptions } impl fmt @@ -3372,6 +3490,8 @@ self stage self . +options +. output ) { @@ -3491,10 +3611,7 @@ glsl_built_in built_in self . -output -self -. -targetting_webgl +options ) ) } @@ -4660,6 +4777,31 @@ RESERVED_KEYWORDS " gl_ " +/ +/ +all +GL +built +- +in +variables +" +_group +" +/ +/ +all +normal +bindings +" +_push_constant_binding_ +" +/ +/ +all +push +constant +bindings ] & mut @@ -5018,8 +5160,6 @@ write self . options -. -version & mut self @@ -5237,6 +5377,75 @@ out ? ; } +if +self +. +entry_point +. +stage += += +ShaderStage +: +: +Vertex +& +& +! +self +. +options +. +writer_flags +. +contains +( +WriterFlags +: +: +DRAW_PARAMETERS +) +& +& +self +. +features +. +contains +( +Features +: +: +INSTANCE_INDEX +) +{ +writeln +! +( +self +. +out +" +uniform +uint +{ +FIRST_INSTANCE_BINDING +} +; +" +) +? +; +writeln +! +( +self +. +out +) +? +; +} / / Enable @@ -11051,15 +11260,15 @@ invariant glsl_built_in ( built_in -output +VaryingOptions +: +: +from_writer_options +( self . options -. -version -. -is_webgl -( +output ) ) ) @@ -11503,17 +11712,17 @@ self entry_point . stage -output -targetting_webgl +options +: +VaryingOptions : +: +from_writer_options +( self . options -. -version -. -is_webgl -( +output ) } ; @@ -12784,19 +12993,17 @@ unwrap ( ) stage -output +options +: +VaryingOptions : -false -targetting_webgl : +from_writer_options +( self . options -. -version -. -is_webgl -( +false ) } ; @@ -12870,19 +13077,17 @@ unwrap ( ) stage -output +options : -false -targetting_webgl +VaryingOptions : +: +from_writer_options +( self . options -. -version -. -is_webgl -( +false ) } ; @@ -16810,19 +17015,17 @@ stage ep . stage -output +options : -true -targetting_webgl +VaryingOptions : +: +from_writer_options +( self . options -. -version -. -is_webgl -( +true ) } ; @@ -16959,19 +17162,17 @@ stage ep . stage -output +options +: +VaryingOptions : -true -targetting_webgl : +from_writer_options +( self . options -. -version -. -is_webgl -( +true ) } ; @@ -18851,6 +19052,58 @@ into ) ; } +crate +: +: +Literal +: +: +AbstractInt +( +_ +) +| +crate +: +: +Literal +: +: +AbstractFloat +( +_ +) += +> +{ +return +Err +( +Error +: +: +Custom +( +" +Abstract +types +should +not +appear +in +IR +presented +to +backends +" +. +into +( +) +) +) +; +} } } Expression @@ -27687,6 +27940,39 @@ bool ) ? } +( +Sk +: +: +AbstractInt +| +Sk +: +: +AbstractFloat +_ +_ +) +| +( +_ +Sk +: +: +AbstractInt +| +Sk +: +: +AbstractFloat +_ +) += +> +unreachable +! +( +) } ; write @@ -32387,6 +32673,51 @@ out " ) ? +crate +: +: +ScalarKind +: +: +AbstractInt +| +crate +: +: +ScalarKind +: +: +AbstractFloat += +> +{ +return +Err +( +Error +: +: +Custom +( +" +Abstract +types +should +not +appear +in +IR +presented +to +backends +" +. +to_string +( +) +) +) +} } Ok ( @@ -34079,6 +34410,31 @@ full bool " } +Sk +: +: +AbstractInt +| +Sk +: +: +AbstractFloat += +> +{ +return +Err +( +Error +: +: +UnsupportedScalar +( +scalar +) +) +; +} } ) } @@ -34106,12 +34462,9 @@ crate : : BuiltIn -output -: -bool -targetting_webgl +options : -bool +VaryingOptions ) - > @@ -34143,6 +34496,8 @@ Position > { if +options +. output { " @@ -34161,6 +34516,8 @@ Bi : ViewIndex if +options +. targetting_webgl = > @@ -34230,12 +34587,45 @@ Bi InstanceIndex = > +{ +if +options +. +draw_parameters +{ +" +( +uint +( +gl_InstanceID +) ++ +uint +( +gl_BaseInstanceARB +) +) " +} +else +{ +/ +/ +Must +match +FISRT_INSTANCE_BINDING +" +( uint ( gl_InstanceID ) ++ +naga_vs_first_instance +) " +} +} Bi : : @@ -34316,6 +34706,8 @@ SampleMask > { if +options +. output { " diff --git a/third_party/rust/naga/src/back/hlsl/conv.rs b/third_party/rust/naga/src/back/hlsl/conv.rs index d8b278f58ed2..d03cb2cf82e3 100644 --- a/third_party/rust/naga/src/back/hlsl/conv.rs +++ b/third_party/rust/naga/src/back/hlsl/conv.rs @@ -78,6 +78,16 @@ Self : : Bool +| +Self +: +: +AbstractInt +| +Self +: +: +AbstractFloat = > unreachable @@ -264,6 +274,35 @@ Ok bool " ) +crate +: +: +ScalarKind +: +: +AbstractInt +| +crate +: +: +ScalarKind +: +: +AbstractFloat += +> +{ +Err +( +Error +: +: +UnsupportedScalar +( +self +) +) +} } } } diff --git a/third_party/rust/naga/src/back/hlsl/writer.rs b/third_party/rust/naga/src/back/hlsl/writer.rs index 64444e51efef..cb429acb7974 100644 --- a/third_party/rust/naga/src/back/hlsl/writer.rs +++ b/third_party/rust/naga/src/back/hlsl/writer.rs @@ -82,23 +82,23 @@ _NagaConstants " ; const -SPECIAL_BASE_VERTEX +SPECIAL_FIRST_VERTEX : & str = " -base_vertex +first_vertex " ; const -SPECIAL_BASE_INSTANCE +SPECIAL_FIRST_INSTANCE : & str = " -base_instance +first_instance " ; const @@ -1287,7 +1287,7 @@ back : : INDENT -SPECIAL_BASE_VERTEX +SPECIAL_FIRST_VERTEX ) ? ; @@ -1309,7 +1309,7 @@ back : : INDENT -SPECIAL_BASE_INSTANCE +SPECIAL_FIRST_INSTANCE ) ? ; @@ -14970,6 +14970,58 @@ out value ) ? +crate +: +: +Literal +: +: +AbstractInt +( +_ +) +| +crate +: +: +Literal +: +: +AbstractFloat +( +_ +) += +> +{ +return +Err +( +Error +: +: +Custom +( +" +Abstract +types +should +not +appear +in +IR +presented +to +backends +" +. +into +( +) +) +) +; +} } Expression : @@ -15425,11 +15477,10 @@ Handle the special semantics -for -base -vertex +of +vertex_index / -instance +instance_index let ff_input = @@ -15489,7 +15540,7 @@ SPECIAL_CBUF_VAR } . { -SPECIAL_BASE_VERTEX +SPECIAL_FIRST_VERTEX } + " @@ -15526,7 +15577,7 @@ SPECIAL_CBUF_VAR } . { -SPECIAL_BASE_INSTANCE +SPECIAL_FIRST_INSTANCE } + " @@ -15558,9 +15609,9 @@ despite their names ( -BASE_VERTEX +FIRST_VERTEX and -BASE_INSTANCE +FIRST_INSTANCE ) / / @@ -15597,14 +15648,14 @@ SPECIAL_CBUF_VAR } . { -SPECIAL_BASE_VERTEX +SPECIAL_FIRST_VERTEX } { SPECIAL_CBUF_VAR } . { -SPECIAL_BASE_INSTANCE +SPECIAL_FIRST_INSTANCE } { SPECIAL_CBUF_VAR diff --git a/third_party/rust/naga/src/back/msl/writer.rs b/third_party/rust/naga/src/back/msl/writer.rs index c7666d504478..fc7261eb3018 100644 --- a/third_party/rust/naga/src/back/msl/writer.rs +++ b/third_party/rust/naga/src/back/msl/writer.rs @@ -2447,6 +2447,29 @@ _ " bool " +Self +{ +kind +: +Sk +: +: +AbstractInt +| +Sk +: +: +AbstractFloat +width +: +_ +} += +> +unreachable +! +( +) } } } @@ -2522,46 +2545,6 @@ members index ] ; -/ -/ -Note -: -this -is -imperfect -- -the -same -structure -can -be -used -for -host -- -shared -/ -/ -things -where -packed -float -would -matter -. -if -member -. -binding -. -is_some -( -) -{ -return -None -; -} let ty_inner = @@ -2668,16 +2651,6 @@ width } } if -member -. -offset -& -0xF -! -= -0 -| -| is_tight = > @@ -9748,6 +9721,40 @@ value ? ; } +crate +: +: +Literal +: +: +AbstractInt +( +_ +) +| +crate +: +: +Literal +: +: +AbstractFloat +( +_ +) += +> +{ +return +Err +( +Error +: +: +Validation +) +; +} } crate : @@ -25804,34 +25811,9 @@ enumerate ( ) { -/ -/ -quick -and -dirty -way -to -figure -out -if -we -need -this -. -. -. if member . -binding -. -is_none -( -) -& -& -member -. offset > last_offset @@ -32319,6 +32301,47 @@ out ? ; } +/ +/ +insert +padding +initialization +if +needed +if +self +. +struct_member_pads +. +contains +( +& +( +arg +. +ty +member_index +as +u32 +) +) +{ +write +! +( +self +. +out +" +{ +{ +} +} +" +) +? +; +} if let Some diff --git a/third_party/rust/naga/src/back/spv/block.rs b/third_party/rust/naga/src/back/spv/block.rs index c5f7fe5d871b..b2b5745b7134 100644 --- a/third_party/rust/naga/src/back/spv/block.rs +++ b/third_party/rust/naga/src/back/spv/block.rs @@ -8804,6 +8804,16 @@ Sk : : Bool +| +Sk +: +: +AbstractInt +| +Sk +: +: +AbstractFloat = > unreachable diff --git a/third_party/rust/naga/src/back/spv/image.rs b/third_party/rust/naga/src/back/spv/image.rs index 136c04a5945e..7da78d547be2 100644 --- a/third_party/rust/naga/src/back/spv/image.rs +++ b/third_party/rust/naga/src/back/spv/image.rs @@ -2700,6 +2700,59 @@ index " ) } +( +crate +: +: +ScalarKind +: +: +AbstractInt +| +crate +: +: +ScalarKind +: +: +AbstractFloat +_ +) +| +( +_ +crate +: +: +ScalarKind +: +: +AbstractInt +| +crate +: +: +ScalarKind +: +: +AbstractFloat +) += +> +{ +unreachable +! +( +" +abstract +types +should +never +reach +backends +" +) +} } ; let diff --git a/third_party/rust/naga/src/back/spv/writer.rs b/third_party/rust/naga/src/back/spv/writer.rs index b0a8e726eac4..dde902f47d00 100644 --- a/third_party/rust/naga/src/back/spv/writer.rs +++ b/third_party/rust/naga/src/back/spv/writer.rs @@ -5467,6 +5467,33 @@ type_bool ( id ) +Sk +: +: +AbstractInt +| +Sk +: +: +AbstractFloat += +> +{ +unreachable +! +( +" +abstract +types +should +never +reach +the +backend +" +) +; +} } } fn @@ -7934,6 +7961,48 @@ constant_false type_id id ) +crate +: +: +Literal +: +: +AbstractInt +( +_ +) +| +crate +: +: +Literal +: +: +AbstractFloat +( +_ +) += +> +{ +unreachable +! +( +" +Abstract +types +should +not +appear +in +IR +presented +to +backends +" +) +; +} } ; instruction @@ -10749,6 +10818,41 @@ Float = > false +Sk +: +: +AbstractInt +| +Sk +: +: +AbstractFloat += +> +{ +return +Err +( +Error +: +: +Validation +( +" +Abstract +types +should +not +appear +in +IR +presented +to +backends +" +) +) +} } _ = diff --git a/third_party/rust/naga/src/back/wgsl/writer.rs b/third_party/rust/naga/src/back/wgsl/writer.rs index b9efc3abe26f..07e3dbc095fe 100644 --- a/third_party/rust/naga/src/back/wgsl/writer.rs +++ b/third_party/rust/naga/src/back/wgsl/writer.rs @@ -8090,6 +8090,34 @@ Literal : F64 ( +value +) += +> +write +! +( +self +. +out +" +{ +: +? +} +lf +" +value +) +? +crate +: +: +Literal +: +: +I64 +( _ ) = @@ -8105,7 +8133,7 @@ Custom ( " unsupported -f64 +i64 literal " . @@ -8122,7 +8150,18 @@ crate Literal : : -I64 +AbstractInt +( +_ +) +| +crate +: +: +Literal +: +: +AbstractFloat ( _ ) @@ -8138,12 +8177,19 @@ Error Custom ( " -unsupported -i64 -literal +Abstract +types +should +not +appear +in +IR +presented +to +backends " . -to_string +into ( ) ) diff --git a/third_party/rust/naga/src/compact/mod.rs b/third_party/rust/naga/src/compact/mod.rs index 7baa56601bd5..acefe92f7691 100644 --- a/third_party/rust/naga/src/compact/mod.rs +++ b/third_party/rust/naga/src/compact/mod.rs @@ -808,6 +808,74 @@ ty } / / +Treat +all +named +types +as +used +. +for +( +handle +ty +) +in +module +. +types +. +iter +( +) +{ +log +: +: +trace +! +( +" +tracing +type +{ +: +? +} +name +{ +: +? +} +" +handle +ty +. +name +) +; +if +ty +. +name +. +is_some +( +) +{ +module_tracer +. +types_used +. +insert +( +handle +) +; +} +} +/ +/ Propagate usage through diff --git a/third_party/rust/naga/src/front/glsl/types.rs b/third_party/rust/naga/src/front/glsl/types.rs index c2f7c350343a..65ba8efad54f 100644 --- a/third_party/rust/naga/src/front/glsl/types.rs +++ b/third_party/rust/naga/src/front/glsl/types.rs @@ -1363,6 +1363,16 @@ ScalarKind : : Bool +| +ScalarKind +: +: +AbstractInt +| +ScalarKind +: +: +AbstractFloat = > return diff --git a/third_party/rust/naga/src/front/wgsl/error.rs b/third_party/rust/naga/src/front/wgsl/error.rs index 66802f782836..149449b606a1 100644 --- a/third_party/rust/naga/src/front/wgsl/error.rs +++ b/third_party/rust/naga/src/front/wgsl/error.rs @@ -264,19 +264,11 @@ iter ( ) . -map +filter_map ( | label | -{ -Label -: -: -primary -( -( -) label . 0 @@ -285,9 +277,35 @@ to_range ( ) . -unwrap +map +( +| +range +| +( +label +range +) +) +) +. +map +( +| +( +label +range +) +| +{ +Label +: +: +primary +( ( ) +range ) . with_message @@ -1601,6 +1619,21 @@ ConstantEvaluatorError ConstantEvaluatorError Span ) +AutoConversion +{ +dest_span +: +Span +dest_type +: +String +source_span +: +Span +source_type +: +String +} } impl < @@ -5913,6 +5946,97 @@ vec [ ] } +Error +: +: +AutoConversion +{ +dest_span +ref +dest_type +source_span +ref +source_type +} += +> +ParseError +{ +message +: +format +! +( +" +automatic +conversions +cannot +convert +{ +source_type +} +to +{ +dest_type +} +" +) +labels +: +vec +! +[ +( +dest_span +format +! +( +" +a +value +of +type +{ +dest_type +} +is +required +here +" +) +. +into +( +) +) +( +source_span +format +! +( +" +this +expression +has +type +{ +source_type +} +" +) +. +into +( +) +) +] +notes +: +vec +! +[ +] +} } } } diff --git a/third_party/rust/naga/src/front/wgsl/lower/construction.rs b/third_party/rust/naga/src/front/wgsl/lower/construction.rs index ce6779085d38..3432eedc9289 100644 --- a/third_party/rust/naga/src/front/wgsl/lower/construction.rs +++ b/third_party/rust/naga/src/front/wgsl/lower/construction.rs @@ -64,6 +64,18 @@ ExpressionContext Lowerer } ; +use +crate +: +: +front +: +: +wgsl +: +: +Scalar +; / / / @@ -662,15 +674,6 @@ Vec < Span > -first_component_ty_inner -: -& -' -a -crate -: -: -TypeInner } } impl @@ -977,6 +980,17 @@ source > > { +use +crate +: +: +proc +: +: +TypeResolution +as +Tr +; let constructor_h = @@ -1027,7 +1041,7 @@ component = self . -expression +expression_for_abstract ( component ctx @@ -1057,10 +1071,11 @@ span ty_inner } } -[ -component ref -rest +ast_components +[ +_ +_ . . ] @@ -1068,49 +1083,9 @@ rest > { let -span -= -ctx -. -ast_expressions -. -get_span -( -component -) -; -let -component -= -self -. -expression -( -component -ctx -) -? -; -let components = -std -: -: -iter -: -: -once -( -Ok -( -component -) -) -. -chain -( -rest +ast_components . iter ( @@ -1120,17 +1095,16 @@ map ( | & -component +expr | self . -expression +expression_for_abstract ( -component +expr ctx ) ) -) . collect : @@ -1149,20 +1123,7 @@ _ let spans = -std -: -: -iter -: -: -once -( -span -) -. -chain -( -rest +ast_components . iter ( @@ -1172,7 +1133,7 @@ map ( | & -component +expr | ctx . @@ -1180,8 +1141,7 @@ ast_expressions . get_span ( -component -) +expr ) ) . @@ -1189,19 +1149,22 @@ collect ( ) ; -let -first_component_ty_inner -= -super -: -: -resolve_inner -! -( +for +& +component +in +& +components +{ ctx +. +grow_types +( component ) +? ; +} Components : : @@ -1209,7 +1172,6 @@ Many { components spans -first_component_ty_inner } } } @@ -1267,7 +1229,7 @@ module ; let expr -= +; match ( components @@ -1443,6 +1405,9 @@ scalar ) = > +{ +expr += crate : : @@ -1468,6 +1433,8 @@ scalar width ) } +; +} / / Vector @@ -1538,6 +1505,9 @@ dst_size src_size = > +{ +expr += crate : : @@ -1563,6 +1533,8 @@ dst_scalar width ) } +; +} / / Vector @@ -1741,6 +1713,9 @@ dst_rows src_rows = > +{ +expr += crate : : @@ -1754,13 +1729,9 @@ expr component kind : -crate -: -: -ScalarKind -: -: -Float +dst_scalar +. +kind convert : Some @@ -1770,6 +1741,8 @@ dst_scalar width ) } +; +} / / Matrix @@ -1922,6 +1895,9 @@ size ) = > +{ +expr += crate : : @@ -1935,6 +1911,8 @@ value : component } +; +} / / Vector @@ -1948,6 +1926,7 @@ Components : One { +mut component ty_inner : @@ -1960,7 +1939,7 @@ TypeInner : Scalar ( -src_scalar +_ ) . . @@ -1983,19 +1962,35 @@ Vector { size scalar -: -dst_scalar } ) ) ) -if -dst_scalar -= -= -src_scalar = > +{ +ctx +. +convert_slice_to_common_scalar +( +std +: +: +slice +: +: +from_mut +( +& +mut +component +) +scalar +) +? +; +expr += crate : : @@ -2009,6 +2004,8 @@ value : component } +; +} / / Vector @@ -2017,42 +2014,16 @@ constructor by elements ) +partial ( Components : : Many { +mut components -first_component_ty_inner -: -& -crate -: -: -TypeInner -: -: -Scalar -( -scalar -) -| -& -crate -: -: -TypeInner -: -: -Vector -{ -scalar -. -. -} -. -. +spans } Constructor : @@ -2062,83 +2033,62 @@ PartialVector size } ) -| -( -Components -: -: -Many += +> { -components -first_component_ty_inner -: +let +consensus_scalar += +automatic_conversion_consensus +( & -crate -: -: -TypeInner -: -: -Scalar -{ -. +components +ctx +) . -} +map_err +( +| +index | -& -crate -: -: -TypeInner -: -: -Vector { -. -. -} -. -. -} -Constructor +Error : : -Type -( +InvalidConstructorComponentType ( -_ -& -crate -: -: -TypeInner -: -: -Vector -{ -size -scalar -} +spans +[ +index +] +index +as +i32 ) +} ) +? +; +ctx +. +convert_slice_to_common_scalar +( +& +mut +components +consensus_scalar ) -= -> -{ +? +; let inner = -crate -: -: -TypeInner -: -: -Vector -{ +consensus_scalar +. +to_inner_vector +( size -scalar -} +) ; let ty @@ -2150,6 +2100,8 @@ ensure_type_exists inner ) ; +expr += crate : : @@ -2161,24 +2113,37 @@ Compose ty components } +; } / / -Matrix +Vector constructor ( by elements ) +full +type +given ( Components : : Many { +mut components -first_component_ty_inner +. +. +} +Constructor +: : +Type +( +( +ty & crate : @@ -2186,73 +2151,167 @@ crate TypeInner : : -Scalar -( +Vector +{ scalar -) . . } -Constructor +) +) +) += +> +{ +ctx +. +try_automatic_conversions_for_vector +( +& +mut +components +scalar +ty_span +) +? +; +expr += +crate : : -PartialMatrix +Expression +: +: +Compose { -columns -rows +ty +components +} +; } +/ +/ +Matrix +constructor +( +by +elements ) -| +partial ( Components : : Many { +mut components -first_component_ty_inner -: -& -crate -: -: -TypeInner +spans +} +Constructor : : -Scalar +PartialMatrix { -. -. +columns +rows } +) +if +components . +len +( +) += += +columns +as +usize +* +rows +as +usize += +> +{ +let +consensus_scalar += +automatic_conversion_consensus +( +& +components +ctx +) . -} -Constructor +map_err +( +| +index +| +{ +Error : : -Type +InvalidConstructorComponentType ( +spans +[ +index +] +index +as +i32 +) +} +) +? +; +/ +/ +We +actually +only +accept +floating +- +point +elements +. +let +consensus_scalar += +consensus_scalar +. +automatic_conversion_combine ( -_ -& crate : : -TypeInner +Scalar : : -Matrix -{ -columns -rows -scalar -} +ABSTRACT_FLOAT ) +. +unwrap_or +( +consensus_scalar ) +; +ctx +. +convert_slice_to_common_scalar +( +& +mut +components +consensus_scalar ) -= -> -{ +? +; let vec_ty = @@ -2260,19 +2319,12 @@ ctx . ensure_type_exists ( -crate -: -: -TypeInner -: -: -Vector -{ -scalar -size -: +consensus_scalar +. +to_inner_vector +( rows -} +) ) ; let @@ -2363,9 +2415,13 @@ Matrix columns rows scalar +: +consensus_scalar } ) ; +expr += crate : : @@ -2377,6 +2433,7 @@ Compose ty components } +; } / / @@ -2384,52 +2441,28 @@ Matrix constructor ( by -columns +elements ) +type +given ( Components : : Many { +mut components -first_component_ty_inner -: -& -crate -: -: -TypeInner -: -: -Vector -{ -scalar -. -. -} . . } Constructor : : -PartialMatrix -{ -columns -rows -} -) -| +Type ( -Components -: -: -Many -{ -components -first_component_ty_inner -: +( +_ & crate : @@ -2437,40 +2470,151 @@ crate TypeInner : : -Vector +Matrix { -. -. +columns +rows +scalar } +) +) +) +if +components . -. -} -Constructor +len +( +) += += +columns +as +usize +* +rows +as +usize += +> +{ +let +element += +Tr : : -Type +Value +( +crate +: +: +TypeInner +: +: +Scalar ( +scalar +) +) +; +ctx +. +try_automatic_conversions_slice ( -_ & +mut +components +& +element +ty_span +) +? +; +let +vec_ty += +ctx +. +ensure_type_exists +( +scalar +. +to_inner_vector +( +rows +) +) +; +let +components += +components +. +chunks +( +rows +as +usize +) +. +map +( +| +vec_components +| +{ +ctx +. +append_expression +( crate : : -TypeInner +Expression : : -Matrix +Compose { -columns -rows -scalar +ty +: +vec_ty +components +: +Vec +: +: +from +( +vec_components +) } +Default +: +: +default +( ) ) +} ) -= +. +collect +: +: +< +Result +< +Vec +< +_ > -{ +_ +> +> +( +) +? +; let ty = @@ -2492,6 +2636,8 @@ scalar } ) ; +expr += crate : : @@ -2503,164 +2649,146 @@ Compose ty components } +; } / / -Array +Matrix constructor -- -infer -type ( +by +columns +) +partial +( +Components +: +: +Many +{ +mut components +spans +} Constructor : : -PartialArray +PartialMatrix +{ +columns +rows +} ) = > { let -components +consensus_scalar = +automatic_conversion_consensus +( +& components +ctx +) . -into_components_vec +map_err +( +| +index +| +{ +Error +: +: +InvalidConstructorComponentType ( +spans +[ +index +] +index +as +i32 +) +} ) +? ; -let -base -= ctx . -register_type +convert_slice_to_common_scalar ( +& +mut components -[ -0 -] +consensus_scalar ) ? ; let -inner +ty = +ctx +. +ensure_type_exists +( crate : : TypeInner : : -Array +Matrix { -base -size +columns +rows +scalar : +consensus_scalar +} +) +; +expr += crate : : -ArraySize +Expression : : -Constant +Compose +{ +ty +components +} +; +} +/ +/ +Matrix +constructor ( -NonZeroU32 -: -: -new +by +columns +) +type +given ( -u32 +Components : : -try_from -( +Many +{ +mut components . -len -( -) -) . -unwrap -( -) -) -. -unwrap -( -) -) -stride -: -{ -self -. -layouter -. -update -( -ctx -. -module -. -to_ctx -( -) -) -. -unwrap -( -) -; -self -. -layouter -[ -base -] -. -to_stride -( -) -} -} -; -let -ty -= -ctx -. -ensure_type_exists -( -inner -) -; -crate -: -: -Expression -: -: -Compose -{ -ty -components -} -} -/ -/ -Array -or -Struct -constructor -( -components -Constructor -: -: -Type +} +Constructor +: +: +Type ( ( ty @@ -2671,23 +2799,13 @@ crate TypeInner : : -Array +Matrix { -. -. -} -| -& -crate -: -: -TypeInner -: +columns : -Struct -{ -. -. +_ +rows +scalar } ) ) @@ -2696,199 +2814,495 @@ Struct > { let -components +component_ty = -components -. -into_components_vec -( -) -; crate : : -Expression +TypeInner : : -Compose +Vector { -ty -components -} -} -/ -/ -ERRORS -/ -/ -Bad -conversion -( -type -cast -) -( -Components -: +size : -One -{ -span -ty_inner -. -. +rows +scalar } -constructor -) -= -> -{ -let -from_type -= -ty_inner +; +ctx . -to_wgsl +try_automatic_conversions_slice ( & -ctx -. -module -. -to_ctx +mut +components +& +Tr +: +: +Value ( +component_ty ) +ty_span ) +? ; -return -Err -( -Error +expr += +crate : : -BadTypeCast -{ -span -from_type -to_type +Expression : -constructor -. -to_error_string -( -ctx -) +: +Compose +{ +ty +components } -) ; } / / -Too -many -parameters -for -scalar +Array constructor +- +infer +type ( -Components -: -: -Many -{ -spans -. -. -} +components Constructor : : -Type -( -( -_ -& -crate -: -: -TypeInner -: -: -Scalar -{ -. -. -} -) -) +PartialArray ) = > { let -span +mut +components = -spans -[ -1 -] -. -until -( -spans -. -last -( -) +components . -unwrap +into_components_vec ( ) -) ; -return -Err -( -Error -: -: -UnexpectedComponents +if +let +Ok ( -span +consensus_scalar ) += +automatic_conversion_consensus +( +& +components +ctx ) -; -} +{ +/ +/ +Note +that +this +will +* +not +* +necessarily +convert +all +the +/ +/ +components +to +the +same +type +! +The +automatic_conversion_consensus +/ +/ +function +only +considers +the +parameters +' +leaf +scalar +/ +/ +types +; +the +parameters +themselves +could +be +any +mix +of +/ +/ +vectors +matrices +and +scalars +. +/ +/ +/ +/ +But +* +if +* +it +is +possible +for +this +array +construction +/ +/ +expression +to +be +well +- +typed +at +all +then +all +the +/ +/ +parameters +must +have +the +same +type +constructors +( +vec / / -Parameters -are -of -the -wrong -type -for -vector -or matrix +scalar +) +applied +to +their +leaf +scalars +so +/ +/ +reconciling +their +scalars +is +always +the +right +thing +to +/ +/ +do +. +And +if +this +array +construction +is +not +well +- +typed +/ +/ +these +conversions +will +not +make +it +so +and +we +can +let +/ +/ +validation +catch +the +error +. +ctx +. +convert_slice_to_common_scalar +( +& +mut +components +consensus_scalar +) +? +; +} +else +{ +/ +/ +There +' +s +no +consensus +scalar +. +Emit +the +Compose +/ +/ +expression +anyway +and +let +validation +catch +the +problem +. +} +let +base += +ctx +. +register_type +( +components +[ +0 +] +) +? +; +let +inner += +crate +: +: +TypeInner +: +: +Array +{ +base +size +: +crate +: +: +ArraySize +: +: +Constant +( +NonZeroU32 +: +: +new +( +u32 +: +: +try_from +( +components +. +len +( +) +) +. +unwrap +( +) +) +. +unwrap +( +) +) +stride +: +{ +self +. +layouter +. +update +( +ctx +. +module +. +to_ctx +( +) +) +. +unwrap +( +) +; +self +. +layouter +[ +base +] +. +to_stride +( +) +} +} +; +let +ty += +ctx +. +ensure_type_exists +( +inner +) +; +expr += +crate +: +: +Expression +: +: +Compose +{ +ty +components +} +; +} +/ +/ +Array constructor +explicit +type ( -Components +components +Constructor +: +: +Type +( +( +ty +& +crate +: +: +TypeInner +: +: +Array +{ +base +. +. +} +) +) +) += +> +{ +let +mut +components += +components +. +into_components_vec +( +) +; +ctx +. +try_automatic_conversions_slice +( +& +mut +components +& +Tr +: +: +Handle +( +base +) +ty_span +) +? +; +expr += +crate : : -Many +Expression +: +: +Compose { -spans -. -. +ty +components +} +; } +/ +/ +Struct +constructor +( +components Constructor : : Type ( ( -_ +ty & crate : @@ -2896,61 +3310,301 @@ crate TypeInner : : -Vector +Struct { +ref +members . . } +) +) +) += +> +{ +let +mut +components += +components +. +into_components_vec +( +) +; +let +struct_ty_span += +ctx +. +module +. +types +. +get_span +( +ty +) +; +/ +/ +Make +a +vector +of +the +members +' +type +handles +in +advance +to +/ +/ +avoid +borrowing +members +from +ctx +while +we +generate +/ +/ +new +code +. +let +members +: +Vec +< +Handle +< +crate +: +: +Type +> +> += +members +. +iter +( +) +. +map +( +| +m | +m +. +ty +) +. +collect +( +) +; +for +( +component +& +ty +) +in +components +. +iter_mut +( +) +. +zip +( +& +members +) +{ +* +component += +ctx +. +try_automatic_conversions +( +* +component & +Tr +: +: +Handle +( +ty +) +struct_ty_span +) +? +; +} +expr += crate : : -TypeInner +Expression : : -Matrix +Compose +{ +ty +components +} +; +} +/ +/ +ERRORS +/ +/ +Bad +conversion +( +type +cast +) +( +Components +: +: +One { +span +ty_inner . . } +constructor ) += +> +{ +let +from_type += +ty_inner +. +to_wgsl +( +& +ctx +. +module +. +to_ctx +( ) -| -Constructor +) +; +return +Err +( +Error : : -PartialVector +BadTypeCast +{ +span +from_type +to_type +: +constructor +. +to_error_string +( +ctx +) +} +) +; +} +/ +/ +Too +many +parameters +for +scalar +constructor +( +Components +: +: +Many { +spans . . } -| Constructor : : -PartialMatrix +Type +( +( +_ +& +crate +: +: +TypeInner +: +: +Scalar +{ +. +. +} +) +) +) += +> { +let +span += +spans +[ +1 +] . +until +( +spans . -} +last +( ) -= -> -{ +. +unwrap +( +) +) +; return Err ( Error : : -InvalidConstructorComponentType +UnexpectedComponents ( -spans -[ -0 -] -0 +span ) ) ; @@ -2979,7 +3633,6 @@ ty_span ) ) } -; let expr = @@ -3195,66 +3848,263 @@ ConstructorType : Scalar ( -scalar -) -= -> -{ -let -ty -= +scalar +) += +> +{ +let +ty += +ctx +. +ensure_type_exists +( +scalar +. +to_inner_scalar +( +) +) +; +Constructor +: +: +Type +( +ty +) +} +ast +: +: +ConstructorType +: +: +PartialVector +{ +size +} += +> +Constructor +: +: +PartialVector +{ +size +} +ast +: +: +ConstructorType +: +: +Vector +{ +size +scalar +} += +> +{ +let +ty += +ctx +. +ensure_type_exists +( +scalar +. +to_inner_vector +( +size +) +) +; +Constructor +: +: +Type +( +ty +) +} +ast +: +: +ConstructorType +: +: +PartialMatrix +{ +columns +rows +} += +> +{ +Constructor +: +: +PartialMatrix +{ +columns +rows +} +} +ast +: +: +ConstructorType +: +: +Matrix +{ +rows +columns +width +} += +> +{ +let +ty += +ctx +. +ensure_type_exists +( +crate +: +: +TypeInner +: +: +Matrix +{ +columns +rows +scalar +: +crate +: +: +Scalar +: +: +float +( +width +) +} +) +; +Constructor +: +: +Type +( +ty +) +} +ast +: +: +ConstructorType +: +: +PartialArray += +> +Constructor +: +: +PartialArray +ast +: +: +ConstructorType +: +: +Array +{ +base +size +} += +> +{ +let +base += +self +. +resolve_ast_type +( +base +& +mut +ctx +. +as_global +( +) +) +? +; +let +size += +self +. +array_size +( +size +& +mut +ctx +. +as_global +( +) +) +? +; +self +. +layouter +. +update +( ctx . -ensure_type_exists -( -scalar +module . -to_inner_scalar +to_ctx ( ) ) -; -Constructor -: -: -Type +. +unwrap ( -ty ) -} -ast -: -: -ConstructorType -: -: -PartialVector -{ -size -} -= -> -Constructor -: -: -PartialVector -{ -size -} -ast -: -: -ConstructorType -: -: -Vector -{ -size -scalar -} +; +let +stride = -> -{ +self +. +layouter +[ +base +] +. +to_stride +( +) +; let ty = @@ -3262,12 +4112,18 @@ ctx . ensure_type_exists ( -scalar -. -to_inner_vector -( +crate +: +: +TypeInner +: +: +Array +{ +base size -) +stride +} ) ; Constructor @@ -3284,147 +4140,305 @@ ast ConstructorType : : -PartialMatrix -{ -columns -rows -} +Type +( +ty +) = > -{ Constructor : : -PartialMatrix -{ -columns -rows +Type +( +ty +) } +; +Ok +( +handle +) } -ast -: -: -ConstructorType -: -: -Matrix -{ -rows -columns -width } -= -> -{ -let -ty -= -ctx +/ +/ +/ +Find +the +consensus +scalar +of +components +under +WGSL +' +s +automatic +/ +/ +/ +conversions . -ensure_type_exists +/ +/ +/ +/ +/ +/ +If +components +can +all +be +converted +to +any +common +scalar +via +/ +/ +/ +WGSL +' +s +automatic +conversions +return +the +best +such +scalar +. +/ +/ +/ +/ +/ +/ +The +components +slice +must +not +be +empty +. +All +elements +' +types +must +/ +/ +/ +have +been +resolved +. +/ +/ +/ +/ +/ +/ +If +components +are +definitely +not +acceptable +as +arguments +to +such +/ +/ +/ +constructors +return +Err +( +i +) +where +i +is +the +index +in +/ +/ +/ +components +of +some +problematic +argument +. +/ +/ +/ +/ +/ +/ +This +function +doesn +' +t +fully +type +- +check +the +arguments +- +it +only +/ +/ +/ +considers +their +leaf +scalar +types +. +This +means +it +may +return +Ok +/ +/ +/ +even +when +the +Naga +validator +will +reject +the +resulting +/ +/ +/ +construction +expression +later +. +fn +automatic_conversion_consensus ( -crate -: -: -TypeInner -: -: -Matrix -{ -columns -rows -scalar +components : +& +[ +Handle +< crate : : -Scalar -: -: -float -( -width -) -} -) -; -Constructor -: +Expression +> +] +ctx : -Type -( -ty +& +ExpressionContext +< +' +_ +' +_ +' +_ +> ) -} -ast -: -: -ConstructorType -: -: -PartialArray -= +- > -Constructor -: -: -PartialArray -ast -: -: -ConstructorType -: -: -Array -{ -base -size -} -= +Result +< +Scalar +usize > { let -base +types = -self -. -resolve_ast_type -( -base & -mut ctx . -as_global -( -) -) -? +module +. +types ; let -size +mut +inners = -self +components . -array_size +iter ( -size +) +. +map +( +| & -mut +c +| ctx . -as_global +typifier +( +) +[ +c +] +. +inner_with ( +types ) ) -? ; -self +log +: +: +debug +! +( +" +wgsl +automatic_conversion_consensus +: +{ +: +? +} +" +inners . -layouter +clone +( +) . -update +map +( +| +inner +| +inner +. +to_wgsl ( +& ctx . module @@ -3433,78 +4447,128 @@ to_ctx ( ) ) +) . -unwrap +collect +: +: +< +Vec +< +String +> +> ( ) +) ; let -stride +mut +best = -self +inners . -layouter -[ -base -] +next +( +) . -to_stride +unwrap +( +) +. +scalar +( +) +. +ok_or ( +0_usize ) +? ; +for +( +inner +i +) +in +inners +. +zip +( +1 +. +. +) +{ let -ty +scalar = -ctx +inner . -ensure_type_exists +scalar ( -crate -: -: -TypeInner -: -: -Array +) +. +ok_or +( +i +) +? +; +match +best +. +automatic_conversion_combine +( +scalar +) { -base -size -stride -} +Some +( +new_best ) += +> +{ +best += +new_best ; -Constructor -: -: -Type +} +None += +> +return +Err ( -ty +i ) } -ast -: -: -ConstructorType +} +log : : -Type +debug +! ( -ty -) -= -> -Constructor +" +consensus : +{ : -Type +? +} +" +best +. +to_wgsl ( -ty ) -} +) ; Ok ( -handle +best ) } -} diff --git a/third_party/rust/naga/src/front/wgsl/lower/conversion.rs b/third_party/rust/naga/src/front/wgsl/lower/conversion.rs new file mode 100644 index 000000000000..98dc530eb124 --- /dev/null +++ b/third_party/rust/naga/src/front/wgsl/lower/conversion.rs @@ -0,0 +1,2748 @@ +/ +/ +! +WGSL +' +s +automatic +conversions +for +abstract +types +. +use +crate +: +: +{ +Handle +Span +} +; +impl +< +' +source +' +temp +' +out +> +super +: +: +ExpressionContext +< +' +source +' +temp +' +out +> +{ +/ +/ +/ +Try +to +use +WGSL +' +s +automatic +conversions +to +convert +expr +to +goal_ty +. +/ +/ +/ +/ +/ +/ +If +no +conversions +are +necessary +return +expr +unchanged +. +/ +/ +/ +/ +/ +/ +If +automatic +conversions +cannot +convert +expr +to +goal_ty +return +an +/ +/ +/ +[ +AutoConversion +] +error +. +/ +/ +/ +/ +/ +/ +Although +the +Load +Rule +is +one +of +the +automatic +conversions +this +/ +/ +/ +function +assumes +it +has +already +been +applied +if +appropriate +as +/ +/ +/ +indicated +by +the +fact +that +the +Rust +type +of +expr +is +not +Typed +< +_ +> +. +/ +/ +/ +/ +/ +/ +[ +AutoConversion +] +: +super +: +: +Error +: +: +AutoConversion +pub +fn +try_automatic_conversions +( +& +mut +self +expr +: +Handle +< +crate +: +: +Expression +> +goal_ty +: +& +crate +: +: +proc +: +: +TypeResolution +goal_span +: +Span +) +- +> +Result +< +Handle +< +crate +: +: +Expression +> +super +: +: +Error +< +' +source +> +> +{ +let +expr_span += +self +. +get_expression_span +( +expr +) +; +/ +/ +Keep +the +TypeResolution +so +we +can +get +type +names +for +/ +/ +structs +in +error +messages +. +let +expr_resolution += +super +: +: +resolve +! +( +self +expr +) +; +let +types += +& +self +. +module +. +types +; +let +expr_inner += +expr_resolution +. +inner_with +( +types +) +; +let +goal_inner += +goal_ty +. +inner_with +( +types +) +; +/ +/ +If +expr +already +has +the +requested +type +we +' +re +done +. +if +expr_inner +. +equivalent +( +goal_inner +types +) +{ +return +Ok +( +expr +) +; +} +let +( +_expr_scalar +goal_scalar +) += +match +expr_inner +. +automatically_converts_to +( +goal_inner +types +) +{ +Some +( +scalars +) += +> +scalars +None += +> +{ +let +gctx += +& +self +. +module +. +to_ctx +( +) +; +let +source_type += +expr_resolution +. +to_wgsl +( +gctx +) +; +let +dest_type += +goal_ty +. +to_wgsl +( +gctx +) +; +return +Err +( +super +: +: +Error +: +: +AutoConversion +{ +dest_span +: +goal_span +dest_type +source_span +: +expr_span +source_type +} +) +; +} +} +; +let +converted += +if +let +crate +: +: +TypeInner +: +: +Array +{ +. +. +} += +* +goal_inner +{ +let +span += +self +. +get_expression_span +( +expr +) +; +self +. +as_const_evaluator +( +) +. +cast_array +( +expr +goal_scalar +span +) +. +map_err +( +| +err +| +super +: +: +Error +: +: +ConstantEvaluatorError +( +err +span +) +) +? +} +else +{ +let +cast += +crate +: +: +Expression +: +: +As +{ +expr +kind +: +goal_scalar +. +kind +convert +: +Some +( +goal_scalar +. +width +) +} +; +self +. +append_expression +( +cast +expr_span +) +? +} +; +Ok +( +converted +) +} +/ +/ +/ +Try +to +convert +exprs +to +goal_ty +using +WGSL +' +s +automatic +conversions +. +pub +fn +try_automatic_conversions_slice +( +& +mut +self +exprs +: +& +mut +[ +Handle +< +crate +: +: +Expression +> +] +goal_ty +: +& +crate +: +: +proc +: +: +TypeResolution +goal_span +: +Span +) +- +> +Result +< +( +) +super +: +: +Error +< +' +source +> +> +{ +for +expr +in +exprs +. +iter_mut +( +) +{ +* +expr += +self +. +try_automatic_conversions +( +* +expr +goal_ty +goal_span +) +? +; +} +Ok +( +( +) +) +} +/ +/ +/ +Apply +WGSL +' +s +automatic +conversions +to +a +vector +constructor +' +s +arguments +. +/ +/ +/ +/ +/ +/ +When +calling +a +vector +constructor +like +vec3 +< +f32 +> +( +. +. +. +) +the +parameters +/ +/ +/ +can +be +a +mix +of +scalars +and +vectors +with +the +latter +being +spread +out +to +/ +/ +/ +contribute +each +of +their +components +as +a +component +of +the +new +value +. +/ +/ +/ +When +the +element +type +is +explicit +as +with +< +f32 +> +in +the +example +above +/ +/ +/ +WGSL +' +s +automatic +conversions +should +convert +abstract +scalar +and +vector +/ +/ +/ +parameters +to +the +constructor +' +s +required +scalar +type +. +pub +fn +try_automatic_conversions_for_vector +( +& +mut +self +exprs +: +& +mut +[ +Handle +< +crate +: +: +Expression +> +] +goal_scalar +: +crate +: +: +Scalar +goal_span +: +Span +) +- +> +Result +< +( +) +super +: +: +Error +< +' +source +> +> +{ +use +crate +: +: +proc +: +: +TypeResolution +as +Tr +; +use +crate +: +: +TypeInner +as +Ti +; +let +goal_scalar_res += +Tr +: +: +Value +( +Ti +: +: +Scalar +( +goal_scalar +) +) +; +for +( +i +expr +) +in +exprs +. +iter_mut +( +) +. +enumerate +( +) +{ +/ +/ +Keep +the +TypeResolution +so +we +can +get +full +type +names +/ +/ +in +error +messages +. +let +expr_resolution += +super +: +: +resolve +! +( +self +* +expr +) +; +let +types += +& +self +. +module +. +types +; +let +expr_inner += +expr_resolution +. +inner_with +( +types +) +; +match +* +expr_inner +{ +Ti +: +: +Scalar +( +_ +) += +> +{ +* +expr += +self +. +try_automatic_conversions +( +* +expr +& +goal_scalar_res +goal_span +) +? +; +} +Ti +: +: +Vector +{ +size +scalar +: +_ +} += +> +{ +let +goal_vector_res += +Tr +: +: +Value +( +Ti +: +: +Vector +{ +size +scalar +: +goal_scalar +} +) +; +* +expr += +self +. +try_automatic_conversions +( +* +expr +& +goal_vector_res +goal_span +) +? +; +} +_ += +> +{ +let +span += +self +. +get_expression_span +( +* +expr +) +; +return +Err +( +super +: +: +Error +: +: +InvalidConstructorComponentType +( +span +i +as +i32 +) +) +; +} +} +} +Ok +( +( +) +) +} +/ +/ +/ +Convert +all +expressions +in +exprs +to +a +common +scalar +type +. +/ +/ +/ +/ +/ +/ +Note +that +the +caller +is +responsible +for +making +sure +these +/ +/ +/ +conversions +are +actually +justified +. +This +function +simply +/ +/ +/ +generates +As +expressions +regardless +of +whether +they +are +/ +/ +/ +permitted +WGSL +automatic +conversions +. +Callers +intending +to +/ +/ +/ +implement +automatic +conversions +need +to +determine +for +/ +/ +/ +themselves +whether +the +casts +we +we +generate +are +justified +/ +/ +/ +perhaps +by +calling +TypeInner +: +: +automatically_converts_to +or +/ +/ +/ +Scalar +: +: +automatic_conversion_combine +. +pub +fn +convert_slice_to_common_scalar +( +& +mut +self +exprs +: +& +mut +[ +Handle +< +crate +: +: +Expression +> +] +goal +: +crate +: +: +Scalar +) +- +> +Result +< +( +) +super +: +: +Error +< +' +source +> +> +{ +for +expr +in +exprs +. +iter_mut +( +) +{ +let +inner += +super +: +: +resolve_inner +! +( +self +* +expr +) +; +/ +/ +Do +nothing +if +inner +doesn +' +t +even +have +leaf +scalars +; +/ +/ +it +' +s +a +type +error +that +validation +will +catch +. +if +inner +. +scalar +( +) +! += +Some +( +goal +) +{ +let +cast += +crate +: +: +Expression +: +: +As +{ +expr +: +* +expr +kind +: +goal +. +kind +convert +: +Some +( +goal +. +width +) +} +; +let +expr_span += +self +. +get_expression_span +( +* +expr +) +; +* +expr += +self +. +append_expression +( +cast +expr_span +) +? +; +} +} +Ok +( +( +) +) +} +/ +/ +/ +Return +an +expression +for +the +concretized +value +of +expr +. +/ +/ +/ +/ +/ +/ +If +expr +is +already +concrete +return +it +unchanged +. +pub +fn +concretize +( +& +mut +self +mut +expr +: +Handle +< +crate +: +: +Expression +> +) +- +> +Result +< +Handle +< +crate +: +: +Expression +> +super +: +: +Error +< +' +source +> +> +{ +let +inner += +super +: +: +resolve_inner +! +( +self +expr +) +; +if +let +Some +( +scalar +) += +inner +. +automatically_convertible_scalar +( +& +self +. +module +. +types +) +{ +let +concretized += +scalar +. +concretize +( +) +; +if +concretized +! += +scalar +{ +let +span += +self +. +get_expression_span +( +expr +) +; +expr += +self +. +as_const_evaluator +( +) +. +cast_array +( +expr +concretized +span +) +. +map_err +( +| +err +| +super +: +: +Error +: +: +ConstantEvaluatorError +( +err +span +) +) +? +; +} +} +Ok +( +expr +) +} +} +impl +crate +: +: +TypeInner +{ +/ +/ +/ +Determine +whether +self +automatically +converts +to +goal +. +/ +/ +/ +/ +/ +/ +If +WGSL +' +s +automatic +conversions +( +excluding +the +Load +Rule +) +will +/ +/ +/ +convert +self +to +goal +then +return +a +pair +( +from +to +) +/ +/ +/ +where +from +and +to +are +the +scalar +types +of +the +leaf +values +/ +/ +/ +of +self +and +goal +. +/ +/ +/ +/ +/ +/ +This +function +assumes +that +self +and +goal +are +different +/ +/ +/ +types +. +Callers +should +first +check +whether +any +conversion +is +/ +/ +/ +needed +at +all +. +/ +/ +/ +/ +/ +/ +If +the +automatic +conversions +cannot +convert +self +to +goal +/ +/ +/ +return +None +. +fn +automatically_converts_to +( +& +self +goal +: +& +Self +types +: +& +crate +: +: +UniqueArena +< +crate +: +: +Type +> +) +- +> +Option +< +( +crate +: +: +Scalar +crate +: +: +Scalar +) +> +{ +use +crate +: +: +ScalarKind +as +Sk +; +use +crate +: +: +TypeInner +as +Ti +; +/ +/ +Automatic +conversions +only +change +the +scalar +type +of +a +value +' +s +leaves +/ +/ +( +e +. +g +. +vec4 +< +AbstractFloat +> +to +vec4 +< +f32 +> +) +never +the +type +/ +/ +constructors +applied +to +those +scalar +types +( +e +. +g +. +never +scalar +to +/ +/ +vec4 +or +vec2 +to +vec3 +) +. +So +first +we +check +that +the +type +/ +/ +constructors +match +extracting +the +leaf +scalar +types +in +the +process +. +let +expr_scalar +; +let +goal_scalar +; +match +( +self +goal +) +{ +( +& +Ti +: +: +Scalar +( +expr +) +& +Ti +: +: +Scalar +( +goal +) +) += +> +{ +expr_scalar += +expr +; +goal_scalar += +goal +; +} +( +& +Ti +: +: +Vector +{ +size +: +expr_size +scalar +: +expr +} +& +Ti +: +: +Vector +{ +size +: +goal_size +scalar +: +goal +} +) +if +expr_size += += +goal_size += +> +{ +expr_scalar += +expr +; +goal_scalar += +goal +; +} +( +& +Ti +: +: +Matrix +{ +rows +: +expr_rows +columns +: +expr_columns +scalar +: +expr +} +& +Ti +: +: +Matrix +{ +rows +: +goal_rows +columns +: +goal_columns +scalar +: +goal +} +) +if +expr_rows += += +goal_rows +& +& +expr_columns += += +goal_columns += +> +{ +expr_scalar += +expr +; +goal_scalar += +goal +; +} +( +& +Ti +: +: +Array +{ +base +: +expr_base +size +: +expr_size +stride +: +_ +} +& +Ti +: +: +Array +{ +base +: +goal_base +size +: +goal_size +stride +: +_ +} +) +if +expr_size += += +goal_size += +> +{ +return +types +[ +expr_base +] +. +inner +. +automatically_converts_to +( +& +types +[ +goal_base +] +. +inner +types +) +; +} +_ += +> +return +None +} +match +( +expr_scalar +. +kind +goal_scalar +. +kind +) +{ +( +Sk +: +: +AbstractFloat +Sk +: +: +Float +) += +> +{ +} +( +Sk +: +: +AbstractInt +Sk +: +: +Sint +| +Sk +: +: +Uint +| +Sk +: +: +AbstractFloat +| +Sk +: +: +Float +) += +> +{ +} +_ += +> +return +None +} +log +: +: +trace +! +( +" +okay +: +expr +{ +expr_scalar +: +? +} +goal +{ +goal_scalar +: +? +} +" +) +; +Some +( +( +expr_scalar +goal_scalar +) +) +} +fn +automatically_convertible_scalar +( +& +self +types +: +& +crate +: +: +UniqueArena +< +crate +: +: +Type +> +) +- +> +Option +< +crate +: +: +Scalar +> +{ +use +crate +: +: +TypeInner +as +Ti +; +match +* +self +{ +Ti +: +: +Scalar +( +scalar +) +| +Ti +: +: +Vector +{ +scalar +. +. +} +| +Ti +: +: +Matrix +{ +scalar +. +. +} += +> +{ +Some +( +scalar +) +} +Ti +: +: +Array +{ +base +. +. +} += +> +types +[ +base +] +. +inner +. +automatically_convertible_scalar +( +types +) +Ti +: +: +Atomic +( +_ +) +| +Ti +: +: +Pointer +{ +. +. +} +| +Ti +: +: +ValuePointer +{ +. +. +} +| +Ti +: +: +Struct +{ +. +. +} +| +Ti +: +: +Image +{ +. +. +} +| +Ti +: +: +Sampler +{ +. +. +} +| +Ti +: +: +AccelerationStructure +| +Ti +: +: +RayQuery +| +Ti +: +: +BindingArray +{ +. +. +} += +> +None +} +} +} +impl +crate +: +: +Scalar +{ +/ +/ +/ +Find +the +common +type +of +self +and +other +under +WGSL +' +s +/ +/ +/ +automatic +conversions +. +/ +/ +/ +/ +/ +/ +If +there +are +any +scalars +to +which +WGSL +' +s +automatic +conversions +/ +/ +/ +will +convert +both +self +and +other +return +the +best +such +/ +/ +/ +scalar +. +Otherwise +return +None +. +pub +const +fn +automatic_conversion_combine +( +self +other +: +Self +) +- +> +Option +< +crate +: +: +Scalar +> +{ +use +crate +: +: +ScalarKind +as +Sk +; +match +( +self +. +kind +other +. +kind +) +{ +/ +/ +When +the +kinds +match +. +. +. +( +Sk +: +: +AbstractFloat +Sk +: +: +AbstractFloat +) +| +( +Sk +: +: +AbstractInt +Sk +: +: +AbstractInt +) +| +( +Sk +: +: +Sint +Sk +: +: +Sint +) +| +( +Sk +: +: +Uint +Sk +: +: +Uint +) +| +( +Sk +: +: +Float +Sk +: +: +Float +) +| +( +Sk +: +: +Bool +Sk +: +: +Bool +) += +> +{ +if +self +. +width += += +other +. +width +{ +/ +/ +. +. +. +either +no +conversion +is +necessary +. +. +. +Some +( +self +) +} +else +{ +/ +/ +. +. +. +or +no +conversion +is +possible +. +/ +/ +We +never +convert +concrete +to +concrete +and +/ +/ +abstract +types +should +have +only +one +size +. +None +} +} +/ +/ +AbstractInt +converts +to +AbstractFloat +. +( +Sk +: +: +AbstractFloat +Sk +: +: +AbstractInt +) += +> +Some +( +self +) +( +Sk +: +: +AbstractInt +Sk +: +: +AbstractFloat +) += +> +Some +( +other +) +/ +/ +AbstractFloat +converts +to +Float +. +( +Sk +: +: +AbstractFloat +Sk +: +: +Float +) += +> +Some +( +other +) +( +Sk +: +: +Float +Sk +: +: +AbstractFloat +) += +> +Some +( +self +) +/ +/ +AbstractInt +converts +to +concrete +integer +or +float +. +( +Sk +: +: +AbstractInt +Sk +: +: +Uint +| +Sk +: +: +Sint +| +Sk +: +: +Float +) += +> +Some +( +other +) +( +Sk +: +: +Uint +| +Sk +: +: +Sint +| +Sk +: +: +Float +Sk +: +: +AbstractInt +) += +> +Some +( +self +) +/ +/ +AbstractFloat +can +' +t +be +reconciled +with +concrete +integer +types +. +( +Sk +: +: +AbstractFloat +Sk +: +: +Uint +| +Sk +: +: +Sint +) +| +( +Sk +: +: +Uint +| +Sk +: +: +Sint +Sk +: +: +AbstractFloat +) += +> +{ +None +} +/ +/ +Nothing +can +be +reconciled +with +bool +. +( +Sk +: +: +Bool +_ +) +| +( +_ +Sk +: +: +Bool +) += +> +None +/ +/ +Different +concrete +types +cannot +be +reconciled +. +( +Sk +: +: +Sint +| +Sk +: +: +Uint +| +Sk +: +: +Float +Sk +: +: +Sint +| +Sk +: +: +Uint +| +Sk +: +: +Float +) += +> +None +} +} +const +fn +concretize +( +self +) +- +> +Self +{ +use +crate +: +: +ScalarKind +as +Sk +; +match +self +. +kind +{ +Sk +: +: +Sint +| +Sk +: +: +Uint +| +Sk +: +: +Float +| +Sk +: +: +Bool += +> +self +Sk +: +: +AbstractInt += +> +Self +: +: +I32 +Sk +: +: +AbstractFloat += +> +Self +: +: +F32 +} +} +} diff --git a/third_party/rust/naga/src/front/wgsl/lower/mod.rs b/third_party/rust/naga/src/front/wgsl/lower/mod.rs index bb867027e133..e3009aa0ed66 100644 --- a/third_party/rust/naga/src/front/wgsl/lower/mod.rs +++ b/third_party/rust/naga/src/front/wgsl/lower/mod.rs @@ -117,6 +117,9 @@ Span mod construction ; +mod +conversion +; / / / @@ -610,6 +613,13 @@ expr } ; } +pub +( +super +) +use +resolve +; / / / @@ -843,6 +853,12 @@ ensure_type_exists & mut self +name +: +Option +< +String +> inner : crate @@ -875,8 +891,6 @@ Type { inner name -: -None } Span : @@ -5047,6 +5061,7 @@ as_global . ensure_type_exists ( +None inner ) } @@ -6932,11 +6947,12 @@ as_const ) ; let +mut init = self . -expression +expression_for_abstract ( c . @@ -6948,73 +6964,94 @@ ectx ? ; let -inferred_type -= -ectx -. -register_type -( -init -) -? +ty ; +if let +Some +( explicit_ty +) = c . ty -. -map -( -| -ty -| +{ +let +explicit_ty += self . resolve_ast_type ( -ty +explicit_ty & mut -ctx -) -) +ectx . -transpose +as_global ( ) +) ? ; -if let -Some -( -explicit -) +explicit_ty_res = +crate +: +: +proc +: +: +TypeResolution +: +: +Handle +( explicit_ty -{ -if -explicit -! -= -inferred_type -{ -let -gctx +) +; +init = -ctx -. -module +ectx . -to_ctx +try_automatic_conversions ( +init +& +explicit_ty_res +c +. +name +. +span ) -; -return -Err +. +map_err ( +| +error +| +match +error +{ +Error +: +: +AutoConversion +{ +dest_span +: +_ +dest_type +source_span +: +_ +source_type +} += +> Error : : @@ -7029,27 +7066,47 @@ name span expected : -explicit -. -to_wgsl -( -& -gctx -) +dest_type got : -inferred_type +source_type +} +other += +> +other +} +) +? +; +ty += +explicit_ty +; +} +else +{ +init += +ectx . -to_wgsl +concretize ( -& -gctx +init ) -} +? +; +ty += +ectx +. +register_type +( +init ) +? ; } -} let handle = @@ -7092,8 +7149,6 @@ Override : None ty -: -inferred_type init } span @@ -7191,11 +7246,23 @@ ty = self . -resolve_ast_type +resolve_named_ast_type ( alias . ty +Some +( +alias +. +name +. +name +. +to_string +( +) +) & mut ctx @@ -7225,6 +7292,52 @@ ty } } } +/ +/ +Constant +evaluation +may +leave +abstract +- +typed +literals +and +/ +/ +compositions +in +expression +arenas +so +we +need +to +compact +the +module +/ +/ +to +remove +unused +expressions +and +types +. +crate +: +: +compact +: +: +compact +( +& +mut +module +) +; Ok ( module @@ -10705,6 +10818,65 @@ Rule if possible . +/ +/ +/ +/ +/ +/ +For +the +time +being +this +concretizes +abstract +values +to +support +/ +/ +/ +consumers +that +haven +' +t +been +adapted +to +consume +them +yet +. +Consumers +/ +/ +/ +prepared +for +abstract +values +can +call +[ +expression_for_abstract +] +. +/ +/ +/ +/ +/ +/ +[ +expression_for_abstract +] +: +Lowerer +: +: +expression_for_abstract fn expression ( @@ -10761,7 +10933,7 @@ expr = self . -expression_for_reference +expression_for_abstract ( expr ctx @@ -10770,13 +10942,13 @@ ctx ; ctx . -apply_load_rule +concretize ( expr ) } fn -expression_for_reference +expression_for_abstract ( & mut @@ -10812,7 +10984,77 @@ _ > Result < -Typed +Handle +< +crate +: +: +Expression +> +Error +< +' +source +> +> +{ +let +expr += +self +. +expression_for_reference +( +expr +ctx +) +? +; +ctx +. +apply_load_rule +( +expr +) +} +fn +expression_for_reference +( +& +mut +self +expr +: +Handle +< +ast +: +: +Expression +< +' +source +> +> +ctx +: +& +mut +ExpressionContext +< +' +source +' +_ +' +_ +> +) +- +> +Result +< +Typed < Handle < @@ -10978,25 +11220,83 @@ Literal : Number ( -_ +Number +: +: +F64 +( +f +) +) += +> +crate +: +: +Literal +: +: +F64 +( +f +) +ast +: +: +Literal +: +: +Number +( +Number +: +: +AbstractInt +( +i +) +) += +> +crate +: +: +Literal +: +: +AbstractInt +( +i +) +ast +: +: +Literal +: +: +Number +( +Number +: +: +AbstractFloat +( +f +) ) = > { -unreachable -! +crate +: +: +Literal +: +: +AbstractFloat ( -" -got -abstract -numeric -type -when -not -expected -" +f ) -; } ast : @@ -18165,6 +18465,22 @@ Dynamic / / / +Build +the +Naga +equivalent +of +a +named +AST +type +. +/ +/ +/ +/ +/ +/ Return a Naga @@ -18178,10 +18494,59 @@ front - end type +/ +/ +/ handle +which +should +be +named +name +if +given . +/ +/ +/ +/ +/ +/ +If +handle +refers +to +a +type +cached +in +[ +SpecialTypes +] +/ +/ +/ +name +may +be +ignored +. +/ +/ +/ +/ +/ +/ +[ +SpecialTypes +] +: +crate +: +: +SpecialTypes fn -resolve_ast_type +resolve_named_ast_type ( & mut @@ -18199,6 +18564,12 @@ Type source > > +name +: +Option +< +String +> ctx : & @@ -18721,10 +19092,89 @@ ctx . ensure_type_exists ( +name inner ) ) } +/ +/ +/ +Return +a +Naga +Handle +< +Type +> +representing +the +front +- +end +type +handle +. +fn +resolve_ast_type +( +& +mut +self +handle +: +Handle +< +ast +: +: +Type +< +' +source +> +> +ctx +: +& +mut +GlobalContext +< +' +source +' +_ +' +_ +> +) +- +> +Result +< +Handle +< +crate +: +: +Type +> +Error +< +' +source +> +> +{ +self +. +resolve_named_ast_type +( +handle +None +ctx +) +} fn binding ( diff --git a/third_party/rust/naga/src/front/wgsl/parse/lexer.rs b/third_party/rust/naga/src/front/wgsl/parse/lexer.rs index 3cd54a895ad7..a4c1929fe97d 100644 --- a/third_party/rust/naga/src/front/wgsl/parse/lexer.rs +++ b/third_party/rust/naga/src/front/wgsl/parse/lexer.rs @@ -3875,6 +3875,10 @@ cfg test ) ] +# +[ +track_caller +] fn sub_test ( @@ -3982,7 +3986,7 @@ Ok Number : : -I32 +AbstractInt ( 291 ) @@ -4030,7 +4034,7 @@ Ok Number : : -I32 +AbstractInt ( 123 ) @@ -4046,7 +4050,7 @@ Ok Number : : -I32 +AbstractInt ( 0 ) @@ -4078,7 +4082,7 @@ Ok Number : : -I32 +AbstractInt ( 63 ) @@ -4167,7 +4171,7 @@ Ok Number : : -F32 +AbstractFloat ( 1 . @@ -4184,7 +4188,7 @@ Ok Number : : -F32 +AbstractFloat ( 0 . @@ -4202,7 +4206,7 @@ Ok Number : : -F32 +AbstractFloat ( 12 . @@ -4250,7 +4254,7 @@ Ok Number : : -F32 +AbstractFloat ( 0 . @@ -4268,7 +4272,7 @@ Ok Number : : -F32 +AbstractFloat ( 43 . @@ -4303,7 +4307,7 @@ Ok Number : : -F32 +AbstractFloat ( 0 . @@ -4334,7 +4338,7 @@ Ok Number : : -F32 +AbstractFloat ( 0 . @@ -5295,6 +5299,151 @@ NotRepresentable test ] fn +double_floats +( +) +{ +sub_test +( +" +0x1 +. +2p4lf +0x1p8lf +0 +. +0625lf +625e +- +4lf +10lf +10l +" +& +[ +Token +: +: +Number +( +Ok +( +Number +: +: +F64 +( +18 +. +0 +) +) +) +Token +: +: +Number +( +Ok +( +Number +: +: +F64 +( +256 +. +0 +) +) +) +Token +: +: +Number +( +Ok +( +Number +: +: +F64 +( +0 +. +0625 +) +) +) +Token +: +: +Number +( +Ok +( +Number +: +: +F64 +( +0 +. +0625 +) +) +) +Token +: +: +Number +( +Ok +( +Number +: +: +F64 +( +10 +. +0 +) +) +) +Token +: +: +Number +( +Ok +( +Number +: +: +AbstractInt +( +10 +) +) +) +Token +: +: +Word +( +" +l +" +) +] +) +} +# +[ +test +] +fn test_tokens ( ) @@ -5335,7 +5484,7 @@ Ok Number : : -I32 +AbstractInt ( 92 ) @@ -5386,7 +5535,7 @@ Ok Number : : -I32 +AbstractInt ( 3 ) @@ -5441,7 +5590,7 @@ Ok Number : : -I32 +AbstractInt ( 44 ) @@ -5692,6 +5841,205 @@ Operation ] ) ; +/ +/ +Type +suffixes +are +only +allowed +on +hex +float +literals +/ +/ +if +you +provided +an +exponent +. +sub_test +( +" +0x1 +. +2f +0x1 +. +2f +0x1 +. +2h +0x1 +. +2H +0x1 +. +2lf +" +& +[ +/ +/ +The +' +f +' +suffixes +are +taken +as +a +hex +digit +: +/ +/ +the +fractional +part +is +0x2f +/ +256 +. +Token +: +: +Number +( +Ok +( +Number +: +: +AbstractFloat +( +1 +. +0 ++ +0x2f +as +f64 +/ +256 +. +0 +) +) +) +Token +: +: +Number +( +Ok +( +Number +: +: +AbstractFloat +( +1 +. +0 ++ +0x2f +as +f64 +/ +256 +. +0 +) +) +) +Token +: +: +Number +( +Ok +( +Number +: +: +AbstractFloat +( +1 +. +125 +) +) +) +Token +: +: +Word +( +" +h +" +) +Token +: +: +Number +( +Ok +( +Number +: +: +AbstractFloat +( +1 +. +125 +) +) +) +Token +: +: +Word +( +" +H +" +) +Token +: +: +Number +( +Ok +( +Number +: +: +AbstractFloat +( +1 +. +125 +) +) +) +Token +: +: +Word +( +" +lf +" +) +] +) } # [ @@ -5755,7 +6103,7 @@ Ok Number : : -I32 +AbstractInt ( 0 ) diff --git a/third_party/rust/naga/src/front/wgsl/parse/number.rs b/third_party/rust/naga/src/front/wgsl/parse/number.rs index f5bfd8559f0f..4d7334240983 100644 --- a/third_party/rust/naga/src/front/wgsl/parse/number.rs +++ b/third_party/rust/naga/src/front/wgsl/parse/number.rs @@ -131,153 +131,16 @@ F32 ( f32 ) -} -impl -Number -{ -/ -/ -/ -Convert -abstract -numbers -to -a -plausible -concrete -counterpart -. -/ -/ -/ / / / -Return -concrete -numbers -unchanged -. -If -the -conversion -would -be -/ -/ -/ -lossy -return -an -error -. -fn -abstract_to_concrete -( -self -) -- -> -Result -< -Number -NumberError -> -{ -match -self -{ -Number -: -: -AbstractInt -( -num -) -= -> -i32 -: -: -try_from -( -num -) -. -map -( -Number -: -: -I32 -) -. -map_err -( -| -_ -| -NumberError -: -: -NotRepresentable -) -Number -: -: -AbstractFloat -( -num -) -= -> -{ -let -num -= -num -as -f32 -; -if -num -. -is_finite -( -) -{ -Ok -( -Number -: -: -F32 -( -num -) -) -} -else -{ -Err -( -NumberError -: -: -NotRepresentable -) -} -} -num -= -> -Ok +Concrete +f64 +F64 ( -num +f64 ) } -} -} / / TODO @@ -345,14 +208,6 @@ Token Number ( result -. -and_then -( -Number -: -: -abstract_to_concrete -) ) rest ) @@ -375,11 +230,19 @@ IntKind I32 U32 } +# +[ +derive +( +Debug +) +] enum FloatKind { -F32 F16 +F32 +F64 } / / @@ -1174,9 +1037,12 @@ bytes ident [ ( +( pattern : pat_param +) +* = > to @@ -1184,6 +1050,9 @@ to expr ) * +( +) +? ] ) = @@ -1195,7 +1064,10 @@ bytes ( & [ +( pattern +) +* ref rest . @@ -1433,6 +1305,62 @@ len } ; } +macro_rules +! +consume_float_suffix +{ +( +bytes +: +ident +) += +> +{ +consume_map +! +( +bytes +[ +b +' +h +' += +> +FloatKind +: +: +F16 +b +' +f +' += +> +FloatKind +: +: +F32 +b +' +l +' +b +' +f +' += +> +FloatKind +: +: +F64 +] +) +} +; +} / / / @@ -1865,32 +1793,10 @@ bytes let kind = -consume_map +consume_float_suffix ! ( bytes -[ -b -' -f -' -= -> -FloatKind -: -: -F32 -b -' -h -' -= -> -FloatKind -: -: -F16 -] ) ; ( @@ -2055,32 +1961,10 @@ bytes let kind = -consume_map +consume_float_suffix ! ( bytes -[ -b -' -f -' -= -> -FloatKind -: -: -F32 -b -' -h -' -= -> -FloatKind -: -: -F16 -] ) ; ( @@ -2298,32 +2182,10 @@ bytes let kind = -consume_map +consume_float_suffix ! ( bytes -[ -b -' -f -' -= -> -FloatKind -: -: -F32 -b -' -h -' -= -> -FloatKind -: -: -F16 -] ) ; ( @@ -2440,32 +2302,10 @@ bytes let kind = -consume_map +consume_float_suffix ! ( bytes -[ -b -' -f -' -= -> -FloatKind -: -: -F32 -b -' -h -' -= -> -FloatKind -: -: -F16 -] ) ; ( @@ -2575,6 +2415,22 @@ U32 ) b ' +h +' += +> +Kind +: +: +Float +( +FloatKind +: +: +F16 +) +b +' f ' = @@ -2591,7 +2447,11 @@ F32 ) b ' -h +l +' +b +' +f ' = > @@ -2603,7 +2463,7 @@ Float FloatKind : : -F16 +F64 ) ] ) @@ -3384,6 +3244,22 @@ Some FloatKind : : +F16 +) += +> +Err +( +NumberError +: +: +UnimplementedF16 +) +Some +( +FloatKind +: +: F32 ) = @@ -3450,8 +3326,57 @@ Some FloatKind : : -F16 +F64 +) += +> +match +hexf_parse +: +: +parse_hexf64 +( +input +false +) +{ +Ok +( +num +) += +> +Ok +( +Number +: +: +F64 +( +num ) +) +/ +/ +can +only +be +ParseHexfErrorKind +: +: +Inexact +but +we +can +' +t +check +since +it +' +s +private +_ = > Err @@ -3459,10 +3384,11 @@ Err NumberError : : -UnimplementedF16 +NotRepresentable ) } } +} / / input @@ -3683,6 +3609,64 @@ Some FloatKind : : +F64 +) += +> +{ +let +num += +input +. +parse +: +: +< +f64 +> +( +) +. +unwrap +( +) +; +/ +/ +will +never +fail +num +. +is_finite +( +) +. +then_some +( +Number +: +: +F64 +( +num +) +) +. +ok_or +( +NumberError +: +: +NotRepresentable +) +} +Some +( +FloatKind +: +: F16 ) = diff --git a/third_party/rust/naga/src/front/wgsl/tests.rs b/third_party/rust/naga/src/front/wgsl/tests.rs index 1ef3a111418c..0d22d27af67b 100644 --- a/third_party/rust/naga/src/front/wgsl/tests.rs +++ b/third_party/rust/naga/src/front/wgsl/tests.rs @@ -615,7 +615,8 @@ vec2 f32 > ( -0 +0i +0i ) ; } @@ -1435,15 +1436,9 @@ vec3 u32 > ( -0 -. -0 -1 -. -0 -2 -. -0 +0u +1u +2u ) 1 ) diff --git a/third_party/rust/naga/src/front/wgsl/to_wgsl.rs b/third_party/rust/naga/src/front/wgsl/to_wgsl.rs index a500a80548a5..9ec84e1f3b05 100644 --- a/third_party/rust/naga/src/front/wgsl/to_wgsl.rs +++ b/third_party/rust/naga/src/front/wgsl/to_wgsl.rs @@ -1205,6 +1205,44 @@ bool to_string ( ) +crate +: +: +ScalarKind +: +: +AbstractInt += +> +return +" +{ +AbstractInt +} +" +. +to_string +( +) +crate +: +: +ScalarKind +: +: +AbstractFloat += +> +return +" +{ +AbstractFloat +} +" +. +to_string +( +) } ; format diff --git a/third_party/rust/naga/src/lib.rs b/third_party/rust/naga/src/lib.rs index 9c5a7d96a00e..c2a24e071883 100644 --- a/third_party/rust/naga/src/lib.rs +++ b/third_party/rust/naga/src/lib.rs @@ -2301,6 +2301,24 @@ Bytes / / / +Width +of +abstract +types +in +bytes +. +pub +const +ABSTRACT_WIDTH +: +Bytes += +8 +; +/ +/ +/ Hash map that @@ -3705,6 +3723,59 @@ Boolean type . Bool +/ +/ +/ +WGSL +abstract +integer +type +. +/ +/ +/ +/ +/ +/ +These +are +forbidden +by +validation +and +should +never +reach +backends +. +AbstractInt +/ +/ +/ +Abstract +floating +- +point +type +. +/ +/ +/ +/ +/ +/ +These +are +forbidden +by +validation +and +should +never +reach +backends +. +AbstractFloat } / / @@ -6845,6 +6916,14 @@ Bool ( bool ) +AbstractInt +( +i64 +) +AbstractFloat +( +f64 +) } # [ diff --git a/third_party/rust/naga/src/proc/constant_evaluator.rs b/third_party/rust/naga/src/proc/constant_evaluator.rs index 522d596c9a40..0205cb462892 100644 --- a/third_party/rust/naga/src/proc/constant_evaluator.rs +++ b/third_party/rust/naga/src/proc/constant_evaluator.rs @@ -1052,10 +1052,25 @@ error Cannot cast type +{ +from +} +to +{ +to +} " ) ] InvalidCastArg +{ +from +: +String +to +: +String +} # [ error @@ -1286,6 +1301,69 @@ String error ( " +the +concrete +type +{ +to_type +} +cannot +represent +the +abstract +value +{ +value +} +accurately +" +) +] +AutomaticConversionLossy +{ +value +: +String +to_type +: +& +' +static +str +} +# +[ +error +( +" +abstract +floating +- +point +values +cannot +be +automatically +converted +to +integers +" +) +] +AutomaticConversionFloatToInt +{ +to_type +: +& +' +static +str +} +# +[ +error +( +" Division by zero @@ -1869,6 +1947,67 @@ block ) } } +pub +fn +to_ctx +( +& +self +) +- +> +crate +: +: +proc +: +: +GlobalCtx +{ +crate +: +: +proc +: +: +GlobalCtx +{ +types +: +self +. +types +constants +: +self +. +constants +const_expressions +: +match +self +. +function_local_data +{ +Some +( +ref +data +) += +> +data +. +const_expressions +None += +> +self +. +expressions +} +} +} fn check ( @@ -6589,6 +6728,155 @@ span ? ; let +make_error += +| +| +- +> +Result +< +_ +ConstantEvaluatorError +> +{ +let +ty += +self +. +resolve_type +( +expr +) +? +; +# +[ +cfg +( +feature += +" +wgsl +- +in +" +) +] +let +from += +ty +. +to_wgsl +( +& +self +. +to_ctx +( +) +) +; +# +[ +cfg +( +feature += +" +wgsl +- +in +" +) +] +let +to += +target +. +to_wgsl +( +) +; +# +[ +cfg +( +not +( +feature += +" +wgsl +- +in +" +) +) +] +let +from += +format +! +( +" +{ +ty +: +? +} +" +) +; +# +[ +cfg +( +not +( +feature += +" +wgsl +- +in +" +) +) +] +let +to += +format +! +( +" +{ +target +: +? +} +" +) +; +Err +( +ConstantEvaluatorError +: +: +InvalidCastArg +{ +from +to +} +) +} +; +let expr = match @@ -6694,14 +6982,45 @@ _ > { return -Err +make_error ( -ConstantEvaluatorError -: -: -InvalidCastArg ) +; } +Literal +: +: +AbstractInt +( +v +) += +> +i32 +: +: +try_from_abstract +( +v +) +? +Literal +: +: +AbstractFloat +( +v +) += +> +i32 +: +: +try_from_abstract +( +v +) +? } ) Sc @@ -6783,14 +7102,45 @@ _ > { return -Err +make_error ( -ConstantEvaluatorError +) +; +} +Literal : : -InvalidCastArg +AbstractInt +( +v ) -} += +> +u32 +: +: +try_from_abstract +( +v +) +? +Literal +: +: +AbstractFloat +( +v +) += +> +u32 +: +: +try_from_abstract +( +v +) +? } ) Sc @@ -6874,26 +7224,57 @@ _ > { return -Err +make_error ( -ConstantEvaluatorError +) +; +} +Literal : : -InvalidCastArg +AbstractInt +( +v ) -} += +> +f32 +: +: +try_from_abstract +( +v +) +? +Literal +: +: +AbstractFloat +( +v +) += +> +f32 +: +: +try_from_abstract +( +v +) +? } ) Sc : : -BOOL +F64 = > Literal : : -Bool +F64 ( match literal @@ -6908,9 +7289,8 @@ v = > v -! -= -0 +as +f64 Literal : : @@ -6921,9 +7301,8 @@ v = > v -! -= -0 +as +f64 Literal : : @@ -6934,15 +7313,12 @@ v = > v -! -= -0 -. -0 +as +f64 Literal : : -Bool +F64 ( v ) @@ -6952,11 +7328,17 @@ v Literal : : -F64 +Bool ( -_ +v ) -| += +> +v +as +u32 +as +f64 Literal : : @@ -6966,122 +7348,360 @@ _ ) = > -{ return -Err +make_error ( -ConstantEvaluatorError +) +Literal : : -InvalidCastArg -) -} -} +AbstractInt +( +v ) -_ = > -return -Err -( -ConstantEvaluatorError +f64 : : -InvalidCastArg +try_from_abstract +( +v ) -} -; -Expression +? +Literal : : -Literal +AbstractFloat ( -literal +v ) -} -Expression -: -: -Compose -{ -ty -components -: -ref -src_components -} = > -{ -let -ty_inner -= -match -self -. -types -[ -ty -] -. -inner -{ -TypeInner +f64 : : -Vector -{ -size -. -. +try_from_abstract +( +v +) +? } +) +Sc +: +: +BOOL = > -TypeInner +Literal : : -Vector +Bool +( +match +literal { -size -scalar -: -target -} -TypeInner +Literal : : -Matrix -{ -columns -rows -. -. -} +I32 +( +v +) = > -TypeInner -: +v +! += +0 +Literal : -Matrix -{ -columns -rows -scalar : -target -} -_ +U32 +( +v +) = > -return -Err -( -ConstantEvaluatorError +v +! += +0 +Literal : : -InvalidCastArg +F32 +( +v ) -} += +> +v +! += +0 +. +0 +Literal +: +: +Bool +( +v +) += +> +v +Literal +: +: +F64 +( +_ +) +| +Literal +: +: +I64 +( +_ +) +| +Literal +: +: +AbstractInt +( +_ +) +| +Literal +: +: +AbstractFloat +( +_ +) += +> +{ +return +make_error +( +) +; +} +} +) +Sc +: +: +ABSTRACT_FLOAT += +> +Literal +: +: +AbstractFloat +( +match +literal +{ +Literal +: +: +AbstractInt +( +v +) += +> +{ +/ +/ +Overflow +is +forbidden +but +inexact +conversions +/ +/ +are +fine +. +The +range +of +f64 +is +far +larger +than +/ +/ +that +of +i64 +so +we +don +' +t +have +to +check +anything +/ +/ +here +. +v +as +f64 +} +Literal +: +: +AbstractFloat +( +v +) += +> +v +_ += +> +return +make_error +( +) +} +) +_ += +> +{ +log +: +: +debug +! +( +" +Constant +evaluator +refused +to +convert +value +to +{ +target +: +? +} +" +) +; +return +make_error +( +) +; +} +} +; +Expression +: +: +Literal +( +literal +) +} +Expression +: +: +Compose +{ +ty +components +: +ref +src_components +} += +> +{ +let +ty_inner += +match +self +. +types +[ +ty +] +. +inner +{ +TypeInner +: +: +Vector +{ +size +. +. +} += +> +TypeInner +: +: +Vector +{ +size +scalar +: +target +} +TypeInner +: +: +Matrix +{ +columns +rows +. +. +} += +> +TypeInner +: +: +Matrix +{ +columns +rows +scalar +: +target +} +_ += +> +return +make_error +( +) +} ; let mut @@ -7196,12 +7816,8 @@ _ = > return -Err +make_error ( -ConstantEvaluatorError -: -: -InvalidCastArg ) } ; @@ -7213,21 +7829,147 @@ expr span ) } -fn -unary_op -( -& -mut -self -op -: -UnaryOperator +/ +/ +/ +Convert +the +scalar +leaves +of +expr +to +target +handling +arrays +. +/ +/ +/ +/ +/ +/ +expr +must +be +a +Compose +expression +whose +type +is +a +scalar +vector +/ +/ +/ +matrix +or +nested +arrays +of +such +. +/ +/ +/ +/ +/ +/ +This +is +basically +the +same +as +the +[ +cast +] +method +except +that +that +/ +/ +/ +should +only +handle +Naga +[ +As +] +expressions +which +cannot +convert +arrays +. +/ +/ +/ +/ +/ +/ +Treat +span +as +the +location +of +the +resulting +expression +. +/ +/ +/ +/ +/ +/ +[ +cast +] +: +ConstantEvaluator +: +: +cast +/ +/ +/ +[ +As +] +: +crate +: +: +Expression +: +: +As +pub +fn +cast_array +( +& +mut +self expr : Handle < Expression > +target +: +crate +: +: +Scalar span : Span @@ -7244,81 +7986,366 @@ ConstantEvaluatorError > { let -expr +Expression +: +: +Compose +{ +ty +ref +components +} = self . -eval_zero_value_and_splat +expressions +[ +expr +] +else +{ +return +self +. +cast ( expr +target span ) -? +; +} ; let -expr +crate +: +: +TypeInner +: +: +Array +{ +base +: +_ +size +stride +: +_ +} = -match self . -expressions +types [ -expr +ty ] +. +inner +else { -Expression -: -: -Literal +return +self +. +cast ( -value +expr +target +span ) +; +} +; +let +mut +components = -> -Expression -: -: -Literal +components +. +clone ( -match -op +) +; +for +component +in +& +mut +components { -UnaryOperator -: -: -Negate +* +component = -> -match -value -{ -Literal -: -: -I32 +self +. +cast_array ( -v +* +component +target +span ) +? +; +} +let +first = -> -Literal -: -: -I32 +components +. +first ( -- -v ) -Literal -: -: -F32 +. +unwrap ( -v ) +; +let +new_base = -> -Literal +match +self +. +resolve_type +( +* +first +) +? +{ +crate +: +: +proc +: +: +TypeResolution +: +: +Handle +( +ty +) += +> +ty +crate +: +: +proc +: +: +TypeResolution +: +: +Value +( +inner +) += +> +{ +self +. +types +. +insert +( +Type +{ +name +: +None +inner +} +span +) +} +} +; +let +new_base_stride += +self +. +types +[ +new_base +] +. +inner +. +size +( +self +. +to_ctx +( +) +) +; +let +new_array_ty += +self +. +types +. +insert +( +Type +{ +name +: +None +inner +: +TypeInner +: +: +Array +{ +base +: +new_base +size +stride +: +new_base_stride +} +} +span +) +; +let +compose += +Expression +: +: +Compose +{ +ty +: +new_array_ty +components +} +; +self +. +register_evaluated_expr +( +compose +span +) +} +fn +unary_op +( +& +mut +self +op +: +UnaryOperator +expr +: +Handle +< +Expression +> +span +: +Span +) +- +> +Result +< +Handle +< +Expression +> +ConstantEvaluatorError +> +{ +let +expr += +self +. +eval_zero_value_and_splat +( +expr +span +) +? +; +let +expr += +match +self +. +expressions +[ +expr +] +{ +Expression +: +: +Literal +( +value +) += +> +Expression +: +: +Literal +( +match +op +{ +UnaryOperator +: +: +Negate += +> +match +value +{ +Literal +: +: +I32 +( +v +) += +> +Literal +: +: +I32 +( +- +v +) +Literal +: +: +F32 +( +v +) += +> +Literal : : F32 @@ -9198,19 +10225,224 @@ span ) } } -} -# -[ -cfg +fn +resolve_type ( -test +& +self +expr +: +Handle +< +Expression +> ) -] -mod -tests -{ -use -std +- +> +Result +< +crate +: +: +proc +: +: +TypeResolution +ConstantEvaluatorError +> +{ +use +crate +: +: +proc +: +: +TypeResolution +as +Tr +; +use +crate +: +: +Expression +as +Ex +; +let +resolution += +match +self +. +expressions +[ +expr +] +{ +Ex +: +: +Literal +( +ref +literal +) += +> +Tr +: +: +Value +( +literal +. +ty_inner +( +) +) +Ex +: +: +Constant +( +c +) += +> +Tr +: +: +Handle +( +self +. +constants +[ +c +] +. +ty +) +Ex +: +: +ZeroValue +( +ty +) +| +Ex +: +: +Compose +{ +ty +. +. +} += +> +Tr +: +: +Handle +( +ty +) +Ex +: +: +Splat +{ +size +value +} += +> +{ +let +Tr +: +: +Value +( +TypeInner +: +: +Scalar +( +scalar +) +) += +self +. +resolve_type +( +value +) +? +else +{ +return +Err +( +ConstantEvaluatorError +: +: +SplatScalarOnly +) +; +} +; +Tr +: +: +Value +( +TypeInner +: +: +Vector +{ +scalar +size +} +) +} +_ += +> +return +Err +( +ConstantEvaluatorError +: +: +SubexpressionsAreNotConstant +) +} +; +Ok +( +resolution +) +} +} +# +[ +cfg +( +test +) +] +mod +tests +{ +use +std : : vec @@ -11753,3 +12985,646 @@ result } } } +/ +/ +/ +Trait +for +conversions +of +abstract +values +to +concrete +types +. +trait +TryFromAbstract +< +T +> +: +Sized +{ +/ +/ +/ +Convert +an +abstract +literal +value +to +Self +. +/ +/ +/ +/ +/ +/ +Since +Naga +' +s +AbstractInt +and +AbstractFloat +exist +to +support +/ +/ +/ +WGSL +we +follow +WGSL +' +s +conversion +rules +here +: +/ +/ +/ +/ +/ +/ +- +WGSL +6 +. +1 +. +2 +. +Conversion +Rank +says +that +automatic +conversions +/ +/ +/ +to +integers +are +either +lossless +or +an +error +. +/ +/ +/ +/ +/ +/ +- +WGSL +14 +. +6 +. +4 +Floating +Point +Conversion +says +that +conversions +/ +/ +/ +to +floating +point +in +constant +expressions +and +override +/ +/ +/ +expressions +are +errors +if +the +value +is +out +of +range +for +the +/ +/ +/ +destination +type +but +rounding +is +okay +. +/ +/ +/ +/ +/ +/ +[ +AbstractInt +] +: +crate +: +: +Literal +: +: +AbstractInt +/ +/ +/ +[ +Float +] +: +crate +: +: +Literal +: +: +Float +fn +try_from_abstract +( +value +: +T +) +- +> +Result +< +Self +ConstantEvaluatorError +> +; +} +impl +TryFromAbstract +< +i64 +> +for +i32 +{ +fn +try_from_abstract +( +value +: +i64 +) +- +> +Result +< +i32 +ConstantEvaluatorError +> +{ +i32 +: +: +try_from +( +value +) +. +map_err +( +| +_ +| +ConstantEvaluatorError +: +: +AutomaticConversionLossy +{ +value +: +format +! +( +" +{ +value +: +? +} +" +) +to_type +: +" +i32 +" +} +) +} +} +impl +TryFromAbstract +< +i64 +> +for +u32 +{ +fn +try_from_abstract +( +value +: +i64 +) +- +> +Result +< +u32 +ConstantEvaluatorError +> +{ +u32 +: +: +try_from +( +value +) +. +map_err +( +| +_ +| +ConstantEvaluatorError +: +: +AutomaticConversionLossy +{ +value +: +format +! +( +" +{ +value +: +? +} +" +) +to_type +: +" +u32 +" +} +) +} +} +impl +TryFromAbstract +< +i64 +> +for +f32 +{ +fn +try_from_abstract +( +value +: +i64 +) +- +> +Result +< +Self +ConstantEvaluatorError +> +{ +let +f += +value +as +f32 +; +/ +/ +The +range +of +i64 +is +roughly +18 +10 +whereas +the +range +of +/ +/ +f32 +is +roughly +3 +. +4 +10 +so +there +' +s +no +opportunity +for +/ +/ +overflow +here +. +Ok +( +f +) +} +} +impl +TryFromAbstract +< +f64 +> +for +f32 +{ +fn +try_from_abstract +( +value +: +f64 +) +- +> +Result +< +f32 +ConstantEvaluatorError +> +{ +let +f += +value +as +f32 +; +if +f +. +is_infinite +( +) +{ +return +Err +( +ConstantEvaluatorError +: +: +AutomaticConversionLossy +{ +value +: +format +! +( +" +{ +value +: +? +} +" +) +to_type +: +" +f32 +" +} +) +; +} +Ok +( +f +) +} +} +impl +TryFromAbstract +< +i64 +> +for +f64 +{ +fn +try_from_abstract +( +value +: +i64 +) +- +> +Result +< +Self +ConstantEvaluatorError +> +{ +let +f += +value +as +f64 +; +/ +/ +The +range +of +i64 +is +roughly +18 +10 +whereas +the +range +of +/ +/ +f64 +is +roughly +1 +. +8 +10 +so +there +' +s +no +opportunity +for +/ +/ +overflow +here +. +Ok +( +f +) +} +} +impl +TryFromAbstract +< +f64 +> +for +f64 +{ +fn +try_from_abstract +( +value +: +f64 +) +- +> +Result +< +f64 +ConstantEvaluatorError +> +{ +Ok +( +value +) +} +} +impl +TryFromAbstract +< +f64 +> +for +i32 +{ +fn +try_from_abstract +( +_ +: +f64 +) +- +> +Result +< +Self +ConstantEvaluatorError +> +{ +Err +( +ConstantEvaluatorError +: +: +AutomaticConversionFloatToInt +{ +to_type +: +" +i32 +" +} +) +} +} +impl +TryFromAbstract +< +f64 +> +for +u32 +{ +fn +try_from_abstract +( +_ +: +f64 +) +- +> +Result +< +Self +ConstantEvaluatorError +> +{ +Err +( +ConstantEvaluatorError +: +: +AutomaticConversionFloatToInt +{ +to_type +: +" +u32 +" +} +) +} +} diff --git a/third_party/rust/naga/src/proc/mod.rs b/third_party/rust/naga/src/proc/mod.rs index 5eda3b930cd0..f09720be6fe1 100644 --- a/third_party/rust/naga/src/proc/mod.rs +++ b/third_party/rust/naga/src/proc/mod.rs @@ -599,6 +599,22 @@ ScalarKind : : Float +| +crate +: +: +ScalarKind +: +: +AbstractInt +| +crate +: +: +ScalarKind +: +: +AbstractFloat = > true @@ -756,6 +772,56 @@ crate BOOL_WIDTH } ; +pub +const +ABSTRACT_INT +: +Self += +Self +{ +kind +: +crate +: +: +ScalarKind +: +: +AbstractInt +width +: +crate +: +: +ABSTRACT_WIDTH +} +; +pub +const +ABSTRACT_FLOAT +: +Self += +Self +{ +kind +: +crate +: +: +ScalarKind +: +: +AbstractFloat +width +: +crate +: +: +ABSTRACT_WIDTH +} +; / / / @@ -1152,6 +1218,14 @@ F64 ( v ) +| +Self +: +: +AbstractFloat +( +v +) = > { @@ -1285,6 +1359,14 @@ I64 ( v ) +| +Self +: +: +AbstractInt +( +v +) = > { @@ -1650,7 +1732,31 @@ _ ) = > -1 +crate +: +: +BOOL_WIDTH +Self +: +: +AbstractInt +( +_ +) +| +Self +: +: +AbstractFloat +( +_ +) += +> +crate +: +: +ABSTRACT_WIDTH } } pub @@ -1768,6 +1874,38 @@ Scalar : : BOOL +Self +: +: +AbstractInt +( +_ +) += +> +crate +: +: +Scalar +: +: +ABSTRACT_INT +Self +: +: +AbstractFloat +( +_ +) += +> +crate +: +: +Scalar +: +: +ABSTRACT_FLOAT } } pub @@ -1838,6 +1976,43 @@ super : TypeInner { +/ +/ +/ +Return +the +scalar +type +of +self +. +/ +/ +/ +/ +/ +/ +If +inner +is +a +scalar +vector +or +matrix +type +return +/ +/ +/ +its +scalar +type +. +Otherwise +return +None +. pub const fn diff --git a/third_party/rust/naga/src/valid/expression.rs b/third_party/rust/naga/src/valid/expression.rs index 9cf22d45698e..72129fe2900c 100644 --- a/third_party/rust/naga/src/valid/expression.rs +++ b/third_party/rust/naga/src/valid/expression.rs @@ -5331,6 +5331,16 @@ Sk : : Bool +| +Sk +: +: +AbstractInt +| +Sk +: +: +AbstractFloat = > false @@ -5417,6 +5427,16 @@ Sk : : Bool +| +Sk +: +: +AbstractInt +| +Sk +: +: +AbstractFloat = > false @@ -5469,6 +5489,16 @@ Sk : : Bool +| +Sk +: +: +AbstractInt +| +Sk +: +: +AbstractFloat ) | None @@ -5941,6 +5971,16 @@ Sk : : Bool +| +Sk +: +: +AbstractInt +| +Sk +: +: +AbstractFloat = > false @@ -6131,6 +6171,16 @@ Sk : : Float +| +Sk +: +: +AbstractInt +| +Sk +: +: +AbstractFloat = > false @@ -6224,6 +6274,16 @@ Sk : : Float +| +Sk +: +: +AbstractInt +| +Sk +: +: +AbstractFloat = > false @@ -6489,6 +6549,16 @@ Float Sk : : +AbstractInt +| +Sk +: +: +AbstractFloat +| +Sk +: +: Bool = > diff --git a/third_party/rust/naga/src/valid/function.rs b/third_party/rust/naga/src/valid/function.rs index e1d36e07dd32..fdf33c43e938 100644 --- a/third_party/rust/naga/src/valid/function.rs +++ b/third_party/rust/naga/src/valid/function.rs @@ -1077,25 +1077,27 @@ Expression error ( " -Store +The +type of { value : ? } -into +doesn +' +t +match +the +type +stored +in { pointer : ? } -doesn -' -t -have -matching -types " ) ] diff --git a/third_party/rust/naga/src/valid/type.rs b/third_party/rust/naga/src/valid/type.rs index f84ae9637024..5ebcd82deaf7 100644 --- a/third_party/rust/naga/src/valid/type.rs +++ b/third_party/rust/naga/src/valid/type.rs @@ -1345,6 +1345,23 @@ supported ) ] Unsupported64Bit +# +[ +error +( +" +Abstract +types +may +only +appear +in +constant +expressions +" +) +] +Abstract } / / @@ -1990,6 +2007,34 @@ width = 4 } +crate +: +: +ScalarKind +: +: +AbstractInt +| +crate +: +: +ScalarKind +: +: +AbstractFloat += +> +{ +return +Err +( +WidthError +: +: +Abstract +) +; +} } ; if @@ -2458,6 +2503,22 @@ ScalarKind : : Float +| +crate +: +: +ScalarKind +: +: +AbstractInt +| +crate +: +: +ScalarKind +: +: +AbstractFloat = > false diff --git a/third_party/rust/wgpu-core/.cargo-checksum.json b/third_party/rust/wgpu-core/.cargo-checksum.json index 3920960c1165..dbdb6f1a11c8 100644 --- a/third_party/rust/wgpu-core/.cargo-checksum.json +++ b/third_party/rust/wgpu-core/.cargo-checksum.json @@ -11,7 +11,7 @@ toml " : " -bde42e04a69f912ac871368e202df8af116ea0ef010a2f08a62388b6985ca61f +5119648ea52e97ad3fa2f0f24cc30e0b305fe81f710a33396bdadaf7397d41b9 " " LICENSE @@ -51,7 +51,7 @@ rs " : " -d7add33189aa453ad19acd8ac38465f44e233d0e8da42be5a3aadfc50a87a491 +b709658ed6b9af2ed07ff77b8da64912cd26a9d7caaecee26c77a92efdc615d4 " " src @@ -90,7 +90,7 @@ rs " : " -65499812d269e23efb12a12a455f58f52f3014f8db224d02951b7331638f6ad4 +8929095abd1508fdbc4b51db1bcfe513f77954fcfb269888c91b47c90b943c03 " " src @@ -142,7 +142,7 @@ rs " : " -e7c5e83a1b6398e68279b10910f426d7dde1ce3c800752bb88688b37f69b7872 +9ffa26b0306067ad63fc61fbde985ad98d495a2ad739f51bf54a39f702f45d3a " " src @@ -168,7 +168,7 @@ rs " : " -0b9a8804de0a85d3b4c593df2da78ce5d6c3e53169b05ca9babd3ec984cbe9f7 +61a9f34d813700606b49224d9de19773c49eb3dd42fa4027357a334dc63e2579 " " src @@ -181,7 +181,7 @@ rs " : " -49dd1261e3ad1effc4ebdad1bc3061f4330f991b8291df75591a1e2bc5eaa257 +60969f020bddfb88a0c3b459b72b94d3a9a96cc635d20e88d016765d0fb94ba5 " " src @@ -218,7 +218,7 @@ rs " : " -3be88717a7d164ea73842f90b93c359f8ea06bbae253af9a195734640d5a830d +33c47e5aaa44ad4a485a996af52247e765bedfa18724ab7662ce34c78754448b " " src @@ -231,7 +231,7 @@ rs " : " -6c2b2e7f98f71231c97f19cf19c4d8ff254ee9862a8422f973270656658aed96 +bbda212777bf5156feb9ee4c46d7c7621888c11544903a26bf86e7b708590f5a " " src @@ -244,7 +244,7 @@ rs " : " -9bae0d30eaf51af5545eea10d5c8af6ca3ced2518d24c42880ec3c8f1f7664b2 +4ec88e037307e597fc661c85c9fa28f2d70a82a222a5fec5c97c450d33224f37 " " src @@ -257,7 +257,7 @@ rs " : " -aec77faebaa750f843f2f04ea9a2021598098783f16f95e739bc64fabcc29619 +9525b939e49b4c2860928c04a660a4556b34bfbed23e00318635a5ad46bce061 " " src @@ -270,7 +270,7 @@ rs " : " -0e707723d58cecfb402fe35eb9944278de96a95496bd2e62b50a71ef3e44d079 +a47f4d8b605c477fc6a63058e1340872590631c9a1a7f4e454bbbbe01aada757 " " src @@ -283,7 +283,7 @@ rs " : " -21408dfd2c99e3ce36a77d08ba86cf52f32bb376ed82690bbbf74937bfd42cbe +9a8ec674567a8866a6bd1ed2ad06e474bd2504ed91f228d3040cb6db18fe5f2b " " src @@ -305,7 +305,7 @@ rs " : " -fd2a7995bdb64f1186fd71c4f6b59f34c543ee695912b1fad7931c88ec024584 +9aa9448791477007b850c5eb1584e7c74c14fe43ac47ab3b5f29373850f463ee " " src @@ -338,7 +338,7 @@ rs " : " -4684c40d56ad8f49f36455ea84f2901df587fc3574274ac132b8236ece6926a3 +0aa4258f93e05f6991385980a553e67892a0f1769e37624ae0466f83161af697 " " src @@ -399,7 +399,7 @@ rs " : " -643ce09d9a623f00e66e1eb50b2facc4d072f4149c9953343c1b0e8c4a5f6915 +46b13911e15310a7ced4e5f13eeaa5d2cde7762b8ffa282a28d0c812e7036458 " " src @@ -410,7 +410,7 @@ rs " : " -23ac375edd02c7808ccb901b392bb34960339027b2e068b9009f89d413946515 +9408b33250c7062599045cc11dd1f52d6036415f0e5c568b37c73348b330bb7c " " src @@ -421,7 +421,7 @@ rs " : " -e09adc811a7553daa4d826fd6001be14a7d21222fc8ba76040d4fd5c0f017787 +1d615e582254cfa108dd1925df7b6b0ae0c9845714b1351b8bcd4c7aa4b4dd69 " " src @@ -432,7 +432,7 @@ rs " : " -5a15e583ee2b4c1afcf596c8429437a50e9fd1e17f8fbf4fafb482928940815e +1c28d6dbc3125b5eebd12265013618d8585d5c90f3fd1d3529c20e41e1ddecb3 " " src @@ -443,7 +443,7 @@ rs " : " -52a52b0ed41abbed3c6a84f0fb01c5f45c75953bacaa7a9b9bdb95a8825eb573 +e93369ae372b133649b554a3d0338d74823cfded8b7e84d01bf1f000b670f471 " " src @@ -454,7 +454,7 @@ rs " : " -14a3fedcf422688dc484c91abc5b2522c388fd5587c61e11a4b0bd882284fb24 +be6b9b648911c2277d9f88ca9e9a2811ec28fdf8118e009a47de0c16179f28aa " " src @@ -465,7 +465,7 @@ rs " : " -343811d28ed0926ef2d7f116d5ad8b4b6b6f530d7dfb5b9afbb90f2bb3ccfbc1 +6ba6416522ba2f1d2a279c220960aabdfb071c4e0ade888c8cbc2b91325c4203 " " src @@ -478,7 +478,7 @@ rs " : " -2e37fdae4e3b81f4e9d4bc35d71849ce82846afbb55c3de75c5db101c888e216 +a6762fad8bf5b257d37fb8844f0ee44ecb04f052c58655404b8af0036ac929e5 " " src @@ -491,7 +491,7 @@ rs " : " -8ef7af1d0152a3a8d706402a416c2e74c9282354cad055d2c0c527486cb3019e +f8994ad91db7f3bb1b7f8b8b0f6884753d733ce28238b36f31da2230706f848e " " src @@ -504,7 +504,7 @@ rs " : " -028b04676f8a42a1f67bb9f6ffb809f56fa6349596b52561bce5b78c176e51e7 +5fdef0bcf20999fda97342e261341809394dcad3ee97e2bc2429c5a1e41d48d5 " " src @@ -530,7 +530,7 @@ rs " : " -57f13386f0829cd6e1a894e454f69929eea7494565e530ed9f80bd7d50a4ba2d +65142de8e8425eee26e32bfef8169af3ed0e98455d5e470517717a3c15e8036c " " src @@ -543,7 +543,7 @@ rs " : " -ea8ba2089e72401dcd37738d0583c411ec100a7436626f738d8d81bc188cbd99 +d4e92ef3400cf48b2e76d8b7c1e4c6a1cef0d3d060c6abdb46b9a3b386bc9dc9 " " src @@ -554,7 +554,7 @@ rs " : " -0ca7fe772c06f788bd758e720d35e5664ffe69188922c7a1981f3855206e200b +4bd36b7b02ad0122fda719790d40cc68058e0f8e3ba3cd622f1d76db377320f9 " } " diff --git a/third_party/rust/wgpu-core/Cargo.toml b/third_party/rust/wgpu-core/Cargo.toml index d11bff8a64c1..3cbda4428ac3 100644 --- a/third_party/rust/wgpu-core/Cargo.toml +++ b/third_party/rust/wgpu-core/Cargo.toml @@ -500,6 +500,10 @@ types [ features ] +api_log_info += +[ +] default = [ @@ -631,6 +635,10 @@ naga deserialize " ] +resource_log_info += +[ +] serial - pass @@ -746,7 +754,7 @@ version . 3 . -64 +66 " features = diff --git a/third_party/rust/wgpu-core/src/binding_model.rs b/third_party/rust/wgpu-core/src/binding_model.rs index 36764080c0fd..77a4998a4311 100644 --- a/third_party/rust/wgpu-core/src/binding_model.rs +++ b/third_party/rust/wgpu-core/src/binding_model.rs @@ -51,6 +51,7 @@ Resource ResourceInfo ResourceType } +resource_log track : : @@ -3254,18 +3255,29 @@ mut self ) { -log -: -: -info +if +let +Some +( +raw +) += +self +. +raw +. +take +( +) +{ +resource_log ! ( " -Destroying +Destroy +raw BindGroupLayout { -: -? } " self @@ -3277,21 +3289,6 @@ label ) ) ; -if -let -Some -( -raw -) -= -self -. -raw -. -take -( -) -{ unsafe { use @@ -4486,18 +4483,29 @@ mut self ) { -log -: -: -info +if +let +Some +( +raw +) += +self +. +raw +. +take +( +) +{ +resource_log ! ( " -Destroying +Destroy +raw PipelineLayout { -: -? } " self @@ -4509,21 +4517,6 @@ label ) ) ; -if -let -Some -( -raw -) -= -self -. -raw -. -take -( -) -{ unsafe { use @@ -6160,18 +6153,29 @@ mut self ) { -log -: -: -info +if +let +Some +( +raw +) += +self +. +raw +. +take +( +) +{ +resource_log ! ( " -Destroying +Destroy +raw BindGroup { -: -? } " self @@ -6183,21 +6187,6 @@ label ) ) ; -if -let -Some -( -raw -) -= -self -. -raw -. -take -( -) -{ unsafe { use diff --git a/third_party/rust/wgpu-core/src/command/clear.rs b/third_party/rust/wgpu-core/src/command/clear.rs index 9001983f0c29..e50f11b2dd5d 100644 --- a/third_party/rust/wgpu-core/src/command/clear.rs +++ b/third_party/rust/wgpu-core/src/command/clear.rs @@ -43,6 +43,7 @@ crate : : { +api_log command : : @@ -117,7 +118,6 @@ math : align_to BufferAddress -BufferSize BufferUsages ImageSubresourceRange TextureAspect @@ -300,7 +300,7 @@ COPY_BUFFER_ALIGNMENT ] UnalignedFillSize ( -BufferSize +BufferAddress ) # [ @@ -610,7 +610,7 @@ size : Option < -BufferSize +BufferAddress > ) - @@ -636,10 +636,7 @@ clear_buffer " ) ; -log -: -: -trace +api_log ! ( " @@ -931,10 +928,6 @@ size { if size -. -get -( -) % wgt : @@ -963,10 +956,6 @@ destination_end_offset offset + size -. -get -( -) ; if destination_end_offset @@ -1014,10 +1003,6 @@ size offset + size -. -get -( -) None = > @@ -1204,10 +1189,7 @@ clear_texture " ) ; -log -: -: -trace +api_log ! ( " @@ -2345,6 +2327,35 @@ FormatAspects COLOR ) ; +if +texture_desc +. +format += += +wgt +: +: +TextureFormat +: +: +NV12 +{ +/ +/ +TODO +: +Currently +COPY_DST +for +NV12 +textures +is +unsupported +. +return +; +} / / Gather diff --git a/third_party/rust/wgpu-core/src/command/mod.rs b/third_party/rust/wgpu-core/src/command/mod.rs index 65c2f49a187b..8a89a5502d37 100644 --- a/third_party/rust/wgpu-core/src/command/mod.rs +++ b/third_party/rust/wgpu-core/src/command/mod.rs @@ -176,6 +176,7 @@ crate : : { +api_log global : : @@ -189,6 +190,7 @@ identity : : GlobalIdentityHandlerFactory +resource_log Label } ; @@ -894,18 +896,18 @@ is_none return ; } -log -: -: -info +resource_log ! ( " -Destroying +resource +: +: CommandBuffer -{ : -? +: +drop +{ } " self @@ -1678,7 +1680,7 @@ A log : : -info +trace ! ( " @@ -2898,10 +2900,7 @@ push_debug_group " ) ; -log -: -: -trace +api_log ! ( " @@ -3098,10 +3097,7 @@ insert_debug_marker " ) ; -log -: -: -trace +api_log ! ( " @@ -3294,10 +3290,7 @@ pop_debug_marker " ) ; -log -: -: -trace +api_log ! ( " diff --git a/third_party/rust/wgpu-core/src/command/render.rs b/third_party/rust/wgpu-core/src/command/render.rs index b667a8b70ef2..a548f5183635 100644 --- a/third_party/rust/wgpu-core/src/command/render.rs +++ b/third_party/rust/wgpu-core/src/command/render.rs @@ -12,6 +12,7 @@ crate : : { +api_log binding_model : : @@ -9317,10 +9318,7 @@ bind_group_id = > { -log -: -: -trace +api_log ! ( " @@ -9768,10 +9766,7 @@ pipeline_id = > { -log -: -: -trace +api_log ! ( " @@ -10468,10 +10463,7 @@ size = > { -log -: -: -trace +api_log ! ( " @@ -10741,10 +10733,7 @@ size = > { -log -: -: -trace +api_log ! ( " @@ -11118,10 +11107,7 @@ color = > { -log -: -: -trace +api_log ! ( " @@ -11189,10 +11175,7 @@ value = > { -log -: -: -trace +api_log ! ( " @@ -11250,10 +11233,7 @@ depth_max = > { -log -: -: -trace +api_log ! ( " @@ -11489,10 +11469,7 @@ values_offset = > { -log -: -: -trace +api_log ! ( " @@ -11649,10 +11626,7 @@ rect = > { -log -: -: -trace +api_log ! ( " @@ -11783,10 +11757,7 @@ first_instance = > { -log -: -: -trace +api_log ! ( " @@ -11968,10 +11939,7 @@ first_instance = > { -log -: -: -trace +api_log ! ( " @@ -12167,10 +12135,7 @@ indexed = > { -log -: -: -trace +api_log ! ( " @@ -12535,10 +12500,7 @@ indexed = > { -log -: -: -trace +api_log ! ( " @@ -13072,10 +13034,7 @@ unwrap ( ) ; -log -: -: -trace +api_log ! ( " @@ -13115,10 +13074,7 @@ PopDebugGroup = > { -log -: -: -trace +api_log ! ( " @@ -13225,10 +13181,7 @@ unwrap ( ) ; -log -: -: -trace +api_log ! ( " @@ -13272,10 +13225,7 @@ query_index = > { -log -: -: -trace +api_log ! ( " @@ -13387,10 +13337,7 @@ query_index = > { -log -: -: -trace +api_log ! ( " @@ -13497,10 +13444,7 @@ EndOcclusionQuery = > { -log -: -: -trace +api_log ! ( " @@ -13548,10 +13492,7 @@ query_index = > { -log -: -: -trace +api_log ! ( " @@ -13644,10 +13585,7 @@ EndPipelineStatisticsQuery = > { -log -: -: -trace +api_log ! ( " @@ -13694,10 +13632,7 @@ bundle_id = > { -log -: -: -trace +api_log ! ( " diff --git a/third_party/rust/wgpu-core/src/command/transfer.rs b/third_party/rust/wgpu-core/src/command/transfer.rs index 6cec70cd47e1..2c018a0dc201 100644 --- a/third_party/rust/wgpu-core/src/command/transfer.rs +++ b/third_party/rust/wgpu-core/src/command/transfer.rs @@ -28,6 +28,7 @@ crate : : { +api_log command : : @@ -3730,6 +3731,35 @@ copy_buffer_to_buffer " ) ; +api_log +! +( +" +CommandEncoder +: +: +copy_buffer_to_buffer +{ +source +: +? +} +- +> +{ +destination +: +? +} +{ +size +: +? +} +bytes +" +) +; if source = @@ -4749,6 +4779,38 @@ copy_buffer_to_texture " ) ; +api_log +! +( +" +CommandEncoder +: +: +copy_buffer_to_texture +{ +: +? +} +- +> +{ +: +? +} +{ +copy_size +: +? +} +" +source +. +buffer +destination +. +texture +) +; let hub = @@ -5728,6 +5790,38 @@ copy_texture_to_buffer " ) ; +api_log +! +( +" +CommandEncoder +: +: +copy_texture_to_buffer +{ +: +? +} +- +> +{ +: +? +} +{ +copy_size +: +? +} +" +source +. +texture +destination +. +buffer +) +; let hub = @@ -6787,6 +6881,38 @@ copy_texture_to_texture " ) ; +api_log +! +( +" +CommandEncoder +: +: +copy_texture_to_texture +{ +: +? +} +- +> +{ +: +? +} +{ +copy_size +: +? +} +" +source +. +texture +destination +. +texture +) +; let hub = diff --git a/third_party/rust/wgpu-core/src/device/global.rs b/third_party/rust/wgpu-core/src/device/global.rs index b787253e50dc..7c248aa6c747 100644 --- a/third_party/rust/wgpu-core/src/device/global.rs +++ b/third_party/rust/wgpu-core/src/device/global.rs @@ -23,6 +23,7 @@ crate : : { +api_log binding_model command conv @@ -1212,27 +1213,29 @@ assign buffer ) ; -log -: -: -info +api_log ! ( " -Created -Buffer +Device +: +: +create_buffer +( { +desc : ? } -with +) +- +> { +id : ? } " -id -desc ) ; let @@ -3431,36 +3434,31 @@ destroy " ) ; -let -hub -= -A -: -: -hub -( -self -) -; -log -: -: -debug +api_log ! ( " Buffer +: +: +destroy { +buffer_id : ? } -is -asked -to -be -dropped " -buffer_id +) +; +let +hub += +A +: +: +hub +( +self ) ; let @@ -3542,25 +3540,20 @@ drop " ) ; -log -: -: -debug +api_log ! ( " Buffer +: +: +drop { +buffer_id : ? } -is -asked -to -be -dropped " -buffer_id ) ; let @@ -3995,27 +3988,29 @@ assign texture ) ; -log -: -: -info +api_log ! ( " -Created -Texture +Device +: +: +create_texture +( { +desc : ? } -with +) +- +> { +id : ? } " -id -desc ) ; device @@ -4049,6 +4044,26 @@ None ; } ; +log +: +: +error +! +( +" +Device +: +: +create_texture +error +{ +error +: +? +} +" +) +; let id = @@ -4501,27 +4516,22 @@ assign texture ) ; -log -: -: -info +api_log ! ( " -Created -Texture -{ +Device : -? -} -with +: +create_texture +- +> { +id : ? } " -id -desc ) ; device @@ -4555,6 +4565,26 @@ None ; } ; +log +: +: +error +! +( +" +Device +: +: +create_texture +error +{ +error +: +? +} +" +) +; let id = @@ -4887,27 +4917,22 @@ assign buffer ) ; -log -: -: -info +api_log ! ( " -Created -buffer -{ +Device : -? -} -with +: +create_buffer +- +> { +id : ? } " -id -desc ) ; device @@ -4943,6 +4968,26 @@ None ; } ; +log +: +: +error +! +( +" +Device +: +: +create_buffer +error +{ +error +: +? +} +" +) +; let id = @@ -5048,10 +5093,7 @@ destroy " ) ; -log -: -: -trace +api_log ! ( " @@ -5078,24 +5120,6 @@ hub self ) ; -log -: -: -debug -! -( -" -Texture -{ -: -? -} -is -destroyed -" -texture_id -) -; let mut texture_guard @@ -5378,25 +5402,20 @@ drop " ) ; -log -: -: -debug +api_log ! ( " Texture +: +: +drop { +texture_id : ? } -is -asked -to -be -dropped " -texture_id ) ; let @@ -5823,21 +5842,29 @@ assign view ) ; -log -: -: -info +api_log ! ( " -Created -TextureView +Texture +: +: +create_view +( { +texture_id : ? } -" +) +- +> +{ id +: +? +} +" ) ; device @@ -5875,18 +5902,20 @@ Texture : : create_view +( { +texture_id : ? } +) error { +error : ? } " -texture_id -error ) ; let @@ -5997,25 +6026,20 @@ drop " ) ; -log -: -: -debug +api_log ! ( " TextureView +: +: +drop { +texture_view_id : ? } -is -asked -to -be -dropped " -texture_view_id ) ; let @@ -6386,21 +6410,22 @@ assign sampler ) ; -log -: -: -info +api_log ! ( " -Created -Sampler -{ +Device : -? +: +create_sampler +- +> +{ +id +: +? } " -id ) ; device @@ -6521,25 +6546,20 @@ drop " ) ; -log -: -: -debug +api_log ! ( " Sampler +: +: +drop { +sampler_id : ? } -is -asked -to -be -dropped " -sampler_id ) ; let @@ -6927,10 +6947,7 @@ bgl_guard ) } { -log -: -: -info +api_log ! ( " @@ -7014,21 +7031,22 @@ assign layout ) ; -log -: -: -info +api_log ! ( " -Created -BindGroupLayout +Device +: +: +create_bind_group_layout +- +> { +id : ? } " -id ) ; return @@ -7150,25 +7168,20 @@ drop " ) ; -log -: -: -debug +api_log ! ( " BindGroupLayout +: +: +drop { +bind_group_layout_id : ? } -is -asked -to -be -dropped " -bind_group_layout_id ) ; let @@ -7483,21 +7496,22 @@ assign layout ) ; -log -: -: -info +api_log ! ( " -Created -PipelineLayout +Device +: +: +create_pipeline_layout +- +> { +id : ? } " -id ) ; return @@ -7602,25 +7616,20 @@ drop " ) ; -log -: -: -debug +api_log ! ( " PipelineLayout +: +: +drop { +pipeline_layout_id : ? } -is -asked -to -be -dropped " -pipeline_layout_id ) ; let @@ -8004,21 +8013,22 @@ assign bind_group ) ; -log -: -: -info +api_log ! ( " -Created -BindGroup +Device +: +: +create_bind_group +- +> { +id : ? } " -id ) ; device @@ -8139,25 +8149,20 @@ drop " ) ; -log -: -: -debug +api_log ! ( " BindGroup +: +: +drop { +bind_group_id : ? } -is -asked -to -be -dropped " -bind_group_id ) ; let @@ -8599,27 +8604,22 @@ assign shader ) ; -log -: -: -info +api_log ! ( " -Created -ShaderModule -{ +Device : -? -} -with +: +create_shader_module +- +> { +id : ? } " -id -desc ) ; return @@ -8630,6 +8630,27 @@ None ; } ; +log +: +: +error +! +( +" +Device +: +: +create_shader_module +error +: +{ +error +: +? +} +" +) +; let id = @@ -9023,27 +9044,22 @@ assign shader ) ; -log -: -: -info +api_log ! ( " -Created -ShaderModule -{ +Device : -? -} -with +: +create_shader_module_spirv +- +> { +id : ? } " -id -desc ) ; return @@ -9054,6 +9070,27 @@ None ; } ; +log +: +: +error +! +( +" +Device +: +: +create_shader_module_spirv +error +: +{ +error +: +? +} +" +) +; let id = @@ -9148,25 +9185,20 @@ drop " ) ; -log -: -: -debug +api_log ! ( " ShaderModule +: +: +drop { +shader_module_id : ? } -is -asked -to -be -dropped " -shader_module_id ) ; let @@ -9509,27 +9541,22 @@ assign command_buffer ) ; -log -: -: -info +api_log ! ( " -Created -CommandBuffer -{ +Device : -? -} -with +: +create_command_encoder +- +> { +id : ? } " -id -desc ) ; return @@ -9634,25 +9661,20 @@ drop " ) ; -log -: -: -debug +api_log ! ( " CommandEncoder +: +: +drop { +command_encoder_id : ? } -is -asked -to -be -dropped " -command_encoder_id ) ; let @@ -9743,25 +9765,20 @@ drop " ) ; -log -: -: -debug +api_log ! ( " CommandBuffer +: +: +drop { +command_buffer_id : ? } -is -asked -to -be -dropped " -command_buffer_id ) ; self @@ -9823,10 +9840,7 @@ create_render_bundle_encoder " ) ; -log -: -: -trace +api_log ! ( " @@ -10192,21 +10206,22 @@ assign render_bundle ) ; -log -: -: -info +api_log ! ( " -Created -RenderBundle +RenderBundleEncoder +: +: +finish +- +> { +id : ? } " -id ) ; device @@ -10327,25 +10342,20 @@ drop " ) ; -log -: -: -debug +api_log ! ( " RenderBundle +: +: +drop { +render_bundle_id : ? } -is -asked -to -be -dropped " -render_bundle_id ) ; let @@ -10648,21 +10658,22 @@ assign query_set ) ; -log -: -: -info +api_log ! ( " -Created -QuerySet +Device +: +: +create_query_set +- +> { +id : ? } " -id ) ; device @@ -10741,25 +10752,20 @@ drop " ) ; -log -: -: -debug +api_log ! ( " QuerySet +: +: +drop { +query_set_id : ? } -is -asked -to -be -dropped " -query_set_id ) ; let @@ -11200,27 +11206,22 @@ assign pipeline ) ; -log -: -: -info +api_log ! ( " -Created -RenderPipeline -{ +Device : -? -} -with +: +create_render_pipeline +- +> { +id : ? } " -id -desc ) ; device @@ -11396,6 +11397,26 @@ IMPLICIT_FAILURE ; } } +log +: +: +error +! +( +" +Device +: +: +create_render_pipeline +error +{ +error +: +? +} +" +) +; ( id Some @@ -11703,25 +11724,20 @@ drop " ) ; -log -: -: -debug +api_log ! ( " RenderPipeline +: +: +drop { +render_pipeline_id : ? } -is -asked -to -be -dropped " -render_pipeline_id ) ; let @@ -12112,27 +12128,22 @@ assign pipeline ) ; -log -: -: -info +api_log ! ( " -Created -ComputePipeline -{ +Device : -? -} -with +: +create_compute_pipeline +- +> { +id : ? } " -id -desc ) ; device @@ -12624,25 +12635,20 @@ drop " ) ; -log -: -: -debug +api_log ! ( " ComputePipeline +: +: +drop { +compute_pipeline_id : ? } -is -asked -to -be -dropped " -compute_pipeline_id ) ; let @@ -12828,6 +12834,9 @@ hal : : SurfaceCapabilities +max_texture_dimension_2d +: +u32 ) - > @@ -12858,87 +12867,26 @@ height ; if width -< -caps -. -extents -. -start -( -) -. -width -| -| -width > -caps -. -extents -. -end -( -) -. -width -| -| -height -< -caps -. -extents -. -start -( -) -. -height +max_texture_dimension_2d | | height > -caps -. -extents -. -end -( -) -. -height +max_texture_dimension_2d { -log -: -: -warn -! +return +Err ( -" -Requested -size -{ -} -x -{ -} -is -outside -of -the -supported -range +E : -{ : -? -} -" +TooLarge +{ width height -caps -. -extents +max_texture_dimension_2d +} ) ; } @@ -13175,10 +13123,7 @@ present_modes ; } ; -log -: -: -info +api_log ! ( " @@ -13417,10 +13362,7 @@ composite_alpha_modes ; } ; -log -: -: -info +api_log ! ( " @@ -14044,6 +13986,11 @@ mut hal_config & caps +device +. +limits +. +max_texture_dimension_2d ) { break @@ -14092,7 +14039,6 @@ device . maintain ( -hub fence wgt : @@ -14570,7 +14516,6 @@ lock_life . triage_suspected ( -hub & device . @@ -14662,10 +14607,7 @@ bool WaitIdleError > { -log -: -: -trace +api_log ! ( " @@ -14786,7 +14728,6 @@ device . maintain ( -hub fence maintain ) @@ -14998,7 +14939,6 @@ device . maintain ( -hub fence maintain ) @@ -15094,6 +15034,14 @@ bool WaitIdleError > { +api_log +! +( +" +poll_all_devices +" +) +; let mut closures @@ -15407,10 +15355,7 @@ id DeviceId ) { -log -: -: -trace +api_log ! ( " @@ -15490,10 +15435,7 @@ id DeviceId ) { -log -: -: -trace +api_log ! ( " @@ -15587,25 +15529,20 @@ drop " ) ; -log -: -: -debug +api_log ! ( " Device +: +: +drop { +device_id : ? } -is -asked -to -be -dropped " -device_id ) ; let @@ -15826,10 +15763,7 @@ device_id DeviceId ) { -log -: -: -trace +api_log ! ( " @@ -16071,10 +16005,7 @@ message str ) { -log -: -: -trace +api_log ! ( " @@ -16156,25 +16087,20 @@ drop " ) ; -log -: -: -debug +api_log ! ( " Queue +: +: +drop { +queue_id : ? } -is -asked -to -be -dropped " -queue_id ) ; let @@ -16242,10 +16168,7 @@ BufferMapOperation > BufferAccessResult { -log -: -: -trace +api_log ! ( " @@ -16355,6 +16278,26 @@ clone ) ; } +log +: +: +error +! +( +" +Buffer +: +: +map_async +error +{ +err +: +? +} +" +) +; return Err ( @@ -16871,27 +16814,6 @@ clone } ; } -log -: -: -debug -! -( -" -Buffer -{ -: -? -} -map -state -- -> -Waiting -" -buffer_id -) -; { let mut @@ -17023,10 +16945,7 @@ get_mapped_range " ) ; -log -: -: -trace +api_log ! ( " @@ -17467,10 +17386,7 @@ Buffer " ) ; -log -: -: -trace +api_log ! ( " diff --git a/third_party/rust/wgpu-core/src/device/life.rs b/third_party/rust/wgpu-core/src/device/life.rs index a745b1a14e59..e5c73b2f438a 100644 --- a/third_party/rust/wgpu-core/src/device/life.rs +++ b/third_party/rust/wgpu-core/src/device/life.rs @@ -54,10 +54,6 @@ hal_api : : HalApi -hub -: -: -Hub id : : @@ -83,10 +79,6 @@ pipeline ComputePipeline RenderPipeline } -registry -: -: -Registry resource : : @@ -475,100 +467,6 @@ map self } fn -map -< -Id -R -> -( -& -self -) -- -> -& -FastHashMap -< -Id -Arc -< -R -> -> -where -Id -: -id -: -: -TypedId -R -: -Resource -< -Id -> -{ -let -map -= -self -. -maps -. -get -( -R -: -: -TYPE -) -. -unwrap -( -) -; -let -any_map -= -map -. -as_ref -( -) -. -as_any -( -) -; -let -map -= -any_map -. -downcast_ref -: -: -< -FastHashMap -< -Id -Arc -< -R -> -> -> -( -) -. -unwrap -( -) -; -map -} -fn map_mut < Id @@ -1033,59 +931,6 @@ r ; self } -pub -( -crate -) -fn -contains -< -Id -R -> -( -& -mut -self -id -: -& -Id -) -- -> -bool -where -Id -: -id -: -: -TypedId -R -: -Resource -< -Id -> -{ -self -. -map -: -: -< -Id -R -> -( -) -. -contains_key -( -id -) -} } / / @@ -3067,7 +2912,7 @@ done_count log : : -info +debug ! ( " @@ -3417,7 +3262,6 @@ triage_resources < Id R -F T > ( @@ -3458,17 +3302,6 @@ ResourceTracker Id R > -registry -: -& -Registry -< -Id -R -> -count_fn -: -F mut on_remove : @@ -3496,24 +3329,6 @@ Resource < Id > -F -: -Fn -( -u64 -& -[ -ActiveSubmission -< -A -> -] -& -Id -) -- -> -usize T : FnMut @@ -3562,35 +3377,6 @@ submission_index ) ; let -mut -count -= -1 -; -count -+ -= -count_fn -( -submit_index -active -& -id -) -; -count -+ -= -registry -. -contains -( -id -) -as -usize -; -let non_referenced_resources = active @@ -3628,25 +3414,6 @@ a last_resources ) ; -count -+ -= -non_referenced_resources -. -contains -: -: -< -Id -R -> -( -& -id -) -as -usize -; let is_removed = @@ -3655,7 +3422,6 @@ trackers remove_abandoned ( id -count ) ; if @@ -3705,13 +3471,6 @@ triage_suspected_render_bundles & mut self -hub -: -& -Hub -< -A -> trackers : & @@ -3801,16 +3560,6 @@ mut trackers . bundles -& -hub -. -render_bundles -| -_submit_index -_active -_id -| -0 | _bundle_id _bundle @@ -4065,13 +3814,6 @@ triage_suspected_bind_groups & mut self -hub -: -& -Hub -< -A -> trackers : & @@ -4161,16 +3903,6 @@ mut trackers . bind_groups -& -hub -. -bind_groups -| -_submit_index -_active -_id -| -0 | _bind_group_id _bind_group @@ -4444,13 +4176,6 @@ triage_suspected_texture_views & mut self -hub -: -& -Hub -< -A -> trackers : & @@ -4540,16 +4265,6 @@ mut trackers . views -& -hub -. -texture_views -| -_submit_index -_active -_id -| -0 | _texture_view_id _texture_view @@ -4668,13 +4383,6 @@ triage_suspected_textures & mut self -hub -: -& -Hub -< -A -> trackers : & @@ -4760,16 +4468,6 @@ mut trackers . textures -& -hub -. -textures -| -_submit_index -_active -_id -| -0 | _texture_id _texture @@ -4827,13 +4525,6 @@ triage_suspected_samplers & mut self -hub -: -& -Hub -< -A -> trackers : & @@ -4919,16 +4610,6 @@ mut trackers . samplers -& -hub -. -samplers -| -_submit_index -_active -_id -| -0 | _sampler_id _sampler @@ -4986,13 +4667,6 @@ triage_suspected_buffers & mut self -hub -: -& -Hub -< -A -> trackers : & @@ -5082,97 +4756,6 @@ mut trackers . buffers -& -hub -. -buffers -| -submit_index -active -buffer_id -| -{ -let -mut -count -= -0 -; -let -mapped -= -active -. -iter -( -) -. -find -( -| -a -| -a -. -index -= -= -submit_index -) -. -map_or -( -& -self -. -mapped -| -a -| -& -a -. -mapped -) -; -mapped -. -iter -( -) -. -for_each -( -| -b -| -{ -if -b -. -as_info -( -) -. -id -( -) -= -= -* -buffer_id -{ -count -+ -= -1 -; -} -} -) -; -count -} | _buffer_id _buffer @@ -5295,13 +4878,6 @@ triage_suspected_compute_pipelines & mut self -hub -: -& -Hub -< -A -> trackers : & @@ -5391,16 +4967,6 @@ mut trackers . compute_pipelines -& -hub -. -compute_pipelines -| -_submit_index -_active -_id -| -0 | _compute_pipeline_id _compute_pipeline @@ -5501,13 +5067,6 @@ triage_suspected_render_pipelines & mut self -hub -: -& -Hub -< -A -> trackers : & @@ -5597,16 +5156,6 @@ mut trackers . render_pipelines -& -hub -. -render_pipelines -| -_submit_index -_active -_id -| -0 | _render_pipeline_id _render_pipeline @@ -6066,13 +5615,6 @@ triage_suspected_query_sets & mut self -hub -: -& -Hub -< -A -> trackers : & @@ -6134,16 +5676,6 @@ mut trackers . query_sets -& -hub -. -query_sets -| -_submit_index -_active -_id -| -0 | _query_set_id _query_set @@ -6684,13 +6216,6 @@ triage_suspected & mut self -hub -: -& -Hub -< -A -> trackers : & @@ -6758,7 +6283,6 @@ self . triage_suspected_render_bundles ( -hub trackers # [ @@ -6780,7 +6304,6 @@ self . triage_suspected_compute_pipelines ( -hub trackers # [ @@ -6802,7 +6325,6 @@ self . triage_suspected_render_pipelines ( -hub trackers # [ @@ -6824,7 +6346,6 @@ self . triage_suspected_bind_groups ( -hub trackers # [ @@ -6886,7 +6407,6 @@ self . triage_suspected_query_sets ( -hub trackers ) ; @@ -6894,7 +6414,6 @@ self . triage_suspected_samplers ( -hub trackers # [ @@ -6922,7 +6441,6 @@ self . triage_suspected_texture_views ( -hub trackers # [ @@ -6944,7 +6462,6 @@ self . triage_suspected_textures ( -hub trackers # [ @@ -6966,7 +6483,6 @@ self . triage_suspected_buffers ( -hub trackers # [ @@ -7229,13 +6745,6 @@ handle_mapping & mut self -hub -: -& -Hub -< -A -> raw : & @@ -7346,26 +6855,6 @@ lock ( ) ; -let -mut -count -= -1 -; -count -+ -= -hub -. -buffers -. -contains -( -buffer_id -) -as -usize -; trackers . buffers @@ -7373,7 +6862,6 @@ buffers remove_abandoned ( buffer_id -count ) } ; @@ -7400,7 +6888,7 @@ Idle log : : -info +trace ! ( " diff --git a/third_party/rust/wgpu-core/src/device/mod.rs b/third_party/rust/wgpu-core/src/device/mod.rs index 30a6ba477017..450a778249a1 100644 --- a/third_party/rust/wgpu-core/src/device/mod.rs +++ b/third_party/rust/wgpu-core/src/device/mod.rs @@ -39,6 +39,7 @@ resource BufferAccessError BufferMapOperation } +resource_log Label DOWNLEVEL_ERROR_MESSAGE } @@ -1771,13 +1772,6 @@ inner } } } -# -[ -allow -( -trivial_casts -) -] pub ( crate @@ -1844,33 +1838,53 @@ unsafe { / / -We -need -to -pass +Ensure message +is +structured as a -c_char -typed -pointer +null +- +terminated +C +string . -To -avoid -trivial +It +only / / -conversion -warnings -on -some -platforms -we -use +needs +to +live +as +long +as the -allow -lint +callback +invocation . +let +message += +std +: +: +ffi +: +: +CString +: +: +new +( +message +) +. +unwrap +( +) +; ( inner . @@ -1888,10 +1902,6 @@ message as_ptr ( ) -as -* -const -c_char ) } } @@ -2574,18 +2584,17 @@ A Device ) { -log -: -: -info +resource_log ! ( " -Destroying +CommandAllocator +: +: +dispose +encoders { } -command -encoders " self . diff --git a/third_party/rust/wgpu-core/src/device/queue.rs b/third_party/rust/wgpu-core/src/device/queue.rs index 21c3a8b7f187..0588ba080845 100644 --- a/third_party/rust/wgpu-core/src/device/queue.rs +++ b/third_party/rust/wgpu-core/src/device/queue.rs @@ -26,6 +26,7 @@ crate : : { +api_log command : : @@ -96,6 +97,7 @@ StagingBuffer Texture TextureInner } +resource_log track FastHashMap SubmissionIndex @@ -2539,6 +2541,30 @@ write_buffer " ) ; +api_log +! +( +" +Queue +: +: +write_buffer +{ +buffer_id +: +? +} +{ +} +bytes +" +data +. +len +( +) +) +; let hub = @@ -3053,21 +3079,20 @@ assign staging_buffer ) ; -log -: -: -info +resource_log ! ( " -Created -StagingBuffer +Queue +: +: +create_staging_buffer { +id : ? } " -id ) ; Ok @@ -4185,6 +4210,29 @@ write_texture " ) ; +api_log +! +( +" +Queue +: +: +write_texture +{ +: +? +} +{ +size +: +? +} +" +destination +. +texture +) +; let hub = @@ -7300,10 +7348,7 @@ submit " ) ; -log -: -: -trace +api_log ! ( " @@ -9757,7 +9802,6 @@ device . maintain ( -hub fence wgt : @@ -10015,10 +10059,7 @@ Result InvalidQueue > { -log -: -: -trace +api_log ! ( " diff --git a/third_party/rust/wgpu-core/src/device/resource.rs b/third_party/rust/wgpu-core/src/device/resource.rs index 327dcdbb4347..9a7e371f775f 100644 --- a/third_party/rust/wgpu-core/src/device/resource.rs +++ b/third_party/rust/wgpu-core/src/device/resource.rs @@ -117,6 +117,7 @@ Texture TextureView TextureViewNotRenderableReason } +resource_log storage : : @@ -1193,18 +1194,14 @@ mut self ) { -log -: -: -info +resource_log ! ( " -Destroying +Destroy +raw Device { -: -? } " self @@ -1592,18 +1589,6 @@ Adapter A > > -alignments -: -hal -: -: -Alignments -downlevel -: -wgt -: -: -DownlevelCapabilities desc : & @@ -1957,6 +1942,36 @@ COPY_SRC ) ; } +let +alignments += +adapter +. +raw +. +capabilities +. +alignments +. +clone +( +) +; +let +downlevel += +adapter +. +raw +. +capabilities +. +downlevel +. +clone +( +) +; Ok ( Self @@ -2233,7 +2248,7 @@ limits : desc . -limits +required_limits . clone ( @@ -2242,7 +2257,7 @@ features : desc . -features +required_features downlevel instance_flags pending_writes @@ -2501,13 +2516,6 @@ this ' this self -hub -: -& -Hub -< -A -> fence : & @@ -2663,7 +2671,6 @@ life_tracker . triage_suspected ( -hub & self . @@ -2884,7 +2891,6 @@ life_tracker . handle_mapping ( -hub self . raw @@ -5342,19 +5348,14 @@ continue ; } if +! +check_texture_view_format_compatible +( desc . format -. -remove_srgb_suffix -( -) -! -= +* format -. -remove_srgb_suffix -( ) { return @@ -5691,6 +5692,21 @@ size . depth_or_array_layers { +macro_rules +! +push_clear_view +{ +( +format +: +expr +plane +: +expr +) += +> +{ let desc = @@ -5704,8 +5720,6 @@ label clear_label format : -desc -. format dimension usage @@ -5744,6 +5758,9 @@ Some 1 ) } +plane +: +plane } ; clear_views @@ -5781,6 +5798,68 @@ from ) ; } +; +} +if +desc +. +format += += +wgt +: +: +TextureFormat +: +: +NV12 +{ +push_clear_view +! +( +wgt +: +: +TextureFormat +: +: +R8Unorm +Some +( +0 +) +) +; +push_clear_view +! +( +wgt +: +: +TextureFormat +: +: +Rg8Unorm +Some +( +1 +) +) +; +} +else +{ +push_clear_view +! +( +desc +. +format +None +) +; +} +} } resource : @@ -6765,6 +6844,20 @@ layer_end ; } ; +validate_texture_view_plane +( +texture +. +desc +. +format +resolved_format +desc +. +plane +) +? +; / / https @@ -7306,6 +7399,11 @@ usage range : resolved_range +plane +: +desc +. +plane } ; let @@ -13075,9 +13173,8 @@ pub_usage internal_use ) = -Self -: -: +self +. texture_use_parameters ( binding @@ -13232,9 +13329,8 @@ pub_usage internal_use ) = -Self -: -: +self +. texture_use_parameters ( binding @@ -13754,6 +13850,13 @@ crate fn texture_use_parameters ( +self +: +& +Arc +< +Self +> binding : u32 @@ -13930,6 +14033,12 @@ range . aspect ) +Some +( +self +. +features +) ) . unwrap @@ -15035,7 +15144,7 @@ hal PipelineLayoutFlags : : -BASE_VERTEX_INSTANCE +FIRST_VERTEX_INSTANCE bind_group_layouts : & @@ -20060,6 +20169,127 @@ pub crate ) fn +get_texture_format_features +( +& +self +adapter +: +& +Adapter +< +A +> +format +: +TextureFormat +) +- +> +wgt +: +: +TextureFormatFeatures +{ +/ +/ +Variant +of +adapter +. +get_texture_format_features +that +takes +device +features +into +account +use +wgt +: +: +TextureFormatFeatureFlags +as +tfsc +; +let +mut +format_features += +adapter +. +get_texture_format_features +( +format +) +; +if +( +format += += +TextureFormat +: +: +R32Float +| +| +format += += +TextureFormat +: +: +Rg32Float +| +| +format += += +TextureFormat +: +: +Rgba32Float +) +& +& +! +self +. +features +. +contains +( +wgt +: +: +Features +: +: +FLOAT32_FILTERABLE +) +{ +format_features +. +flags +. +set +( +tfsc +: +: +FILTERABLE +false +) +; +} +format_features +} +pub +( +crate +) +fn describe_format_features ( & @@ -20165,10 +20395,11 @@ downlevel { Ok ( -adapter +self . get_texture_format_features ( +adapter format ) ) @@ -21191,3 +21422,191 @@ self info } } +fn +check_texture_view_format_compatible +( +texture_format +: +TextureFormat +view_format +: +TextureFormat +) +- +> +bool +{ +use +TextureFormat +: +: +* +; +match +( +texture_format +view_format +) +{ +( +NV12 +R8Unorm +| +R8Uint +| +Rg8Unorm +| +Rg8Uint +) += +> +true +_ += +> +texture_format +. +remove_srgb_suffix +( +) += += +view_format +. +remove_srgb_suffix +( +) +} +} +fn +validate_texture_view_plane +( +texture_format +: +TextureFormat +view_format +: +TextureFormat +plane +: +Option +< +u32 +> +) +- +> +Result +< +( +) +resource +: +: +CreateTextureViewError +> +{ +use +TextureFormat +: +: +* +; +match +( +texture_format +view_format +plane +) +{ +( +NV12 +R8Unorm +| +R8Uint +Some +( +0 +) +) += +> +Ok +( +( +) +) +( +NV12 +Rg8Unorm +| +Rg8Uint +Some +( +1 +) +) += +> +Ok +( +( +) +) +( +NV12 +_ +_ +) += +> +{ +Err +( +resource +: +: +CreateTextureViewError +: +: +InvalidTextureViewPlane +{ +plane +view_format +} +) +} +( +_ +_ +Some +( +_ +) +) += +> +Err +( +resource +: +: +CreateTextureViewError +: +: +InvalidTextureViewPlaneOnNonplanarTexture +{ +plane +texture_format +} +) +_ += +> +Ok +( +( +) +) +} +} diff --git a/third_party/rust/wgpu-core/src/device/trace.rs b/third_party/rust/wgpu-core/src/device/trace.rs index 8b2f202a38ed..e8bff840887f 100644 --- a/third_party/rust/wgpu-core/src/device/trace.rs +++ b/third_party/rust/wgpu-core/src/device/trace.rs @@ -986,7 +986,7 @@ Option wgt : : -BufferSize +BufferAddress > } ClearTexture diff --git a/third_party/rust/wgpu-core/src/global.rs b/third_party/rust/wgpu-core/src/global.rs index c773b366d7a8..0522d27b179d 100644 --- a/third_party/rust/wgpu-core/src/global.rs +++ b/third_party/rust/wgpu-core/src/global.rs @@ -57,6 +57,7 @@ registry Registry RegistryReport } +resource_log storage : : @@ -1160,15 +1161,14 @@ drop " ) ; -log -: -: -info +resource_log ! ( " -Destroying Global +: +: +drop " ) ; diff --git a/third_party/rust/wgpu-core/src/id.rs b/third_party/rust/wgpu-core/src/id.rs index 430c5c42f6a5..2f165e684b11 100644 --- a/third_party/rust/wgpu-core/src/id.rs +++ b/third_party/rust/wgpu-core/src/id.rs @@ -1308,44 +1308,102 @@ unzip ( ) ; -formatter -. -debug_struct -( +let +backend += +match +backend +{ +Backend +: +: +Vulkan += +> " -Id +vk " -) -. -field -( +Backend +: +: +Metal += +> " -index +mtl " -& -index -) -. -field -( +Backend +: +: +Dx12 += +> " -epoch +d3d12 " -& -epoch -) -. -field +Backend +: +: +Dx11 += +> +" +d3d11 +" +Backend +: +: +Gl += +> +" +gl +" +Backend +: +: +BrowserWebGpu += +> +" +webgpu +" +Backend +: +: +Empty += +> +" +_ +" +} +; +write +! ( +formatter " +Id +( +{ +index +} +{ +epoch +} +{ backend +} +) " -& -backend ) -. -finish +? +; +Ok ( +( +) ) } } diff --git a/third_party/rust/wgpu-core/src/instance.rs b/third_party/rust/wgpu-core/src/instance.rs index 1889df18d4ea..f246015e0048 100644 --- a/third_party/rust/wgpu-core/src/instance.rs +++ b/third_party/rust/wgpu-core/src/instance.rs @@ -16,6 +16,7 @@ any_surface : : AnySurface +api_log device : : @@ -66,6 +67,7 @@ Resource ResourceInfo ResourceType } +resource_log LabelHelpers DOWNLEVEL_WARNING_MESSAGE } @@ -2208,10 +2210,7 @@ A RequestDeviceError > { -log -: -: -info +api_log ! ( " @@ -2222,16 +2221,6 @@ create_device " ) ; -let -caps -= -& -self -. -raw -. -capabilities -; if let Ok @@ -2252,20 +2241,6 @@ hal_device . queue self -caps -. -alignments -. -clone -( -) -caps -. -downlevel -. -clone -( -) desc trace_path instance_flags @@ -2393,7 +2368,7 @@ contains ( desc . -features +required_features ) { return @@ -2406,7 +2381,7 @@ UnsupportedFeature ( desc . -features +required_features - self . @@ -2533,7 +2508,7 @@ preconditions if desc . -features +required_features . contains ( @@ -2623,7 +2598,7 @@ check_limits & desc . -limits +required_limits & caps . @@ -2662,11 +2637,11 @@ open ( desc . -features +required_features & desc . -limits +required_limits ) } . @@ -5140,10 +5115,7 @@ drop " ) ; -log -: -: -info +api_log ! ( " @@ -5791,10 +5763,7 @@ enumerate_adapters " ) ; -log -: -: -trace +api_log ! ( " @@ -6230,21 +6199,18 @@ scope Instance : : -pick_adapter +request_adapter " ) ; -log -: -: -trace +api_log ! ( " Instance : : -pick_adapter +request_adapter " ) ; @@ -7828,10 +7794,7 @@ unreachable ) } ; -log -: -: -info +resource_log ! ( " @@ -8304,10 +8267,7 @@ drop " ) ; -log -: -: -trace +api_log ! ( " @@ -8483,10 +8443,7 @@ request_device " ) ; -log -: -: -trace +api_log ! ( " @@ -8637,10 +8594,7 @@ assign device ) ; -log -: -: -info +resource_log ! ( " @@ -8696,10 +8650,7 @@ assign queue ) ; -log -: -: -info +resource_log ! ( " @@ -9027,10 +8978,7 @@ assign device ) ; -log -: -: -info +resource_log ! ( " @@ -9086,10 +9034,7 @@ assign queue ) ; -log -: -: -info +resource_log ! ( " diff --git a/third_party/rust/wgpu-core/src/lib.rs b/third_party/rust/wgpu-core/src/lib.rs index 9f0a810519d1..aafc3791cfce 100644 --- a/third_party/rust/wgpu-core/src/lib.rs +++ b/third_party/rust/wgpu-core/src/lib.rs @@ -2606,6 +2606,182 @@ other } ; } +# +[ +cfg +( +feature += +" +api_log_info +" +) +] +macro_rules +! +api_log +{ +( +( +arg +: +tt +) ++ +) += +> +( +log +: +: +info +! +( +( +arg +) ++ +) +) +} +# +[ +cfg +( +not +( +feature += +" +api_log_info +" +) +) +] +macro_rules +! +api_log +{ +( +( +arg +: +tt +) ++ +) += +> +( +log +: +: +trace +! +( +( +arg +) ++ +) +) +} +pub +( +crate +) +use +api_log +; +# +[ +cfg +( +feature += +" +resource_log_info +" +) +] +macro_rules +! +resource_log +{ +( +( +arg +: +tt +) ++ +) += +> +( +log +: +: +info +! +( +( +arg +) ++ +) +) +} +# +[ +cfg +( +not +( +feature += +" +resource_log_info +" +) +) +] +macro_rules +! +resource_log +{ +( +( +arg +: +tt +) ++ +) += +> +( +log +: +: +trace +! +( +( +arg +) ++ +) +) +} +pub +( +crate +) +use +resource_log +; / / / diff --git a/third_party/rust/wgpu-core/src/pipeline.rs b/third_party/rust/wgpu-core/src/pipeline.rs index f6398b74abb7..a820e79c7cb8 100644 --- a/third_party/rust/wgpu-core/src/pipeline.rs +++ b/third_party/rust/wgpu-core/src/pipeline.rs @@ -66,6 +66,7 @@ Resource ResourceInfo ResourceType } +resource_log validation Label } @@ -464,18 +465,29 @@ mut self ) { -log -: -: -info +if +let +Some +( +raw +) += +self +. +raw +. +take +( +) +{ +resource_log ! ( " -Destroying +Destroy +raw ShaderModule { -: -? } " self @@ -487,21 +499,6 @@ label ) ) ; -if -let -Some -( -raw -) -= -self -. -raw -. -take -( -) -{ # [ cfg @@ -2032,18 +2029,29 @@ mut self ) { -log -: -: -info +if +let +Some +( +raw +) += +self +. +raw +. +take +( +) +{ +resource_log ! ( " -Destroying +Destroy +raw ComputePipeline { -: -? } " self @@ -2055,21 +2063,6 @@ label ) ) ; -if -let -Some -( -raw -) -= -self -. -raw -. -take -( -) -{ unsafe { use @@ -4347,18 +4340,29 @@ mut self ) { -log -: -: -info +if +let +Some +( +raw +) += +self +. +raw +. +take +( +) +{ +resource_log ! ( " -Destroying +Destroy +raw RenderPipeline { -: -? } " self @@ -4370,21 +4374,6 @@ label ) ) ; -if -let -Some -( -raw -) -= -self -. -raw -. -take -( -) -{ unsafe { use diff --git a/third_party/rust/wgpu-core/src/present.rs b/third_party/rust/wgpu-core/src/present.rs index 1e66b7c5ad30..425a21347554 100644 --- a/third_party/rust/wgpu-core/src/present.rs +++ b/third_party/rust/wgpu-core/src/present.rs @@ -540,6 +540,54 @@ error ( " Surface +width +and +height +must +be +within +the +maximum +supported +texture +size +. +Requested +was +( +{ +width +} +height +) +maximum +extent +is +{ +max_texture_dimension_2d +} +. +" +) +] +TooLarge +{ +width +: +u32 +height +: +u32 +max_texture_dimension_2d +: +u32 +} +# +[ +error +( +" +Surface does not support @@ -1353,6 +1401,9 @@ ImageSubresourceRange default ( ) +plane +: +None } ; let @@ -1569,7 +1620,7 @@ texture log : : -info +debug ! ( " diff --git a/third_party/rust/wgpu-core/src/registry.rs b/third_party/rust/wgpu-core/src/registry.rs index 44e3318acac7..a94d6d2ad468 100644 --- a/third_party/rust/wgpu-core/src/registry.rs +++ b/third_party/rust/wgpu-core/src/registry.rs @@ -883,34 +883,6 @@ pub crate ) fn -contains -( -& -self -id -: -I -) -- -> -bool -{ -self -. -read -( -) -. -contains -( -id -) -} -pub -( -crate -) -fn try_get ( & diff --git a/third_party/rust/wgpu-core/src/resource.rs b/third_party/rust/wgpu-core/src/resource.rs index b44f36c0f2c3..271d677b505f 100644 --- a/third_party/rust/wgpu-core/src/resource.rs +++ b/third_party/rust/wgpu-core/src/resource.rs @@ -73,6 +73,7 @@ BufferInitTracker TextureInitTracker } resource +resource_log track : : @@ -561,26 +562,6 @@ free id ) ; -log -: -: -info -! -( -" -Freeing -{ -: -? -} -" -self -. -label -( -) -) -; } } } @@ -2853,18 +2834,29 @@ mut self ) { -log -: -: -info +if +let +Some +( +raw +) += +self +. +raw +. +take +( +) +{ +resource_log ! ( " -Destroying +Destroy +raw Buffer { -: -? } " self @@ -2876,21 +2868,6 @@ label ) ) ; -if -let -Some -( -raw -) -= -self -. -raw -. -take -( -) -{ unsafe { use @@ -4537,29 +4514,6 @@ mut self ) { -log -: -: -info -! -( -" -Destroying -StagingBuffer -{ -: -? -} -" -self -. -info -. -label -( -) -) -; if let Some @@ -4579,6 +4533,25 @@ take ( ) { +resource_log +! +( +" +Destroy +raw +StagingBuffer +{ +} +" +self +. +info +. +label +( +) +) +; unsafe { use @@ -5107,18 +5080,14 @@ mut self ) { -log -: -: -info +resource_log ! ( " -Destroying +Destroy +raw Texture { -: -? } " self @@ -7293,6 +7262,23 @@ wgt : : ImageSubresourceRange +/ +/ +/ +The +plane +of +the +texture +view +. +pub +plane +: +Option +< +u32 +> } # [ @@ -7727,18 +7713,29 @@ mut self ) { -log -: -: -info +if +let +Some +( +raw +) += +self +. +raw +. +take +( +) +{ +resource_log ! ( " -Destroying +Destroy +raw TextureView { -: -? } " self @@ -7750,21 +7747,6 @@ label ) ) ; -if -let -Some -( -raw -) -= -self -. -raw -. -take -( -) -{ unsafe { use @@ -8280,6 +8262,88 @@ wgt : TextureFormat } +# +[ +error +( +" +Invalid +texture +view +plane +{ +plane +: +? +} +with +view +format +{ +view_format +: +? +} +" +) +] +InvalidTextureViewPlane +{ +plane +: +Option +< +u32 +> +view_format +: +wgt +: +: +TextureFormat +} +# +[ +error +( +" +Invalid +texture +view +plane +{ +plane +: +? +} +on +non +- +planar +texture +{ +texture_format +: +? +} +" +) +] +InvalidTextureViewPlaneOnNonplanarTexture +{ +plane +: +Option +< +u32 +> +texture_format +: +wgt +: +: +TextureFormat +} } # [ @@ -8803,18 +8867,14 @@ mut self ) { -log -: -: -info +resource_log ! ( " -Destroying +Destroy +raw Sampler { -: -? } " self @@ -9513,18 +9573,14 @@ mut self ) { -log -: -: -info +resource_log ! ( " -Destroying +Destroy +raw QuerySet { -: -? } " self diff --git a/third_party/rust/wgpu-core/src/storage.rs b/third_party/rust/wgpu-core/src/storage.rs index b90c513b14e2..98ba85773a7b 100644 --- a/third_party/rust/wgpu-core/src/storage.rs +++ b/third_party/rust/wgpu-core/src/storage.rs @@ -131,10 +131,6 @@ yet . Destroyed ( -Arc -< -T -> Epoch ) / @@ -536,7 +532,6 @@ Element : Destroyed ( -_ storage_epoch ) | @@ -1189,7 +1184,6 @@ Element : Destroyed ( -_ storage_epoch ) = @@ -1323,7 +1317,7 @@ T log : : -info +trace ! ( " @@ -1397,7 +1391,7 @@ str log : : -info +trace ! ( " @@ -1663,8 +1657,8 @@ Element : Occupied ( -. -. +_ +e ) = slot @@ -1692,7 +1686,10 @@ slot Element : : -Vacant +Destroyed +( +e +) ) { debug_assert_eq @@ -1702,53 +1699,19 @@ storage_epoch epoch ) ; -* -slot -= -Element -: -: -Destroyed +return +Ok ( value -storage_epoch ) ; } } -if -let -Element -: -: -Destroyed -( -ref -value -. -. -) -= -* -slot -{ -Ok -( -value -. -clone -( -) -) -} -else -{ Err ( InvalidId ) } -} pub ( crate @@ -1770,7 +1733,7 @@ T log : : -info +trace ! ( " @@ -1856,7 +1819,7 @@ T log : : -info +trace ! ( " @@ -1923,13 +1886,26 @@ Occupied value storage_epoch ) -| += +> +{ +assert_eq +! +( +epoch +storage_epoch +) +; +Some +( +value +) +} Element : : Destroyed ( -value storage_epoch ) = @@ -1942,10 +1918,7 @@ epoch storage_epoch ) ; -Some -( -value -) +None } Element : diff --git a/third_party/rust/wgpu-core/src/track/buffer.rs b/third_party/rust/wgpu-core/src/track/buffer.rs index 6b0158a02b40..1275cb515c13 100644 --- a/third_party/rust/wgpu-core/src/track/buffer.rs +++ b/third_party/rust/wgpu-core/src/track/buffer.rs @@ -1915,7 +1915,9 @@ A / / / -Removes +Try +to +remove the buffer id @@ -2068,25 +2070,19 @@ reference / / / -Return +Returns true if -this -tracker -contained the -buffer -id -. -This -/ -/ -/ -implies -that -we +resource +was removed -it +or +if +not +existing +in +metadata . / / @@ -2150,9 +2146,6 @@ self id : BufferId -external_count -: -usize ) - > @@ -2219,42 +2212,47 @@ index ; / / +RefCount 2 -ref -count -if -only -in -Device -Tracker +means +that +resource +is +hold +just +by +DeviceTracker and +this suspected resource itself -and +/ +/ +so +it +' +s already +been released from user -/ -/ +and so +it +' +s not -appearing -in +inside Registry -let -min_ref_count -= -1 -+ -external_count -; +\ +Storage if existing_ref_count < = -min_ref_count +2 { self . @@ -2268,7 +2266,7 @@ index log : : -info +trace ! ( " @@ -2294,7 +2292,7 @@ else log : : -info +trace ! ( " @@ -2314,10 +2312,13 @@ id existing_ref_count ) ; +return +false +; } } } -false +true } } impl diff --git a/third_party/rust/wgpu-core/src/track/metadata.rs b/third_party/rust/wgpu-core/src/track/metadata.rs index c5ecc277cf96..bc04f2fa3990 100644 --- a/third_party/rust/wgpu-core/src/track/metadata.rs +++ b/third_party/rust/wgpu-core/src/track/metadata.rs @@ -992,20 +992,10 @@ strong_count ( self . -resources -. -get_unchecked +get_resource_unchecked ( index ) -. -as_ref -( -) -. -unwrap_unchecked -( -) ) } } diff --git a/third_party/rust/wgpu-core/src/track/mod.rs b/third_party/rust/wgpu-core/src/track/mod.rs index c3823a36c595..f05be7298e75 100644 --- a/third_party/rust/wgpu-core/src/track/mod.rs +++ b/third_party/rust/wgpu-core/src/track/mod.rs @@ -3785,9 +3785,6 @@ self id : Id -external_count -: -usize ) - > diff --git a/third_party/rust/wgpu-core/src/track/stateless.rs b/third_party/rust/wgpu-core/src/track/stateless.rs index 6d75012532a4..e5dae73bca21 100644 --- a/third_party/rust/wgpu-core/src/track/stateless.rs +++ b/third_party/rust/wgpu-core/src/track/stateless.rs @@ -68,6 +68,7 @@ resource : : Resource +resource_log storage : : @@ -622,7 +623,9 @@ T / / / -Removes +Try +to +remove the given resource @@ -659,6 +662,12 @@ the resource was removed +or +if +not +existing +in +metadata . / / @@ -694,9 +703,6 @@ self id : Id -external_count -: -usize ) - > @@ -730,6 +736,22 @@ return false ; } +resource_log +! +( +" +StatelessTracker +: +: +remove_abandoned +{ +id +: +? +} +" +) +; self . tracker_assert_in_bounds @@ -763,42 +785,47 @@ index ; / / +RefCount 2 -ref -count -if -only -in -Device -Tracker +means +that +resource +is +hold +just +by +DeviceTracker and +this suspected resource itself -and +/ +/ +so +it +' +s already +been released from user -/ -/ +and so +it +' +s not -appearing -in +inside Registry -let -min_ref_count -= -1 -+ -external_count -; +\ +Storage if existing_ref_count < = -min_ref_count +2 { self . @@ -812,7 +839,7 @@ index log : : -info +trace ! ( " @@ -843,7 +870,7 @@ else log : : -info +trace ! ( " @@ -868,10 +895,13 @@ id existing_ref_count ) ; +return +false +; } } } -false +true } } impl diff --git a/third_party/rust/wgpu-core/src/track/texture.rs b/third_party/rust/wgpu-core/src/track/texture.rs index 35b251897758..93733df549a9 100644 --- a/third_party/rust/wgpu-core/src/track/texture.rs +++ b/third_party/rust/wgpu-core/src/track/texture.rs @@ -2676,7 +2676,9 @@ A / / / -Removes +Try +to +remove the given resource @@ -2713,6 +2715,12 @@ the resource was removed +or +if +not +existing +in +metadata . / / @@ -2748,9 +2756,6 @@ self id : TextureId -external_count -: -usize ) - > @@ -2817,42 +2822,47 @@ index ; / / +RefCount 2 -ref -count -if -only -in -Device -Tracker +means +that +resource +is +hold +just +by +DeviceTracker and +this suspected resource itself -and +/ +/ +so +it +' +s already +been released from user -/ -/ +and so +it +' +s not -appearing -in +inside Registry -let -min_ref_count -= -1 -+ -external_count -; +\ +Storage if existing_ref_count < = -min_ref_count +2 { self . @@ -2890,7 +2900,7 @@ index log : : -info +trace ! ( " @@ -2916,7 +2926,7 @@ else log : : -info +trace ! ( " @@ -2936,10 +2946,13 @@ id existing_ref_count ) ; +return +false +; } } } -false +true } } impl diff --git a/third_party/rust/wgpu-core/src/validation.rs b/third_party/rust/wgpu-core/src/validation.rs index 345a4b74bf78..657551076d5a 100644 --- a/third_party/rust/wgpu-core/src/validation.rs +++ b/third_party/rust/wgpu-core/src/validation.rs @@ -3911,6 +3911,22 @@ naga ScalarKind : : +AbstractInt +| +naga +: +: +ScalarKind +: +: +AbstractFloat +| +naga +: +: +ScalarKind +: +: Bool = > @@ -5112,6 +5128,21 @@ format Tf : : +NV12 += +> +panic +! +( +" +Unexpected +nv12 +format +" +) +Tf +: +: Rgb9e5Ufloat = > diff --git a/third_party/rust/wgpu-hal/.cargo-checksum.json b/third_party/rust/wgpu-hal/.cargo-checksum.json index da28a7cebfa4..151627678324 100644 --- a/third_party/rust/wgpu-hal/.cargo-checksum.json +++ b/third_party/rust/wgpu-hal/.cargo-checksum.json @@ -11,7 +11,7 @@ toml " : " -af8f5b97c66922b8f68e5214102cc79befc3a3a86984a611a3bdc01fae168523 +f472b730bbef76aa4770fd53b53535c1d0773145c8a40aac2deb6e7465ff70bc " " LICENSE @@ -38,7 +38,7 @@ md " : " -78377f5876fafd77963eff7e3c2ba3a7e3ad5cf9201b09ed5612e49c2288eb18 +099ee611a911dc19330a61bffcde13663929a51b25ac528ee33ea796d695491e " " examples @@ -51,7 +51,7 @@ rs " : " -360828f6f103ce966a152ceaff50087b59d0eac580fac12c8f89850024ccc233 +c74696fd871200a46e3592ce5a662c42d9587c13b7def75c5cac4c34d9685ad5 " " examples @@ -92,7 +92,7 @@ rs " : " -33f536693b08a9f00b0358416be8f368894bf92a2e673b16622fa9c244854c91 +81210e7603f5304fa1dc294f984eacf27e18df7d3f228063f6acb0d7985c37cd " " src @@ -107,7 +107,7 @@ rs " : " -536a6ff638ce32bdbf7cd697270f563c14f2c8cc013bb0e9565e06dc5127730a +3cd184da7712d1cea10cad740afb4c9dbdb40b69d7386d56dbaa15f4853c6ac7 " " src @@ -122,7 +122,7 @@ rs " : " -baad31f4529f1cf9d10519c4cceccbb21ed9bba7d7ea99e4789c1d5ddf3a450b +fc68c6211c82a912b454c3004185f46a1416bce38ddc5b0555e0def6539cfb27 " " src @@ -221,7 +221,7 @@ rs " : " -cacb8243f9107f63bc3247a76b3d28adc3b87d79ffee0af90214a483ab51285b +173e99507610282a7858c142ffe2b9755dac0d61bcaed7ae69394002d476c4f6 " " src @@ -234,7 +234,7 @@ rs " : " -e4959ec3dc6f8494844e01b56ba162ba91270c9c9a52e83315c8730fcfe188b9 +3a329369bbd9deeb2fbe3c274a5a5d5f0d2da9eeb64b76592e922446e52c5a51 " " src @@ -299,7 +299,7 @@ rs " : " -03763cc928b38a4153ab91d7a6ab7d38e2f64c7590f2e17a29c56e0a93b1284f +33c4b790c22115d68db11883a8fb8da194fba0937636a56cc779b7bf48a5ce44 " " src @@ -312,7 +312,7 @@ rs " : " -8a99d028ce379f14c19d88069c91a58d6fd7b1957e0a114c369f51a0bfaee1e9 +9c6b24f7a09c54b61ac36d0cbd74b2ff8e5c5474ee834f06f39cf18caf95b7d2 " " src @@ -351,7 +351,7 @@ rs " : " -0ac995a92acd8cbe160f58f7347ed50ce5c0d16a3da496127aff66eecca765e7 +6baf4b32df1f91a7d2060b00a14850530b857de1147c8cf1d85abd6f5e90e4c2 " " src @@ -377,7 +377,7 @@ rs " : " -9c5c3babcdfc0daa81ba85a2729020e102e5bcc7c2ec35d3d228ccf477775edf +fe9e7ed1786c7142fa5bf04e9ad2ee729fdd92c926bb734afa75651206cf737d " " src @@ -429,7 +429,7 @@ rs " : " -c09241520377e6a47ad8822c69075e6e16e6c558e18bb64398c8d7424fc57dcf +7db9595d0f67c441605ef5830555c27fc2e9c9c6aa0151baf52c9d04fc536617 " " src @@ -440,7 +440,7 @@ rs " : " -8288689e0016c60e58d1c3e24fe3a9ef247bb23961c9f01482a0bf21870379a0 +de72a7dcbd2b562195a3a49a4065008cb4402381b8dbb83ef348398c3f9d920e " " src @@ -453,7 +453,7 @@ rs " : " -6e38936a7a3f01f9aa13b6568e495499b320d009f33146cf978cf57bcd795013 +32f658df60a226fb4f3ff242267f442945c9c9670d7a5692301c3f90cdd1f5cf " " src @@ -466,7 +466,7 @@ rs " : " -9c4f2e474d0fd512f4d8da2a42ca309f9ec3c7bbf472d043b59a180cb3b0f459 +7d6a760c721e759c6c32998b5a42466fe35bcff5ecc109af42b2aaec85e444ea " " src @@ -479,7 +479,7 @@ rs " : " -23f7f82b74fb01dc09cf9b696a6977d993e65c4f700b3029984ff2dbdc9b3dda +9cd65b70c1a2f92f22a83dda825e175f367cbb3d6201a31d90e84aaf63e63d9b " " src @@ -492,7 +492,7 @@ rs " : " -8e13133b398f25850e342777edd06076188644a1013004b2a08e00845d62e6a6 +b19f2437e403e08511ff341efc63e55c78fcdeffa3785d02a892a743a26a3663 " " src @@ -531,7 +531,7 @@ rs " : " -43b3e9d03f9eca064832dd307e4b8b8f1d2d3bbcdad21c87af3854f9bd479e3d +e9a232ffb9331cd3873ea7afd4bd39e07503873d592bacd576efebd58e452323 " " src @@ -544,7 +544,7 @@ rs " : " -ee8e9673b4856baa23026009ee41fe92c5c91503b07c484199229334a99f9e0c +fe795add7b32ae4cd89e40db93e5bae62b6c7bc5741c71f21d292bd0a511de58 " " src @@ -641,7 +641,7 @@ rs " : " -04b61b4d07fc001fd3c2d95d7577bc485e7ac67406e7052681222d32233cc0ae +072e3f2a781b9cba47d17e7fe3954697d6328cb48ecd2dd0f0f2f500efefe51a " " src @@ -654,7 +654,7 @@ rs " : " -9d200608a3f931ee2d37f085809c761eb809bae2058f8caa25c592c7d2c19752 +9ae2496b3a2df3263f2f5a53a6bd4245800c53072673c3444c274c7fffa2a8dc " " src @@ -667,7 +667,7 @@ rs " : " -95512642ff903a57b661b10b72b44c065a760a3096bcb2aabbd9977e6dba0d5b +702edebb7aff60acc67d6e183f2dad999f2528b0f00bccc25197fb01911a3b6e " " src @@ -706,7 +706,7 @@ rs " : " -3c49207a7cc88b75785aa4886147121192d19d01cdc621319aff36b3659fa98c +e248de570dddfad70a83ef1788d1a15b037b0e861937c8eff00dd0c09dfae82d " " src @@ -745,7 +745,7 @@ rs " : " -d9af751f16d30b3d129a7481d1f529ef53cc7c6e0ca0b6f25181f8449f23b6fd +5a8d9a2757c9ec86ba7f1ac7b79cf577830908c6fd9935ea1af7519457d85562 " " src @@ -758,7 +758,7 @@ rs " : " -e10346068cdf97f50b98b5d7481b09f601319843cf843206c95c597fad36144e +5f0da371d3189ce42c141039a3a435717c12077f5d09226af61b5c51e4bde68c " " src @@ -771,7 +771,7 @@ rs " : " -63abaed541f7f5263f5e3a27e3e7fad419cb32c7b8af25081aa547add12087a8 +ee41a6d5a17c9474296b8e850b5dcb10452c8077e3ff70a68351a374726115b6 " " src @@ -784,7 +784,7 @@ rs " : " -1557ee3b93a085b1704b858a42a7b3b8c742c20b87ab325e9f0096ec5b97bc59 +c83be51f540e5a3294eb755ec8c787edc204aaea727d62b66887d7f88775a041 " " src @@ -797,7 +797,7 @@ rs " : " -e16d2e849b2ead8d83d354946bbffd03c26e2b024b07fe8b59c3ea47093a0a12 +d9a084ac91a2b541b14d8ea565a7a581d281e54ec2828b64e5be2989e0113ed7 " " src diff --git a/third_party/rust/wgpu-hal/Cargo.toml b/third_party/rust/wgpu-hal/Cargo.toml index c55df4abae6f..0f1083546e1d 100644 --- a/third_party/rust/wgpu-hal/Cargo.toml +++ b/third_party/rust/wgpu-hal/Cargo.toml @@ -552,7 +552,7 @@ version . 29 . -2 +4 " features = @@ -856,7 +856,7 @@ sys . 3 . -65 +66 " wasm - @@ -911,7 +911,7 @@ version . 3 . -64 +66 " features = diff --git a/third_party/rust/wgpu-hal/README.md b/third_party/rust/wgpu-hal/README.md index f338fb3ebdc3..8450d4f9dd81 100644 --- a/third_party/rust/wgpu-hal/README.md +++ b/third_party/rust/wgpu-hal/README.md @@ -193,7 +193,7 @@ it . The API -accept +accepts iterators in order diff --git a/third_party/rust/wgpu-hal/examples/halmark/main.rs b/third_party/rust/wgpu-hal/examples/halmark/main.rs index 9266b617b883..c2e7a999f4d8 100644 --- a/third_party/rust/wgpu-hal/examples/halmark/main.rs +++ b/third_party/rust/wgpu-hal/examples/halmark/main.rs @@ -2877,6 +2877,9 @@ ImageSubresourceRange default ( ) +plane +: +None } ; let @@ -4347,6 +4350,9 @@ ImageSubresourceRange default ( ) +plane +: +None } ; let diff --git a/third_party/rust/wgpu-hal/examples/raw-gles.rs b/third_party/rust/wgpu-hal/examples/raw-gles.rs index 627bf1eb287d..e75a5a7ebc45 100644 --- a/third_party/rust/wgpu-hal/examples/raw-gles.rs +++ b/third_party/rust/wgpu-hal/examples/raw-gles.rs @@ -1100,6 +1100,9 @@ ImageSubresourceRange default ( ) +plane +: +None } ) . diff --git a/third_party/rust/wgpu-hal/src/auxil/dxgi/conv.rs b/third_party/rust/wgpu-hal/src/auxil/dxgi/conv.rs index 436e2d76c0b0..1cdb1e316406 100644 --- a/third_party/rust/wgpu-hal/src/auxil/dxgi/conv.rs +++ b/third_party/rust/wgpu-hal/src/auxil/dxgi/conv.rs @@ -501,6 +501,13 @@ DXGI_FORMAT_D32_FLOAT_S8X24_UINT Tf : : +NV12 += +> +DXGI_FORMAT_NV12 +Tf +: +: Bc1RgbaUnorm = > diff --git a/third_party/rust/wgpu-hal/src/auxil/dxgi/exception.rs b/third_party/rust/wgpu-hal/src/auxil/dxgi/exception.rs index 7ab25076a992..96b6e3ce1ca9 100644 --- a/third_party/rust/wgpu-hal/src/auxil/dxgi/exception.rs +++ b/third_party/rust/wgpu-hal/src/auxil/dxgi/exception.rs @@ -753,8 +753,13 @@ crate : VALIDATION_CANARY . -set +add ( +message +. +to_string +( +) ) ; } diff --git a/third_party/rust/wgpu-hal/src/dx11/adapter.rs b/third_party/rust/wgpu-hal/src/dx11/adapter.rs index 515b9e6aff3c..17c996362a9c 100644 --- a/third_party/rust/wgpu-hal/src/dx11/adapter.rs +++ b/third_party/rust/wgpu-hal/src/dx11/adapter.rs @@ -917,6 +917,74 @@ dxgi_format_b8g8r8a8_unormfcs 87 / / +float32 +- +filterable +should +always +be +available +on +dx11 +/ +/ +https +: +/ +/ +learn +. +microsoft +. +com +/ +en +- +us +/ +windows +/ +win32 +/ +direct3ddxgi +/ +format +- +support +- +for +- +direct3d +- +11 +- +0 +- +feature +- +level +- +hardware +# +dxgi_format_r32g32b32a32_floatfcs +- +2 +features +. +set +( +wgt +: +: +Features +: +: +FLOAT32_FILTERABLE +true +) +; +/ +/ / / Fill diff --git a/third_party/rust/wgpu-hal/src/dx11/command.rs b/third_party/rust/wgpu-hal/src/dx11/command.rs index 74f590857ae0..54255ecfc593 100644 --- a/third_party/rust/wgpu-hal/src/dx11/command.rs +++ b/third_party/rust/wgpu-hal/src/dx11/command.rs @@ -950,13 +950,13 @@ draw & mut self -start_vertex +first_vertex : u32 vertex_count : u32 -start_instance +first_instance : u32 instance_count @@ -976,7 +976,7 @@ draw_indexed & mut self -start_index +first_index : u32 index_count @@ -985,7 +985,7 @@ u32 base_vertex : i32 -start_instance +first_instance : u32 instance_count diff --git a/third_party/rust/wgpu-hal/src/dx12/adapter.rs b/third_party/rust/wgpu-hal/src/dx12/adapter.rs index 9054c5158152..f88e52e490aa 100644 --- a/third_party/rust/wgpu-hal/src/dx12/adapter.rs +++ b/third_party/rust/wgpu-hal/src/dx12/adapter.rs @@ -1564,6 +1564,14 @@ Features : : DUAL_SOURCE_BLENDING +| +wgt +: +: +Features +: +: +TEXTURE_FORMAT_NV12 ; / / @@ -1827,6 +1835,31 @@ bgra8unorm_storage_supported ; / / +float32 +- +filterable +should +always +be +available +on +d3d12 +features +. +set +( +wgt +: +: +Features +: +: +FLOAT32_FILTERABLE +true +) +; +/ +/ TODO : Determine @@ -1866,6 +1899,52 @@ default ( ) ; +let +mut +downlevel += +wgt +: +: +DownlevelCapabilities +: +: +default +( +) +; +/ +/ +https +: +/ +/ +github +. +com +/ +gfx +- +rs +/ +wgpu +/ +issues +/ +2471 +downlevel +. +flags +- += +wgt +: +: +DownlevelFlags +: +: +VERTEX_AND_INSTANCE_INDEX_RESPECTS_RESPECTIVE_FIRST_VALUE_IN_INDIRECT_DRAW +; Some ( crate @@ -2498,16 +2577,6 @@ unwrap ) } downlevel -: -wgt -: -: -DownlevelCapabilities -: -: -default -( -) } } ) @@ -3847,50 +3916,6 @@ swap_chain_sizes = 16 current_extent -/ -/ -TODO -: -figure -out -the -exact -bounds -extents -: -wgt -: -: -Extent3d -{ -width -: -16 -height -: -16 -depth_or_array_layers -: -1 -} -. -. -= -wgt -: -: -Extent3d -{ -width -: -4096 -height -: -4096 -depth_or_array_layers -: -1 -} usage : crate diff --git a/third_party/rust/wgpu-hal/src/dx12/command.rs b/third_party/rust/wgpu-hal/src/dx12/command.rs index 81b4bf050bf1..ac4e190cf825 100644 --- a/third_party/rust/wgpu-hal/src/dx12/command.rs +++ b/third_party/rust/wgpu-hal/src/dx12/command.rs @@ -616,10 +616,10 @@ prepare_draw & mut self -base_vertex +first_vertex : i32 -base_instance +first_instance : u32 ) @@ -740,10 +740,10 @@ RootElement : SpecialConstantBuffer { -base_vertex +first_vertex : other_vertex -base_instance +first_instance : other_instance other @@ -752,13 +752,13 @@ _ } = > -base_vertex +first_vertex ! = other_vertex | | -base_instance +first_instance ! = other_instance @@ -802,8 +802,8 @@ RootElement : SpecialConstantBuffer { -base_vertex -base_instance +first_vertex +first_instance other : 0 @@ -871,17 +871,17 @@ RootElement : SpecialConstantBuffer { -base_vertex -base_instance +first_vertex +first_instance other } = > [ -base_vertex +first_vertex as u32 -base_instance +first_instance other ] ! @@ -927,7 +927,7 @@ RootElement : SpecialConstantBuffer { -base_vertex +first_vertex : count [ @@ -935,7 +935,7 @@ count ] as i32 -base_instance +first_instance : count [ @@ -1204,8 +1204,8 @@ RootElement : SpecialConstantBuffer { -base_vertex -base_instance +first_vertex +first_instance other } = @@ -1229,7 +1229,7 @@ list set_graphics_root_constant ( index -base_vertex +first_vertex as u32 0 @@ -1240,7 +1240,7 @@ list set_graphics_root_constant ( index -base_instance +first_instance 1 ) ; @@ -1257,7 +1257,7 @@ list set_compute_root_constant ( index -base_vertex +first_vertex as u32 0 @@ -1268,7 +1268,7 @@ list set_compute_root_constant ( index -base_instance +first_instance 1 ) ; @@ -1575,10 +1575,10 @@ RootElement : SpecialConstantBuffer { -base_vertex +first_vertex : 0 -base_instance +first_instance : 0 other @@ -6937,13 +6937,13 @@ draw & mut self -start_vertex +first_vertex : u32 vertex_count : u32 -start_instance +first_instance : u32 instance_count @@ -6957,10 +6957,10 @@ self . prepare_draw ( -start_vertex +first_vertex as i32 -start_instance +first_instance ) } ; @@ -6980,8 +6980,8 @@ draw ( vertex_count instance_count -start_vertex -start_instance +first_vertex +first_instance ) ; } @@ -6992,7 +6992,7 @@ draw_indexed & mut self -start_index +first_index : u32 index_count @@ -7001,7 +7001,7 @@ u32 base_vertex : i32 -start_instance +first_instance : u32 instance_count @@ -7016,7 +7016,7 @@ self prepare_draw ( base_vertex -start_instance +first_instance ) } ; @@ -7036,9 +7036,9 @@ draw_indexed ( index_count instance_count -start_index +first_index base_vertex -start_instance +first_instance ) ; } diff --git a/third_party/rust/wgpu-hal/src/dx12/device.rs b/third_party/rust/wgpu-hal/src/dx12/device.rs index c72aa90388af..b27ef3dd306d 100644 --- a/third_party/rust/wgpu-hal/src/dx12/device.rs +++ b/third_party/rust/wgpu-hal/src/dx12/device.rs @@ -2956,9 +2956,16 @@ desc range . base_array_layer +desc +. +plane +. +unwrap_or +( 0 ) ) +) handle_srv : if @@ -6299,7 +6306,7 @@ crate PipelineLayoutFlags : : -BASE_VERTEX_INSTANCE +FIRST_VERTEX_INSTANCE | crate : @@ -6376,12 +6383,10 @@ bind_cbv / 0 = -base -vertex +first_vertex 1 = -base -instance +first_instance 2 = other diff --git a/third_party/rust/wgpu-hal/src/dx12/mod.rs b/third_party/rust/wgpu-hal/src/dx12/mod.rs index c55d68d3b6c6..0ef2c20a1fa8 100644 --- a/third_party/rust/wgpu-hal/src/dx12/mod.rs +++ b/third_party/rust/wgpu-hal/src/dx12/mod.rs @@ -1527,10 +1527,10 @@ Empty Constant SpecialConstantBuffer { -base_vertex +first_vertex : i32 -base_instance +first_instance : u32 other diff --git a/third_party/rust/wgpu-hal/src/dx12/view.rs b/third_party/rust/wgpu-hal/src/dx12/view.rs index 08700eb742f9..81213a18da49 100644 --- a/third_party/rust/wgpu-hal/src/dx12/view.rs +++ b/third_party/rust/wgpu-hal/src/dx12/view.rs @@ -83,6 +83,9 @@ u32 mip_level_count : u32 +plane +: +u32 } impl crate @@ -226,6 +229,16 @@ unwrap_or ! 0 ) +plane +: +self +. +plane +. +unwrap_or +( +0 +) } } } @@ -516,7 +529,9 @@ self mip_level_count PlaneSlice : -0 +self +. +plane ResourceMinLODClamp : 0 @@ -650,7 +665,9 @@ self array_layer_count PlaneSlice : -0 +self +. +plane ResourceMinLODClamp : 0 @@ -1065,7 +1082,9 @@ self mip_level_base PlaneSlice : -0 +self +. +plane } } } @@ -1129,7 +1148,9 @@ self array_layer_count PlaneSlice : -0 +self +. +plane } } } @@ -1472,7 +1493,9 @@ self mip_level_base PlaneSlice : -0 +self +. +plane } } } @@ -1596,7 +1619,9 @@ self array_layer_count PlaneSlice : -0 +self +. +plane } } } diff --git a/third_party/rust/wgpu-hal/src/empty.rs b/third_party/rust/wgpu-hal/src/empty.rs index 6c2ef7cc3b87..423253ea4fd5 100644 --- a/third_party/rust/wgpu-hal/src/empty.rs +++ b/third_party/rust/wgpu-hal/src/empty.rs @@ -2115,13 +2115,13 @@ draw & mut self -start_vertex +first_vertex : u32 vertex_count : u32 -start_instance +first_instance : u32 instance_count @@ -2137,7 +2137,7 @@ draw_indexed & mut self -start_index +first_index : u32 index_count @@ -2146,7 +2146,7 @@ u32 base_vertex : i32 -start_instance +first_instance : u32 instance_count diff --git a/third_party/rust/wgpu-hal/src/gles/adapter.rs b/third_party/rust/wgpu-hal/src/gles/adapter.rs index 22704cddf617..8236f8cab5b3 100644 --- a/third_party/rust/wgpu-hal/src/gles/adapter.rs +++ b/third_party/rust/wgpu-hal/src/gles/adapter.rs @@ -2985,6 +2985,14 @@ DownlevelFlags : : COMPARISON_SAMPLERS +| +wgt +: +: +DownlevelFlags +: +: +VERTEX_AND_INSTANCE_INDEX_RESPECTS_RESPECTIVE_FIRST_VALUE_IN_INDIRECT_DRAW ; downlevel_flags . @@ -3051,39 +3059,6 @@ GL_ARB_multi_draw_indirect ) ) ; -/ -/ -TODO -: -we -can -actually -support -positive -base_vertex -in -the -same -way -/ -/ -as -we -emulate -the -start_instance -. -But -we -can -' -t -deal -with -negatives -. -. -. downlevel_flags . set @@ -4158,6 +4133,47 @@ GL_KHR_texture_compression_astc_hdr ) ; } +features +. +set +( +wgt +: +: +Features +: +: +FLOAT32_FILTERABLE +extensions +. +contains +( +" +GL_ARB_color_buffer_float +" +) +| +| +extensions +. +contains +( +" +GL_EXT_color_buffer_float +" +) +| +| +extensions +. +contains +( +" +OES_texture_float_linear +" +) +) +; / / We @@ -4464,27 +4480,8 @@ super PrivateCapabilities : : -TEXTURE_FLOAT_LINEAR -if -full_ver -. -is_some -( -) -{ -color_buffer_float -} -else -{ -extensions -. -contains -( -" -OES_texture_float_linear -" -) -} +QUERY_BUFFERS +query_buffers ) ; private_caps @@ -4497,8 +4494,12 @@ super PrivateCapabilities : : -QUERY_BUFFERS -query_buffers +QUERY_64BIT +full_ver +. +is_some +( +) ) ; private_caps @@ -4577,6 +4578,123 @@ supported ) ) ; +if +let +Some +( +full_ver +) += +full_ver +{ +let +supported += +full_ver +> += +( +4 +2 +) +& +& +extensions +. +contains +( +" +GL_ARB_shader_draw_parameters +" +) +; +private_caps +. +set +( +super +: +: +PrivateCapabilities +: +: +FULLY_FEATURED_INSTANCING +supported +) +; +/ +/ +Desktop +4 +. +2 +and +greater +specify +the +first +instance +parameter +. +/ +/ +/ +/ +For +all +other +versions +the +behavior +is +undefined +. +/ +/ +/ +/ +We +only +support +indirect +first +instance +when +we +also +have +ARB_shader_draw_parameters +as +/ +/ +that +' +s +the +only +way +to +get +gl_InstanceID +to +work +correctly +. +features +. +set +( +wgt +: +: +Features +: +: +INDIRECT_FIRST_INSTANCE +supported +) +; +} let max_texture_size = @@ -5558,10 +5676,7 @@ wasm32 " allow ( -clippy -: -: -drop_ref +dropping_references ) ) ] @@ -5601,7 +5716,6 @@ private_caps workarounds features shading_language_version -max_texture_size next_shader_id : Default @@ -7153,15 +7267,15 @@ MULTISAMPLE_RESOLVE let texture_float_linear = -private_caps_fn +feature_fn ( -super +wgt : : -PrivateCapabilities +Features : : -TEXTURE_FLOAT_LINEAR +FLOAT32_FILTERABLE filterable ) ; @@ -7537,6 +7651,16 @@ depth Tf : : +NV12 += +> +unreachable +! +( +) +Tf +: +: Rgb9e5Ufloat = > @@ -7927,49 +8051,6 @@ swap_chain_sizes current_extent : None -extents -: -wgt -: -: -Extent3d -{ -width -: -4 -height -: -4 -depth_or_array_layers -: -1 -} -. -. -= -wgt -: -: -Extent3d -{ -width -: -self -. -shared -. -max_texture_size -height -: -self -. -shared -. -max_texture_size -depth_or_array_layers -: -1 -} usage : crate diff --git a/third_party/rust/wgpu-hal/src/gles/command.rs b/third_party/rust/wgpu-hal/src/gles/command.rs index a57849b7e318..54df6f353358 100644 --- a/third_party/rust/wgpu-hal/src/gles/command.rs +++ b/third_party/rust/wgpu-hal/src/gles/command.rs @@ -224,6 +224,15 @@ usize active_first_instance : u32 +first_instance_location +: +Option +< +glow +: +: +UniformLocation +> push_constant_descs : ArrayVec @@ -438,6 +447,14 @@ Default default ( ) +first_instance_location +: +Default +: +: +default +( +) push_constant_descs : Default @@ -1412,8 +1429,60 @@ first_instance u32 ) { +/ +/ +If +we +support +fully +featured +instancing +we +want +to +bind +everything +as +normal +/ +/ +and +let +the +draw +call +sort +it +out +. +let +emulated_first_instance_value += if +self +. +private_caps +. +contains +( +super +: +: +PrivateCapabilities +: +: +FULLY_FEATURED_INSTANCING +) +{ +0 +} +else +{ first_instance +} +; +if +emulated_first_instance_value ! = self @@ -1454,7 +1523,7 @@ state . active_first_instance = -first_instance +emulated_first_instance_value ; } if @@ -1471,11 +1540,31 @@ self . rebind_vertex_data ( -first_instance +emulated_first_instance_value ) ; } } +# +[ +allow +( +clippy +: +: +clone_on_copy +) +] +/ +/ +False +positive +when +cloning +glow +: +: +UniformLocation fn set_pipeline_inner ( @@ -1514,6 +1603,20 @@ self . state . +first_instance_location += +inner +. +first_instance_location +. +clone +( +) +; +self +. +state +. push_constant_descs = inner @@ -3936,6 +4039,7 @@ format sample_type ( None +None ) . unwrap @@ -6763,13 +6867,13 @@ draw & mut self -start_vertex +first_vertex : u32 vertex_count : u32 -start_instance +first_instance : u32 instance_count @@ -6781,9 +6885,29 @@ self . prepare_draw ( -start_instance +first_instance ) ; +# +[ +allow +( +clippy +: +: +clone_on_copy +) +] +/ +/ +False +positive +when +cloning +glow +: +: +UniformLocation self . cmd_buffer @@ -6804,9 +6928,21 @@ self state . topology -start_vertex +first_vertex vertex_count +first_instance instance_count +first_instance_location +: +self +. +state +. +first_instance_location +. +clone +( +) } ) ; @@ -6818,7 +6954,7 @@ draw_indexed & mut self -start_index +first_index : u32 index_count @@ -6827,7 +6963,7 @@ u32 base_vertex : i32 -start_instance +first_instance : u32 instance_count @@ -6839,7 +6975,7 @@ self . prepare_draw ( -start_instance +first_instance ) ; let @@ -6900,13 +7036,33 @@ index_offset + index_size * -start_index +first_index as wgt : : BufferAddress ; +# +[ +allow +( +clippy +: +: +clone_on_copy +) +] +/ +/ +False +positive +when +cloning +glow +: +: +UniformLocation self . cmd_buffer @@ -6931,7 +7087,19 @@ index_type index_offset index_count base_vertex +first_instance instance_count +first_instance_location +: +self +. +state +. +first_instance_location +. +clone +( +) } ) ; @@ -7008,6 +7176,26 @@ wgt : BufferAddress ; +# +[ +allow +( +clippy +: +: +clone_on_copy +) +] +/ +/ +False +positive +when +cloning +glow +: +: +UniformLocation self . cmd_buffer @@ -7038,6 +7226,17 @@ unwrap ( ) indirect_offset +first_instance_location +: +self +. +state +. +first_instance_location +. +clone +( +) } ) ; @@ -7153,6 +7352,26 @@ wgt : BufferAddress ; +# +[ +allow +( +clippy +: +: +clone_on_copy +) +] +/ +/ +False +positive +when +cloning +glow +: +: +UniformLocation self . cmd_buffer @@ -7184,6 +7403,17 @@ unwrap ( ) indirect_offset +first_instance_location +: +self +. +state +. +first_instance_location +. +clone +( +) } ) ; diff --git a/third_party/rust/wgpu-hal/src/gles/conv.rs b/third_party/rust/wgpu-hal/src/gles/conv.rs index da79bf54df97..436c6672242a 100644 --- a/third_party/rust/wgpu-hal/src/gles/conv.rs +++ b/third_party/rust/wgpu-hal/src/gles/conv.rs @@ -1025,6 +1025,16 @@ UNSIGNED_INT_24_8 Tf : : +NV12 += +> +unreachable +! +( +) +Tf +: +: Rgb9e5Ufloat = > diff --git a/third_party/rust/wgpu-hal/src/gles/device.rs b/third_party/rust/wgpu-hal/src/gles/device.rs index 27d79e283e63..ee87da7817cd 100644 --- a/third_party/rust/wgpu-hal/src/gles/device.rs +++ b/third_party/rust/wgpu-hal/src/gles/device.rs @@ -3427,6 +3427,74 @@ clone } } } +let +first_instance_location += +if +has_stages +. +contains +( +wgt +: +: +ShaderStages +: +: +VERTEX +) +{ +/ +/ +If +this +returns +none +( +the +uniform +isn +' +t +active +) +that +' +s +fine +we +just +won +' +t +set +it +. +unsafe +{ +gl +. +get_uniform_location +( +program +naga +: +: +back +: +: +glsl +: +: +FIRST_INSTANCE_BINDING +) +} +} +else +{ +None +} +; Ok ( Arc @@ -3441,6 +3509,7 @@ PipelineInner { program sampler_map +first_instance_location push_constant_descs : uniforms @@ -5333,6 +5402,14 @@ format sample_type ( None +Some +( +self +. +shared +. +features +) ) { Some @@ -7291,6 +7368,35 @@ SHADER_TEXTURE_SHADOW_LOD ) ) ; +writer_flags +. +set +( +glsl +: +: +WriterFlags +: +: +DRAW_PARAMETERS +self +. +shared +. +private_caps +. +contains +( +super +: +: +PrivateCapabilities +: +: +FULLY_FEATURED_INSTANCING +) +) +; / / We @@ -9364,17 +9470,6 @@ lock ; let mut -temp_string -= -String -: -: -new -( -) -; -let -mut queries = Vec @@ -9390,7 +9485,7 @@ usize ) ; for -i +_ in 0 . @@ -9426,150 +9521,71 @@ OutOfMemory ) ? ; -# -[ -cfg -( -not -( -target_arch -= -" -wasm32 -" -) -) -] -if -gl -. -supports_debug -( -) -{ -use -std -: -: -fmt -: -: -Write -; / / -Initialize -the -query -so -we -can -label -it -match -desc -. -ty -{ -wgt -: -: -QueryType -: -: -Timestamp -= -> -unsafe -{ -gl -. -query_counter -( -query -glow -: -: -TIMESTAMP -) -} -_ -= -> -( -) -} -if -let -Some -( -label -) -= -desc -. +We +aren +' +t +really +able +to +in +general label -{ -temp_string +queries . -clear -( -) -; -let -_ -= -write -! -( -temp_string +/ +/ +/ +/ +We +could +take +a +timestamp +here +to " -{ -label -} -[ -{ -i -} -] +initialize " -) -; -let -name -= -unsafe -{ -mem -: -: -transmute -( +the query -) -} -; -unsafe -{ -gl +/ +/ +but +that +' +s +a +bit +of +a +hack +and +we +don +' +t +want +to +insert +/ +/ +random +timestamps +into +the +command +stream +of +we +don +' +t +have +to . -object_label -( -glow -: -: -QUERY -name -Some -( -& -temp_string -) -) -} -; -} -} queries . push diff --git a/third_party/rust/wgpu-hal/src/gles/mod.rs b/third_party/rust/wgpu-hal/src/gles/mod.rs index c36880415e0e..bf5cb70a5d28 100644 --- a/third_party/rust/wgpu-hal/src/gles/mod.rs +++ b/third_party/rust/wgpu-hal/src/gles/mod.rs @@ -292,10 +292,7 @@ doesn ' t support -" -base -instance -" +first_instance semantics . However @@ -433,13 +430,190 @@ on whether or not -start_instance +first_instance is used - stride has changed +# +# +Handling +of +base_vertex +first_instance +and +first_vertex +Between +indirect +the +lack +of +first_instance +semantics +and +the +availability +of +gl_BaseInstance +in +shaders +getting +buffers +and +builtins +to +work +correctly +is +a +bit +tricky +. +We +never +emulate +base_vertex +and +gl_VertexID +behaves +as +builtin +( +vertex_index +) +does +so +we +never +need +to +do +anything +about +that +. +We +always +advertise +support +for +VERTEX_AND_INSTANCE_INDEX_RESPECTS_RESPECTIVE_FIRST_VALUE_IN_INDIRECT_DRAW +. +# +# +# +GL +4 +. +2 ++ +with +ARB_shader_draw_parameters +- +builtin +( +instance_index +) +translates +to +gl_InstanceID ++ +gl_BaseInstance +- +We +bind +instance +buffers +without +any +offset +emulation +. +- +We +advertise +support +for +the +INDIRECT_FIRST_INSTANCE +feature +. +While +we +can +theoretically +have +a +card +with +4 +. +2 ++ +support +but +without +ARB_shader_draw_parameters +we +don +' +t +bother +with +that +combination +. +# +# +# +GLES +& +GL +4 +. +1 +- +builtin +( +instance_index +) +translates +to +gl_InstanceID ++ +naga_vs_first_instance +- +We +bind +instance +buffers +with +offset +emulation +. +- +We +_do +not_ +advertise +support +for +INDIRECT_FIRST_INSTANCE +and +cpu +- +side +pretend +the +first_instance +is +0 +on +indirect +calls +. * / / @@ -1235,34 +1409,34 @@ COLOR_BUFFER_FLOAT / / Supports -linear -flitering -f32 -textures +query +buffer +objects . const -TEXTURE_FLOAT_LINEAR +QUERY_BUFFERS = 1 < < -10 +11 ; / / / Supports -query -buffer -objects -. +64 +bit +queries +via +glGetQueryObjectui64v const -QUERY_BUFFERS +QUERY_64BIT = 1 < < -11 +12 ; / / @@ -1277,7 +1451,7 @@ TEXTURE_STORAGE 1 < < -12 +13 ; / / @@ -1294,7 +1468,7 @@ DEBUG_FNS 1 < < -13 +14 ; / / @@ -1309,7 +1483,49 @@ INVALIDATE_FRAMEBUFFER 1 < < -14 +15 +; +/ +/ +/ +Indicates +support +for +glDrawElementsInstancedBaseVertexBaseInstance +and +ARB_shader_draw_parameters +/ +/ +/ +/ +/ +/ +When +this +is +true +instance +offset +emulation +via +vertex +buffer +rebinding +and +a +shader +uniform +will +be +disabled +. +const +FULLY_FEATURED_INSTANCING += +1 +< +< +16 ; } } @@ -1566,9 +1782,6 @@ glsl : : Version -max_texture_size -: -u32 next_shader_id : AtomicU32 @@ -3159,6 +3372,15 @@ Program sampler_map : SamplerBindMap +first_instance_location +: +Option +< +glow +: +: +UniformLocation +> push_constant_descs : ArrayVec @@ -4111,15 +4333,27 @@ Draw topology : u32 -start_vertex +first_vertex : u32 vertex_count : u32 +first_instance +: +u32 instance_count : u32 +first_instance_location +: +Option +< +glow +: +: +UniformLocation +> } DrawIndexed { @@ -4141,9 +4375,21 @@ BufferAddress base_vertex : i32 +first_instance +: +u32 instance_count : u32 +first_instance_location +: +Option +< +glow +: +: +UniformLocation +> } DrawIndirect { @@ -4162,6 +4408,15 @@ wgt : : BufferAddress +first_instance_location +: +Option +< +glow +: +: +UniformLocation +> } DrawIndexedIndirect { @@ -4183,6 +4438,15 @@ wgt : : BufferAddress +first_instance_location +: +Option +< +glow +: +: +UniformLocation +> } Dispatch ( @@ -4955,6 +5219,94 @@ finish ) } } +# +[ +cfg +( +all +( +target_arch += +" +wasm32 +" +feature += +" +fragile +- +send +- +sync +- +non +- +atomic +- +wasm +" +not +( +target_feature += +" +atomics +" +) +) +) +] +unsafe +impl +Sync +for +CommandBuffer +{ +} +# +[ +cfg +( +all +( +target_arch += +" +wasm32 +" +feature += +" +fragile +- +send +- +sync +- +non +- +atomic +- +wasm +" +not +( +target_feature += +" +atomics +" +) +) +) +] +unsafe +impl +Send +for +CommandBuffer +{ +} / / TODO @@ -5074,6 +5426,94 @@ finish [ cfg ( +all +( +target_arch += +" +wasm32 +" +feature += +" +fragile +- +send +- +sync +- +non +- +atomic +- +wasm +" +not +( +target_feature += +" +atomics +" +) +) +) +] +unsafe +impl +Sync +for +CommandEncoder +{ +} +# +[ +cfg +( +all +( +target_arch += +" +wasm32 +" +feature += +" +fragile +- +send +- +sync +- +non +- +atomic +- +wasm +" +not +( +target_feature += +" +atomics +" +) +) +) +] +unsafe +impl +Send +for +CommandEncoder +{ +} +# +[ +cfg +( not ( all @@ -5431,9 +5871,14 @@ crate : VALIDATION_CANARY . -set +add +( +message +. +to_string ( ) +) ; } } diff --git a/third_party/rust/wgpu-hal/src/gles/queue.rs b/third_party/rust/wgpu-hal/src/gles/queue.rs index 6c189d87293b..1ae71d5b46ae 100644 --- a/third_party/rust/wgpu-hal/src/gles/queue.rs +++ b/third_party/rust/wgpu-hal/src/gles/queue.rs @@ -1094,13 +1094,73 @@ C Draw { topology -start_vertex +first_vertex vertex_count instance_count +first_instance +ref +first_instance_location } = > { +let +supports_full_instancing += +self +. +shared +. +private_caps +. +contains +( +PrivateCapabilities +: +: +FULLY_FEATURED_INSTANCING +) +; +if +supports_full_instancing +{ +unsafe +{ +gl +. +draw_arrays_instanced_base_instance +( +topology +first_vertex +as +i32 +vertex_count +as +i32 +instance_count +as +i32 +first_instance +) +} +} +else +{ +unsafe +{ +gl +. +uniform_1_u32 +( +first_instance_location +. +as_ref +( +) +first_instance +) +; +} / / Don @@ -1165,7 +1225,7 @@ gl draw_arrays_instanced ( topology -start_vertex +first_vertex as i32 vertex_count @@ -1176,6 +1236,7 @@ as i32 ) } +} ; } C @@ -1188,7 +1249,10 @@ index_type index_count index_offset base_vertex +first_instance instance_count +ref +first_instance_location } = > @@ -1196,6 +1260,27 @@ instance_count match base_vertex { +0 += +> +{ +unsafe +{ +gl +. +uniform_1_u32 +( +first_instance_location +. +as_ref +( +) +first_instance +) +} +; +unsafe +{ / / Don @@ -1263,11 +1348,6 @@ wgpu issues / 3578 -0 -= -> -unsafe -{ gl . draw_elements_instanced @@ -1285,9 +1365,96 @@ as i32 ) } +} _ = > +{ +let +supports_full_instancing += +self +. +shared +. +private_caps +. +contains +( +PrivateCapabilities +: +: +FULLY_FEATURED_INSTANCING +) +; +if +supports_full_instancing +{ +unsafe +{ +gl +. +draw_elements_instanced_base_vertex_base_instance +( +topology +index_count +as +i32 +index_type +index_offset +as +i32 +instance_count +as +i32 +base_vertex +first_instance +) +} +} +else +{ +unsafe +{ +gl +. +uniform_1_u32 +( +first_instance_location +. +as_ref +( +) +first_instance +) +} +; +/ +/ +If +we +' +ve +gotten +here +wgpu +- +core +has +already +validated +that +this +function +exists +via +the +DownlevelFlags +: +: +BASE_VERTEX +feature +. unsafe { gl @@ -1310,6 +1477,8 @@ base_vertex } } } +} +} C : : @@ -1318,6 +1487,8 @@ DrawIndirect topology indirect_buf indirect_offset +ref +first_instance_location } = > @@ -1326,6 +1497,21 @@ unsafe { gl . +uniform_1_u32 +( +first_instance_location +. +as_ref +( +) +0 +) +} +; +unsafe +{ +gl +. bind_buffer ( glow @@ -1362,6 +1548,8 @@ topology index_type indirect_buf indirect_offset +ref +first_instance_location } = > @@ -1370,6 +1558,21 @@ unsafe { gl . +uniform_1_u32 +( +first_instance_location +. +as_ref +( +) +0 +) +} +; +unsafe +{ +gl +. bind_buffer ( glow @@ -4972,6 +5175,21 @@ u64 ; unsafe { +if +self +. +shared +. +private_caps +. +contains +( +PrivateCapabilities +: +: +QUERY_64BIT +) +{ let result : @@ -4997,6 +5215,25 @@ as usize ) } +else +{ +result += +gl +. +get_query_parameter_u32 +( +query +glow +: +: +QUERY_RESULT +) +as +u64 +; +} +} ; temp_query_results . diff --git a/third_party/rust/wgpu-hal/src/lib.rs b/third_party/rust/wgpu-hal/src/lib.rs index f4f94db9313e..296b043a4c23 100644 --- a/third_party/rust/wgpu-hal/src/lib.rs +++ b/third_party/rust/wgpu-hal/src/lib.rs @@ -731,14 +731,8 @@ NonNull sync : : -{ -atomic -: -: -AtomicBool Arc } -} ; use bitflags @@ -747,6 +741,12 @@ bitflags bitflags ; use +parking_lot +: +: +Mutex +; +use thiserror : : @@ -4619,13 +4619,13 @@ draw & mut self -start_vertex +first_vertex : u32 vertex_count : u32 -start_instance +first_instance : u32 instance_count @@ -4640,7 +4640,7 @@ draw_indexed & mut self -start_index +first_index : u32 index_count @@ -4649,7 +4649,7 @@ u32 base_vertex : i32 -start_instance +first_instance : u32 instance_count @@ -4913,14 +4913,13 @@ u32 Include support for -base -vertex +first_vertex / -instance +first_instance drawing . const -BASE_VERTEX_INSTANCE +FIRST_VERTEX_INSTANCE = 1 < @@ -7152,37 +7151,6 @@ Extent3d / / / -Range -of -supported -extents -. -/ -/ -/ -/ -/ -/ -current_extent -must -be -inside -this -range -. -pub -extents -: -RangeInclusive -< -wgt -: -: -Extent3d -> -/ -/ -/ Supported texture usage @@ -7785,6 +7753,13 @@ wgt : : ImageSubresourceRange +pub +plane +: +Option +< +u32 +> } # [ @@ -10579,24 +10554,57 @@ A / / Stores -if +the +text +of any -API validation -error -has +errors +that +have occurred -in -this -process +since / / / -since -it -was +the last -reset +call +to +get_and_reset +. +/ +/ +/ +/ +/ +/ +Each +value +is +a +validation +error +and +a +message +associated +with +it +/ +/ +/ +or +None +if +the +error +has +no +message +from +the +api . / / @@ -10693,12 +10701,17 @@ ValidationCanary { inner : -AtomicBool +Mutex +: +: +new +( +Vec : : new ( -false +) ) } ; @@ -10716,7 +10729,13 @@ ValidationCanary { inner : -AtomicBool +Mutex +< +Vec +< +String +> +> } impl ValidationCanary @@ -10738,32 +10757,26 @@ function is dead fn -set +add ( & self +msg +: +String ) { self . inner . -store +lock ( -true -std -: -: -sync -: -: -atomic -: -: -Ordering -: -: -SeqCst +) +. +push +( +msg ) ; } @@ -10771,13 +10784,12 @@ SeqCst / / Returns -true -if any API validation -error -has +errors +that +hav occurred in this @@ -10802,28 +10814,27 @@ self ) - > -bool +Vec +< +String +> { self . inner . -swap +lock +( +) +. +drain +( +. +. +) +. +collect ( -false -std -: -: -sync -: -: -atomic -: -: -Ordering -: -: -SeqCst ) } } diff --git a/third_party/rust/wgpu-hal/src/metal/adapter.rs b/third_party/rust/wgpu-hal/src/metal/adapter.rs index 199ec5445349..7611baab94ff 100644 --- a/third_party/rust/wgpu-hal/src/metal/adapter.rs +++ b/third_party/rust/wgpu-hal/src/metal/adapter.rs @@ -1674,6 +1674,19 @@ flags Tf : : +NV12 += +> +return +Tfc +: +: +empty +( +) +Tf +: +: Rgb9e5Ufloat = > @@ -2210,49 +2223,6 @@ CompositeAlphaMode PostMultiplied ] current_extent -extents -: -wgt -: -: -Extent3d -{ -width -: -4 -height -: -4 -depth_or_array_layers -: -1 -} -. -. -= -wgt -: -: -Extent3d -{ -width -: -pc -. -max_texture_size -as -u32 -height -: -pc -. -max_texture_size -as -u32 -depth_or_array_layers -: -1 -} usage : crate @@ -2599,8 +2569,24 @@ MTLFeatureSet macOS_GPUFamily2_v1 ] ; +/ +/ +/ +" +Indirect +draw +& +dispatch +arguments +" +in +the +Metal +feature +set +tables const -BASE_INSTANCE_SUPPORT +INDIRECT_DRAW_DISPATCH_SUPPORT : & [ @@ -2623,29 +2609,46 @@ MTLFeatureSet macOS_GPUFamily1_v1 ] ; +/ +/ +/ +" +Base +vertex +/ +instance +drawing +" +in +the +Metal +feature +set +tables +/ +/ +/ +/ +/ +/ +in +our +terms +base_vertex +and +first_instance +must +be +0 const -BASE_VERTEX_INSTANCE_SUPPORT +BASE_VERTEX_FIRST_INSTANCE_SUPPORT : & [ MTLFeatureSet ] = -& -[ -MTLFeatureSet -: -: -iOS_GPUFamily3_v1 -MTLFeatureSet -: -: -tvOS_GPUFamily2_v1 -MTLFeatureSet -: -: -macOS_GPUFamily1_v1 -] +INDIRECT_DRAW_DISPATCH_SUPPORT ; const TEXTURE_CUBE_ARRAY_SUPPORT @@ -3765,7 +3768,7 @@ supports_any device SAMPLER_CLAMP_TO_BORDER_SUPPORT ) -base_instance +indirect_draw_dispatch : Self : @@ -3773,9 +3776,9 @@ Self supports_any ( device -BASE_INSTANCE_SUPPORT +INDIRECT_DRAW_DISPATCH_SUPPORT ) -base_vertex_instance_drawing +base_vertex_first_instance_drawing : Self : @@ -3783,7 +3786,7 @@ Self supports_any ( device -BASE_VERTEX_INSTANCE_SUPPORT +BASE_VERTEX_FIRST_INSTANCE_SUPPORT ) dual_source_blending : @@ -3856,6 +3859,34 @@ supports_any device TEXTURE_CUBE_ARRAY_SUPPORT ) +supports_float_filtering +: +os_is_mac +| +| +( +version +. +at_least +( +( +11 +0 +) +( +14 +0 +) +os_is_mac +) +& +& +device +. +supports_32bit_float_filtering +( +) +) format_depth24_stencil8 : os_is_mac @@ -5072,11 +5103,6 @@ empty F : : -INDIRECT_FIRST_INSTANCE -| -F -: -: MAPPABLE_PRIMARY_BUFFERS | F @@ -5122,12 +5148,38 @@ DEPTH32FLOAT_STENCIL8 F : : -MULTI_DRAW_INDIRECT +BGRA8UNORM_STORAGE +; +features +. +set +( +F +: +: +FLOAT32_FILTERABLE +self +. +supports_float_filtering +) +; +features +. +set +( +F +: +: +INDIRECT_FIRST_INSTANCE | F : : -BGRA8UNORM_STORAGE +MULTI_DRAW_INDIRECT +self +. +indirect_draw_dispatch +) ; features . @@ -5553,6 +5605,51 @@ wgt DownlevelFlags : : +INDIRECT_EXECUTION +self +. +indirect_draw_dispatch +) +; +/ +/ +TODO +: +add +another +flag +for +first_instance +downlevel +. +flags +. +set +( +wgt +: +: +DownlevelFlags +: +: +BASE_VERTEX +self +. +base_vertex_first_instance_drawing +) +; +downlevel +. +flags +. +set +( +wgt +: +: +DownlevelFlags +: +: ANISOTROPIC_FILTERING true ) @@ -6207,6 +6304,16 @@ Depth32Float_Stencil8 Tf : : +NV12 += +> +unreachable +! +( +) +Tf +: +: Rgb9e5Ufloat = > diff --git a/third_party/rust/wgpu-hal/src/metal/command.rs b/third_party/rust/wgpu-hal/src/metal/command.rs index ae5d0064dc04..183285a673bb 100644 --- a/third_party/rust/wgpu-hal/src/metal/command.rs +++ b/third_party/rust/wgpu-hal/src/metal/command.rs @@ -6793,13 +6793,13 @@ draw & mut self -start_vertex +first_vertex : u32 vertex_count : u32 -start_instance +first_instance : u32 instance_count @@ -6825,7 +6825,7 @@ unwrap ) ; if -start_instance +first_instance ! = 0 @@ -6839,7 +6839,7 @@ self state . raw_primitive_type -start_vertex +first_vertex as _ vertex_count @@ -6848,7 +6848,7 @@ _ instance_count as _ -start_instance +first_instance as _ ) @@ -6870,7 +6870,7 @@ self state . raw_primitive_type -start_vertex +first_vertex as _ vertex_count @@ -6893,7 +6893,7 @@ self state . raw_primitive_type -start_vertex +first_vertex as _ vertex_count @@ -6910,7 +6910,7 @@ draw_indexed & mut self -start_index +first_index : u32 index_count @@ -6919,7 +6919,7 @@ u32 base_vertex : i32 -start_instance +first_instance : u32 instance_count @@ -6972,7 +6972,7 @@ index . stride * -start_index +first_index as wgt : @@ -6986,7 +6986,7 @@ base_vertex 0 | | -start_instance +first_instance ! = 0 @@ -7020,7 +7020,7 @@ _ base_vertex as _ -start_instance +first_instance as _ ) diff --git a/third_party/rust/wgpu-hal/src/metal/mod.rs b/third_party/rust/wgpu-hal/src/metal/mod.rs index 9e3a91ce73b7..e6a568910683 100644 --- a/third_party/rust/wgpu-hal/src/metal/mod.rs +++ b/third_party/rust/wgpu-hal/src/metal/mod.rs @@ -1143,10 +1143,10 @@ bool sampler_clamp_to_border : bool -base_instance +indirect_draw_dispatch : bool -base_vertex_instance_drawing +base_vertex_first_instance_drawing : bool dual_source_blending @@ -1170,6 +1170,9 @@ bool texture_cube_array : bool +supports_float_filtering +: +bool format_depth24_stencil8 : bool diff --git a/third_party/rust/wgpu-hal/src/vulkan/adapter.rs b/third_party/rust/wgpu-hal/src/vulkan/adapter.rs index 9c60e6c5a7a9..44abfbc9977a 100644 --- a/third_party/rust/wgpu-hal/src/vulkan/adapter.rs +++ b/third_party/rust/wgpu-hal/src/vulkan/adapter.rs @@ -1914,6 +1914,13 @@ to_wgpu ( & self +adapter_info +: +& +wgt +: +: +AdapterInfo instance : & @@ -2096,6 +2103,11 @@ Df : : NONBLOCKING_QUERY_RESOLVE +| +Df +: +: +VERTEX_AND_INSTANCE_INDEX_RESPECTS_RESPECTIVE_FIRST_VALUE_IN_INDIRECT_DRAW ; dl_flags . @@ -3266,6 +3278,115 @@ device_api_version ) ) ; +features +. +set +( +F +: +: +FLOAT32_FILTERABLE +is_float32_filterable_supported +( +instance +phd +) +) +; +features +. +set +( +F +: +: +TEXTURE_FORMAT_NV12 +( +caps +. +device_api_version +> += +vk +: +: +API_VERSION_1_1 +| +| +caps +. +supports_extension +( +vk +: +: +KhrSamplerYcbcrConversionFn +: +: +name +( +) +) +) +& +& +supports_format +( +instance +phd +vk +: +: +Format +: +: +G8_B8R8_2PLANE_420_UNORM +vk +: +: +ImageTiling +: +: +OPTIMAL +vk +: +: +FormatFeatureFlags +: +: +SAMPLED_IMAGE +| +vk +: +: +FormatFeatureFlags +: +: +TRANSFER_SRC +| +vk +: +: +FormatFeatureFlags +: +: +TRANSFER_DST +) +& +& +! +adapter_info +. +driver +. +contains +( +" +MoltenVK +" +) +) +; ( features dl_flags @@ -6320,6 +6441,8 @@ phd_features to_wgpu ( & +info +& self . shared @@ -6537,6 +6660,86 @@ major = 0 { +if +driver +. +driver_id += += +ash +: +: +vk +: +: +DriverId +: +: +MOLTENVK +{ +log +: +: +debug +! +( +" +Adapter +is +not +Vulkan +compliant +but +is +MoltenVK +continuing +" +) +; +} +else +if +self +. +shared +. +flags +. +contains +( +wgt +: +: +InstanceFlags +: +: +ALLOW_UNDERLYING_NONCOMPLIANT_ADAPTER +) +{ +log +: +: +warn +! +( +" +Adapter +is +not +Vulkan +compliant +: +{ +} +" +info +. +name +) +; +} +else +{ log : : @@ -6565,6 +6768,7 @@ None ; } } +} if phd_capabilities . @@ -9805,12 +10009,11 @@ format sample_type ( None -) -. -unwrap -( +None ) { +Some +( wgt : : @@ -9819,10 +10022,10 @@ TextureSampleType : Float { -filterable -: -_ +. +. } +) = > limits @@ -9835,6 +10038,8 @@ limits . sampled_image_color_sample_counts ) +Some +( wgt : : @@ -9842,7 +10047,10 @@ TextureSampleType : : Sint +) | +Some +( wgt : : @@ -9850,6 +10058,7 @@ TextureSampleType : : Uint +) = > { @@ -9860,10 +10069,13 @@ sampled_image_integer_sample_counts _ = > -unreachable -! -( -) +vk +: +: +SampleCountFlags +: +: +TYPE_1 } } ; @@ -10252,62 +10464,6 @@ None } ; let -min_extent -= -wgt -: -: -Extent3d -{ -width -: -caps -. -min_image_extent -. -width -height -: -caps -. -min_image_extent -. -height -depth_or_array_layers -: -1 -} -; -let -max_extent -= -wgt -: -: -Extent3d -{ -width -: -caps -. -max_image_extent -. -width -height -: -caps -. -max_image_extent -. -height -depth_or_array_layers -: -caps -. -max_image_array_layers -} -; -let raw_present_modes = { @@ -10490,13 +10646,6 @@ min_image_count = max_image_count current_extent -extents -: -min_extent -. -. -= -max_extent usage : conv @@ -10879,6 +11028,111 @@ rgba16unorm rgba16snorm } fn +is_float32_filterable_supported +( +instance +: +& +ash +: +: +Instance +phd +: +vk +: +: +PhysicalDevice +) +- +> +bool +{ +let +tiling += +vk +: +: +ImageTiling +: +: +OPTIMAL +; +let +features += +vk +: +: +FormatFeatureFlags +: +: +SAMPLED_IMAGE_FILTER_LINEAR +; +let +r_float += +supports_format +( +instance +phd +vk +: +: +Format +: +: +R32_SFLOAT +tiling +features +) +; +let +rg_float += +supports_format +( +instance +phd +vk +: +: +Format +: +: +R32G32_SFLOAT +tiling +features +) +; +let +rgba_float += +supports_format +( +instance +phd +vk +: +: +Format +: +: +R32G32B32A32_SFLOAT +tiling +features +) +; +r_float +& +& +rg_float +& +& +rgba_float +} +fn supports_format ( instance diff --git a/third_party/rust/wgpu-hal/src/vulkan/command.rs b/third_party/rust/wgpu-hal/src/vulkan/command.rs index 4fd2753a3ba3..48abb3013c31 100644 --- a/third_party/rust/wgpu-hal/src/vulkan/command.rs +++ b/third_party/rust/wgpu-hal/src/vulkan/command.rs @@ -4313,13 +4313,13 @@ draw & mut self -start_vertex +first_vertex : u32 vertex_count : u32 -start_instance +first_instance : u32 instance_count @@ -4342,8 +4342,8 @@ self active vertex_count instance_count -start_vertex -start_instance +first_vertex +first_instance ) } ; @@ -4355,7 +4355,7 @@ draw_indexed & mut self -start_index +first_index : u32 index_count @@ -4364,7 +4364,7 @@ u32 base_vertex : i32 -start_instance +first_instance : u32 instance_count @@ -4387,9 +4387,9 @@ self active index_count instance_count -start_index +first_index base_vertex -start_instance +first_instance ) } ; diff --git a/third_party/rust/wgpu-hal/src/vulkan/conv.rs b/third_party/rust/wgpu-hal/src/vulkan/conv.rs index 3e7f1ea90f91..328c8897b76e 100644 --- a/third_party/rust/wgpu-hal/src/vulkan/conv.rs +++ b/third_party/rust/wgpu-hal/src/vulkan/conv.rs @@ -600,6 +600,16 @@ D16_UNORM Tf : : +NV12 += +> +F +: +: +G8_B8R8_2PLANE_420_UNORM +Tf +: +: Rgb9e5Ufloat = > @@ -1656,6 +1666,7 @@ view_format sample_type ( None +None ) . unwrap @@ -3481,6 +3492,12 @@ crate : : FormatAspects +plane +: +Option +< +u32 +> ) - > @@ -3503,6 +3520,78 @@ empty ( ) ; +match +plane +{ +Some +( +0 +) += +> +flags +| += +vk +: +: +ImageAspectFlags +: +: +PLANE_0 +Some +( +1 +) += +> +flags +| += +vk +: +: +ImageAspectFlags +: +: +PLANE_1 +Some +( +2 +) += +> +flags +| += +vk +: +: +ImageAspectFlags +: +: +PLANE_2 +Some +( +plane +) += +> +panic +! +( +" +Unexpected +plane +{ +} +" +plane +) +None += +> +{ if aspects . @@ -3529,6 +3618,8 @@ ImageAspectFlags COLOR ; } +} +} if aspects . @@ -5032,6 +5123,12 @@ wgt : : TextureFormat +plane +: +Option +< +u32 +> ) - > @@ -5062,6 +5159,7 @@ range . aspect ) +plane ) base_mip_level : @@ -5171,6 +5269,7 @@ map_subresource_range ( range format +None ) ; if @@ -5284,6 +5383,7 @@ map_aspects base . aspect +None ) mip_level : diff --git a/third_party/rust/wgpu-hal/src/vulkan/device.rs b/third_party/rust/wgpu-hal/src/vulkan/device.rs index 605a45009fc4..8acdc939352e 100644 --- a/third_party/rust/wgpu-hal/src/vulkan/device.rs +++ b/third_party/rust/wgpu-hal/src/vulkan/device.rs @@ -7243,6 +7243,9 @@ range desc . format +desc +. +plane ) ; let diff --git a/third_party/rust/wgpu-hal/src/vulkan/instance.rs b/third_party/rust/wgpu-hal/src/vulkan/instance.rs index 21c07d4bb17b..4ca7b037088b 100644 --- a/third_party/rust/wgpu-hal/src/vulkan/instance.rs +++ b/third_party/rust/wgpu-hal/src/vulkan/instance.rs @@ -295,17 +295,33 @@ VUID - VkSwapchainCreateInfoKHR - -imageExtent +pNext - -01274 +07781 " / / -- -it +This +happens +when +a +surface +is +configured +with +a +size +outside +the +allowed +extent +. +/ +/ +It ' s -a +s false positive due @@ -318,12 +334,13 @@ ness of surface resizing +. const -VUID_VKSWAPCHAINCREATEINFOKHR_IMAGEEXTENT_01274 +VUID_VKSWAPCHAINCREATEINFOKHR_PNEXT_07781 : i32 = -0x7cd0911d +0x4c8929c1 ; if cd @@ -331,7 +348,7 @@ cd message_id_number = = -VUID_VKSWAPCHAINCREATEINFOKHR_IMAGEEXTENT_01274 +VUID_VKSWAPCHAINCREATEINFOKHR_PNEXT_07781 { return vk @@ -1163,8 +1180,13 @@ crate : VALIDATION_CANARY . -set +add ( +message +. +to_string +( +) ) ; } diff --git a/third_party/rust/wgpu-types/.cargo-checksum.json b/third_party/rust/wgpu-types/.cargo-checksum.json index bfbb7b453796..6fa2b850914b 100644 --- a/third_party/rust/wgpu-types/.cargo-checksum.json +++ b/third_party/rust/wgpu-types/.cargo-checksum.json @@ -11,7 +11,7 @@ toml " : " -e45ee369c8f91526056ba7f46504e270da1d8b2de65431bbaf36426bcd54da68 +18549fb7d7de2ea2481f30292dca63889856a33bd1b3698e16cee6631ab65df4 " " LICENSE @@ -51,7 +51,7 @@ rs " : " -6c3886f27653eee4359a8d150a6091a7d6e0ff1abab44c9afff2d54a0d0a474b +61f4f46533468f82e3d22e42d6e8b3d8b68504ccd4f9b4b9ea67b0664c42a34e " " src diff --git a/third_party/rust/wgpu-types/Cargo.toml b/third_party/rust/wgpu-types/Cargo.toml index eca9278789fb..a46f983c7514 100644 --- a/third_party/rust/wgpu-types/Cargo.toml +++ b/third_party/rust/wgpu-types/Cargo.toml @@ -380,7 +380,7 @@ sys . 3 . -65 +66 " [ target @@ -411,7 +411,7 @@ version . 3 . -64 +66 " features = diff --git a/third_party/rust/wgpu-types/src/lib.rs b/third_party/rust/wgpu-types/src/lib.rs index d0510ed383a5..a8a8a408a40d 100644 --- a/third_party/rust/wgpu-types/src/lib.rs +++ b/third_party/rust/wgpu-types/src/lib.rs @@ -2327,10 +2327,8 @@ zero value for the -" -first -instance -" +first_instance +member in indirect draw @@ -2342,6 +2340,72 @@ calls / / / +If +this +feature +is +not +enabled +and +the +first_instance +member +is +non +- +zero +the +behavior +may +be +: +/ +/ +/ +- +The +draw +call +is +ignored +. +/ +/ +/ +- +The +draw +call +is +executed +as +if +the +first_instance +is +zero +. +/ +/ +/ +- +The +draw +call +is +executed +with +the +correct +first_instance +value +. +/ +/ +/ +/ +/ +/ Supported Platforms : @@ -2363,6 +2427,44 @@ DX12 / - Metal +on +Apple3 ++ +or +Mac1 ++ +/ +/ +/ +- +OpenGL +( +Desktop +4 +. +2 ++ +with +ARB_shader_draw_parameters +only +) +/ +/ +/ +/ +/ +/ +Not +Supported +: +/ +/ +/ +- +OpenGL +ES +/ +WebGL / / / @@ -2714,7 +2816,98 @@ issues ) / / -TODO +/ +Allows +textures +with +formats +" +r32float +" +" +rg32float +" +and +" +rgba32float +" +to +be +filterable +. +/ +/ +/ +/ +/ +/ +Supported +Platforms +: +/ +/ +/ +- +Vulkan +( +mainly +on +Desktop +GPUs +) +/ +/ +/ +- +DX12 +/ +/ +/ +- +Metal +on +macOS +or +Apple9 ++ +GPUs +optional +on +iOS +/ +iPadOS +with +Apple7 +/ +8 +GPUs +/ +/ +/ +- +GL +with +one +of +GL_ARB_color_buffer_float +/ +GL_EXT_color_buffer_float +/ +OES_texture_float_linear +/ +/ +/ +/ +/ +/ +This +is +a +web +and +native +feature +. const FLOAT32_FILTERABLE = @@ -5338,6 +5531,12 @@ Vulkan / - Metal +on +Apple3 ++ +or +Mac1 ++ ( Emulated on @@ -6613,7 +6812,63 @@ SHADER_UNUSED_VERTEX_OUTPUT ; / / -54 +/ +Allows +for +creation +of +textures +of +format +[ +TextureFormat +: +: +NV12 +] +/ +/ +/ +/ +/ +/ +Supported +platforms +: +/ +/ +/ +- +DX12 +/ +/ +/ +- +Vulkan +/ +/ +/ +/ +/ +/ +This +is +a +native +only +feature +. +const +TEXTURE_FORMAT_NV12 += +1 +< +< +55 +; +/ +/ +55 . . 59 @@ -7253,6 +7508,154 @@ DISCARD_HAL_LABELS < 2 ; +/ +/ +/ +Whether +wgpu +should +expose +adapters +that +run +on +top +of +non +- +compliant +adapters +. +/ +/ +/ +/ +/ +/ +Turning +this +on +might +mean +that +some +of +the +functionality +provided +by +the +wgpu +/ +/ +/ +adapter +/ +device +is +not +working +or +is +broken +. +It +could +be +that +all +the +functionality +/ +/ +/ +wgpu +currently +exposes +works +but +we +can +' +t +tell +for +sure +since +we +have +no +additional +/ +/ +/ +transparency +into +what +is +working +and +what +is +not +on +the +underlying +adapter +. +/ +/ +/ +/ +/ +/ +This +mainly +applies +to +a +Vulkan +driver +' +s +compliance +version +. +If +the +major +compliance +version +/ +/ +/ +is +0 +then +the +driver +is +ignored +. +This +flag +allows +that +driver +to +be +enabled +for +testing +. +const +ALLOW_UNDERLYING_NONCOMPLIANT_ADAPTER += +1 +< +< +3 +; } } impl @@ -7625,6 +8028,32 @@ bit ) ; } +if +let +Some +( +bit +) += +env +( +" +WGPU_ALLOW_UNDERLYING_NONCOMPLIANT_ADAPTER +" +) +{ +self +. +set +( +Self +: +: +ALLOW_UNDERLYING_NONCOMPLIANT_ADAPTER +bit +) +; +} self } } @@ -11594,12 +12023,17 @@ FL10 level hardware WebGL2 -and GLES 3 . 0 -devices +and +Metal +on +Apple1 +/ +Apple2 +GPUs do not support @@ -11623,10 +12057,76 @@ zero base_vertex parameter to +direct indexed draw calls . +/ +/ +/ +/ +/ +/ +Indirect +calls +if +supported +always +support +non +- +zero +base_vertex +. +/ +/ +/ +/ +/ +/ +Supported +by +: +/ +/ +/ +- +Vulkan +/ +/ +/ +- +DX12 +/ +/ +/ +- +Metal +on +Apple3 ++ +or +Mac1 ++ +/ +/ +/ +- +OpenGL +3 +. +2 ++ +/ +/ +/ +- +OpenGL +ES +3 +. +2 const BASE_VERTEX = @@ -12597,6 +13097,289 @@ NONBLOCKING_QUERY_RESOLVE < 22 ; +/ +/ +/ +If +this +is +true +use +of +builtin +( +vertex_index +) +and +builtin +( +instance_index +) +will +properly +take +into +consideration +/ +/ +/ +the +first_vertex +and +first_instance +parameters +of +indirect +draw +calls +. +/ +/ +/ +/ +/ +/ +If +this +is +false +builtin +( +vertex_index +) +and +builtin +( +instance_index +) +will +start +by +counting +from +0 +ignoring +the +/ +/ +/ +first_vertex +and +first_instance +parameters +. +/ +/ +/ +/ +/ +/ +For +example +if +you +had +a +draw +call +like +this +: +/ +/ +/ +- +first_vertex +: +4 +/ +/ +/ +- +vertex_count +: +12 +/ +/ +/ +/ +/ +/ +When +this +flag +is +present +builtin +( +vertex_index +) +will +start +at +4 +and +go +up +to +15 +( +12 +invocations +) +. +/ +/ +/ +/ +/ +/ +When +this +flag +is +not +present +builtin +( +vertex_index +) +will +start +at +0 +and +go +up +to +11 +( +12 +invocations +) +. +/ +/ +/ +/ +/ +/ +This +only +affects +the +builtins +in +the +shaders +/ +/ +/ +vertex +buffers +and +instance +rate +vertex +buffers +will +behave +like +expected +with +this +flag +disabled +. +/ +/ +/ +/ +/ +/ +See +also +[ +Features +: +: +] +/ +/ +/ +/ +/ +/ +Supported +By +: +/ +/ +/ +- +Vulkan +/ +/ +/ +- +Metal +/ +/ +/ +- +OpenGL +/ +/ +/ +/ +/ +/ +Will +be +implemented +in +the +future +by +: +/ +/ +/ +- +DX12 +( +[ +# +2471 +] +( +https +: +/ +/ +github +. +com +/ +gfx +- +rs +/ +wgpu +/ +issues +/ +2471 +) +) +const +VERTEX_AND_INSTANCE_INDEX_RESPECTS_RESPECTIVE_FIRST_VALUE_IN_INDIRECT_DRAW += +1 +< +< +23 +; } } impl_bitflags @@ -13407,70 +14190,131 @@ L / / / -Features +Specifies +the +features that +are +required +by the device -should -support +request . -If -any -feature -is -not -supported -by / / / +The +request +will +fail +if the adapter -creating -a -device +cannot +provide +these +features +. +/ +/ +/ +/ +/ +/ +Exactly +the +specified +set +of +features +and +no +more +or +less +/ +/ +/ will -panic +be +allowed +in +validation +of +API +calls +on +the +resulting +device . pub -features +required_features : Features / / / -Limits +Specifies +the +limits that +are +required +by the device -should -support +request . -If -any -limit -is -" -better -" -than -the -limit -exposed -by / / / +The +request +will +fail +if the adapter -creating -a -device +cannot +provide +these +limits +. +/ +/ +/ +/ +/ +/ +Exactly +the +specified +limits +and +no +better +or +worse +/ +/ +/ will -panic +be +allowed +in +validation +of +API +calls +on +the +resulting +device . pub -limits +required_limits : Limits } @@ -13539,16 +14383,16 @@ self . label ) -features +required_features : self . -features -limits +required_features +required_limits : self . -limits +required_limits . clone ( @@ -20023,6 +20867,146 @@ format Depth32FloatStencil8 / / +/ +YUV +4 +: +2 +: +0 +chroma +subsampled +format +. +/ +/ +/ +/ +/ +/ +Contains +two +planes +: +/ +/ +/ +- +0 +: +Single +8 +bit +channel +luminance +. +/ +/ +/ +- +1 +: +Dual +8 +bit +channel +chrominance +at +half +width +and +half +height +. +/ +/ +/ +/ +/ +/ +Valid +view +formats +for +luminance +are +[ +TextureFormat +: +: +R8Unorm +] +and +[ +TextureFormat +: +: +R8Uint +] +. +/ +/ +/ +/ +/ +/ +Valid +view +formats +for +chrominance +are +[ +TextureFormat +: +: +Rg8Unorm +] +and +[ +TextureFormat +: +: +Rg8Uint +] +. +/ +/ +/ +/ +/ +/ +Width +and +height +must +be +even +. +/ +/ +/ +/ +/ +/ +[ +Features +: +: +TEXTURE_FORMAT_NV12 +] +must +be +enabled +to +use +this +texture +format +. +NV12 +/ +/ Compressed textures usable @@ -22733,6 +23717,15 @@ TextureFormat : Depth24PlusStencil8 " +nv12 +" += +> +TextureFormat +: +: +NV12 +" rgb9e5ufloat " = @@ -23877,6 +24870,15 @@ stencil8 TextureFormat : : +NV12 += +> +" +nv12 +" +TextureFormat +: +: Rgb9e5Ufloat = > @@ -25313,6 +26315,16 @@ Depth32FloatStencil8 Self : : +NV12 += +> +( +2 +2 +) +Self +: +: Bc1RgbaUnorm | Self @@ -25892,6 +26904,16 @@ DEPTH32FLOAT_STENCIL8 Self : : +NV12 += +> +Features +: +: +TEXTURE_FORMAT_NV12 +Self +: +: R16Unorm | Self @@ -26214,6 +27236,14 @@ TextureUsages STORAGE_BINDING ; let +binding += +TextureUsages +: +: +TEXTURE_BINDING +; +let all_flags = TextureUsages @@ -26715,6 +27745,31 @@ Depth32FloatStencil8 msaa attachment ) +/ +/ +We +only +support +sampling +nv12 +textures +until +we +implement +transfer +plane +data +. +Self +: +: +NV12 += +> +( +noaa +binding +) Self : : @@ -27041,15 +28096,77 @@ basic ) } ; +/ +/ +Get +whether +the +format +is +filterable +taking +features +into +account +let +sample_type1 += +self +. +sample_type +( +None +Some +( +device_features +) +) +; let is_filterable = +sample_type1 += += +Some +( +TextureSampleType +: +: +Float +{ +filterable +: +true +} +) +; +/ +/ +Features +that +enable +filtering +don +' +t +affect +blendability +let +sample_type2 += self . sample_type ( None +None ) +; +let +is_blendable += +sample_type2 = = Some @@ -27084,7 +28201,7 @@ TextureFormatFeatureFlags : : BLENDABLE -is_filterable +is_blendable ) ; TextureFormatFeatures @@ -27148,6 +28265,12 @@ Option < TextureAspect > +device_features +: +Option +< +Features +> ) - > @@ -27170,7 +28293,7 @@ true } ; let -unfilterable_float +float32_sample_type = TextureSampleType : @@ -27179,7 +28302,25 @@ Float { filterable : -false +device_features +. +unwrap_or +( +Features +: +: +empty +( +) +) +. +contains +( +Features +: +: +FLOAT32_FILTERABLE +) } ; let @@ -27303,7 +28444,7 @@ Rgba32Float > Some ( -unfilterable_float +float32_sample_type ) Self : @@ -27496,6 +28637,13 @@ uint Self : : +NV12 += +> +None +Self +: +: R16Unorm | Self @@ -28488,6 +29636,13 @@ Some Self : : +NV12 += +> +None +Self +: +: Bc1RgbaUnorm | Self @@ -29013,6 +30168,13 @@ StencilOnly Self : : +NV12 += +> +3 +Self +: +: Bc4RUnorm | Self @@ -55390,9 +56552,10 @@ C [ derive ( -Clone Copy +Clone Debug +Default ) ] pub @@ -55430,17 +56593,14 @@ u32 / / / -Offset -into +The +Index +of the +first vertex -buffers -in -vertices to -begin -drawing -from +draw . pub first_vertex @@ -55449,16 +56609,131 @@ u32 / / / -First +The +instance +ID +of +the +first instance to draw . +/ +/ +/ +/ +/ +/ +Has +to +be +0 +unless +[ +Features +: +: +INDIRECT_FIRST_INSTANCE +] +( +crate +: +: +Features +: +: +INDIRECT_FIRST_INSTANCE +) +is +enabled +. pub first_instance : u32 } +impl +DrawIndirectArgs +{ +/ +/ +/ +Returns +the +bytes +representation +of +the +struct +ready +to +be +written +in +a +buffer +. +pub +fn +as_bytes +( +& +self +) +- +> +& +[ +u8 +] +{ +unsafe +{ +std +: +: +mem +: +: +transmute +( +std +: +: +slice +: +: +from_raw_parts +( +self +as +* +const +_ +as +* +const +u8 +std +: +: +mem +: +: +size_of +: +: +< +Self +> +( +) +) +) +} +} +} / / / @@ -55480,9 +56755,10 @@ C [ derive ( -Clone Copy +Clone Debug +Default ) ] pub @@ -55520,16 +56796,13 @@ u32 / / / -Offset -into +The +first +index +within the index buffer -in -indices -begin -drawing -from . pub first_index @@ -55538,17 +56811,19 @@ u32 / / / -Added +The +value +added to -each +the +vertex index -value before indexing into the vertex -buffers +buffer . pub base_vertex @@ -55557,16 +56832,131 @@ i32 / / / -First +The +instance +ID +of +the +first instance to draw . +/ +/ +/ +/ +/ +/ +Has +to +be +0 +unless +[ +Features +: +: +INDIRECT_FIRST_INSTANCE +] +( +crate +: +: +Features +: +: +INDIRECT_FIRST_INSTANCE +) +is +enabled +. pub first_instance : u32 } +impl +DrawIndexedIndirectArgs +{ +/ +/ +/ +Returns +the +bytes +representation +of +the +struct +ready +to +be +written +in +a +buffer +. +pub +fn +as_bytes +( +& +self +) +- +> +& +[ +u8 +] +{ +unsafe +{ +std +: +: +mem +: +: +transmute +( +std +: +: +slice +: +: +from_raw_parts +( +self +as +* +const +_ +as +* +const +u8 +std +: +: +mem +: +: +size_of +: +: +< +Self +> +( +) +) +) +} +} +} / / / @@ -55588,9 +56978,10 @@ C [ derive ( -Clone Copy +Clone Debug +Default ) ] pub @@ -55600,54 +56991,132 @@ DispatchIndirectArgs / / / +The +number +of +work +groups +in X dimension -of -the -grid -of -workgroups -to -dispatch . pub -group_size_x +x : u32 / / / +The +number +of +work +groups +in Y dimension -of -the -grid -of -workgroups -to -dispatch . pub -group_size_y +y : u32 / / / +The +number +of +work +groups +in Z dimension -of +. +pub +z +: +u32 +} +impl +DispatchIndirectArgs +{ +/ +/ +/ +Returns the -grid +bytes +representation of -workgroups +the +struct +ready to -dispatch +be +written +into +a +buffer . pub -group_size_z +fn +as_bytes +( +& +self +) +- +> +& +[ +u8 +] +{ +unsafe +{ +std : -u32 +: +mem +: +: +transmute +( +std +: +: +slice +: +: +from_raw_parts +( +self +as +* +const +_ +as +* +const +u8 +std +: +: +mem +: +: +size_of +: +: +< +Self +> +( +) +) +) +} +} } / /