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

This commit is contained in:
Branimir Karadžić 2018-04-17 15:42:18 -07:00
Родитель 84d694a032
Коммит 5bb6a14876
51 изменённых файлов: 657 добавлений и 361 удалений

Просмотреть файл

@ -29,8 +29,13 @@ public:
m_debug = BGFX_DEBUG_TEXT;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -98,8 +98,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -493,8 +493,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -116,8 +116,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -27,8 +27,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -76,8 +76,13 @@ public:
m_debug = BGFX_DEBUG_TEXT;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -99,8 +99,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -323,14 +323,15 @@ public:
| 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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -136,8 +136,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -154,8 +154,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -68,8 +68,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -51,8 +51,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -43,8 +43,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -805,8 +805,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -1885,8 +1885,13 @@ public:
m_debug = BGFX_DEBUG_TEXT;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -75,8 +75,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -1301,8 +1301,13 @@ public:
m_viewState = ViewState(uint16_t(m_width), uint16_t(m_height));
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -126,8 +126,13 @@ public:
m_deltaTimeAvgNs = 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();
m_maxDim = (int32_t)bx::pow(float(caps->limits.maxDrawCalls), 1.0f/3.0f);

Просмотреть файл

@ -501,8 +501,13 @@ public:
| 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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -166,8 +166,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -1250,8 +1250,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -207,8 +207,13 @@ public:
m_debug = BGFX_DEBUG_TEXT;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -83,8 +83,13 @@ public:
m_debug = BGFX_DEBUG_TEXT;
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();
bool swapChainSupported = 0 != (caps->supported & BGFX_CAPS_SWAP_CHAIN);

Просмотреть файл

@ -50,8 +50,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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();
float texelHalf = bgfx::RendererType::Direct3D9 == renderer ? 0.5f : 0.0f;

Просмотреть файл

@ -127,8 +127,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -22,12 +22,10 @@ int32_t _main_(int32_t _argc, char** _argv)
(void)_argc;
(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);
// Enable debug text.

Просмотреть файл

@ -79,8 +79,13 @@ public:
m_debug = BGFX_DEBUG_TEXT;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -76,8 +76,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -303,8 +303,13 @@ public:
| 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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -494,8 +494,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -35,9 +35,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -208,9 +208,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -246,8 +246,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -125,8 +125,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -121,8 +121,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -99,8 +99,13 @@ public:
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -423,8 +423,13 @@ namespace
m_debug = BGFX_DEBUG_NONE;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -413,8 +413,13 @@ public:
m_debug = BGFX_DEBUG_TEXT;
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.
bgfx::setDebug(m_debug);

Просмотреть файл

@ -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.
///
/// param[in] _ptr Pointer to allocated data.
@ -1748,39 +1806,13 @@ namespace bgfx
/// 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.
///
/// @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.
///

Просмотреть файл

@ -590,6 +590,37 @@ typedef struct bgfx_allocator_vtbl
} 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);
@ -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 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);

Просмотреть файл

@ -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);
uint8_t (*get_supported_renderers)(uint8_t _max, bgfx_renderer_type_t* _enum);
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 (*reset)(uint32_t _width, uint32_t _height, uint32_t _flags);
uint32_t (*frame)(bool _capture);

Просмотреть файл

@ -6,7 +6,7 @@
#ifndef 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.
#define BGFX_STATE_WRITE_R UINT64_C(0x0000000000000001) //!< Enable R write.

Просмотреть файл

