Просмотр исходного кода

noop: Pretend all features that are not returning results to CPU are available.

Branimir Karadžić 9 лет назад
Родитель
Сommit
d639452e9b
3 измененных файлов с 34 добавлено и 4 удалено
  1. 10 3
      src/bgfx.cpp
  2. 23 0
      src/renderer_noop.cpp
  3. 1 1
      tools/shaderc/shaderc_hlsl.cpp

+ 10 - 3
src/bgfx.cpp

@@ -575,7 +575,11 @@ namespace bgfx
 	{
 		BGFX_CHECK_MAIN_THREAD();
 
-		destroyProgram(m_program);
+		if (isValid(m_program) )
+		{
+			destroyProgram(m_program);
+		}
+
 		destroyTexture(m_texture);
 		s_ctx->destroyTransientVertexBuffer(m_vb);
 		s_ctx->destroyTransientIndexBuffer(m_ib);
@@ -2446,12 +2450,15 @@ namespace bgfx
 				s_callbackStub = BX_NEW(g_allocator, CallbackStub);
 		}
 
-		if (!BX_ENABLED(BX_PLATFORM_EMSCRIPTEN || BX_PLATFORM_NACL || BX_PLATFORM_PS4)
+		if (true
+		&&  !BX_ENABLED(BX_PLATFORM_EMSCRIPTEN || BX_PLATFORM_NACL || BX_PLATFORM_PS4)
+		&&  RendererType::Noop != _type
 		&&  NULL == g_platformData.ndt
 		&&  NULL == g_platformData.nwh
 		&&  NULL == g_platformData.context
 		&&  NULL == g_platformData.backBuffer
-		&&  NULL == g_platformData.backBufferDS)
+		&&  NULL == g_platformData.backBufferDS
+		   )
 		{
 			BX_TRACE("bgfx platform data like window handle or backbuffer must be set.");
 			goto error;

+ 23 - 0
src/renderer_noop.cpp

@@ -13,6 +13,29 @@ namespace bgfx { namespace noop
 	{
 		RendererContextNOOP()
 		{
+			// Pretend all features that are not returning results to CPU
+			// are available.
+			g_caps.supported = 0
+				| BGFX_CAPS_TEXTURE_COMPARE_LEQUAL
+				| BGFX_CAPS_TEXTURE_COMPARE_ALL
+				| BGFX_CAPS_TEXTURE_3D
+				| BGFX_CAPS_VERTEX_ATTRIB_HALF
+				| BGFX_CAPS_VERTEX_ATTRIB_UINT10
+				| BGFX_CAPS_INSTANCING
+				| BGFX_CAPS_FRAGMENT_DEPTH
+				| BGFX_CAPS_BLEND_INDEPENDENT
+				| BGFX_CAPS_COMPUTE
+				| BGFX_CAPS_FRAGMENT_ORDERING
+				| BGFX_CAPS_SWAP_CHAIN
+				| BGFX_CAPS_INDEX32
+				| BGFX_CAPS_DRAW_INDIRECT
+				| BGFX_CAPS_HIDPI
+				| BGFX_CAPS_TEXTURE_BLIT
+				| BGFX_CAPS_ALPHA_TO_COVERAGE
+				| BGFX_CAPS_CONSERVATIVE_RASTER
+				| BGFX_CAPS_TEXTURE_2D_ARRAY
+				| BGFX_CAPS_TEXTURE_CUBE_ARRAY
+				;
 		}
 
 		~RendererContextNOOP()

+ 1 - 1
tools/shaderc/shaderc_hlsl.cpp

@@ -107,7 +107,7 @@ namespace bgfx { namespace hlsl
 
 			if (g_verbose)
 			{
-				char filePath[PATH_MAX];
+				char filePath[MAX_PATH];
 				GetModuleFileNameA( (HMODULE)s_d3dcompilerdll, filePath, sizeof(filePath) );
 				BX_TRACE("Loaded %s compiler (%s).", compiler->fileName, filePath);
 			}