device.rs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. //! The device titles get from device creation, laid out as their inlined
  2. //! code expects: the object header, then device fields. Its table starts
  3. //! like the PC device interface (IUnknown, the object methods, then the
  4. //! device methods in PC order); console additions follow. Methods we have
  5. //! not written log their table offset and fail, so a run shows what to
  6. //! write next.
  7. #![allow(clippy::not_unsafe_ptr_arg_deref)]
  8. use std::ffi::c_void;
  9. use crate::object::{
  10. self, E_INVALIDARG, E_NOINTERFACE, E_NOTIMPL, HRESULT, Iid, Object, S_FALSE, S_OK, Table, This,
  11. guid, guid_text,
  12. };
  13. use crate::{
  14. descriptor, dxgi, fence, frame, list, pipeline, query, queue, resource, root, signature,
  15. };
  16. /// What D3D returns when none of the requested feature levels is supported.
  17. const UNSUPPORTED: HRESULT = 0x887A_0004_u32 as i32;
  18. /// The device interface id (the same as on PC). Titles also import it as
  19. /// data.
  20. pub static IID: Iid = guid(
  21. 0x189819f1,
  22. 0x1db6,
  23. 0x4b57,
  24. [0xbe, 0x54, 0x18, 0x21, 0x33, 0x9b, 0x85, 0xf7],
  25. );
  26. /// The levels the device answers to, as on PC: `ID3D12Device1` to
  27. /// `ID3D12Device8`, and `ID3D12Device11`, which Grand Theft Auto VI creates
  28. /// its device as. Each level's table is the one before plus its methods.
  29. const LEVEL_IIDS: [Iid; 9] = [
  30. guid(
  31. 0x77acce80,
  32. 0x638e,
  33. 0x4e65,
  34. [0x88, 0x95, 0xc1, 0xf2, 0x33, 0x86, 0x86, 0x3e],
  35. ),
  36. guid(
  37. 0x30baa41e,
  38. 0xb15b,
  39. 0x475c,
  40. [0xa0, 0xbb, 0x1a, 0xf5, 0xc5, 0xb6, 0x43, 0x28],
  41. ),
  42. guid(
  43. 0x81dadc15,
  44. 0x2bad,
  45. 0x4392,
  46. [0x93, 0xc5, 0x10, 0x13, 0x45, 0xc4, 0xaa, 0x98],
  47. ),
  48. guid(
  49. 0xe865df17,
  50. 0xa9ee,
  51. 0x46f9,
  52. [0xa4, 0x63, 0x30, 0x98, 0x31, 0x5a, 0xa2, 0xe5],
  53. ),
  54. guid(
  55. 0x8b4f173b,
  56. 0x2fea,
  57. 0x4b80,
  58. [0x8f, 0x58, 0x43, 0x07, 0x19, 0x1a, 0xb9, 0x5d],
  59. ),
  60. guid(
  61. 0xc70b221b,
  62. 0x40e4,
  63. 0x4a17,
  64. [0x89, 0xaf, 0x02, 0x5a, 0x07, 0x27, 0xa6, 0xdc],
  65. ),
  66. guid(
  67. 0x5c014b53,
  68. 0x68a1,
  69. 0x4b9b,
  70. [0x8b, 0xd1, 0xdd, 0x60, 0x46, 0xb9, 0x35, 0x8b],
  71. ),
  72. guid(
  73. 0x728f1fa2,
  74. 0xea11,
  75. 0x4a9f,
  76. [0x9b, 0x52, 0x9b, 0x42, 0xa4, 0x84, 0xd5, 0xc9],
  77. ),
  78. guid(
  79. 0x5405c344,
  80. 0xd457,
  81. 0x444e,
  82. [0xb4, 0xdd, 0x23, 0x66, 0xe4, 0x5a, 0xee, 0x39],
  83. ),
  84. ];
  85. /// Whether `iid` names the device: its first interface or a newer level.
  86. pub(crate) fn is_device(iid: *const Iid) -> bool {
  87. object::is(iid, &[IID]) || object::is(iid, &LEVEL_IIDS)
  88. }
  89. /// The interface version these layouts were checked against (2.4). Both
  90. /// Minecraft (March 2022) and Grand Theft Auto VI (April 2026) pass it.
  91. pub const CHECKED_VERSION: u32 = 0x0002_0004;
  92. /// Feature level 12_2, what the console hardware supports.
  93. const HIGHEST_FEATURE_LEVEL: u32 = 0xc200;
  94. #[repr(C)]
  95. pub struct Device {
  96. object: Object,
  97. /// GPU address of a null constant buffer; none yet.
  98. null_constant_buffer: u64,
  99. /// Byte 0 non-zero: calls the title would otherwise inline come to the
  100. /// table. The rest is reserved.
  101. out_of_line: [u32; 16],
  102. }
  103. const _: () = assert!(size_of::<Device>() == 0x58);
  104. /// One device per process, as on the console.
  105. pub(crate) static DEVICE: Device = Device {
  106. object: Object::new(&FUNCTIONS),
  107. null_constant_buffer: 0,
  108. out_of_line: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  109. };
  110. pub(crate) fn device() -> This {
  111. (&raw const DEVICE).cast()
  112. }
  113. /// Device creation: `(adapter, parameters, iid, out)`. The parameters start
  114. /// with the interface version; the rest (ring and scratch sizes, features
  115. /// to leave out) does not matter to us yet.
  116. pub extern "system" fn create(
  117. _adapter: *const c_void,
  118. parameters: *const u32,
  119. iid: *const Iid,
  120. out: *mut This,
  121. ) -> HRESULT {
  122. if parameters.is_null() || iid.is_null() {
  123. return E_INVALIDARG;
  124. }
  125. // SAFETY: checked non-null; the title passes its parameters and an id.
  126. let (version, iid) = unsafe { (parameters.read(), &*iid) };
  127. tracing::info!(version = format_args!("{version:#x}"), "D3D12.X device");
  128. if version != CHECKED_VERSION {
  129. tracing::warn!(
  130. version = format_args!("{version:#x}"),
  131. "device layouts were checked against {CHECKED_VERSION:#x} only"
  132. );
  133. }
  134. if !is_device(iid) {
  135. tracing::warn!(iid = %guid_text(iid), "device created as an unknown interface");
  136. return E_NOINTERFACE;
  137. }
  138. if out.is_null() {
  139. return S_FALSE;
  140. }
  141. if *iid == LEVEL_IIDS[8] {
  142. NEWER.store(true, std::sync::atomic::Ordering::Relaxed);
  143. }
  144. object::answer(object::DEVICE, iid, Some(device()), out)
  145. }
  146. /// Set when the title creates the device as `ID3D12Device11`. Its lists and
  147. /// queues then have the newer layouts (two more methods each; see
  148. /// `list` and `queue`), although the interface version stays 2.4.
  149. /// shortcut: the creation interface is the only sign of the newer layouts
  150. /// we have (Grand Theft Auto VI, April 2026, versus Minecraft, March 2022);
  151. /// look for a better one if a title breaks the rule.
  152. static NEWER: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
  153. pub(crate) fn newer() -> bool {
  154. NEWER.load(std::sync::atomic::Ordering::Relaxed)
  155. }
  156. /// The device, or its DXGI side.
  157. extern "system" fn query_interface(this: This, iid: *const Iid, out: *mut This) -> HRESULT {
  158. let found = if is_device(iid) {
  159. Some(this)
  160. } else if object::is(iid, &dxgi::DEVICE_IIDS) {
  161. Some(dxgi::device())
  162. } else {
  163. None
  164. };
  165. object::answer(object::DEVICE, iid, found, out)
  166. }
  167. /// What `D3D12ConfigureVirtualMemoryX` takes and fills in.
  168. #[repr(C)]
  169. pub struct VirtualMemory {
  170. flags: u32,
  171. /// GPU page table size in 4 MiB pages.
  172. page_table_pages: u32,
  173. /// Memory kept across title processes for the frame buffer.
  174. preserved_bytes: u32,
  175. /// Out: the range graphics addresses fall in.
  176. lowest: u64,
  177. highest: u64,
  178. }
  179. const _: () = assert!(size_of::<VirtualMemory>() == 0x20);
  180. /// `d3d12_xs!D3D12ConfigureVirtualMemoryX`, called before any graphics
  181. /// allocation. The inputs size console structures we do not have; the
  182. /// range out is all of user space, since GPU addresses are CPU addresses.
  183. pub extern "system" fn configure_virtual_memory(config: *mut VirtualMemory) -> HRESULT {
  184. // SAFETY: the title passes its configuration (null is tolerated).
  185. let Some(config) = (unsafe { config.as_mut() }) else {
  186. return E_INVALIDARG;
  187. };
  188. tracing::info!(
  189. flags = config.flags,
  190. page_table_pages = config.page_table_pages,
  191. preserved_bytes = config.preserved_bytes,
  192. "graphics virtual memory"
  193. );
  194. (config.lowest, config.highest) = user_space();
  195. S_OK
  196. }
  197. fn user_space() -> (u64, u64) {
  198. #[cfg(windows)]
  199. {
  200. use windows_sys::Win32::System::SystemInformation::{GetSystemInfo, SYSTEM_INFO};
  201. // SAFETY: plain data, filled in by the call.
  202. let mut info: SYSTEM_INFO = unsafe { std::mem::zeroed() };
  203. // SAFETY: a valid out pointer.
  204. unsafe { GetSystemInfo(&mut info) };
  205. (
  206. info.lpMinimumApplicationAddress as u64,
  207. info.lpMaximumApplicationAddress as u64,
  208. )
  209. }
  210. #[cfg(not(windows))]
  211. (0x1_0000, 0x7fff_fffe_ffff)
  212. }
  213. extern "system" fn node_count(_: This) -> u32 {
  214. 1
  215. }
  216. /// Feature query 2: the highest of the requested feature levels we support.
  217. #[repr(C)]
  218. struct FeatureLevels {
  219. count: u32,
  220. requested: *const u32,
  221. highest: u32,
  222. }
  223. /// Feature query 0, what an RDNA 2 GPU reports. The console's layout has
  224. /// one field more than PC's (index 11).
  225. const OPTIONS: [u32; 16] = [
  226. 1, // double-precision shader operations
  227. 1, // output-merger logic operations
  228. 2, // minimum precision: 16-bit
  229. 3, // tiled resources tier
  230. 3, // resource binding tier
  231. 1, // stencil reference from pixel shaders
  232. 1, // typed UAV loads of more formats
  233. 1, // rasterizer-ordered views
  234. 3, // conservative rasterization tier
  235. 40, // GPU address bits per resource
  236. 0, // 64 KiB standard swizzle
  237. 0, // console-only field
  238. 0, // cross-node sharing tier
  239. 0, // cross-adapter row-major textures
  240. 1, // viewport and render target index from any stage
  241. 2, // resource heap tier
  242. ];
  243. extern "system" fn check_feature_support(
  244. _: This,
  245. feature: u32,
  246. data: *mut c_void,
  247. size: u32,
  248. ) -> HRESULT {
  249. const OPTIONS_QUERY: u32 = 0;
  250. const ARCHITECTURE: u32 = 1;
  251. const FEATURE_LEVELS: u32 = 2;
  252. const FORMAT_SUPPORT: u32 = 3;
  253. const MULTISAMPLE: u32 = 4;
  254. let expected = match feature {
  255. OPTIONS_QUERY => size_of_val(&OPTIONS),
  256. ARCHITECTURE => 16,
  257. FEATURE_LEVELS => size_of::<FeatureLevels>(),
  258. FORMAT_SUPPORT => 12,
  259. MULTISAMPLE => 16,
  260. _ => {
  261. tracing::warn!(feature, size, "device feature query not implemented");
  262. return E_NOTIMPL;
  263. }
  264. };
  265. if data.is_null() || size as usize != expected {
  266. return E_INVALIDARG;
  267. }
  268. match feature {
  269. OPTIONS_QUERY => {
  270. // SAFETY: checked size and non-null.
  271. unsafe { data.cast::<[u32; 16]>().write_unaligned(OPTIONS) };
  272. S_OK
  273. }
  274. ARCHITECTURE => {
  275. // SAFETY: checked size and non-null.
  276. let a = unsafe { &mut *data.cast::<[u32; 4]>() };
  277. if a[0] != 0 {
  278. return E_INVALIDARG; // one node only
  279. }
  280. // Not tile-based; unified, cache-coherent memory.
  281. a[1..].copy_from_slice(&[0, 1, 1]);
  282. S_OK
  283. }
  284. FORMAT_SUPPORT => {
  285. // SAFETY: checked size and non-null.
  286. let q = unsafe { &mut *data.cast::<[u32; 3]>() };
  287. // shortcut: every use of every format; answer from the host
  288. // device once there is one.
  289. q[1] = 0x7fff_ffff;
  290. q[2] = 0xffff;
  291. S_OK
  292. }
  293. MULTISAMPLE => {
  294. // SAFETY: checked size and non-null.
  295. let q = unsafe { &mut *data.cast::<[u32; 4]>() };
  296. // Format, sample count, flags in; one quality level out for the
  297. // counts the hardware has.
  298. q[3] = u32::from(matches!(q[1], 1 | 2 | 4 | 8));
  299. S_OK
  300. }
  301. _ => feature_levels(data),
  302. }
  303. }
  304. fn feature_levels(data: *mut c_void) -> HRESULT {
  305. // SAFETY: the caller checked size and non-null.
  306. let query = unsafe { &mut *data.cast::<FeatureLevels>() };
  307. if query.requested.is_null() {
  308. return E_INVALIDARG;
  309. }
  310. // SAFETY: the title passes `count` levels.
  311. let requested = unsafe { std::slice::from_raw_parts(query.requested, query.count as usize) };
  312. match requested
  313. .iter()
  314. .copied()
  315. .filter(|&l| l <= HIGHEST_FEATURE_LEVEL)
  316. .max()
  317. {
  318. Some(level) => {
  319. query.highest = level;
  320. S_OK
  321. }
  322. None => UNSUPPORTED,
  323. }
  324. }
  325. /// IUnknown 3, object methods 4, device methods 76 (0x18-0x290), then the
  326. /// methods `ID3D12Device1` to `ID3D12Device8` add, in order: 3, 1, 3, 6, 9,
  327. /// 1, 2, 9 (0x298-0x3a0, the console's own among them), then those of
  328. /// `ID3D12Device9` to `ID3D12Device11`, whose console layout is unknown.
  329. /// Every slot exists so that a call to one we have not written logs it.
  330. static FUNCTIONS: Table<160> = {
  331. let mut f = object::d3d12_object(object::missing_table::<{ object::DEVICE }, 160>());
  332. f[0] = query_interface as *const (); // 0x00
  333. f[7] = node_count as *const (); // 0x38
  334. f[8] = queue::create as *const (); // 0x40
  335. f[9] = list::create_allocator as *const (); // 0x48
  336. f[12] = list::create_list as *const (); // 0x60
  337. f[10] = pipeline::create_graphics as *const (); // 0x50
  338. f[11] = pipeline::create_compute as *const (); // 0x58
  339. f[13] = check_feature_support as *const (); // 0x68
  340. f[14] = descriptor::create_heap as *const (); // 0x70
  341. f[15] = descriptor::increment_size as *const (); // 0x78
  342. f[16] = root::create as *const (); // 0x80
  343. f[17] = descriptor::create_cbv as *const (); // 0x88
  344. f[18] = descriptor::create_srv as *const (); // 0x90
  345. f[19] = descriptor::create_uav as *const (); // 0x98
  346. f[20] = descriptor::create_rtv as *const (); // 0xa0
  347. f[21] = descriptor::create_dsv as *const (); // 0xa8
  348. f[22] = descriptor::create_sampler as *const (); // 0xb0
  349. f[23] = descriptor::copy as *const (); // 0xb8
  350. f[24] = descriptor::copy_simple as *const (); // 0xc0
  351. f[25] = resource::allocation_info as *const (); // 0xc8
  352. f[26] = resource::custom_heap_properties as *const (); // 0xd0
  353. f[27] = resource::create_committed as *const (); // 0xd8
  354. f[28] = resource::create_heap as *const (); // 0xe0
  355. f[29] = resource::create_placed as *const (); // 0xe8
  356. f[36] = fence::create as *const (); // 0x120
  357. f[38] = resource::copyable_footprints as *const (); // 0x130
  358. f[39] = query::create as *const (); // 0x138
  359. f[41] = signature::create as *const (); // 0x148
  360. f[48] = queue::create_x as *const (); // 0x180
  361. f[61] = descriptor::create_sampler_x as *const (); // 0x1e8
  362. f[62] = pipeline::create_compute_x as *const (); // 0x1f0
  363. f[69] = object::ignore as *const (); // 0x228 debug error filter
  364. f[70] = descriptor::create_placed_srv as *const (); // 0x230
  365. f[71] = descriptor::create_placed_uav as *const (); // 0x238
  366. f[73] = list::create_list_x as *const (); // 0x248
  367. f[74] = resource::register_page_pool as *const (); // 0x250
  368. f[75] = resource::unregister_page_pool as *const (); // 0x258
  369. // CreateCommittedResourceX: its description is PC's plus DCC options,
  370. // which we have no use for (the AMD upscaler's, on Series S).
  371. f[76] = resource::create_committed as *const (); // 0x260
  372. f[78] = frame::set_interval as *const (); // 0x270
  373. f[79] = frame::schedule as *const (); // 0x278
  374. f[80] = frame::wait as *const (); // 0x280
  375. f[81] = frame::statistics as *const (); // 0x288
  376. f[86] = pipeline::create_stream as *const (); // 0x2b0
  377. f[108] = resource::allocation_info2 as *const (); // 0x360
  378. f[127] = resource::create_committed3 as *const (); // 0x3f8
  379. f[133] = resource::create_at_address as *const (); // 0x428
  380. Table(f)
  381. };
  382. #[cfg(test)]
  383. mod tests {
  384. use super::*;
  385. use crate::object::slot;
  386. fn create_as(iid: &Iid) -> (HRESULT, This) {
  387. let version = CHECKED_VERSION;
  388. let mut device = std::ptr::null();
  389. let hr = create(std::ptr::null(), &version, iid, &mut device);
  390. (hr, device)
  391. }
  392. #[test]
  393. fn creation_hands_out_the_device() {
  394. let (hr, device) = create_as(&IID);
  395. assert_eq!(hr, S_OK);
  396. assert_eq!(device, super::device());
  397. // The title tests byte 0x18 before inlining a device call.
  398. // SAFETY: the device is 0x58 bytes.
  399. assert_ne!(unsafe { device.cast::<u8>().add(0x18).read() }, 0);
  400. assert_eq!(create_as(&[0; 16]).0, E_NOINTERFACE);
  401. assert_eq!(
  402. slot::<extern "system" fn(This) -> u32>(device, 0x38)(device),
  403. 1
  404. );
  405. let missing = slot::<extern "system" fn() -> HRESULT>(device, 0xf0);
  406. assert_eq!(missing(), E_NOTIMPL);
  407. }
  408. #[test]
  409. fn newer_device_levels_are_the_same_device() {
  410. // ID3D12Device11, as Grand Theft Auto VI asks for it.
  411. let (hr, device) = create_as(&LEVEL_IIDS[8]);
  412. assert_eq!((hr, device), (S_OK, super::device()));
  413. let mut same = std::ptr::null();
  414. assert_eq!(query_interface(device, &LEVEL_IIDS[4], &mut same), S_OK);
  415. assert_eq!(same, device);
  416. // A Device8 method we have not written fails without crashing.
  417. let missing = slot::<extern "system" fn() -> HRESULT>(device, 0x3a0);
  418. assert_eq!(missing(), E_NOTIMPL);
  419. }
  420. /// A device child, and the DXGI device, hand out the device as any
  421. /// interface the device itself answers to.
  422. #[test]
  423. fn the_device_is_found_at_every_level_through_others() {
  424. type Get = extern "system" fn(This, *const Iid, *mut This) -> HRESULT;
  425. let fence_iid = &crate::fence::FENCE_IIDS[0];
  426. let mut fence = std::ptr::null();
  427. assert_eq!(
  428. crate::fence::create(std::ptr::null(), 0, 0, fence_iid, &mut fence),
  429. S_OK
  430. );
  431. let get_device = slot::<Get>(fence, 0x38);
  432. let dxgi = dxgi::device();
  433. let query = slot::<Get>(dxgi, 0);
  434. for iid in std::iter::once(&IID).chain(&LEVEL_IIDS) {
  435. let mut found = std::ptr::null();
  436. assert_eq!(get_device(fence, iid, &mut found), S_OK, "{iid:02x?}");
  437. assert_eq!(found, device());
  438. let mut found = std::ptr::null();
  439. assert_eq!(query(dxgi, iid, &mut found), S_OK, "{iid:02x?}");
  440. assert_eq!(found, device());
  441. }
  442. // What the device is not, it is not through them either.
  443. let mut found = device();
  444. assert_eq!(get_device(fence, fence_iid, &mut found), E_NOINTERFACE);
  445. assert!(found.is_null());
  446. slot::<extern "system" fn(This) -> u32>(fence, 0x10)(fence);
  447. }
  448. /// The host's: a fence's `GetDevice` for `ID3D12Device5`.
  449. #[cfg(windows)]
  450. #[test]
  451. fn the_hosts_children_hand_out_newer_device_levels() {
  452. use windows::Win32::Graphics::Direct3D12::{
  453. D3D12_FENCE_FLAG_NONE, ID3D12Device5, ID3D12Fence,
  454. };
  455. let Some(host) = crate::host::host() else {
  456. return; // no host GPU here
  457. };
  458. // SAFETY: plain calls on the host device and its fence.
  459. unsafe {
  460. let fence: ID3D12Fence = host.device.CreateFence(0, D3D12_FENCE_FLAG_NONE).unwrap();
  461. let mut device: Option<ID3D12Device5> = None;
  462. assert!(fence.GetDevice(&mut device).is_ok());
  463. assert!(device.is_some());
  464. }
  465. }
  466. #[test]
  467. fn virtual_memory_configuration_reports_user_space() {
  468. let mut config = VirtualMemory {
  469. flags: 0,
  470. page_table_pages: 7,
  471. preserved_bytes: 0,
  472. lowest: 0,
  473. highest: 0,
  474. };
  475. assert_eq!(configure_virtual_memory(&mut config), S_OK);
  476. assert!(0 < config.lowest && config.lowest < config.highest);
  477. let heap = Box::new(0u8);
  478. assert!((config.lowest..=config.highest).contains(&(&raw const *heap as u64)));
  479. assert_eq!(configure_virtual_memory(std::ptr::null_mut()), E_INVALIDARG);
  480. }
  481. #[test]
  482. fn feature_levels_pick_the_highest_supported() {
  483. type Check = extern "system" fn(This, u32, *mut c_void, u32) -> HRESULT;
  484. let device = device();
  485. let check = slot::<Check>(device, 0x68);
  486. let query = |levels: &[u32], size| {
  487. let mut query = FeatureLevels {
  488. count: levels.len() as u32,
  489. requested: levels.as_ptr(),
  490. highest: 0,
  491. };
  492. let hr = check(device, 2, (&raw mut query).cast(), size);
  493. (hr, query.highest)
  494. };
  495. let levels = [0xb000, 0xb100, 0xc000, 0xc100, 0xd000];
  496. assert_eq!(query(&levels, 0x18), (S_OK, 0xc100));
  497. assert_eq!(query(&levels, 0x10).0, E_INVALIDARG);
  498. assert_eq!(query(&levels[4..], 0x18).0, UNSUPPORTED);
  499. }
  500. }