public static ComPtr <TUp> UpCast <T, TUp>(ComPtr <T> comPtr) where T : unmanaged where TUp : unmanaged { // if this is hit, your cast is invalid. either use TryCast or have a valid type #if DEBUG Debug.Assert(comPtr.TryQueryInterface(out ComPtr <TUp> assertion)); assertion.Dispose(); #endif return((TUp *)comPtr.Get()); }
public unsafe Win7Output(GraphicsDevice device, IntPtr hwnd, OutputConfiguration desc) : base(device, desc) { _allocator = device.CreateAllocator(ExecutionContext.Graphics); _presentContext = device.CreateList(ExecutionContext.Graphics, _allocator.Ptr, null).As <ID3D12GraphicsCommandList>(); _presentFlags = desc.SyncInterval > 0 ? D3D12_DOWNLEVEL_PRESENT_FLAGS.D3D12_DOWNLEVEL_PRESENT_FLAG_WAIT_FOR_VBLANK : 0; _hwnd = hwnd; _presentQueue = device.GraphicsQueue; if (!ComPtr.TryQueryInterface(_presentQueue.GetQueue(), out ID3D12CommandQueueDownlevel * pDownlevel)) { ThrowHelper.ThrowPlatformNotSupportedException("Not on windows7"); } _queue = new(pDownlevel); RECT window; _ = Windows.GetClientRect(hwnd, &window); InternalResize(new Size(width: window.right - window.left, height: window.bottom - window.top)); }