Browse Source

D3D12: Enabled direct access textures.

Branimir Karadžić 7 years ago
parent
commit
a02e57f121
2 changed files with 19 additions and 6 deletions
  1. 1 1
      src/renderer_d3d11.cpp
  2. 18 5
      src/renderer_d3d12.cpp

+ 1 - 1
src/renderer_d3d11.cpp

@@ -4932,7 +4932,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 				srvd.Format = getSrvFormat();
 			}
 
-			bool directAccess = s_renderD3D11->m_directAccessSupport
+			const bool directAccess = s_renderD3D11->m_directAccessSupport
 				&& !renderTarget
 				&& !readBack
 				&& !blit

+ 18 - 5
src/renderer_d3d12.cpp

@@ -650,6 +650,7 @@ namespace bgfx { namespace d3d12
 			, m_vsChanges(0)
 			, m_backBufferColorIdx(0)
 			, m_rtMsaa(false)
+			, m_directAccessSupport(false)
 		{
 		}
 
@@ -1272,6 +1273,11 @@ namespace bgfx { namespace d3d12
 					, (void**)&m_rootSignature
 					) );
 
+				m_directAccessSupport = true
+					&& BX_ENABLED(BX_PLATFORM_XBOXONE)
+					&& m_architecture.UMA
+					;
+
 				g_caps.supported |= ( 0
 					| BGFX_CAPS_TEXTURE_3D
 					| BGFX_CAPS_TEXTURE_COMPARE_ALL
@@ -1281,8 +1287,8 @@ namespace bgfx { namespace d3d12
 					| BGFX_CAPS_FRAGMENT_DEPTH
 					| BGFX_CAPS_BLEND_INDEPENDENT
 					| BGFX_CAPS_COMPUTE
-					| (m_options.ROVsSupported ? BGFX_CAPS_FRAGMENT_ORDERING : 0)
-//					| (m_architecture.UMA ? BGFX_CAPS_TEXTURE_DIRECT_ACCESS : 0)
+					| (m_options.ROVsSupported ? BGFX_CAPS_FRAGMENT_ORDERING     : 0)
+					| (m_directAccessSupport   ? BGFX_CAPS_TEXTURE_DIRECT_ACCESS : 0)
 					| (BX_ENABLED(BX_PLATFORM_WINDOWS) ? BGFX_CAPS_SWAP_CHAIN : 0)
 					| BGFX_CAPS_TEXTURE_BLIT
 					| BGFX_CAPS_TEXTURE_READ_BACK
@@ -3337,6 +3343,7 @@ data.NumQualityLevels = 0;
 		FrameBufferHandle m_fbh;
 		uint32_t m_backBufferColorIdx;
 		bool m_rtMsaa;
+		bool m_directAccessSupport;
 	};
 
 	static RendererContextD3D12* s_renderD3D12;
@@ -4720,6 +4727,13 @@ data.NumQualityLevels = 0;
 				state = D3D12_RESOURCE_STATE_COPY_DEST;
 			}
 
+			const bool directAccess = s_renderD3D12->m_directAccessSupport
+				&& !renderTarget
+//				&& !readBack
+				&& !blit
+				&& !writeOnly
+				;
+
 			switch (m_type)
 			{
 			case Texture2D:
@@ -4807,10 +4821,9 @@ data.NumQualityLevels = 0;
 
 			m_ptr = createCommittedResource(device, HeapProperty::Texture, &resourceDesc, clearValue);
 
-			if (kk != 0)
+			if (directAccess)
 			{
-//				void* directAccessPtr;
-//				DX_CHECK(m_ptr->Map(0, NULL, &directAccessPtr) );
+				DX_CHECK(m_ptr->Map(0, NULL, &m_directAccessPtr) );
 			}
 
 			if (kk != 0)