Browse Source

Changed bgfx::init to take init parameters as structure instead of arguments.

Branimir Karadžić 7 years ago
parent
commit
5bb6a14876
51 changed files with 657 additions and 361 deletions
  1. 7 2
      examples/00-helloworld/helloworld.cpp
  2. 7 2
      examples/01-cubes/cubes.cpp
  3. 7 2
      examples/02-metaballs/metaballs.cpp
  4. 7 2
      examples/03-raymarch/raymarch.cpp
  5. 7 2
      examples/04-mesh/mesh.cpp
  6. 7 2
      examples/05-instancing/instancing.cpp
  7. 7 2
      examples/06-bump/bump.cpp
  8. 9 8
      examples/07-callback/callback.cpp
  9. 7 2
      examples/08-update/update.cpp
  10. 7 2
      examples/09-hdr/hdr.cpp
  11. 7 2
      examples/10-font/font.cpp
  12. 7 2
      examples/11-fontsdf/fontsdf.cpp
  13. 7 2
      examples/12-lod/lod.cpp
  14. 7 2
      examples/13-stencil/stencil.cpp
  15. 7 2
      examples/14-shadowvolumes/shadowvolumes.cpp
  16. 7 2
      examples/15-shadowmaps-simple/shadowmaps_simple.cpp
  17. 7 2
      examples/16-shadowmaps/shadowmaps.cpp
  18. 7 2
      examples/17-drawstress/drawstress.cpp
  19. 7 2
      examples/18-ibl/ibl.cpp
  20. 7 2
      examples/19-oit/oit.cpp
  21. 7 2
      examples/20-nanovg/nanovg.cpp
  22. 7 2
      examples/21-deferred/deferred.cpp
  23. 7 2
      examples/22-windows/windows.cpp
  24. 7 2
      examples/23-vectordisplay/main.cpp
  25. 7 2
      examples/24-nbody/nbody.cpp
  26. 4 6
      examples/25-c99/helloworld.c
  27. 7 2
      examples/26-occlusion/occlusion.cpp
  28. 7 2
      examples/27-terrain/terrain.cpp
  29. 7 2
      examples/28-wireframe/wireframe.cpp
  30. 7 2
      examples/29-debugdraw/debugdraw.cpp
  31. 7 3
      examples/30-picking/picking.cpp
  32. 7 3
      examples/31-rsm/reflectiveshadowmap.cpp
  33. 7 2
      examples/32-particles/particles.cpp
  34. 7 2
      examples/33-pom/pom.cpp
  35. 7 2
      examples/34-mvs/mvs.cpp
  36. 7 2
      examples/35-dynamic/dynamic.cpp
  37. 7 2
      examples/36-sky/sky.cpp
  38. 7 2
      examples/37-gpudrivenrendering/gpudrivenrendering.cpp
  39. 60 28
      include/bgfx/bgfx.h
  40. 35 1
      include/bgfx/c99/bgfx.h
  41. 2 1
      include/bgfx/c99/platform.h
  42. 1 1
      include/bgfx/defines.h
  43. 90 43
      src/bgfx.cpp
  44. 30 41
      src/bgfx_p.h
  45. 3 3
      src/config.h
  46. 38 30
      src/renderer_d3d11.cpp
  47. 31 23
      src/renderer_d3d12.cpp
  48. 20 20
      src/renderer_d3d9.cpp
  49. 34 34
      src/renderer_gl.cpp
  50. 34 34
      src/renderer_mtl.mm
  51. 14 14
      src/renderer_vk.cpp

+ 7 - 2
examples/00-helloworld/helloworld.cpp

@@ -29,8 +29,13 @@ public:
 		m_debug  = BGFX_DEBUG_TEXT;
 		m_debug  = BGFX_DEBUG_TEXT;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/01-cubes/cubes.cpp

@@ -98,8 +98,13 @@ public:
 		m_debug  = BGFX_DEBUG_NONE;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/02-metaballs/metaballs.cpp

@@ -493,8 +493,13 @@ public:
 		m_debug  = BGFX_DEBUG_NONE;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/03-raymarch/raymarch.cpp

@@ -116,8 +116,13 @@ public:
 		m_debug  = BGFX_DEBUG_NONE;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/04-mesh/mesh.cpp

@@ -27,8 +27,13 @@ public:
 		m_debug  = BGFX_DEBUG_NONE;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/05-instancing/instancing.cpp

@@ -76,8 +76,13 @@ public:
 		m_debug  = BGFX_DEBUG_TEXT;
 		m_debug  = BGFX_DEBUG_TEXT;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/06-bump/bump.cpp

@@ -99,8 +99,13 @@ public:
 		m_debug  = BGFX_DEBUG_NONE;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 9 - 8
examples/07-callback/callback.cpp

@@ -323,14 +323,15 @@ public:
 			| BGFX_RESET_MSAA_X16
 			| BGFX_RESET_MSAA_X16
 			;
 			;
 
 
-		bgfx::init(
-			  args.m_type
-			, args.m_pciId
-			, 0
-			, &m_callback  // custom callback handler
-			, &m_allocator // custom allocator
-			);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		init.callback  = &m_callback;  // custom callback handler
+		init.allocator = &m_allocator; // custom allocator
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/08-update/update.cpp

@@ -136,8 +136,13 @@ public:
 		m_debug  = BGFX_DEBUG_NONE;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/09-hdr/hdr.cpp

@@ -154,8 +154,13 @@ public:
 		m_debug  = BGFX_DEBUG_NONE;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable m_debug text.
 		// Enable m_debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/10-font/font.cpp

@@ -68,8 +68,13 @@ public:
 		m_debug  = BGFX_DEBUG_NONE;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/11-fontsdf/fontsdf.cpp

@@ -51,8 +51,13 @@ public:
 		m_debug = BGFX_DEBUG_NONE;
 		m_debug = BGFX_DEBUG_NONE;
 		m_reset = BGFX_RESET_VSYNC;
 		m_reset = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/12-lod/lod.cpp

@@ -43,8 +43,13 @@ public:
 		m_debug  = BGFX_DEBUG_NONE;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/13-stencil/stencil.cpp

@@ -805,8 +805,13 @@ public:
 		m_debug = BGFX_DEBUG_NONE;
 		m_debug = BGFX_DEBUG_NONE;
 		m_reset = BGFX_RESET_VSYNC;
 		m_reset = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_viewState.m_width, m_viewState.m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_viewState.m_width;
+		init.resolution.height = m_viewState.m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/14-shadowvolumes/shadowvolumes.cpp

@@ -1885,8 +1885,13 @@ public:
 		m_debug = BGFX_DEBUG_TEXT;
 		m_debug = BGFX_DEBUG_TEXT;
 		m_reset = BGFX_RESET_VSYNC;
 		m_reset = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_viewState.m_width, m_viewState.m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_viewState.m_width;
+		init.resolution.height = m_viewState.m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/15-shadowmaps-simple/shadowmaps_simple.cpp

@@ -75,8 +75,13 @@ public:
 		m_debug = BGFX_DEBUG_NONE;
 		m_debug = BGFX_DEBUG_NONE;
 		m_reset = BGFX_RESET_VSYNC;
 		m_reset = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/16-shadowmaps/shadowmaps.cpp

@@ -1301,8 +1301,13 @@ public:
 		m_viewState = ViewState(uint16_t(m_width), uint16_t(m_height));
 		m_viewState = ViewState(uint16_t(m_width), uint16_t(m_height));
 		m_clearValues = ClearValues(0x00000000, 1.0f, 0);
 		m_clearValues = ClearValues(0x00000000, 1.0f, 0);
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_viewState.m_width, m_viewState.m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_viewState.m_width;
+		init.resolution.height = m_viewState.m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/17-drawstress/drawstress.cpp

@@ -126,8 +126,13 @@ public:
 		m_deltaTimeAvgNs = 0;
 		m_deltaTimeAvgNs = 0;
 		m_numFrames      = 0;
 		m_numFrames      = 0;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		const bgfx::Caps* caps = bgfx::getCaps();
 		const bgfx::Caps* caps = bgfx::getCaps();
 		m_maxDim = (int32_t)bx::pow(float(caps->limits.maxDrawCalls), 1.0f/3.0f);
 		m_maxDim = (int32_t)bx::pow(float(caps->limits.maxDrawCalls), 1.0f/3.0f);

+ 7 - 2
examples/18-ibl/ibl.cpp

@@ -501,8 +501,13 @@ public:
 			| BGFX_RESET_MSAA_X16
 			| BGFX_RESET_MSAA_X16
 			;
 			;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/19-oit/oit.cpp

@@ -166,8 +166,13 @@ public:
 		m_debug  = BGFX_DEBUG_NONE;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/20-nanovg/nanovg.cpp

@@ -1250,8 +1250,13 @@ public:
 		m_debug  = BGFX_DEBUG_NONE;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/21-deferred/deferred.cpp

@@ -207,8 +207,13 @@ public:
 		m_debug  = BGFX_DEBUG_TEXT;
 		m_debug  = BGFX_DEBUG_TEXT;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable m_debug text.
 		// Enable m_debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/22-windows/windows.cpp

@@ -83,8 +83,13 @@ public:
 		m_debug  = BGFX_DEBUG_TEXT;
 		m_debug  = BGFX_DEBUG_TEXT;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		const bgfx::Caps* caps = bgfx::getCaps();
 		const bgfx::Caps* caps = bgfx::getCaps();
 		bool swapChainSupported = 0 != (caps->supported & BGFX_CAPS_SWAP_CHAIN);
 		bool swapChainSupported = 0 != (caps->supported & BGFX_CAPS_SWAP_CHAIN);

+ 7 - 2
examples/23-vectordisplay/main.cpp

@@ -50,8 +50,13 @@ public:
 		m_debug = BGFX_DEBUG_NONE;
 		m_debug = BGFX_DEBUG_NONE;
 		m_reset = BGFX_RESET_VSYNC;
 		m_reset = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		const bgfx::RendererType::Enum renderer = bgfx::getRendererType();
 		const bgfx::RendererType::Enum renderer = bgfx::getRendererType();
 		float texelHalf = bgfx::RendererType::Direct3D9 == renderer ? 0.5f : 0.0f;
 		float texelHalf = bgfx::RendererType::Direct3D9 == renderer ? 0.5f : 0.0f;

+ 7 - 2
examples/24-nbody/nbody.cpp

@@ -127,8 +127,13 @@ public:
 		m_debug  = BGFX_DEBUG_NONE;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 4 - 6
examples/25-c99/helloworld.c

@@ -22,12 +22,10 @@ int32_t _main_(int32_t _argc, char** _argv)
 	(void)_argc;
 	(void)_argc;
 	(void)_argv;
 	(void)_argv;
 
 
-	bgfx_init(BGFX_RENDERER_TYPE_COUNT
-			, BGFX_PCI_ID_NONE
-			, 0
-			, NULL
-			, NULL
-			);
+	bgfx_init_t init;
+	bgfx_init_ctor(&init);
+
+	bgfx_init(&init);
 	bgfx_reset(width, height, reset);
 	bgfx_reset(width, height, reset);
 
 
 	// Enable debug text.
 	// Enable debug text.

+ 7 - 2
examples/26-occlusion/occlusion.cpp

@@ -79,8 +79,13 @@ public:
 		m_debug  = BGFX_DEBUG_TEXT;
 		m_debug  = BGFX_DEBUG_TEXT;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/27-terrain/terrain.cpp

@@ -76,8 +76,13 @@ public:
 		m_debug  = BGFX_DEBUG_NONE;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable m_debug text.
 		// Enable m_debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/28-wireframe/wireframe.cpp

@@ -303,8 +303,13 @@ public:
 			| BGFX_RESET_MSAA_X16
 			| BGFX_RESET_MSAA_X16
 			;
 			;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable m_debug text.
 		// Enable m_debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/29-debugdraw/debugdraw.cpp

@@ -494,8 +494,13 @@ public:
 		m_debug  = BGFX_DEBUG_NONE;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC | BGFX_RESET_MSAA_X16;
 		m_reset  = BGFX_RESET_VSYNC | BGFX_RESET_MSAA_X16;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable m_debug text.
 		// Enable m_debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 3
examples/30-picking/picking.cpp

@@ -35,9 +35,13 @@ public:
 		m_debug  = BGFX_DEBUG_NONE;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 3
examples/31-rsm/reflectiveshadowmap.cpp

@@ -208,9 +208,13 @@ public:
 		m_debug  = BGFX_DEBUG_NONE;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/32-particles/particles.cpp

@@ -246,8 +246,13 @@ public:
 		m_debug  = BGFX_DEBUG_NONE;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable m_debug text.
 		// Enable m_debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/33-pom/pom.cpp

@@ -125,8 +125,13 @@ public:
 		m_debug  = BGFX_DEBUG_NONE;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/34-mvs/mvs.cpp

@@ -121,8 +121,13 @@ public:
 		m_debug  = BGFX_DEBUG_NONE;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/35-dynamic/dynamic.cpp

@@ -99,8 +99,13 @@ public:
 		m_debug  = BGFX_DEBUG_NONE;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 7 - 2
examples/36-sky/sky.cpp

@@ -423,8 +423,13 @@ namespace
 			m_debug = BGFX_DEBUG_NONE;
 			m_debug = BGFX_DEBUG_NONE;
 			m_reset = BGFX_RESET_VSYNC;
 			m_reset = BGFX_RESET_VSYNC;
 
 
-			bgfx::init(args.m_type, args.m_pciId);
-			bgfx::reset(m_width, m_height, m_reset);
+			bgfx::Init init;
+			init.type     = args.m_type;
+			init.vendorId = args.m_pciId;
+			init.resolution.width  = m_width;
+			init.resolution.height = m_height;
+			init.resolution.reset  = m_reset;
+			bgfx::init(init);
 
 
 			// Enable m_debug text.
 			// Enable m_debug text.
 			bgfx::setDebug(m_debug);
 			bgfx::setDebug(m_debug);

+ 7 - 2
examples/37-gpudrivenrendering/gpudrivenrendering.cpp

