Parcourir la source

Moved settings in config.h file. Added config for PerfHUD device and PIX markers.

bkaradzic il y a 13 ans
Parent
commit
7e90a27790
4 fichiers modifiés avec 129 ajouts et 96 suppressions
  1. 1 90
      src/bgfx_p.h
  2. 107 0
      src/config.h
  3. 15 4
      src/renderer_d3d9.cpp
  4. 6 2
      src/renderer_d3d9.h

+ 1 - 90
src/bgfx_p.h

@@ -76,99 +76,10 @@ extern HWND g_bgfxHwnd;
 #define BGFX_MAGIC MAKEFOURCC('B','G','F','X')
 
 namespace std { namespace tr1 {} using namespace tr1; } // namespace std
-
 #include <string>
 #include <unordered_map>
 
-#if !defined(BGFX_CONFIG_RENDERER_DIRECT3D) && !defined(BGFX_CONFIG_RENDERER_OPENGL) && !defined(BGFX_CONFIG_RENDERER_OPENGLES) && !defined(BGFX_CONFIG_RENDERER_NULL)
-#	ifndef BGFX_CONFIG_RENDERER_DIRECT3D
-#		define BGFX_CONFIG_RENDERER_DIRECT3D (BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360)
-#	endif // BGFX_CONFIG_RENDERER_DIRECT3D
-
-#	ifndef BGFX_CONFIG_RENDERER_OPENGL
-#		define BGFX_CONFIG_RENDERER_OPENGL (BX_PLATFORM_LINUX)
-#	endif // BGFX_CONFIG_RENDERER_OPENGL
-
-#	ifndef BGFX_CONFIG_RENDERER_OPENGLES
-#		define BGFX_CONFIG_RENDERER_OPENGLES (BX_PLATFORM_NACL|BX_PLATFORM_ANDROID)
-#	endif // BGFX_CONFIG_RENDERER_OPENGLES
-
-#	ifndef BGFX_CONFIG_RENDERER_NULL
-#		define BGFX_CONFIG_RENDERER_NULL (!(BGFX_CONFIG_RENDERER_DIRECT3D|BGFX_CONFIG_RENDERER_OPENGL|BGFX_CONFIG_RENDERER_OPENGLES) )
-#	endif // BGFX_CONFIG_RENDERER_NULL
-#endif // !defined...
-
-#ifndef BGFX_CONFIG_MULTITHREADED
-#	define BGFX_CONFIG_MULTITHREADED ( (BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360|BX_PLATFORM_NACL)&(!BGFX_CONFIG_RENDERER_NULL) )
-#endif // BGFX_CONFIG_MULTITHREADED
-
-#ifndef BGFX_CONFIG_MAX_DRAW_CALLS
-#	define BGFX_CONFIG_MAX_DRAW_CALLS (8<<10)
-#endif // BGFX_CONFIG_MAX_DRAW_CALLS
-
-#ifndef BGFX_CONFIG_MAX_MATRIX_CACHE
-#	define BGFX_CONFIG_MAX_MATRIX_CACHE (16<<10)
-#endif // BGFX_CONFIG_MAX_MATRIX_CACHE
-
-#ifndef BGFX_CONFIG_MAX_VIEWS
-#	define BGFX_CONFIG_MAX_VIEWS 32
-#endif // BGFX_CONFIG_MAX_VIEWS
-
-#ifndef BGFX_CONFIG_MAX_INDEX_BUFFERS
-#	define BGFX_CONFIG_MAX_INDEX_BUFFERS (4<<10)
-#endif // BGFX_CONFIG_MAX_INDEX_BUFFERS
-
-#ifndef BGFX_CONFIG_MAX_VERTEX_DECLS
-#	define BGFX_CONFIG_MAX_VERTEX_DECLS 64
-#endif // BGFX_CONFIG_MAX_VERTEX_DECLS
-
-#ifndef BGFX_CONFIG_MAX_VERTEX_BUFFERS
-#	define BGFX_CONFIG_MAX_VERTEX_BUFFERS (4<<10)
-#endif // BGFX_CONFIG_MAX_VERTEX_BUFFERS
-
-#ifndef BGFX_CONFIG_MAX_VERTEX_SHADERS
-#	define BGFX_CONFIG_MAX_VERTEX_SHADERS 256
-#endif // BGFX_CONFIG_MAX_VERTEX_SHADERS
-
-#ifndef BGFX_CONFIG_MAX_FRAGMENT_SHADERS
-#	define BGFX_CONFIG_MAX_FRAGMENT_SHADERS 256
-#endif // BGFX_CONFIG_MAX_FRAGMENT_SHADERS
-
-#ifndef BGFX_CONFIG_MAX_MATERIALS
-#	define BGFX_CONFIG_MAX_MATERIALS 512
-#endif // BGFX_CONFIG_MAX_MATERIALS
-
-#ifndef BGFX_CONFIG_MAX_PROGRAMS
-#	define BGFX_CONFIG_MAX_PROGRAMS (4<<10)
-#endif // BGFX_CONFIG_MAX_PROGRAMS
-
-#ifndef BGFX_CONFIG_MAX_TEXTURES
-#	define BGFX_CONFIG_MAX_TEXTURES (4<<10)
-#endif // BGFX_CONFIG_MAX_TEXTURES
-
-#ifndef BGFX_CONFIG_MAX_RENDER_TARGETS
-#	define BGFX_CONFIG_MAX_RENDER_TARGETS 64
-#endif // BGFX_CONFIG_MAX_RENDER_TARGETS
-
-#ifndef BGFX_CONFIG_MAX_UNIFORMS
-#	define BGFX_CONFIG_MAX_UNIFORMS 512
-#endif // BGFX_CONFIG_MAX_CONSTANTS
-
-#ifndef BGFX_CONFIG_MAX_COMMAND_BUFFER_SIZE
-#	define BGFX_CONFIG_MAX_COMMAND_BUFFER_SIZE (64<<10)
-#endif // BGFX_CONFIG_MAX_COMMAND_BUFFER_SIZE
-
-#ifndef BGFX_CONFIG_DYNAMIC_VERTEX_BUFFER_SIZE
-#	define BGFX_CONFIG_DYNAMIC_VERTEX_BUFFER_SIZE (6<<20)
-#endif // BGFX_DYNAMIC_VERTEX_BUFFER_SIZE
-
-#ifndef BGFX_CONFIG_DYNAMIC_INDEX_BUFFER_SIZE
-#	define BGFX_CONFIG_DYNAMIC_INDEX_BUFFER_SIZE (2<<20)
-#endif // BGFX_CONFIG_DYNAMIC_INDEX_BUFFER_SIZE
-
-#ifndef BGFX_CONFIG_MAX_CONSTANT_BUFFER_SIZE
-#	define BGFX_CONFIG_MAX_CONSTANT_BUFFER_SIZE (512<<10)
-#endif // BGFX_CONFIG_MAX_CONSTANT_BUFFER_SIZE
+#include "config.h"
 
 #if BGFX_CONFIG_MULTITHREADED
 #	include <bx/sem.h>