@ -1382,10 +1382,13 @@ namespace bgfx
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?");
m_init = _init;
m_init.resolution.reset &= ~BGFX_RESET_INTERNAL_FORCE;
m_exit = false;
m_flipped = true;
m_frames = 0;
@ -1442,11 +1445,19 @@ namespace bgfx
m_declRef.init();
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::RendererInit);
cmdbuf.write(_type);
cmdbuf.write(_init);
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);
m_encoder[0].begin(m_submit, 0);
m_encoder0 = reinterpret_cast<Encoder*>(&m_encoder[0]);
@ -1537,6 +1548,16 @@ namespace bgfx
frame();
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_dynIndexBufferAllocator.compact();
@ -1697,7 +1718,7 @@ namespace bgfx
{
bx::MutexScope scopeLock(m_encoderApiLock);
uint16_t idx = m_encoderHandle.alloc();
uint16_t idx = m_encoderHandle->alloc();
if (kInvalidHandle == idx)
{
return NULL;
@ -1761,8 +1782,8 @@ namespace bgfx
void Context::swap()
{
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_perfStats.numViews = 0;
@ -1795,9 +1816,10 @@ namespace bgfx
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();
@ -1806,7 +1828,7 @@ namespace bgfx
}
///
RendererContextI* rendererCreate(RendererType::Enum _type, const Init& _init);
RendererContextI* rendererCreate(const Init& _init);
///
void rendererDestroy(RendererContextI* _renderCtx);
@ -1825,7 +1847,8 @@ namespace bgfx
rendererDestroy(m_renderCtx);
Init init;
m_renderCtx = rendererCreate(RendererType::Noop, init);
init.type = RendererType::Noop;
m_renderCtx = rendererCreate(init);
g_caps.rendererType = RendererType::Noop;
}
}
@ -2060,7 +2083,7 @@ namespace bgfx
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];
uint32_t numScores = 0;
@ -2071,7 +2094,7 @@ namespace bgfx
if (s_rendererCreator[ii].supported)
{
int32_t score = 0;
if (_type == renderer)
if (_init.type == renderer)
{
score += 1000;
}
@ -2184,11 +2207,10 @@ namespace bgfx
);
BX_CHECK(!m_rendererInitialized, "This shouldn't happen! Bad synchronization?");
RendererType::Enum type;
_cmdbuf.read(type);
Init init;
m_renderCtx = rendererCreate(type, init);
_cmdbuf.read(init);
m_renderCtx = rendererCreate(init);
m_rendererInitialized = NULL != m_renderCtx;
@ -2741,7 +2763,24 @@ namespace bgfx
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)
{
@ -2760,9 +2799,9 @@ namespace bgfx
ErrorState::Enum errorState = ErrorState::Default;
if (NULL != _allocator)
if (NULL != _init.allocator)
{
g_allocator = _allocator;
g_allocator = _init.allocator;
}
else
{
@ -2771,9 +2810,9 @@ namespace bgfx
s_allocatorStub = BX_NEW(&allocator, AllocatorStub);
}
if (NULL != _callback)
if (NULL != _init.callback)
{
g_callback = _callback;
g_callback = _init.callback;
}
else
{
@ -2783,7 +2822,7 @@ namespace bgfx
if (true
&& !BX_ENABLED(BX_PLATFORM_EMSCRIPTEN || BX_PLATFORM_PS4)
&& RendererType::Noop != _type
&& RendererType::Noop != _init.type
&& NULL == g_platformData.ndt
&& NULL == g_platformData.nwh
&& NULL == g_platformData.context
@ -2815,17 +2854,17 @@ namespace bgfx
g_caps.limits.maxUniforms = BGFX_CONFIG_MAX_UNIFORMS;
g_caps.limits.maxOcclusionQueries = BGFX_CONFIG_MAX_OCCLUSION_QUERIES;
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...");
errorState = ErrorState::ContextAllocated;
s_ctx = BX_ALIGNED_NEW(g_allocator, Context, 64);
if (s_ctx->init(_type) )
if (s_ctx->init(_init) )
{
BX_TRACE("Init complete.");
return true;
@ -2864,6 +2903,19 @@ error:
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()
{
BX_TRACE("Shutdown...");
@ -3672,8 +3724,8 @@ error:
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);
}
@ -4027,8 +4079,8 @@ error:
{
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);
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) );
}
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;
BX_PLACEMENT_NEW(_init, bgfx::Init);
}
static bgfx::AllocatorC99 s_allocator;
s_allocator.m_interface = _allocator;
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)
@ -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(get_supported_renderers) \
BGFX_IMPORT_FUNC(get_renderer_name) \
BGFX_IMPORT_FUNC(init_ctor) \
BGFX_IMPORT_FUNC(init) \
BGFX_IMPORT_FUNC(shutdown) \
BGFX_IMPORT_FUNC(reset) \

Просмотреть файл