@@ -413,8 +413,13 @@ public:
 		m_debug  = BGFX_DEBUG_TEXT;
 		m_debug  = BGFX_DEBUG_TEXT;
 		m_reset  = BGFX_RESET_VSYNC;
 		m_reset  = BGFX_RESET_VSYNC;
 
 
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
+		bgfx::Init init;
+		init.type     = args.m_type;
+		init.vendorId = args.m_pciId;
+		init.resolution.width  = m_width;
+		init.resolution.height = m_height;
+		init.resolution.reset  = m_reset;
+		bgfx::init(init);
 
 
 		// Enable debug text.
 		// Enable debug text.
 		bgfx::setDebug(m_debug);
 		bgfx::setDebug(m_debug);

+ 60 - 28
include/bgfx/bgfx.h

@@ -557,6 +557,64 @@ namespace bgfx
 	{
 	{
 	}
 	}
 
 
+	///
+	///
+	/// @attention C99 equivalent is `bgfx_resolution_t`.
+	///
+	struct Resolution
+	{
+		Resolution();
+
+		uint32_t width;  //!< Backbuffer width.
+		uint32_t height; //!< Backbuffer height.
+		uint32_t reset;	 //!< Reset parameters.
+	};
+
+	/// Initialization parameters used by `bgfx::init`.
+	///
+	/// @attention C99 equivalent is `bgfx_init_t`.
+	///
+	struct Init
+	{
+		Init();
+
+		/// Select rendering backend. When set to RendererType::Count
+		/// a default rendering backend will be selected appropriate to the platform.
+		/// See: `bgfx::RendererType`
+		RendererType::Enum type;
+
+		/// Vendor PCI id. If set to `BGFX_PCI_ID_NONE` it will select the first
+		/// device.
+		///   - `BGFX_PCI_ID_NONE` - Autoselect adapter.
+		///   - `BGFX_PCI_ID_SOFTWARE_RASTERIZER` - Software rasterizer.
+		///   - `BGFX_PCI_ID_AMD` - AMD adapter.
+		///   - `BGFX_PCI_ID_INTEL` - Intel adapter.
+		///   - `BGFX_PCI_ID_NVIDIA` - nVidia adapter.
+		uint16_t vendorId;
+
+		/// Device id. If set to 0 it will select first device, or device with
+		/// matching id.
+		uint16_t deviceId;
+
+		Resolution resolution;
+
+		struct Limits
+		{
+			uint16_t maxEncoders; //!< Maximum number of encoder threads.
+		};
+
+		Limits limits;
+
+		/// Provide application specific callback interface.
+		/// See: `bgfx::CallbackI`
+		CallbackI* callback;
+
+		/// Custom allocator. When a custom allocator is not
+		/// specified, bgfx uses the CRT allocator. Bgfx assumes
+		/// custom allocator is thread safe.
+		bx::AllocatorI* allocator;
+	};
+
 	/// Memory release callback.
 	/// Memory release callback.
 	///
 	///
 	/// param[in] _ptr Pointer to allocated data.
 	/// param[in] _ptr Pointer to allocated data.
@@ -1748,39 +1806,13 @@ namespace bgfx
 
 
 	/// Initialize bgfx library.
 	/// Initialize bgfx library.
 	///
 	///
-	/// @param[in] _type Select rendering backend. When set to RendererType::Count
-	///   a default rendering backend will be selected appropriate to the platform.
-	///   See: `bgfx::RendererType`
-	///
-	/// @param[in] _vendorId Vendor PCI id. If set to `BGFX_PCI_ID_NONE` it will select the first
-	///   device.
-	///   - `BGFX_PCI_ID_NONE` - Autoselect adapter.
-	///   - `BGFX_PCI_ID_SOFTWARE_RASTERIZER` - Software rasterizer.
-	///   - `BGFX_PCI_ID_AMD` - AMD adapter.
-	///   - `BGFX_PCI_ID_INTEL` - Intel adapter.
-	///   - `BGFX_PCI_ID_NVIDIA` - nVidia adapter.
-	///
-	/// @param[in] _deviceId Device id. If set to 0 it will select first device, or device with
-	///   matching id.
-	///
-	/// @param[in] _callback Provide application specific callback interface.
-	///   See: `bgfx::CallbackI`
-	///
-	/// @param[in] _allocator Custom allocator. When a custom allocator is not
-	///   specified, bgfx uses the CRT allocator. Bgfx assumes
-	///   custom allocator is thread safe.
+	/// @param[in] _init Initialization parameters. See: `bgfx::Init` for more info.
 	///
 	///
 	/// @returns `true` if initialization was successful.
 	/// @returns `true` if initialization was successful.
 	///
 	///
 	/// @attention C99 equivalent is `bgfx_init`.
 	/// @attention C99 equivalent is `bgfx_init`.
 	///
 	///
-	bool init(
-		  RendererType::Enum _type = RendererType::Count
-		, uint16_t _vendorId = BGFX_PCI_ID_NONE
-		, uint16_t _deviceId = 0
-		, CallbackI* _callback = NULL
-		, bx::AllocatorI* _allocator = NULL
-		);
+	bool init(const Init& _init);
 
 
 	/// Shutdown bgfx library.
 	/// Shutdown bgfx library.
 	///
 	///

+ 35 - 1
include/bgfx/c99/bgfx.h

@@ -590,6 +590,37 @@ typedef struct bgfx_allocator_vtbl
 
 
 } bgfx_allocator_vtbl_t;
 } bgfx_allocator_vtbl_t;
 
 
+/**/
+typedef struct bgfx_resolution
+{
+    uint32_t width;
+    uint32_t height;
+    uint32_t flags;
+
+} bgfx_resolution_t;
+
+/**/
+typedef struct bgfx_init_limits
+{
+    uint16_t maxEncoders;
+
+} bgfx_init_limits_t;
+
+/**/
+typedef struct bgfx_init
+{
+    bgfx_renderer_type_t type;
+    uint16_t vendorId;
+    uint16_t deviceId;
+
+    bgfx_resolution_t  resolution;
+    bgfx_init_limits_t limits;
+
+    bgfx_callback_interface_t*  callback;
+    bgfx_allocator_interface_t* allocator;
+
+} bgfx_init_t;
+
 /**/
 /**/
 BGFX_C_API void bgfx_vertex_decl_begin(bgfx_vertex_decl_t* _decl, bgfx_renderer_type_t _renderer);
 BGFX_C_API void bgfx_vertex_decl_begin(bgfx_vertex_decl_t* _decl, bgfx_renderer_type_t _renderer);
 
 
@@ -627,7 +658,10 @@ BGFX_C_API uint8_t bgfx_get_supported_renderers(uint8_t _max, bgfx_renderer_type
 BGFX_C_API const char* bgfx_get_renderer_name(bgfx_renderer_type_t _type);
 BGFX_C_API const char* bgfx_get_renderer_name(bgfx_renderer_type_t _type);
 
 
 /**/
 /**/
-BGFX_C_API bool bgfx_init(bgfx_renderer_type_t _type, uint16_t _vendorId, uint16_t _deviceId, bgfx_callback_interface_t* _callback, bgfx_allocator_interface_t* _allocator);
+BGFX_C_API void bgfx_init_ctor(bgfx_init_t* _init);
+
+/**/
+BGFX_C_API bool bgfx_init(const bgfx_init_t* _init);
 
 
 /**/
 /**/
 BGFX_C_API void bgfx_shutdown(void);
 BGFX_C_API void bgfx_shutdown(void);

+ 2 - 1
include/bgfx/c99/platform.h

@@ -83,7 +83,8 @@ typedef struct bgfx_interface_vtbl
     void (*topology_sort_tri_list)(bgfx_topology_sort_t _sort, void* _dst, uint32_t _dstSize, const float _dir[3], const float _pos[3], const void* _vertices, uint32_t _stride, const void* _indices, uint32_t _numIndices, bool _index32);
     void (*topology_sort_tri_list)(bgfx_topology_sort_t _sort, void* _dst, uint32_t _dstSize, const float _dir[3], const float _pos[3], const void* _vertices, uint32_t _stride, const void* _indices, uint32_t _numIndices, bool _index32);
     uint8_t (*get_supported_renderers)(uint8_t _max, bgfx_renderer_type_t* _enum);
     uint8_t (*get_supported_renderers)(uint8_t _max, bgfx_renderer_type_t* _enum);
     const char* (*get_renderer_name)(bgfx_renderer_type_t _type);
     const char* (*get_renderer_name)(bgfx_renderer_type_t _type);
-    bool (*init)(bgfx_renderer_type_t _type, uint16_t _vendorId, uint16_t _deviceId, bgfx_callback_interface_t* _callback, bgfx_allocator_interface_t* _allocator);
+    void (*init_ctor)(bgfx_init_t* _init);
+    bool (*init)(const bgfx_init_t* _init);
     void (*shutdown)();
     void (*shutdown)();
     void (*reset)(uint32_t _width, uint32_t _height, uint32_t _flags);
     void (*reset)(uint32_t _width, uint32_t _height, uint32_t _flags);
     uint32_t (*frame)(bool _capture);
     uint32_t (*frame)(bool _capture);

+ 1 - 1
include/bgfx/defines.h

@@ -6,7 +6,7 @@
 #ifndef BGFX_DEFINES_H_HEADER_GUARD
 #ifndef BGFX_DEFINES_H_HEADER_GUARD
 #define BGFX_DEFINES_H_HEADER_GUARD
 #define BGFX_DEFINES_H_HEADER_GUARD
 
 
-#define BGFX_API_VERSION UINT32_C(64)
+#define BGFX_API_VERSION UINT32_C(65)
 
 
 /// Color RGB/alpha/depth write. When it's not specified write will be disabled.
 /// Color RGB/alpha/depth write. When it's not specified write will be disabled.
 #define BGFX_STATE_WRITE_R                 UINT64_C(0x0000000000000001) //!< Enable R write.
 #define BGFX_STATE_WRITE_R                 UINT64_C(0x0000000000000001) //!< Enable R write.

+ 90 - 43
src/bgfx.cpp

@@ -1382,10 +1382,13 @@ namespace bgfx
 		TextureFormat::RGBA8, // D3D9 doesn't support RGBA8
 		TextureFormat::RGBA8, // D3D9 doesn't support RGBA8
 	};
 	};
 
 
-	bool Context::init(RendererType::Enum _type)
+	bool Context::init(const Init& _init)
 	{
 	{
 		BX_CHECK(!m_rendererInitialized, "Already initialized?");
 		BX_CHECK(!m_rendererInitialized, "Already initialized?");
 
 
+		m_init = _init;
+		m_init.resolution.reset &= ~BGFX_RESET_INTERNAL_FORCE;
+
 		m_exit    = false;
 		m_exit    = false;
 		m_flipped = true;
 		m_flipped = true;
 		m_frames  = 0;
 		m_frames  = 0;
@@ -1442,11 +1445,19 @@ namespace bgfx
 		m_declRef.init();
 		m_declRef.init();
 
 
 		CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::RendererInit);
 		CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::RendererInit);
-		cmdbuf.write(_type);
+		cmdbuf.write(_init);
 
 
 		frameNoRenderWait();
 		frameNoRenderWait();
 
 
-		uint16_t idx = m_encoderHandle.alloc();
+		m_encoderHandle = bx::createHandleAlloc(g_allocator, _init.limits.maxEncoders);
+		m_encoder       = (EncoderImpl*)BX_ALLOC(g_allocator, sizeof(EncoderImpl)*_init.limits.maxEncoders);
+		m_encoderStats  = (EncoderStats*)BX_ALLOC(g_allocator, sizeof(EncoderStats)*_init.limits.maxEncoders);
+		for (uint32_t ii = 0, num = _init.limits.maxEncoders; ii < num; ++ii)
+		{
+			BX_PLACEMENT_NEW(&m_encoder[ii], EncoderImpl);
+		}
+
+		uint16_t idx = m_encoderHandle->alloc();
 		BX_CHECK(0 == idx, "Internal encoder handle is not 0 (idx %d).", idx); BX_UNUSED(idx);
 		BX_CHECK(0 == idx, "Internal encoder handle is not 0 (idx %d).", idx); BX_UNUSED(idx);
 		m_encoder[0].begin(m_submit, 0);
 		m_encoder[0].begin(m_submit, 0);
 		m_encoder0 = reinterpret_cast<Encoder*>(&m_encoder[0]);
 		m_encoder0 = reinterpret_cast<Encoder*>(&m_encoder[0]);
@@ -1537,6 +1548,16 @@ namespace bgfx
 		frame();
 		frame();
 
 
 		m_encoder[0].end(true);
 		m_encoder[0].end(true);
+		m_encoderHandle->free(0);
+		bx::destroyHandleAlloc(g_allocator, m_encoderHandle);
+		m_encoderHandle = NULL;
+
+		for (uint32_t ii = 0, num = g_caps.limits.maxEncoders; ii < num; ++ii)
+		{
+			m_encoder[ii].~EncoderImpl();
+		}
+		BX_FREE(g_allocator, m_encoder);
+		BX_FREE(g_allocator, m_encoderStats);
 
 
 		m_dynVertexBufferAllocator.compact();
 		m_dynVertexBufferAllocator.compact();
 		m_dynIndexBufferAllocator.compact();
 		m_dynIndexBufferAllocator.compact();
