From 39176274946d70ff520f265dee8fbd16d5fe0000 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 1 Dec 2017 13:22:27 +0100 Subject: Updated GENie, BGFX, BX, added BIMG since it is separated now, updated all shader binaries and MAME part of code to support new interfaces [Miodrag Milanovic] --- 3rdparty/bgfx/examples/19-oit/oit.cpp | 396 ++++++++++++++++++---------------- 1 file changed, 209 insertions(+), 187 deletions(-) (limited to '3rdparty/bgfx/examples/19-oit/oit.cpp') diff --git a/3rdparty/bgfx/examples/19-oit/oit.cpp b/3rdparty/bgfx/examples/19-oit/oit.cpp index 90c5db05c99..63905a2b89d 100644 --- a/3rdparty/bgfx/examples/19-oit/oit.cpp +++ b/3rdparty/bgfx/examples/19-oit/oit.cpp @@ -7,6 +7,9 @@ #include "bgfx_utils.h" #include "imgui/imgui.h" +namespace +{ + struct PosColorVertex { float m_x; @@ -142,19 +145,25 @@ void screenSpaceQuad(float _textureWidth, float _textureHeight, bool _originBott vertex[2].m_u = maxu; vertex[2].m_v = maxv; - bgfx::setVertexBuffer(&vb); + bgfx::setVertexBuffer(0, &vb); } } class ExampleOIT : public entry::AppI { - void init(int _argc, char** _argv) BX_OVERRIDE +public: + ExampleOIT(const char* _name, const char* _description) + : entry::AppI(_name, _description) + { + } + + void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) override { Args args(_argc, _argv); - m_width = 1280; - m_height = 720; - m_debug = BGFX_DEBUG_TEXT; + m_width = _width; + m_height = _height; + m_debug = BGFX_DEBUG_NONE; m_reset = BGFX_RESET_VSYNC; bgfx::init(args.m_type, args.m_pciId); @@ -206,12 +215,11 @@ class ExampleOIT : public entry::AppI m_wbPass = loadProgram("vs_oit", "fs_oit_wb" ); m_wbBlit = loadProgram("vs_oit_blit", "fs_oit_wb_blit" ); - m_fbtextures[0].idx = bgfx::invalidHandle; - m_fbtextures[1].idx = bgfx::invalidHandle; - m_fbh.idx = bgfx::invalidHandle; + m_fbtextures[0].idx = bgfx::kInvalidHandle; + m_fbtextures[1].idx = bgfx::kInvalidHandle; + m_fbh.idx = bgfx::kInvalidHandle; m_mode = 1; - m_scrollArea = 0; m_frontToBack = true; m_fadeInOut = false; @@ -219,25 +227,35 @@ class ExampleOIT : public entry::AppI m_oldHeight = 0; m_oldReset = m_reset; + m_mrtSupported = true + && 2 <= caps->limits.maxFBAttachments + && bgfx::isTextureValid(0, false, 1, bgfx::TextureFormat::RGBA16F, BGFX_TEXTURE_RT) + && bgfx::isTextureValid(0, false, 1, bgfx::TextureFormat::R16F, BGFX_TEXTURE_RT) + ; + m_timeOffset = bx::getHPCounter(); } - int shutdown() BX_OVERRIDE + int shutdown() override { // Cleanup. imguiDestroy(); - bgfx::destroyFrameBuffer(m_fbh); - bgfx::destroyIndexBuffer(m_ibh); - bgfx::destroyVertexBuffer(m_vbh); - bgfx::destroyProgram(m_blend); - bgfx::destroyProgram(m_wbSeparatePass); - bgfx::destroyProgram(m_wbSeparateBlit); - bgfx::destroyProgram(m_wbPass); - bgfx::destroyProgram(m_wbBlit); - bgfx::destroyUniform(s_texColor0); - bgfx::destroyUniform(s_texColor1); - bgfx::destroyUniform(u_color); + if (bgfx::isValid(m_fbh) ) + { + bgfx::destroy(m_fbh); + } + + bgfx::destroy(m_ibh); + bgfx::destroy(m_vbh); + bgfx::destroy(m_blend); + bgfx::destroy(m_wbSeparatePass); + bgfx::destroy(m_wbSeparateBlit); + bgfx::destroy(m_wbPass); + bgfx::destroy(m_wbBlit); + bgfx::destroy(s_texColor0); + bgfx::destroy(s_texColor1); + bgfx::destroy(u_color); // Shutdown bgfx. bgfx::shutdown(); @@ -245,30 +263,10 @@ class ExampleOIT : public entry::AppI return 0; } - bool update() BX_OVERRIDE + bool update() override { if (!entry::processEvents(m_width, m_height, m_debug, m_reset, &m_mouseState) ) { - if (m_oldWidth != m_width - || m_oldHeight != m_height - || m_oldReset != m_reset - || !bgfx::isValid(m_fbh) ) - { - // Recreate variable size render targets when resolution changes. - m_oldWidth = m_width; - m_oldHeight = m_height; - m_oldReset = m_reset; - - if (bgfx::isValid(m_fbh) ) - { - bgfx::destroyFrameBuffer(m_fbh); - } - - m_fbtextures[0] = bgfx::createTexture2D(uint16_t(m_width), uint16_t(m_height), false, 1, bgfx::TextureFormat::RGBA16F, BGFX_TEXTURE_RT); - m_fbtextures[1] = bgfx::createTexture2D(uint16_t(m_width), uint16_t(m_height), false, 1, bgfx::TextureFormat::R16F, BGFX_TEXTURE_RT); - m_fbh = bgfx::createFrameBuffer(BX_COUNTOF(m_fbtextures), m_fbtextures, true); - } - imguiBeginFrame(m_mouseState.m_mx , m_mouseState.m_my , (m_mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) @@ -279,148 +277,167 @@ class ExampleOIT : public entry::AppI , uint16_t(m_height) ); - imguiBeginScrollArea("Settings", m_width - m_width / 4 - 10, 10, m_width / 4, m_height / 3, &m_scrollArea); - imguiSeparatorLine(); + showExampleDialog(this + , !m_mrtSupported + ? "MRT or frame buffer texture format are not supported." + : NULL + ); - imguiLabel("Blend mode:"); + if (m_mrtSupported) + { + if (m_oldWidth != m_width + || m_oldHeight != m_height + || m_oldReset != m_reset + || !bgfx::isValid(m_fbh) ) + { + // Recreate variable size render targets when resolution changes. + m_oldWidth = m_width; + m_oldHeight = m_height; + m_oldReset = m_reset; - m_mode = imguiChoose(m_mode - , "None" - , "Separate" - , "MRT Independent" - ); + if (bgfx::isValid(m_fbh) ) + { + bgfx::destroy(m_fbh); + } - imguiSeparatorLine(); + m_fbtextures[0] = bgfx::createTexture2D(uint16_t(m_width), uint16_t(m_height), false, 1, bgfx::TextureFormat::RGBA16F, BGFX_TEXTURE_RT); + m_fbtextures[1] = bgfx::createTexture2D(uint16_t(m_width), uint16_t(m_height), false, 1, bgfx::TextureFormat::R16F, BGFX_TEXTURE_RT); + m_fbh = bgfx::createFrameBuffer(BX_COUNTOF(m_fbtextures), m_fbtextures, true); + } - if (imguiCheck("Front to back", m_frontToBack) ) - { - m_frontToBack ^= true; - } + ImGui::SetNextWindowPos( + ImVec2(m_width - m_width / 5.0f - 10.0f, 10.0f) + , ImGuiSetCond_FirstUseEver + ); + ImGui::Begin("Settings" + , NULL + , ImVec2(m_width / 5.0f, m_height / 3.0f) + , ImGuiWindowFlags_AlwaysAutoResize + ); - if (imguiCheck("Fade in/out", m_fadeInOut) ) - { - m_fadeInOut ^= true; - } + ImGui::Separator(); - imguiEndScrollArea(); - imguiEndFrame(); + ImGui::Text("Blend mode:"); - // Set view 0 default viewport. - bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) ); - bgfx::setViewRect(1, 0, 0, uint16_t(m_width), uint16_t(m_height) ); - - int64_t now = bx::getHPCounter(); - static int64_t last = now; - const int64_t frameTime = now - last; - last = now; - const double freq = double(bx::getHPFrequency() ); - const double toMs = 1000.0/freq; - - float time = (float)( (now-m_timeOffset)/freq); - - // Use debug font to print information about this example. - bgfx::dbgTextClear(); - // Reference: - // Weighted, Blended Order-Independent Transparency - // http://jcgt.org/published/0002/02/09/ - // http://casual-effects.blogspot.com/2014/03/weighted-blended-order-independent.html - bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/19-oit"); - bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Weighted, Blended Order Independent Transparency."); - bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs); - - float at[3] = { 0.0f, 0.0f, 0.0f }; - float eye[3] = { 0.0f, 0.0f, -7.0f }; - - float view[16]; - float proj[16]; - - // Set view and projection matrix for view 0. - bx::mtxLookAt(view, eye, at); - mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f); - - bgfx::setViewTransform(0, view, proj); - - // Set palette color for index 0 - bgfx::setPaletteColor(0, 0.0f, 0.0f, 0.0f, 0.0f); - - // Set palette color for index 1 - bgfx::setPaletteColor(1, 1.0f, 1.0f, 1.0f, 1.0f); - - bgfx::setViewClear(0 - , BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH - , 1.0f // Depth - , 0 // Stencil - , 0 // FB texture 0, color palette 0 - , 1 == m_mode ? 1 : 0 // FB texture 1, color palette 1 - ); + ImGui::RadioButton("None", &m_mode, 0); + ImGui::RadioButton("Separate", &m_mode, 1); + ImGui::RadioButton("MRT Independent", &m_mode, 2); - bgfx::setViewClear(1 - , BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH - , 1.0f // Depth - , 0 // Stencil - , 0 // Color palette 0 - ); + ImGui::Separator(); - bgfx::FrameBufferHandle invalid = BGFX_INVALID_HANDLE; - bgfx::setViewFrameBuffer(0, 0 == m_mo
SDL-Specific Commandline Options
================================


