The open source OpenXR runtime
0
fork

Configure Feed

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

c/main: Refactor vertex rot getting in renderer

+38 -31
+38 -31
src/xrt/compositor/main/comp_renderer.c
··· 216 216 } 217 217 218 218 static void 219 + calc_vertex_rot_data(struct comp_renderer *r, struct xrt_matrix_2x2 out_vertex_rots[2]) 220 + { 221 + bool pre_rotate = false; 222 + if (r->c->target->surface_transform & VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR || 223 + r->c->target->surface_transform & VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR) { 224 + COMP_SPEW(r->c, "Swapping width and height, since we are pre rotating"); 225 + pre_rotate = true; 226 + } 227 + 228 + const struct xrt_matrix_2x2 rotation_90_cw = {{ 229 + .vecs = 230 + { 231 + {0, 1}, 232 + {-1, 0}, 233 + }, 234 + }}; 235 + 236 + for (uint32_t i = 0; i < 2; i++) { 237 + // Get the view. 238 + struct xrt_view *v = &r->c->xdev->hmd->views[i]; 239 + 240 + // Copy data. 241 + struct xrt_matrix_2x2 rot = v->rot; 242 + 243 + // Should we rotate. 244 + if (pre_rotate) { 245 + m_mat2x2_multiply(&rot, &rotation_90_cw, &rot); 246 + } 247 + 248 + out_vertex_rots[i] = rot; 249 + } 250 + } 251 + 252 + static void 219 253 calc_pose_data(struct comp_renderer *r, 220 254 struct xrt_fov out_fovs[2], 221 255 struct xrt_pose out_world[2], ··· 298 332 { 299 333 COMP_TRACE_MARKER(); 300 334 301 - struct comp_compositor *c = r->c; 302 - 303 335 304 336 /* 305 337 * Rendering 306 338 */ 307 - 308 - bool pre_rotate = false; 309 - if (r->c->target->surface_transform & VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR || 310 - r->c->target->surface_transform & VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR) { 311 - COMP_SPEW(c, "Swapping width and height, since we are pre rotating"); 312 - pre_rotate = true; 313 - } 314 339 315 340 struct render_viewport_data l_viewport_data; 316 341 struct render_viewport_data r_viewport_data; 317 342 318 343 calc_viewport_data(r, &l_viewport_data, &r_viewport_data); 319 344 320 - struct xrt_view *l_v = &r->c->xdev->hmd->views[0]; 321 - struct xrt_view *r_v = &r->c->xdev->hmd->views[1]; 322 - 345 + struct xrt_matrix_2x2 vertex_rots[2]; 346 + calc_vertex_rot_data(r, vertex_rots); 323 347 324 348 325 349 /* ··· 328 352 329 353 struct render_gfx_mesh_ubo_data distortion_data[2] = { 330 354 { 331 - .vertex_rot = l_v->rot, 355 + .vertex_rot = vertex_rots[0], 332 356 .post_transform = src_norm_rects[0], 333 357 }, 334 358 { 335 - .vertex_rot = r_v->rot, 359 + .vertex_rot = vertex_rots[1], 336 360 .post_transform = src_norm_rects[1], 337 361 }, 338 362 }; 339 - 340 - const struct xrt_matrix_2x2 rotation_90_cw = {{ 341 - .vecs = 342 - { 343 - {0, 1}, 344 - {-1, 0}, 345 - }, 346 - }}; 347 - 348 - if (pre_rotate) { 349 - m_mat2x2_multiply(&distortion_data[0].vertex_rot, // 350 - &rotation_90_cw, // 351 - &distortion_data[0].vertex_rot); // 352 - m_mat2x2_multiply(&distortion_data[1].vertex_rot, // 353 - &rotation_90_cw, // 354 - &distortion_data[1].vertex_rot); // 355 - } 356 363 357 364 render_gfx_update_distortion(rr, // 358 365 0, // view_index