@@ -1697,7 +1718,7 @@ namespace bgfx
 		{
 		{
 			bx::MutexScope scopeLock(m_encoderApiLock);
 			bx::MutexScope scopeLock(m_encoderApiLock);
 
 
-			uint16_t idx = m_encoderHandle.alloc();
+			uint16_t idx = m_encoderHandle->alloc();
 			if (kInvalidHandle == idx)
 			if (kInvalidHandle == idx)
 			{
 			{
 				return NULL;
 				return NULL;
@@ -1761,8 +1782,8 @@ namespace bgfx
 	void Context::swap()
 	void Context::swap()
 	{
 	{
 		freeDynamicBuffers();
 		freeDynamicBuffers();
-		m_submit->m_resolution = m_resolution;
-		m_resolution.m_flags &= ~BGFX_RESET_INTERNAL_FORCE;
+		m_submit->m_resolution = m_init.resolution;
+		m_init.resolution.reset &= ~BGFX_RESET_INTERNAL_FORCE;
 		m_submit->m_debug = m_debug;
 		m_submit->m_debug = m_debug;
 		m_submit->m_perfStats.numViews = 0;
 		m_submit->m_perfStats.numViews = 0;
 
 
@@ -1795,9 +1816,10 @@ namespace bgfx
 
 
 		bx::memSet(m_seq, 0, sizeof(m_seq) );
 		bx::memSet(m_seq, 0, sizeof(m_seq) );
 
 
-		m_submit->m_textVideoMem->resize(m_render->m_textVideoMem->m_small
-			, m_resolution.m_width
-			, m_resolution.m_height
+		m_submit->m_textVideoMem->resize(
+			  m_render->m_textVideoMem->m_small
+			, m_init.resolution.width
+			, m_init.resolution.height
 			);
 			);
 
 
 		int64_t now = bx::getHPCounter();
 		int64_t now = bx::getHPCounter();
@@ -1806,7 +1828,7 @@ namespace bgfx
 	}
 	}
 
 
 	///
 	///
-	RendererContextI* rendererCreate(RendererType::Enum _type, const Init& _init);
+	RendererContextI* rendererCreate(const Init& _init);
 
 
 	///
 	///
 	void rendererDestroy(RendererContextI* _renderCtx);
 	void rendererDestroy(RendererContextI* _renderCtx);
@@ -1825,7 +1847,8 @@ namespace bgfx
 				rendererDestroy(m_renderCtx);
 				rendererDestroy(m_renderCtx);
 
 
 				Init init;
 				Init init;
-				m_renderCtx = rendererCreate(RendererType::Noop, init);
+				init.type = RendererType::Noop;
+				m_renderCtx = rendererCreate(init);
 				g_caps.rendererType = RendererType::Noop;
 				g_caps.rendererType = RendererType::Noop;
 			}
 			}
 		}
 		}
@@ -2060,7 +2083,7 @@ namespace bgfx
 		return *(const int32_t*)_rhs - *(const int32_t*)_lhs;
 		return *(const int32_t*)_rhs - *(const int32_t*)_lhs;
 	}
 	}
 
 
-	RendererContextI* rendererCreate(RendererType::Enum _type, const Init& _init)
+	RendererContextI* rendererCreate(const Init& _init)
 	{
 	{
 		int32_t scores[RendererType::Count];
 		int32_t scores[RendererType::Count];
 		uint32_t numScores = 0;
 		uint32_t numScores = 0;
@@ -2071,7 +2094,7 @@ namespace bgfx
 			if (s_rendererCreator[ii].supported)
 			if (s_rendererCreator[ii].supported)
 			{
 			{
 				int32_t score = 0;
 				int32_t score = 0;
-				if (_type == renderer)
+				if (_init.type == renderer)
 				{
 				{
 					score += 1000;
 					score += 1000;
 				}
 				}
@@ -2184,11 +2207,10 @@ namespace bgfx
 						);
 						);
 					BX_CHECK(!m_rendererInitialized, "This shouldn't happen! Bad synchronization?");
 					BX_CHECK(!m_rendererInitialized, "This shouldn't happen! Bad synchronization?");
 
 
-					RendererType::Enum type;
-					_cmdbuf.read(type);
-
 					Init init;
 					Init init;
-					m_renderCtx = rendererCreate(type, init);
+					_cmdbuf.read(init);
+
+					m_renderCtx = rendererCreate(init);
 
 
 					m_rendererInitialized = NULL != m_renderCtx;
 					m_rendererInitialized = NULL != m_renderCtx;
 
 
@@ -2741,7 +2763,24 @@ namespace bgfx
 		return s_rendererCreator[_type].name;
 		return s_rendererCreator[_type].name;
 	}
 	}
 
 
