| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- //! Query heaps. Nothing runs on a GPU yet, so no query ever produces a
- //! result; the heap only remembers its description.
- #![allow(clippy::not_unsafe_ptr_arg_deref)]
- use crate::object::{self, E_INVALIDARG, HRESULT, Iid, Object, QUERY_HEAP, Table, This, guid};
- use crate::resource::PAGEABLE_IIDS;
- const HEAP_IIDS: [Iid; 4] = [
- guid(
- 0x0d9658ae,
- 0xed45,
- 0x469e,
- [0xa6, 0x1d, 0x97, 0x0e, 0xc5, 0x83, 0xca, 0xb4],
- ),
- PAGEABLE_IIDS[0],
- PAGEABLE_IIDS[1],
- PAGEABLE_IIDS[2],
- ];
- #[repr(C)]
- #[derive(Debug, Clone, Copy)]
- pub(crate) struct Desc {
- kind: u32,
- count: u32,
- nodes: u32,
- }
- #[repr(C)]
- struct Heap {
- object: Object,
- desc: Desc,
- }
- /// Device method.
- pub(crate) extern "system" fn create(
- _: This,
- desc: *const Desc,
- iid: *const Iid,
- out: *mut This,
- ) -> HRESULT {
- // SAFETY: the title passes a description (null is tolerated).
- let Some(&desc) = (unsafe { desc.as_ref() }) else {
- return E_INVALIDARG;
- };
- tracing::debug!(?desc, "query heap");
- let heap = Box::new(Heap {
- object: Object::new(&FUNCTIONS),
- desc,
- });
- object::hand_out(QUERY_HEAP, heap, iid, &HEAP_IIDS, out)
- }
- extern "system" fn query(this: This, iid: *const Iid, out: *mut This) -> HRESULT {
- object::answer(
- QUERY_HEAP,
- iid,
- object::is(iid, &HEAP_IIDS).then_some(this),
- out,
- )
- }
- extern "system" fn release(this: This) -> u32 {
- object::release_boxed::<Heap>(this)
- }
- /// IUnknown 3, object 4, device child 1.
- static FUNCTIONS: Table<24> = {
- let mut f = object::d3d12_object(object::missing_table::<QUERY_HEAP, 24>());
- f[0] = query as *const ();
- f[2] = release as *const ();
- f[7] = object::parent_device as *const (); // 0x38
- Table(f)
- };
|