pipeline.rs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. //! Pipeline states. Both descriptions start as on PC: the root signature,
  2. //! then the shader stages (five for graphics, one for compute); streams
  3. //! carry the rest of the graphics state as subobjects of the standard
  4. //! types.
  5. //!
  6. //! Host pipelines are made on a pipeline's first draw, not at creation:
  7. //! Grand Theft Auto VI creates some 60,000 pipelines in its first 20
  8. //! seconds and draws with a few dozen (decision 0007, step 3). Shader
  9. //! containers are shared by content hash and translated once, on first
  10. //! use (decision 0003).
  11. //!
  12. //! shortcut: only vertex plus pixel pipelines from streams and compute
  13. //! pipelines get host pipelines; mesh, tessellation and geometry stages,
  14. //! and the plain graphics description, keep their containers only. The 32-byte
  15. //! packet after the header stays zero: titles only copy it inline, which
  16. //! our null command-list limits keep from running.
  17. #![allow(clippy::not_unsafe_ptr_arg_deref)]
  18. use std::collections::HashMap;
  19. use std::mem::offset_of;
  20. use std::sync::{Arc, Mutex, OnceLock};
  21. use crate::object::{self, E_INVALIDARG, HRESULT, Iid, Object, PIPELINE, Table, This, guid};
  22. use crate::resource::PAGEABLE_IIDS;
  23. const PIPELINE_IIDS: [Iid; 4] = [
  24. guid(
  25. 0x765a30f3,
  26. 0xf624,
  27. 0x4c6f,
  28. [0xa8, 0x28, 0xac, 0xe9, 0x48, 0x62, 0x24, 0x45],
  29. ),
  30. PAGEABLE_IIDS[0],
  31. PAGEABLE_IIDS[1],
  32. PAGEABLE_IIDS[2],
  33. ];
  34. #[repr(C)]
  35. pub(crate) struct Bytecode {
  36. code: *const u8,
  37. size: usize,
  38. }
  39. #[repr(C)]
  40. pub(crate) struct GraphicsHead {
  41. root: This,
  42. /// Vertex, pixel, domain, hull, geometry.
  43. stages: [Bytecode; 5],
  44. }
  45. #[repr(C)]
  46. pub(crate) struct ComputeHead {
  47. root: This,
  48. stage: Bytecode,
  49. }
  50. /// A shader container a title passed, shared by every pipeline with the
  51. /// same bytes.
  52. pub(crate) struct Shader {
  53. pub(crate) stage: &'static str,
  54. /// The first 8 bytes of its BLAKE3, as logged.
  55. pub(crate) hash: String,
  56. container: Vec<u8>,
  57. #[cfg(windows)]
  58. translated: OnceLock<Option<Translated>>,
  59. }
  60. impl std::fmt::Debug for Shader {
  61. fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  62. write!(f, "{} {}", self.stage, self.hash)
  63. }
  64. }
  65. /// Every container seen, by full content hash.
  66. static SHADERS: Mutex<Option<HashMap<[u8; 32], Arc<Shader>>>> = Mutex::new(None);
  67. /// The shared container for `bytes`.
  68. fn shader(stage: &'static str, bytes: &[u8]) -> Arc<Shader> {
  69. let full = blake3::hash(bytes);
  70. let mut shaders = SHADERS.lock().unwrap_or_else(|e| e.into_inner());
  71. shaders
  72. .get_or_insert_with(HashMap::new)
  73. .entry(*full.as_bytes())
  74. .or_insert_with(|| {
  75. Arc::new(Shader {
  76. stage,
  77. hash: full.to_hex()[..16].to_owned(),
  78. container: bytes.to_vec(),
  79. #[cfg(windows)]
  80. translated: OnceLock::new(),
  81. })
  82. })
  83. .clone()
  84. }
  85. /// A translated shader and the console resources its code reads.
  86. #[cfg(windows)]
  87. pub(crate) struct Translated {
  88. pub(crate) host: victory_shader::emit::HostShader,
  89. pub(crate) used: Vec<victory_shader::UsedResource>,
  90. }
  91. #[cfg(windows)]
  92. impl Shader {
  93. /// The translation, made on first use; a shader that does not
  94. /// translate is logged once.
  95. pub(crate) fn translated(&self) -> Option<&Translated> {
  96. self.translated
  97. .get_or_init(|| {
  98. let done = translate(&self.container);
  99. match &done {
  100. Ok(t) => tracing::info!(
  101. stage = self.stage,
  102. hash = %self.hash,
  103. user_data = t.host.user_data.len(),
  104. samplers = t.host.samplers.len(),
  105. "shader translated"
  106. ),
  107. Err(e) => tracing::warn!(
  108. stage = self.stage,
  109. hash = %self.hash,
  110. error = %e,
  111. "shader does not translate; its pipelines' draws are dropped"
  112. ),
  113. }
  114. done.ok()
  115. })
  116. .as_ref()
  117. }
  118. }
  119. #[cfg(windows)]
  120. fn translate(container: &[u8]) -> Result<Translated, String> {
  121. use victory_shader::{Container, FourCC, HwStage};
  122. let host = crate::shader_cache::host_shader(container)?;
  123. let c = Container::parse(container).map_err(|e| e.to_string())?;
  124. let used = match c.part(FourCC::DXIL) {
  125. Some(part) => victory_shader::native_programs(part.data)
  126. .map_err(|e| e.to_string())?
  127. .into_iter()
  128. .find(|p| {
  129. matches!(
  130. p.stage,
  131. HwStage::Vs | HwStage::Ps | HwStage::Ms | HwStage::Cs
  132. )
  133. })
  134. .map(|p| p.used)
  135. .unwrap_or_default(),
  136. None => Vec::new(),
  137. };
  138. Ok(Translated { host, used })
  139. }
  140. #[repr(C)]
  141. struct Pipeline {
  142. object: Object,
  143. packet: [u32; 8],
  144. /// Each used stage's container.
  145. shaders: Vec<Arc<Shader>>,
  146. /// Whether a list has bound it yet (its shaders are logged then).
  147. bound: std::sync::atomic::AtomicBool,
  148. /// What its host pipeline is made from, and the host pipeline once made
  149. /// (by a worker: the title may release the pipeline meanwhile).
  150. #[cfg(windows)]
  151. host: Arc<make::Pending>,
  152. }
  153. const _: () = assert!(offset_of!(Pipeline, packet) == 0x10);
  154. /// Stage names, in description order.
  155. const GRAPHICS_STAGES: [&str; 5] = ["vertex", "pixel", "domain", "hull", "geometry"];
  156. fn pipeline<'a>(this: This) -> &'a Pipeline {
  157. // SAFETY: the title passes one of our pipelines.
  158. unsafe { &*this.cast::<Pipeline>() }
  159. }
  160. /// List method: logs each pipeline's shaders the first time a list binds
  161. /// it, so a run lists the shaders its frames need first.
  162. pub(crate) fn bound(this: This) {
  163. if this.is_null() {
  164. return;
  165. }
  166. let p = pipeline(this);
  167. if p.bound.swap(true, std::sync::atomic::Ordering::Relaxed) {
  168. return;
  169. }
  170. let frame = crate::frame::current();
  171. for shader in &p.shaders {
  172. tracing::info!(pipeline = ?this, frame, stage = shader.stage, size = shader.container.len(), hash = %shader.hash, "first bind");
  173. }
  174. }
  175. /// The host pipeline of a title pipeline; `None` if one of its shaders does
  176. /// not translate, the host refuses it, or it is still being made (its first
  177. /// use starts that, see [`make`]).
  178. #[cfg(windows)]
  179. pub(crate) fn host_pipeline<'a>(this: This) -> Option<&'a host::HostPipeline> {
  180. if this.is_null() {
  181. return None;
  182. }
  183. make::ready(&pipeline(this).host)
  184. }
  185. /// Host pipelines queued and not made yet.
  186. #[cfg(windows)]
  187. pub(crate) fn making() -> u64 {
  188. make::waiting()
  189. }
  190. /// Draws and dispatches dropped since the last [`take_drops`], by reason
  191. /// (diagnostics).
  192. #[cfg(all(windows, feature = "diagnostics"))]
  193. static DROPS: Mutex<Option<HashMap<String, u64>>> = Mutex::new(None);
  194. /// Shader hashes as printed in the pipeline diagnostics.
  195. #[cfg(all(windows, feature = "diagnostics"))]
  196. fn parse_skip_hashes(value: &str) -> Vec<String> {
  197. value
  198. .split(',')
  199. .map(str::trim)
  200. .filter(|hash| !hash.is_empty())
  201. .filter_map(|hash| {
  202. if hash.len() == 16 && hash.bytes().all(|byte| byte.is_ascii_hexdigit()) {
  203. Some(hash.to_ascii_lowercase())
  204. } else {
  205. tracing::warn!(
  206. hash,
  207. "VICTORY_SKIP_PIPELINES expects 16-digit shader hashes"
  208. );
  209. None
  210. }
  211. })
  212. .collect()
  213. }
  214. #[cfg(all(windows, feature = "diagnostics"))]
  215. fn skipped_shader(p: &Pipeline) -> Option<&str> {
  216. static HASHES: OnceLock<Vec<String>> = OnceLock::new();
  217. let hashes = HASHES.get_or_init(|| {
  218. let value = std::env::var("VICTORY_SKIP_PIPELINES").unwrap_or_default();
  219. parse_skip_hashes(&value)
  220. });
  221. if hashes.is_empty() {
  222. return None;
  223. }
  224. p.shaders
  225. .iter()
  226. .find(|shader| hashes.contains(&shader.hash))
  227. .map(|shader| shader.hash.as_str())
  228. }
  229. #[cfg(all(windows, feature = "diagnostics"))]
  230. pub(crate) fn is_skipped(this: This) -> bool {
  231. !this.is_null() && skipped_shader(pipeline(this)).is_some()
  232. }
  233. /// Counts a draw or dispatch of `this` intentionally skipped or dropped
  234. /// for want of a host pipeline (diagnostics).
  235. #[cfg(all(windows, feature = "diagnostics"))]
  236. pub(crate) fn note_drop(this: This) {
  237. let why = if this.is_null() {
  238. Some("no pipeline set".to_owned())
  239. } else {
  240. let p = pipeline(this);
  241. skipped_shader(p)
  242. .map(|hash| format!("skipped shader {hash}"))
  243. .or_else(|| make::missing(&p.host))
  244. };
  245. if let Some(why) = why {
  246. note_why(why);
  247. }
  248. }
  249. /// Counts a draw or dispatch dropped for `why` (diagnostics).
  250. #[cfg(all(windows, feature = "diagnostics"))]
  251. pub(crate) fn note_why(why: String) {
  252. let mut drops = DROPS.lock().unwrap_or_else(|e| e.into_inner());
  253. *drops.get_or_insert_with(HashMap::new).entry(why).or_default() += 1;
  254. }
  255. /// The drops counted since the last call, most first (diagnostics).
  256. #[cfg(all(windows, feature = "diagnostics"))]
  257. pub(crate) fn take_drops() -> Vec<(String, u64)> {
  258. let drops = DROPS.lock().unwrap_or_else(|e| e.into_inner()).take();
  259. let mut drops: Vec<(String, u64)> = drops.into_iter().flatten().collect();
  260. // Frame reports only show the first 40 reasons. Keep ties ordered so
  261. // a HashMap iteration order change cannot change which reasons appear.
  262. drops.sort_unstable_by(|a, b| b.1.cmp(&a.1).then_with(|| a.0.cmp(&b.0)));
  263. drops
  264. }
  265. /// The stage's container, if it has one.
  266. fn copy(stage: &'static str, code: &Bytecode) -> Option<Arc<Shader>> {
  267. if code.code.is_null() || code.size == 0 {
  268. return None;
  269. }
  270. // SAFETY: the title passes `size` bytes of shader code.
  271. Some(shader(stage, unsafe {
  272. std::slice::from_raw_parts(code.code, code.size)
  273. }))
  274. }
  275. fn hand_out(
  276. shaders: Vec<Arc<Shader>>,
  277. #[cfg(windows)] graphics: Option<Box<host::GraphicsState>>,
  278. iid: *const Iid,
  279. out: *mut This,
  280. ) -> HRESULT {
  281. tracing::trace!(?shaders, "pipeline state");
  282. #[cfg(windows)]
  283. let host = Arc::new(make::Pending::new(shaders.clone(), graphics));
  284. #[cfg(windows)]
  285. make::early(&host);
  286. let pipeline = Box::new(Pipeline {
  287. object: Object::new(&FUNCTIONS),
  288. packet: [0; 8],
  289. #[cfg(windows)]
  290. host,
  291. shaders,
  292. bound: std::sync::atomic::AtomicBool::new(false),
  293. });
  294. object::hand_out(PIPELINE, pipeline, iid, &PIPELINE_IIDS, out)
  295. }
  296. /// Device method.
  297. pub(crate) extern "system" fn create_graphics(
  298. _: This,
  299. desc: *const GraphicsHead,
  300. iid: *const Iid,
  301. out: *mut This,
  302. ) -> HRESULT {
  303. // SAFETY: the title passes a description (null is tolerated).
  304. let Some(desc) = (unsafe { desc.as_ref() }) else {
  305. return E_INVALIDARG;
  306. };
  307. let stages = GRAPHICS_STAGES.iter().zip(&desc.stages);
  308. let shaders = stages.filter_map(|(s, c)| copy(s, c)).collect();
  309. hand_out(
  310. shaders,
  311. #[cfg(windows)]
  312. None,
  313. iid,
  314. out,
  315. )
  316. }
  317. /// Device method.
  318. pub(crate) extern "system" fn create_compute(
  319. _: This,
  320. desc: *const ComputeHead,
  321. iid: *const Iid,
  322. out: *mut This,
  323. ) -> HRESULT {
  324. // SAFETY: the title passes a description (null is tolerated).
  325. let Some(desc) = (unsafe { desc.as_ref() }) else {
  326. return E_INVALIDARG;
  327. };
  328. hand_out(
  329. copy("compute", &desc.stage).into_iter().collect(),
  330. #[cfg(windows)]
  331. None,
  332. iid,
  333. out,
  334. )
  335. }
  336. /// Device method 0x1f0: the plain compute description plus console
  337. /// extensions `(desc, extension count, extensions, iid, out)`.
  338. /// shortcut: the extensions (console shader settings) are ignored, as is
  339. /// the rest of the description.
  340. pub(crate) extern "system" fn create_compute_x(
  341. this: This,
  342. desc: *const ComputeHead,
  343. _extensions: u32,
  344. _extended: *const u8,
  345. iid: *const Iid,
  346. out: *mut This,
  347. ) -> HRESULT {
  348. create_compute(this, desc, iid, out)
  349. }
  350. /// A pipeline described as a stream: its size and the subobjects, each a
  351. /// type then its data, padded to 8 bytes.
  352. #[repr(C)]
  353. pub(crate) struct StreamDesc {
  354. size: usize,
  355. stream: *const u8,
  356. }
  357. /// A subobject type's size (type included), and the stage it is if it is a
  358. /// shader. The console numbers amplification and mesh shaders 23 and 24
  359. /// (PC: 24 and 25); its own types from 25 on are not sized yet.
  360. fn subobject(kind: u32) -> Option<(usize, Option<&'static str>)> {
  361. let stage = |name| Some((24, Some(name)));
  362. match kind {
  363. 1 => stage("vertex"),
  364. 2 => stage("pixel"),
  365. 3 => stage("domain"),
  366. 4 => stage("hull"),
  367. 5 => stage("geometry"),
  368. 6 => stage("compute"),
  369. 23 => stage("amplification"),
  370. 24 => stage("mesh"),
  371. 0 => Some((16, None)),
  372. 12 | 19 => Some((24, None)),
  373. 7 | 15 => Some((40, None)),
  374. 8 => Some((336, None)),
  375. 10 => Some((48, None)),
  376. 11 => Some((56, None)),
  377. 17 => Some((16, None)),
  378. 21 => Some((64, None)),
  379. 22 => Some((32, None)),
  380. 9 | 13 | 14 | 16 | 18 | 20 => Some((8, None)),
  381. _ => None,
  382. }
  383. }
  384. /// Device method: a pipeline from a stream; the shaders are kept, and the
  385. /// graphics state for the host pipeline.
  386. pub(crate) extern "system" fn create_stream(
  387. _: This,
  388. desc: *const StreamDesc,
  389. iid: *const Iid,
  390. out: *mut This,
  391. ) -> HRESULT {
  392. // SAFETY: the title passes a description (null is tolerated).
  393. let Some(desc) = (unsafe { desc.as_ref() }) else {
  394. return E_INVALIDARG;
  395. };
  396. if desc.stream.is_null() {
  397. return E_INVALIDARG;
  398. }
  399. let mut shaders = Vec::new();
  400. #[cfg(windows)]
  401. let mut graphics = host::GraphicsState::default();
  402. let mut at = 0;
  403. while at + 8 <= desc.size {
  404. // SAFETY: inside the stream the title passes.
  405. let kind = unsafe { desc.stream.add(at).cast::<u32>().read_unaligned() };
  406. let Some((size, stage)) = subobject(kind) else {
  407. tracing::warn!(
  408. kind,
  409. at,
  410. "pipeline subobject of unknown size; the rest is ignored"
  411. );
  412. break;
  413. };
  414. if let Some(stage) = stage {
  415. // SAFETY: a shader subobject has its bytecode at +8.
  416. let code = unsafe { &*desc.stream.add(at + 8).cast::<Bytecode>() };
  417. shaders.extend(copy(stage, code));
  418. }
  419. #[cfg(windows)]
  420. // SAFETY: a whole subobject of this kind lies at `at`.
  421. unsafe {
  422. graphics.read(kind, desc.stream.add(at))
  423. };
  424. at += size;
  425. }
  426. hand_out(
  427. shaders,
  428. #[cfg(windows)]
  429. Some(Box::new(graphics)),
  430. iid,
  431. out,
  432. )
  433. }
  434. extern "system" fn query(this: This, iid: *const Iid, out: *mut This) -> HRESULT {
  435. let found = object::is(iid, &PIPELINE_IIDS).then_some(this);
  436. object::answer(PIPELINE, iid, found, out)
  437. }
  438. extern "system" fn release(this: This) -> u32 {
  439. object::release_boxed::<Pipeline>(this)
  440. }
  441. /// IUnknown 3, object 4, device child 1, pipeline 3.
  442. static FUNCTIONS: Table<24> = {
  443. let mut f = object::d3d12_object(object::missing_table::<PIPELINE, 24>());
  444. f[0] = query as *const ();
  445. f[2] = release as *const ();
  446. f[7] = object::parent_device as *const (); // 0x38
  447. Table(f)
  448. };
  449. #[cfg(windows)]
  450. pub(crate) mod host;
  451. #[cfg(windows)]
  452. mod library;
  453. #[cfg(windows)]
  454. mod make;
  455. /// Keeps compiled host pipelines, and the list of title pipelines to start
  456. /// early, in `dir` (a folder of the cache) across runs.
  457. #[cfg(windows)]
  458. pub fn use_pipeline_cache(dir: std::path::PathBuf) {
  459. library::use_pipeline_cache(dir);
  460. }
  461. /// Saves the pipeline cache now if anything was added (at the end of a run).
  462. #[cfg(windows)]
  463. pub fn save_pipeline_cache() {
  464. library::save(true);
  465. }
  466. #[cfg(test)]
  467. mod tests {
  468. #[cfg(all(windows, feature = "diagnostics"))]
  469. #[test]
  470. fn skip_hashes_accepts_full_hashes_only() {
  471. assert!(super::parse_skip_hashes(" , ").is_empty());
  472. assert_eq!(
  473. super::parse_skip_hashes(" 0123456789ABCDEF, 0123456789abcde, xyz, 0011223344556677,"),
  474. ["0123456789abcdef", "0011223344556677"]
  475. );
  476. }
  477. use super::*;
  478. use crate::object::{S_OK, slot};
  479. fn shaders(p: This) -> Vec<(&'static str, Vec<u8>)> {
  480. pipeline(p)
  481. .shaders
  482. .iter()
  483. .map(|s| (s.stage, s.container.clone()))
  484. .collect()
  485. }
  486. #[test]
  487. fn pipelines_keep_their_shaders() {
  488. let (vs, ps) = ([1u8, 2, 3], [4u8; 5]);
  489. let none = || Bytecode {
  490. code: std::ptr::null(),
  491. size: 0,
  492. };
  493. let desc = GraphicsHead {
  494. root: std::ptr::null(),
  495. stages: [
  496. Bytecode {
  497. code: vs.as_ptr(),
  498. size: vs.len(),
  499. },
  500. Bytecode {
  501. code: ps.as_ptr(),
  502. size: ps.len(),
  503. },
  504. none(),
  505. none(),
  506. none(),
  507. ],
  508. };
  509. let mut p = std::ptr::null();
  510. assert_eq!(
  511. create_graphics(std::ptr::null(), &desc, &PIPELINE_IIDS[0], &mut p),
  512. S_OK
  513. );
  514. assert_eq!(
  515. shaders(p),
  516. [("vertex", vs.to_vec()), ("pixel", ps.to_vec())]
  517. );
  518. // A second pipeline with the same pixel shader shares its container.
  519. let mut q = std::ptr::null();
  520. create_graphics(std::ptr::null(), &desc, &PIPELINE_IIDS[0], &mut q);
  521. assert!(Arc::ptr_eq(
  522. &pipeline(p).shaders[1],
  523. &pipeline(q).shaders[1]
  524. ));
  525. assert_eq!(slot::<extern "system" fn(This) -> u32>(p, 0x10)(p), 0);
  526. }
  527. /// The stream layout Grand Theft Auto VI builds (title+0x86f090): root
  528. /// signature, five shader slots (the first a mesh shader), blend, sample
  529. /// mask, rasterizer, depth-stencil 1, sample description, input layout,
  530. /// topology, render target and depth formats: 0x2b0 bytes.
  531. #[test]
  532. fn streams_yield_their_shaders() {
  533. let (ms, ps) = ([9u8; 7], [4u8; 5]);
  534. let mut stream = vec![0u8; 0x2b0];
  535. let mut put = |at: usize, v: u64| stream[at..at + 8].copy_from_slice(&v.to_le_bytes());
  536. for (at, kind) in [
  537. (0x10, 24),
  538. (0x28, 2),
  539. (0x40, 3),
  540. (0x58, 4),
  541. (0x70, 5),
  542. (0x88, 8),
  543. (0x1d8, 9),
  544. (0x1e0, 10),
  545. (0x210, 21),
  546. (0x250, 17),
  547. (0x260, 12),
  548. (0x278, 14),
  549. (0x280, 15),
  550. (0x2a8, 16),
  551. ] {
  552. put(at, kind);
  553. }
  554. put(0x18, ms.as_ptr() as u64);
  555. put(0x20, ms.len() as u64);
  556. put(0x30, ps.as_ptr() as u64);
  557. put(0x38, ps.len() as u64);
  558. // Topology type 3 (triangles), one render target of format 28.
  559. put(0x278, 14 | 3 << 32);
  560. put(0x280, 15 | 28 << 32);
  561. put(0x2a0, 1 << 32);
  562. let desc = StreamDesc {
  563. size: stream.len(),
  564. stream: stream.as_ptr(),
  565. };
  566. let mut p = std::ptr::null();
  567. let hr = create_stream(std::ptr::null(), &desc, &PIPELINE_IIDS[0], &mut p);
  568. assert_eq!(hr, S_OK);
  569. assert_eq!(shaders(p), [("mesh", ms.to_vec()), ("pixel", ps.to_vec())]);
  570. #[cfg(windows)]
  571. {
  572. let g = pipeline(p).host.graphics.as_deref().unwrap();
  573. assert_eq!(g.topology.0, 3);
  574. assert_eq!(
  575. (g.targets.NumRenderTargets, g.targets.RTFormats[0].0),
  576. (1, 28)
  577. );
  578. }
  579. }
  580. }