The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

c/main: Tidy window surface creation code

+49 -11
+5 -2
src/xrt/compositor/main/comp_window_android.c
··· 103 103 static VkResult 104 104 comp_window_android_create_surface(struct comp_window_android *cwa, 105 105 struct ANativeWindow *window, 106 - VkSurfaceKHR *vk_surface) 106 + VkSurfaceKHR *out_surface) 107 107 { 108 108 struct vk_bundle *vk = get_vk(cwa); 109 109 VkResult ret; ··· 114 114 .window = window, 115 115 }; 116 116 117 + VkSurfaceKHR surface = VK_NULL_HANDLE; 117 118 ret = vk->vkCreateAndroidSurfaceKHR( // 118 119 vk->instance, // 119 120 &surface_info, // 120 121 NULL, // 121 - vk_surface); // 122 + &surface); // 122 123 if (ret != VK_SUCCESS) { 123 124 COMP_ERROR(cwa->base.base.c, "vkCreateAndroidSurfaceKHR: %s", vk_result_string(ret)); 124 125 return ret; 125 126 } 127 + 128 + *out_surface = surface; 126 129 127 130 return VK_SUCCESS; 128 131 }
+14 -1
src/xrt/compositor/main/comp_window_direct.c
··· 257 257 vk_print_display_surface_create_info(vk, &surface_info, U_LOGGING_INFO); 258 258 259 259 // Everything decided and logged, do the creation. 260 - return vk->vkCreateDisplayPlaneSurfaceKHR(vk->instance, &surface_info, NULL, &cts->surface.handle); 260 + VkSurfaceKHR surface = VK_NULL_HANDLE; 261 + ret = vk->vkCreateDisplayPlaneSurfaceKHR( // 262 + vk->instance, // 263 + &surface_info, // 264 + NULL, // 265 + &surface); // 266 + if (ret != VK_SUCCESS) { 267 + COMP_ERROR(cts->base.c, "vkCreateDisplayPlaneSurfaceKHR: %s", vk_result_string(ret)); 268 + return ret; 269 + } 270 + 271 + cts->surface.handle = surface; 272 + 273 + return VK_SUCCESS; 261 274 } 262 275 263 276 #ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
+10 -2
src/xrt/compositor/main/comp_window_mswin.c
··· 145 145 } 146 146 147 147 static VkResult 148 - comp_window_mswin_create_surface(struct comp_window_mswin *w, VkSurfaceKHR *vk_surface) 148 + comp_window_mswin_create_surface(struct comp_window_mswin *w, VkSurfaceKHR *out_surface) 149 149 { 150 150 struct vk_bundle *vk = get_vk(w); 151 151 VkResult ret; 152 + 152 153 VkWin32SurfaceCreateInfoKHR surface_info = { 153 154 .sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR, 154 155 .hinstance = w->instance, 155 156 .hwnd = w->window, 156 157 }; 157 158 158 - ret = vk->vkCreateWin32SurfaceKHR(vk->instance, &surface_info, NULL, vk_surface); 159 + VkSurfaceKHR surface = VK_NULL_HANDLE; 160 + ret = vk->vkCreateWin32SurfaceKHR( // 161 + vk->instance, // 162 + &surface_info, // 163 + NULL, // 164 + &surface); // 159 165 if (ret != VK_SUCCESS) { 160 166 COMP_ERROR(w->base.base.c, "vkCreateWin32SurfaceKHR: %s", vk_result_string(ret)); 161 167 return ret; 162 168 } 169 + 170 + *out_surface = surface; 163 171 164 172 return VK_SUCCESS; 165 173 }
+10 -3
src/xrt/compositor/main/comp_window_wayland.c
··· 76 76 comp_window_wayland_init_swapchain(struct comp_target *ct, uint32_t width, uint32_t height); 77 77 78 78 static VkResult 79 - comp_window_wayland_create_surface(struct comp_window_wayland *w, VkSurfaceKHR *vk_surface); 79 + comp_window_wayland_create_surface(struct comp_window_wayland *w, VkSurfaceKHR *out_surface); 80 80 81 81 static void 82 82 comp_window_wayland_flush(struct comp_target *ct); ··· 216 216 } 217 217 218 218 static VkResult 219 - comp_window_wayland_create_surface(struct comp_window_wayland *w, VkSurfaceKHR *vk_surface) 219 + comp_window_wayland_create_surface(struct comp_window_wayland *w, VkSurfaceKHR *out_surface) 220 220 { 221 221 struct vk_bundle *vk = get_vk(w); 222 222 VkResult ret; ··· 227 227 .surface = w->surface, 228 228 }; 229 229 230 - ret = vk->vkCreateWaylandSurfaceKHR(vk->instance, &surface_info, NULL, vk_surface); 230 + VkSurfaceKHR surface = VK_NULL_HANDLE; 231 + ret = vk->vkCreateWaylandSurfaceKHR( // 232 + vk->instance, // 233 + &surface_info, // 234 + NULL, // 235 + &surface); // 231 236 if (ret != VK_SUCCESS) { 232 237 COMP_ERROR(w->base.base.c, "vkCreateWaylandSurfaceKHR: %s", vk_result_string(ret)); 233 238 return ret; 234 239 } 240 + 241 + *out_surface = surface; 235 242 236 243 return VK_SUCCESS; 237 244 }
+10 -3
src/xrt/compositor/main/comp_window_xcb.c
··· 105 105 comp_window_xcb_get_atom(struct comp_window_xcb *w, const char *name); 106 106 107 107 static VkResult 108 - comp_window_xcb_create_surface(struct comp_window_xcb *w, VkSurfaceKHR *surface); 108 + comp_window_xcb_create_surface(struct comp_window_xcb *w, VkSurfaceKHR *out_surface); 109 109 110 110 static void 111 111 comp_window_xcb_update_window_title(struct comp_target *ct, const char *title); ··· 401 401 } 402 402 403 403 static VkResult 404 - comp_window_xcb_create_surface(struct comp_window_xcb *w, VkSurfaceKHR *surface) 404 + comp_window_xcb_create_surface(struct comp_window_xcb *w, VkSurfaceKHR *out_surface) 405 405 { 406 406 struct vk_bundle *vk = get_vk(w); 407 407 VkResult ret; ··· 412 412 .window = w->window, 413 413 }; 414 414 415 - ret = vk->vkCreateXcbSurfaceKHR(vk->instance, &surface_info, NULL, surface); 415 + VkSurfaceKHR surface = VK_NULL_HANDLE; 416 + ret = vk->vkCreateXcbSurfaceKHR( // 417 + vk->instance, // 418 + &surface_info, // 419 + NULL, // 420 + &surface); // 416 421 if (ret != VK_SUCCESS) { 417 422 COMP_ERROR(w->base.base.c, "vkCreateXcbSurfaceKHR: %s", vk_result_string(ret)); 418 423 return ret; 419 424 } 425 + 426 + *out_surface = surface; 420 427 421 428 return VK_SUCCESS; 422 429 }