1 /// Presentation module
2 module gfx.graal.presentation;
3 
4 import core.time : Duration;
5 
6 import gfx.core.rc;
7 import gfx.graal.format;
8 import gfx.graal.image;
9 import gfx.graal.sync;
10 
11 import std.typecons : Tuple;
12 
13 struct SurfaceCaps
14 {
15     uint minImages;
16     uint maxImages;
17     uint[2] minSize;
18     uint[2] maxSize;
19     uint maxLayers;
20     ImageUsage usage;
21     CompositeAlpha supportedAlpha;
22 }
23 
24 enum CompositeAlpha {
25     opaque          = 0x01,
26     preMultiplied   = 0x02,
27     postMultiplied  = 0x04,
28     inherit         = 0x08,
29 }
30 
31 enum PresentMode {
32     immediate,
33     fifo,
34     mailbox,
35 }
36 
37 interface Surface : AtomicRefCounted
38 {}
39 
40 interface Swapchain : AtomicRefCounted
41 {
42     import gfx.graal.device : Device;
43 
44     /// Get the parent device
45     @property Device device();
46 
47     /// Get the Surface that this swapchain is bound to.
48     @property Surface surface();
49 
50     /// The image format of this swapchain
51     @property Format format();
52 
53     /// Get the list of images owned by this swapchain.
54     /// The index of each image is meaningful and is often used to reference
55     /// the image (such as the index returned by acquireNextImage)
56     @property ImageBase[] images();
57 
58     /// use negative timeout to specify no timeout at all
59     /// Params:
60     ///     timeout = the maximum time to wait until the call returns
61     ///     semaphore = the semaphore
62     ///     suboptimal = a flag that implementation may set if the swapchain need
63     ///                  to be recreated
64     /// Returns: the index of an available image or uint.max if timeout expired
65     ///          before any image was returned to the application
66     uint acquireNextImage(Duration timeout, Semaphore semaphore, out bool suboptimal);
67 }