Skip to content

Commit 0c2a7e7

Browse files
committed
Deploying to master from @ 7aca31fe9c87ed0d5005ae8a82e1474113a63c70 🚀
1 parent 164ac36 commit 0c2a7e7

File tree

80 files changed

+751
-541
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+751
-541
lines changed

‎doc/search-index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎doc/src/wgpu_hal/auxil/mod.rs.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,17 @@
136136
<span id="136">136</span>
137137
<span id="137">137</span>
138138
<span id="138">138</span>
139+
<span id="139">139</span>
140+
<span id="140">140</span>
141+
<span id="141">141</span>
142+
<span id="142">142</span>
143+
<span id="143">143</span>
144+
<span id="144">144</span>
145+
<span id="145">145</span>
146+
<span id="146">146</span>
147+
<span id="147">147</span>
148+
<span id="148">148</span>
149+
<span id="149">149</span>
139150
</pre><pre class="rust"><code><span class="attribute">#[cfg(any(feature = <span class="string">&quot;dx11&quot;</span>, feature = <span class="string">&quot;dx12&quot;</span>))]
140151
</span><span class="kw">pub</span>(<span class="kw">super</span>) <span class="kw">mod </span>dxgi;
141152

@@ -204,6 +215,17 @@
204215
}
205216

206217
<span class="kw">impl </span><span class="kw">crate</span>::CopyExtent {
218+
<span class="kw">pub fn </span>map_extent_to_copy_size(extent: <span class="kw-2">&amp;</span>wgt::Extent3d, dim: wgt::TextureDimension) -&gt; <span class="self">Self </span>{
219+
<span class="self">Self </span>{
220+
width: extent.width,
221+
height: extent.height,
222+
depth: <span class="kw">match </span>dim {
223+
wgt::TextureDimension::D1 | wgt::TextureDimension::D2 =&gt; <span class="number">1</span>,
224+
wgt::TextureDimension::D3 =&gt; extent.depth_or_array_layers,
225+
},
226+
}
227+
}
228+
207229
<span class="kw">pub fn </span>min(<span class="kw-2">&amp;</span><span class="self">self</span>, other: <span class="kw-2">&amp;</span><span class="self">Self</span>) -&gt; <span class="self">Self </span>{
208230
<span class="self">Self </span>{
209231
width: <span class="self">self</span>.width.min(other.width),

‎doc/src/wgpu_hal/gles/device.rs.html

Lines changed: 142 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,60 @@
11681168
<span id="1168">1168</span>
11691169
<span id="1169">1169</span>
11701170
<span id="1170">1170</span>
1171+
<span id="1171">1171</span>
1172+
<span id="1172">1172</span>
1173+
<span id="1173">1173</span>
1174+
<span id="1174">1174</span>
1175+
<span id="1175">1175</span>
1176+
<span id="1176">1176</span>
1177+
<span id="1177">1177</span>
1178+
<span id="1178">1178</span>
1179+
<span id="1179">1179</span>
1180+
<span id="1180">1180</span>
1181+
<span id="1181">1181</span>
1182+
<span id="1182">1182</span>
1183+
<span id="1183">1183</span>
1184+
<span id="1184">1184</span>
1185+
<span id="1185">1185</span>
1186+
<span id="1186">1186</span>
1187+
<span id="1187">1187</span>
1188+
<span id="1188">1188</span>
1189+
<span id="1189">1189</span>
1190+
<span id="1190">1190</span>
1191+
<span id="1191">1191</span>
1192+
<span id="1192">1192</span>
1193+
<span id="1193">1193</span>
1194+
<span id="1194">1194</span>
1195+
<span id="1195">1195</span>
1196+
<span id="1196">1196</span>
1197+
<span id="1197">1197</span>
1198+
<span id="1198">1198</span>
1199+
<span id="1199">1199</span>
1200+
<span id="1200">1200</span>
1201+
<span id="1201">1201</span>
1202+
<span id="1202">1202</span>
1203+
<span id="1203">1203</span>
1204+
<span id="1204">1204</span>
1205+
<span id="1205">1205</span>
1206+
<span id="1206">1206</span>
1207+
<span id="1207">1207</span>
1208+
<span id="1208">1208</span>
1209+
<span id="1209">1209</span>
1210+
<span id="1210">1210</span>
1211+
<span id="1211">1211</span>
1212+
<span id="1212">1212</span>
1213+
<span id="1213">1213</span>
1214+
<span id="1214">1214</span>
1215+
<span id="1215">1215</span>
1216+
<span id="1216">1216</span>
1217+
<span id="1217">1217</span>
1218+
<span id="1218">1218</span>
1219+
<span id="1219">1219</span>
1220+
<span id="1220">1220</span>
1221+
<span id="1221">1221</span>
1222+
<span id="1222">1222</span>
1223+
<span id="1223">1223</span>
1224+
<span id="1224">1224</span>
11711225
</pre><pre class="rust"><code><span class="kw">use </span><span class="kw">super</span>::conv;
11721226
<span class="kw">use </span><span class="kw">crate</span>::auxil::map_naga_stage;
11731227
<span class="kw">use </span>glow::HasContext;
@@ -1254,6 +1308,77 @@
12541308
}
12551309

12561310
<span class="kw">impl </span><span class="kw">super</span>::Device {
1311+
<span class="doccomment">/// # Safety
1312+
///
1313+
/// - `name` must be created respecting `desc`
1314+
/// - `name` must be a texture
1315+
/// - If `drop_guard` is [`None`], wgpu-hal will take ownership of the texture. If `drop_guard` is
1316+
/// [`Some`], the texture must be valid until the drop implementation
1317+
/// of the drop guard is called.
1318+
</span><span class="attribute">#[cfg(any(not(target_arch = <span class="string">&quot;wasm32&quot;</span>), feature = <span class="string">&quot;emscripten&quot;</span>))]
1319+
</span><span class="kw">pub unsafe fn </span>texture_from_raw(
1320+
<span class="kw-2">&amp;</span><span class="self">self</span>,
1321+
name: std::num::NonZeroU32,
1322+
desc: <span class="kw-2">&amp;</span><span class="kw">crate</span>::TextureDescriptor,
1323+
drop_guard: <span class="prelude-ty">Option</span>&lt;<span class="kw">crate</span>::DropGuard&gt;,
1324+
) -&gt; <span class="kw">super</span>::Texture {
1325+
<span class="kw">let </span><span class="kw-2">mut </span>copy_size = <span class="kw">crate</span>::CopyExtent::map_extent_to_copy_size(<span class="kw-2">&amp;</span>desc.size, desc.dimension);
1326+
1327+
<span class="kw">let </span>(target, <span class="kw">_</span>, is_cubemap) = <span class="kw">super</span>::Texture::get_info_from_desc(<span class="kw-2">&amp;mut </span>copy_size, desc);
1328+
1329+
<span class="kw">super</span>::Texture {
1330+
inner: <span class="kw">super</span>::TextureInner::Texture {
1331+
raw: glow::NativeTexture(name),
1332+
target,
1333+
},
1334+
drop_guard,
1335+
mip_level_count: desc.mip_level_count,
1336+
array_layer_count: <span class="kw">if </span>desc.dimension == wgt::TextureDimension::D2 {
1337+
desc.size.depth_or_array_layers
1338+
} <span class="kw">else </span>{
1339+
<span class="number">1
1340+
</span>},
1341+
format: desc.format,
1342+
format_desc: <span class="self">self</span>.shared.describe_texture_format(desc.format),
1343+
copy_size,
1344+
is_cubemap,
1345+
}
1346+
}
1347+
1348+
<span class="doccomment">/// # Safety
1349+
///
1350+
/// - `name` must be created respecting `desc`
1351+
/// - `name` must be a renderbuffer
1352+
/// - If `drop_guard` is [`None`], wgpu-hal will take ownership of the renderbuffer. If `drop_guard` is
1353+
/// [`Some`], the renderbuffer must be valid until the drop implementation
1354+
/// of the drop guard is called.
1355+
</span><span class="attribute">#[cfg(any(not(target_arch = <span class="string">&quot;wasm32&quot;</span>), feature = <span class="string">&quot;emscripten&quot;</span>))]
1356+
</span><span class="kw">pub unsafe fn </span>texture_from_raw_renderbuffer(
1357+
<span class="kw-2">&amp;</span><span class="self">self</span>,
1358+
name: std::num::NonZeroU32,
1359+
desc: <span class="kw-2">&amp;</span><span class="kw">crate</span>::TextureDescriptor,
1360+
drop_guard: <span class="prelude-ty">Option</span>&lt;<span class="kw">crate</span>::DropGuard&gt;,
1361+
) -&gt; <span class="kw">super</span>::Texture {
1362+
<span class="kw">let </span>copy_size = <span class="kw">crate</span>::CopyExtent::map_extent_to_copy_size(<span class="kw-2">&amp;</span>desc.size, desc.dimension);
1363+
1364+
<span class="kw">super</span>::Texture {
1365+
inner: <span class="kw">super</span>::TextureInner::Renderbuffer {
1366+
raw: glow::NativeRenderbuffer(name),
1367+
},
1368+
drop_guard,
1369+
mip_level_count: desc.mip_level_count,
1370+
array_layer_count: <span class="kw">if </span>desc.dimension == wgt::TextureDimension::D2 {
1371+
desc.size.depth_or_array_layers
1372+
} <span class="kw">else </span>{
1373+
<span class="number">1
1374+
</span>},
1375+
format: desc.format,
1376+
format_desc: <span class="self">self</span>.shared.describe_texture_format(desc.format),
1377+
copy_size,
1378+
is_cubemap: <span class="bool-val">false</span>,
1379+
}
1380+
}
1381+
12571382
<span class="kw">unsafe fn </span>compile_shader(
12581383
gl: <span class="kw-2">&amp;</span>glow::Context,
12591384
shader: <span class="kw-2">&amp;</span>str,
@@ -1751,32 +1876,8 @@
17511876
(<span class="kw">super</span>::TextureInner::Renderbuffer { raw }, <span class="bool-val">false</span>)
17521877
} <span class="kw">else </span>{
17531878
<span class="kw">let </span>raw = gl.create_texture().unwrap();
1754-
<span class="kw">let </span>(target, is_3d, is_cubemap) = <span class="kw">match </span>desc.dimension {
1755-
wgt::TextureDimension::D1 | wgt::TextureDimension::D2 =&gt; {
1756-
<span class="kw">if </span>desc.size.depth_or_array_layers &gt; <span class="number">1 </span>{
1757-
<span class="comment">//HACK: detect a cube map
1758-
</span><span class="kw">let </span>cube_count = <span class="kw">if </span>desc.size.width == desc.size.height
1759-
&amp;&amp; desc.size.depth_or_array_layers % <span class="number">6 </span>== <span class="number">0
1760-
</span>&amp;&amp; desc.sample_count == <span class="number">1
1761-
</span>{
1762-
<span class="prelude-val">Some</span>(desc.size.depth_or_array_layers / <span class="number">6</span>)
1763-
} <span class="kw">else </span>{
1764-
<span class="prelude-val">None
1765-
</span>};
1766-
<span class="kw">match </span>cube_count {
1767-
<span class="prelude-val">None </span>=&gt; (glow::TEXTURE_2D_ARRAY, <span class="bool-val">true</span>, <span class="bool-val">false</span>),
1768-
<span class="prelude-val">Some</span>(<span class="number">1</span>) =&gt; (glow::TEXTURE_CUBE_MAP, <span class="bool-val">false</span>, <span class="bool-val">true</span>),
1769-
<span class="prelude-val">Some</span>(<span class="kw">_</span>) =&gt; (glow::TEXTURE_CUBE_MAP_ARRAY, <span class="bool-val">true</span>, <span class="bool-val">true</span>),
1770-
}
1771-
} <span class="kw">else </span>{
1772-
(glow::TEXTURE_2D, <span class="bool-val">false</span>, <span class="bool-val">false</span>)
1773-
}
1774-
}
1775-
wgt::TextureDimension::D3 =&gt; {
1776-
copy_size.depth = desc.size.depth_or_array_layers;
1777-
(glow::TEXTURE_3D, <span class="bool-val">true</span>, <span class="bool-val">false</span>)
1778-
}
1779-
};
1879+
<span class="kw">let </span>(target, is_3d, is_cubemap) =
1880+
<span class="kw">super</span>::Texture::get_info_from_desc(<span class="kw-2">&amp;mut </span>copy_size, desc);
17801881

17811882
gl.bind_texture(target, <span class="prelude-val">Some</span>(raw));
17821883
<span class="comment">//Note: this has to be done before defining the storage!
@@ -1833,6 +1934,7 @@
18331934

18341935
<span class="prelude-val">Ok</span>(<span class="kw">super</span>::Texture {
18351936
inner,
1937+
drop_guard: <span class="prelude-val">None</span>,
18361938
mip_level_count: desc.mip_level_count,
18371939
array_layer_count: <span class="kw">if </span>desc.dimension == wgt::TextureDimension::D2 {
18381940
desc.size.depth_or_array_layers
@@ -1846,16 +1948,22 @@
18461948
})
18471949
}
18481950
<span class="kw">unsafe fn </span>destroy_texture(<span class="kw-2">&amp;</span><span class="self">self</span>, texture: <span class="kw">super</span>::Texture) {
1849-
<span class="kw">let </span>gl = <span class="kw-2">&amp;</span><span class="self">self</span>.shared.context.lock();
1850-
<span class="kw">match </span>texture.inner {
1851-
<span class="kw">super</span>::TextureInner::Renderbuffer { raw, .. } =&gt; {
1852-
gl.delete_renderbuffer(raw);
1853-
}
1854-
<span class="kw">super</span>::TextureInner::DefaultRenderbuffer =&gt; {}
1855-
<span class="kw">super</span>::TextureInner::Texture { raw, .. } =&gt; {
1856-
gl.delete_texture(raw);
1951+
<span class="kw">if </span>texture.drop_guard.is_none() {
1952+
<span class="kw">let </span>gl = <span class="kw-2">&amp;</span><span class="self">self</span>.shared.context.lock();
1953+
<span class="kw">match </span>texture.inner {
1954+
<span class="kw">super</span>::TextureInner::Renderbuffer { raw, .. } =&gt; {
1955+
gl.delete_renderbuffer(raw);
1956+
}
1957+
<span class="kw">super</span>::TextureInner::DefaultRenderbuffer =&gt; {}
1958+
<span class="kw">super</span>::TextureInner::Texture { raw, .. } =&gt; {
1959+
gl.delete_texture(raw);
1960+
}
18571961
}
18581962
}
1963+
1964+
<span class="comment">// For clarity, we explicitly drop the drop guard. Although this has no real semantic effect as the
1965+
// end of the scope will drop the drop guard since this function takes ownership of the texture.
1966+
</span>drop(texture.drop_guard);
18591967
}
18601968

18611969
<span class="kw">unsafe fn </span>create_texture_view(

‎doc/src/wgpu_hal/gles/egl.rs.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,7 @@
12591259
<span id="1259">1259</span>
12601260
<span id="1260">1260</span>
12611261
<span id="1261">1261</span>
1262+
<span id="1262">1262</span>
12621263
</pre><pre class="rust"><code><span class="kw">use </span>glow::HasContext;
12631264
<span class="kw">use </span>parking_lot::{Mutex, MutexGuard};
12641265

@@ -2502,6 +2503,7 @@
25022503
inner: <span class="kw">super</span>::TextureInner::Renderbuffer {
25032504
raw: sc.renderbuffer,
25042505
},
2506+
drop_guard: <span class="prelude-val">None</span>,
25052507
array_layer_count: <span class="number">1</span>,
25062508
mip_level_count: <span class="number">1</span>,
25072509
format: sc.format,

‎doc/src/wgpu_hal/gles/mod.rs.html

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,43 @@
785785
<span id="785">785</span>
786786
<span id="786">786</span>
787787
<span id="787">787</span>
788+
<span id="788">788</span>
789+
<span id="789">789</span>
790+
<span id="790">790</span>
791+
<span id="791">791</span>
792+
<span id="792">792</span>
793+
<span id="793">793</span>
794+
<span id="794">794</span>
795+
<span id="795">795</span>
796+
<span id="796">796</span>
797+
<span id="797">797</span>
798+
<span id="798">798</span>
799+
<span id="799">799</span>
800+
<span id="800">800</span>
801+
<span id="801">801</span>
802+
<span id="802">802</span>
803+
<span id="803">803</span>
804+
<span id="804">804</span>
805+
<span id="805">805</span>
806+
<span id="806">806</span>
807+
<span id="807">807</span>
808+
<span id="808">808</span>
809+
<span id="809">809</span>
810+
<span id="810">810</span>
811+
<span id="811">811</span>
812+
<span id="812">812</span>
813+
<span id="813">813</span>
814+
<span id="814">814</span>
815+
<span id="815">815</span>
816+
<span id="816">816</span>
817+
<span id="817">817</span>
818+
<span id="818">818</span>
819+
<span id="819">819</span>
820+
<span id="820">820</span>
821+
<span id="821">821</span>
822+
<span id="822">822</span>
823+
<span id="823">823</span>
824+
<span id="824">824</span>
788825
</pre><pre class="rust"><code><span class="doccomment">/*!
789826
# OpenGL ES3 API (aka GLES3).
790827

@@ -855,6 +892,8 @@
855892
<span class="kw">mod </span>device;
856893
<span class="kw">mod </span>queue;
857894

895+
<span class="kw">use crate</span>::{CopyExtent, TextureDescriptor};
896+
858897
<span class="attribute">#[cfg(any(not(target_arch = <span class="string">&quot;wasm32&quot;</span>), feature = <span class="string">&quot;emscripten&quot;</span>))]
859898
</span><span class="kw">pub use </span><span class="self">self</span>::egl::{AdapterContext, AdapterContextLock};
860899
<span class="attribute">#[cfg(any(not(target_arch = <span class="string">&quot;wasm32&quot;</span>), feature = <span class="string">&quot;emscripten&quot;</span>))]
@@ -1052,19 +1091,21 @@
10521091
<span class="attribute">#[derive(Debug)]
10531092
</span><span class="kw">pub struct </span>Texture {
10541093
inner: TextureInner,
1094+
drop_guard: <span class="prelude-ty">Option</span>&lt;<span class="kw">crate</span>::DropGuard&gt;,
10551095
mip_level_count: u32,
10561096
array_layer_count: u32,
10571097
format: wgt::TextureFormat,
10581098
<span class="attribute">#[allow(unused)]
10591099
</span>format_desc: TextureFormatDesc,
1060-
copy_size: <span class="kw">crate</span>::CopyExtent,
1100+
copy_size: CopyExtent,
10611101
is_cubemap: bool,
10621102
}
10631103

10641104
<span class="kw">impl </span>Texture {
10651105
<span class="kw">pub fn </span>default_framebuffer(format: wgt::TextureFormat) -&gt; <span class="self">Self </span>{
10661106
<span class="self">Self </span>{
10671107
inner: TextureInner::DefaultRenderbuffer,
1108+
drop_guard: <span class="prelude-val">None</span>,
10681109
mip_level_count: <span class="number">1</span>,
10691110
array_layer_count: <span class="number">1</span>,
10701111
format,
@@ -1073,14 +1114,47 @@
10731114
external: <span class="number">0</span>,
10741115
data_type: <span class="number">0</span>,
10751116
},
1076-
copy_size: <span class="kw">crate</span>::CopyExtent {
1117+
copy_size: CopyExtent {
10771118
width: <span class="number">0</span>,
10781119
height: <span class="number">0</span>,
10791120
depth: <span class="number">0</span>,
10801121
},
10811122
is_cubemap: <span class="bool-val">false</span>,
10821123
}
10831124
}
1125+
1126+
<span class="doccomment">/// Returns the `target`, whether the image is 3d and whether the image is a cubemap.
1127+
</span><span class="kw">fn </span>get_info_from_desc(
1128+
copy_size: <span class="kw-2">&amp;mut </span>CopyExtent,
1129+
desc: <span class="kw-2">&amp;</span>TextureDescriptor,
1130+
) -&gt; (u32, bool, bool) {
1131+
<span class="kw">match </span>desc.dimension {
1132+
wgt::TextureDimension::D1 | wgt::TextureDimension::D2 =&gt; {
1133+
<span class="kw">if </span>desc.size.depth_or_array_layers &gt; <span class="number">1 </span>{
1134+
<span class="comment">//HACK: detect a cube map
1135+
</span><span class="kw">let </span>cube_count = <span class="kw">if </span>desc.size.width == desc.size.height
1136+
&amp;&amp; desc.size.depth_or_array_layers % <span class="number">6 </span>== <span class="number">0
1137+
</span>&amp;&amp; desc.sample_count == <span class="number">1
1138+
</span>{
1139+
<span class="prelude-val">Some</span>(desc.size.depth_or_array_layers / <span class="number">6</span>)
1140+
} <span class="kw">else </span>{
1141+
<span class="prelude-val">None
1142+
</span>};
1143+
<span class="kw">match </span>cube_count {
1144+
<span class="prelude-val">None </span>=&gt; (glow::TEXTURE_2D_ARRAY, <span class="bool-val">true</span>, <span class="bool-val">false</span>),
1145+
<span class="prelude-val">Some</span>(<span class="number">1</span>) =&gt; (glow::TEXTURE_CUBE_MAP, <span class="bool-val">false</span>, <span class="bool-val">true</span>),
1146+
<span class="prelude-val">Some</span>(<span class="kw">_</span>) =&gt; (glow::TEXTURE_CUBE_MAP_ARRAY, <span class="bool-val">true</span>, <span class="bool-val">true</span>),
1147+
}
1148+
} <span class="kw">else </span>{
1149+
(glow::TEXTURE_2D, <span class="bool-val">false</span>, <span class="bool-val">false</span>)
1150+
}
1151+
}
1152+
wgt::TextureDimension::D3 =&gt; {
1153+
copy_size.depth = desc.size.depth_or_array_layers;
1154+
(glow::TEXTURE_3D, <span class="bool-val">true</span>, <span class="bool-val">false</span>)
1155+
}
1156+
}
1157+
}
10841158
}
10851159

10861160
<span class="attribute">#[derive(Clone, Debug)]

0 commit comments

Comments
 (0)