mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
Merge branch 'master' of github.com:bkaradzic/bgfx
This commit is contained in:
commit
2850924e95
20 changed files with 268 additions and 464 deletions
25
README.md
25
README.md
|
@ -411,9 +411,22 @@ build errors.
|
|||
Debugging
|
||||
---------
|
||||
|
||||
When using DX11 renderer, you can drop in `renderdoc.dll` into working
|
||||
directory, and it will be automatically loaded during bgfx initialization. This
|
||||
allows frame capture at any time by pressing **F11**.
|
||||
### RenderDoc
|
||||
|
||||
Loading of RenderDoc is integrated in bgfx when using DX11 renderer. You can
|
||||
drop in `renderdoc.dll` from RenderDoc distribution into working directory,
|
||||
and it will be automatically loaded during bgfx initialization. This allows
|
||||
frame capture at any time by pressing **F11**.
|
||||
|
||||
Download: [RenderDoc](https://renderdoc.org/builds)
|
||||
|
||||
### IntelGPA
|
||||
|
||||
Right click **Intel GPA Monitor** tray icon, choose preferences, check
|
||||
"Auto-detect launched applications" option. Find `InjectionList.txt` in GPA
|
||||
directory and add `examples-*` to the list.
|
||||
|
||||
Download: [IntelGPA](https://software.intel.com/en-us/vcsource/tools/intel-gpa)
|
||||
|
||||
Other debuggers:
|
||||
|
||||
|
@ -423,12 +436,12 @@ Other debuggers:
|
|||
| CodeXL | Linux/Win | | | x | | |
|
||||
| IntelGPA | Linux/OSX/Win | x | x | | x | |
|
||||
| RenderDoc | Win | | x | | | x |
|
||||
| vogl | Linux | | | x | | x |
|
||||
|
||||
Download:
|
||||
[APITrace](https://apitrace.github.io/)
|
||||
[CodeXL](http://developer.amd.com/tools-and-sdks/opencl-zone/codexl/)
|
||||
[IntelGPA](https://software.intel.com/en-us/vcsource/tools/intel-gpa)
|
||||
[RenderDoc](http://cryengine.com/renderdoc)
|
||||
|
||||
[vogl](https://github.com/ValveSoftware/vogl)
|
||||
|
||||
SDL, GLFW, etc.
|
||||
---------------
|
||||
|
|
|
@ -196,7 +196,8 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
while (!entry::processEvents(width, height, debug, reset) )
|
||||
{
|
||||
// Set view 0 and 1 viewport.
|
||||
bgfx::setViewRectMask(0x3, 0, 0, width, height);
|
||||
bgfx::setViewRect(0, 0, 0, width, height);
|
||||
bgfx::setViewRect(1, 0, 0, width, height);
|
||||
|
||||
// This dummy draw call is here to make sure that view 0 is cleared
|
||||
// if no other draw calls are submitted to view 0.
|
||||
|
|
|
@ -294,8 +294,12 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
|
||||
|
||||
// Set views.
|
||||
bgfx::setViewRectMask(0x1f, 0, 0, width, height);
|
||||
bgfx::setViewFrameBufferMask(0x3, fbh);
|
||||
for (uint32_t ii = 0; ii < 6; ++ii)
|
||||
{
|
||||
bgfx::setViewRect(ii, 0, 0, width, height);
|
||||
}
|
||||
bgfx::setViewFrameBuffer(0, fbh);
|
||||
bgfx::setViewFrameBuffer(1, fbh);
|
||||
|
||||
bgfx::setViewRect(2, 0, 0, 128, 128);
|
||||
bgfx::setViewFrameBuffer(2, lum[0]);
|
||||
|
@ -327,19 +331,10 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
bx::mtxOrtho(proj, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 100.0f);
|
||||
|
||||
// Set view and projection matrix for view 0.
|
||||
bgfx::setViewTransformMask(0
|
||||
|(1<<0)
|
||||
|(1<<2)
|
||||
|(1<<3)
|
||||
|(1<<4)
|
||||
|(1<<5)
|
||||
|(1<<6)
|
||||
|(1<<7)
|
||||
|(1<<8)
|
||||
|(1<<9)
|
||||
, view
|
||||
, proj
|
||||
);
|
||||
for (uint32_t ii = 0; ii < 10; ++ii)
|
||||
{
|
||||
bgfx::setViewTransform(ii, view, proj);
|
||||
}
|
||||
|
||||
float at[3] = { 0.0f, 1.0f, 0.0f };
|
||||
float eye[3] = { 0.0f, 1.0f, -2.5f };
|
||||
|
@ -357,7 +352,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
bx::mtxProj(proj, 60.0f, float(width)/float(height), 0.1f, 100.0f);
|
||||
|
||||
// Set view and projection matrix for view 1.
|
||||
bgfx::setViewTransformMask(1<<1, view, proj);
|
||||
bgfx::setViewTransform(1, view, proj);
|
||||
|
||||
bgfx::setUniform(u_mtx, mtx);
|
||||
|
||||
|
|
|
@ -215,6 +215,39 @@ static bgfx::ProgramHandle loadProgram(const char* _vsName, const char* _fsName)
|
|||
return bgfx::createProgram(vsh, fsh, true /* destroy shaders when program is destroyed */);
|
||||
}
|
||||
|
||||
void setViewClearMask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil)
|
||||
{
|
||||
for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) )
|
||||
{
|
||||
viewMask >>= ntz;
|
||||
view += ntz;
|
||||
|
||||
bgfx::setViewClear( (uint8_t)view, _flags, _rgba, _depth, _stencil);
|
||||
}
|
||||
}
|
||||
|
||||
void setViewTransformMask(uint32_t _viewMask, const void* _view, const void* _proj)
|
||||
{
|
||||
for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) )
|
||||
{
|
||||
viewMask >>= ntz;
|
||||
view += ntz;
|
||||
|
||||
bgfx::setViewTransform( (uint8_t)view, _view, _proj);
|
||||
}
|
||||
}
|
||||
|
||||
void setViewRectMask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
|
||||
{
|
||||
for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) )
|
||||
{
|
||||
viewMask >>= ntz;
|
||||
view += ntz;
|
||||
|
||||
bgfx::setViewRect( (uint8_t)view, _x, _y, _width, _height);
|
||||
}
|
||||
}
|
||||
|
||||
void mtxReflected(float*__restrict _result
|
||||
, const float* __restrict _p /* plane */
|
||||
, const float* __restrict _n /* normal */
|
||||
|
@ -619,7 +652,7 @@ void clearView(uint8_t _id, uint8_t _flags, const ClearValues& _clearValues)
|
|||
|
||||
void clearViewMask(uint32_t _viewMask, uint8_t _flags, const ClearValues& _clearValues)
|
||||
{
|
||||
bgfx::setViewClearMask(_viewMask
|
||||
setViewClearMask(_viewMask
|
||||
, _flags
|
||||
, _clearValues.m_clearRgba
|
||||
, _clearValues.m_clearDepth
|
||||
|
@ -1429,8 +1462,8 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
);
|
||||
|
||||
// Setup view rect and transform for all used views.
|
||||
bgfx::setViewRectMask(s_viewMask, 0, 0, viewState.m_width, viewState.m_height);
|
||||
bgfx::setViewTransformMask(s_viewMask, viewState.m_view, viewState.m_proj);
|
||||
setViewRectMask(s_viewMask, 0, 0, viewState.m_width, viewState.m_height);
|
||||
setViewTransformMask(s_viewMask, viewState.m_view, viewState.m_proj);
|
||||
s_viewMask = 0;
|
||||
|
||||
// Advance to next frame. Rendering thread will be kicked to
|
||||
|
|
|
@ -188,6 +188,39 @@ static bgfx::ProgramHandle loadProgram(const char* _vsName, const char* _fsName)
|
|||
return bgfx::createProgram(vsh, fsh, true /* destroy shaders when program is destroyed */);
|
||||
}
|
||||
|
||||
void setViewClearMask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil)
|
||||
{
|
||||
for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) )
|
||||
{
|
||||
viewMask >>= ntz;
|
||||
view += ntz;
|
||||
|
||||
bgfx::setViewClear( (uint8_t)view, _flags, _rgba, _depth, _stencil);
|
||||
}
|
||||
}
|
||||
|
||||
void setViewTransformMask(uint32_t _viewMask, const void* _view, const void* _proj)
|
||||
{
|
||||
for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) )
|
||||
{
|
||||
viewMask >>= ntz;
|
||||
view += ntz;
|
||||
|
||||
bgfx::setViewTransform( (uint8_t)view, _view, _proj);
|
||||
}
|
||||
}
|
||||
|
||||
void setViewRectMask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
|
||||
{
|
||||
for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) )
|
||||
{
|
||||
viewMask >>= ntz;
|
||||
view += ntz;
|
||||
|
||||
bgfx::setViewRect( (uint8_t)view, _x, _y, _width, _height);
|
||||
}
|
||||
}
|
||||
|
||||
void mtxBillboard(float* __restrict _result
|
||||
, const float* __restrict _view
|
||||
, const float* __restrict _pos
|
||||
|
@ -619,14 +652,6 @@ void submit(uint8_t _id, int32_t _depth = 0)
|
|||
s_viewMask |= 1 << _id;
|
||||
}
|
||||
|
||||
void submitMask(uint32_t _viewMask, int32_t _depth = 0)
|
||||
{
|
||||
bgfx::submitMask(_viewMask, _depth);
|
||||
|
||||
// Keep track of submited view ids.
|
||||
s_viewMask |= _viewMask;
|
||||
}
|
||||
|
||||
struct Aabb
|
||||
{
|
||||
float m_min[3];
|
||||
|
@ -2866,8 +2891,8 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
}
|
||||
|
||||
// Setup view rect and transform for all used views.
|
||||
bgfx::setViewRectMask(s_viewMask, 0, 0, viewState.m_width, viewState.m_height);
|
||||
bgfx::setViewTransformMask(s_viewMask, viewState.m_view, viewState.m_proj);
|
||||
setViewRectMask(s_viewMask, 0, 0, viewState.m_width, viewState.m_height);
|
||||
setViewTransformMask(s_viewMask, viewState.m_view, viewState.m_proj);
|
||||
s_viewMask = 0;
|
||||
|
||||
// Advance to next frame. Rendering thread will be kicked to
|
||||
|
@ -2878,7 +2903,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
s_svAllocator.swap();
|
||||
|
||||
// Reset clear values.
|
||||
bgfx::setViewClearMask(UINT32_MAX
|
||||
setViewClearMask(UINT32_MAX
|
||||
, BGFX_CLEAR_NONE
|
||||
, clearValues.m_clearRgba
|
||||
, clearValues.m_clearDepth
|
||||
|
|
|
@ -16,10 +16,7 @@
|
|||
#include "entry/entry.h"
|
||||
|
||||
#define RENDER_SHADOW_PASS_ID 0
|
||||
#define RENDER_SHADOW_PASS_BIT (1<<RENDER_SHADOW_PASS_ID)
|
||||
|
||||
#define RENDER_SCENE_PASS_ID 1
|
||||
#define RENDER_SCENE_PASS_BIT (1<<RENDER_SCENE_PASS_ID)
|
||||
|
||||
uint32_t packUint32(uint8_t _x, uint8_t _y, uint8_t _z, uint8_t _w)
|
||||
{
|
||||
|
@ -579,7 +576,12 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
bgfx::setViewTransform(RENDER_SCENE_PASS_ID, view, proj);
|
||||
|
||||
// Clear backbuffer and shadowmap framebuffer at beginning.
|
||||
bgfx::setViewClearMask(RENDER_SHADOW_PASS_BIT|RENDER_SCENE_PASS_BIT
|
||||
bgfx::setViewClear(RENDER_SHADOW_PASS_ID
|
||||
, BGFX_CLEAR_COLOR_BIT | BGFX_CLEAR_DEPTH_BIT
|
||||
, 0x303030ff, 1.0f, 0
|
||||
);
|
||||
|
||||
bgfx::setViewClear(RENDER_SCENE_PASS_ID
|
||||
, BGFX_CLEAR_COLOR_BIT | BGFX_CLEAR_DEPTH_BIT
|
||||
, 0x303030ff, 1.0f, 0
|
||||
);
|
||||
|
|
|
@ -37,26 +37,6 @@
|
|||
#define RENDERVIEW_DRAWDEPTH_2_ID 18
|
||||
#define RENDERVIEW_DRAWDEPTH_3_ID 19
|
||||
|
||||
#define RENDERVIEW_SHADOWMAP_0_BIT (1<<RENDERVIEW_SHADOWMAP_0_ID)
|
||||
#define RENDERVIEW_SHADOWMAP_1_BIT (1<<RENDERVIEW_SHADOWMAP_1_ID)
|
||||
#define RENDERVIEW_SHADOWMAP_2_BIT (1<<RENDERVIEW_SHADOWMAP_2_ID)
|
||||
#define RENDERVIEW_SHADOWMAP_3_BIT (1<<RENDERVIEW_SHADOWMAP_3_ID)
|
||||
#define RENDERVIEW_SHADOWMAP_4_BIT (1<<RENDERVIEW_SHADOWMAP_4_ID)
|
||||
#define RENDERVIEW_VBLUR_0_BIT (1<<RENDERVIEW_VBLUR_0_ID)
|
||||
#define RENDERVIEW_HBLUR_0_BIT (1<<RENDERVIEW_HBLUR_0_ID)
|
||||
#define RENDERVIEW_VBLUR_1_BIT (1<<RENDERVIEW_VBLUR_1_ID)
|
||||
#define RENDERVIEW_HBLUR_1_BIT (1<<RENDERVIEW_HBLUR_1_ID)
|
||||
#define RENDERVIEW_VBLUR_2_BIT (1<<RENDERVIEW_VBLUR_2_ID)
|
||||
#define RENDERVIEW_HBLUR_2_BIT (1<<RENDERVIEW_HBLUR_2_ID)
|
||||
#define RENDERVIEW_VBLUR_3_BIT (1<<RENDERVIEW_VBLUR_3_ID)
|
||||
#define RENDERVIEW_HBLUR_3_BIT (1<<RENDERVIEW_HBLUR_3_ID)
|
||||
#define RENDERVIEW_DRAWSCENE_0_BIT (1<<RENDERVIEW_DRAWSCENE_0_ID)
|
||||
#define RENDERVIEW_DRAWSCENE_1_BIT (1<<RENDERVIEW_DRAWSCENE_1_ID)
|
||||
#define RENDERVIEW_DRAWDEPTH_0_BIT (1<<RENDERVIEW_DRAWDEPTH_0_ID)
|
||||
#define RENDERVIEW_DRAWDEPTH_1_BIT (1<<RENDERVIEW_DRAWDEPTH_1_ID)
|
||||
#define RENDERVIEW_DRAWDEPTH_2_BIT (1<<RENDERVIEW_DRAWDEPTH_2_ID)
|
||||
#define RENDERVIEW_DRAWDEPTH_3_BIT (1<<RENDERVIEW_DRAWDEPTH_3_ID)
|
||||
|
||||
uint32_t packUint32(uint8_t _x, uint8_t _y, uint8_t _z, uint8_t _w)
|
||||
{
|
||||
union
|
||||
|
@ -2553,9 +2533,11 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
}
|
||||
|
||||
// Reset render targets.
|
||||
const uint32_t viewMask = (uint32_t(1) << (RENDERVIEW_DRAWDEPTH_3_ID+1) ) - 1;
|
||||
const bgfx::FrameBufferHandle invalidRt = BGFX_INVALID_HANDLE;
|
||||
bgfx::setViewFrameBufferMask(viewMask, invalidRt);
|
||||
for (uint32_t ii = 0; ii < RENDERVIEW_DRAWDEPTH_3_ID+1; ++ii)
|
||||
{
|
||||
bgfx::setViewFrameBuffer(ii, invalidRt);
|
||||
}
|
||||
|
||||
// Determine on-screen rectangle size where depth buffer will be drawn.
|
||||
const uint16_t depthRectHeight = uint16_t(float(viewState.m_height) / 2.5f);
|
||||
|
|
|
@ -273,7 +273,8 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
imguiEndFrame();
|
||||
|
||||
// Set view 0 default viewport.
|
||||
bgfx::setViewRectMask(0x3, 0, 0, width, height);
|
||||
bgfx::setViewRect(0, 0, 0, width, height);
|
||||
bgfx::setViewRect(1, 0, 0, width, height);
|
||||
|
||||
int64_t now = bx::getHPCounter();
|
||||
static int64_t last = now;
|
||||
|
|
|
@ -10,19 +10,10 @@
|
|||
#include "bounds.h"
|
||||
|
||||
#define RENDER_PASS_GEOMETRY_ID 0
|
||||
#define RENDER_PASS_GEOMETRY_BIT (1<<RENDER_PASS_GEOMETRY_ID)
|
||||
|
||||
#define RENDER_PASS_LIGHT_ID 1
|
||||
#define RENDER_PASS_LIGHT_BIT (1<<RENDER_PASS_LIGHT_ID)
|
||||
|
||||
#define RENDER_PASS_COMBINE_ID 2
|
||||
#define RENDER_PASS_COMBINE_BIT (1<<RENDER_PASS_COMBINE_ID)
|
||||
|
||||
#define RENDER_PASS_DEBUG_LIGHTS_ID 3
|
||||
#define RENDER_PASS_DEBUG_LIGHTS_BIT (1<<RENDER_PASS_DEBUG_LIGHTS_ID)
|
||||
|
||||
#define RENDER_PASS_DEBUG_GBUFFER_ID 4
|
||||
#define RENDER_PASS_DEBUG_GBUFFER_BIT (1<<RENDER_PASS_DEBUG_GBUFFER_ID)
|
||||
|
||||
struct PosNormalTangentTexcoordVertex
|
||||
{
|
||||
|
@ -448,14 +439,11 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
float vp[16];
|
||||
float invMvp[16];
|
||||
{
|
||||
bgfx::setViewRectMask(0
|
||||
| RENDER_PASS_GEOMETRY_BIT
|
||||
| RENDER_PASS_LIGHT_BIT
|
||||
| RENDER_PASS_COMBINE_BIT
|
||||
| RENDER_PASS_DEBUG_LIGHTS_BIT
|
||||
| RENDER_PASS_DEBUG_GBUFFER_BIT
|
||||
, 0, 0, width, height
|
||||
);
|
||||
bgfx::setViewRect(RENDER_PASS_GEOMETRY_ID, 0, 0, width, height);
|
||||
bgfx::setViewRect(RENDER_PASS_LIGHT_ID, 0, 0, width, height);
|
||||
bgfx::setViewRect(RENDER_PASS_COMBINE_ID, 0, 0, width, height);
|
||||
bgfx::setViewRect(RENDER_PASS_DEBUG_LIGHTS_ID, 0, 0, width, height);
|
||||
bgfx::setViewRect(RENDER_PASS_DEBUG_GBUFFER_ID, 0, 0, width, height);
|
||||
|
||||
bgfx::setViewFrameBuffer(RENDER_PASS_LIGHT_ID, lightBuffer);
|
||||
|
||||
|
@ -469,11 +457,8 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
bx::mtxInverse(invMvp, vp);
|
||||
|
||||
bx::mtxOrtho(proj, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 100.0f);
|
||||
bgfx::setViewTransformMask(0
|
||||
| RENDER_PASS_LIGHT_BIT
|
||||
| RENDER_PASS_COMBINE_BIT
|
||||
, NULL, proj
|
||||
);
|
||||
bgfx::setViewTransform(RENDER_PASS_LIGHT_ID, NULL, proj);
|
||||
bgfx::setViewTransform(RENDER_PASS_COMBINE_ID, NULL, proj);
|
||||
|
||||
const float aspectRatio = float(height)/float(width);
|
||||
const float size = 10.0f;
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
|
||||
#include <windowsx.h>
|
||||
|
||||
#include <tinystl/allocator.h>
|
||||
#include <tinystl/string.h>
|
||||
|
||||
enum
|
||||
{
|
||||
WM_USER_WINDOW_CREATE = WM_USER,
|
||||
|
@ -89,7 +92,7 @@ namespace entry
|
|||
uint32_t m_width;
|
||||
uint32_t m_height;
|
||||
uint32_t m_flags;
|
||||
std::string m_title;
|
||||
tinystl::string m_title;
|
||||
};
|
||||
|
||||
struct Context
|
||||
|
|
|
@ -1456,7 +1456,7 @@ struct Imgui
|
|||
return selected;
|
||||
}
|
||||
|
||||
void image(bgfx::TextureHandle _image, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align)
|
||||
void image(bgfx::TextureHandle _image, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align, bool _originBottomLeft)
|
||||
{
|
||||
Area& area = getCurrentArea();
|
||||
|
||||
|
@ -1485,7 +1485,7 @@ struct Imgui
|
|||
const int32_t yy = area.m_widgetY;
|
||||
area.m_widgetY += _height + DEFAULT_SPACING;
|
||||
|
||||
screenQuad(xx, yy, _width, _height);
|
||||
screenQuad(xx, yy, _width, _height, _originBottomLeft);
|
||||
bgfx::setUniform(u_imageLod, &_lod);
|
||||
bgfx::setTexture(0, s_texColor, bgfx::isValid(_image) ? _image : m_missingTexture);
|
||||
bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
|
||||
|
@ -1494,12 +1494,12 @@ struct Imgui
|
|||
bgfx::submit(m_view);
|
||||
}
|
||||
|
||||
void image(bgfx::TextureHandle _image, float _lod, float _width, float _aspect, ImguiAlign::Enum _align)
|
||||
void image(bgfx::TextureHandle _image, float _lod, float _width, float _aspect, ImguiAlign::Enum _align, bool _originBottomLeft)
|
||||
{
|
||||
const float width = _width*float(getCurrentArea().m_widgetW);
|
||||
const float height = width/_aspect;
|
||||
|
||||
image(_image, _lod, int32_t(width), int32_t(height), _align);
|
||||
image(_image, _lod, int32_t(width), int32_t(height), _align, _originBottomLeft);
|
||||
}
|
||||
|
||||
void imageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align)
|
||||
|
@ -2330,7 +2330,7 @@ struct Imgui
|
|||
#endif // USE_NANOVG_FONT
|
||||
}
|
||||
|
||||
void screenQuad(int32_t _x, int32_t _y, int32_t _width, uint32_t _height)
|
||||
void screenQuad(int32_t _x, int32_t _y, int32_t _width, uint32_t _height, bool _originBottomLeft = false)
|
||||
{
|
||||
if (bgfx::checkAvailTransientVertexBuffer(6, PosUvVertex::ms_decl) )
|
||||
{
|
||||
|
@ -2350,8 +2350,8 @@ struct Imgui
|
|||
const float texelHalfH = m_halfTexel/heightf;
|
||||
const float minu = texelHalfW;
|
||||
const float maxu = 1.0f - texelHalfW;
|
||||
const float minv = texelHalfH;
|
||||
const float maxv = texelHalfH + 1.0f;
|
||||
const float minv = _originBottomLeft ? texelHalfH+1.0f : texelHalfH ;
|
||||
const float maxv = _originBottomLeft ? texelHalfH : texelHalfH+1.0f;
|
||||
|
||||
vertex[0].m_x = minx;
|
||||
vertex[0].m_y = miny;
|
||||
|
@ -2796,6 +2796,16 @@ ImguiFontHandle imguiCreate(const void* _data, float _fontSize)
|
|||
return s_imgui.create(_data, _fontSize);
|
||||
}
|
||||
|
||||
void imguiDestroy()
|
||||
{
|
||||
s_imgui.destroy();
|
||||
}
|
||||
|
||||
ImguiFontHandle imguiCreateFont(const void* _data, float _fontSize)
|
||||
{
|
||||
return s_imgui.createFont(_data, _fontSize);
|
||||
}
|
||||
|
||||
void imguiSetFont(ImguiFontHandle _handle)
|
||||
{
|
||||
s_imgui.setFont(_handle);
|
||||
|
@ -2807,16 +2817,6 @@ ImguiFontHandle imguiGetCurrentFont()
|
|||
return handle;
|
||||
}
|
||||
|
||||
ImguiFontHandle imguiCreateFont(const void* _data, float _fontSize)
|
||||
{
|
||||
return s_imgui.createFont(_data, _fontSize);
|
||||
}
|
||||
|
||||
void imguiDestroy()
|
||||
{
|
||||
s_imgui.destroy();
|
||||
}
|
||||
|
||||
void imguiBeginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, uint16_t _width, uint16_t _height, char _inputChar, uint8_t _view)
|
||||
{
|
||||
s_imgui.beginFrame(_mx, _my, _button, _scroll, _width, _height, _inputChar, _view);
|
||||
|
@ -2827,6 +2827,26 @@ void imguiEndFrame()
|
|||
s_imgui.endFrame();
|
||||
}
|
||||
|
||||
void imguiDrawText(int32_t _x, int32_t _y, ImguiTextAlign::Enum _align, const char* _text, uint32_t _argb)
|
||||
{
|
||||
s_imgui.drawText(_x, _y, _align, _text, _argb);
|
||||
}
|
||||
|
||||
void imguiDrawLine(float _x0, float _y0, float _x1, float _y1, float _r, uint32_t _argb)
|
||||
{
|
||||
s_imgui.drawLine(_x0, _y0, _x1, _y1, _r, _argb);
|
||||
}
|
||||
|
||||
void imguiDrawRoundedRect(float _x, float _y, float _width, float _height, float _r, uint32_t _argb)
|
||||
{
|
||||
s_imgui.drawRoundedRect(_x, _y, _width, _height, _r, _argb);
|
||||
}
|
||||
|
||||
void imguiDrawRect(float _x, float _y, float _width, float _height, uint32_t _argb)
|
||||
{
|
||||
s_imgui.drawRect(_x, _y, _width, _height, _argb);
|
||||
}
|
||||
|
||||
bool imguiBorderButton(ImguiBorder::Enum _border, bool _checked, bool _enabled)
|
||||
{
|
||||
return s_imgui.borderButton(_border, _checked, _enabled);
|
||||
|
@ -2867,7 +2887,6 @@ void imguiEndScrollArea(int32_t _r)
|
|||
s_imgui.endArea();
|
||||
}
|
||||
|
||||
|
||||
void imguiIndent(uint16_t _width)
|
||||
{
|
||||
s_imgui.indent(_width);
|
||||
|
@ -2913,6 +2932,14 @@ bool imguiCheck(const char* _text, bool _checked, bool _enabled)
|
|||
return s_imgui.check(_text, _checked, _enabled);
|
||||
}
|
||||
|
||||
void imguiBool(const char* _text, bool& _flag, bool _enabled)
|
||||
{
|
||||
if (imguiCheck(_text, _flag, _enabled) )
|
||||
{
|
||||
_flag = !_flag;
|
||||
}
|
||||
}
|
||||
|
||||
bool imguiCollapse(const char* _text, const char* _subtext, bool _checked, bool _enabled)
|
||||
{
|
||||
return s_imgui.collapse(_text, _subtext, _checked, _enabled);
|
||||
|
@ -3016,34 +3043,6 @@ uint32_t imguiChooseUseMacroInstead(uint32_t _selected, ...)
|
|||
return _selected;
|
||||
}
|
||||
|
||||
void imguiDrawText(int32_t _x, int32_t _y, ImguiTextAlign::Enum _align, const char* _text, uint32_t _argb)
|
||||
{
|
||||
s_imgui.drawText(_x, _y, _align, _text, _argb);
|
||||
}
|
||||
|
||||
void imguiDrawLine(float _x0, float _y0, float _x1, float _y1, float _r, uint32_t _argb)
|
||||
{
|
||||
s_imgui.drawLine(_x0, _y0, _x1, _y1, _r, _argb);
|
||||
}
|
||||
|
||||
void imguiDrawRoundedRect(float _x, float _y, float _width, float _height, float _r, uint32_t _argb)
|
||||
{
|
||||
s_imgui.drawRoundedRect(_x, _y, _width, _height, _r, _argb);
|
||||
}
|
||||
|
||||
void imguiDrawRect(float _x, float _y, float _width, float _height, uint32_t _argb)
|
||||
{
|
||||
s_imgui.drawRect(_x, _y, _width, _height, _argb);
|
||||
}
|
||||
|
||||
void imguiBool(const char* _text, bool& _flag, bool _enabled)
|
||||
{
|
||||
if (imguiCheck(_text, _flag, _enabled) )
|
||||
{
|
||||
_flag = !_flag;
|
||||
}
|
||||
}
|
||||
|
||||
void imguiColorWheel(float _rgb[3], bool _respectIndentation, bool _enabled)
|
||||
{
|
||||
s_imgui.colorWheelWidget(_rgb, _respectIndentation, _enabled);
|
||||
|
@ -3069,14 +3068,14 @@ void imguiColorWheel(const char* _text, float _rgb[3], bool& _activated, bool _e
|
|||
}
|
||||
}
|
||||
|
||||
void imguiImage(bgfx::TextureHandle _image, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align)
|
||||
void imguiImage(bgfx::TextureHandle _image, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align, bool _originBottomLeft)
|
||||
{
|
||||
s_imgui.image(_image, _lod, _width, _height, _align);
|
||||
s_imgui.image(_image, _lod, _width, _height, _align, _originBottomLeft);
|
||||
}
|
||||
|
||||
void imguiImage(bgfx::TextureHandle _image, float _lod, float _width, float _aspect, ImguiAlign::Enum _align)
|
||||
void imguiImage(bgfx::TextureHandle _image, float _lod, float _width, float _aspect, ImguiAlign::Enum _align, bool _originBottomLeft)
|
||||
{
|
||||
s_imgui.image(_image, _lod, _width, _aspect, _align);
|
||||
s_imgui.image(_image, _lod, _width, _aspect, _align, _originBottomLeft);
|
||||
}
|
||||
|
||||
void imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align)
|
||||
|
@ -3089,11 +3088,6 @@ void imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod,
|
|||
s_imgui.imageChannel(_image, _channel, _lod, _width, _aspect, _align);
|
||||
}
|
||||
|
||||
bool imguiMouseOverArea()
|
||||
{
|
||||
return s_imgui.m_insideArea;
|
||||
}
|
||||
|
||||
float imguiGetTextLength(const char* _text, ImguiFontHandle _handle)
|
||||
{
|
||||
#if !USE_NANOVG_FONT
|
||||
|
@ -3103,3 +3097,8 @@ float imguiGetTextLength(const char* _text, ImguiFontHandle _handle)
|
|||
return 0.0f;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool imguiMouseOverArea()
|
||||
{
|
||||
return s_imgui.m_insideArea;
|
||||
}
|
||||
|
|
|
@ -126,6 +126,11 @@ void imguiDestroy();
|
|||
void imguiBeginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, uint16_t _width, uint16_t _height, char _inputChar = 0, uint8_t _view = 31);
|
||||
void imguiEndFrame();
|
||||
|
||||
void imguiDrawText(int _x, int _y, ImguiTextAlign::Enum _align, const char* _text, uint32_t _argb);
|
||||
void imguiDrawLine(float _x0, float _y0, float _x1, float _y1, float _r, uint32_t _argb);
|
||||
void imguiDrawRoundedRect(float _x, float _y, float _w, float _h, float _r, uint32_t _argb);
|
||||
void imguiDrawRect(float _x, float _y, float _w, float _h, uint32_t _argb);
|
||||
|
||||
/// Notice: this function is not to be called between imguiBeginArea() and imguiEndArea().
|
||||
bool imguiBorderButton(ImguiBorder::Enum _border, bool _checked, bool _enabled = true);
|
||||
|
||||
|
@ -148,6 +153,7 @@ int32_t imguiGetWidgetY();
|
|||
bool imguiButton(const char* _text, bool _enabled = true, ImguiAlign::Enum _align = ImguiAlign::LeftIndented, uint32_t _rgb0 = IMGUI_BUTTON_RGB0, int32_t _r = IMGUI_BUTTON_R);
|
||||
bool imguiItem(const char* _text, bool _enabled = true);
|
||||
bool imguiCheck(const char* _text, bool _checked, bool _enabled = true);
|
||||
void imguiBool(const char* _text, bool& _flag, bool _enabled = true);
|
||||
bool imguiCollapse(const char* _text, const char* _subtext, bool _checked, bool _enabled = true);
|
||||
void imguiLabel(const char* _format, ...);
|
||||
void imguiLabel(uint32_t _rgba, const char* _format, ...);
|
||||
|
@ -165,21 +171,15 @@ uint8_t imguiTabsUseMacroInstead(uint8_t _selected, bool _enabled, ImguiAlign::E
|
|||
uint32_t imguiChooseUseMacroInstead(uint32_t _selected, ...);
|
||||
#define imguiChoose(...) imguiChooseUseMacroInstead(__VA_ARGS__, NULL)
|
||||
|
||||
void imguiDrawText(int _x, int _y, ImguiTextAlign::Enum _align, const char* _text, uint32_t _argb);
|
||||
void imguiDrawLine(float _x0, float _y0, float _x1, float _y1, float _r, uint32_t _argb);
|
||||
void imguiDrawRoundedRect(float _x, float _y, float _w, float _h, float _r, uint32_t _argb);
|
||||
void imguiDrawRect(float _x, float _y, float _w, float _h, uint32_t _argb);
|
||||
|
||||
void imguiBool(const char* _text, bool& _flag, bool _enabled = true);
|
||||
void imguiColorWheel(float _rgb[3], bool _respectIndentation = false, bool _enabled = true);
|
||||
void imguiColorWheel(const char* _str, float _rgb[3], bool& _activated, bool _enabled = true);
|
||||
|
||||
void imguiImage(bgfx::TextureHandle _image, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align = ImguiAlign::LeftIndented);
|
||||
void imguiImage(bgfx::TextureHandle _image, float _lod, float _scale, float _aspect, ImguiAlign::Enum _align = ImguiAlign::LeftIndented);
|
||||
void imguiImage(bgfx::TextureHandle _image, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align = ImguiAlign::LeftIndented, bool _originBottomLeft = false);
|
||||
void imguiImage(bgfx::TextureHandle _image, float _lod, float _scale, float _aspect, ImguiAlign::Enum _align = ImguiAlign::LeftIndented, bool _originBottomLeft = false);
|
||||
void imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align = ImguiAlign::LeftIndented);
|
||||
void imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, float _scale, float _aspect, ImguiAlign::Enum _align = ImguiAlign::LeftIndented);
|
||||
|
||||
bool imguiMouseOverArea();
|
||||
float imguiGetTextLength(const char* _text, ImguiFontHandle _handle);
|
||||
bool imguiMouseOverArea();
|
||||
|
||||
#endif // IMGUI_H_HEADER_GUARD
|
||||
|
|
|
@ -1062,17 +1062,6 @@ BGFX_C_API void bgfx_set_view_name(uint8_t _id, const char* _name);
|
|||
*/
|
||||
BGFX_C_API void bgfx_set_view_rect(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
|
||||
|
||||
/**
|
||||
* Set view rectangle for multiple views.
|
||||
*
|
||||
* @param _viewMask Bit mask representing affected views.
|
||||
* @param _x Position x from the left corner of the window.
|
||||
* @param _y Position y from the top corner of the window.
|
||||
* @param _width Width of view port region.
|
||||
* @param _height Height of view port region.
|
||||
*/
|
||||
BGFX_C_API void bgfx_set_view_rect_mask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
|
||||
|
||||
/**
|
||||
* Set view scissor. Draw primitive outside view will be clipped. When
|
||||
* _x, _y, _width and _height are set to 0, scissor will be disabled.
|
||||
|
@ -1084,19 +1073,6 @@ BGFX_C_API void bgfx_set_view_rect_mask(uint32_t _viewMask, uint16_t _x, uint16_
|
|||
*/
|
||||
BGFX_C_API void bgfx_set_view_scissor(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
|
||||
|
||||
/**
|
||||
* Set view scissor for multiple views. When _x, _y, _width and _height
|
||||
* are set to 0, scissor will be disabled.
|
||||
*
|
||||
* @param _id View id.
|
||||
* @param _viewMask Bit mask representing affected views.
|
||||
* @param _x Position x from the left corner of the window.
|
||||
* @param _y Position y from the top corner of the window.
|
||||
* @param _width Width of scissor region.
|
||||
* @param _height Height of scissor region.
|
||||
*/
|
||||
BGFX_C_API void bgfx_set_view_scissor_mask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
|
||||
|
||||
/**
|
||||
* Set view clear flags.
|
||||
*
|
||||
|
@ -1122,22 +1098,12 @@ BGFX_C_API void bgfx_set_view_clear(uint8_t _id, uint8_t _flags, uint32_t _rgba,
|
|||
*/
|
||||
BGFX_C_API void bgfx_set_view_clear_mrt(uint8_t _id, uint8_t _flags, float _depth, uint8_t _stencil, uint8_t _0, uint8_t _1, uint8_t _2, uint8_t _3, uint8_t _4, uint8_t _5, uint8_t _6, uint8_t _7);
|
||||
|
||||
/**
|
||||
* Set view clear flags for multiple views.
|
||||
*/
|
||||
BGFX_C_API void bgfx_set_view_clear_mask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil);
|
||||
|
||||
/**
|
||||
* Set view into sequential mode. Draw calls will be sorted in the same
|
||||
* order in which submit calls were called.
|
||||
*/
|
||||
BGFX_C_API void bgfx_set_view_seq(uint8_t _id, bool _enabled);
|
||||
|
||||
/**
|
||||
* Set multiple views into sequential mode.
|
||||
*/
|
||||
BGFX_C_API void bgfx_set_view_seq_mask(uint32_t _viewMask, bool _enabled);
|
||||
|
||||
/**
|
||||
* Set view frame buffer.
|
||||
*
|
||||
|
@ -1148,27 +1114,12 @@ BGFX_C_API void bgfx_set_view_seq_mask(uint32_t _viewMask, bool _enabled);
|
|||
*/
|
||||
BGFX_C_API void bgfx_set_view_frame_buffer(uint8_t _id, bgfx_frame_buffer_handle_t _handle);
|
||||
|
||||
/**
|
||||
* Set view frame buffer for multiple views.
|
||||
*
|
||||
* @param _viewMask View mask.
|
||||
* @param _handle Frame buffer handle. Passing BGFX_INVALID_HANDLE as
|
||||
* frame buffer handle will draw primitives from this view into
|
||||
* default back buffer.
|
||||
*/
|
||||
BGFX_C_API void bgfx_set_view_frame_buffer_mask(uint32_t _viewMask, bgfx_frame_buffer_handle_t _handle);
|
||||
|
||||
/**
|
||||
* Set view view and projection matrices, all draw primitives in this
|
||||
* view will use these matrices.
|
||||
*/
|
||||
BGFX_C_API void bgfx_set_view_transform(uint8_t _id, const void* _view, const void* _proj);
|
||||
|
||||
/**
|
||||
* Set view view and projection matrices for multiple views.
|
||||
*/
|
||||
BGFX_C_API void bgfx_set_view_transform_mask(uint32_t _viewMask, const void* _view, const void* _proj);
|
||||
|
||||
/**
|
||||
* Sets debug marker.
|
||||
*/
|
||||
|
@ -1341,15 +1292,6 @@ BGFX_C_API void bgfx_set_texture_from_frame_buffer(uint8_t _stage, bgfx_uniform_
|
|||
*/
|
||||
BGFX_C_API uint32_t bgfx_submit(uint8_t _id, int32_t _depth);
|
||||
|
||||
/**
|
||||
* Submit primitive for rendering into multiple views.
|
||||
*
|
||||
* @param _viewMask Mask to which views to submit draw primitive calls.
|
||||
* @param _depth Depth for sorting.
|
||||
* @returns Number of draw calls.
|
||||
*/
|
||||
BGFX_C_API uint32_t bgfx_submit_mask(uint32_t _viewMask, int32_t _depth);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -911,16 +911,6 @@ namespace bgfx
|
|||
///
|
||||
void setViewRect(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
|
||||
|
||||
/// Set view rectangle for multiple views.
|
||||
///
|
||||
/// @param _viewMask Bit mask representing affected views.
|
||||
/// @param _x Position x from the left corner of the window.
|
||||
/// @param _y Position y from the top corner of the window.
|
||||
/// @param _width Width of view port region.
|
||||
/// @param _height Height of view port region.
|
||||
///
|
||||
void setViewRectMask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
|
||||
|
||||
/// Set view scissor. Draw primitive outside view will be clipped. When
|
||||
/// _x, _y, _width and _height are set to 0, scissor will be disabled.
|
||||
///
|
||||
|
@ -931,18 +921,6 @@ namespace bgfx
|
|||
///
|
||||
void setViewScissor(uint8_t _id, uint16_t _x = 0, uint16_t _y = 0, uint16_t _width = 0, uint16_t _height = 0);
|
||||
|
||||
/// Set view scissor for multiple views. When _x, _y, _width and _height
|
||||
/// are set to 0, scissor will be disabled.
|
||||
///
|
||||
/// @param _id View id.
|
||||
/// @param _viewMask Bit mask representing affected views.
|
||||
/// @param _x Position x from the left corner of the window.
|
||||
/// @param _y Position y from the top corner of the window.
|
||||
/// @param _width Width of scissor region.
|
||||
/// @param _height Height of scissor region.
|
||||
///
|
||||
void setViewScissorMask(uint32_t _viewMask, uint16_t _x = 0, uint16_t _y = 0, uint16_t _width = 0, uint16_t _height = 0);
|
||||
|
||||
/// Set view clear flags.
|
||||
///
|
||||
/// @param _id View id.
|
||||
|
@ -966,16 +944,10 @@ namespace bgfx
|
|||
///
|
||||
void setViewClear(uint8_t _id, uint8_t _flags, float _depth, uint8_t _stencil, uint8_t _0 = UINT8_MAX, uint8_t _1 = UINT8_MAX, uint8_t _2 = UINT8_MAX, uint8_t _3 = UINT8_MAX, uint8_t _4 = UINT8_MAX, uint8_t _5 = UINT8_MAX, uint8_t _6 = UINT8_MAX, uint8_t _7 = UINT8_MAX);
|
||||
|
||||
/// Set view clear flags for multiple views.
|
||||
void setViewClearMask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba = 0x000000ff, float _depth = 1.0f, uint8_t _stencil = 0);
|
||||
|
||||
/// Set view into sequential mode. Draw calls will be sorted in the same
|
||||
/// order in which submit calls were called.
|
||||
void setViewSeq(uint8_t _id, bool _enabled);
|
||||
|
||||
/// Set multiple views into sequential mode.
|
||||
void setViewSeqMask(uint32_t _viewMask, bool _enabled);
|
||||
|
||||
/// Set view frame buffer.
|
||||
///
|
||||
/// @param _id View id.
|
||||
|
@ -988,25 +960,10 @@ namespace bgfx
|
|||
///
|
||||
void setViewFrameBuffer(uint8_t _id, FrameBufferHandle _handle);
|
||||
|
||||
/// Set view frame buffer for multiple views.
|
||||
///
|
||||
/// @param _viewMask View mask.
|
||||
/// @param _handle Frame buffer handle. Passing BGFX_INVALID_HANDLE as
|
||||
/// frame buffer handle will draw primitives from this view into
|
||||
/// default back buffer.
|
||||
///
|
||||
/// NOTE:
|
||||
/// Not persistent after bgfx::reset call.
|
||||
///
|
||||
void setViewFrameBufferMask(uint32_t _viewMask, FrameBufferHandle _handle);
|
||||
|
||||
/// Set view view and projection matrices, all draw primitives in this
|
||||
/// view will use these matrices.
|
||||
void setViewTransform(uint8_t _id, const void* _view, const void* _proj);
|
||||
|
||||
/// Set view view and projection matrices for multiple views.
|
||||
void setViewTransformMask(uint32_t _viewMask, const void* _view, const void* _proj);
|
||||
|
||||
/// Sets debug marker.
|
||||
void setMarker(const char* _marker);
|
||||
|
||||
|
@ -1159,14 +1116,6 @@ namespace bgfx
|
|||
///
|
||||
uint32_t submit(uint8_t _id, int32_t _depth = 0);
|
||||
|
||||
/// Submit primitive for rendering into multiple views.
|
||||
///
|
||||
/// @param _viewMask Mask to which views to submit draw primitive calls.
|
||||
/// @param _depth Depth for sorting.
|
||||
/// @returns Number of draw calls.
|
||||
///
|
||||
uint32_t submitMask(uint32_t _viewMask, int32_t _depth = 0);
|
||||
|
||||
///
|
||||
void setImage(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle, uint8_t _mip, TextureFormat::Enum _format, Access::Enum _access);
|
||||
|
||||
|
|
|
@ -77,6 +77,7 @@ function exampleProject(_name)
|
|||
}
|
||||
links { -- this is needed only for testing with GLES2/3 on Windows with VS2008
|
||||
"DelayImp",
|
||||
"psapi",
|
||||
}
|
||||
|
||||
configuration { "vs201*" }
|
||||
|
|
129
src/bgfx.cpp
129
src/bgfx.cpp
|
@ -723,57 +723,6 @@ namespace bgfx
|
|||
return m_num;
|
||||
}
|
||||
|
||||
uint32_t Frame::submitMask(uint32_t _viewMask, int32_t _depth)
|
||||
{
|
||||
if (m_discard)
|
||||
{
|
||||
discard();
|
||||
return m_num;
|
||||
}
|
||||
|
||||
if (BGFX_CONFIG_MAX_DRAW_CALLS-1 <= m_num
|
||||
|| (0 == m_draw.m_numVertices && 0 == m_draw.m_numIndices) )
|
||||
{
|
||||
m_numDropped += bx::uint32_cntbits(_viewMask);
|
||||
return m_num;
|
||||
}
|
||||
|
||||
m_constEnd = m_constantBuffer->getPos();
|
||||
|
||||
BX_WARN(invalidHandle != m_key.m_program, "Program with invalid handle");
|
||||
if (invalidHandle != m_key.m_program)
|
||||
{
|
||||
m_key.m_depth = _depth;
|
||||
|
||||
for (uint32_t id = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, id += 1, ntz = bx::uint32_cnttz(viewMask) )
|
||||
{
|
||||
viewMask >>= ntz;
|
||||
id += ntz;
|
||||
|
||||
m_key.m_view = id;
|
||||
m_key.m_seq = s_ctx->m_seq[id] & s_ctx->m_seqMask[id];
|
||||
s_ctx->m_seq[id]++;
|
||||
|
||||
uint64_t key = m_key.encodeDraw();
|
||||
m_sortKeys[m_num] = key;
|
||||
m_sortValues[m_num] = m_numRenderItems;
|
||||
++m_num;
|
||||
}
|
||||
|
||||
m_draw.m_constBegin = m_constBegin;
|
||||
m_draw.m_constEnd = m_constEnd;
|
||||
m_draw.m_flags |= m_flags;
|
||||
m_renderItem[m_numRenderItems].draw = m_draw;
|
||||
++m_numRenderItems;
|
||||
}
|
||||
|
||||
m_draw.clear();
|
||||
m_constBegin = m_constEnd;
|
||||
m_flags = BGFX_STATE_NONE;
|
||||
|
||||
return m_num;
|
||||
}
|
||||
|
||||
uint32_t Frame::dispatch(uint8_t _id, ProgramHandle _handle, uint16_t _numX, uint16_t _numY, uint16_t _numZ)
|
||||
{
|
||||
if (m_discard)
|
||||
|
@ -2571,24 +2520,12 @@ again:
|
|||
s_ctx->setViewRect(_id, _x, _y, _width, _height);
|
||||
}
|
||||
|
||||
void setViewRectMask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
s_ctx->setViewRectMask(_viewMask, _x, _y, _width, _height);
|
||||
}
|
||||
|
||||
void setViewScissor(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
s_ctx->setViewScissor(_id, _x, _y, _width, _height);
|
||||
}
|
||||
|
||||
void setViewScissorMask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
s_ctx->setViewScissorMask(_viewMask, _x, _y, _width, _height);
|
||||
}
|
||||
|
||||
void setViewClear(uint8_t _id, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
|
@ -2601,48 +2538,24 @@ again:
|
|||
s_ctx->setViewClear(_id, _flags, _depth, _stencil, _0, _1, _2, _3, _4, _5, _6, _7);
|
||||
}
|
||||
|
||||
void setViewClearMask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
s_ctx->setViewClearMask(_viewMask, _flags, _rgba, _depth, _stencil);
|
||||
}
|
||||
|
||||
void setViewSeq(uint8_t _id, bool _enabled)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
s_ctx->setViewSeq(_id, _enabled);
|
||||
}
|
||||
|
||||
void setViewSeqMask(uint32_t _viewMask, bool _enabled)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
s_ctx->setViewSeqMask(_viewMask, _enabled);
|
||||
}
|
||||
|
||||
void setViewFrameBuffer(uint8_t _id, FrameBufferHandle _handle)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
s_ctx->setViewFrameBuffer(_id, _handle);
|
||||
}
|
||||
|
||||
void setViewFrameBufferMask(uint32_t _mask, FrameBufferHandle _handle)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
s_ctx->setViewFrameBufferMask(_mask, _handle);
|
||||
}
|
||||
|
||||
void setViewTransform(uint8_t _id, const void* _view, const void* _proj)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
s_ctx->setViewTransform(_id, _view, _proj);
|
||||
}
|
||||
|
||||
void setViewTransformMask(uint32_t _viewMask, const void* _view, const void* _proj)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
s_ctx->setViewTransformMask(_viewMask, _view, _proj);
|
||||
}
|
||||
|
||||
void setMarker(const char* _marker)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
|
@ -2775,12 +2688,6 @@ again:
|
|||
return s_ctx->submit(_id, _depth);
|
||||
}
|
||||
|
||||
uint32_t submitMask(uint32_t _viewMask, int32_t _depth)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
return s_ctx->submitMask(_viewMask, _depth);
|
||||
}
|
||||
|
||||
void setImage(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle, uint8_t _mip, TextureFormat::Enum _format, Access::Enum _access)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
|
@ -3243,21 +3150,11 @@ BGFX_C_API void bgfx_set_view_rect(uint8_t _id, uint16_t _x, uint16_t _y, uint16
|
|||
bgfx::setViewRect(_id, _x, _y, _width, _height);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_set_view_rect_mask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
|
||||
{
|
||||
bgfx::setViewRectMask(_viewMask, _x, _y, _width, _height);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_set_view_scissor(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
|
||||
{
|
||||
bgfx::setViewScissor(_id, _x, _y, _width, _height);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_set_view_scissor_mask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
|
||||
{
|
||||
bgfx::setViewScissorMask(_viewMask, _x, _y, _width, _height);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_set_view_clear(uint8_t _id, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil)
|
||||
{
|
||||
bgfx::setViewClear(_id, _flags, _rgba, _depth, _stencil);
|
||||
|
@ -3268,43 +3165,22 @@ BGFX_C_API void bgfx_set_view_clear_mrt(uint8_t _id, uint8_t _flags, float _dept
|
|||
bgfx::setViewClear(_id, _flags, _depth, _stencil, _0, _1, _2, _3, _4, _5, _6, _7);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_set_view_clear_mask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil)
|
||||
{
|
||||
bgfx::setViewClearMask(_viewMask, _flags, _rgba, _depth, _stencil);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_set_view_seq(uint8_t _id, bool _enabled)
|
||||
{
|
||||
bgfx::setViewSeq(_id, _enabled);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_set_view_seq_mask(uint32_t _viewMask, bool _enabled)
|
||||
{
|
||||
bgfx::setViewSeqMask(_viewMask, _enabled);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_set_view_frame_buffer(uint8_t _id, bgfx_frame_buffer_handle_t _handle)
|
||||
{
|
||||
union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle = { _handle };
|
||||
bgfx::setViewFrameBuffer(_id, handle.cpp);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_set_view_frame_buffer_mask(uint32_t _viewMask, bgfx_frame_buffer_handle_t _handle)
|
||||
{
|
||||
union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle = { _handle };
|
||||
bgfx::setViewFrameBufferMask(_viewMask, handle.cpp);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_set_view_transform(uint8_t _id, const void* _view, const void* _proj)
|
||||
{
|
||||
bgfx::setViewTransform(_id, _view, _proj);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_set_view_transform_mask(uint32_t _viewMask, const void* _view, const void* _proj)
|
||||
{
|
||||
bgfx::setViewTransformMask(_viewMask, _view, _proj);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_set_marker(const char* _marker)
|
||||
{
|
||||
bgfx::setMarker(_marker);
|
||||
|
@ -3410,11 +3286,6 @@ BGFX_C_API uint32_t bgfx_submit(uint8_t _id, int32_t _depth)
|
|||
return bgfx::submit(_id, _depth);
|
||||
}
|
||||
|
||||
BGFX_C_API uint32_t bgfx_submit_mask(uint32_t _viewMask, int32_t _depth)
|
||||
{
|
||||
return bgfx::submitMask(_viewMask, _depth);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_set_image(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_texture_format_t _format, bgfx_access_t _access)
|
||||
{
|
||||
union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } sampler = { _sampler };
|
||||
|
|
73
src/bgfx_p.h
73
src/bgfx_p.h
|
@ -1331,7 +1331,6 @@ namespace bgfx
|
|||
}
|
||||
|
||||
uint32_t submit(uint8_t _id, int32_t _depth);
|
||||
uint32_t submitMask(uint32_t _viewMask, int32_t _depth);
|
||||
uint32_t dispatch(uint8_t _id, ProgramHandle _handle, uint16_t _ngx, uint16_t _ngy, uint16_t _ngz);
|
||||
void sort();
|
||||
|
||||
|
@ -2652,17 +2651,6 @@ namespace bgfx
|
|||
rect.m_height = bx::uint16_max(_height, 1);
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(void setViewRectMask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height) )
|
||||
{
|
||||
for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) )
|
||||
{
|
||||
viewMask >>= ntz;
|
||||
view += ntz;
|
||||
|
||||
setViewRect( (uint8_t)view, _x, _y, _width, _height);
|
||||
}
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(void setViewScissor(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height) )
|
||||
{
|
||||
Rect& scissor = m_scissor[_id];
|
||||
|
@ -2672,17 +2660,6 @@ namespace bgfx
|
|||
scissor.m_height = _height;
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(void setViewScissorMask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height) )
|
||||
{
|
||||
for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) )
|
||||
{
|
||||
viewMask >>= ntz;
|
||||
view += ntz;
|
||||
|
||||
setViewScissor( (uint8_t)view, _x, _y, _width, _height);
|
||||
}
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(void setViewClear(uint8_t _id, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil) )
|
||||
{
|
||||
Clear& clear = m_clear[_id];
|
||||
|
@ -2713,50 +2690,16 @@ namespace bgfx
|
|||
clear.m_stencil = _stencil;
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(void setViewClearMask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil) )
|
||||
{
|
||||
for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) )
|
||||
{
|
||||
viewMask >>= ntz;
|
||||
view += ntz;
|
||||
|
||||
setViewClear( (uint8_t)view, _flags, _rgba, _depth, _stencil);
|
||||
}
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(void setViewSeq(uint8_t _id, bool _enabled) )
|
||||
{
|
||||
m_seqMask[_id] = _enabled ? 0xffff : 0x0;
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(void setViewSeqMask(uint32_t _viewMask, bool _enabled) )
|
||||
{
|
||||
uint16_t mask = _enabled ? 0xffff : 0x0;
|
||||
for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) )
|
||||
{
|
||||
viewMask >>= ntz;
|
||||
view += ntz;
|
||||
|
||||
m_seqMask[view] = mask;
|
||||
}
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(void setViewFrameBuffer(uint8_t _id, FrameBufferHandle _handle) )
|
||||
{
|
||||
m_fb[_id] = _handle;
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(void setViewFrameBufferMask(uint32_t _viewMask, FrameBufferHandle _handle) )
|
||||
{
|
||||
for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) )
|
||||
{
|
||||
viewMask >>= ntz;
|
||||
view += ntz;
|
||||
|
||||
m_fb[view] = _handle;
|
||||
}
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(void setViewTransform(uint8_t _id, const void* _view, const void* _proj) )
|
||||
{
|
||||
if (NULL != _view)
|
||||
|
@ -2778,17 +2721,6 @@ namespace bgfx
|
|||
}
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(void setViewTransformMask(uint32_t _viewMask, const void* _view, const void* _proj) )
|
||||
{
|
||||
for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) )
|
||||
{
|
||||
viewMask >>= ntz;
|
||||
view += ntz;
|
||||
|
||||
setViewTransform( (uint8_t)view, _view, _proj);
|
||||
}
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(void setMarker(const char* _marker) )
|
||||
{
|
||||
m_submit->setMarker(_marker);
|
||||
|
@ -2898,11 +2830,6 @@ namespace bgfx
|
|||
return m_submit->submit(_id, _depth);
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(uint32_t submitMask(uint32_t _viewMask, int32_t _depth) )
|
||||
{
|
||||
return m_submit->submitMask(_viewMask, _depth);
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(void setImage(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle, uint8_t _mip, TextureFormat::Enum _format, Access::Enum _access) )
|
||||
{
|
||||
m_submit->setImage(_stage, _sampler, _handle, _mip, _format, _access);
|
||||
|
|
|
@ -7,7 +7,11 @@
|
|||
|
||||
#if BGFX_CONFIG_RENDERER_DIRECT3D11
|
||||
# include "renderer_d3d11.h"
|
||||
|
||||
# if BGFX_CONFIG_DEBUG_PIX
|
||||
# include <psapi.h>
|
||||
# include <renderdoc/renderdoc_app.h>
|
||||
# endif // BGFX_CONFIG_DEBUG_PIX
|
||||
|
||||
namespace bgfx
|
||||
{
|
||||
|
@ -403,6 +407,47 @@ namespace bgfx
|
|||
return false;
|
||||
};
|
||||
|
||||
#if BGFX_CONFIG_DEBUG_PIX && BX_PLATFORM_WINDOWS
|
||||
bool findModule(const char* _name)
|
||||
{
|
||||
HANDLE process = GetCurrentProcess();
|
||||
DWORD size;
|
||||
BOOL result = EnumProcessModules(process
|
||||
, NULL
|
||||
, 0
|
||||
, &size
|
||||
);
|
||||
if (0 != result)
|
||||
{
|
||||
HMODULE* modules = (HMODULE*)alloca(size);
|
||||
result = EnumProcessModules(process
|
||||
, modules
|
||||
, size
|
||||
, &size
|
||||
);
|
||||
|
||||
if (0 != result)
|
||||
{
|
||||
char moduleName[MAX_PATH];
|
||||
for (uint32_t ii = 0, num = uint32_t(size/sizeof(HMODULE) ); ii < num; ++ii)
|
||||
{
|
||||
result = GetModuleBaseNameA(process
|
||||
, modules[ii]
|
||||
, moduleName
|
||||
, BX_COUNTOF(moduleName)
|
||||
);
|
||||
if (0 != result
|
||||
&& 0 == bx::stricmp(_name, moduleName) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#define RENDERDOC_IMPORT \
|
||||
RENDERDOC_IMPORT_FUNC(RENDERDOC_SetLogFile); \
|
||||
RENDERDOC_IMPORT_FUNC(RENDERDOC_GetCapture); \
|
||||
|
@ -425,6 +470,12 @@ RENDERDOC_IMPORT
|
|||
|
||||
void* loadRenderDoc()
|
||||
{
|
||||
// Skip loading RenderDoc when IntelGPA is present to avoid RenderDoc crash.
|
||||
if (findModule(BX_ARCH_32BIT ? "shimloader32.dll" : "shimloader64.dll") )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* renderdocdll = bx::dlopen("renderdoc.dll");
|
||||
|
||||
if (NULL != renderdocdll)
|
||||
|
@ -474,6 +525,16 @@ RENDERDOC_IMPORT
|
|||
bx::dlclose(_renderdocdll);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void* loadRenderDoc()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void unloadRenderDoc(void*)
|
||||
{
|
||||
}
|
||||
#endif // BGFX_CONFIG_DEBUG_PIX
|
||||
|
||||
struct RendererContextD3D11 : public RendererContextI
|
||||
{
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#else
|
||||
# include <d3d11.h>
|
||||
#endif // BX_COMPILER_MSVC
|
||||
|
||||
#include "renderer_d3d.h"
|
||||
|
||||
#define D3DCOLOR_ARGB(_a, _r, _g, _b) ( (DWORD)( ( ( (_a)&0xff)<<24)|( ( (_r)&0xff)<<16)|( ( (_g)&0xff)<<8)|( (_b)&0xff) ) )
|
||||
|
|
|
@ -533,6 +533,19 @@ namespace bgfx
|
|||
m_fmtDepth = D3DFMT_D24FS8;
|
||||
#endif // BX_PLATFORM_WINDOWS
|
||||
|
||||
{
|
||||
IDirect3DSwapChain9* swapChain;
|
||||
DX_CHECK(m_device->GetSwapChain(0, &swapChain) );
|
||||
|
||||
// GPA increases swapchain ref count.
|
||||
//
|
||||
// This causes assert in debug. When debugger is present refcount
|
||||
// checks are off.
|
||||
setGraphicsDebuggerPresent(1 != getRefCount(swapChain) );
|
||||
|
||||
DX_RELEASE(swapChain, 0);
|
||||
}
|
||||
|
||||
postReset();
|
||||
|
||||
m_initialized = true;
|
||||
|
|
Loading…
Reference in a new issue