+ 107 - 0
src/config.h

@@ -0,0 +1,107 @@
+/*
+ * Copyright 2011-2012 Branimir Karadzic. All rights reserved.
+ * License: http://www.opensource.org/licenses/BSD-2-Clause
+ */
+
+#ifndef __CONFIG_H__
+#define __CONFIG_H__
+
+#if !defined(BGFX_CONFIG_RENDERER_DIRECT3D) && !defined(BGFX_CONFIG_RENDERER_OPENGL) && !defined(BGFX_CONFIG_RENDERER_OPENGLES) && !defined(BGFX_CONFIG_RENDERER_NULL)
+#	ifndef BGFX_CONFIG_RENDERER_DIRECT3D
+#		define BGFX_CONFIG_RENDERER_DIRECT3D (BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360)
+#	endif // BGFX_CONFIG_RENDERER_DIRECT3D
+
+#	ifndef BGFX_CONFIG_RENDERER_OPENGL
+#		define BGFX_CONFIG_RENDERER_OPENGL (BX_PLATFORM_LINUX)
+#	endif // BGFX_CONFIG_RENDERER_OPENGL
+
+#	ifndef BGFX_CONFIG_RENDERER_OPENGLES
+#		define BGFX_CONFIG_RENDERER_OPENGLES (BX_PLATFORM_NACL|BX_PLATFORM_ANDROID)
+#	endif // BGFX_CONFIG_RENDERER_OPENGLES
+
+#	ifndef BGFX_CONFIG_RENDERER_NULL
+#		define BGFX_CONFIG_RENDERER_NULL (!(BGFX_CONFIG_RENDERER_DIRECT3D|BGFX_CONFIG_RENDERER_OPENGL|BGFX_CONFIG_RENDERER_OPENGLES) )
+#	endif // BGFX_CONFIG_RENDERER_NULL
+#endif // !defined...
+
+#ifndef BGFX_CONFIG_DEBUG_PERFHUD
+#	define BGFX_CONFIG_DEBUG_PERFHUD 0
+#endif // BGFX_CONFIG_DEBUG_NVPERFHUD
+
+#ifndef BGFX_CONFIG_DEBUG_PIX
+#	define BGFX_CONFIG_DEBUG_PIX 0
+#endif // BGFX_CONFIG_DEBUG_PIX
+
+#ifndef BGFX_CONFIG_MULTITHREADED
+#	define BGFX_CONFIG_MULTITHREADED ( (BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360|BX_PLATFORM_NACL)&(!BGFX_CONFIG_RENDERER_NULL) )
+#endif // BGFX_CONFIG_MULTITHREADED
+
+#ifndef BGFX_CONFIG_MAX_DRAW_CALLS
+#	define BGFX_CONFIG_MAX_DRAW_CALLS (8<<10)
+#endif // BGFX_CONFIG_MAX_DRAW_CALLS
+
+#ifndef BGFX_CONFIG_MAX_MATRIX_CACHE
+#	define BGFX_CONFIG_MAX_MATRIX_CACHE (16<<10)
+#endif // BGFX_CONFIG_MAX_MATRIX_CACHE
+
+#ifndef BGFX_CONFIG_MAX_VIEWS
+#	define BGFX_CONFIG_MAX_VIEWS 32
+#endif // BGFX_CONFIG_MAX_VIEWS
+
+#ifndef BGFX_CONFIG_MAX_INDEX_BUFFERS
+#	define BGFX_CONFIG_MAX_INDEX_BUFFERS (4<<10)
+#endif // BGFX_CONFIG_MAX_INDEX_BUFFERS
+
+#ifndef BGFX_CONFIG_MAX_VERTEX_DECLS
+#	define BGFX_CONFIG_MAX_VERTEX_DECLS 64
+#endif // BGFX_CONFIG_MAX_VERTEX_DECLS
+
+#ifndef BGFX_CONFIG_MAX_VERTEX_BUFFERS
+#	define BGFX_CONFIG_MAX_VERTEX_BUFFERS (4<<10)
+#endif // BGFX_CONFIG_MAX_VERTEX_BUFFERS
+
+#ifndef BGFX_CONFIG_MAX_VERTEX_SHADERS
+#	define BGFX_CONFIG_MAX_VERTEX_SHADERS 256
+#endif // BGFX_CONFIG_MAX_VERTEX_SHADERS
+
+#ifndef BGFX_CONFIG_MAX_FRAGMENT_SHADERS
+#	define BGFX_CONFIG_MAX_FRAGMENT_SHADERS 256
+#endif // BGFX_CONFIG_MAX_FRAGMENT_SHADERS
+
+#ifndef BGFX_CONFIG_MAX_MATERIALS
+#	define BGFX_CONFIG_MAX_MATERIALS 512
+#endif // BGFX_CONFIG_MAX_MATERIALS
+
+#ifndef BGFX_CONFIG_MAX_PROGRAMS
+#	define BGFX_CONFIG_MAX_PROGRAMS (4<<10)
+#endif // BGFX_CONFIG_MAX_PROGRAMS
+
+#ifndef BGFX_CONFIG_MAX_TEXTURES
+#	define BGFX_CONFIG_MAX_TEXTURES (4<<10)
+#endif // BGFX_CONFIG_MAX_TEXTURES
+
+#ifndef BGFX_CONFIG_MAX_RENDER_TARGETS
+#	define BGFX_CONFIG_MAX_RENDER_TARGETS 64
+#endif // BGFX_CONFIG_MAX_RENDER_TARGETS
+
+#ifndef BGFX_CONFIG_MAX_UNIFORMS
+#	define BGFX_CONFIG_MAX_UNIFORMS 512
+#endif // BGFX_CONFIG_MAX_CONSTANTS
+
+#ifndef BGFX_CONFIG_MAX_COMMAND_BUFFER_SIZE
+#	define BGFX_CONFIG_MAX_COMMAND_BUFFER_SIZE (64<<10)
+#endif // BGFX_CONFIG_MAX_COMMAND_BUFFER_SIZE
+
+#ifndef BGFX_CONFIG_DYNAMIC_VERTEX_BUFFER_SIZE
+#	define BGFX_CONFIG_DYNAMIC_VERTEX_BUFFER_SIZE (6<<20)
+#endif // BGFX_DYNAMIC_VERTEX_BUFFER_SIZE
+
+#ifndef BGFX_CONFIG_DYNAMIC_INDEX_BUFFER_SIZE
+#	define BGFX_CONFIG_DYNAMIC_INDEX_BUFFER_SIZE (2<<20)
+#endif // BGFX_CONFIG_DYNAMIC_INDEX_BUFFER_SIZE
+
+#ifndef BGFX_CONFIG_MAX_CONSTANT_BUFFER_SIZE
+#	define BGFX_CONFIG_MAX_CONSTANT_BUFFER_SIZE (512<<10)
+#endif // BGFX_CONFIG_MAX_CONSTANT_BUFFER_SIZE
+
+#endif // __CONFIG_H__

