Debian Codegraph @

src/xrt/targets/sdl_test/sdl_swapchain.c

raw symbols SCIP
1 // Copyright 2022-2023, Collabora, Ltd.cxx . . $ `<file>/src/xrt/targets/sdl_test/sdl_swapchain.c`/
2 // SPDX-License-Identifier: BSL-1.0
3 /*!
4 * @file
5 * @brief Swapchain code for the sdl code.
6 * @author Jakob Bornecrantz <[email protected]>
7 * @ingroup sdl_test
8 */
9
10 #include "sdl_internal.h"cxx . . $ `<file>/src/xrt/targets/sdl_test/sdl_internal.h`/
11
12 #include "util/u_handles.h"cxx . . $ `<file>/src/xrt/auxiliary/util/u_handles.h`/
13 #include "ogl/ogl_helpers.h"cxx . . $ `<file>/src/xrt/auxiliary/ogl/ogl_helpers.h`/
14
15
16
17 static void
18 post_init_setupcxx . . $ post_init_setup(afa9ffc2df2f52f8).(struct sdl_swapchaincxx . . $ sdl_swapchain# *ssc, struct sdl_programcxx . . $ sdl_program# *sp, const struct xrt_swapchain_create_infocxx . . $ xrt_swapchain_create_info# *info)
19 {
20 ST_DEBUGcxx . . $ `src/xrt/targets/sdl_test/sdl_internal.h:219:9`!(sp, "CREATE");
21
22 sdl_make_currentcxx . . $ sdl_make_current(32b3ed409ec42806).(sp);
23
24 struct ogl_import_resultscxx . . $ ogl_import_results# results = XRT_STRUCT_INITcxx . . $ `src/xrt/include/xrt/xrt_compiler.h:174:9`!;
25 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bret = ogl_import_from_nativecxx . . $ ogl_import_from_native(9a867de72a44bd17).( //
26 ssc->basecxx . . $ sdl_swapchain#base..basecxx . . $ comp_swapchain#base..imagescxx . . $ xrt_swapchain_native#images., // native_images
27 ssc->basecxx . . $ sdl_swapchain#base..basecxx . . $ comp_swapchain#base..basecxx . . $ xrt_swapchain_native#base..image_countcxx . . $ xrt_swapchain#image_count., // native_count
28 info, // info
29 &results); // results
30 assertcxx . . $ `/usr/include/assert.h:118:11`!(bret);
31 (void)bret;
32
33 sdl_make_uncurrentcxx . . $ sdl_make_uncurrent(32b3ed409ec42806).(sp);
34
35 // Setup fields
36 ssc->spcxx . . $ sdl_swapchain#sp. = sp;
37 ssc->wcxx . . $ sdl_swapchain#w. = (int)results.widthcxx . . $ ogl_import_results#width.;
38 ssc->hcxx . . $ sdl_swapchain#h. = (int)results.heightcxx . . $ ogl_import_results#height.;
39
40 for (uint32_tcxx . . $ uint32_t# i = 0; i < results.image_countcxx . . $ ogl_import_results#image_count.; i++) {
41 ssc->memorycxx . . $ sdl_swapchain#memory.[i] = results.memoriescxx . . $ ogl_import_results#memories.[i];
42 ssc->texturescxx . . $ sdl_swapchain#textures.[i] = results.texturescxx . . $ ogl_import_results#textures.[i];
43 }
44 }
45
46 static void
47 really_destroycxx . . $ really_destroy(1be3bc1301f73959).(struct comp_swapchaincxx . . $ comp_swapchain# *sc)
48 {
49 struct sdl_swapchaincxx . . $ sdl_swapchain# *ssc = (struct sdl_swapchaincxx . . $ sdl_swapchain# *)sc;
50 struct sdl_programcxx . . $ sdl_program# *sp = ssc->spcxx . . $ sdl_swapchain#sp.;
51
52 ST_DEBUGcxx . . $ `src/xrt/targets/sdl_test/sdl_internal.h:219:9`!(sp, "DESTROY");
53
54 sdl_make_currentcxx . . $ sdl_make_current(32b3ed409ec42806).(sp);
55
56 uint32_tcxx . . $ uint32_t# image_count = ssc->basecxx . . $ sdl_swapchain#base..basecxx . . $ comp_swapchain#base..basecxx . . $ xrt_swapchain_native#base..image_countcxx . . $ xrt_swapchain#image_count.;
57 if (image_count > 0) {
58 glDeleteTexturescxx . . $ `src/external/glad/include/glad/gl.h:2739:9`!(image_count, ssc->texturescxx . . $ sdl_swapchain#textures.);
59 glDeleteMemoryObjectsEXTcxx . . $ `src/external/glad/include/glad/gl.h:2721:9`!(image_count, ssc->memorycxx . . $ sdl_swapchain#memory.);
60
61 U_ZERO_ARRAYcxx . . $ `src/xrt/auxiliary/util/u_misc.h:78:9`!(ssc->textures);
62 U_ZERO_ARRAYcxx . . $ `src/xrt/auxiliary/util/u_misc.h:78:9`!(ssc->memory);
63 }
64
65 sdl_make_uncurrentcxx . . $ sdl_make_uncurrent(32b3ed409ec42806).(sp);
66
67 // Teardown the base swapchain, freeing all Vulkan resources.
68 comp_swapchain_teardowncxx . . $ comp_swapchain_teardown(1be3bc1301f73959).(sc);
69
70 // Teardown does not free the struct itself.
71 freecxx . . $ free(5d22bdacc48458e8).(ssc);
72 }
73
74
75 /*
76 *
77 * 'Exported' functions.
78 *
79 */
80
81 xrt_result_tcxx . . $ xrt_result_t#
82 sdl_swapchain_createcxx . . $ sdl_swapchain_create(686b0b50bb42a106).(struct xrt_compositorcxx . . $ xrt_compositor# *xc,
83 const struct xrt_swapchain_create_infocxx . . $ xrt_swapchain_create_info# *info,
84 struct xrt_swapchaincxx . . $ xrt_swapchain# **out_xsc)
85 {
86 struct sdl_programcxx . . $ sdl_program# *sp = from_compcxx . . $ from_comp(66d7fec3c1affd02).(xc);
87 xrt_result_tcxx . . $ xrt_result_t# xret;
88
89 /*
90 * In case the default get properties function have been overridden
91 * make sure to correctly dispatch the call to get the properties.
92 */
93 struct xrt_swapchain_create_propertiescxx . . $ xrt_swapchain_create_properties# xsccp = {0};
94 xrt_comp_get_swapchain_create_propertiescxx . . $ xrt_comp_get_swapchain_create_properties(393b3a5f183f49db).(xc, info, &xsccp);
95
96 struct sdl_swapchaincxx . . $ sdl_swapchain# *ssc = U_TYPED_CALLOCcxx . . $ `src/xrt/auxiliary/util/u_misc.h:47:9`!(struct sdl_swapchain);
97
98 xret = comp_swapchain_create_initcxx . . $ comp_swapchain_create_init(1de1ccc4e10ea03e).( //
99 &ssc->basecxx . . $ sdl_swapchain#base., //
100 really_destroycxx . . $ really_destroy(1be3bc1301f73959)., //
101 &sp->ccxx . . $ sdl_program#c..basecxx . . $ sdl_compositor#base..vkcxx . . $ comp_base#vk., //
102 &sp->ccxx . . $ sdl_program#c..basecxx . . $ sdl_compositor#base..cscscxx . . $ comp_base#cscs., //
103 info, //
104 &xsccp); //
105 if (xret != XRT_SUCCESScxx . . $ XRT_SUCCESS.) {
106 freecxx . . $ free(5d22bdacc48458e8).(ssc);
107 return xret;
108 }
109
110 // Init SDL fields and create OpenGL resources.
111 post_init_setupcxx . . $ post_init_setup(afa9ffc2df2f52f8).(ssc, sp, info);
112
113 // Correctly setup refcounts, init sets refcount to zero.
114 xrt_swapchain_referencecxx . . $ xrt_swapchain_reference(aa4f4bdff7c73b6).(out_xsc, &ssc->basecxx . . $ sdl_swapchain#base..basecxx . . $ comp_swapchain#base..basecxx . . $ xrt_swapchain_native#base.);
115
116 return xret;
117 }
118
119 xrt_result_tcxx . . $ xrt_result_t#
120 sdl_swapchain_importcxx . . $ sdl_swapchain_import(c509eb764310a8a3).(struct xrt_compositorcxx . . $ xrt_compositor# *xc,
121 const struct xrt_swapchain_create_infocxx . . $ xrt_swapchain_create_info# *info,
122 struct xrt_image_nativecxx . . $ xrt_image_native# *native_images,
123 uint32_tcxx . . $ uint32_t# native_image_count,
124 struct xrt_swapchaincxx . . $ xrt_swapchain# **out_xsc)
125 {
126 struct sdl_programcxx . . $ sdl_program# *sp = from_compcxx . . $ from_comp(66d7fec3c1affd02).(xc);
127 xrt_result_tcxx . . $ xrt_result_t# xret;
128
129 struct sdl_swapchaincxx . . $ sdl_swapchain# *ssc = U_TYPED_CALLOCcxx . . $ `src/xrt/auxiliary/util/u_misc.h:47:9`!(struct sdl_swapchain);
130
131 xret = comp_swapchain_import_initcxx . . $ comp_swapchain_import_init(d261355939eab812).( //
132 &ssc->basecxx . . $ sdl_swapchain#base., //
133 really_destroycxx . . $ really_destroy(1be3bc1301f73959)., //
134 &sp->ccxx . . $ sdl_program#c..basecxx . . $ sdl_compositor#base..vkcxx . . $ comp_base#vk., //
135 &sp->ccxx . . $ sdl_program#c..basecxx . . $ sdl_compositor#base..cscscxx . . $ comp_base#cscs., //
136 info, //
137 native_images, //
138 native_image_count); //
139 if (xret != XRT_SUCCESScxx . . $ XRT_SUCCESS.) {
140 freecxx . . $ free(5d22bdacc48458e8).(ssc);
141 return xret;
142 }
143
144 // Init SDL fields and create OpenGL resources.
145 post_init_setupcxx . . $ post_init_setup(afa9ffc2df2f52f8).(ssc, sp, info);
146
147 // Correctly setup refcounts, init sets refcount to zero.
148 xrt_swapchain_referencecxx . . $ xrt_swapchain_reference(aa4f4bdff7c73b6).(out_xsc, &ssc->basecxx . . $ sdl_swapchain#base..basecxx . . $ comp_swapchain#base..basecxx . . $ xrt_swapchain_native#base.);
149
150 return xret;
151 }