@@ -1233,7 +1233,7 @@ bool OpenXRAPI::obtain_swapchain_formats() {
12331233	return  true ;
12341234}
12351235
1236- bool  OpenXRAPI::create_main_swapchains (const  Size2i &p_size) {
1236+ bool  OpenXRAPI::create_main_swapchains (const  Size2i &p_size,  bool  p_protected_content ) {
12371237	ERR_NOT_ON_RENDER_THREAD_V (false );
12381238	ERR_FAIL_NULL_V (graphics_extension, false );
12391239	ERR_FAIL_COND_V (session == XR_NULL_HANDLE, false );
@@ -1254,11 +1254,19 @@ bool OpenXRAPI::create_main_swapchains(const Size2i &p_size) {
12541254	*/  
12551255
12561256	render_state.main_swapchain_size  = p_size;
1257+ 	render_state.swapchain_protected_content  = p_protected_content;
12571258	uint32_t  sample_count = 1 ;
12581259
1260+ 	//  Check to see if content should be protected.
1261+ 	XrSwapchainCreateFlags create_flags = 0 ;
1262+ 
1263+ 	if  (p_protected_content) {
1264+ 		create_flags = XR_SWAPCHAIN_CREATE_PROTECTED_CONTENT_BIT;
1265+ 	}
1266+ 
12591267	//  We start with our color swapchain...
12601268	if  (color_swapchain_format != 0 ) {
1261- 		if  (!render_state.main_swapchains [OPENXR_SWAPCHAIN_COLOR].create (0 , XR_SWAPCHAIN_USAGE_SAMPLED_BIT | XR_SWAPCHAIN_USAGE_COLOR_ATTACHMENT_BIT | XR_SWAPCHAIN_USAGE_MUTABLE_FORMAT_BIT, color_swapchain_format, render_state.main_swapchain_size .width , render_state.main_swapchain_size .height , sample_count, view_configuration_views.size ())) {
1269+ 		if  (!render_state.main_swapchains [OPENXR_SWAPCHAIN_COLOR].create (create_flags , XR_SWAPCHAIN_USAGE_SAMPLED_BIT | XR_SWAPCHAIN_USAGE_COLOR_ATTACHMENT_BIT | XR_SWAPCHAIN_USAGE_MUTABLE_FORMAT_BIT, color_swapchain_format, render_state.main_swapchain_size .width , render_state.main_swapchain_size .height , sample_count, view_configuration_views.size ())) {
12621270			return  false ;
12631271		}
12641272
@@ -1270,7 +1278,7 @@ bool OpenXRAPI::create_main_swapchains(const Size2i &p_size) {
12701278	//  - we support our depth layer extension
12711279	//  - we have our spacewarp extension (not yet implemented)
12721280	if  (depth_swapchain_format != 0  && submit_depth_buffer && OpenXRCompositionLayerDepthExtension::get_singleton ()->is_available ()) {
1273- 		if  (!render_state.main_swapchains [OPENXR_SWAPCHAIN_DEPTH].create (0 , XR_SWAPCHAIN_USAGE_SAMPLED_BIT | XR_SWAPCHAIN_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, depth_swapchain_format, render_state.main_swapchain_size .width , render_state.main_swapchain_size .height , sample_count, view_configuration_views.size ())) {
1281+ 		if  (!render_state.main_swapchains [OPENXR_SWAPCHAIN_DEPTH].create (create_flags , XR_SWAPCHAIN_USAGE_SAMPLED_BIT | XR_SWAPCHAIN_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, depth_swapchain_format, render_state.main_swapchain_size .width , render_state.main_swapchain_size .height , sample_count, view_configuration_views.size ())) {
12741282			return  false ;
12751283		}
12761284
@@ -2293,12 +2301,12 @@ void OpenXRAPI::pre_render() {
22932301	OpenXRSwapChainInfo::free_queued ();
22942302
22952303	Size2i swapchain_size = get_recommended_target_size ();
2296- 	if  (swapchain_size != render_state.main_swapchain_size ) {
2304+ 	if  (swapchain_size != render_state.main_swapchain_size  || protected_content != render_state. swapchain_protected_content ) {
22972305		//  Out with the old.
22982306		free_main_swapchains ();
22992307
23002308		//  In with the new.
2301- 		create_main_swapchains (swapchain_size);
2309+ 		create_main_swapchains (swapchain_size, protected_content );
23022310	}
23032311
23042312	void  *view_locate_info_next_pointer = nullptr ;
0 commit comments