This section contains configuration options that are specific to any build supported by SDL (including Windows where compiled as SDL instead of native).



Performance Options
-------------------

.. _mame-scommandline-sdlvideofps:

**-sdlvideofps**

	Enable output of benchmark data on the SDL video subsystem, including your system's video driver, X server (if applicable), and OpenGL stack in **-video opengl** mode.


Video Options
-------------

.. _mame-scommandline-centerh:

**-[no]centerh**

	Center horizontally within the view area. Default is ON (**-centerh**).

.. _mame-scommandline-centerv:

**-[no]centerv**

	Center vertically within the view area. Default is ON (**-centerv**).


Video Soft-Specific Options
---------------------------

.. _mame-scommandline-scalemode:

**-scalemode**

	Scale mode: none, async, yv12, yuy2, yv12x2, yuy2x2 (**-video soft** only). Default is *none*.


SDL Keyboard Mapping
--------------------

.. _mame-scommandline-keymap:

**-keymap**

	Enable keymap. Default is OFF (**-nokeymap**)

.. _mame-scommandline-keymapfile:

**-keymap_file** *<file>*

	Keymap Filename. Default is ``keymap.dat``.


SDL Joystick Mapping
--------------------

.. _mame-scommandline-joyidx:

|
| **-joy_idx1** *<name>*
| **-joy_idx2** *<name>*
| ...
| **-joy_idx8** *<name>*
|

Name of joystick mapped to a given joystick slot, default is *auto*.


.. _mame-scommandline-sixaxis:

**-sixaxis**

	Use special handling for PS3 SixAxis controllers. Default is OFF (**-nosixaxis**)


SDL Low-level Driver Options
~---------------------------

.. _mame-scommandline-videodriver:

**-videodriver** *<driver>*

	SDL video driver to use ('x11', 'directfb', ... or '*auto*' for SDL default)

.. _mame-scommandline-audiodriver:

**-audiodriver** *<driver>*

	SDL audio driver to use ('alsa', 'arts', ... or '*auto*' for SDL default)

.. _mame-scommandline-gllib:

**-gl_lib** *<driver>*

	Alternative **libGL.so** to use; '*auto*' for system default