@ -1629,25 +1629,6 @@ namespace bgfx
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
{
uint32_t m_size;
@ -1818,9 +1799,15 @@ namespace bgfx
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();
@ -1830,10 +1817,12 @@ namespace bgfx
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]);
}
BX_FREE(g_allocator, m_uniformBuffer);
BX_DELETE(g_allocator, m_textVideoMem);
}
@ -1979,7 +1968,7 @@ namespace bgfx
BlitItem m_blitItem[BGFX_CONFIG_MAX_BLIT_ITEMS+1];
FrameCache m_frameCache;
UniformBuffer* m_uniformBuffer[BGFX_CONFIG_MAX_ENCODERS];
UniformBuffer** m_uniformBuffer;
uint32_t m_numRenderItems;
uint16_t m_numBlitItems;
@ -2711,7 +2700,7 @@ namespace bgfx
}
// game thread
bool init(RendererType::Enum _type);
bool init(const Init& _init);
void shutdown();
CommandBuffer& getCommandBuffer(CommandBuffer::Enum _cmd)
@ -2731,9 +2720,9 @@ namespace bgfx
, _width
, _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
| (g_platformDataChangedSinceReset ? BGFX_RESET_INTERNAL_FORCE : 0)
;
@ -2754,11 +2743,11 @@ namespace bgfx
{
TextureHandle handle = { textureIdx };
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
);
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);
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);
}
@ -2808,8 +2797,8 @@ namespace bgfx
Stats& stats = m_submit->m_perfStats;
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;
stats.textWidth = tvm->m_width;
stats.textHeight = tvm->m_height;
@ -4573,7 +4562,7 @@ namespace bgfx
void encoderApiWait()
{
uint16_t numEncoders = m_encoderHandle.getNumHandles();
uint16_t numEncoders = m_encoderHandle->getNumHandles();
for (uint16_t ii = 1; ii < numEncoders; ++ii)
{
@ -4582,15 +4571,15 @@ namespace bgfx
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].cpuTimeEnd = m_encoder[idx].m_cpuTimeEnd;
}
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);
}
@ -4627,11 +4616,11 @@ namespace bgfx
}
#endif // BGFX_CONFIG_MULTITHREADED
EncoderStats m_encoderStats[BGFX_CONFIG_MAX_ENCODERS];
EncoderStats* m_encoderStats;
Encoder* m_encoder0;
EncoderImpl m_encoder[BGFX_CONFIG_MAX_ENCODERS];
EncoderImpl* m_encoder;
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_render;
@ -4762,7 +4751,7 @@ namespace bgfx
uint8_t m_colorPaletteDirty;
Resolution m_resolution;
Init m_init;
int64_t m_frameTimeLast;
uint32_t m_frames;
uint32_t m_debug;

Просмотреть файл

@ -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
#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

Просмотреть файл

