The open source OpenXR runtime
0
fork

Configure Feed

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

c/main: Refactor mesh descriptor and UBO upload

+81 -38
+40 -18
src/xrt/compositor/main/comp_renderer.c
··· 218 218 struct xrt_view *l_v = &r->c->xdev->hmd->views[0]; 219 219 struct xrt_view *r_v = &r->c->xdev->hmd->views[1]; 220 220 221 - struct comp_mesh_ubo_data l_data = { 222 - .vertex_rot = l_v->rot, 223 - }; 221 + 222 + /* 223 + * Init 224 + */ 225 + 226 + comp_rendering_init(c, &c->nr, rr); 227 + 228 + 229 + /* 230 + * Update 231 + */ 224 232 225 - struct comp_mesh_ubo_data r_data = { 226 - .vertex_rot = r_v->rot, 233 + struct comp_mesh_ubo_data distortion_data[2] = { 234 + { 235 + .vertex_rot = l_v->rot, 236 + }, 237 + { 238 + .vertex_rot = r_v->rot, 239 + }, 227 240 }; 228 241 229 242 const struct xrt_matrix_2x2 rotation_90_cw = {{ ··· 235 248 }}; 236 249 237 250 if (pre_rotate) { 238 - math_matrix_2x2_multiply(&l_v->rot, &rotation_90_cw, &l_data.vertex_rot); 239 - math_matrix_2x2_multiply(&r_v->rot, &rotation_90_cw, &r_data.vertex_rot); 251 + math_matrix_2x2_multiply(&distortion_data[0].vertex_rot, // 252 + &rotation_90_cw, // 253 + &distortion_data[0].vertex_rot); // 254 + math_matrix_2x2_multiply(&distortion_data[1].vertex_rot, // 255 + &rotation_90_cw, // 256 + &distortion_data[1].vertex_rot); // 240 257 } 258 + 259 + comp_draw_update_distortion(rr, // 260 + 0, // view_index 261 + r->lr->framebuffers[0].sampler, // 262 + r->lr->framebuffers[0].view, // 263 + &distortion_data[0]); // 264 + 265 + comp_draw_update_distortion(rr, // 266 + 1, // view_index 267 + r->lr->framebuffers[1].sampler, // 268 + r->lr->framebuffers[1].view, // 269 + &distortion_data[1]); // 270 + 241 271 242 272 /* 243 - * Init 273 + * Target 244 274 */ 245 - 246 - comp_rendering_init(c, &c->nr, rr); 247 275 248 276 comp_draw_begin_target_single( // 249 277 rr, // ··· 260 288 0, // view_index 261 289 &l_viewport_data); // viewport_data 262 290 263 - comp_draw_distortion(rr, // 264 - r->lr->framebuffers[0].sampler, // 265 - r->lr->framebuffers[0].view, // 266 - &l_data); // 291 + comp_draw_distortion(rr); 267 292 268 293 comp_draw_end_view(rr); 269 294 ··· 277 302 1, // view_index 278 303 &r_viewport_data); // viewport_data 279 304 280 - comp_draw_distortion(rr, // 281 - r->lr->framebuffers[1].sampler, // 282 - r->lr->framebuffers[1].view, // 283 - &r_data); // 305 + comp_draw_distortion(rr); 284 306 285 307 comp_draw_end_view(rr); 286 308
+16 -4
src/xrt/compositor/render/comp_render.h
··· 390 390 struct comp_rendering *rr, uint32_t layer, VkSampler sampler, VkImageView image_view, struct xrt_layer_data *data); 391 391 392 392 void 393 - comp_draw_distortion(struct comp_rendering *rr, 394 - VkSampler sampler, 395 - VkImageView image_view, 396 - struct comp_mesh_ubo_data *data); 393 + comp_draw_distortion(struct comp_rendering *rr); 394 + 395 + 396 + /* 397 + * 398 + * Update functions. 399 + * 400 + */ 401 + 402 + void 403 + comp_draw_update_distortion(struct comp_rendering *rr, 404 + uint32_t view, 405 + VkSampler sampler, 406 + VkImageView image_view, 407 + struct comp_mesh_ubo_data *data); 408 + 397 409 398 410 399 411 /*
+25 -16
src/xrt/compositor/render/comp_rendering.c
··· 736 736 } 737 737 738 738 void 739 - comp_draw_distortion(struct comp_rendering *rr, 740 - VkSampler sampler, 741 - VkImageView image_view, 742 - struct comp_mesh_ubo_data *data) 739 + comp_draw_distortion(struct comp_rendering *rr) 743 740 { 744 741 struct vk_bundle *vk = &rr->c->vk; 745 742 struct comp_resources *r = rr->r; ··· 750 747 /* 751 748 * Descriptors and pipeline. 752 749 */ 753 - 754 - comp_buffer_write(vk, &v->mesh.ubo, data, sizeof(struct comp_mesh_ubo_data)); 755 - 756 - update_mesh_discriptor_set( // 757 - vk, // vk_bundle 758 - r->mesh.src_binding, // src_binding 759 - sampler, // sampler 760 - image_view, // image_view 761 - r->mesh.ubo_binding, // ubo_binding 762 - v->mesh.ubo.buffer, // buffer 763 - VK_WHOLE_SIZE, // size 764 - v->mesh.descriptor_set); // descriptor_set 765 750 766 751 VkDescriptorSet descriptor_sets[1] = {v->mesh.descriptor_set}; 767 752 vk->vkCmdBindDescriptorSets( // ··· 823 808 0); // firstInstance 824 809 } 825 810 } 811 + 812 + void 813 + comp_draw_update_distortion(struct comp_rendering *rr, 814 + uint32_t view_index, 815 + VkSampler sampler, 816 + VkImageView image_view, 817 + struct comp_mesh_ubo_data *data) 818 + { 819 + struct vk_bundle *vk = &rr->c->vk; 820 + struct comp_resources *r = rr->r; 821 + struct comp_rendering_view *v = &rr->views[view_index]; 822 + 823 + comp_buffer_write(vk, &v->mesh.ubo, data, sizeof(struct comp_mesh_ubo_data)); 824 + 825 + update_mesh_discriptor_set( // 826 + vk, // vk_bundle 827 + r->mesh.src_binding, // src_binding 828 + sampler, // sampler 829 + image_view, // image_view 830 + r->mesh.ubo_binding, // ubo_binding 831 + v->mesh.ubo.buffer, // buffer 832 + VK_WHOLE_SIZE, // size 833 + v->mesh.descriptor_set); // descriptor_set 834 + }