tangled
alpha
login
or
join now
matrixfurry.com
/
monado
0
fork
atom
The open source OpenXR runtime
0
fork
atom
overview
issues
pulls
pipelines
c/main: Refactor dispatch_graphics function
Jakob Bornecrantz
2 years ago
e33418de
4893638c
+43
-67
1 changed file
expand all
collapse all
unified
split
src
xrt
compositor
main
comp_renderer.c
+43
-67
src/xrt/compositor/main/comp_renderer.c
···
926
926
struct comp_target *ct = c->target;
927
927
928
928
struct render_gfx_target_resources *rtr = &r->rtr_array[r->acquired_buffer];
929
929
-
bool one_projection_layer_fast_path = c->base.slot.one_projection_layer_fast_path;
929
929
+
bool fast_path = c->base.slot.one_projection_layer_fast_path;
930
930
931
931
-
// Need to be begin for all paths.
932
932
-
render_gfx_begin(rr);
931
931
+
// Only used if fast_path is true.
932
932
+
const struct comp_layer *layer = &c->base.slot.layers[0];
933
933
934
934
-
// No fast path, standard layer renderer path.
935
935
-
if (!one_projection_layer_fast_path) {
936
936
-
renderer_get_view_projection(r);
937
937
-
comp_layer_renderer_draw( //
938
938
-
r->lr, //
939
939
-
c->nr.cmd, //
940
940
-
&r->scratch_targets[0], //
941
941
-
&r->scratch_targets[1]); //
934
934
+
// Sanity check.
935
935
+
assert(!fast_path || c->base.slot.layer_count >= 1);
942
936
943
943
-
VkSampler clamp_to_border_black = r->c->nr.samplers.clamp_to_border_black;
944
944
-
VkSampler src_samplers[2] = {
945
945
-
clamp_to_border_black,
946
946
-
clamp_to_border_black,
947
947
-
};
948
948
-
VkImageView src_image_views[2] = {
949
949
-
r->scratch.color[0].srgb_view,
950
950
-
r->scratch.color[1].srgb_view,
951
951
-
};
937
937
+
// Need to be begin for all paths.
938
938
+
render_gfx_begin(rr);
952
939
953
953
-
struct xrt_normalized_rect src_norm_rects[2] = {
954
954
-
{.x = 0, .y = 0, .w = 1, .h = 1},
955
955
-
{.x = 0, .y = 0, .w = 1, .h = 1},
956
956
-
};
957
957
-
958
958
-
renderer_build_rendering(r, rr, rtr, src_samplers, src_image_views, src_norm_rects);
959
959
-
960
960
-
// Make the command buffer usable.
961
961
-
render_gfx_end(rr);
962
962
-
963
963
-
renderer_submit_queue(r, rr->r->cmd, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
964
964
-
965
965
-
// We mark afterwards to not include CPU time spent.
966
966
-
comp_target_mark_submit(ct, c->frame.rendering.id, os_monotonic_get_ns());
967
967
-
968
968
-
return;
969
969
-
}
970
970
-
971
971
-
972
972
-
/*
973
973
-
* Fast path.
974
974
-
*/
975
975
-
976
976
-
XRT_MAYBE_UNUSED const uint32_t layer_count = c->base.slot.layer_count;
977
977
-
assert(layer_count >= 1);
978
978
-
979
979
-
int i = 0;
980
980
-
const struct comp_layer *layer = &c->base.slot.layers[i];
981
940
982
982
-
switch (layer->data.type) {
983
983
-
case XRT_LAYER_STEREO_PROJECTION: {
941
941
+
if (fast_path && layer->data.type == XRT_LAYER_STEREO_PROJECTION_DEPTH) {
942
942
+
// Fast path.
984
943
const struct xrt_layer_stereo_projection_data *stereo = &layer->data.stereo;
985
944
const struct xrt_layer_projection_view_data *lvd = &stereo->l;
986
945
const struct xrt_layer_projection_view_data *rvd = &stereo->r;
···
992
951
993
952
do_gfx_mesh_and_proj(r, rr, rtr, layer, lvd, rvd);
994
953
995
995
-
// Make the command buffer usable.
996
996
-
render_gfx_end(rr);
997
997
-
998
998
-
renderer_submit_queue(r, rr->r->cmd, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
999
999
-
1000
1000
-
// We mark afterwards to not include CPU time spent.
1001
1001
-
comp_target_mark_submit(ct, c->frame.rendering.id, os_monotonic_get_ns());
1002
1002
-
} break;
1003
1003
-
1004
1004
-
case XRT_LAYER_STEREO_PROJECTION_DEPTH: {
954
954
+
} else if (fast_path && layer->data.type == XRT_LAYER_STEREO_PROJECTION_DEPTH) {
955
955
+
// Fast path.
1005
956
const struct xrt_layer_stereo_projection_depth_data *stereo = &layer->data.stereo_depth;
1006
957
const struct xrt_layer_projection_view_data *lvd = &stereo->l;
1007
958
const struct xrt_layer_projection_view_data *rvd = &stereo->r;
···
1013
964
1014
965
do_gfx_mesh_and_proj(r, rr, rtr, layer, lvd, rvd);
1015
966
1016
1016
-
// Make the command buffer usable.
1017
1017
-
render_gfx_end(rr);
967
967
+
} else {
968
968
+
969
969
+
renderer_get_view_projection(r);
1018
970
1019
1019
-
renderer_submit_queue(r, rr->r->cmd, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
971
971
+
comp_layer_renderer_draw( //
972
972
+
r->lr, //
973
973
+
c->nr.cmd, //
974
974
+
&r->scratch_targets[0], //
975
975
+
&r->scratch_targets[1]); //
976
976
+
977
977
+
VkSampler clamp_to_border_black = r->c->nr.samplers.clamp_to_border_black;
978
978
+
VkSampler src_samplers[2] = {
979
979
+
clamp_to_border_black,
980
980
+
clamp_to_border_black,
981
981
+
};
982
982
+
VkImageView src_image_views[2] = {
983
983
+
r->scratch.color[0].srgb_view,
984
984
+
r->scratch.color[1].srgb_view,
985
985
+
};
1020
986
1021
1021
-
// We mark afterwards to not include CPU time spent.
1022
1022
-
comp_target_mark_submit(ct, c->frame.rendering.id, os_monotonic_get_ns());
1023
1023
-
} break;
987
987
+
struct xrt_normalized_rect src_norm_rects[2] = {
988
988
+
{.x = 0, .y = 0, .w = 1, .h = 1},
989
989
+
{.x = 0, .y = 0, .w = 1, .h = 1},
990
990
+
};
1024
991
1025
1025
-
default: COMP_ERROR(c, "Unhandled case: '%u'", layer->data.type); assert(false);
992
992
+
renderer_build_rendering(r, rr, rtr, src_samplers, src_image_views, src_norm_rects);
1026
993
}
994
994
+
995
995
+
// Make the command buffer submittable.
996
996
+
render_gfx_end(rr);
997
997
+
998
998
+
// Everything is ready, submit to the queue.
999
999
+
renderer_submit_queue(r, rr->r->cmd, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
1000
1000
+
1001
1001
+
// We mark afterwards to not include CPU time spent.
1002
1002
+
comp_target_mark_submit(ct, c->frame.rendering.id, os_monotonic_get_ns());
1027
1003
}
1028
1004
1029
1005