@ -1002,8 +1002,8 @@ namespace bgfx { namespace d3d11
#endif // !BX_PLATFORM_WINDOWS
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.sampleDesc.Count = 1;
m_scd.sampleDesc.Quality = 0;
@ -1038,6 +1038,14 @@ namespace bgfx { namespace d3d11
, &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
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) );
m_scd.sampleDesc.Count = 1;
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_backBufferDepthStencil = (ID3D11DepthStencilView*)g_platformData.backBufferDS;
}
@ -2093,12 +2101,12 @@ namespace bgfx { namespace d3d11
DX_CHECK(m_swapChain->GetBuffer(0, IID_ID3D11Texture2D, (void**)&color) );
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_TEXTURE2D
;
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
;
@ -2169,7 +2177,7 @@ namespace bgfx { namespace d3d11
HRESULT hr = S_OK;
uint32_t syncInterval = BX_ENABLED(!BX_PLATFORM_WINDOWS)
? 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)
@ -2256,8 +2264,8 @@ namespace bgfx { namespace d3d11
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)
{
return true;
@ -2268,19 +2276,19 @@ namespace bgfx { namespace d3d11
m_deviceCtx->ClearState();
m_dxgi.trim();
suspend(m_device);
m_resolution.m_flags |= BGFX_RESET_SUSPEND;
m_resolution.reset |= BGFX_RESET_SUSPEND;
return true;
}
else if (wasSuspended)
{
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;
if (!!(_resolution.m_flags & BGFX_RESET_MAXANISOTROPY) )
if (!!(_resolution.reset & BGFX_RESET_MAXANISOTROPY) )
{
maxAnisotropy = (m_featureLevel == D3D_FEATURE_LEVEL_9_1)
? D3D_FL9_1_DEFAULT_MAX_ANISOTROPY
@ -2295,7 +2303,7 @@ namespace bgfx { namespace d3d11
}
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+
;
@ -2312,25 +2320,25 @@ namespace bgfx { namespace d3d11
| 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
&& !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.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_scd.width = _resolution.m_width;
m_scd.height = _resolution.m_height;
m_scd.width = _resolution.width;
m_scd.height = _resolution.height;
preReset();
@ -2359,7 +2367,7 @@ namespace bgfx { namespace d3d11
else
{
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);
@ -2376,7 +2384,7 @@ namespace bgfx { namespace d3d11
SwapChainDesc* scd = &m_scd;
SwapChainDesc swapChainScd;
if (0 != (m_resolution.m_flags & BGFX_RESET_HMD)
if (0 != (m_resolution.reset & BGFX_RESET_HMD)
&& m_ovr.isInitialized() )
{
swapChainScd = m_scd;
@ -3100,7 +3108,7 @@ namespace bgfx { namespace d3d11
void capturePostReset()
{
if (m_resolution.m_flags&BGFX_RESET_CAPTURE)
if (m_resolution.reset&BGFX_RESET_CAPTURE)
{
ID3D11Texture2D* 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 != (m_resolution.m_flags & BGFX_RESET_FLUSH_AFTER_RENDER) )
if (0 != (m_resolution.reset & BGFX_RESET_FLUSH_AFTER_RENDER) )
{
deviceCtx->Flush();
}
@ -6437,13 +6445,13 @@ namespace bgfx { namespace d3d11
char hmd[16];
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 "
, !!(m_resolution.m_flags&BGFX_RESET_VSYNC) ? '\xfe' : ' '
, !!(m_resolution.reset&BGFX_RESET_VSYNC) ? '\xfe' : ' '
, 0 != msaa ? '\xfe' : ' '
, 1<<msaa
, 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;

Просмотреть файл

@ -838,8 +838,8 @@ namespace bgfx { namespace d3d12
if (NULL == g_platformData.backBuffer)
{
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.stereo = false;
m_scd.sampleDesc.Count = 1;
@ -874,13 +874,21 @@ namespace bgfx { namespace d3d12
BX_TRACE("Init error: Unable to create Direct3D12 swap chain.");
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_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;
@ -1350,7 +1358,7 @@ namespace bgfx { namespace d3d12
m_cmd.finish(m_backBufferColorFence[(m_backBufferColorIdx-1) % m_scd.bufferCount]);
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;
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;
resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
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.MipLevels = 1;
resourceDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
@ -1975,7 +1983,7 @@ data.NumQualityLevels = 0;
bool updateResolution(const Resolution& _resolution)
{
if (!!(_resolution.m_flags & BGFX_RESET_MAXANISOTROPY) )
if (!!(_resolution.reset & BGFX_RESET_MAXANISOTROPY) )
{
m_maxAnisotropy = D3D12_REQ_MAXANISOTROPY;
}
@ -1984,7 +1992,7 @@ data.NumQualityLevels = 0;
m_maxAnisotropy = 1;
}
bool depthClamp = !!(_resolution.m_flags & BGFX_RESET_DEPTH_CLAMP);
bool depthClamp = !!(_resolution.reset & BGFX_RESET_DEPTH_CLAMP);
if (m_depthClamp != depthClamp)
{
@ -1999,25 +2007,25 @@ data.NumQualityLevels = 0;
| 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
&& 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.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_scd.width = _resolution.m_width;
m_scd.height = _resolution.m_height;
m_scd.width = _resolution.width;
m_scd.height = _resolution.height;
preReset();
@ -2053,7 +2061,7 @@ data.NumQualityLevels = 0;
else
{
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);
@ -6164,7 +6172,7 @@ data.NumQualityLevels = 0;
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();
}
@ -6327,13 +6335,13 @@ data.NumQualityLevels = 0;
char hmd[16];
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 "
, !!(m_resolution.m_flags&BGFX_RESET_VSYNC) ? '\xfe' : ' '
, !!(m_resolution.reset&BGFX_RESET_VSYNC) ? '\xfe' : ' '
, 0 != msaa ? '\xfe' : ' '
, 1<<msaa
, ", no-HMD "
, !!(m_resolution.m_flags&BGFX_RESET_MAXANISOTROPY) ? '\xfe' : ' '
, !!(m_resolution.reset&BGFX_RESET_MAXANISOTROPY) ? '\xfe' : ' '
);
double elapsedCpuMs = double(frameTime)*toMs;

Просмотреть файл

@ -422,8 +422,8 @@ namespace bgfx { namespace d3d9
// http://msdn.microsoft.com/en-us/library/windows/desktop/bb172588%28v=vs.85%29.aspx
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.BackBufferCount = 1;
m_params.MultiSampleType = D3DMULTISAMPLE_NONE;
@ -1398,7 +1398,7 @@ namespace bgfx { namespace d3d9
void updateResolution(const Resolution& _resolution)
{
m_maxAnisotropy = !!(_resolution.m_flags & BGFX_RESET_MAXANISOTROPY)
m_maxAnisotropy = !!(_resolution.reset & BGFX_RESET_MAXANISOTROPY)
? m_caps.MaxAnisotropy
: 1
;
@ -1409,16 +1409,16 @@ namespace bgfx { namespace d3d9
| 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.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();
D3DDEVICE_CREATION_PARAMETERS dcp;
@ -1429,14 +1429,14 @@ namespace bgfx { namespace d3d9
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();
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.MultiSampleQuality = msaa.m_quality;
@ -1465,7 +1465,7 @@ namespace bgfx { namespace d3d9
}
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
{
@ -1752,7 +1752,7 @@ namespace bgfx { namespace d3d9
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 height = m_params.BackBufferHeight;
@ -4338,7 +4338,7 @@ namespace bgfx { namespace d3d9
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();
}
@ -4430,12 +4430,12 @@ namespace bgfx { namespace d3d9
, 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 "
, !!(m_resolution.m_flags&BGFX_RESET_VSYNC) ? '\xfe' : ' '
, !!(m_resolution.reset&BGFX_RESET_VSYNC) ? '\xfe' : ' '
, 0 != msaa ? '\xfe' : ' '
, 1<<msaa
, !!(m_resolution.m_flags&BGFX_RESET_MAXANISOTROPY) ? '\xfe' : ' '
, !!(m_resolution.reset&BGFX_RESET_MAXANISOTROPY) ? '\xfe' : ' '
);
double elapsedCpuMs = double(frameTime)*toMs;

Просмотреть файл

@ -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_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?!
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
{
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) )
{
@ -3016,8 +3016,8 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
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(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)
{
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
: 0.0f
;
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) );
}
@ -3113,16 +3113,16 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
| 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.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();
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;
}
setRenderContextSize(m_resolution.m_width
, m_resolution.m_height
setRenderContextSize(m_resolution.width
, m_resolution.height
, flags
);
updateCapture();
@ -3212,7 +3212,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
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) );
}
@ -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_READ_FRAMEBUFFER, m_msaaBackBufferFbo) );
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)
? GL_NEAREST
: GL_LINEAR
@ -3509,11 +3509,11 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
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);
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
{
@ -3527,8 +3527,8 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
{
GL_CHECK(glReadPixels(0
, 0
, m_resolution.m_width
, m_resolution.m_height
, m_resolution.width
, m_resolution.height
, m_readPixelsFmt
, GL_UNSIGNED_BYTE
, m_capture
@ -3538,11 +3538,11 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
{
bimg::imageSwizzleBgra8(
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_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
? _render->m_hmd.height
: _render->m_resolution.m_height
: _render->m_resolution.height
;
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;
resolutionHeight = hmdEnabled
? _render->m_hmd.height
: _render->m_resolution.m_height
: _render->m_resolution.height
;
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 != (m_resolution.m_flags & BGFX_RESET_FLUSH_AFTER_RENDER) )
if (0 != (m_resolution.reset & BGFX_RESET_FLUSH_AFTER_RENDER) )
{
GL_CHECK(glFlush() );
}
@ -7728,13 +7728,13 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
char hmd[16];
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 "
, !!(m_resolution.m_flags&BGFX_RESET_VSYNC) ? '\xfe' : ' '
, !!(m_resolution.reset&BGFX_RESET_VSYNC) ? '\xfe' : ' '
, 0 != msaa ? '\xfe' : ' '
, 1<<msaa
, 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;

Просмотреть файл

@ -1014,8 +1014,8 @@ namespace bgfx { namespace mtl
{
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() )
//{
@ -1128,7 +1128,7 @@ namespace bgfx { namespace mtl
void updateResolution(const Resolution& _resolution)
{
m_maxAnisotropy = !!(_resolution.m_flags & BGFX_RESET_MAXANISOTROPY)
m_maxAnisotropy = !!(_resolution.reset & BGFX_RESET_MAXANISOTROPY)
? 16
: 1
;
@ -1140,26 +1140,26 @@ namespace bgfx { namespace mtl
| 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;
#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
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
;
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;
@ -1172,8 +1172,8 @@ namespace bgfx { namespace mtl
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.mipmapLevelCount = 1;
m_textureDescriptor.sampleCount = sampleCount;
@ -1236,7 +1236,7 @@ namespace bgfx { namespace mtl
updateCapture();
m_textVideoMem.resize(false, _resolution.m_width, _resolution.m_height);
m_textVideoMem.resize(false, _resolution.width, _resolution.height);
m_textVideoMem.clear();
if (prevMetalLayerPixelFormat != m_metalLayer.pixelFormat)
@ -1254,11 +1254,11 @@ namespace bgfx { namespace mtl
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);
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
{
@ -1280,9 +1280,9 @@ namespace bgfx { namespace mtl
m_cmd.kick(false, true);
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();
@ -1290,11 +1290,11 @@ namespace bgfx { namespace mtl
{
bimg::imageSwizzleBgra8(
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_resolution.m_width*4
, m_resolution.width*4
);
}
@ -1458,8 +1458,8 @@ namespace bgfx { namespace mtl
}
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.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);
}
@ -3194,8 +3194,8 @@ namespace bgfx { namespace mtl
{
m_textureDescriptor.textureType = MTLTextureType2D;
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.mipmapLevelCount = 1;
m_textureDescriptor.sampleCount = 1;
@ -3378,8 +3378,8 @@ namespace bgfx { namespace mtl
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) )
{
@ -4011,12 +4011,12 @@ namespace bgfx { namespace mtl
, 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 "
, !!(m_resolution.m_flags&BGFX_RESET_VSYNC) ? '\xfe' : ' '
, !!(m_resolution.reset&BGFX_RESET_VSYNC) ? '\xfe' : ' '
, 0 != msaa ? '\xfe' : ' '
, 1<<msaa
, !!(m_resolution.m_flags&BGFX_RESET_MAXANISOTROPY) ? '\xfe' : ' '
, !!(m_resolution.reset&BGFX_RESET_MAXANISOTROPY) ? '\xfe' : ' '
);
double elapsedCpuMs = double(frameTime)*toMs;

Просмотреть файл

@ -1379,8 +1379,8 @@ VK_IMPORT_DEVICE
m_sci.minImageCount = BX_COUNTOF(m_backBufferColorImage);
m_sci.imageFormat = surfaceFormats[surfaceFormatIdx].format;
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.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
m_sci.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
@ -2168,7 +2168,7 @@ VK_IMPORT_DEVICE
void updateResolution(const Resolution& _resolution)
{
if (!!(_resolution.m_flags & BGFX_RESET_MAXANISOTROPY) )
if (!!(_resolution.reset & BGFX_RESET_MAXANISOTROPY) )
{
m_maxAnisotropy = UINT32_MAX;
}
@ -2177,7 +2177,7 @@ VK_IMPORT_DEVICE
m_maxAnisotropy = 1;
}
bool depthClamp = !!(_resolution.m_flags & BGFX_RESET_DEPTH_CLAMP);
bool depthClamp = !!(_resolution.reset & BGFX_RESET_DEPTH_CLAMP);
if (m_depthClamp != depthClamp)
{
@ -2185,20 +2185,20 @@ VK_IMPORT_DEVICE
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;
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.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();
#if 1
@ -4487,13 +4487,13 @@ BX_UNUSED(presentMin, presentMax);
char hmd[16];
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 "
, !!(m_resolution.m_flags&BGFX_RESET_VSYNC) ? '\xfe' : ' '
, !!(m_resolution.reset&BGFX_RESET_VSYNC) ? '\xfe' : ' '
, 0 != msaa ? '\xfe' : ' '
, 1<<msaa
, ", no-HMD "
, !!(m_resolution.m_flags&BGFX_RESET_MAXANISOTROPY) ? '\xfe' : ' '
, !!(m_resolution.reset&BGFX_RESET_MAXANISOTROPY) ? '\xfe' : ' '
);
double elapsedCpuMs = double(frameTime)*toMs;