1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
use ::{ ovrResult, ovrSession, ovrTextureSwapChainDesc, ovrTextureSwapChain, ovrMirrorTexture, ovrMirrorTextureDesc, ovrGraphicsLuid, }; use ::libc::c_int; use ::vk_sys::{ Instance, PhysicalDevice, Queue, Device, Image }; extern "C" { /// Find `PhysicalDevice` matching `ovrGraphicsLuid` /// /// **in** `session` Specifies an `ovrSession` previously returned by `ovr_Create`. /// /// **in** `luid` Specifies the luid returned from `ovr_Create`. /// /// **in** `instance` Specifies an `Instance` to search for matching luids in. /// /// **out** `out_physicalDevice` Returns the `PhysicalDevice` matching the instance and luid. /// /// Returns an `ovrResult` indicating success or failure. In the case of failure, use /// `ovr_GetLastErrorInfo` to get more information. /// /// **Note**: This function enumerates the current physical devices and returns the one matching the /// luid. It must be called at least once prior to any `ovr_CreateTextureSwapChainVk` or /// `ovr_CreateMirrorTextureWithOptionsVk` calls, and the instance must remain valid for the lifetime /// of the returned objects. It is assumed the `Device` created by the application will be for the /// returned physical device. pub fn ovr_GetSessionPhysicalDeviceVk( session: ovrSession, luid: ovrGraphicsLuid, instance: Instance, out_physicalDevice: *mut PhysicalDevice) -> ovrResult; /// Select `Queue` to block on till rendering is complete /// /// **in** `session` Specifies an `ovrSession` previously returned by `ovr_Create`. /// /// **in** `queue` Specifies a `Queue` to add a `Fence` operation to and wait on. /// /// Returns an `ovrResult` indicating success or failure. In the case of failure, use /// `ovr_GetLastErrorInfo` to get more information. /// /// **Note**: The queue may be changed at any time but only the value at the time `ovr_SubmitFrame` /// is called will be used. `ovr_SetSynchonizationQueueVk` must be called with a valid `Queue` /// created on the same `Device` the texture sets were created on prior to the first call to /// `ovr_SubmitFrame`. An internally created `Fence` object will be signalled by the completion /// of operations on queue and waited on to synchronize the VR compositor. /// pub fn ovr_SetSynchonizationQueueVk(session: ovrSession, queue: Queue) -> ovrResult; /// Create Texture Swap Chain suitable for use with Vulkan /// /// **in** `session` Specifies an `ovrSession` previously returned by `ovr_Create`. /// /// **in** `device` Specifies the application's `Device` to create resources with. /// /// **in** `desc` Specifies requested texture properties. See notes for more info /// about texture format. /// /// **out** `out_TextureSwapChain` Returns the created `ovrTextureSwapChain`, which will be valid /// upon a successful return value, else it will be NULL. /// This texture chain must be eventually destroyed via `ovr_DestroyTextureSwapChain` /// before destroying the session with `ovr_Destroy`. /// /// Returns an `ovrResult` indicating success or failure. In the case of failure, use /// `ovr_GetLastErrorInfo` to get more information. /// /// **Note**: The texture format provided in `desc` should be thought of as the format the /// distortion-compositor will use for the ShaderResourceView when reading the contents /// of the texture. To that end, it is highly recommended that the application /// requests texture swapchain formats that are in sRGB-space /// (e.g. OVR_FORMAT_R8G8B8A8_UNORM_SRGB) as the compositor does sRGB-correct rendering. /// As such, the compositor relies on the GPU's hardware sampler to do the sRGB-to-linear /// conversion. If the application still prefers to render to a linear format (e.g. /// `OVR_FORMAT_R8G8B8A8_UNORM`) while handling the linear-to-gamma conversion via /// SPIRV code, then the application must still request the corresponding sRGB format and /// also use the `ovrTextureMisc_DX_Typeless` flag in the `ovrTextureSwapChainDesc`'s /// `Flag` field. This will allow the application to create a RenderTargetView that is the /// desired linear format while the compositor continues to treat it as sRGB. Failure to /// do so will cause the compositor to apply unexpected gamma conversions leading to /// gamma-curve artifacts. The `ovrTextureMisc_DX_Typeless` flag for depth buffer formats /// (e.g. `OVR_FORMAT_D32_FLOAT`) is ignored as they are always /// converted to be typeless. /// /// see [`ovr_GetTextureSwapChainLength`](../fn.ovr_GetTextureSwapChainLength.html), [`ovr_GetTextureSwapChainCurrentIndex`](../fn.ovr_GetTextureSwapChainCurrentIndex.html), [`ovr_GetTextureSwapChainDesc`](../fn.ovr_GetTextureSwapChainDesc.html), [`ovr_GetTextureSwapChainBufferVk`](fn.ovr_GetTextureSwapChainBufferVk.html), [`ovr_DestroyTextureSwapChain`](../fn.ovr_DestroyTextureSwapChain.html) /// pub fn ovr_CreateTextureSwapChainVk( session: ovrSession, device: Device, desc: *const ovrTextureSwapChainDesc, out_TextureSwapChain: *mut ovrTextureSwapChain) -> ovrResult; /// Get a specific `Image` within the chain /// /// **in** `session` Specifies an `ovrSession` previously returned by `ovr_Create`. /// /// **in** `chain` Specifies an `ovrTextureSwapChain` previously returned by /// `ovr_CreateTextureSwapChainVk` /// /// **in** `index` Specifies the index within the chain to retrieve. /// Must be between 0 and length (see `ovr_GetTextureSwapChainLength`), /// or may pass -1 to get the buffer at the CurrentIndex location (saving a /// call to `GetTextureSwapChainCurrentIndex`). /// /// **out** `out_Image` Returns the `Image` retrieved. /// /// Returns an `ovrResult` indicating success or failure. In the case of failure, use /// `ovr_GetLastErrorInfo` to get more information. /// pub fn ovr_GetTextureSwapChainBufferVk( session: ovrSession, chain: ovrTextureSwapChain, index: c_int, out_Image: *mut Image) -> ovrResult; /// Create Mirror Texture which is auto-refreshed to mirror Rift contents produced by this /// application. /// /// A second call to `ovr_CreateMirrorTextureWithOptionsVk` for a given `ovrSession` before destroying /// the first one is not supported and will result in an error return. /// /// **in** `session` Specifies an `ovrSession` previously returned by `ovr_Create`. /// /// **in** `device` Specifies the `Device` to create resources with. /// /// **in** `desc` Specifies requested texture properties. See notes for more info /// about texture format. /// /// **out** `out_MirrorTexture` Returns the created `ovrMirrorTexture`, which will be /// valid upon a successful return value, else it will be NULL. /// This texture must be eventually destroyed via `ovr_DestroyMirrorTexture` before /// destroying the session with `ovr_Destroy`. /// /// Returns an `ovrResult` indicating success or failure. In the case of failure, use /// `ovr_GetLastErrorInfo` to get more information. /// /// **Note**: The texture format provided in `desc` should be thought of as the format the /// compositor will use for the `ImageView` when writing into mirror texture. To that end, /// it is highly recommended that the application requests a mirror texture format that is /// in sRGB-space (e.g. `OVR_FORMAT_R8G8B8A8_UNORM_SRGB`) as the compositor does sRGB-correct /// rendering. If however the application wants to still read the mirror texture as a /// linear format (e.g. `OVR_FORMAT_R8G8B8A8_UNORM`) and handle the sRGB-to-linear conversion /// in SPIRV code, then it is recommended the application still requests an sRGB format and /// also use the `ovrTextureMisc_DX_Typeless` flag in the `ovrMirrorTextureDesc`'s /// Flags field. This will allow the application to bind a ShaderResourceView that is a /// linear format while the compositor continues to treat is as sRGB. Failure to do so will /// cause the compositor to apply unexpected gamma conversions leading to /// gamma-curve artifacts. /// /// Example code /// /// ```no_run /// # use ::std::{mem, ptr}; /// # use ::ovr_sys::*; /// # use ::ovr_sys::vulkan::*; /// # let (session, vk_device, mirror_window_height, mirror_window_width) = panic!(); /// # unsafe { /// let mut mirror_texture = ptr::null_mut(); /// let mirror_desc = ovrMirrorTextureDesc { /// Format: OVR_FORMAT_R8G8B8A8_UNORM_SRGB, /// Width: mirror_window_width, /// Height: mirror_window_height, /// .. mem::zeroed() /// }; /// let result = ovr_CreateMirrorTextureWithOptionsVk(session, vk_device, &mirror_desc as *const _, &mut mirror_texture as *mut _); /// /// // ... /// /// // Destroy the texture when done with it. /// ovr_DestroyMirrorTexture(session, mirror_texture); /// mirror_texture = ptr::null_mut(); /// # } /// ``` /// /// see [`ovr_GetMirrorTextureBufferVk`](../fn.ovr_GetMirrorTextureBufferVk.html), [`ovr_DestroyMirrorTexture`](../fn.ovr_DestroyMirrorTexture.html) /// pub fn ovr_CreateMirrorTextureWithOptionsVk( session: ovrSession, device: Device, desc: *const ovrMirrorTextureDesc, out_MirrorTexture: *mut ovrMirrorTexture) -> ovrResult; /// Get a the underlying mirror `Image` /// /// **in** `session` Specifies an `ovrSession` previously returned by `ovr_Create`. /// /// **in** `mirrorTexture` Specifies an `ovrMirrorTexture` previously returned by /// `ovr_CreateMirrorTextureWithOptionsVk` /// /// **out** `out_Image` Returns the `Image` pointer retrieved. /// /// Returns an `ovrResult` indicating success or failure. In the case of failure, use /// `ovr_GetLastErrorInfo` to get more information. /// /// Example code: /// /// ```no_run /// # extern crate ovr_sys; /// # extern crate vk_sys; /// # fn main() { /// # unsafe { /// # use ovr_sys::*; /// # use ovr_sys::vulkan::*; /// # use vk_sys as vk; /// # let (session, mirror_texture, command_buffer, present_image, region, queue, present_info) = panic!(); /// # let vk: vk::DevicePointers = panic!(); /// let mut mirror_image = 0; /// ovr_GetMirrorTextureBufferVk(session, mirror_texture, &mut mirror_image as *mut _); /// /// // ... /// /// vk.CmdBlitImage(command_buffer, mirror_image, vk::IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, present_image, vk::IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion as *const _, vk::FILTER_LINEAR); /// /// // ... /// /// vk.QueuePresentKHR(queue, &present_info as *const _); /// # }} /// ``` /// pub fn ovr_GetMirrorTextureBufferVk( session: ovrSession, mirrorTexture: ovrMirrorTexture, out_Image: *mut Image) -> ovrResult; }