+ 15 - 4
src/renderer_d3d9.cpp

@@ -153,6 +153,9 @@ namespace bgfx
 
 			BGFX_FATAL(m_d3d9, bgfx::Fatal::D3D9_UnableToCreateInterface, "Unable to create Direct3D.");
 
+			uint32_t adapter = D3DADAPTER_DEFAULT;
+			D3DDEVTYPE deviceType = D3DDEVTYPE_HAL;
+
 			uint32_t adapterCount = m_d3d9->GetAdapterCount();
 			for (uint32_t ii = 0; ii < adapterCount; ++ii)
 			{
@@ -169,6 +172,14 @@ namespace bgfx
 						, identifier.SubSysId
 						, identifier.Revision
 						);
+
+#if BGFX_CONFIG_DEBUG_PERFHUD
+				if (0 != strstr(identifier.Description, "PerfHUD") )
+				{
+					adapter = ii;
+					deviceType = D3DDEVTYPE_REF;
+				}
+#endif // BGFX_CONFIG_DEBUG_PERFHUD
 			}
 
 			uint32_t behaviorFlags[] =
@@ -181,8 +192,8 @@ namespace bgfx
 			for (uint32_t ii = 0; ii < countof(behaviorFlags) && NULL == m_device; ++ii)
 			{
 #if BGFX_CONFIG_RENDERER_DIRECT3D_EX
-				DX_CHECK(m_d3d9->CreateDeviceEx(D3DADAPTER_DEFAULT
-						, D3DDEVTYPE_HAL
+				DX_CHECK(m_d3d9->CreateDeviceEx(adapter
+						, deviceType
 						, g_bgfxHwnd
 						, behaviorFlags[ii]
 						, &m_params
@@ -190,8 +201,8 @@ namespace bgfx
 						, &m_device
 						) );
 #else
-				DX_CHECK(m_d3d9->CreateDevice(D3DADAPTER_DEFAULT
-					, D3DDEVTYPE_HAL
+				DX_CHECK(m_d3d9->CreateDevice(adapter
+					, deviceType
 					, g_bgfxHwnd
 					, behaviorFlags[ii]
 					, &m_params

+ 6 - 2
src/renderer_d3d9.h

@@ -76,15 +76,19 @@ namespace bgfx
 
 #if BGFX_CONFIG_DEBUG
 #	define DX_CHECK(_call) _DX_CHECK(_call)
+#else
+#	define DX_CHECK(_call) _call
+#endif // BGFX_CONFIG_DEBUG
+
+#if BGFX_CONFIG_DEBUG_PIX
 #	define PIX_SETMARKER(_col, _name) _PIX_SETMARKER(_col, _name)
 #	define PIX_BEGINEVENT(_col, _name) _PIX_BEGINEVENT(_col, _name)
 #	define PIX_ENDEVENT() _PIX_ENDEVENT()
 #else
-#	define DX_CHECK(_call) _call
 #	define PIX_SETMARKER(_col, _name)
 #	define PIX_BEGINEVENT(_col, _name)
 #	define PIX_ENDEVENT()
-#endif // BGFX_CONFIG_DEBUG
+#endif // BGFX_CONFIG_DEBUG_PIX
 
 #define DX_RELEASE(_ptr, _expected) \
 				do { \