-	bool init(RendererType::Enum _type, uint16_t _vendorId, uint16_t _deviceId, CallbackI* _callback, bx::AllocatorI* _allocator)
+	Resolution::Resolution()
+		: width(1280)
+		, height(720)
+		, reset(BGFX_RESET_NONE)
+	{
+	}
+
+	Init::Init()
+		: type(RendererType::Count)
+		, vendorId(BGFX_PCI_ID_NONE)
+		, deviceId(0)
+		, callback(NULL)
+		, allocator(NULL)
+	{
+		limits.maxEncoders = BGFX_CONFIG_DEFAULT_MAX_ENCODERS;
+	}
+
+	bool init(const Init& _init)
 	{
 	{
 		if (NULL != s_ctx)
 		if (NULL != s_ctx)
 		{
 		{
@@ -2760,9 +2799,9 @@ namespace bgfx
 
 
 		ErrorState::Enum errorState = ErrorState::Default;
 		ErrorState::Enum errorState = ErrorState::Default;
 
 
-		if (NULL != _allocator)
+		if (NULL != _init.allocator)
 		{
 		{
-			g_allocator = _allocator;
+			g_allocator = _init.allocator;
 		}
 		}
 		else
 		else
 		{
 		{
@@ -2771,9 +2810,9 @@ namespace bgfx
 				s_allocatorStub = BX_NEW(&allocator, AllocatorStub);
 				s_allocatorStub = BX_NEW(&allocator, AllocatorStub);
 		}
 		}
 
 
-		if (NULL != _callback)
+		if (NULL != _init.callback)
 		{
 		{
-			g_callback = _callback;
+			g_callback = _init.callback;
 		}
 		}
 		else
 		else
 		{
 		{
@@ -2783,7 +2822,7 @@ namespace bgfx
 
 
 		if (true
 		if (true
 		&&  !BX_ENABLED(BX_PLATFORM_EMSCRIPTEN || BX_PLATFORM_PS4)
 		&&  !BX_ENABLED(BX_PLATFORM_EMSCRIPTEN || BX_PLATFORM_PS4)
-		&&  RendererType::Noop != _type
+		&&  RendererType::Noop != _init.type
 		&&  NULL == g_platformData.ndt
 		&&  NULL == g_platformData.ndt
 		&&  NULL == g_platformData.nwh
 		&&  NULL == g_platformData.nwh
 		&&  NULL == g_platformData.context
 		&&  NULL == g_platformData.context
@@ -2815,17 +2854,17 @@ namespace bgfx
 		g_caps.limits.maxUniforms             = BGFX_CONFIG_MAX_UNIFORMS;
 		g_caps.limits.maxUniforms             = BGFX_CONFIG_MAX_UNIFORMS;
 		g_caps.limits.maxOcclusionQueries     = BGFX_CONFIG_MAX_OCCLUSION_QUERIES;
 		g_caps.limits.maxOcclusionQueries     = BGFX_CONFIG_MAX_OCCLUSION_QUERIES;
 		g_caps.limits.maxFBAttachments        = 1;
 		g_caps.limits.maxFBAttachments        = 1;
-		g_caps.limits.maxEncoders             = BGFX_CONFIG_MAX_ENCODERS;
+		g_caps.limits.maxEncoders             = (0 != BGFX_CONFIG_MULTITHREADED) ? _init.limits.maxEncoders : 1;
 
 
-		g_caps.vendorId = _vendorId;
-		g_caps.deviceId = _deviceId;
+		g_caps.vendorId = _init.vendorId;
+		g_caps.deviceId = _init.deviceId;
 
 
 		BX_TRACE("Init...");
 		BX_TRACE("Init...");
 
 
 		errorState = ErrorState::ContextAllocated;
 		errorState = ErrorState::ContextAllocated;
 
 
 		s_ctx = BX_ALIGNED_NEW(g_allocator, Context, 64);
 		s_ctx = BX_ALIGNED_NEW(g_allocator, Context, 64);
-		if (s_ctx->init(_type) )
+		if (s_ctx->init(_init) )
 		{
 		{
 			BX_TRACE("Init complete.");
 			BX_TRACE("Init complete.");
 			return true;
 			return true;
@@ -2864,6 +2903,19 @@ error:
 		return false;
 		return false;
 	}
 	}
 
 
+	bool init(RendererType::Enum _type, uint16_t _vendorId, uint16_t _deviceId, CallbackI* _callback, bx::AllocatorI* _allocator)
+	{
+		Init in;
+
+		in.type      = _type;
+		in.vendorId  = _vendorId;
+		in.deviceId  = _deviceId;
+		in.callback  = _callback;
+		in.allocator = _allocator;
+
+		return init(in);
+	}
+
 	void shutdown()
 	void shutdown()
 	{
 	{
 		BX_TRACE("Shutdown...");
 		BX_TRACE("Shutdown...");
@@ -3672,8 +3724,8 @@ error:
 
 
 		if (BackbufferRatio::Count != _ratio)
 		if (BackbufferRatio::Count != _ratio)
 		{
 		{
-			_width  = uint16_t(s_ctx->m_resolution.m_width);
-			_height = uint16_t(s_ctx->m_resolution.m_height);
+			_width  = uint16_t(s_ctx->m_init.resolution.width);
+			_height = uint16_t(s_ctx->m_init.resolution.height);
 			getTextureSizeFromRatio(_ratio, _width, _height);
 			getTextureSizeFromRatio(_ratio, _width, _height);
 		}
 		}
 
 
@@ -4027,8 +4079,8 @@ error:
 	{
 	{
 		BX_CHECK(checkView(_id), "Invalid view id: %d", _id);
 		BX_CHECK(checkView(_id), "Invalid view id: %d", _id);
 
 
-		uint16_t width  = uint16_t(s_ctx->m_resolution.m_width);
-		uint16_t height = uint16_t(s_ctx->m_resolution.m_height);
+		uint16_t width  = uint16_t(s_ctx->m_init.resolution.width);
+		uint16_t height = uint16_t(s_ctx->m_init.resolution.height);
 		getTextureSizeFromRatio(_ratio, width, height);
 		getTextureSizeFromRatio(_ratio, width, height);
 		setViewRect(_id, _x, _y, width, height);
 		setViewRect(_id, _x, _y, width, height);
 	}
 	}
@@ -4690,20 +4742,14 @@ BGFX_C_API const char* bgfx_get_renderer_name(bgfx_renderer_type_t _type)
 	return bgfx::getRendererName(bgfx::RendererType::Enum(_type) );
 	return bgfx::getRendererName(bgfx::RendererType::Enum(_type) );
 }
 }
 
 
-BGFX_C_API bool bgfx_init(bgfx_renderer_type_t _type, uint16_t _vendorId, uint16_t _deviceId, bgfx_callback_interface_t* _callback, bgfx_allocator_interface_t* _allocator)
+BGFX_C_API void bgfx_init_ctor(bgfx_init_t* _init)
 {
 {
-	static bgfx::CallbackC99 s_callback;
-	s_callback.m_interface = _callback;
-
-	static bgfx::AllocatorC99 s_allocator;
-	s_allocator.m_interface = _allocator;
+	BX_PLACEMENT_NEW(_init, bgfx::Init);
+}
 
 
-	return bgfx::init(bgfx::RendererType::Enum(_type)
-		, _vendorId
-		, _deviceId
-		, NULL == _callback  ? NULL : &s_callback
-		, NULL == _allocator ? NULL : &s_allocator
-		);
+BGFX_C_API bool bgfx_init(const bgfx_init_t* _init)
+{
+	return bgfx::init(*reinterpret_cast<const bgfx::Init*>(_init) );
 }
 }
 
 
 BGFX_C_API void bgfx_shutdown(void)
 BGFX_C_API void bgfx_shutdown(void)
@@ -5663,6 +5709,7 @@ BGFX_C_API bgfx_interface_vtbl_t* bgfx_get_interface(uint32_t _version)
 	BGFX_IMPORT_FUNC(topology_sort_tri_list)                               \
 	BGFX_IMPORT_FUNC(topology_sort_tri_list)                               \
 	BGFX_IMPORT_FUNC(get_supported_renderers)                              \
 	BGFX_IMPORT_FUNC(get_supported_renderers)                              \
 	BGFX_IMPORT_FUNC(get_renderer_name)                                    \
 	BGFX_IMPORT_FUNC(get_renderer_name)                                    \
+	BGFX_IMPORT_FUNC(init_ctor)                                            \
 	BGFX_IMPORT_FUNC(init)                                                 \
 	BGFX_IMPORT_FUNC(init)                                                 \
 	BGFX_IMPORT_FUNC(shutdown)                                             \
 	BGFX_IMPORT_FUNC(shutdown)                                             \
 	BGFX_IMPORT_FUNC(reset)                                                \
 	BGFX_IMPORT_FUNC(reset)                                                \

+ 30 - 41
src/bgfx_p.h

@@ -1629,25 +1629,6 @@ namespace bgfx
 		TextureHandle m_dst;
 		TextureHandle m_dst;
 	};
 	};
 
 
-	struct Resolution
-	{
-		Resolution()
-			: m_width(1280)
-			, m_height(720)
-			, m_flags(BGFX_RESET_NONE)
-		{
-		}
-
-		uint32_t m_width;
-		uint32_t m_height;
-		uint32_t m_flags;
-	};
-
-	struct Init
-	{
-		Resolution resolution;
-	};
-
 	struct IndexBuffer
 	struct IndexBuffer
 	{
 	{
 		uint32_t m_size;
 		uint32_t m_size;
@@ -1818,9 +1799,15 @@ namespace bgfx
 
 
 		void create()
 		void create()
 		{
 		{
-			for (uint32_t ii = 0; ii < BX_COUNTOF(m_uniformBuffer); ++ii)
 			{
 			{
-				m_uniformBuffer[ii] = UniformBuffer::create();
+				const uint32_t num = g_caps.limits.maxEncoders;
+
+				m_uniformBuffer = (UniformBuffer**)BX_ALLOC(g_allocator, sizeof(UniformBuffer*)*num);
+
+				for (uint32_t ii = 0; ii < num; ++ii)
+				{
+					m_uniformBuffer[ii] = UniformBuffer::create();
+				}
 			}
 			}
 
 
 			reset();
 			reset();
@@ -1830,10 +1817,12 @@ namespace bgfx
 
 
 		void destroy()
 		void destroy()
 		{
 		{
-			for (uint32_t ii = 0; ii < BX_COUNTOF(m_uniformBuffer); ++ii)
+			for (uint32_t ii = 0, num = g_caps.limits.maxEncoders; ii < num; ++ii)
 			{
 			{
 				UniformBuffer::destroy(m_uniformBuffer[ii]);
 				UniformBuffer::destroy(m_uniformBuffer[ii]);
 			}
 			}
+
+			BX_FREE(g_allocator, m_uniformBuffer);
 			BX_DELETE(g_allocator, m_textVideoMem);
 			BX_DELETE(g_allocator, m_textVideoMem);
 		}
 		}
 
 
@@ -1979,7 +1968,7 @@ namespace bgfx
 		BlitItem m_blitItem[BGFX_CONFIG_MAX_BLIT_ITEMS+1];
 		BlitItem m_blitItem[BGFX_CONFIG_MAX_BLIT_ITEMS+1];
 
 
 		FrameCache m_frameCache;
 		FrameCache m_frameCache;
-		UniformBuffer* m_uniformBuffer[BGFX_CONFIG_MAX_ENCODERS];
+		UniformBuffer** m_uniformBuffer;
 
 
 		uint32_t m_numRenderItems;
 		uint32_t m_numRenderItems;
 		uint16_t m_numBlitItems;
 		uint16_t m_numBlitItems;
@@ -2711,7 +2700,7 @@ namespace bgfx
 		}
 		}
 
 
 		// game thread
 		// game thread
-		bool init(RendererType::Enum _type);
+		bool init(const Init& _init);
 		void shutdown();
 		void shutdown();
 
 
 		CommandBuffer& getCommandBuffer(CommandBuffer::Enum _cmd)
 		CommandBuffer& getCommandBuffer(CommandBuffer::Enum _cmd)
@@ -2731,9 +2720,9 @@ namespace bgfx
 				, _width
 				, _width
 				, _height
 				, _height
 				);
 				);
-			m_resolution.m_width  = bx::clamp(_width,  1u, g_caps.limits.maxTextureSize);
-			m_resolution.m_height = bx::clamp(_height, 1u, g_caps.limits.maxTextureSize);
-			m_resolution.m_flags  = 0
+			m_init.resolution.width  = bx::clamp(_width,  1u, g_caps.limits.maxTextureSize);
+			m_init.resolution.height = bx::clamp(_height, 1u, g_caps.limits.maxTextureSize);
+			m_init.resolution.reset  = 0
 				| _flags
 				| _flags
 				| (g_platformDataChangedSinceReset ? BGFX_RESET_INTERNAL_FORCE : 0)
 				| (g_platformDataChangedSinceReset ? BGFX_RESET_INTERNAL_FORCE : 0)
 				;
 				;
@@ -2754,11 +2743,11 @@ namespace bgfx
 				{
 				{
 					TextureHandle handle = { textureIdx };
 					TextureHandle handle = { textureIdx };
 					resizeTexture(handle
 					resizeTexture(handle
-						, uint16_t(m_resolution.m_width)
-						, uint16_t(m_resolution.m_height)
+						, uint16_t(m_init.resolution.width)
+						, uint16_t(m_init.resolution.height)
 						, textureRef.m_numMips
 						, textureRef.m_numMips
 						);
 						);
-					m_resolution.m_flags |= BGFX_RESET_INTERNAL_FORCE;
+					m_init.resolution.reset |= BGFX_RESET_INTERNAL_FORCE;
 				}
 				}
 			}
 			}
 		}
 		}
@@ -2772,7 +2761,7 @@ namespace bgfx
 		{
 		{
 			BGFX_MUTEX_SCOPE(m_resourceApiLock);
 			BGFX_MUTEX_SCOPE(m_resourceApiLock);
 
 
-			m_submit->m_textVideoMem->resize(_small, (uint16_t)m_resolution.m_width, (uint16_t)m_resolution.m_height);
+			m_submit->m_textVideoMem->resize(_small, (uint16_t)m_init.resolution.width, (uint16_t)m_init.resolution.height);
 			m_submit->m_textVideoMem->clear(_attr);
 			m_submit->m_textVideoMem->clear(_attr);
 		}
 		}
 
 
@@ -2808,8 +2797,8 @@ namespace bgfx
 
 
 			Stats& stats = m_submit->m_perfStats;
 			Stats& stats = m_submit->m_perfStats;
 			const Resolution& resolution = m_submit->m_resolution;
 			const Resolution& resolution = m_submit->m_resolution;
-			stats.width  = uint16_t(resolution.m_width);
-			stats.height = uint16_t(resolution.m_height);
+			stats.width  = uint16_t(resolution.width);
+			stats.height = uint16_t(resolution.height);
 			const TextVideoMem* tvm = m_submit->m_textVideoMem;
 			const TextVideoMem* tvm = m_submit->m_textVideoMem;
 			stats.textWidth  = tvm->m_width;
 			stats.textWidth  = tvm->m_width;
 			stats.textHeight = tvm->m_height;
 			stats.textHeight = tvm->m_height;
@@ -4573,7 +4562,7 @@ namespace bgfx
 
 
 		void encoderApiWait()
 		void encoderApiWait()
 		{
 		{
-			uint16_t numEncoders = m_encoderHandle.getNumHandles();
+			uint16_t numEncoders = m_encoderHandle->getNumHandles();
 
 
 			for (uint16_t ii = 1; ii < numEncoders; ++ii)
 			for (uint16_t ii = 1; ii < numEncoders; ++ii)
 			{
 			{
@@ -4582,15 +4571,15 @@ namespace bgfx
 
 
 			for (uint16_t ii = 0; ii < numEncoders; ++ii)
 			for (uint16_t ii = 0; ii < numEncoders; ++ii)
 			{
 			{
-				uint16_t idx = m_encoderHandle.getHandleAt(ii);
+				uint16_t idx = m_encoderHandle->getHandleAt(ii);
 				m_encoderStats[ii].cpuTimeBegin = m_encoder[idx].m_cpuTimeBegin;
 				m_encoderStats[ii].cpuTimeBegin = m_encoder[idx].m_cpuTimeBegin;
 				m_encoderStats[ii].cpuTimeEnd   = m_encoder[idx].m_cpuTimeEnd;
 				m_encoderStats[ii].cpuTimeEnd   = m_encoder[idx].m_cpuTimeEnd;
 			}
 			}
 
 
 			m_submit->m_perfStats.numEncoders = uint8_t(numEncoders);
 			m_submit->m_perfStats.numEncoders = uint8_t(numEncoders);
 
 
-			m_encoderHandle.reset();
-			uint16_t idx = m_encoderHandle.alloc();
+			m_encoderHandle->reset();
+			uint16_t idx = m_encoderHandle->alloc();
 			BX_CHECK(0 == idx, "Internal encoder handle is not 0 (idx %d).", idx); BX_UNUSED(idx);
 			BX_CHECK(0 == idx, "Internal encoder handle is not 0 (idx %d).", idx); BX_UNUSED(idx);
 		}
 		}
 
 
@@ -4627,11 +4616,11 @@ namespace bgfx
 		}
 		}
 #endif // BGFX_CONFIG_MULTITHREADED
 #endif // BGFX_CONFIG_MULTITHREADED
 
 
-		EncoderStats  m_encoderStats[BGFX_CONFIG_MAX_ENCODERS];
+		EncoderStats* m_encoderStats;
 		Encoder*      m_encoder0;
 		Encoder*      m_encoder0;
-		EncoderImpl   m_encoder[BGFX_CONFIG_MAX_ENCODERS];
+		EncoderImpl*  m_encoder;
 		uint32_t      m_numEncoders;
 		uint32_t      m_numEncoders;
-		bx::HandleAllocT<BGFX_CONFIG_MAX_ENCODERS> m_encoderHandle;
+		bx::HandleAlloc* m_encoderHandle;
 
 
 		Frame  m_frame[1+(BGFX_CONFIG_MULTITHREADED ? 1 : 0)];
 		Frame  m_frame[1+(BGFX_CONFIG_MULTITHREADED ? 1 : 0)];
 		Frame* m_render;
 		Frame* m_render;
@@ -4762,7 +4751,7 @@ namespace bgfx
 
 
 		uint8_t m_colorPaletteDirty;
 		uint8_t m_colorPaletteDirty;
 
 
-		Resolution m_resolution;
+		Init     m_init;
 		int64_t  m_frameTimeLast;
 		int64_t  m_frameTimeLast;
 		uint32_t m_frames;
 		uint32_t m_frames;
 		uint32_t m_debug;
 		uint32_t m_debug;

+ 3 - 3
src/config.h

@@ -327,8 +327,8 @@ BX_STATIC_ASSERT(bx::isPowerOf2(BGFX_CONFIG_MAX_VIEWS), "BGFX_CONFIG_MAX_VIEWS m
 #	define BGFX_CONFIG_MIP_LOD_BIAS 0
 #	define BGFX_CONFIG_MIP_LOD_BIAS 0
 #endif // BGFX_CONFIG_MIP_LOD_BIAS
 #endif // BGFX_CONFIG_MIP_LOD_BIAS
 
 
-#ifndef BGFX_CONFIG_MAX_ENCODERS
-#	define BGFX_CONFIG_MAX_ENCODERS ( (0 != BGFX_CONFIG_MULTITHREADED) ? 8 : 1)
-#endif // BGFX_CONFIG_MAX_ENCODERS
+#ifndef BGFX_CONFIG_DEFAULT_MAX_ENCODERS
+#	define BGFX_CONFIG_DEFAULT_MAX_ENCODERS ( (0 != BGFX_CONFIG_MULTITHREADED) ? 8 : 1)
+#endif // BGFX_CONFIG_DEFAULT_MAX_ENCODERS
 
 
 #endif // BGFX_CONFIG_H_HEADER_GUARD
 #endif // BGFX_CONFIG_H_HEADER_GUARD

+ 38 - 30
src/renderer_d3d11.cpp

@@ -1002,8 +1002,8 @@ namespace bgfx { namespace d3d11
 #endif // !BX_PLATFORM_WINDOWS
 #endif // !BX_PLATFORM_WINDOWS
 
 
 					bx::memSet(&m_scd, 0, sizeof(m_scd) );
 					bx::memSet(&m_scd, 0, sizeof(m_scd) );
-					m_scd.width  = _init.resolution.m_width;
-					m_scd.height = _init.resolution.m_height;
+					m_scd.width  = _init.resolution.width;
+					m_scd.height = _init.resolution.height;
 					m_scd.format  = DXGI_FORMAT_R8G8B8A8_UNORM;
 					m_scd.format  = DXGI_FORMAT_R8G8B8A8_UNORM;
 					m_scd.sampleDesc.Count   = 1;
 					m_scd.sampleDesc.Count   = 1;
 					m_scd.sampleDesc.Quality = 0;
 					m_scd.sampleDesc.Quality = 0;
@@ -1038,6 +1038,14 @@ namespace bgfx { namespace d3d11
 							, &m_swapChain
 							, &m_swapChain
 							);
 							);
 					}
 					}
+					else
+					{
+						m_resolution       = _init.resolution;
+						m_resolution.reset = _init.resolution.reset & (~BGFX_RESET_INTERNAL_FORCE);
+
+						m_textVideoMem.resize(false, _init.resolution.width, _init.resolution.height);
+						m_textVideoMem.clear();
+					}
 
 
 #if BX_PLATFORM_WINDOWS
 #if BX_PLATFORM_WINDOWS
 					DX_CHECK(m_dxgi.m_factory->MakeWindowAssociation( (HWND)g_platformData.nwh, 0
 					DX_CHECK(m_dxgi.m_factory->MakeWindowAssociation( (HWND)g_platformData.nwh, 0
@@ -1057,8 +1065,8 @@ namespace bgfx { namespace d3d11
 					bx::memSet(&m_scd, 0, sizeof(m_scd) );
 					bx::memSet(&m_scd, 0, sizeof(m_scd) );
 					m_scd.sampleDesc.Count   = 1;
 					m_scd.sampleDesc.Count   = 1;
 					m_scd.sampleDesc.Quality = 0;
 					m_scd.sampleDesc.Quality = 0;
-					m_scd.width  = _init.resolution.m_width;
-					m_scd.height = _init.resolution.m_height;
+					m_scd.width  = _init.resolution.width;
+					m_scd.height = _init.resolution.height;
 					m_backBufferColor        = (ID3D11RenderTargetView*)g_platformData.backBuffer;
 					m_backBufferColor        = (ID3D11RenderTargetView*)g_platformData.backBuffer;
 					m_backBufferDepthStencil = (ID3D11DepthStencilView*)g_platformData.backBufferDS;
 					m_backBufferDepthStencil = (ID3D11DepthStencilView*)g_platformData.backBufferDS;
 				}
 				}
@@ -2093,12 +2101,12 @@ namespace bgfx { namespace d3d11
 				DX_CHECK(m_swapChain->GetBuffer(0, IID_ID3D11Texture2D, (void**)&color) );
 				DX_CHECK(m_swapChain->GetBuffer(0, IID_ID3D11Texture2D, (void**)&color) );
 
 
 				D3D11_RENDER_TARGET_VIEW_DESC desc;
 				D3D11_RENDER_TARGET_VIEW_DESC desc;
-				desc.ViewDimension = (m_resolution.m_flags & BGFX_RESET_MSAA_MASK)
+				desc.ViewDimension = (m_resolution.reset & BGFX_RESET_MSAA_MASK)
 					? D3D11_RTV_DIMENSION_TEXTURE2DMS
 					? D3D11_RTV_DIMENSION_TEXTURE2DMS
 					: D3D11_RTV_DIMENSION_TEXTURE2D
 					: D3D11_RTV_DIMENSION_TEXTURE2D
 					;
 					;
 				desc.Texture2D.MipSlice = 0;
 				desc.Texture2D.MipSlice = 0;
-				desc.Format = (m_resolution.m_flags & BGFX_RESET_SRGB_BACKBUFFER)
+				desc.Format = (m_resolution.reset & BGFX_RESET_SRGB_BACKBUFFER)
 					? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
 					? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
 					: DXGI_FORMAT_R8G8B8A8_UNORM
 					: DXGI_FORMAT_R8G8B8A8_UNORM
 					;
 					;
@@ -2169,7 +2177,7 @@ namespace bgfx { namespace d3d11
 				HRESULT hr = S_OK;
 				HRESULT hr = S_OK;
 				uint32_t syncInterval = BX_ENABLED(!BX_PLATFORM_WINDOWS)
 				uint32_t syncInterval = BX_ENABLED(!BX_PLATFORM_WINDOWS)
 					? 1 // sync interval of 0 is not supported on WinRT
 					? 1 // sync interval of 0 is not supported on WinRT
-					: !!(m_resolution.m_flags & BGFX_RESET_VSYNC)
+					: !!(m_resolution.reset & BGFX_RESET_VSYNC)
 					;
 					;
 
 
 				for (uint32_t ii = 1, num = m_numWindows; ii < num && SUCCEEDED(hr); ++ii)
 				for (uint32_t ii = 1, num = m_numWindows; ii < num && SUCCEEDED(hr); ++ii)
@@ -2256,8 +2264,8 @@ namespace bgfx { namespace d3d11
 
 
 		bool updateResolution(const Resolution& _resolution)
 		bool updateResolution(const Resolution& _resolution)
 		{
 		{
-			const bool suspended    = !!( _resolution.m_flags & BGFX_RESET_SUSPEND);
-			const bool wasSuspended = !!(m_resolution.m_flags & BGFX_RESET_SUSPEND);
+			const bool suspended    = !!( _resolution.reset & BGFX_RESET_SUSPEND);
+			const bool wasSuspended = !!(m_resolution.reset & BGFX_RESET_SUSPEND);
 			if (suspended && wasSuspended)
 			if (suspended && wasSuspended)
 			{
 			{
 				return true;
 				return true;
@@ -2268,19 +2276,19 @@ namespace bgfx { namespace d3d11
 				m_deviceCtx->ClearState();
 				m_deviceCtx->ClearState();
 				m_dxgi.trim();
 				m_dxgi.trim();
 				suspend(m_device);
 				suspend(m_device);
-				m_resolution.m_flags |= BGFX_RESET_SUSPEND;
+				m_resolution.reset |= BGFX_RESET_SUSPEND;
 				return true;
 				return true;
 			}
 			}
 			else if (wasSuspended)
 			else if (wasSuspended)
 			{
 			{
 				resume(m_device);
 				resume(m_device);
-				m_resolution.m_flags &= ~BGFX_RESET_SUSPEND;
+				m_resolution.reset &= ~BGFX_RESET_SUSPEND;
 			}
 			}
 
 
-			bool recenter = !!(_resolution.m_flags & BGFX_RESET_HMD_RECENTER);
+			bool recenter = !!(_resolution.reset & BGFX_RESET_HMD_RECENTER);
 
 
 			uint32_t maxAnisotropy = 1;
 			uint32_t maxAnisotropy = 1;
-			if (!!(_resolution.m_flags & BGFX_RESET_MAXANISOTROPY) )
+			if (!!(_resolution.reset & BGFX_RESET_MAXANISOTROPY) )
 			{
 			{
 				maxAnisotropy = (m_featureLevel == D3D_FEATURE_LEVEL_9_1)
 				maxAnisotropy = (m_featureLevel == D3D_FEATURE_LEVEL_9_1)
 								? D3D_FL9_1_DEFAULT_MAX_ANISOTROPY
 								? D3D_FL9_1_DEFAULT_MAX_ANISOTROPY
@@ -2295,7 +2303,7 @@ namespace bgfx { namespace d3d11
 			}
 			}
 
 
 			bool depthClamp = true
 			bool depthClamp = true
-				&& !!(_resolution.m_flags & BGFX_RESET_DEPTH_CLAMP)
+				&& !!(_resolution.reset & BGFX_RESET_DEPTH_CLAMP)
 				&& m_featureLevel > D3D_FEATURE_LEVEL_9_3 // disabling depth clamp is only supported on 10_0+
 				&& m_featureLevel > D3D_FEATURE_LEVEL_9_3 // disabling depth clamp is only supported on 10_0+
 				;
 				;
 
 
@@ -2312,25 +2320,25 @@ namespace bgfx { namespace d3d11
 				| BGFX_RESET_SUSPEND
 				| BGFX_RESET_SUSPEND
 				);
 				);
 
 
-			if (m_resolution.m_width            !=  _resolution.m_width
-			||  m_resolution.m_height           !=  _resolution.m_height
-			|| (m_resolution.m_flags&maskFlags) != (_resolution.m_flags&maskFlags) )
+			if (m_resolution.width            !=  _resolution.width
+			||  m_resolution.height           !=  _resolution.height
+			|| (m_resolution.reset&maskFlags) != (_resolution.reset&maskFlags) )
 			{
 			{
-				uint32_t flags = _resolution.m_flags & (~BGFX_RESET_INTERNAL_FORCE);
+				uint32_t flags = _resolution.reset & (~BGFX_RESET_INTERNAL_FORCE);
 
 
 				bool resize = true
 				bool resize = true
 					&& !BX_ENABLED(BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT) // can't use ResizeBuffers on Windows Phone
 					&& !BX_ENABLED(BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT) // can't use ResizeBuffers on Windows Phone
-					&& (m_resolution.m_flags&BGFX_RESET_MSAA_MASK) == (flags&BGFX_RESET_MSAA_MASK)
+					&& (m_resolution.reset&BGFX_RESET_MSAA_MASK) == (flags&BGFX_RESET_MSAA_MASK)
 					;
 					;
 
 
 				m_resolution = _resolution;
 				m_resolution = _resolution;
-				m_resolution.m_flags = flags;
+				m_resolution.reset = flags;
 
 
-				m_textVideoMem.resize(false, _resolution.m_width, _resolution.m_height);
+				m_textVideoMem.resize(false, _resolution.width, _resolution.height);
 				m_textVideoMem.clear();
 				m_textVideoMem.clear();
 
 
-				m_scd.width  = _resolution.m_width;
-				m_scd.height = _resolution.m_height;
+				m_scd.width  = _resolution.width;
+				m_scd.height = _resolution.height;
 
 
 				preReset();
 				preReset();
 
 
@@ -2359,7 +2367,7 @@ namespace bgfx { namespace d3d11
 					else
 					else
 					{
 					{
 						updateMsaa();
 						updateMsaa();
-						m_scd.sampleDesc = s_msaa[(m_resolution.m_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT];
+						m_scd.sampleDesc = s_msaa[(m_resolution.reset&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT];
 
 
 						DX_RELEASE(m_swapChain, 0);
 						DX_RELEASE(m_swapChain, 0);
 
 
@@ -2376,7 +2384,7 @@ namespace bgfx { namespace d3d11
 
 
 						SwapChainDesc* scd = &m_scd;
 						SwapChainDesc* scd = &m_scd;
 						SwapChainDesc swapChainScd;
 						SwapChainDesc swapChainScd;
-						if (0 != (m_resolution.m_flags & BGFX_RESET_HMD)
+						if (0 != (m_resolution.reset & BGFX_RESET_HMD)
 						&&  m_ovr.isInitialized() )
 						&&  m_ovr.isInitialized() )
 						{
 						{
 							swapChainScd = m_scd;
 							swapChainScd = m_scd;
@@ -3100,7 +3108,7 @@ namespace bgfx { namespace d3d11
 
 
 		void capturePostReset()
 		void capturePostReset()
 		{
 		{
-			if (m_resolution.m_flags&BGFX_RESET_CAPTURE)
+			if (m_resolution.reset&BGFX_RESET_CAPTURE)
 			{
 			{
 				ID3D11Texture2D* backBuffer;
 				ID3D11Texture2D* backBuffer;
 				DX_CHECK(m_swapChain->GetBuffer(0, IID_ID3D11Texture2D, (void**)&backBuffer) );
 				DX_CHECK(m_swapChain->GetBuffer(0, IID_ID3D11Texture2D, (void**)&backBuffer) );
@@ -6322,7 +6330,7 @@ namespace bgfx { namespace d3d11
 
 
 			if (0 < _render->m_numRenderItems)
 			if (0 < _render->m_numRenderItems)
 			{
 			{
-				if (0 != (m_resolution.m_flags & BGFX_RESET_FLUSH_AFTER_RENDER) )
+				if (0 != (m_resolution.reset & BGFX_RESET_FLUSH_AFTER_RENDER) )
 				{
 				{
 					deviceCtx->Flush();
 					deviceCtx->Flush();
 				}
 				}
@@ -6437,13 +6445,13 @@ namespace bgfx { namespace d3d11
 				char hmd[16];
 				char hmd[16];
 				bx::snprintf(hmd, BX_COUNTOF(hmd), ", [%c] HMD ", hmdEnabled ? '\xfe' : ' ');
 				bx::snprintf(hmd, BX_COUNTOF(hmd), ", [%c] HMD ", hmdEnabled ? '\xfe' : ' ');
 
 
-				const uint32_t msaa = (m_resolution.m_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT;
+				const uint32_t msaa = (m_resolution.reset&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT;
 				tvm.printf(10, pos++, 0x8b, "  Reset flags: [%c] vsync, [%c] MSAAx%d%s, [%c] MaxAnisotropy "
 				tvm.printf(10, pos++, 0x8b, "  Reset flags: [%c] vsync, [%c] MSAAx%d%s, [%c] MaxAnisotropy "
-					, !!(m_resolution.m_flags&BGFX_RESET_VSYNC) ? '\xfe' : ' '
+					, !!(m_resolution.reset&BGFX_RESET_VSYNC) ? '\xfe' : ' '
 					, 0 != msaa ? '\xfe' : ' '
 					, 0 != msaa ? '\xfe' : ' '
 					, 1<<msaa
 					, 1<<msaa
 					, m_ovr.isInitialized() ? hmd : ", no-HMD "
 					, m_ovr.isInitialized() ? hmd : ", no-HMD "
-					, !!(m_resolution.m_flags&BGFX_RESET_MAXANISOTROPY) ? '\xfe' : ' '
+					, !!(m_resolution.reset&BGFX_RESET_MAXANISOTROPY) ? '\xfe' : ' '
 					);
 					);
 
 
 				double elapsedCpuMs = double(frameTime)*toMs;
 				double elapsedCpuMs = double(frameTime)*toMs;

+ 31 - 23
src/renderer_d3d12.cpp

@@ -838,8 +838,8 @@ namespace bgfx { namespace d3d12
 			if (NULL == g_platformData.backBuffer)
 			if (NULL == g_platformData.backBuffer)
 			{
 			{
 				bx::memSet(&m_scd, 0, sizeof(m_scd) );
 				bx::memSet(&m_scd, 0, sizeof(m_scd) );
-				m_scd.width  = _init.resolution.m_width;
-				m_scd.height = _init.resolution.m_height;
+				m_scd.width  = _init.resolution.width;
+				m_scd.height = _init.resolution.height;
 				m_scd.format = DXGI_FORMAT_R8G8B8A8_UNORM;
 				m_scd.format = DXGI_FORMAT_R8G8B8A8_UNORM;
 				m_scd.stereo  = false;
 				m_scd.stereo  = false;
 				m_scd.sampleDesc.Count   = 1;
 				m_scd.sampleDesc.Count   = 1;
@@ -874,13 +874,21 @@ namespace bgfx { namespace d3d12
 					BX_TRACE("Init error: Unable to create Direct3D12 swap chain.");
 					BX_TRACE("Init error: Unable to create Direct3D12 swap chain.");
 					goto error;
 					goto error;
 				}
 				}
+				else
+				{
+					m_resolution       = _init.resolution;
+					m_resolution.reset = _init.resolution.reset & (~BGFX_RESET_INTERNAL_FORCE);
+
+					m_textVideoMem.resize(false, _init.resolution.width, _init.resolution.height);
+					m_textVideoMem.clear();
+				}
 			}
 			}
 
 
 			m_presentElapsed = 0;
 			m_presentElapsed = 0;
 
 
 			{
 			{
-				m_resolution.m_width  = _init.resolution.m_width;
-				m_resolution.m_height = _init.resolution.m_height;
+				m_resolution.width  = _init.resolution.width;
+				m_resolution.height = _init.resolution.height;
 
 
 				m_numWindows = 1;
 				m_numWindows = 1;
 
 
@@ -1350,7 +1358,7 @@ namespace bgfx { namespace d3d12
 				m_cmd.finish(m_backBufferColorFence[(m_backBufferColorIdx-1) % m_scd.bufferCount]);
 				m_cmd.finish(m_backBufferColorFence[(m_backBufferColorIdx-1) % m_scd.bufferCount]);
 
 
 				HRESULT hr = S_OK;
 				HRESULT hr = S_OK;
-				uint32_t syncInterval = !!(m_resolution.m_flags & BGFX_RESET_VSYNC);
+				uint32_t syncInterval = !!(m_resolution.reset & BGFX_RESET_VSYNC);
 				uint32_t flags = 0 == syncInterval ? DXGI_PRESENT_RESTART : 0;
 				uint32_t flags = 0 == syncInterval ? DXGI_PRESENT_RESTART : 0;
 				for (uint32_t ii = 1, num = m_numWindows; ii < num && SUCCEEDED(hr); ++ii)
 				for (uint32_t ii = 1, num = m_numWindows; ii < num && SUCCEEDED(hr); ++ii)
 				{
 				{
@@ -1895,8 +1903,8 @@ namespace bgfx { namespace d3d12
 			D3D12_RESOURCE_DESC resourceDesc;
 			D3D12_RESOURCE_DESC resourceDesc;
 			resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
 			resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
 			resourceDesc.Alignment = 0;
 			resourceDesc.Alignment = 0;
-			resourceDesc.Width     = bx::uint32_max(m_resolution.m_width,  1);
-			resourceDesc.Height    = bx::uint32_max(m_resolution.m_height, 1);
+			resourceDesc.Width     = bx::uint32_max(m_resolution.width,  1);
+			resourceDesc.Height    = bx::uint32_max(m_resolution.height, 1);
 			resourceDesc.DepthOrArraySize   = 1;
 			resourceDesc.DepthOrArraySize   = 1;
 			resourceDesc.MipLevels          = 1;
 			resourceDesc.MipLevels          = 1;
 			resourceDesc.Format             = DXGI_FORMAT_D24_UNORM_S8_UINT;
 			resourceDesc.Format             = DXGI_FORMAT_D24_UNORM_S8_UINT;
@@ -1975,7 +1983,7 @@ data.NumQualityLevels = 0;
 
 
 		bool updateResolution(const Resolution& _resolution)
 		bool updateResolution(const Resolution& _resolution)
 		{
 		{
-			if (!!(_resolution.m_flags & BGFX_RESET_MAXANISOTROPY) )
+			if (!!(_resolution.reset & BGFX_RESET_MAXANISOTROPY) )
 			{
 			{
 				m_maxAnisotropy = D3D12_REQ_MAXANISOTROPY;
 				m_maxAnisotropy = D3D12_REQ_MAXANISOTROPY;
 			}
 			}
@@ -1984,7 +1992,7 @@ data.NumQualityLevels = 0;
 				m_maxAnisotropy = 1;
 				m_maxAnisotropy = 1;
 			}
 			}
 
 
-			bool depthClamp = !!(_resolution.m_flags & BGFX_RESET_DEPTH_CLAMP);
+			bool depthClamp = !!(_resolution.reset & BGFX_RESET_DEPTH_CLAMP);
 
 
 			if (m_depthClamp != depthClamp)
 			if (m_depthClamp != depthClamp)
 			{
 			{
@@ -1999,25 +2007,25 @@ data.NumQualityLevels = 0;
 				| BGFX_RESET_SUSPEND
 				| BGFX_RESET_SUSPEND
 				);
 				);
 
 
-			if (m_resolution.m_width            !=  _resolution.m_width
-			||  m_resolution.m_height           !=  _resolution.m_height
-			|| (m_resolution.m_flags&maskFlags) != (_resolution.m_flags&maskFlags) )
+			if (m_resolution.width            !=  _resolution.width
+			||  m_resolution.height           !=  _resolution.height
+			|| (m_resolution.reset&maskFlags) != (_resolution.reset&maskFlags) )
 			{
 			{
-				uint32_t flags = _resolution.m_flags & (~BGFX_RESET_INTERNAL_FORCE);
+				uint32_t flags = _resolution.reset & (~BGFX_RESET_INTERNAL_FORCE);
 
 
 				bool resize = true
 				bool resize = true
 					&& BX_ENABLED(BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT)
 					&& BX_ENABLED(BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT)
-					&& (m_resolution.m_flags&BGFX_RESET_MSAA_MASK) == (_resolution.m_flags&BGFX_RESET_MSAA_MASK)
+					&& (m_resolution.reset&BGFX_RESET_MSAA_MASK) == (_resolution.reset&BGFX_RESET_MSAA_MASK)
 					;
 					;
 
 
 				m_resolution = _resolution;
 				m_resolution = _resolution;
-				m_resolution.m_flags = flags;
+				m_resolution.reset = flags;
 
 
-				m_textVideoMem.resize(false, _resolution.m_width, _resolution.m_height);
+				m_textVideoMem.resize(false, _resolution.width, _resolution.height);
 				m_textVideoMem.clear();
 				m_textVideoMem.clear();
 
 
-				m_scd.width  = _resolution.m_width;
-				m_scd.height = _resolution.m_height;
+				m_scd.width  = _resolution.width;
+				m_scd.height = _resolution.height;
 
 
 				preReset();
 				preReset();
 
 
@@ -2053,7 +2061,7 @@ data.NumQualityLevels = 0;
 				else
 				else
 				{
 				{
 					updateMsaa();
 					updateMsaa();
-					m_scd.sampleDesc = s_msaa[(m_resolution.m_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT];
+					m_scd.sampleDesc = s_msaa[(m_resolution.reset&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT];
 
 
 					DX_RELEASE(m_swapChain, 0);
 					DX_RELEASE(m_swapChain, 0);
 
 
@@ -6164,7 +6172,7 @@ data.NumQualityLevels = 0;
 
 
 			if (0 < _render->m_numRenderItems)
 			if (0 < _render->m_numRenderItems)
 			{
 			{
-				if (0 != (m_resolution.m_flags & BGFX_RESET_FLUSH_AFTER_RENDER) )
+				if (0 != (m_resolution.reset & BGFX_RESET_FLUSH_AFTER_RENDER) )
 				{
 				{
 //					deviceCtx->Flush();
 //					deviceCtx->Flush();
 				}
 				}
@@ -6327,13 +6335,13 @@ data.NumQualityLevels = 0;
 				char hmd[16];
 				char hmd[16];
 				bx::snprintf(hmd, BX_COUNTOF(hmd), ", [%c] HMD ", hmdEnabled ? '\xfe' : ' ');
 				bx::snprintf(hmd, BX_COUNTOF(hmd), ", [%c] HMD ", hmdEnabled ? '\xfe' : ' ');
 
 
-				const uint32_t msaa = (m_resolution.m_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT;
+				const uint32_t msaa = (m_resolution.reset&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT;
 				tvm.printf(10, pos++, 0x8b, " Reset flags: [%c] vsync, [%c] MSAAx%d%s, [%c] MaxAnisotropy "
 				tvm.printf(10, pos++, 0x8b, " Reset flags: [%c] vsync, [%c] MSAAx%d%s, [%c] MaxAnisotropy "
-					, !!(m_resolution.m_flags&BGFX_RESET_VSYNC) ? '\xfe' : ' '
+					, !!(m_resolution.reset&BGFX_RESET_VSYNC) ? '\xfe' : ' '
 					, 0 != msaa ? '\xfe' : ' '
 					, 0 != msaa ? '\xfe' : ' '
 					, 1<<msaa
 					, 1<<msaa
 					, ", no-HMD "
 					, ", no-HMD "
-					, !!(m_resolution.m_flags&BGFX_RESET_MAXANISOTROPY) ? '\xfe' : ' '
+					, !!(m_resolution.reset&BGFX_RESET_MAXANISOTROPY) ? '\xfe' : ' '
 					);
 					);
 
 
 				double elapsedCpuMs = double(frameTime)*toMs;
 				double elapsedCpuMs = double(frameTime)*toMs;

+ 20 - 20
src/renderer_d3d9.cpp

@@ -422,8 +422,8 @@ namespace bgfx { namespace d3d9
 
 
 			// http://msdn.microsoft.com/en-us/library/windows/desktop/bb172588%28v=vs.85%29.aspx
 			// http://msdn.microsoft.com/en-us/library/windows/desktop/bb172588%28v=vs.85%29.aspx
 			bx::memSet(&m_params, 0, sizeof(m_params) );
 			bx::memSet(&m_params, 0, sizeof(m_params) );
-			m_params.BackBufferWidth  = _init.resolution.m_width;
-			m_params.BackBufferHeight = _init.resolution.m_height;
+			m_params.BackBufferWidth  = _init.resolution.width;
+			m_params.BackBufferHeight = _init.resolution.height;
 			m_params.BackBufferFormat = adapterFormat;
 			m_params.BackBufferFormat = adapterFormat;
 			m_params.BackBufferCount = 1;
 			m_params.BackBufferCount = 1;
 			m_params.MultiSampleType = D3DMULTISAMPLE_NONE;
 			m_params.MultiSampleType = D3DMULTISAMPLE_NONE;
@@ -1398,7 +1398,7 @@ namespace bgfx { namespace d3d9
 
 
 		void updateResolution(const Resolution& _resolution)
 		void updateResolution(const Resolution& _resolution)
 		{
 		{
-			m_maxAnisotropy = !!(_resolution.m_flags & BGFX_RESET_MAXANISOTROPY)
+			m_maxAnisotropy = !!(_resolution.reset & BGFX_RESET_MAXANISOTROPY)
 				? m_caps.MaxAnisotropy
 				? m_caps.MaxAnisotropy
 				: 1
 				: 1
 				;
 				;
@@ -1409,16 +1409,16 @@ namespace bgfx { namespace d3d9
 				| BGFX_RESET_SUSPEND
 				| BGFX_RESET_SUSPEND
 				);
 				);
 
 
-			if (m_resolution.m_width            !=  _resolution.m_width
-			||  m_resolution.m_height           !=  _resolution.m_height
-			|| (m_resolution.m_flags&maskFlags) != (_resolution.m_flags&maskFlags) )
+			if (m_resolution.width            !=  _resolution.width
+			||  m_resolution.height           !=  _resolution.height
+			|| (m_resolution.reset&maskFlags) != (_resolution.reset&maskFlags) )
 			{
 			{
-				uint32_t flags = _resolution.m_flags & (~BGFX_RESET_INTERNAL_FORCE);
+				uint32_t flags = _resolution.reset & (~BGFX_RESET_INTERNAL_FORCE);
 
 
 				m_resolution = _resolution;
 				m_resolution = _resolution;
-				m_resolution.m_flags = flags;
+				m_resolution.reset = flags;
 
 
-				m_textVideoMem.resize(false, _resolution.m_width, _resolution.m_height);
+				m_textVideoMem.resize(false, _resolution.width, _resolution.height);
 				m_textVideoMem.clear();
 				m_textVideoMem.clear();
 
 
 				D3DDEVICE_CREATION_PARAMETERS dcp;
 				D3DDEVICE_CREATION_PARAMETERS dcp;
@@ -1429,14 +1429,14 @@ namespace bgfx { namespace d3d9
 
 
 				m_params.BackBufferFormat = dm.Format;
 				m_params.BackBufferFormat = dm.Format;
 
 
-				m_params.BackBufferWidth  = _resolution.m_width;
-				m_params.BackBufferHeight = _resolution.m_height;
-				m_params.FullScreen_RefreshRateInHz = BGFX_RESET_FULLSCREEN == (m_resolution.m_flags&BGFX_RESET_FULLSCREEN_MASK) ? 60 : 0;
-				m_params.PresentationInterval = !!(m_resolution.m_flags&BGFX_RESET_VSYNC) ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
+				m_params.BackBufferWidth  = _resolution.width;
+				m_params.BackBufferHeight = _resolution.height;
+				m_params.FullScreen_RefreshRateInHz = BGFX_RESET_FULLSCREEN == (m_resolution.reset&BGFX_RESET_FULLSCREEN_MASK) ? 60 : 0;
+				m_params.PresentationInterval = !!(m_resolution.reset&BGFX_RESET_VSYNC) ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
 
 
 				updateMsaa();
 				updateMsaa();
 
 
-				Msaa& msaa = s_msaa[(m_resolution.m_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT];
+				Msaa& msaa = s_msaa[(m_resolution.reset&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT];
 				m_params.MultiSampleType    = msaa.m_type;
 				m_params.MultiSampleType    = msaa.m_type;
 				m_params.MultiSampleQuality = msaa.m_quality;
 				m_params.MultiSampleQuality = msaa.m_quality;
 
 
@@ -1465,7 +1465,7 @@ namespace bgfx { namespace d3d9
 				}
 				}
 				DX_CHECK(m_device->SetDepthStencilSurface(m_backBufferDepthStencil) );
 				DX_CHECK(m_device->SetDepthStencilSurface(m_backBufferDepthStencil) );
 
 
-				DX_CHECK(m_device->SetRenderState(D3DRS_SRGBWRITEENABLE, 0 != (m_resolution.m_flags & BGFX_RESET_SRGB_BACKBUFFER) ) );
+				DX_CHECK(m_device->SetRenderState(D3DRS_SRGBWRITEENABLE, 0 != (m_resolution.reset & BGFX_RESET_SRGB_BACKBUFFER) ) );
 			}
 			}
 			else
 			else
 			{
 			{
@@ -1752,7 +1752,7 @@ namespace bgfx { namespace d3d9
 
 
 		void capturePostReset()
 		void capturePostReset()
 		{
 		{
-			if (m_resolution.m_flags&BGFX_RESET_CAPTURE)
+			if (m_resolution.reset&BGFX_RESET_CAPTURE)
 			{
 			{
 				uint32_t width  = m_params.BackBufferWidth;
 				uint32_t width  = m_params.BackBufferWidth;
 				uint32_t height = m_params.BackBufferHeight;
 				uint32_t height = m_params.BackBufferHeight;
@@ -4338,7 +4338,7 @@ namespace bgfx { namespace d3d9
 
 
 			if (0 < _render->m_numRenderItems)
 			if (0 < _render->m_numRenderItems)
 			{
 			{
-				if (0 != (m_resolution.m_flags & BGFX_RESET_FLUSH_AFTER_RENDER) )
+				if (0 != (m_resolution.reset & BGFX_RESET_FLUSH_AFTER_RENDER) )
 				{
 				{
 					flush();
 					flush();
 				}
 				}
@@ -4430,12 +4430,12 @@ namespace bgfx { namespace d3d9
 					, freq/frameTime
 					, freq/frameTime
 					);
 					);
 
 
-				const uint32_t msaa = (m_resolution.m_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT;
+				const uint32_t msaa = (m_resolution.reset&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT;
 				tvm.printf(10, pos++, 0x8b, "  Reset flags: [%c] vsync, [%c] MSAAx%d, [%c] MaxAnisotropy "
 				tvm.printf(10, pos++, 0x8b, "  Reset flags: [%c] vsync, [%c] MSAAx%d, [%c] MaxAnisotropy "
-					, !!(m_resolution.m_flags&BGFX_RESET_VSYNC) ? '\xfe' : ' '
+					, !!(m_resolution.reset&BGFX_RESET_VSYNC) ? '\xfe' : ' '
 					, 0 != msaa ? '\xfe' : ' '
 					, 0 != msaa ? '\xfe' : ' '
 					, 1<<msaa
 					, 1<<msaa
-					, !!(m_resolution.m_flags&BGFX_RESET_MAXANISOTROPY) ? '\xfe' : ' '
+					, !!(m_resolution.reset&BGFX_RESET_MAXANISOTROPY) ? '\xfe' : ' '
 					);
 					);
 
 
 				double elapsedCpuMs = double(frameTime)*toMs;
 				double elapsedCpuMs = double(frameTime)*toMs;

+ 34 - 34
src/renderer_gl.cpp

@@ -1771,7 +1771,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 			bx::memSet(m_uniforms, 0, sizeof(m_uniforms) );
 			bx::memSet(m_uniforms, 0, sizeof(m_uniforms) );
 			bx::memSet(&m_resolution, 0, sizeof(m_resolution) );
 			bx::memSet(&m_resolution, 0, sizeof(m_resolution) );
 
 
-			setRenderContextSize(_init.resolution.m_width, _init.resolution.m_height);
+			setRenderContextSize(_init.resolution.width, _init.resolution.height);
 
 
 			// Must be after context is initialized?!
 			// Must be after context is initialized?!
 			VRImplI* vrImpl = NULL;
 			VRImplI* vrImpl = NULL;
@@ -2924,8 +2924,8 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 		void requestScreenShot(FrameBufferHandle _handle, const char* _filePath) override
 		void requestScreenShot(FrameBufferHandle _handle, const char* _filePath) override
 		{
 		{
 			SwapChainGL* swapChain = NULL;
 			SwapChainGL* swapChain = NULL;
-			uint32_t width  = m_resolution.m_width;
-			uint32_t height = m_resolution.m_height;
+			uint32_t width  = m_resolution.width;
+			uint32_t height = m_resolution.height;
 
 
 			if (isValid(_handle) )
 			if (isValid(_handle) )
 			{
 			{
@@ -3016,8 +3016,8 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 				GL_CHECK(glBindVertexArray(m_vao) );
 				GL_CHECK(glBindVertexArray(m_vao) );
 			}
 			}
 
 
-			uint32_t width  = m_resolution.m_width;
-			uint32_t height = m_resolution.m_height;
+			uint32_t width  = m_resolution.width;
+			uint32_t height = m_resolution.height;
 
 
 			GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_backBufferFbo) );
 			GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_backBufferFbo) );
 			GL_CHECK(glViewport(0, 0, width, height) );
 			GL_CHECK(glViewport(0, 0, width, height) );
@@ -3088,15 +3088,15 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 
 
 		void updateResolution(const Resolution& _resolution)
 		void updateResolution(const Resolution& _resolution)
 		{
 		{
-			bool recenter   = !!(_resolution.m_flags & BGFX_RESET_HMD_RECENTER);
-			m_maxAnisotropy = !!(_resolution.m_flags & BGFX_RESET_MAXANISOTROPY)
+			bool recenter   = !!(_resolution.reset & BGFX_RESET_HMD_RECENTER);
+			m_maxAnisotropy = !!(_resolution.reset & BGFX_RESET_MAXANISOTROPY)
 				? m_maxAnisotropyDefault
 				? m_maxAnisotropyDefault
 				: 0.0f
 				: 0.0f
 				;
 				;
 
 
 			if (s_extension[Extension::ARB_depth_clamp].m_supported)
 			if (s_extension[Extension::ARB_depth_clamp].m_supported)
 			{
 			{
-				if (!!(_resolution.m_flags & BGFX_RESET_DEPTH_CLAMP) )
+				if (!!(_resolution.reset & BGFX_RESET_DEPTH_CLAMP) )
 				{
 				{
 					GL_CHECK(glEnable(GL_DEPTH_CLAMP) );
 					GL_CHECK(glEnable(GL_DEPTH_CLAMP) );
 				}
 				}
@@ -3113,16 +3113,16 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 				| BGFX_RESET_SUSPEND
 				| BGFX_RESET_SUSPEND
 				);
 				);
 
 
-			if (m_resolution.m_width            !=  _resolution.m_width
-			||  m_resolution.m_height           !=  _resolution.m_height
-			|| (m_resolution.m_flags&maskFlags) != (_resolution.m_flags&maskFlags) )
+			if (m_resolution.width            !=  _resolution.width
+			||  m_resolution.height           !=  _resolution.height
+			|| (m_resolution.reset&maskFlags) != (_resolution.reset&maskFlags) )
 			{
 			{
-				uint32_t flags = _resolution.m_flags & (~BGFX_RESET_INTERNAL_FORCE);
+				uint32_t flags = _resolution.reset & (~BGFX_RESET_INTERNAL_FORCE);
 
 
 				m_resolution = _resolution;
 				m_resolution = _resolution;
-				m_resolution.m_flags = flags;
+				m_resolution.reset = flags;
 
 
-				m_textVideoMem.resize(false, _resolution.m_width, _resolution.m_height);
+				m_textVideoMem.resize(false, _resolution.width, _resolution.height);
 				m_textVideoMem.clear();
 				m_textVideoMem.clear();
 
 
 				if ( (flags & BGFX_RESET_HMD)
 				if ( (flags & BGFX_RESET_HMD)
@@ -3131,8 +3131,8 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 					flags &= ~BGFX_RESET_MSAA_MASK;
 					flags &= ~BGFX_RESET_MSAA_MASK;
 				}
 				}
 
 
-				setRenderContextSize(m_resolution.m_width
-						, m_resolution.m_height
+				setRenderContextSize(m_resolution.width
+						, m_resolution.height
 						, flags
 						, flags
 						);
 						);
 				updateCapture();
 				updateCapture();
@@ -3212,7 +3212,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 
 
 				if (m_srgbWriteControlSupport)
 				if (m_srgbWriteControlSupport)
 				{
 				{
-					if (0 != (m_resolution.m_flags & BGFX_RESET_SRGB_BACKBUFFER) )
+					if (0 != (m_resolution.reset & BGFX_RESET_SRGB_BACKBUFFER) )
 					{
 					{
 						GL_CHECK(glEnable(GL_FRAMEBUFFER_SRGB) );
 						GL_CHECK(glEnable(GL_FRAMEBUFFER_SRGB) );
 					}
 					}
@@ -3314,8 +3314,8 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 				GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_backBufferFbo) );
 				GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_backBufferFbo) );
 				GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, m_msaaBackBufferFbo) );
 				GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, m_msaaBackBufferFbo) );
 				GL_CHECK(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0) );
 				GL_CHECK(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0) );
-				uint32_t width  = m_resolution.m_width;
-				uint32_t height = m_resolution.m_height;
+				uint32_t width  = m_resolution.width;
+				uint32_t height = m_resolution.height;
 				GLenum filter = BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) || BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES < 30)
 				GLenum filter = BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) || BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES < 30)
 					? GL_NEAREST
 					? GL_NEAREST
 					: GL_LINEAR
 					: GL_LINEAR
@@ -3509,11 +3509,11 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 
 
 		void updateCapture()
 		void updateCapture()
 		{
 		{
-			if (m_resolution.m_flags&BGFX_RESET_CAPTURE)
+			if (m_resolution.reset&BGFX_RESET_CAPTURE)
 			{
 			{
-				m_captureSize = m_resolution.m_width*m_resolution.m_height*4;
+				m_captureSize = m_resolution.width*m_resolution.height*4;
 				m_capture = BX_REALLOC(g_allocator, m_capture, m_captureSize);
 				m_capture = BX_REALLOC(g_allocator, m_capture, m_captureSize);
-				g_callback->captureBegin(m_resolution.m_width, m_resolution.m_height, m_resolution.m_width*4, TextureFormat::BGRA8, true);
+				g_callback->captureBegin(m_resolution.width, m_resolution.height, m_resolution.width*4, TextureFormat::BGRA8, true);
 			}
 			}
 			else
 			else
 			{
 			{
@@ -3527,8 +3527,8 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 			{
 			{
 				GL_CHECK(glReadPixels(0
 				GL_CHECK(glReadPixels(0
 					, 0
 					, 0
-					, m_resolution.m_width
-					, m_resolution.m_height
+					, m_resolution.width
+					, m_resolution.height
 					, m_readPixelsFmt
 					, m_readPixelsFmt
 					, GL_UNSIGNED_BYTE
 					, GL_UNSIGNED_BYTE
 					, m_capture
 					, m_capture
@@ -3538,11 +3538,11 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 				{
 				{
 					bimg::imageSwizzleBgra8(
 					bimg::imageSwizzleBgra8(
 						  m_capture
 						  m_capture
-						, m_resolution.m_width*4
-						, m_resolution.m_width
-						, m_resolution.m_height
+						, m_resolution.width*4
+						, m_resolution.width
+						, m_resolution.height
 						, m_capture
 						, m_capture
-						, m_resolution.m_width*4
+						, m_resolution.width*4
 						);
 						);
 				}
 				}
 
 
@@ -6607,7 +6607,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 
 
 		int32_t resolutionHeight = hmdEnabled
 		int32_t resolutionHeight = hmdEnabled
 					? _render->m_hmd.height
 					? _render->m_hmd.height
-					: _render->m_resolution.m_height
+					: _render->m_resolution.height
 					;
 					;
 		uint32_t blendFactor = 0;
 		uint32_t blendFactor = 0;
 
 
@@ -6700,7 +6700,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 						fbh = _render->m_view[view].m_fbh;
 						fbh = _render->m_view[view].m_fbh;
 						resolutionHeight = hmdEnabled
 						resolutionHeight = hmdEnabled
 							? _render->m_hmd.height
 							? _render->m_hmd.height
-							: _render->m_resolution.m_height
+							: _render->m_resolution.height
 							;
 							;
 						resolutionHeight = setFrameBuffer(fbh, resolutionHeight, discardFlags);
 						resolutionHeight = setFrameBuffer(fbh, resolutionHeight, discardFlags);
 					}
 					}
@@ -7635,7 +7635,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 
 
 			if (0 < _render->m_numRenderItems)
 			if (0 < _render->m_numRenderItems)
 			{
 			{
-				if (0 != (m_resolution.m_flags & BGFX_RESET_FLUSH_AFTER_RENDER) )
+				if (0 != (m_resolution.reset & BGFX_RESET_FLUSH_AFTER_RENDER) )
 				{
 				{
 					GL_CHECK(glFlush() );
 					GL_CHECK(glFlush() );
 				}
 				}
@@ -7728,13 +7728,13 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 				char hmd[16];
 				char hmd[16];
 				bx::snprintf(hmd, BX_COUNTOF(hmd), ", [%c] HMD ", hmdEnabled ? '\xfe' : ' ');
 				bx::snprintf(hmd, BX_COUNTOF(hmd), ", [%c] HMD ", hmdEnabled ? '\xfe' : ' ');
 
 
-				const uint32_t msaa = (m_resolution.m_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT;
+				const uint32_t msaa = (m_resolution.reset&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT;
 				tvm.printf(10, pos++, 0x8b, "  Reset flags: [%c] vsync, [%c] MSAAx%d%s, [%c] MaxAnisotropy "
 				tvm.printf(10, pos++, 0x8b, "  Reset flags: [%c] vsync, [%c] MSAAx%d%s, [%c] MaxAnisotropy "
-					, !!(m_resolution.m_flags&BGFX_RESET_VSYNC) ? '\xfe' : ' '
+					, !!(m_resolution.reset&BGFX_RESET_VSYNC) ? '\xfe' : ' '
 					, 0 != msaa ? '\xfe' : ' '
 					, 0 != msaa ? '\xfe' : ' '
 					, 1<<msaa
 					, 1<<msaa
 					, m_ovr.isInitialized() ? hmd : ", no-HMD "
 					, m_ovr.isInitialized() ? hmd : ", no-HMD "
-					, !!(m_resolution.m_flags&BGFX_RESET_MAXANISOTROPY) ? '\xfe' : ' '
+					, !!(m_resolution.reset&BGFX_RESET_MAXANISOTROPY) ? '\xfe' : ' '
 					);
 					);
 
 
 				double elapsedCpuMs = double(frameTime)*toMs;
 				double elapsedCpuMs = double(frameTime)*toMs;

+ 34 - 34
src/renderer_mtl.mm

@@ -1014,8 +1014,8 @@ namespace bgfx { namespace mtl
 		{
 		{
 			RenderCommandEncoder rce = m_renderCommandEncoder;
 			RenderCommandEncoder rce = m_renderCommandEncoder;
 
 
-			uint32_t width  = m_resolution.m_width;
-			uint32_t height  = m_resolution.m_height;
+			uint32_t width  = m_resolution.width;
+			uint32_t height = m_resolution.height;
 
 
 			//if (m_ovr.isEnabled() )
 			//if (m_ovr.isEnabled() )
 			//{
 			//{
@@ -1128,7 +1128,7 @@ namespace bgfx { namespace mtl
 
 
 		void updateResolution(const Resolution& _resolution)
 		void updateResolution(const Resolution& _resolution)
 		{
 		{
-			m_maxAnisotropy = !!(_resolution.m_flags & BGFX_RESET_MAXANISOTROPY)
+			m_maxAnisotropy = !!(_resolution.reset & BGFX_RESET_MAXANISOTROPY)
 				? 16
 				? 16
 				: 1
 				: 1
 				;
 				;
@@ -1140,26 +1140,26 @@ namespace bgfx { namespace mtl
 				| BGFX_RESET_SUSPEND
 				| BGFX_RESET_SUSPEND
 				);
 				);
 
 
-			if (m_resolution.m_width            !=  _resolution.m_width
-			||  m_resolution.m_height           !=  _resolution.m_height
-			|| (m_resolution.m_flags&maskFlags) != (_resolution.m_flags&maskFlags) )
+			if (m_resolution.width            !=  _resolution.width
+			||  m_resolution.height           !=  _resolution.height
+			|| (m_resolution.reset&maskFlags) != (_resolution.reset&maskFlags) )
 			{
 			{
-				int sampleCount = s_msaa[(_resolution.m_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT];
+				int sampleCount = s_msaa[(_resolution.reset&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT];
 
 
 				MTLPixelFormat prevMetalLayerPixelFormat = m_metalLayer.pixelFormat;
 				MTLPixelFormat prevMetalLayerPixelFormat = m_metalLayer.pixelFormat;
 
 
 #if BX_PLATFORM_OSX > 101300
 #if BX_PLATFORM_OSX > 101300
-				m_metalLayer.displaySyncEnabled = 0 != (_resolution.m_flags&BGFX_RESET_VSYNC);
+				m_metalLayer.displaySyncEnabled = 0 != (_resolution.reset&BGFX_RESET_VSYNC);
 #endif // BX_PLATFORM_OSX > 101300
 #endif // BX_PLATFORM_OSX > 101300
 
 
-				m_metalLayer.drawableSize = CGSizeMake(_resolution.m_width, _resolution.m_height);
-				m_metalLayer.pixelFormat = (m_resolution.m_flags & BGFX_RESET_SRGB_BACKBUFFER)
+				m_metalLayer.drawableSize = CGSizeMake(_resolution.width, _resolution.height);
+				m_metalLayer.pixelFormat = (m_resolution.reset & BGFX_RESET_SRGB_BACKBUFFER)
 					? MTLPixelFormatBGRA8Unorm_sRGB
 					? MTLPixelFormatBGRA8Unorm_sRGB
 					: MTLPixelFormatBGRA8Unorm
 					: MTLPixelFormatBGRA8Unorm
 					;
 					;
 
 
 				m_resolution = _resolution;
 				m_resolution = _resolution;
-				m_resolution.m_flags &= ~BGFX_RESET_INTERNAL_FORCE;
+				m_resolution.reset &= ~BGFX_RESET_INTERNAL_FORCE;
 
 
 				m_textureDescriptor.textureType = sampleCount > 1 ? MTLTextureType2DMultisample : MTLTextureType2D;
 				m_textureDescriptor.textureType = sampleCount > 1 ? MTLTextureType2DMultisample : MTLTextureType2D;
 
 
@@ -1172,8 +1172,8 @@ namespace bgfx { namespace mtl
 					m_textureDescriptor.pixelFormat = MTLPixelFormatDepth32Float;
 					m_textureDescriptor.pixelFormat = MTLPixelFormatDepth32Float;
 				}
 				}
 
 
-				m_textureDescriptor.width  = _resolution.m_width;
-				m_textureDescriptor.height = _resolution.m_height;
+				m_textureDescriptor.width  = _resolution.width;
+				m_textureDescriptor.height = _resolution.height;
 				m_textureDescriptor.depth  = 1;
 				m_textureDescriptor.depth  = 1;
 				m_textureDescriptor.mipmapLevelCount = 1;
 				m_textureDescriptor.mipmapLevelCount = 1;
 				m_textureDescriptor.sampleCount = sampleCount;
 				m_textureDescriptor.sampleCount = sampleCount;
@@ -1236,7 +1236,7 @@ namespace bgfx { namespace mtl
 
 
 				updateCapture();
 				updateCapture();
 
 
-				m_textVideoMem.resize(false, _resolution.m_width, _resolution.m_height);
+				m_textVideoMem.resize(false, _resolution.width, _resolution.height);
 				m_textVideoMem.clear();
 				m_textVideoMem.clear();
 
 
 				if (prevMetalLayerPixelFormat != m_metalLayer.pixelFormat)
 				if (prevMetalLayerPixelFormat != m_metalLayer.pixelFormat)
@@ -1254,11 +1254,11 @@ namespace bgfx { namespace mtl
 
 
 		void updateCapture()
 		void updateCapture()
 		{
 		{
-			if (m_resolution.m_flags&BGFX_RESET_CAPTURE)
+			if (m_resolution.reset&BGFX_RESET_CAPTURE)
 			{
 			{
-				m_captureSize = m_resolution.m_width*m_resolution.m_height*4;
+				m_captureSize = m_resolution.width*m_resolution.height*4;
 				m_capture = BX_REALLOC(g_allocator, m_capture, m_captureSize);
 				m_capture = BX_REALLOC(g_allocator, m_capture, m_captureSize);
-				g_callback->captureBegin(m_resolution.m_width, m_resolution.m_height, m_resolution.m_width*4, TextureFormat::BGRA8, false);
+				g_callback->captureBegin(m_resolution.width, m_resolution.height, m_resolution.width*4, TextureFormat::BGRA8, false);
 			}
 			}
 			else
 			else
 			{
 			{
@@ -1280,9 +1280,9 @@ namespace bgfx { namespace mtl
 				m_cmd.kick(false, true);
 				m_cmd.kick(false, true);
 				m_commandBuffer = 0;
 				m_commandBuffer = 0;
 
 
-				MTLRegion region = { { 0, 0, 0 }, { m_resolution.m_width, m_resolution.m_height, 1 } };
+				MTLRegion region = { { 0, 0, 0 }, { m_resolution.width, m_resolution.height, 1 } };
 
 
-				m_screenshotTarget.getBytes(m_capture, 4*m_resolution.m_width, 0, region, 0, 0);
+				m_screenshotTarget.getBytes(m_capture, 4*m_resolution.width, 0, region, 0, 0);
 
 
 				m_commandBuffer = m_cmd.alloc();
 				m_commandBuffer = m_cmd.alloc();
 
 
@@ -1290,11 +1290,11 @@ namespace bgfx { namespace mtl
 				{
 				{
 					bimg::imageSwizzleBgra8(
 					bimg::imageSwizzleBgra8(
 						  m_capture
 						  m_capture
-						, m_resolution.m_width*4
-						, m_resolution.m_width
-						, m_resolution.m_height
+						, m_resolution.width*4
+						, m_resolution.width
+						, m_resolution.height
 						, m_capture
 						, m_capture
-						, m_resolution.m_width*4
+						, m_resolution.width*4
 						);
 						);
 				}
 				}
 
 
@@ -1458,8 +1458,8 @@ namespace bgfx { namespace mtl
 			}
 			}
 			else
 			else
 			{
 			{
-				width  = m_resolution.m_width;
-				height = m_resolution.m_height;
+				width  = m_resolution.width;
+				height = m_resolution.height;
 			}
 			}
 
 
 
 
@@ -3183,8 +3183,8 @@ namespace bgfx { namespace mtl
 		{
 		{
 			if (m_screenshotTarget)
 			if (m_screenshotTarget)
 			{
 			{
-				if (m_screenshotTarget.width()  != m_resolution.m_width
-				||  m_screenshotTarget.height() != m_resolution.m_height)
+				if (m_screenshotTarget.width()  != m_resolution.width
+				||  m_screenshotTarget.height() != m_resolution.height)
 				{
 				{
 					MTL_RELEASE(m_screenshotTarget);
 					MTL_RELEASE(m_screenshotTarget);
 				}
 				}
@@ -3194,8 +3194,8 @@ namespace bgfx { namespace mtl
 			{
 			{
 				m_textureDescriptor.textureType = MTLTextureType2D;
 				m_textureDescriptor.textureType = MTLTextureType2D;
 				m_textureDescriptor.pixelFormat = m_metalLayer.pixelFormat;
 				m_textureDescriptor.pixelFormat = m_metalLayer.pixelFormat;
-				m_textureDescriptor.width  = m_resolution.m_width;
-				m_textureDescriptor.height = m_resolution.m_height;
+				m_textureDescriptor.width  = m_resolution.width;
+				m_textureDescriptor.height = m_resolution.height;
 				m_textureDescriptor.depth  = 1;
 				m_textureDescriptor.depth  = 1;
 				m_textureDescriptor.mipmapLevelCount = 1;
 				m_textureDescriptor.mipmapLevelCount = 1;
 				m_textureDescriptor.sampleCount = 1;
 				m_textureDescriptor.sampleCount = 1;
@@ -3378,8 +3378,8 @@ namespace bgfx { namespace mtl
 
 
 						fbh = _render->m_view[view].m_fbh;
 						fbh = _render->m_view[view].m_fbh;
 
 
-						uint32_t width  = m_resolution.m_width;
-						uint32_t height = m_resolution.m_height;
+						uint32_t width  = m_resolution.width;
+						uint32_t height = m_resolution.height;
 
 
 						if (isValid(fbh) )
 						if (isValid(fbh) )
 						{
 						{
@@ -4011,12 +4011,12 @@ namespace bgfx { namespace mtl
 					, freq/frameTime
 					, freq/frameTime
 					);
 					);
 
 
-				const uint32_t msaa = (m_resolution.m_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT;
+				const uint32_t msaa = (m_resolution.reset&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT;
 				tvm.printf(10, pos++, 0x8b, "  Reset flags: [%c] vsync, [%c] MSAAx%d, [%c] MaxAnisotropy "
 				tvm.printf(10, pos++, 0x8b, "  Reset flags: [%c] vsync, [%c] MSAAx%d, [%c] MaxAnisotropy "
-					, !!(m_resolution.m_flags&BGFX_RESET_VSYNC) ? '\xfe' : ' '
+					, !!(m_resolution.reset&BGFX_RESET_VSYNC) ? '\xfe' : ' '
 					, 0 != msaa ? '\xfe' : ' '
 					, 0 != msaa ? '\xfe' : ' '
 					, 1<<msaa
 					, 1<<msaa
-					, !!(m_resolution.m_flags&BGFX_RESET_MAXANISOTROPY) ? '\xfe' : ' '
+					, !!(m_resolution.reset&BGFX_RESET_MAXANISOTROPY) ? '\xfe' : ' '
 					);
 					);
 
 
 				double elapsedCpuMs = double(frameTime)*toMs;
 				double elapsedCpuMs = double(frameTime)*toMs;

+ 14 - 14
src/renderer_vk.cpp

@@ -1379,8 +1379,8 @@ VK_IMPORT_DEVICE
 				m_sci.minImageCount   = BX_COUNTOF(m_backBufferColorImage);
 				m_sci.minImageCount   = BX_COUNTOF(m_backBufferColorImage);
 				m_sci.imageFormat     = surfaceFormats[surfaceFormatIdx].format;
 				m_sci.imageFormat     = surfaceFormats[surfaceFormatIdx].format;
 				m_sci.imageColorSpace = surfaceFormats[surfaceFormatIdx].colorSpace;
 				m_sci.imageColorSpace = surfaceFormats[surfaceFormatIdx].colorSpace;
-				m_sci.imageExtent.width  = _init.resolution.m_width;
-				m_sci.imageExtent.height = _init.resolution.m_height;
+				m_sci.imageExtent.width  = _init.resolution.width;
+				m_sci.imageExtent.height = _init.resolution.height;
 				m_sci.imageArrayLayers = 1;
 				m_sci.imageArrayLayers = 1;
 				m_sci.imageUsage       = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
 				m_sci.imageUsage       = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
 				m_sci.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
 				m_sci.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
@@ -2168,7 +2168,7 @@ VK_IMPORT_DEVICE
 
 
 		void updateResolution(const Resolution& _resolution)
 		void updateResolution(const Resolution& _resolution)
 		{
 		{
-			if (!!(_resolution.m_flags & BGFX_RESET_MAXANISOTROPY) )
+			if (!!(_resolution.reset & BGFX_RESET_MAXANISOTROPY) )
 			{
 			{
 				m_maxAnisotropy = UINT32_MAX;
 				m_maxAnisotropy = UINT32_MAX;
 			}
 			}
@@ -2177,7 +2177,7 @@ VK_IMPORT_DEVICE
 				m_maxAnisotropy = 1;
 				m_maxAnisotropy = 1;
 			}
 			}
 
 
-			bool depthClamp = !!(_resolution.m_flags & BGFX_RESET_DEPTH_CLAMP);
+			bool depthClamp = !!(_resolution.reset & BGFX_RESET_DEPTH_CLAMP);
 
 
 			if (m_depthClamp != depthClamp)
 			if (m_depthClamp != depthClamp)
 			{
 			{
@@ -2185,20 +2185,20 @@ VK_IMPORT_DEVICE
 				m_pipelineStateCache.invalidate();
 				m_pipelineStateCache.invalidate();
 			}
 			}
 
 
-			uint32_t flags = _resolution.m_flags & ~(BGFX_RESET_HMD_RECENTER | BGFX_RESET_MAXANISOTROPY | BGFX_RESET_DEPTH_CLAMP);
+			uint32_t flags = _resolution.reset & ~(BGFX_RESET_HMD_RECENTER | BGFX_RESET_MAXANISOTROPY | BGFX_RESET_DEPTH_CLAMP);
 
 
-			if (m_resolution.m_width  != _resolution.m_width
-			||  m_resolution.m_height != _resolution.m_height
-			||  m_resolution.m_flags  != flags)
+			if (m_resolution.width  != _resolution.width
+			||  m_resolution.height != _resolution.height
+			||  m_resolution.reset  != flags)
 			{
 			{
 				flags &= ~BGFX_RESET_INTERNAL_FORCE;
 				flags &= ~BGFX_RESET_INTERNAL_FORCE;
 
 
-				bool resize = (m_resolution.m_flags&BGFX_RESET_MSAA_MASK) == (_resolution.m_flags&BGFX_RESET_MSAA_MASK);
+				bool resize = (m_resolution.reset&BGFX_RESET_MSAA_MASK) == (_resolution.reset&BGFX_RESET_MSAA_MASK);
 
 
 				m_resolution = _resolution;
 				m_resolution = _resolution;
-				m_resolution.m_flags = flags;
+				m_resolution.reset = flags;
 
 
-				m_textVideoMem.resize(false, _resolution.m_width, _resolution.m_height);
+				m_textVideoMem.resize(false, _resolution.width, _resolution.height);
 				m_textVideoMem.clear();
 				m_textVideoMem.clear();
 
 
 #if 1
 #if 1
@@ -4487,13 +4487,13 @@ BX_UNUSED(presentMin, presentMax);
 				char hmd[16];
 				char hmd[16];
 				bx::snprintf(hmd, BX_COUNTOF(hmd), ", [%c] HMD ", hmdEnabled ? '\xfe' : ' ');
 				bx::snprintf(hmd, BX_COUNTOF(hmd), ", [%c] HMD ", hmdEnabled ? '\xfe' : ' ');
 
 
-				const uint32_t msaa = (m_resolution.m_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT;
+				const uint32_t msaa = (m_resolution.reset&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT;
 				tvm.printf(10, pos++, 0x8b, " Reset flags: [%c] vsync, [%c] MSAAx%d%s, [%c] MaxAnisotropy "
 				tvm.printf(10, pos++, 0x8b, " Reset flags: [%c] vsync, [%c] MSAAx%d%s, [%c] MaxAnisotropy "
-					, !!(m_resolution.m_flags&BGFX_RESET_VSYNC) ? '\xfe' : ' '
+					, !!(m_resolution.reset&BGFX_RESET_VSYNC) ? '\xfe' : ' '
 					, 0 != msaa ? '\xfe' : ' '
 					, 0 != msaa ? '\xfe' : ' '
 					, 1<<msaa
 					, 1<<msaa
 					, ", no-HMD "
 					, ", no-HMD "
-					, !!(m_resolution.m_flags&BGFX_RESET_MAXANISOTROPY) ? '\xfe' : ' '
+					, !!(m_resolution.reset&BGFX_RESET_MAXANISOTROPY) ? '\xfe' : ' '
 					);
 					);
 
 
 				double elapsedCpuMs = double(frameTime)*toMs;
 				double elapsedCpuMs = double(frameTime)*toMs;