summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/src
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bgfx/src')
-rw-r--r--3rdparty/bgfx/src/amalgamated.cpp4
-rw-r--r--3rdparty/bgfx/src/bgfx.cpp504
-rw-r--r--3rdparty/bgfx/src/bgfx_compute.sh30
-rw-r--r--3rdparty/bgfx/src/bgfx_p.h299
-rw-r--r--3rdparty/bgfx/src/bgfx_shader.sh62
-rw-r--r--3rdparty/bgfx/src/charset.h13
-rw-r--r--3rdparty/bgfx/src/config.h48
-rw-r--r--3rdparty/bgfx/src/debug_renderdoc.cpp6
-rw-r--r--3rdparty/bgfx/src/fs_clear0.bin.h12
-rw-r--r--3rdparty/bgfx/src/fs_clear0.sc2
-rw-r--r--3rdparty/bgfx/src/fs_clear1.bin.h14
-rw-r--r--3rdparty/bgfx/src/fs_clear1.sc2
-rw-r--r--3rdparty/bgfx/src/fs_clear2.bin.h16
-rw-r--r--3rdparty/bgfx/src/fs_clear2.sc2
-rw-r--r--3rdparty/bgfx/src/fs_clear3.bin.h17
-rw-r--r--3rdparty/bgfx/src/fs_clear3.sc2
-rw-r--r--3rdparty/bgfx/src/fs_clear4.bin.h17
-rw-r--r--3rdparty/bgfx/src/fs_clear4.sc2
-rw-r--r--3rdparty/bgfx/src/fs_clear5.bin.h17
-rw-r--r--3rdparty/bgfx/src/fs_clear5.sc2
-rw-r--r--3rdparty/bgfx/src/fs_clear6.bin.h17
-rw-r--r--3rdparty/bgfx/src/fs_clear6.sc2
-rw-r--r--3rdparty/bgfx/src/fs_clear7.bin.h17
-rw-r--r--3rdparty/bgfx/src/fs_clear7.sc2
-rw-r--r--3rdparty/bgfx/src/fs_debugfont.bin.h85
-rw-r--r--3rdparty/bgfx/src/glcontext_nsgl.mm2
-rw-r--r--3rdparty/bgfx/src/glimports.h6
-rw-r--r--3rdparty/bgfx/src/hmd.cpp212
-rw-r--r--3rdparty/bgfx/src/hmd.h101
-rw-r--r--3rdparty/bgfx/src/hmd_openvr.cpp2
-rw-r--r--3rdparty/bgfx/src/hmd_ovr.cpp299
-rw-r--r--3rdparty/bgfx/src/hmd_ovr.h169
-rw-r--r--3rdparty/bgfx/src/image.cpp73
-rw-r--r--3rdparty/bgfx/src/image.h2
-rw-r--r--3rdparty/bgfx/src/makefile4
-rw-r--r--3rdparty/bgfx/src/renderer.h5
-rw-r--r--3rdparty/bgfx/src/renderer_d3d11.cpp492
-rw-r--r--3rdparty/bgfx/src/renderer_d3d11.h25
-rw-r--r--3rdparty/bgfx/src/renderer_d3d12.cpp52
-rw-r--r--3rdparty/bgfx/src/renderer_d3d9.cpp60
-rw-r--r--3rdparty/bgfx/src/renderer_gl.cpp643
-rw-r--r--3rdparty/bgfx/src/renderer_gl.h48
-rw-r--r--3rdparty/bgfx/src/renderer_gnm.cpp44
-rw-r--r--3rdparty/bgfx/src/renderer_mtl.h1
-rw-r--r--3rdparty/bgfx/src/renderer_mtl.mm155
-rw-r--r--3rdparty/bgfx/src/renderer_noop.cpp (renamed from 3rdparty/bgfx/src/renderer_null.cpp)55
-rw-r--r--3rdparty/bgfx/src/renderer_vk.cpp6
-rw-r--r--3rdparty/bgfx/src/vertexdecl.cpp1
-rw-r--r--3rdparty/bgfx/src/vs_clear.bin.h42
-rw-r--r--3rdparty/bgfx/src/vs_debugfont.bin.h74
50 files changed, 2217 insertions, 1550 deletions
diff --git a/3rdparty/bgfx/src/amalgamated.cpp b/3rdparty/bgfx/src/amalgamated.cpp
index 90059ad5585..9e5de6e2b86 100644
--- a/3rdparty/bgfx/src/amalgamated.cpp
+++ b/3rdparty/bgfx/src/amalgamated.cpp
@@ -9,15 +9,17 @@
#include "glcontext_ppapi.cpp"
#include "glcontext_wgl.cpp"
#include "image.cpp"
+#include "hmd.cpp"
#include "hmd_ovr.cpp"
#include "hmd_openvr.cpp"
#include "debug_renderdoc.cpp"
#include "renderer_d3d9.cpp"
#include "renderer_d3d11.cpp"
#include "renderer_d3d12.cpp"
-#include "renderer_null.cpp"
+#include "renderer_noop.cpp"
#include "renderer_gl.cpp"
#include "renderer_vk.cpp"
+#include "renderer_gnm.cpp"
#include "shader_dxbc.cpp"
#include "shader_dx9bc.cpp"
#include "shader_spirv.cpp"
diff --git a/3rdparty/bgfx/src/bgfx.cpp b/3rdparty/bgfx/src/bgfx.cpp
index 627c90b85b2..02b76fa8b09 100644
--- a/3rdparty/bgfx/src/bgfx.cpp
+++ b/3rdparty/bgfx/src/bgfx.cpp
@@ -426,6 +426,87 @@ namespace bgfx
va_end(argList);
}
+#include "vs_debugfont.bin.h"
+#include "fs_debugfont.bin.h"
+#include "vs_clear.bin.h"
+#include "fs_clear0.bin.h"
+#include "fs_clear1.bin.h"
+#include "fs_clear2.bin.h"
+#include "fs_clear3.bin.h"
+#include "fs_clear4.bin.h"
+#include "fs_clear5.bin.h"
+#include "fs_clear6.bin.h"
+#include "fs_clear7.bin.h"
+
+ struct EmbeddedShader
+ {
+ struct Data
+ {
+ bgfx::RendererType::Enum type;
+ const uint8_t* data;
+ uint32_t size;
+ };
+
+ const char* name;
+ Data data[RendererType::Count];
+ };
+
+#define BGFX_DECLARE_SHADER_EMBEDDED(_name) \
+ { \
+ #_name, \
+ { \
+ { bgfx::RendererType::Direct3D9, BX_CONCATENATE(_name, _dx9 ), sizeof(BX_CONCATENATE(_name, _dx9 ) ) }, \
+ { bgfx::RendererType::Direct3D11, BX_CONCATENATE(_name, _dx11), sizeof(BX_CONCATENATE(_name, _dx11) ) }, \
+ { bgfx::RendererType::Direct3D12, BX_CONCATENATE(_name, _dx11), sizeof(BX_CONCATENATE(_name, _dx11) ) }, \
+ { bgfx::RendererType::Gnm, BX_CONCATENATE(_name, _pssl), BX_CONCATENATE(_name, _pssl_size) }, \
+ { bgfx::RendererType::Metal, BX_CONCATENATE(_name, _mtl ), sizeof(BX_CONCATENATE(_name, _mtl ) ) }, \
+ { bgfx::RendererType::OpenGL, BX_CONCATENATE(_name, _glsl), sizeof(BX_CONCATENATE(_name, _glsl) ) }, \
+ { bgfx::RendererType::OpenGLES, BX_CONCATENATE(_name, _glsl), sizeof(BX_CONCATENATE(_name, _glsl) ) }, \
+ { bgfx::RendererType::Vulkan, BX_CONCATENATE(_name, _glsl), sizeof(BX_CONCATENATE(_name, _glsl) ) }, \
+ { bgfx::RendererType::Count, NULL, 0 }, \
+ } \
+ }
+
+ static const EmbeddedShader s_embeddedShaders[] =
+ {
+ BGFX_DECLARE_SHADER_EMBEDDED(vs_debugfont),
+ BGFX_DECLARE_SHADER_EMBEDDED(fs_debugfont),
+
+ BGFX_DECLARE_SHADER_EMBEDDED(vs_clear),
+
+ BGFX_DECLARE_SHADER_EMBEDDED(fs_clear0),
+ BGFX_DECLARE_SHADER_EMBEDDED(fs_clear1),
+ BGFX_DECLARE_SHADER_EMBEDDED(fs_clear2),
+ BGFX_DECLARE_SHADER_EMBEDDED(fs_clear3),
+ BGFX_DECLARE_SHADER_EMBEDDED(fs_clear4),
+ BGFX_DECLARE_SHADER_EMBEDDED(fs_clear5),
+ BGFX_DECLARE_SHADER_EMBEDDED(fs_clear6),
+ BGFX_DECLARE_SHADER_EMBEDDED(fs_clear7),
+
+ { NULL, { { bgfx::RendererType::Count, NULL, 0 } } }
+ };
+
+ static ShaderHandle createEmbeddedShader(RendererType::Enum _type, const char* _name)
+ {
+ for (const EmbeddedShader* es = s_embeddedShaders; NULL != es->name; ++es)
+ {
+ if (0 == strcmp(_name, es->name) )
+ {
+ for (const EmbeddedShader::Data* esd = es->data; RendererType::Count != esd->type; ++esd)
+ {
+ if (_type == esd->type)
+ {
+ return createShader(makeRef(esd->data, esd->size) );
+ }
+ }
+ }
+ }
+
+ ShaderHandle handle = BGFX_INVALID_HANDLE;
+ return handle;
+ }
+
+
#include "charset.h"
void charsetFillTexture(const uint8_t* _charset, uint8_t* _rgba, uint32_t _height, uint32_t _pitch, uint32_t _bpp)
@@ -461,10 +542,10 @@ namespace bgfx
.add(Attrib::TexCoord0, 2, AttribType::Float)
.end();
- uint16_t width = 2048;
+ uint16_t width = 2048;
uint16_t height = 24;
- uint8_t bpp = 1;
- uint32_t pitch = width*bpp;
+ uint8_t bpp = 1;
+ uint32_t pitch = width*bpp;
const Memory* mem;
@@ -481,49 +562,8 @@ namespace bgfx
, mem
);
- switch (g_caps.rendererType)
- {
- case RendererType::Direct3D9:
- mem = makeRef(vs_debugfont_dx9, sizeof(vs_debugfont_dx9) );
- break;
-
- case RendererType::Direct3D11:
- case RendererType::Direct3D12:
- mem = makeRef(vs_debugfont_dx11, sizeof(vs_debugfont_dx11) );
- break;
-
- case RendererType::Metal:
- mem = makeRef(vs_debugfont_mtl, sizeof(vs_debugfont_mtl) );
- break;
-
- default:
- mem = makeRef(vs_debugfont_glsl, sizeof(vs_debugfont_glsl) );
- break;
- }
-
- ShaderHandle vsh = createShader(mem);
-
- switch (g_caps.rendererType)
- {
- case RendererType::Direct3D9:
- mem = makeRef(fs_debugfont_dx9, sizeof(fs_debugfont_dx9) );
- break;
-
- case RendererType::Direct3D11:
- case RendererType::Direct3D12:
- mem = makeRef(fs_debugfont_dx11, sizeof(fs_debugfont_dx11) );
- break;
-
- case RendererType::Metal:
- mem = makeRef(fs_debugfont_mtl, sizeof(fs_debugfont_mtl) );
- break;
-
- default:
- mem = makeRef(fs_debugfont_glsl, sizeof(fs_debugfont_glsl) );
- break;
- }
-
- ShaderHandle fsh = createShader(mem);
+ ShaderHandle vsh = createEmbeddedShader(g_caps.rendererType, "vs_debugfont");
+ ShaderHandle fsh = createEmbeddedShader(g_caps.rendererType, "fs_debugfont");
m_program = createProgram(vsh, fsh, true);
@@ -535,7 +575,11 @@ namespace bgfx
{
BGFX_CHECK_MAIN_THREAD();
- destroyProgram(m_program);
+ if (isValid(m_program) )
+ {
+ destroyProgram(m_program);
+ }
+
destroyTexture(m_texture);
s_ctx->destroyTransientVertexBuffer(m_vb);
s_ctx->destroyTransientIndexBuffer(m_ib);
@@ -651,123 +695,21 @@ namespace bgfx
{
BGFX_CHECK_MAIN_THREAD();
- if (RendererType::Null != g_caps.rendererType)
+ if (RendererType::Noop != g_caps.rendererType)
{
m_decl
.begin()
.add(Attrib::Position, 3, AttribType::Float)
.end();
- ShaderHandle vsh = BGFX_INVALID_HANDLE;
-
- struct Mem
- {
- Mem(const void* _data, size_t _size)
- : data(_data)
- , size(_size)
- {
- }
-
- const void* data;
- size_t size;
- };
-
- const Memory* fragMem[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
- if (RendererType::Direct3D9 == g_caps.rendererType)
- {
- vsh = createShader(makeRef(vs_clear_dx9, sizeof(vs_clear_dx9) ) );
-
- const Mem mem[] =
- {
- Mem(fs_clear0_dx9, sizeof(fs_clear0_dx9) ),
- Mem(fs_clear1_dx9, sizeof(fs_clear1_dx9) ),
- Mem(fs_clear2_dx9, sizeof(fs_clear2_dx9) ),
- Mem(fs_clear3_dx9, sizeof(fs_clear3_dx9) ),
- Mem(fs_clear4_dx9, sizeof(fs_clear4_dx9) ),
- Mem(fs_clear5_dx9, sizeof(fs_clear5_dx9) ),
- Mem(fs_clear6_dx9, sizeof(fs_clear6_dx9) ),
- Mem(fs_clear7_dx9, sizeof(fs_clear7_dx9) ),
- };
-
- for (uint32_t ii = 0, num = g_caps.maxFBAttachments; ii < num; ++ii)
- {
- fragMem[ii] = makeRef(mem[ii].data, uint32_t(mem[ii].size) );
- }
- }
- else if (RendererType::Direct3D11 == g_caps.rendererType
- || RendererType::Direct3D12 == g_caps.rendererType)
- {
- vsh = createShader(makeRef(vs_clear_dx11, sizeof(vs_clear_dx11) ) );
-
- const Mem mem[] =
- {
- Mem(fs_clear0_dx11, sizeof(fs_clear0_dx11) ),
- Mem(fs_clear1_dx11, sizeof(fs_clear1_dx11) ),
- Mem(fs_clear2_dx11, sizeof(fs_clear2_dx11) ),
- Mem(fs_clear3_dx11, sizeof(fs_clear3_dx11) ),
- Mem(fs_clear4_dx11, sizeof(fs_clear4_dx11) ),
- Mem(fs_clear5_dx11, sizeof(fs_clear5_dx11) ),
- Mem(fs_clear6_dx11, sizeof(fs_clear6_dx11) ),
- Mem(fs_clear7_dx11, sizeof(fs_clear7_dx11) ),
- };
-
- for (uint32_t ii = 0, num = g_caps.maxFBAttachments; ii < num; ++ii)
- {
- fragMem[ii] = makeRef(mem[ii].data, uint32_t(mem[ii].size) );
- }
- }
- else if (RendererType::OpenGLES == g_caps.rendererType
- || RendererType::OpenGL == g_caps.rendererType
- || RendererType::Vulkan == g_caps.rendererType)
- {
- vsh = createShader(makeRef(vs_clear_glsl, sizeof(vs_clear_glsl) ) );
+ ShaderHandle vsh = createEmbeddedShader(g_caps.rendererType, "vs_clear");
- const Mem mem[] =
- {
- Mem(fs_clear0_glsl, sizeof(fs_clear0_glsl) ),
- Mem(fs_clear1_glsl, sizeof(fs_clear1_glsl) ),
- Mem(fs_clear2_glsl, sizeof(fs_clear2_glsl) ),
- Mem(fs_clear3_glsl, sizeof(fs_clear3_glsl) ),
- Mem(fs_clear4_glsl, sizeof(fs_clear4_glsl) ),
- Mem(fs_clear5_glsl, sizeof(fs_clear5_glsl) ),
- Mem(fs_clear6_glsl, sizeof(fs_clear6_glsl) ),
- Mem(fs_clear7_glsl, sizeof(fs_clear7_glsl) ),
- };
-
- for (uint32_t ii = 0, num = g_caps.maxFBAttachments; ii < num; ++ii)
- {
- fragMem[ii] = makeRef(mem[ii].data, uint32_t(mem[ii].size) );
- }
- }
- else if (RendererType::Metal == g_caps.rendererType)
+ for (uint32_t ii = 0, num = g_caps.limits.maxFBAttachments; ii < num; ++ii)
{
- vsh = createShader(makeRef(vs_clear_mtl, sizeof(vs_clear_mtl) ) );
+ char name[32];
+ bx::snprintf(name, BX_COUNTOF(name), "fs_clear%d", ii);
+ ShaderHandle fsh = createEmbeddedShader(g_caps.rendererType, name);
- const Mem mem[] =
- {
- Mem(fs_clear0_mtl, sizeof(fs_clear0_mtl) ),
- Mem(fs_clear1_mtl, sizeof(fs_clear1_mtl) ),
- Mem(fs_clear2_mtl, sizeof(fs_clear2_mtl) ),
- Mem(fs_clear3_mtl, sizeof(fs_clear3_mtl) ),
- Mem(fs_clear4_mtl, sizeof(fs_clear4_mtl) ),
- Mem(fs_clear5_mtl, sizeof(fs_clear5_mtl) ),
- Mem(fs_clear6_mtl, sizeof(fs_clear6_mtl) ),
- Mem(fs_clear7_mtl, sizeof(fs_clear7_mtl) ),
- };
-
- for (uint32_t ii = 0, num = g_caps.maxFBAttachments; ii < num; ++ii)
- {
- fragMem[ii] = makeRef(mem[ii].data, uint32_t(mem[ii].size) );
- }
- }
- else
- {
- BGFX_FATAL(false, Fatal::UnableToInitialize, "Unknown renderer type %d", g_caps.rendererType);
- }
-
- for (uint32_t ii = 0, num = g_caps.maxFBAttachments; ii < num; ++ii)
- {
- ShaderHandle fsh = createShader(fragMem[ii]);
m_program[ii] = createProgram(vsh, fsh);
BX_CHECK(isValid(m_program[ii]), "Failed to create clear quad program.");
destroyShader(fsh);
@@ -783,9 +725,9 @@ namespace bgfx
{
BGFX_CHECK_MAIN_THREAD();
- if (RendererType::Null != g_caps.rendererType)
+ if (RendererType::Noop != g_caps.rendererType)
{
- for (uint32_t ii = 0, num = g_caps.maxFBAttachments; ii < num; ++ii)
+ for (uint32_t ii = 0, num = g_caps.limits.maxFBAttachments; ii < num; ++ii)
{
if (isValid(m_program[ii]) )
{
@@ -898,6 +840,18 @@ namespace bgfx
m_draw.m_constEnd = m_uniformEnd;
m_draw.m_stateFlags |= m_stateFlags;
+ uint32_t numVertices = UINT32_MAX;
+ for (uint32_t idx = 0, streamMask = m_draw.m_streamMask, ntz = bx::uint32_cnttz(streamMask)
+ ; 0 != streamMask
+ ; streamMask >>= 1, idx += 1, ntz = bx::uint32_cnttz(streamMask)
+ )
+ {
+ streamMask >>= ntz;
+ idx += ntz;
+ numVertices = bx::uint32_min(numVertices, m_numVertices[idx]);
+ }
+ m_draw.m_numVertices = numVertices;
+
if (isValid(_occlusionQuery) )
{
BX_CHECK(!isValid(m_draw.m_occlusionQuery), "");
@@ -1026,7 +980,7 @@ namespace bgfx
if (s_ctx->renderFrame() )
{
Context* ctx = s_ctx;
- ctx->gameSemWait();
+ ctx->apiSemWait();
s_ctx = NULL;
ctx->renderSemPost();
return RenderFrame::Exiting;
@@ -1080,34 +1034,47 @@ namespace bgfx
static const CapsFlags s_capsFlags[] =
{
#define CAPS_FLAGS(_x) { _x, #_x }
- CAPS_FLAGS(BGFX_CAPS_TEXTURE_COMPARE_LEQUAL),
- CAPS_FLAGS(BGFX_CAPS_TEXTURE_COMPARE_ALL),
- CAPS_FLAGS(BGFX_CAPS_TEXTURE_3D),
- CAPS_FLAGS(BGFX_CAPS_VERTEX_ATTRIB_HALF),
- CAPS_FLAGS(BGFX_CAPS_VERTEX_ATTRIB_UINT10),
- CAPS_FLAGS(BGFX_CAPS_INSTANCING),
- CAPS_FLAGS(BGFX_CAPS_RENDERER_MULTITHREADED),
- CAPS_FLAGS(BGFX_CAPS_FRAGMENT_DEPTH),
+ CAPS_FLAGS(BGFX_CAPS_ALPHA_TO_COVERAGE),
CAPS_FLAGS(BGFX_CAPS_BLEND_INDEPENDENT),
CAPS_FLAGS(BGFX_CAPS_COMPUTE),
+ CAPS_FLAGS(BGFX_CAPS_CONSERVATIVE_RASTER),
+ CAPS_FLAGS(BGFX_CAPS_DRAW_INDIRECT),
+ CAPS_FLAGS(BGFX_CAPS_FRAGMENT_DEPTH),
CAPS_FLAGS(BGFX_CAPS_FRAGMENT_ORDERING),
- CAPS_FLAGS(BGFX_CAPS_SWAP_CHAIN),
+ CAPS_FLAGS(BGFX_CAPS_GRAPHICS_DEBUGGER),
+ CAPS_FLAGS(BGFX_CAPS_HIDPI),
CAPS_FLAGS(BGFX_CAPS_HMD),
CAPS_FLAGS(BGFX_CAPS_INDEX32),
- CAPS_FLAGS(BGFX_CAPS_DRAW_INDIRECT),
- CAPS_FLAGS(BGFX_CAPS_HIDPI),
- CAPS_FLAGS(BGFX_CAPS_TEXTURE_BLIT),
- CAPS_FLAGS(BGFX_CAPS_TEXTURE_READ_BACK),
+ CAPS_FLAGS(BGFX_CAPS_INSTANCING),
CAPS_FLAGS(BGFX_CAPS_OCCLUSION_QUERY),
- CAPS_FLAGS(BGFX_CAPS_ALPHA_TO_COVERAGE),
- CAPS_FLAGS(BGFX_CAPS_CONSERVATIVE_RASTER),
+ CAPS_FLAGS(BGFX_CAPS_RENDERER_MULTITHREADED),
+ CAPS_FLAGS(BGFX_CAPS_SWAP_CHAIN),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_2D_ARRAY),
+ CAPS_FLAGS(BGFX_CAPS_TEXTURE_3D),
+ CAPS_FLAGS(BGFX_CAPS_TEXTURE_BLIT),
+ CAPS_FLAGS(BGFX_CAPS_TEXTURE_COMPARE_ALL),
+ CAPS_FLAGS(BGFX_CAPS_TEXTURE_COMPARE_LEQUAL),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_CUBE_ARRAY),
+ CAPS_FLAGS(BGFX_CAPS_TEXTURE_READ_BACK),
+ CAPS_FLAGS(BGFX_CAPS_VERTEX_ATTRIB_HALF),
+ CAPS_FLAGS(BGFX_CAPS_VERTEX_ATTRIB_UINT10),
#undef CAPS_FLAGS
};
static void dumpCaps()
{
+ BX_TRACE("");
+
+ RendererType::Enum renderers[RendererType::Count];
+ uint8_t num = getSupportedRenderers(BX_COUNTOF(renderers), renderers);
+
+ BX_TRACE("Supported renderer backends (%d):", num);
+ for (uint32_t ii = 0; ii < num; ++ii)
+ {
+ BX_TRACE("\t - %s", getRendererName(renderers[ii]) );
+ }
+
+ BX_TRACE("");
BX_TRACE("Sort key masks:");
BX_TRACE("\t View %016" PRIx64, SORT_KEY_VIEW_MASK);
BX_TRACE("\t Draw bit %016" PRIx64, SORT_KEY_DRAW_BIT);
@@ -1117,6 +1084,7 @@ namespace bgfx
BX_TRACE("\tC Program %016" PRIx64, SORT_KEY_COMPUTE_PROGRAM_MASK);
BX_TRACE("\tD Depth %016" PRIx64, SORT_KEY_DRAW_DEPTH_MASK);
+ BX_TRACE("");
BX_TRACE("Supported capabilities (renderer %s, vendor 0x%04x, device 0x%04x):"
, s_ctx->m_renderCtx->getRendererName()
, g_caps.vendorId
@@ -1130,6 +1098,30 @@ namespace bgfx
}
}
+ BX_TRACE("");
+ BX_TRACE("Limits:");
+#define LIMITS(_x) BX_TRACE("\t%-24s %d", #_x, g_caps.limits._x)
+ LIMITS(maxDrawCalls);
+ LIMITS(maxBlits);
+ LIMITS(maxTextureSize);
+ LIMITS(maxViews);
+ LIMITS(maxFrameBuffers);
+ LIMITS(maxFBAttachments);
+ LIMITS(maxPrograms);
+ LIMITS(maxShaders);
+ LIMITS(maxTextures);
+ LIMITS(maxTextureSamplers);
+ LIMITS(maxVertexDecls);
+ LIMITS(maxVertexStreams);
+ LIMITS(maxIndexBuffers);
+ LIMITS(maxVertexBuffers);
+ LIMITS(maxDynamicIndexBuffers);
+ LIMITS(maxDynamicVertexBuffers);
+ LIMITS(maxUniforms);
+ LIMITS(maxOcclusionQueries);
+#undef LIMITS
+
+ BX_TRACE("");
BX_TRACE("Supported texture formats:");
BX_TRACE("\t +---------------- 2D: x = supported / * = emulated");
BX_TRACE("\t |+--------------- 2D: sRGB format");
@@ -1169,11 +1161,13 @@ namespace bgfx
}
}
- BX_TRACE("Max FB attachments: %d", g_caps.maxFBAttachments);
+ BX_TRACE("");
BX_TRACE("NDC depth [%d, 1], origin %s left."
, g_caps.homogeneousDepth ? -1 : 0
, g_caps.originBottomLeft ? "bottom" : "top"
);
+
+ BX_TRACE("");
}
TextureFormat::Enum getViableTextureFormat(const ImageContainer& _imageContainer)
@@ -1312,7 +1306,7 @@ namespace bgfx
g_caps.formats[fmt] |= 0 == (g_caps.formats[fmt] & BGFX_CAPS_FORMAT_TEXTURE_CUBE) ? BGFX_CAPS_FORMAT_TEXTURE_CUBE_EMULATED : 0;
}
- for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii)
+ for (uint32_t ii = 0; ii < TextureFormat::UnknownDepth; ++ii)
{
bool convertable = imageConvert(TextureFormat::BGRA8, TextureFormat::Enum(ii) );
g_caps.formats[ii] |= 0 == (g_caps.formats[ii] & BGFX_CAPS_FORMAT_TEXTURE_2D ) && convertable ? BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED : 0;
@@ -1325,6 +1319,7 @@ namespace bgfx
g_caps.supported |= 0
| (BX_ENABLED(BGFX_CONFIG_MULTITHREADED) && !m_singleThreaded ? BGFX_CAPS_RENDERER_MULTITHREADED : 0)
+ | (isGraphicsDebuggerPresent() ? BGFX_CAPS_GRAPHICS_DEBUGGER : 0)
;
dumpCaps();
@@ -1374,10 +1369,10 @@ namespace bgfx
m_dynVertexBufferAllocator.compact();
m_dynIndexBufferAllocator.compact();
- BX_CHECK(m_vertexDeclHandle.getNumHandles() == uint16_t(m_declRef.m_vertexDeclMap.size() )
+ BX_CHECK(m_vertexDeclHandle.getNumHandles() == m_declRef.m_vertexDeclMap.getNumElements()
, "VertexDeclRef mismatch, num handles %d, handles in hash map %d."
, m_vertexDeclHandle.getNumHandles()
- , m_declRef.m_vertexDeclMap.size()
+ , m_declRef.m_vertexDeclMap.getNumElements()
);
m_declRef.shutdown(m_vertexDeclHandle);
@@ -1495,6 +1490,11 @@ namespace bgfx
m_occlusionQuerySet.clear();
}
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_UNIFORM) )
+ {
+ m_uniformSet.clear();
+ }
+
m_submit->m_capture = _capture;
BGFX_PROFILER_SCOPE(bgfx, main_thread_frame, 0xff2040ff);
@@ -1560,15 +1560,7 @@ namespace bgfx
const char* Context::getName(UniformHandle _handle) const
{
- for (UniformHashMap::const_iterator it = m_uniformHashMap.begin(), itEnd = m_uniformHashMap.end(); it != itEnd; ++it)
- {
- if (it->second.idx == _handle.idx)
- {
- return it->first.c_str();
- }
- }
-
- return NULL;
+ return m_uniformRef[_handle.idx].m_name.getPtr();
}
bool Context::renderFrame()
@@ -1581,22 +1573,23 @@ namespace bgfx
m_renderCtx->flip(m_render->m_hmd);
}
- gameSemWait();
-
- rendererExecCommands(m_render->m_cmdPre);
- if (m_rendererInitialized)
+ if (apiSemWait(BGFX_CONFIG_API_SEMAPHORE_TIMEOUT) )
{
- BGFX_PROFILER_SCOPE(bgfx, render_submit, 0xff2040ff);
- m_renderCtx->submit(m_render, m_clearQuad, m_textVideoMemBlitter);
- }
- rendererExecCommands(m_render->m_cmdPost);
+ rendererExecCommands(m_render->m_cmdPre);
+ if (m_rendererInitialized)
+ {
+ BGFX_PROFILER_SCOPE(bgfx, render_submit, 0xff2040ff);
+ m_renderCtx->submit(m_render, m_clearQuad, m_textVideoMemBlitter);
+ }
+ rendererExecCommands(m_render->m_cmdPost);
- renderSemPost();
+ renderSemPost();
- if (m_rendererInitialized
- && m_flipAfterRender)
- {
- m_renderCtx->flip(m_render->m_hmd);
+ if (m_rendererInitialized
+ && m_flipAfterRender)
+ {
+ m_renderCtx->flip(m_render->m_hmd);
+ }
}
return m_exit;
@@ -1720,6 +1713,7 @@ namespace bgfx
BGFX_RENDERER_CONTEXT(mtl);
BGFX_RENDERER_CONTEXT(gl);
BGFX_RENDERER_CONTEXT(vk);
+ BGFX_RENDERER_CONTEXT(gnm);
#undef BGFX_RENDERER_CONTEXT
@@ -1733,14 +1727,15 @@ namespace bgfx
static RendererCreator s_rendererCreator[] =
{
- { noop::rendererCreate, noop::rendererDestroy, BGFX_RENDERER_NULL_NAME, !!BGFX_CONFIG_RENDERER_NULL }, // Noop
+ { noop::rendererCreate, noop::rendererDestroy, BGFX_RENDERER_NOOP_NAME, !!BGFX_CONFIG_RENDERER_NOOP }, // Noop
{ d3d9::rendererCreate, d3d9::rendererDestroy, BGFX_RENDERER_DIRECT3D9_NAME, !!BGFX_CONFIG_RENDERER_DIRECT3D9 }, // Direct3D9
{ d3d11::rendererCreate, d3d11::rendererDestroy, BGFX_RENDERER_DIRECT3D11_NAME, !!BGFX_CONFIG_RENDERER_DIRECT3D11 }, // Direct3D11
{ d3d12::rendererCreate, d3d12::rendererDestroy, BGFX_RENDERER_DIRECT3D12_NAME, !!BGFX_CONFIG_RENDERER_DIRECT3D12 }, // Direct3D12
+ { gnm::rendererCreate, gnm::rendererDestroy, BGFX_RENDERER_GNM_NAME, !!BGFX_CONFIG_RENDERER_GNM }, // GNM
#if BX_PLATFORM_OSX || BX_PLATFORM_IOS
{ mtl::rendererCreate, mtl::rendererDestroy, BGFX_RENDERER_METAL_NAME, !!BGFX_CONFIG_RENDERER_METAL }, // Metal
#else
- { noop::rendererCreate, noop::rendererDestroy, BGFX_RENDERER_NULL_NAME, !!BGFX_CONFIG_RENDERER_NULL }, // Noop
+ { noop::rendererCreate, noop::rendererDestroy, BGFX_RENDERER_NOOP_NAME, false }, // Noop
#endif // BX_PLATFORM_OSX || BX_PLATFORM_IOS
{ gl::rendererCreate, gl::rendererDestroy, BGFX_RENDERER_OPENGL_NAME, !!BGFX_CONFIG_RENDERER_OPENGLES }, // OpenGLES
{ gl::rendererCreate, gl::rendererDestroy, BGFX_RENDERER_OPENGL_NAME, !!BGFX_CONFIG_RENDERER_OPENGL }, // OpenGL
@@ -1808,7 +1803,7 @@ namespace bgfx
score += 1000;
}
- score += RendererType::Null != renderer ? 1 : 0;
+ score += RendererType::Noop != renderer ? 1 : 0;
if (BX_ENABLED(BX_PLATFORM_WINDOWS) )
{
@@ -1828,6 +1823,15 @@ namespace bgfx
score += RendererType::Direct3D12 == renderer ? -100 : 0;
}
}
+ else if (BX_ENABLED(BX_PLATFORM_LINUX) )
+ {
+ score += RendererType::OpenGL == renderer ? 20 : 0;
+ score += RendererType::OpenGLES == renderer ? 10 : 0;
+ }
+ else if (BX_ENABLED(BX_PLATFORM_OSX) )
+ {
+ score += RendererType::OpenGL == renderer ? 20 : 0;
+ }
else if (BX_ENABLED(0
|| BX_PLATFORM_ANDROID
|| BX_PLATFORM_EMSCRIPTEN
@@ -1838,6 +1842,10 @@ namespace bgfx
{
score += RendererType::OpenGLES == renderer ? 20 : 0;
}
+ else if (BX_ENABLED(BX_PLATFORM_PS4) )
+ {
+ score += RendererType::Gnm == renderer ? 20 : 0;
+ }
else if (BX_ENABLED(0
|| BX_PLATFORM_XBOXONE
|| BX_PLATFORM_WINRT
@@ -2236,7 +2244,10 @@ namespace bgfx
void* data;
_cmdbuf.read(data);
- m_renderCtx->readTexture(handle, data);
+ uint8_t mip;
+ _cmdbuf.read(mip);
+
+ m_renderCtx->readTexture(handle, data,mip);
}
break;
@@ -2386,10 +2397,12 @@ namespace bgfx
topologySortTriList(_sort, _dst, _dstSize, _dir, _pos, _vertices, _stride, _indices, _numIndices, _index32, g_allocator);
}
- uint8_t getSupportedRenderers(RendererType::Enum _enum[RendererType::Count])
+ uint8_t getSupportedRenderers(uint8_t _max, RendererType::Enum* _enum)
{
+ _enum = _max == 0 ? NULL : _enum;
+
uint8_t num = 0;
- for (uint8_t ii = 0; ii < uint8_t(RendererType::Count); ++ii)
+ for (uint8_t ii = 0; ii < RendererType::Count; ++ii)
{
if ( (RendererType::Direct3D11 == ii || RendererType::Direct3D12 == ii)
&& windowsVersionIs(Condition::LessEqual, 0x0502) )
@@ -2397,9 +2410,17 @@ namespace bgfx
continue;
}
- if (s_rendererCreator[ii].supported)
+ if (NULL == _enum)
{
- _enum[num++] = RendererType::Enum(ii);
+ num++;
+ }
+ else
+ {
+ if (num < _max
+ && s_rendererCreator[ii].supported)
+ {
+ _enum[num++] = RendererType::Enum(ii);
+ }
}
}
@@ -2452,21 +2473,39 @@ namespace bgfx
s_callbackStub = BX_NEW(g_allocator, CallbackStub);
}
- if (!BX_ENABLED(BX_PLATFORM_EMSCRIPTEN || BX_PLATFORM_NACL)
+ if (true
+ && !BX_ENABLED(BX_PLATFORM_EMSCRIPTEN || BX_PLATFORM_NACL || BX_PLATFORM_PS4)
+ && RendererType::Noop != _type
&& NULL == g_platformData.ndt
&& NULL == g_platformData.nwh
&& NULL == g_platformData.context
&& NULL == g_platformData.backBuffer
- && NULL == g_platformData.backBufferDS)
+ && NULL == g_platformData.backBufferDS
+ )
{
BX_TRACE("bgfx platform data like window handle or backbuffer must be set.");
goto error;
}
memset(&g_caps, 0, sizeof(g_caps) );
- g_caps.maxViews = BGFX_CONFIG_MAX_VIEWS;
- g_caps.maxDrawCalls = BGFX_CONFIG_MAX_DRAW_CALLS;
- g_caps.maxFBAttachments = 1;
+ g_caps.limits.maxDrawCalls = BGFX_CONFIG_MAX_DRAW_CALLS;
+ g_caps.limits.maxBlits = BGFX_CONFIG_MAX_BLIT_ITEMS;
+ g_caps.limits.maxViews = BGFX_CONFIG_MAX_VIEWS;
+ g_caps.limits.maxFrameBuffers = BGFX_CONFIG_MAX_FRAME_BUFFERS;
+ g_caps.limits.maxPrograms = BGFX_CONFIG_MAX_PROGRAMS;
+ g_caps.limits.maxShaders = BGFX_CONFIG_MAX_SHADERS;
+ g_caps.limits.maxTextures = BGFX_CONFIG_MAX_TEXTURES;
+ g_caps.limits.maxTextureSamplers = BGFX_CONFIG_MAX_TEXTURE_SAMPLERS;
+ g_caps.limits.maxVertexDecls = BGFX_CONFIG_MAX_VERTEX_DECLS;
+ g_caps.limits.maxVertexStreams = BGFX_CONFIG_MAX_VERTEX_STREAMS;
+ g_caps.limits.maxIndexBuffers = BGFX_CONFIG_MAX_INDEX_BUFFERS;
+ g_caps.limits.maxVertexBuffers = BGFX_CONFIG_MAX_VERTEX_BUFFERS;
+ g_caps.limits.maxDynamicIndexBuffers = BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS;
+ g_caps.limits.maxDynamicVertexBuffers = BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS;
+ g_caps.limits.maxUniforms = BGFX_CONFIG_MAX_UNIFORMS;
+ g_caps.limits.maxOcclusionQueries = BGFX_CONFIG_MAX_OCCUSION_QUERIES;
+ g_caps.limits.maxFBAttachments = 1;
+
g_caps.vendorId = _vendorId;
g_caps.deviceId = _deviceId;
@@ -2474,7 +2513,7 @@ namespace bgfx
errorState = ErrorState::ContextAllocated;
- s_ctx = BX_ALIGNED_NEW(g_allocator, Context, 16);
+ s_ctx = BX_ALIGNED_NEW(g_allocator, Context, 64);
if (s_ctx->init(_type) )
{
BX_TRACE("Init complete.");
@@ -2487,7 +2526,7 @@ error:
switch (errorState)
{
case ErrorState::ContextAllocated:
- BX_ALIGNED_DELETE(g_allocator, s_ctx, 16);
+ BX_ALIGNED_DELETE(g_allocator, s_ctx, 64);
s_ctx = NULL;
case ErrorState::Default:
@@ -3132,7 +3171,7 @@ error:
{
BGFX_CHECK_MAIN_THREAD();
BX_CHECK(NULL != _mem, "_mem can't be NULL");
- if (_width == 0
+ if (_width == 0
|| _height == 0)
{
release(_mem);
@@ -3177,12 +3216,12 @@ error:
}
}
- uint32_t readTexture(TextureHandle _handle, void* _data)
+ uint32_t readTexture(TextureHandle _handle, void* _data, uint8_t _mip)
{
BGFX_CHECK_MAIN_THREAD();
BX_CHECK(NULL != _data, "_data can't be NULL");
BGFX_CHECK_CAPS(BGFX_CAPS_TEXTURE_READ_BACK, "Texture read-back is not supported!");
- return s_ctx->readTexture(_handle, _data);
+ return s_ctx->readTexture(_handle, _data, _mip);
}
uint32_t readTexture(FrameBufferHandle _handle, uint8_t _attachment, void* _data)
@@ -3503,7 +3542,7 @@ error:
void setVertexBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices)
{
BGFX_CHECK_MAIN_THREAD();
- s_ctx->setVertexBuffer(_handle, _startVertex, _numVertices);
+ s_ctx->setVertexBuffer(0, _handle, _startVertex, _numVertices);
}
void setVertexBuffer(DynamicVertexBufferHandle _handle)
@@ -3514,7 +3553,7 @@ error:
void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices)
{
BGFX_CHECK_MAIN_THREAD();
- s_ctx->setVertexBuffer(_handle, _startVertex, _numVertices);
+ s_ctx->setVertexBuffer(0, _handle, _startVertex, _numVertices);
}
void setVertexBuffer(const TransientVertexBuffer* _tvb)
@@ -3526,7 +3565,7 @@ error:
{
BGFX_CHECK_MAIN_THREAD();
BX_CHECK(NULL != _tvb, "_tvb can't be NULL");
- s_ctx->setVertexBuffer(_tvb, _startVertex, _numVertices);
+ s_ctx->setVertexBuffer(0, _tvb, _startVertex, _numVertices);
}
void setInstanceDataBuffer(const InstanceDataBuffer* _idb, uint32_t _num)
@@ -3551,12 +3590,15 @@ error:
void setTexture(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle, uint32_t _flags)
{
BGFX_CHECK_MAIN_THREAD();
+ BX_CHECK(_stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, "Invalid stage %d (max %d).", _stage, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS);
s_ctx->setTexture(_stage, _sampler, _handle, _flags);
}
void setTexture(uint8_t _stage, UniformHandle _sampler, FrameBufferHandle _handle, uint8_t _attachment, uint32_t _flags)
{
BGFX_CHECK_MAIN_THREAD();
+ BX_CHECK(_stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, "Invalid stage %d (max %d).", _stage, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS);
+ BX_CHECK(_attachment < g_caps.limits.maxFBAttachments, "Frame buffer attachment index %d is invalid.", _attachment);
s_ctx->setTexture(_stage, _sampler, _handle, _attachment, _flags);
}
@@ -3592,42 +3634,50 @@ error:
void setBuffer(uint8_t _stage, IndexBufferHandle _handle, Access::Enum _access)
{
BGFX_CHECK_MAIN_THREAD();
+ BX_CHECK(_stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, "Invalid stage %d (max %d).", _stage, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS);
s_ctx->setBuffer(_stage, _handle, _access);
}
void setBuffer(uint8_t _stage, VertexBufferHandle _handle, Access::Enum _access)
{
BGFX_CHECK_MAIN_THREAD();
+ BX_CHECK(_stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, "Invalid stage %d (max %d).", _stage, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS);
s_ctx->setBuffer(_stage, _handle, _access);
}
void setBuffer(uint8_t _stage, DynamicIndexBufferHandle _handle, Access::Enum _access)
{
BGFX_CHECK_MAIN_THREAD();
+ BX_CHECK(_stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, "Invalid stage %d (max %d).", _stage, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS);
s_ctx->setBuffer(_stage, _handle, _access);
}
void setBuffer(uint8_t _stage, DynamicVertexBufferHandle _handle, Access::Enum _access)
{
BGFX_CHECK_MAIN_THREAD();
+ BX_CHECK(_stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, "Invalid stage %d (max %d).", _stage, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS);
s_ctx->setBuffer(_stage, _handle, _access);
}
void setBuffer(uint8_t _stage, IndirectBufferHandle _handle, Access::Enum _access)
{
BGFX_CHECK_MAIN_THREAD();
+ BX_CHECK(_stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, "Invalid stage %d (max %d).", _stage, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS);
s_ctx->setBuffer(_stage, _handle, _access);
}
void setImage(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle, uint8_t _mip, Access::Enum _access, TextureFormat::Enum _format)
{
BGFX_CHECK_MAIN_THREAD();
+ BX_CHECK(_stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, "Invalid stage %d (max %d).", _stage, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS);
s_ctx->setImage(_stage, _sampler, _handle, _mip, _access, _format);
}
void setImage(uint8_t _stage, UniformHandle _sampler, FrameBufferHandle _handle, uint8_t _attachment, Access::Enum _access, TextureFormat::Enum _format)
{
BGFX_CHECK_MAIN_THREAD();
+ BX_CHECK(_stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, "Invalid stage %d (max %d).", _stage, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS);
+ BX_CHECK(_attachment < g_caps.limits.maxFBAttachments, "Frame buffer attachment index %d is invalid.", _attachment);
s_ctx->setImage(_stage, _sampler, _handle, _attachment, _access, _format);
}
@@ -3670,6 +3720,7 @@ error:
{
BGFX_CHECK_MAIN_THREAD();
BGFX_CHECK_CAPS(BGFX_CAPS_TEXTURE_BLIT, "Texture blit is not supported!");
+ BX_CHECK(_attachment < g_caps.limits.maxFBAttachments, "Frame buffer attachment index %d is invalid.", _attachment);
s_ctx->blit(_id, _dst, _dstMip, _dstX, _dstY, _dstZ, _src, _attachment, _srcMip, _srcX, _srcY, _srcZ, _width, _height, _depth);
}
@@ -3739,6 +3790,7 @@ BGFX_C99_STRUCT_SIZE_CHECK(bgfx::InstanceDataBuffer, bgfx_instance_data_buffe
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TextureInfo, bgfx_texture_info_t);
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Attachment, bgfx_attachment_t);
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Caps::GPU, bgfx_caps_gpu_t);
+BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Caps::Limits, bgfx_caps_limits_t);
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Caps, bgfx_caps_t);
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::PlatformData, bgfx_platform_data_t);
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::InternalData, bgfx_internal_data_t);
@@ -3891,9 +3943,9 @@ BGFX_C_API void bgfx_image_rgba8_downsample_2x2(uint32_t _width, uint32_t _heigh
bgfx::imageRgba8Downsample2x2(_width, _height, _pitch, _src, _dst);
}
-BGFX_C_API uint8_t bgfx_get_supported_renderers(bgfx_renderer_type_t _enum[BGFX_RENDERER_TYPE_COUNT])
+BGFX_C_API uint8_t bgfx_get_supported_renderers(uint8_t _max, bgfx_renderer_type_t* _enum)
{
- return bgfx::getSupportedRenderers( (bgfx::RendererType::Enum*)_enum);
+ return bgfx::getSupportedRenderers(_max, (bgfx::RendererType::Enum*)_enum);
}
BGFX_C_API const char* bgfx_get_renderer_name(bgfx_renderer_type_t _type)
@@ -4240,10 +4292,10 @@ BGFX_C_API void bgfx_update_texture_cube(bgfx_texture_handle_t _handle, uint16_t
bgfx::updateTextureCube(handle.cpp, _layer, _side, _mip, _x, _y, _width, _height, (const bgfx::Memory*)_mem, _pitch);
}
-BGFX_C_API uint32_t bgfx_read_texture(bgfx_texture_handle_t _handle, void* _data)
+BGFX_C_API uint32_t bgfx_read_texture(bgfx_texture_handle_t _handle, void* _data, uint8_t _mip)
{
union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
- return bgfx::readTexture(handle.cpp, _data);
+ return bgfx::readTexture(handle.cpp, _data, _mip);
}
BGFX_C_API uint32_t bgfx_read_frame_buffer(bgfx_frame_buffer_handle_t _handle, uint8_t _attachment, void* _data)
@@ -4725,6 +4777,8 @@ BGFX_C_API bgfx_interface_vtbl_t* bgfx_get_interface(uint32_t _version)
BGFX_IMPORT_FUNC(update_texture_2d) \
BGFX_IMPORT_FUNC(update_texture_3d) \
BGFX_IMPORT_FUNC(update_texture_cube) \
+ BGFX_IMPORT_FUNC(read_texture) \
+ BGFX_IMPORT_FUNC(read_frame_buffer) \
BGFX_IMPORT_FUNC(destroy_texture) \
BGFX_IMPORT_FUNC(create_frame_buffer) \
BGFX_IMPORT_FUNC(create_frame_buffer_scaled) \
@@ -4787,7 +4841,7 @@ BGFX_C_API bgfx_interface_vtbl_t* bgfx_get_interface(uint32_t _version)
static bgfx_interface_vtbl_t s_bgfx_interface =
{
-#define BGFX_IMPORT_FUNC(_name) bgfx_##_name,
+#define BGFX_IMPORT_FUNC(_name) BX_CONCATENATE(bgfx_, _name),
BGFX_IMPORT
#undef BGFX_IMPORT_FUNC
};
diff --git a/3rdparty/bgfx/src/bgfx_compute.sh b/3rdparty/bgfx/src/bgfx_compute.sh
index 32cdac319da..f6dd7541f29 100644
--- a/3rdparty/bgfx/src/bgfx_compute.sh
+++ b/3rdparty/bgfx/src/bgfx_compute.sh
@@ -19,6 +19,7 @@
#define rg16f float2
#define rgba16f float4
#define rgba8 float4
+#define rgba32f float4
#define IMAGE2D_RO( _name, _format, _reg) Texture2D<_format> _name : register(t[_reg])
#define UIMAGE2D_RO(_name, _format, _reg) Texture2D<_format> _name : register(t[_reg])
@@ -27,6 +28,13 @@
#define IMAGE2D_RW( _name, _reg) RWTexture2D<float> _name : register(u[_reg])
#define UIMAGE2D_RW(_name, _reg) RWTexture2D<uint> _name : register(u[_reg])
+#define IMAGE2D_ARRAY_RO( _name, _format, _reg) Texture2DArray<_format> _name : register(t[_reg])
+#define UIMAGE2D_ARRAY_RO(_name, _format, _reg) Texture2DArray<_format> _name : register(t[_reg])
+#define IMAGE2D_ARRAY_WR( _name, _format, _reg) RWTexture2DArray<_format> _name : register(u[_reg])
+#define UIMAGE2D_ARRAY_WR(_name, _format, _reg) RWTexture2DArray<_format> _name : register(u[_reg])
+#define IMAGE2D_ARRAY_RW( _name, _reg) RWTexture2DArray<float> _name : register(u[_reg])
+#define UIMAGE2D_ARRAY_RW(_name, _reg) RWTexture2DArray<uint> _name : register(u[_reg])
+
#define IMAGE3D_RO( _name, _format, _reg) Texture3D<_format> _name : register(t[_reg])
#define UIMAGE3D_RO(_name, _format, _reg) Texture3D<_format> _name : register(t[_reg])
#define IMAGE3D_WR( _name, _format, _reg) RWTexture3D<_format> _name : register(u[_reg])
@@ -41,12 +49,15 @@
#define NUM_THREADS(_x, _y, _z) [numthreads(_x, _y, _z)]
#define __IMAGE_IMPL(_textureType, _storeComponents, _type, _loadComponents) \
- _type imageLoad( Texture2D<_textureType> _image, ivec2 _uv) { return _image[_uv ]._loadComponents; } \
- _type imageLoad( Texture3D<_textureType> _image, ivec3 _uvw) { return _image[_uvw]._loadComponents; } \
- _type imageLoad(RWTexture2D<_textureType> _image, ivec2 _uv) { return _image[_uv ]._loadComponents; } \
- _type imageLoad(RWTexture3D<_textureType> _image, ivec3 _uvw, _type _value) { return _image[_uvw]._loadComponents; } \
- void imageStore(RWTexture2D<_textureType> _image, ivec2 _uv, _type _value) { _image[_uv ] = _value._storeComponents; } \
- void imageStore(RWTexture3D<_textureType> _image, ivec3 _uvw, _type _value) { _image[_uvw] = _value._storeComponents; }
+ _type imageLoad( Texture2D<_textureType> _image, ivec2 _uv) { return _image[_uv ]._loadComponents; } \
+ _type imageLoad(RWTexture2DArray<_textureType> _image, ivec3 _uvw) { return _image[_uvw ]._loadComponents; } \
+ _type imageLoad( Texture3D<_textureType> _image, ivec3 _uvw) { return _image[_uvw]._loadComponents; } \
+ _type imageLoad( RWTexture2D<_textureType> _image, ivec2 _uv) { return _image[_uv ]._loadComponents; } \
+ _type imageLoad(RWTexture2DArray<_textureType> _image, ivec3 _uvw, _type _value) { return _image[_uvw]._loadComponents; } \
+ _type imageLoad( RWTexture3D<_textureType> _image, ivec3 _uvw, _type _value) { return _image[_uvw]._loadComponents; } \
+ void imageStore( RWTexture2D<_textureType> _image, ivec2 _uv, _type _value) { _image[_uv ] = _value._storeComponents; } \
+ void imageStore(RWTexture2DArray<_textureType> _image, ivec3 _uvw, _type _value) { _image[_uvw] = _value._storeComponents; } \
+ void imageStore( RWTexture3D<_textureType> _image, ivec3 _uvw, _type _value) { _image[_uvw] = _value._storeComponents; }
__IMAGE_IMPL(float, x, vec4, xxxx)
__IMAGE_IMPL(vec2, xy, vec4, xyyy)
@@ -148,6 +159,13 @@ uint atomicCompSwap(uint _mem, uint _compare, uint _data)
#define IMAGE2D_RW( _name, _reg) __IMAGE_XX(_name, r32f, _reg, image2D, readwrite)
#define UIMAGE2D_RW(_name, _reg) __IMAGE_XX(_name, r32ui, _reg, uimage2D, readwrite)
+#define IMAGE2D_ARRAY_RO( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image2DArray, readonly)
+#define UIMAGE2D_ARRAY_RO(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage2DArray, readonly)
+#define IMAGE2D_ARRAY_WR( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image2DArray, writeonly)
+#define UIMAGE2D_ARRAY_WR(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage2DArray, writeonly)
+#define IMAGE2D_ARRAY_RW( _name, _reg) __IMAGE_XX(_name, r32f, _reg, image2DArray, readwrite)
+#define UIMAGE2D_ARRAY_RW(_name, _reg) __IMAGE_XX(_name, r32ui, _reg, uimage2DArray, readwrite)
+
#define IMAGE3D_RO( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image3D, readonly)
#define UIMAGE3D_RO(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage3D, readonly)
#define IMAGE3D_WR( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image3D, writeonly)
diff --git a/3rdparty/bgfx/src/bgfx_p.h b/3rdparty/bgfx/src/bgfx_p.h
index 561a9fa2c99..ea6e4331ca6 100644
--- a/3rdparty/bgfx/src/bgfx_p.h
+++ b/3rdparty/bgfx/src/bgfx_p.h
@@ -220,7 +220,8 @@ namespace stl
#define BGFX_RENDERER_DIRECT3D12_NAME "Direct3D 12"
#define BGFX_RENDERER_METAL_NAME "Metal"
#define BGFX_RENDERER_VULKAN_NAME "Vulkan"
-#define BGFX_RENDERER_NULL_NAME "NULL"
+#define BGFX_RENDERER_GNM_NAME "GNM"
+#define BGFX_RENDERER_NOOP_NAME "Noop"
#if BGFX_CONFIG_RENDERER_OPENGL
# if BGFX_CONFIG_RENDERER_OPENGL >= 31 && BGFX_CONFIG_RENDERER_OPENGL <= 33
@@ -332,6 +333,8 @@ namespace bgfx
extern bx::AllocatorI* g_allocator;
extern Caps g_caps;
+ typedef bx::StringT<&g_allocator> String;
+
void setGraphicsDebuggerPresent(bool _present);
bool isGraphicsDebuggerPresent();
void release(const Memory* _mem);
@@ -399,13 +402,13 @@ namespace bgfx
void resize(bool _small = false, uint32_t _width = BGFX_DEFAULT_WIDTH, uint32_t _height = BGFX_DEFAULT_HEIGHT)
{
- uint32_t width = bx::uint32_max(1, _width/8);
- uint32_t height = bx::uint32_max(1, _height/(_small ? 8 : 16) );
+ uint32_t width = bx::uint32_imax(1, _width/8);
+ uint32_t height = bx::uint32_imax(1, _height/(_small ? 8 : 16) );
if (NULL == m_mem
- || m_width != width
+ || m_width != width
|| m_height != height
- || m_small != _small)
+ || m_small != _small)
{
m_small = _small;
m_width = (uint16_t)width;
@@ -1146,40 +1149,40 @@ namespace bgfx
{
}
- const UniformInfo* find(const char* _name) const
- {
- UniformHashMap::const_iterator it = m_uniforms.find(_name);
- if (it != m_uniforms.end() )
+ const UniformInfo* find(const char* _name) const
+ {
+ uint16_t handle = m_uniforms.find(bx::hashMurmur2A(_name) );
+ if (UniformHashMap::invalid != handle)
{
- return &it->second;
+ return &m_info[handle];
}
- return NULL;
- }
+ return NULL;
+ }
const UniformInfo& add(UniformHandle _handle, const char* _name, const void* _data)
{
- UniformHashMap::iterator it = m_uniforms.find(_name);
- if (it == m_uniforms.end() )
- {
- UniformInfo info;
- info.m_data = _data;
- info.m_handle = _handle;
+ BX_CHECK(isValid(_handle), "Uniform handle is invalid (name: %s)!", _name);
+ const uint32_t key = bx::hashMurmur2A(_name);
+ m_uniforms.removeByKey(key);
+ m_uniforms.insert(key, _handle.idx);
- stl::pair<UniformHashMap::iterator, bool> result = m_uniforms.insert(UniformHashMap::value_type(_name, info) );
- return result.first->second;
- }
-
- UniformInfo& info = it->second;
+ UniformInfo& info = m_info[_handle.idx];
info.m_data = _data;
info.m_handle = _handle;
return info;
}
+ void remove(UniformHandle _handle)
+ {
+ m_uniforms.removeByHandle(_handle.idx);
+ }
+
private:
- typedef stl::unordered_map<stl::string, UniformInfo> UniformHashMap;
+ typedef bx::HandleHashMapT<BGFX_CONFIG_MAX_UNIFORMS*2> UniformHashMap;
UniformHashMap m_uniforms;
+ UniformInfo m_info[BGFX_CONFIG_MAX_UNIFORMS];
};
struct Binding
@@ -1214,6 +1217,20 @@ namespace bgfx
} m_un;
};
+ struct Stream
+ {
+ void clear()
+ {
+ m_startVertex = 0;
+ m_handle.idx = invalidHandle;
+ m_decl.idx = invalidHandle;
+ }
+
+ uint32_t m_startVertex;
+ VertexBufferHandle m_handle;
+ VertexDeclHandle m_decl;
+ };
+
struct RenderDraw
{
void clear()
@@ -1226,7 +1243,6 @@ namespace bgfx
m_matrix = 0;
m_startIndex = 0;
m_numIndices = UINT32_MAX;
- m_startVertex = 0;
m_numVertices = UINT32_MAX;
m_instanceDataOffset = 0;
m_instanceDataStride = 0;
@@ -1236,8 +1252,8 @@ namespace bgfx
m_num = 1;
m_submitFlags = BGFX_SUBMIT_EYE_FIRST;
m_scissor = UINT16_MAX;
- m_vertexBuffer.idx = invalidHandle;
- m_vertexDecl.idx = invalidHandle;
+ m_streamMask = 0;
+ m_stream[0].clear();
m_indexBuffer.idx = invalidHandle;
m_instanceDataBuffer.idx = invalidHandle;
m_indirectBuffer.idx = invalidHandle;
@@ -1252,7 +1268,17 @@ namespace bgfx
}
}
+ bool setStreamBit(uint8_t _stream, VertexBufferHandle _handle)
+ {
+ const uint8_t bit = 1<<_stream;
+ const uint8_t mask = m_streamMask & ~bit;
+ const uint8_t tmp = isValid(_handle) ? bit : 0;
+ m_streamMask = mask | tmp;
+ return 0 != tmp;
+ }
+
Binding m_bind[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
+ Stream m_stream[BGFX_CONFIG_MAX_VERTEX_STREAMS];
uint64_t m_stateFlags;
uint64_t m_stencil;
uint32_t m_rgba;
@@ -1261,7 +1287,6 @@ namespace bgfx
uint32_t m_matrix;
uint32_t m_startIndex;
uint32_t m_numIndices;
- uint32_t m_startVertex;
uint32_t m_numVertices;
uint32_t m_instanceDataOffset;
uint32_t m_numInstances;
@@ -1271,9 +1296,8 @@ namespace bgfx
uint16_t m_num;
uint16_t m_scissor;
uint8_t m_submitFlags;
+ uint8_t m_streamMask;
- VertexBufferHandle m_vertexBuffer;
- VertexDeclHandle m_vertexDecl;
IndexBufferHandle m_indexBuffer;
VertexBufferHandle m_instanceDataBuffer;
IndirectBufferHandle m_indirectBuffer;
@@ -1553,27 +1577,44 @@ namespace bgfx
m_discard = 0 == _numIndices;
}
- void setVertexBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices)
+ void setVertexBuffer(uint8_t _stream, VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices)
{
- m_draw.m_startVertex = _startVertex;
- m_draw.m_numVertices = _numVertices;
- m_draw.m_vertexBuffer = _handle;
+ if (m_draw.setStreamBit(_stream, _handle) )
+ {
+ Stream& stream = m_draw.m_stream[_stream];
+ stream.m_startVertex = _startVertex;
+ stream.m_handle = _handle;
+ stream.m_decl.idx = invalidHandle;
+ m_numVertices[_stream] = _numVertices;
+ }
}
- void setVertexBuffer(const DynamicVertexBuffer& _dvb, uint32_t _startVertex, uint32_t _numVertices)
+ void setVertexBuffer(uint8_t _stream, const DynamicVertexBuffer& _dvb, uint32_t _startVertex, uint32_t _numVertices)
{
- m_draw.m_startVertex = _dvb.m_startVertex + _startVertex;
- m_draw.m_numVertices = bx::uint32_min(bx::uint32_imax(0, _dvb.m_numVertices - _startVertex), _numVertices);
- m_draw.m_vertexBuffer = _dvb.m_handle;
- m_draw.m_vertexDecl = _dvb.m_decl;
+ if (m_draw.setStreamBit(_stream, _dvb.m_handle) )
+ {
+ Stream& stream = m_draw.m_stream[_stream];
+ stream.m_startVertex = _dvb.m_startVertex + _startVertex;
+ stream.m_handle = _dvb.m_handle;
+ stream.m_decl = _dvb.m_decl;
+ m_numVertices[_stream] =
+ bx::uint32_min(bx::uint32_imax(0, _dvb.m_numVertices - _startVertex), _numVertices)
+ ;
+ }
}
- void setVertexBuffer(const TransientVertexBuffer* _tvb, uint32_t _startVertex, uint32_t _numVertices)
+ void setVertexBuffer(uint8_t _stream, const TransientVertexBuffer* _tvb, uint32_t _startVertex, uint32_t _numVertices)
{
- m_draw.m_startVertex = _tvb->startVertex + _startVertex;
- m_draw.m_numVertices = bx::uint32_min(bx::uint32_imax(0, _tvb->size/_tvb->stride - _startVertex), _numVertices);
- m_draw.m_vertexBuffer = _tvb->handle;
- m_draw.m_vertexDecl = _tvb->decl;
+ if (m_draw.setStreamBit(_stream, _tvb->handle) )
+ {
+ Stream& stream = m_draw.m_stream[_stream];
+ stream.m_startVertex = _tvb->startVertex + _startVertex;
+ stream.m_handle = _tvb->handle;
+ stream.m_decl = _tvb->decl;
+ m_numVertices[_stream] =
+ bx::uint32_min(bx::uint32_imax(0, _tvb->size/_tvb->stride - _startVertex), _numVertices)
+ ;
+ }
}
void setInstanceDataBuffer(const InstanceDataBuffer* _idb, uint32_t _num)
@@ -1799,6 +1840,7 @@ namespace bgfx
RenderItem m_renderItem[BGFX_CONFIG_MAX_DRAW_CALLS+1];
RenderDraw m_draw;
RenderCompute m_compute;
+ uint32_t m_numVertices[BGFX_CONFIG_MAX_VERTEX_STREAMS];
uint32_t m_blitKeys[BGFX_CONFIG_MAX_BLIT_ITEMS+1];
BlitItem m_blitItem[BGFX_CONFIG_MAX_BLIT_ITEMS+1];
uint64_t m_stateFlags;
@@ -1872,31 +1914,25 @@ namespace bgfx
template <uint16_t MaxHandlesT>
void shutdown(bx::HandleAllocT<MaxHandlesT>& _handleAlloc)
{
- for (VertexDeclMap::iterator it = m_vertexDeclMap.begin(), itEnd = m_vertexDeclMap.end(); it != itEnd; ++it)
+ for (VertexDeclMap::Iterator it = m_vertexDeclMap.first(); m_vertexDeclMap.next(it); )
{
- _handleAlloc.free(it->second.idx);
+ _handleAlloc.free(it.handle);
}
- m_vertexDeclMap.clear();
+ m_vertexDeclMap.reset();
}
VertexDeclHandle find(uint32_t _hash)
{
- VertexDeclMap::const_iterator it = m_vertexDeclMap.find(_hash);
- if (it != m_vertexDeclMap.end() )
- {
- return it->second;
- }
-
- VertexDeclHandle result = BGFX_INVALID_HANDLE;
- return result;
+ VertexDeclHandle handle = { m_vertexDeclMap.find(_hash) };
+ return handle;
}
void add(VertexBufferHandle _handle, VertexDeclHandle _declHandle, uint32_t _hash)
{
m_vertexBufferRef[_handle.idx] = _declHandle;
m_vertexDeclRef[_declHandle.idx]++;
- m_vertexDeclMap.insert(stl::make_pair(_hash, _declHandle) );
+ m_vertexDeclMap.insert(_hash, _declHandle.idx);
}
VertexDeclHandle release(VertexBufferHandle _handle)
@@ -1913,13 +1949,14 @@ namespace bgfx
}
}
- bx::mapRemove(m_vertexDeclMap, declHandle);
+ m_vertexDeclMap.removeByHandle(declHandle.idx);
return declHandle;
}
- typedef stl::unordered_map<uint32_t, VertexDeclHandle> VertexDeclMap;
+ typedef bx::HandleHashMapT<BGFX_CONFIG_MAX_VERTEX_DECLS*2> VertexDeclMap;
VertexDeclMap m_vertexDeclMap;
+
uint16_t m_vertexDeclRef[BGFX_CONFIG_MAX_VERTEX_DECLS];
VertexDeclHandle m_vertexBufferRef[BGFX_CONFIG_MAX_VERTEX_BUFFERS];
};
@@ -2073,7 +2110,7 @@ namespace bgfx
virtual void updateTextureBegin(TextureHandle _handle, uint8_t _side, uint8_t _mip) = 0;
virtual void updateTexture(TextureHandle _handle, uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem) = 0;
virtual void updateTextureEnd() = 0;
- virtual void readTexture(TextureHandle _handle, void* _data) = 0;
+ virtual void readTexture(TextureHandle _handle, void* _data, uint8_t _mip) = 0;
virtual void resizeTexture(TextureHandle _handle, uint16_t _width, uint16_t _height, uint8_t _numMips) = 0;
virtual void overrideInternal(TextureHandle _handle, uintptr_t _ptr) = 0;
virtual uintptr_t getInternal(TextureHandle _handle) = 0;
@@ -2150,9 +2187,14 @@ namespace bgfx
BGFX_API_FUNC(void reset(uint32_t _width, uint32_t _height, uint32_t _flags) )
{
- BX_WARN(0 != _width && 0 != _height, "Frame buffer resolution width or height cannot be 0 (width %d, height %d).", _width, _height);
- m_resolution.m_width = bx::uint32_max(1, _width);
- m_resolution.m_height = bx::uint32_max(1, _height);
+ BX_WARN(1 <= int32_t(_width)
+ && 1 <= int32_t(_height)
+ , "Frame buffer resolution width or height cannot be 0 (width %d, height %d)."
+ , _width
+ , _height
+ );
+ m_resolution.m_width = bx::uint32_imax(1, _width);
+ m_resolution.m_height = bx::uint32_imax(1, _height);
m_resolution.m_flags = 0
| _flags
| (g_platformDataChangedSinceReset ? BGFX_RESET_INTERNAL_FORCE : 0)
@@ -2799,8 +2841,16 @@ namespace bgfx
{
bx::MemoryReader reader(_mem->data, _mem->size);
+ bx::Error err;
+
uint32_t magic;
- bx::read(&reader, magic);
+ bx::read(&reader, magic, &err);
+
+ if (!err.isOk() )
+ {
+ ShaderHandle invalid = BGFX_INVALID_HANDLE;
+ return invalid;
+ }
if (BGFX_CHUNK_MAGIC_CSH != magic
&& BGFX_CHUNK_MAGIC_FSH != magic
@@ -2956,15 +3006,15 @@ namespace bgfx
if (!isValid(_vsh)
|| !isValid(_fsh) )
{
- BX_WARN(false, "Vertex/fragment shader is invalid (vsh %d, fsh %d).", _vsh.idx, _fsh.idx);
+ BX_TRACE("Vertex/fragment shader is invalid (vsh %d, fsh %d).", _vsh.idx, _fsh.idx);
ProgramHandle invalid = BGFX_INVALID_HANDLE;
return invalid;
}
- ProgramHashMap::const_iterator it = m_programHashMap.find(uint32_t(_fsh.idx<<16)|_vsh.idx);
- if (it != m_programHashMap.end() )
+ uint16_t idx = m_programHashMap.find(uint32_t(_fsh.idx<<16)|_vsh.idx);
+ if (ProgramHashMap::invalid != idx)
{
- ProgramHandle handle = it->second;
+ ProgramHandle handle = { idx };
ProgramRef& pr = m_programRef[handle.idx];
++pr.m_refCount;
return handle;
@@ -2974,7 +3024,7 @@ namespace bgfx
const ShaderRef& fsr = m_shaderRef[_fsh.idx];
if (vsr.m_hash != fsr.m_hash)
{
- BX_WARN(vsr.m_hash == fsr.m_hash, "Vertex shader output doesn't match fragment shader input.");
+ BX_TRACE("Vertex shader output doesn't match fragment shader input.");
ProgramHandle invalid = BGFX_INVALID_HANDLE;
return invalid;
}
@@ -2992,7 +3042,9 @@ namespace bgfx
pr.m_fsh = _fsh;
pr.m_refCount = 1;
- m_programHashMap.insert(stl::make_pair(uint32_t(_fsh.idx<<16)|_vsh.idx, handle) );
+ const uint32_t key = uint32_t(_fsh.idx<<16)|_vsh.idx;
+ bool ok = m_programHashMap.insert(key, handle.idx);
+ BX_CHECK(ok, "Program already exists (key: %x, handle: %3d)!", key, handle.idx); BX_UNUSED(ok);
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateProgram);
cmdbuf.write(handle);
@@ -3018,10 +3070,10 @@ namespace bgfx
return invalid;
}
- ProgramHashMap::const_iterator it = m_programHashMap.find(_vsh.idx);
- if (it != m_programHashMap.end() )
+ uint16_t idx = m_programHashMap.find(_vsh.idx);
+ if (ProgramHashMap::invalid != idx)
{
- ProgramHandle handle = it->second;
+ ProgramHandle handle = { idx };
ProgramRef& pr = m_programRef[handle.idx];
++pr.m_refCount;
return handle;
@@ -3040,7 +3092,9 @@ namespace bgfx
pr.m_fsh = fsh;
pr.m_refCount = 1;
- m_programHashMap.insert(stl::make_pair(uint32_t(_vsh.idx), handle) );
+ const uint32_t key = uint32_t(_vsh.idx);
+ bool ok = m_programHashMap.insert(key, handle.idx);
+ BX_CHECK(ok, "Program already exists (key: %x, handle: %3d)!", key, handle.idx); BX_UNUSED(ok);
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateProgram);
cmdbuf.write(handle);
@@ -3077,7 +3131,7 @@ namespace bgfx
hash |= pr.m_fsh.idx << 16;
}
- bx::mapRemove(m_programHashMap, hash);
+ m_programHashMap.removeByHandle(_handle.idx);
}
}
@@ -3148,11 +3202,17 @@ namespace bgfx
textureDecRef(_handle);
}
- BGFX_API_FUNC(uint32_t readTexture(TextureHandle _handle, void* _data) )
+ BGFX_API_FUNC(uint32_t readTexture(TextureHandle _handle, void* _data, uint8_t _mip) )
{
+ BGFX_CHECK_HANDLE("readTexture", m_textureHandle, _handle);
+
+ const TextureRef& ref = m_textureRef[_handle.idx];
+ BX_CHECK(_mip < ref.m_numMips, "Invalid mip: %d num mips:", _mip, ref.m_numMips); BX_UNUSED(ref);
+
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::ReadTexture);
cmdbuf.write(_handle);
cmdbuf.write(_data);
+ cmdbuf.write(_mip);
return m_frames + 2;
}
@@ -3160,9 +3220,11 @@ namespace bgfx
{
const FrameBufferRef& ref = m_frameBufferRef[_handle.idx];
BX_CHECK(!ref.m_window, "Can't sample window frame buffer.");
+
TextureHandle textureHandle = ref.un.m_th[_attachment];
- BX_CHECK(isValid(textureHandle), "Frame buffer texture %d is invalid.", _attachment);
- return readTexture(textureHandle, _data);
+ BGFX_CHECK_HANDLE("readTexture", m_textureHandle, textureHandle);
+
+ return readTexture(textureHandle, _data,0);
}
void resizeTexture(TextureHandle _handle, uint16_t _width, uint16_t _height, uint8_t _numMips)
@@ -3263,7 +3325,7 @@ namespace bgfx
}
}
- return color <= g_caps.maxFBAttachments
+ return color <= g_caps.limits.maxFBAttachments
&& depth <= 1
;
}
@@ -3273,7 +3335,7 @@ namespace bgfx
BX_CHECK(checkFrameBuffer(_num, _attachment)
, "Too many frame buffer attachments (num attachments: %d, max color attachments %d)!"
, _num
- , g_caps.maxFBAttachments
+ , g_caps.limits.maxFBAttachments
);
FrameBufferHandle handle = { m_frameBufferHandle.alloc() };
@@ -3369,11 +3431,16 @@ namespace bgfx
return handle;
}
- UniformHashMap::iterator it = m_uniformHashMap.find(_name);
- if (it != m_uniformHashMap.end() )
+ uint16_t idx = m_uniformHashMap.find(bx::hashMurmur2A(_name) );
+ if (UniformHashMap::invalid != idx)
{
- UniformHandle handle = it->second;
+ UniformHandle handle = { idx };
UniformRef& uniform = m_uniformRef[handle.idx];
+ BX_CHECK(uniform.m_type == _type
+ , "Uniform type mismatch (type: %d, expected %d)."
+ , _type
+ , uniform.m_type
+ );
uint32_t oldsize = g_uniformTypeSize[uniform.m_type];
uint32_t newsize = g_uniformTypeSize[_type];
@@ -3399,17 +3466,18 @@ namespace bgfx
UniformHandle handle = { m_uniformHandle.alloc() };
- BX_WARN(isValid(handle), "Failed to allocate uniform handle.");
if (isValid(handle) )
{
BX_TRACE("Creating uniform (handle %3d) %s", handle.idx, _name);
UniformRef& uniform = m_uniformRef[handle.idx];
+ uniform.m_name.set(_name);
uniform.m_refCount = 1;
uniform.m_type = _type;
uniform.m_num = _num;
- m_uniformHashMap.insert(stl::make_pair(stl::string(_name), handle) );
+ bool ok = m_uniformHashMap.insert(bx::hashMurmur2A(_name), handle.idx);
+ BX_CHECK(ok, "Uniform already exists (name: %s)!", _name); BX_UNUSED(ok);
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateUniform);
cmdbuf.write(handle);
@@ -3419,6 +3487,10 @@ namespace bgfx
cmdbuf.write(len);
cmdbuf.write(_name, len);
}
+ else
+ {
+ BX_TRACE("Failed to allocate uniform handle.");
+ }
return handle;
}
@@ -3433,7 +3505,8 @@ namespace bgfx
if (0 == refs)
{
- bx::mapRemove(m_uniformHashMap, _handle);
+ uniform.m_name.clear();
+ m_uniformHashMap.removeByHandle(_handle.idx);
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyUniform);
cmdbuf.write(_handle);
@@ -3666,6 +3739,7 @@ namespace bgfx
{
BGFX_CHECK_HANDLE("setUniform", m_uniformHandle, _handle);
UniformRef& uniform = m_uniformRef[_handle.idx];
+ BX_CHECK(isValid(_handle) && 0 < uniform.m_refCount, "Setting invalid uniform (handle %3d)!", _handle.idx);
BX_CHECK(_num == UINT16_MAX || uniform.m_num >= _num, "Truncated uniform update. %d (max: %d)", _num, uniform.m_num);
if (BX_ENABLED(BGFX_CONFIG_DEBUG_UNIFORM) )
{
@@ -3697,22 +3771,25 @@ namespace bgfx
m_submit->setIndexBuffer(_tib, _firstIndex, _numIndices);
}
- BGFX_API_FUNC(void setVertexBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices) )
+ BGFX_API_FUNC(void setVertexBuffer(uint8_t _stream, VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices) )
{
BGFX_CHECK_HANDLE("setVertexBuffer", m_vertexBufferHandle, _handle);
- m_submit->setVertexBuffer(_handle, _startVertex, _numVertices);
+ BX_CHECK(_stream < BGFX_CONFIG_MAX_VERTEX_STREAMS, "Invalid stream %d (max %d).", _stream, BGFX_CONFIG_MAX_VERTEX_STREAMS);
+ m_submit->setVertexBuffer(_stream, _handle, _startVertex, _numVertices);
}
- BGFX_API_FUNC(void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices) )
+ BGFX_API_FUNC(void setVertexBuffer(uint8_t _stream, DynamicVertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices) )
{
BGFX_CHECK_HANDLE("setVertexBuffer", m_dynamicVertexBufferHandle, _handle);
- m_submit->setVertexBuffer(m_dynamicVertexBuffers[_handle.idx], _startVertex, _numVertices);
+ BX_CHECK(_stream < BGFX_CONFIG_MAX_VERTEX_STREAMS, "Invalid stream %d (max %d).", _stream, BGFX_CONFIG_MAX_VERTEX_STREAMS);
+ m_submit->setVertexBuffer(_stream, m_dynamicVertexBuffers[_handle.idx], _startVertex, _numVertices);
}
- BGFX_API_FUNC(void setVertexBuffer(const TransientVertexBuffer* _tvb, uint32_t _startVertex, uint32_t _numVertices) )
+ BGFX_API_FUNC(void setVertexBuffer(uint8_t _stream, const TransientVertexBuffer* _tvb, uint32_t _startVertex, uint32_t _numVertices) )
{
BGFX_CHECK_HANDLE("setVertexBuffer", m_vertexBufferHandle, _tvb->handle);
- m_submit->setVertexBuffer(_tvb, _startVertex, _numVertices);
+ BX_CHECK(_stream < BGFX_CONFIG_MAX_VERTEX_STREAMS, "Invalid stream %d (max %d).", _stream, BGFX_CONFIG_MAX_VERTEX_STREAMS);
+ m_submit->setVertexBuffer(_stream, _tvb, _startVertex, _numVertices);
}
BGFX_API_FUNC(void setInstanceDataBuffer(const InstanceDataBuffer* _idb, uint32_t _num) )
@@ -3749,7 +3826,6 @@ namespace bgfx
BGFX_API_FUNC(void setTexture(uint8_t _stage, UniformHandle _sampler, FrameBufferHandle _handle, uint8_t _attachment, uint32_t _flags) )
{
BGFX_CHECK_HANDLE_INVALID_OK("setTexture/FrameBufferHandle", m_frameBufferHandle, _handle);
- BX_CHECK(_attachment < g_caps.maxFBAttachments, "Frame buffer attachment index %d is invalid.", _attachment);
TextureHandle textureHandle = BGFX_INVALID_HANDLE;
if (isValid(_handle) )
{
@@ -3841,7 +3917,6 @@ namespace bgfx
BGFX_API_FUNC(void setImage(uint8_t _stage, UniformHandle _sampler, FrameBufferHandle _handle, uint8_t _attachment, Access::Enum _access, TextureFormat::Enum _format) )
{
- BX_CHECK(_attachment < g_caps.maxFBAttachments, "Frame buffer attachment index %d is invalid.", _attachment);
TextureHandle textureHandle = BGFX_INVALID_HANDLE;
if (isValid(_handle) )
{
@@ -3922,21 +3997,28 @@ namespace bgfx
{
if (!m_singleThreaded)
{
- m_gameSem.post();
+ m_apiSem.post();
}
}
- void gameSemWait()
+ bool apiSemWait(int32_t _msecs = -1)
{
- if (!m_singleThreaded)
+ if (m_singleThreaded)
+ {
+ return true;
+ }
+
+ BGFX_PROFILER_SCOPE(bgfx, main_thread_wait, 0xff2040ff);
+ int64_t start = bx::getHPCounter();
+ bool ok = m_apiSem.wait(_msecs);
+ if (ok)
{
- BGFX_PROFILER_SCOPE(bgfx, main_thread_wait, 0xff2040ff);
- int64_t start = bx::getHPCounter();
- bool ok = m_gameSem.wait();
- BX_CHECK(ok, "Semaphore wait failed."); BX_UNUSED(ok);
m_render->m_waitSubmit = bx::getHPCounter()-start;
m_submit->m_perfStats.waitSubmit = m_submit->m_waitSubmit;
+ return true;
}
+
+ return false;
}
void renderSemPost()
@@ -3961,15 +4043,17 @@ namespace bgfx
}
bx::Semaphore m_renderSem;
- bx::Semaphore m_gameSem;
+ bx::Semaphore m_apiSem;
bx::Thread m_thread;
#else
void gameSemPost()
{
}
- void gameSemWait()
+ bool apiSemWait(int32_t _msecs = -1)
{
+ BX_UNUSED(_msecs);
+ return true;
}
void renderSemPost()
@@ -4027,14 +4111,15 @@ namespace bgfx
{
ShaderHandle m_vsh;
ShaderHandle m_fsh;
- int16_t m_refCount;
+ int16_t m_refCount;
};
struct UniformRef
{
+ String m_name;
UniformType::Enum m_type;
- uint16_t m_num;
- int16_t m_refCount;
+ uint16_t m_num;
+ int16_t m_refCount;
};
struct TextureRef
@@ -4060,13 +4145,13 @@ namespace bgfx
HandleSet m_uniformSet;
HandleSet m_occlusionQuerySet;
- typedef stl::unordered_map<stl::string, UniformHandle> UniformHashMap;
+ typedef bx::HandleHashMapT<BGFX_CONFIG_MAX_UNIFORMS*2> UniformHashMap;
UniformHashMap m_uniformHashMap;
UniformRef m_uniformRef[BGFX_CONFIG_MAX_UNIFORMS];
ShaderRef m_shaderRef[BGFX_CONFIG_MAX_SHADERS];
- typedef stl::unordered_map<uint32_t, ProgramHandle> ProgramHashMap;
+ typedef bx::HandleHashMapT<BGFX_CONFIG_MAX_PROGRAMS*2> ProgramHashMap;
ProgramHashMap m_programHashMap;
ProgramRef m_programRef[BGFX_CONFIG_MAX_PROGRAMS];
diff --git a/3rdparty/bgfx/src/bgfx_shader.sh b/3rdparty/bgfx/src/bgfx_shader.sh
index f607f17d74e..c84e4bdc62a 100644
--- a/3rdparty/bgfx/src/bgfx_shader.sh
+++ b/3rdparty/bgfx/src/bgfx_shader.sh
@@ -28,7 +28,7 @@
# define EARLY_DEPTH_STENCIL
#endif // BGFX_SHADER_LANGUAGE_HLSL > 3 && BGFX_SHADER_TYPE_FRAGMENT
-#if BGFX_SHADER_LANGUAGE_HLSL
+#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL
# define CONST(_x) static const _x
# define dFdx(_x) ddx(_x)
# define dFdy(_y) ddy(-_y)
@@ -39,18 +39,26 @@
# define bvec3 bool3
# define bvec4 bool4
-# if BGFX_SHADER_LANGUAGE_HLSL > 3
-# if BGFX_SHADER_LANGUAGE_HLSL > 4
+# if BGFX_SHADER_LANGUAGE_HLSL > 4
+# define REGISTER(_type, _reg) register(_type[_reg])
+# else
+# define REGISTER(_type, _reg) register(_type ## _reg)
+# endif // BGFX_SHADER_LANGUAGE_HLSL
+
+# if BGFX_SHADER_LANGUAGE_HLSL > 3 || BGFX_SHADER_LANGUAGE_PSSL
+# if BGFX_SHADER_LANGUAGE_HLSL > 4 || BGFX_SHADER_LANGUAGE_PSSL
# define dFdxCoarse(_x) ddx_coarse(_x)
# define dFdxFine(_x) ddx_fine(_x)
# define dFdyCoarse(_y) ddy_coarse(-_y)
# define dFdyFine(_y) ddy_fine(-_y)
# endif // BGFX_SHADER_LANGUAGE_HLSL > 4
+# if BGFX_SHADER_LANGUAGE_HLSL
float intBitsToFloat(int _x) { return asfloat(_x); }
vec2 intBitsToFloat(uint2 _x) { return asfloat(_x); }
vec3 intBitsToFloat(uint3 _x) { return asfloat(_x); }
vec4 intBitsToFloat(uint4 _x) { return asfloat(_x); }
+# endif // BGFX_SHADER_LANGUAGE_HLSL
float uintBitsToFloat(uint _x) { return asfloat(_x); }
vec2 uintBitsToFloat(uint2 _x) { return asfloat(_x); }
@@ -192,7 +200,7 @@ vec4 bgfxTexture3DLod(BgfxSampler3D _sampler, vec3 _coord, float _level)
ivec4 bgfxTexture3D(BgfxISampler3D _sampler, vec3 _coord)
{
- ivec3 size;
+ uvec3 size;
_sampler.m_texture.GetDimensions(size.x, size.y, size.z);
return _sampler.m_texture.Load(ivec4(_coord * size, 0) );
}
@@ -201,7 +209,7 @@ uvec4 bgfxTexture3D(BgfxUSampler3D _sampler, vec3 _coord)
{
uvec3 size;
_sampler.m_texture.GetDimensions(size.x, size.y, size.z);
- return _sampler.m_texture.Load(uvec4(_coord * size, 0) );
+ return _sampler.m_texture.Load(ivec4(_coord * size, 0) );
}
vec4 bgfxTextureCube(BgfxSamplerCube _sampler, vec3 _coord)
@@ -240,14 +248,14 @@ vec4 bgfxTexelFetch(BgfxSampler3D _sampler, ivec3 _coord, int _lod)
}
# define SAMPLER2D(_name, _reg) \
- uniform SamplerState _name ## Sampler : register(s[_reg]); \
- uniform Texture2D _name ## Texture : register(t[_reg]); \
+ uniform SamplerState _name ## Sampler : REGISTER(s, _reg); \
+ uniform Texture2D _name ## Texture : REGISTER(t, _reg); \
static BgfxSampler2D _name = { _name ## Sampler, _name ## Texture }
# define ISAMPLER2D(_name, _reg) \
- uniform Texture2D<ivec4> _name ## Texture : register(t[_reg]); \
+ uniform Texture2D<ivec4> _name ## Texture : REGISTER(t, _reg); \
static BgfxISampler2D _name = { _name ## Texture }
# define USAMPLER2D(_name, _reg) \
- uniform Texture2D<uvec4> _name ## Texture : register(t[_reg]); \
+ uniform Texture2D<uvec4> _name ## Texture : REGISTER(t, _reg); \
static BgfxUSampler2D _name = { _name ## Texture }
# define sampler2D BgfxSampler2D
# define texture2D(_sampler, _coord) bgfxTexture2D(_sampler, _coord)
@@ -255,43 +263,43 @@ vec4 bgfxTexelFetch(BgfxSampler3D _sampler, ivec3 _coord, int _lod)
# define texture2DProj(_sampler, _coord) bgfxTexture2DProj(_sampler, _coord)
# define SAMPLER2DARRAY(_name, _reg) \
- uniform SamplerState _name ## Sampler : register(s[_reg]); \
- uniform Texture2DArray _name ## Texture : register(t[_reg]); \
+ uniform SamplerState _name ## Sampler : REGISTER(s, _reg); \
+ uniform Texture2DArray _name ## Texture : REGISTER(t, _reg); \
static BgfxSampler2DArray _name = { _name ## Sampler, _name ## Texture }
# define sampler2DArray BgfxSampler2DArray
# define texture2DArray(_sampler, _coord) bgfxTexture2DArray(_sampler, _coord)
# define texture2DArrayLod(_sampler, _coord, _lod) bgfxTexture2DArrayLod(_sampler, _coord, _lod)
# define SAMPLER2DMS(_name, _reg) \
- uniform Texture2DMS<vec4> _name ## Texture : register(t[_reg]); \
+ uniform Texture2DMS<vec4> _name ## Texture : REGISTER(t, _reg); \
static BgfxSampler2DMS _name = { _name ## Texture }
# define sampler2DMS BgfxSampler2DMS
# define SAMPLER2DSHADOW(_name, _reg) \
- uniform SamplerComparisonState _name ## Sampler : register(s[_reg]); \
- uniform Texture2D _name ## Texture : register(t[_reg]); \
+ uniform SamplerComparisonState _name ## Sampler : REGISTER(s, _reg); \
+ uniform Texture2D _name ## Texture : REGISTER(t, _reg); \
static BgfxSampler2DShadow _name = { _name ## Sampler, _name ## Texture }
# define sampler2DShadow BgfxSampler2DShadow
# define shadow2D(_sampler, _coord) bgfxShadow2D(_sampler, _coord)
# define shadow2DProj(_sampler, _coord) bgfxShadow2DProj(_sampler, _coord)
# define SAMPLER3D(_name, _reg) \
- uniform SamplerState _name ## Sampler : register(s[_reg]); \
- uniform Texture3D _name ## Texture : register(t[_reg]); \
+ uniform SamplerState _name ## Sampler : REGISTER(s, _reg); \
+ uniform Texture3D _name ## Texture : REGISTER(t, _reg); \
static BgfxSampler3D _name = { _name ## Sampler, _name ## Texture }
# define ISAMPLER3D(_name, _reg) \
- uniform Texture3D<ivec4> _name ## Texture : register(t[_reg]); \
+ uniform Texture3D<ivec4> _name ## Texture : REGISTER(t, _reg); \
static BgfxISampler3D _name = { _name ## Texture }
# define USAMPLER3D(_name, _reg) \
- uniform Texture3D<uvec4> _name ## Texture : register(t[_reg]); \
+ uniform Texture3D<uvec4> _name ## Texture : REGISTER(t, _reg); \
static BgfxUSampler3D _name = { _name ## Texture }
# define sampler3D BgfxSampler3D
# define texture3D(_sampler, _coord) bgfxTexture3D(_sampler, _coord)
# define texture3DLod(_sampler, _coord, _level) bgfxTexture3DLod(_sampler, _coord, _level)
# define SAMPLERCUBE(_name, _reg) \
- uniform SamplerState _name ## Sampler : register(s[_reg]); \
- uniform TextureCube _name ## Texture : register(t[_reg]); \
+ uniform SamplerState _name ## Sampler : REGISTER(s, _reg); \
+ uniform TextureCube _name ## Texture : REGISTER(t, _reg); \
static BgfxSamplerCube _name = { _name ## Sampler, _name ## Texture }
# define samplerCube BgfxSamplerCube
# define textureCube(_sampler, _coord) bgfxTextureCube(_sampler, _coord)
@@ -333,19 +341,19 @@ float bgfxShadow2DProj(sampler2DShadow _sampler, vec4 _coord)
#endif // 0
}
-# define SAMPLER2D(_name, _reg) uniform sampler2D _name : register(s ## _reg)
-# define SAMPLER2DMS(_name, _reg) uniform sampler2DMS _name : register(s ## _reg)
+# define SAMPLER2D(_name, _reg) uniform sampler2D _name : REGISTER(s, _reg)
+# define SAMPLER2DMS(_name, _reg) uniform sampler2DMS _name : REGISTER(s, _reg)
# define texture2D(_sampler, _coord) tex2D(_sampler, _coord)
# define texture2DProj(_sampler, _coord) bgfxTexture2DProj(_sampler, _coord)
-# define SAMPLER2DSHADOW(_name, _reg) uniform sampler2DShadow _name : register(s ## _reg)
+# define SAMPLER2DSHADOW(_name, _reg) uniform sampler2DShadow _name : REGISTER(s, _reg)
# define shadow2D(_sampler, _coord) bgfxShadow2D(_sampler, _coord)
# define shadow2DProj(_sampler, _coord) bgfxShadow2DProj(_sampler, _coord)
-# define SAMPLER3D(_name, _reg) uniform sampler3D _name : register(s ## _reg)
+# define SAMPLER3D(_name, _reg) uniform sampler3D _name : REGISTER(s, _reg)
# define texture3D(_sampler, _coord) tex3D(_sampler, _coord)
-# define SAMPLERCUBE(_name, _reg) uniform samplerCUBE _name : register(s[_reg])
+# define SAMPLERCUBE(_name, _reg) uniform samplerCUBE _name : REGISTER(s, _reg)
# define textureCube(_sampler, _coord) texCUBE(_sampler, _coord)
# if BGFX_SHADER_LANGUAGE_HLSL == 2
@@ -441,11 +449,11 @@ vec2 vec2_splat(float _x) { return vec2(_x, _x); }
vec3 vec3_splat(float _x) { return vec3(_x, _x, _x); }
vec4 vec4_splat(float _x) { return vec4(_x, _x, _x, _x); }
-#if BGFX_SHADER_LANGUAGE_GLSL >= 130 || BGFX_SHADER_LANGUAGE_HLSL
+#if BGFX_SHADER_LANGUAGE_GLSL >= 130 || BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL
uvec2 uvec2_splat(uint _x) { return uvec2(_x, _x); }
uvec3 uvec3_splat(uint _x) { return uvec3(_x, _x, _x); }
uvec4 uvec4_splat(uint _x) { return uvec4(_x, _x, _x, _x); }
-#endif // BGFX_SHADER_LANGUAGE_GLSL >= 130 || BGFX_SHADER_LANGUAGE_HLSL
+#endif // BGFX_SHADER_LANGUAGE_GLSL >= 130 || BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL
uniform vec4 u_viewRect;
uniform vec4 u_viewTexel;
diff --git a/3rdparty/bgfx/src/charset.h b/3rdparty/bgfx/src/charset.h
index 15b3f81b645..32938ae260b 100644
--- a/3rdparty/bgfx/src/charset.h
+++ b/3rdparty/bgfx/src/charset.h
@@ -522,16 +522,3 @@ static const uint8_t vga8x16[256*16] =
0x00, 0x00, 0x00, 0x00, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
-
-#include "vs_debugfont.bin.h"
-#include "fs_debugfont.bin.h"
-
-#include "vs_clear.bin.h"
-#include "fs_clear0.bin.h"
-#include "fs_clear1.bin.h"
-#include "fs_clear2.bin.h"
-#include "fs_clear3.bin.h"
-#include "fs_clear4.bin.h"
-#include "fs_clear5.bin.h"
-#include "fs_clear6.bin.h"
-#include "fs_clear7.bin.h"
diff --git a/3rdparty/bgfx/src/config.h b/3rdparty/bgfx/src/config.h
index f9e4ddd2408..6ef37b421b8 100644
--- a/3rdparty/bgfx/src/config.h
+++ b/3rdparty/bgfx/src/config.h
@@ -19,7 +19,8 @@
&& !defined(BGFX_CONFIG_RENDERER_OPENGL) \
&& !defined(BGFX_CONFIG_RENDERER_OPENGLES) \
&& !defined(BGFX_CONFIG_RENDERER_VULKAN) \
- && !defined(BGFX_CONFIG_RENDERER_NULL)
+ && !defined(BGFX_CONFIG_RENDERER_GNM) \
+ && !defined(BGFX_CONFIG_RENDERER_NOOP)
# ifndef BGFX_CONFIG_RENDERER_DIRECT3D9
# define BGFX_CONFIG_RENDERER_DIRECT3D9 (0 \
@@ -72,11 +73,21 @@
# endif // BGFX_CONFIG_RENDERER_OPENGLES
# ifndef BGFX_CONFIG_RENDERER_VULKAN
-# define BGFX_CONFIG_RENDERER_VULKAN 0
+# define BGFX_CONFIG_RENDERER_VULKAN (0 \
+ || BX_PLATFORM_ANDROID \
+ || BX_PLATFORM_LINUX \
+ || BX_PLATFORM_WINDOWS \
+ ? 1 : 0)
# endif // BGFX_CONFIG_RENDERER_VULKAN
-# ifndef BGFX_CONFIG_RENDERER_NULL
-# define BGFX_CONFIG_RENDERER_NULL (!(0 \
+# ifndef BGFX_CONFIG_RENDERER_GNM
+# define BGFX_CONFIG_RENDERER_GNM (0 \
+ || BX_PLATFORM_PS4 \
+ ? 1 : 0)
+# endif // BGFX_CONFIG_RENDERER_GNM
+
+# ifndef BGFX_CONFIG_RENDERER_NOOP
+# define BGFX_CONFIG_RENDERER_NOOP (!(0 \
|| BGFX_CONFIG_RENDERER_DIRECT3D9 \
|| BGFX_CONFIG_RENDERER_DIRECT3D11 \
|| BGFX_CONFIG_RENDERER_DIRECT3D12 \
@@ -84,8 +95,9 @@
|| BGFX_CONFIG_RENDERER_OPENGL \
|| BGFX_CONFIG_RENDERER_OPENGLES \
|| BGFX_CONFIG_RENDERER_VULKAN \
+ || BGFX_CONFIG_RENDERER_GNM \
? 1 : 0) )
-# endif // BGFX_CONFIG_RENDERER_NULL
+# endif // BGFX_CONFIG_RENDERER_NOOP
#else
# ifndef BGFX_CONFIG_RENDERER_DIRECT3D9
# define BGFX_CONFIG_RENDERER_DIRECT3D9 0
@@ -115,9 +127,13 @@
# define BGFX_CONFIG_RENDERER_VULKAN 0
# endif // BGFX_CONFIG_RENDERER_VULKAN
-# ifndef BGFX_CONFIG_RENDERER_NULL
-# define BGFX_CONFIG_RENDERER_NULL 0
-# endif // BGFX_CONFIG_RENDERER_NULL
+# ifndef BGFX_CONFIG_RENDERER_GNM
+# define BGFX_CONFIG_RENDERER_GNM 0
+# endif // BGFX_CONFIG_RENDERER_GNM
+
+# ifndef BGFX_CONFIG_RENDERER_NOOP
+# define BGFX_CONFIG_RENDERER_NOOP 0
+# endif // BGFX_CONFIG_RENDERER_NOOP
#endif // !defined...
#if BGFX_CONFIG_RENDERER_OPENGL && BGFX_CONFIG_RENDERER_OPENGL < 21
@@ -237,6 +253,10 @@
# define BGFX_CONFIG_MAX_VERTEX_BUFFERS (4<<10)
#endif // BGFX_CONFIG_MAX_VERTEX_BUFFERS
+#ifndef BGFX_CONFIG_MAX_VERTEX_STREAMS
+# define BGFX_CONFIG_MAX_VERTEX_STREAMS 1
+#endif // BGFX_CONFIG_MAX_VERTEX_STREAMS
+
#ifndef BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS
# define BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS (4<<10)
#endif // BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS
@@ -315,4 +335,16 @@
# define BGFX_CONFIG_PROFILER_REMOTERY_BUILD_LIB BGFX_CONFIG_PROFILER_REMOTERY
#endif // BGFX_CONFIG_PROFILER_REMOTERY_BUILD_LIB
+#ifndef BGFX_CONFIG_RENDERDOC_LOG_FILEPATH
+# define BGFX_CONFIG_RENDERDOC_LOG_FILEPATH "temp/bgfx"
+#endif // BGFX_CONFIG_RENDERDOC_LOG_FILEPATH
+
+#ifndef BGFX_CONFIG_RENDERDOC_CAPTURE_KEYS
+# define BGFX_CONFIG_RENDERDOC_CAPTURE_KEYS { eRENDERDOC_Key_F11 }
+#endif // BGFX_CONFIG_RENDERDOC_CAPTURE_KEYS
+
+#ifndef BGFX_CONFIG_API_SEMAPHORE_TIMEOUT
+# define BGFX_CONFIG_API_SEMAPHORE_TIMEOUT (-1)
+#endif // BGFX_CONFIG_API_SEMAPHORE_TIMEOUT
+
#endif // BGFX_CONFIG_H_HEADER_GUARD
diff --git a/3rdparty/bgfx/src/debug_renderdoc.cpp b/3rdparty/bgfx/src/debug_renderdoc.cpp
index 0aca626468b..db1fabbab94 100644
--- a/3rdparty/bgfx/src/debug_renderdoc.cpp
+++ b/3rdparty/bgfx/src/debug_renderdoc.cpp
@@ -74,12 +74,12 @@ namespace bgfx
if (NULL != RENDERDOC_GetAPI
&& 1 == RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_1_0, (void**)&s_renderDoc) )
{
- s_renderDoc->SetLogFilePathTemplate("temp/bgfx");
+ s_renderDoc->SetLogFilePathTemplate(BGFX_CONFIG_RENDERDOC_LOG_FILEPATH);
s_renderDoc->SetFocusToggleKeys(NULL, 0);
- RENDERDOC_InputButton captureKey = eRENDERDOC_Key_F11;
- s_renderDoc->SetCaptureKeys(&captureKey, 1);
+ RENDERDOC_InputButton captureKeys[] = BGFX_CONFIG_RENDERDOC_CAPTURE_KEYS;
+ s_renderDoc->SetCaptureKeys(captureKeys, BX_COUNTOF(captureKeys) );
s_renderDoc->SetCaptureOptionU32(eRENDERDOC_Option_AllowVSync, 1);
s_renderDoc->SetCaptureOptionU32(eRENDERDOC_Option_SaveAllInitials, 1);
diff --git a/3rdparty/bgfx/src/fs_clear0.bin.h b/3rdparty/bgfx/src/fs_clear0.bin.h
index 1bc08adc675..e9e8cc6f6c1 100644
--- a/3rdparty/bgfx/src/fs_clear0.bin.h
+++ b/3rdparty/bgfx/src/fs_clear0.bin.h
@@ -9,11 +9,11 @@ static const uint8_t fs_clear0_glsl[128] =
0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, // olor = bgfx_clea
0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5b, 0x30, 0x5d, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // r_color[0];.}...
};
-static const uint8_t fs_clear0_dx9[204] =
+static const uint8_t fs_clear0_dx9[208] =
{
0x46, 0x53, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, 0x67, 0x66, 0x78, 0x5f, // FSH........bgfx_
0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x12, 0x08, 0x00, 0x00, 0x01, // clear_color.....
- 0x00, 0xa8, 0x00, 0x00, 0x03, 0xff, 0xff, 0xfe, 0xff, 0x24, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, // .........$.CTAB.
+ 0x00, 0xac, 0x00, 0x00, 0x03, 0xff, 0xff, 0xfe, 0xff, 0x25, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, // .........%.CTAB.
0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x1c, // ...[............
0x00, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, // .......T...0....
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, // .......D.......b
@@ -21,9 +21,9 @@ static const uint8_t fs_clear0_dx9[204] =
0xab, 0xab, 0xab, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, // ................
0x00, 0x00, 0x00, 0x70, 0x73, 0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, // ...ps_3_0.Micros
0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, // oft (R) HLSL Sha
- 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, // der Compiler 9.2
- 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, // 9.952.3111......
- 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0xff, 0xff, 0x00, 0x00, 0x00, // ............
+ 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2e, // der Compiler 10.
+ 0x30, 0x2e, 0x31, 0x30, 0x30, 0x31, 0x31, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, 0xab, 0x01, // 0.10011.16384...
+ 0x00, 0x00, 0x02, 0x00, 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0xff, 0xff, 0x00, 0x00, 0x00, // ................
};
static const uint8_t fs_clear0_dx11[339] =
{
@@ -80,3 +80,5 @@ static const uint8_t fs_clear0_mtl[426] =
0x5b, 0x30, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, // [0];. return _m
0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // tl_o;.}...
};
+extern const uint8_t* fs_clear0_pssl;
+extern const uint32_t fs_clear0_pssl_size;
diff --git a/3rdparty/bgfx/src/fs_clear0.sc b/3rdparty/bgfx/src/fs_clear0.sc
index 07131b43823..cedd5a6f652 100644
--- a/3rdparty/bgfx/src/fs_clear0.sc
+++ b/3rdparty/bgfx/src/fs_clear0.sc
@@ -3,6 +3,8 @@
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
+#include "bgfx_shader.sh"
+
uniform vec4 bgfx_clear_color[8];
void main()
diff --git a/3rdparty/bgfx/src/fs_clear1.bin.h b/3rdparty/bgfx/src/fs_clear1.bin.h
index 78195927d3f..40bb8481160 100644
--- a/3rdparty/bgfx/src/fs_clear1.bin.h
+++ b/3rdparty/bgfx/src/fs_clear1.bin.h
@@ -12,11 +12,11 @@ static const uint8_t fs_clear1_glsl[170] =
0x20, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // bgfx_clear_colo
0x72, 0x5b, 0x31, 0x5d, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // r[1];.}...
};
-static const uint8_t fs_clear1_dx9[216] =
+static const uint8_t fs_clear1_dx9[220] =
{
0x46, 0x53, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, 0x67, 0x66, 0x78, 0x5f, // FSH........bgfx_
0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x12, 0x08, 0x00, 0x00, 0x02, // clear_color.....
- 0x00, 0xb4, 0x00, 0x00, 0x03, 0xff, 0xff, 0xfe, 0xff, 0x24, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, // .........$.CTAB.
+ 0x00, 0xb8, 0x00, 0x00, 0x03, 0xff, 0xff, 0xfe, 0xff, 0x25, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, // .........%.CTAB.
0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x1c, // ...[............
0x00, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, // .......T...0....
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, // .......D.......b
@@ -24,10 +24,10 @@ static const uint8_t fs_clear1_dx9[216] =
0xab, 0xab, 0xab, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, // ................
0x00, 0x00, 0x00, 0x70, 0x73, 0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, // ...ps_3_0.Micros
0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, // oft (R) HLSL Sha
- 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, // der Compiler 9.2
- 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, // 9.952.3111......
- 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x01, 0x08, 0x0f, 0x80, 0x01, // ................
- 0x00, 0xe4, 0xa0, 0xff, 0xff, 0x00, 0x00, 0x00, // ........
+ 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2e, // der Compiler 10.
+ 0x30, 0x2e, 0x31, 0x30, 0x30, 0x31, 0x31, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, 0xab, 0x01, // 0.10011.16384...
+ 0x00, 0x00, 0x02, 0x00, 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x01, // ................
+ 0x08, 0x0f, 0x80, 0x01, 0x00, 0xe4, 0xa0, 0xff, 0xff, 0x00, 0x00, 0x00, // ............
};
static const uint8_t fs_clear1_dx11[411] =
{
@@ -95,3 +95,5 @@ static const uint8_t fs_clear1_mtl[531] =
0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, // return _mtl_o;.}
0x0a, 0x0a, 0x00, // ...
};
+extern const uint8_t* fs_clear1_pssl;
+extern const uint32_t fs_clear1_pssl_size;
diff --git a/3rdparty/bgfx/src/fs_clear1.sc b/3rdparty/bgfx/src/fs_clear1.sc
index 160c1a83193..277a455c0bf 100644
--- a/3rdparty/bgfx/src/fs_clear1.sc
+++ b/3rdparty/bgfx/src/fs_clear1.sc
@@ -3,6 +3,8 @@
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
+#include "bgfx_shader.sh"
+
uniform vec4 bgfx_clear_color[8];
void main()
diff --git a/3rdparty/bgfx/src/fs_clear2.bin.h b/3rdparty/bgfx/src/fs_clear2.bin.h
index 049708bfe32..7d19bb38b53 100644
--- a/3rdparty/bgfx/src/fs_clear2.bin.h
+++ b/3rdparty/bgfx/src/fs_clear2.bin.h
@@ -15,11 +15,11 @@ static const uint8_t fs_clear2_glsl[210] =
0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5b, 0x32, 0x5d, 0x3b, 0x0a, 0x7d, 0x0a, // ear_color[2];.}.
0x0a, 0x00, // ..
};
-static const uint8_t fs_clear2_dx9[228] =
+static const uint8_t fs_clear2_dx9[232] =
{
0x46, 0x53, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, 0x67, 0x66, 0x78, 0x5f, // FSH........bgfx_
0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x12, 0x08, 0x00, 0x00, 0x03, // clear_color.....
- 0x00, 0xc0, 0x00, 0x00, 0x03, 0xff, 0xff, 0xfe, 0xff, 0x24, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, // .........$.CTAB.
+ 0x00, 0xc4, 0x00, 0x00, 0x03, 0xff, 0xff, 0xfe, 0xff, 0x25, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, // .........%.CTAB.
0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x1c, // ...[............
0x00, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, // .......T...0....
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, // .......D.......b
@@ -27,11 +27,11 @@ static const uint8_t fs_clear2_dx9[228] =
0xab, 0xab, 0xab, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, // ................
0x00, 0x00, 0x00, 0x70, 0x73, 0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, // ...ps_3_0.Micros
0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, // oft (R) HLSL Sha
- 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, // der Compiler 9.2
- 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, // 9.952.3111......
- 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x01, 0x08, 0x0f, 0x80, 0x01, // ................
- 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x0f, 0x80, 0x02, 0x00, 0xe4, 0xa0, 0xff, // ................
- 0xff, 0x00, 0x00, 0x00, // ....
+ 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2e, // der Compiler 10.
+ 0x30, 0x2e, 0x31, 0x30, 0x30, 0x31, 0x31, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, 0xab, 0x01, // 0.10011.16384...
+ 0x00, 0x00, 0x02, 0x00, 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x01, // ................
+ 0x08, 0x0f, 0x80, 0x01, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x0f, 0x80, 0x02, // ................
+ 0x00, 0xe4, 0xa0, 0xff, 0xff, 0x00, 0x00, 0x00, // ........
};
static const uint8_t fs_clear2_dx11[483] =
{
@@ -109,3 +109,5 @@ static const uint8_t fs_clear2_mtl[621] =
0x6c, 0x6f, 0x72, 0x5b, 0x32, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, // lor[2];. return
0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // _mtl_o;.}...
};
+extern const uint8_t* fs_clear2_pssl;
+extern const uint32_t fs_clear2_pssl_size;
diff --git a/3rdparty/bgfx/src/fs_clear2.sc b/3rdparty/bgfx/src/fs_clear2.sc
index f0a849efae2..bfab0e8d31e 100644
--- a/3rdparty/bgfx/src/fs_clear2.sc
+++ b/3rdparty/bgfx/src/fs_clear2.sc
@@ -3,6 +3,8 @@
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
+#include "bgfx_shader.sh"
+
uniform vec4 bgfx_clear_color[8];
void main()
diff --git a/3rdparty/bgfx/src/fs_clear3.bin.h b/3rdparty/bgfx/src/fs_clear3.bin.h
index 667d2f12f02..82f60bc695a 100644
--- a/3rdparty/bgfx/src/fs_clear3.bin.h
+++ b/3rdparty/bgfx/src/fs_clear3.bin.h
@@ -17,11 +17,11 @@ static const uint8_t fs_clear3_glsl[250] =
0x20, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // bgfx_clear_colo
0x72, 0x5b, 0x33, 0x5d, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // r[3];.}...
};
-static const uint8_t fs_clear3_dx9[240] =
+static const uint8_t fs_clear3_dx9[244] =
{
0x46, 0x53, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, 0x67, 0x66, 0x78, 0x5f, // FSH........bgfx_
0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x12, 0x08, 0x00, 0x00, 0x04, // clear_color.....
- 0x00, 0xcc, 0x00, 0x00, 0x03, 0xff, 0xff, 0xfe, 0xff, 0x24, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, // .........$.CTAB.
+ 0x00, 0xd0, 0x00, 0x00, 0x03, 0xff, 0xff, 0xfe, 0xff, 0x25, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, // .........%.CTAB.
0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x1c, // ...[............
0x00, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, // .......T...0....
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, // .......D.......b
@@ -29,11 +29,12 @@ static const uint8_t fs_clear3_dx9[240] =
0xab, 0xab, 0xab, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, // ................
0x00, 0x00, 0x00, 0x70, 0x73, 0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, // ...ps_3_0.Micros
0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, // oft (R) HLSL Sha
- 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, // der Compiler 9.2
- 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, // 9.952.3111......
- 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x01, 0x08, 0x0f, 0x80, 0x01, // ................
- 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x0f, 0x80, 0x02, 0x00, 0xe4, 0xa0, 0x01, // ................
- 0x00, 0x00, 0x02, 0x03, 0x08, 0x0f, 0x80, 0x03, 0x00, 0xe4, 0xa0, 0xff, 0xff, 0x00, 0x00, 0x00, // ................
+ 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2e, // der Compiler 10.
+ 0x30, 0x2e, 0x31, 0x30, 0x30, 0x31, 0x31, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, 0xab, 0x01, // 0.10011.16384...
+ 0x00, 0x00, 0x02, 0x00, 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x01, // ................
+ 0x08, 0x0f, 0x80, 0x01, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x0f, 0x80, 0x02, // ................
+ 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x03, 0x08, 0x0f, 0x80, 0x03, 0x00, 0xe4, 0xa0, 0xff, // ................
+ 0xff, 0x00, 0x00, 0x00, // ....
};
static const uint8_t fs_clear3_dx11[555] =
{
@@ -121,3 +122,5 @@ static const uint8_t fs_clear3_mtl[711] =
0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, // ;. return _mtl_
0x6f, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // o;.}...
};
+extern const uint8_t* fs_clear3_pssl;
+extern const uint32_t fs_clear3_pssl_size;
diff --git a/3rdparty/bgfx/src/fs_clear3.sc b/3rdparty/bgfx/src/fs_clear3.sc
index 529faaadbfa..de4c0729110 100644
--- a/3rdparty/bgfx/src/fs_clear3.sc
+++ b/3rdparty/bgfx/src/fs_clear3.sc
@@ -3,6 +3,8 @@
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
+#include "bgfx_shader.sh"
+
uniform vec4 bgfx_clear_color[8];
void main()
diff --git a/3rdparty/bgfx/src/fs_clear4.bin.h b/3rdparty/bgfx/src/fs_clear4.bin.h
index 0272fdb11c7..8d91172fc31 100644
--- a/3rdparty/bgfx/src/fs_clear4.bin.h
+++ b/3rdparty/bgfx/src/fs_clear4.bin.h
@@ -20,11 +20,11 @@ static const uint8_t fs_clear4_glsl[290] =
0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5b, 0x34, 0x5d, 0x3b, 0x0a, 0x7d, 0x0a, // ear_color[4];.}.
0x0a, 0x00, // ..
};
-static const uint8_t fs_clear4_dx9[240] =
+static const uint8_t fs_clear4_dx9[244] =
{
0x46, 0x53, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, 0x67, 0x66, 0x78, 0x5f, // FSH........bgfx_
0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x12, 0x08, 0x00, 0x00, 0x04, // clear_color.....
- 0x00, 0xcc, 0x00, 0x00, 0x03, 0xff, 0xff, 0xfe, 0xff, 0x24, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, // .........$.CTAB.
+ 0x00, 0xd0, 0x00, 0x00, 0x03, 0xff, 0xff, 0xfe, 0xff, 0x25, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, // .........%.CTAB.
0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x1c, // ...[............
0x00, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, // .......T...0....
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, // .......D.......b
@@ -32,11 +32,12 @@ static const uint8_t fs_clear4_dx9[240] =
0xab, 0xab, 0xab, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, // ................
0x00, 0x00, 0x00, 0x70, 0x73, 0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, // ...ps_3_0.Micros
0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, // oft (R) HLSL Sha
- 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, // der Compiler 9.2
- 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, // 9.952.3111......
- 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x01, 0x08, 0x0f, 0x80, 0x01, // ................
- 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x0f, 0x80, 0x02, 0x00, 0xe4, 0xa0, 0x01, // ................
- 0x00, 0x00, 0x02, 0x03, 0x08, 0x0f, 0x80, 0x03, 0x00, 0xe4, 0xa0, 0xff, 0xff, 0x00, 0x00, 0x00, // ................
+ 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2e, // der Compiler 10.
+ 0x30, 0x2e, 0x31, 0x30, 0x30, 0x31, 0x31, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, 0xab, 0x01, // 0.10011.16384...
+ 0x00, 0x00, 0x02, 0x00, 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x01, // ................
+ 0x08, 0x0f, 0x80, 0x01, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x0f, 0x80, 0x02, // ................
+ 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x03, 0x08, 0x0f, 0x80, 0x03, 0x00, 0xe4, 0xa0, 0xff, // ................
+ 0xff, 0x00, 0x00, 0x00, // ....
};
static const uint8_t fs_clear4_dx11[499] =
{
@@ -127,3 +128,5 @@ static const uint8_t fs_clear4_mtl[801] =
0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, // turn _mtl_o;.}..
0x00, // .
};
+extern const uint8_t* fs_clear4_pssl;
+extern const uint32_t fs_clear4_pssl_size;
diff --git a/3rdparty/bgfx/src/fs_clear4.sc b/3rdparty/bgfx/src/fs_clear4.sc
index efc69e23776..725ada0829a 100644
--- a/3rdparty/bgfx/src/fs_clear4.sc
+++ b/3rdparty/bgfx/src/fs_clear4.sc
@@ -3,6 +3,8 @@
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
+#include "bgfx_shader.sh"
+
uniform vec4 bgfx_clear_color[8];
void main()
diff --git a/3rdparty/bgfx/src/fs_clear5.bin.h b/3rdparty/bgfx/src/fs_clear5.bin.h
index 4321d7999d0..455fa0b6f25 100644
--- a/3rdparty/bgfx/src/fs_clear5.bin.h
+++ b/3rdparty/bgfx/src/fs_clear5.bin.h
@@ -22,11 +22,11 @@ static const uint8_t fs_clear5_glsl[330] =
0x20, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // bgfx_clear_colo
0x72, 0x5b, 0x35, 0x5d, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // r[5];.}...
};
-static const uint8_t fs_clear5_dx9[240] =
+static const uint8_t fs_clear5_dx9[244] =
{
0x46, 0x53, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, 0x67, 0x66, 0x78, 0x5f, // FSH........bgfx_
0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x12, 0x08, 0x00, 0x00, 0x04, // clear_color.....
- 0x00, 0xcc, 0x00, 0x00, 0x03, 0xff, 0xff, 0xfe, 0xff, 0x24, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, // .........$.CTAB.
+ 0x00, 0xd0, 0x00, 0x00, 0x03, 0xff, 0xff, 0xfe, 0xff, 0x25, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, // .........%.CTAB.
0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x1c, // ...[............
0x00, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, // .......T...0....
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, // .......D.......b
@@ -34,11 +34,12 @@ static const uint8_t fs_clear5_dx9[240] =
0xab, 0xab, 0xab, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, // ................
0x00, 0x00, 0x00, 0x70, 0x73, 0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, // ...ps_3_0.Micros
0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, // oft (R) HLSL Sha
- 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, // der Compiler 9.2
- 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, // 9.952.3111......
- 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x01, 0x08, 0x0f, 0x80, 0x01, // ................
- 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x0f, 0x80, 0x02, 0x00, 0xe4, 0xa0, 0x01, // ................
- 0x00, 0x00, 0x02, 0x03, 0x08, 0x0f, 0x80, 0x03, 0x00, 0xe4, 0xa0, 0xff, 0xff, 0x00, 0x00, 0x00, // ................
+ 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2e, // der Compiler 10.
+ 0x30, 0x2e, 0x31, 0x30, 0x30, 0x31, 0x31, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, 0xab, 0x01, // 0.10011.16384...
+ 0x00, 0x00, 0x02, 0x00, 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x01, // ................
+ 0x08, 0x0f, 0x80, 0x01, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x0f, 0x80, 0x02, // ................
+ 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x03, 0x08, 0x0f, 0x80, 0x03, 0x00, 0xe4, 0xa0, 0xff, // ................
+ 0xff, 0x00, 0x00, 0x00, // ....
};
static const uint8_t fs_clear5_dx11[559] =
{
@@ -137,3 +138,5 @@ static const uint8_t fs_clear5_mtl[891] =
0x72, 0x5b, 0x35, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, // r[5];. return _
0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // mtl_o;.}...
};
+extern const uint8_t* fs_clear5_pssl;
+extern const uint32_t fs_clear5_pssl_size;
diff --git a/3rdparty/bgfx/src/fs_clear5.sc b/3rdparty/bgfx/src/fs_clear5.sc
index 625dcc42493..7444467ffbe 100644
--- a/3rdparty/bgfx/src/fs_clear5.sc
+++ b/3rdparty/bgfx/src/fs_clear5.sc
@@ -3,6 +3,8 @@
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
+#include "bgfx_shader.sh"
+
uniform vec4 bgfx_clear_color[8];
void main()
diff --git a/3rdparty/bgfx/src/fs_clear6.bin.h b/3rdparty/bgfx/src/fs_clear6.bin.h
index fb602785679..dd845365996 100644
--- a/3rdparty/bgfx/src/fs_clear6.bin.h
+++ b/3rdparty/bgfx/src/fs_clear6.bin.h
@@ -25,11 +25,11 @@ static const uint8_t fs_clear6_glsl[370] =
0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5b, 0x36, 0x5d, 0x3b, 0x0a, 0x7d, 0x0a, // ear_color[6];.}.
0x0a, 0x00, // ..
};
-static const uint8_t fs_clear6_dx9[240] =
+static const uint8_t fs_clear6_dx9[244] =
{
0x46, 0x53, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, 0x67, 0x66, 0x78, 0x5f, // FSH........bgfx_
0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x12, 0x08, 0x00, 0x00, 0x04, // clear_color.....
- 0x00, 0xcc, 0x00, 0x00, 0x03, 0xff, 0xff, 0xfe, 0xff, 0x24, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, // .........$.CTAB.
+ 0x00, 0xd0, 0x00, 0x00, 0x03, 0xff, 0xff, 0xfe, 0xff, 0x25, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, // .........%.CTAB.
0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x1c, // ...[............
0x00, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, // .......T...0....
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, // .......D.......b
@@ -37,11 +37,12 @@ static const uint8_t fs_clear6_dx9[240] =
0xab, 0xab, 0xab, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, // ................
0x00, 0x00, 0x00, 0x70, 0x73, 0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, // ...ps_3_0.Micros
0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, // oft (R) HLSL Sha
- 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, // der Compiler 9.2
- 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, // 9.952.3111......
- 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x01, 0x08, 0x0f, 0x80, 0x01, // ................
- 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x0f, 0x80, 0x02, 0x00, 0xe4, 0xa0, 0x01, // ................
- 0x00, 0x00, 0x02, 0x03, 0x08, 0x0f, 0x80, 0x03, 0x00, 0xe4, 0xa0, 0xff, 0xff, 0x00, 0x00, 0x00, // ................
+ 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2e, // der Compiler 10.
+ 0x30, 0x2e, 0x31, 0x30, 0x30, 0x31, 0x31, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, 0xab, 0x01, // 0.10011.16384...
+ 0x00, 0x00, 0x02, 0x00, 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x01, // ................
+ 0x08, 0x0f, 0x80, 0x01, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x0f, 0x80, 0x02, // ................
+ 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x03, 0x08, 0x0f, 0x80, 0x03, 0x00, 0xe4, 0xa0, 0xff, // ................
+ 0xff, 0x00, 0x00, 0x00, // ....
};
static const uint8_t fs_clear6_dx11[619] =
{
@@ -150,3 +151,5 @@ static const uint8_t fs_clear6_mtl[981] =
0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, // return _mtl_o;
0x0a, 0x7d, 0x0a, 0x0a, 0x00, // .}...
};
+extern const uint8_t* fs_clear6_pssl;
+extern const uint32_t fs_clear6_pssl_size;
diff --git a/3rdparty/bgfx/src/fs_clear6.sc b/3rdparty/bgfx/src/fs_clear6.sc
index c7ae56a3e14..c5843fdcb24 100644
--- a/3rdparty/bgfx/src/fs_clear6.sc
+++ b/3rdparty/bgfx/src/fs_clear6.sc
@@ -3,6 +3,8 @@
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
+#include "bgfx_shader.sh"
+
uniform vec4 bgfx_clear_color[8];
void main()
diff --git a/3rdparty/bgfx/src/fs_clear7.bin.h b/3rdparty/bgfx/src/fs_clear7.bin.h
index 1716ac32d86..caf3798fea4 100644
--- a/3rdparty/bgfx/src/fs_clear7.bin.h
+++ b/3rdparty/bgfx/src/fs_clear7.bin.h
@@ -27,11 +27,11 @@ static const uint8_t fs_clear7_glsl[410] =
0x20, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // bgfx_clear_colo
0x72, 0x5b, 0x37, 0x5d, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // r[7];.}...
};
-static const uint8_t fs_clear7_dx9[240] =
+static const uint8_t fs_clear7_dx9[244] =
{
0x46, 0x53, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, 0x67, 0x66, 0x78, 0x5f, // FSH........bgfx_
0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x12, 0x08, 0x00, 0x00, 0x04, // clear_color.....
- 0x00, 0xcc, 0x00, 0x00, 0x03, 0xff, 0xff, 0xfe, 0xff, 0x24, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, // .........$.CTAB.
+ 0x00, 0xd0, 0x00, 0x00, 0x03, 0xff, 0xff, 0xfe, 0xff, 0x25, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, // .........%.CTAB.
0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x1c, // ...[............
0x00, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, // .......T...0....
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, // .......D.......b
@@ -39,11 +39,12 @@ static const uint8_t fs_clear7_dx9[240] =
0xab, 0xab, 0xab, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, // ................
0x00, 0x00, 0x00, 0x70, 0x73, 0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, // ...ps_3_0.Micros
0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, // oft (R) HLSL Sha
- 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, // der Compiler 9.2
- 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, // 9.952.3111......
- 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x01, 0x08, 0x0f, 0x80, 0x01, // ................
- 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x0f, 0x80, 0x02, 0x00, 0xe4, 0xa0, 0x01, // ................
- 0x00, 0x00, 0x02, 0x03, 0x08, 0x0f, 0x80, 0x03, 0x00, 0xe4, 0xa0, 0xff, 0xff, 0x00, 0x00, 0x00, // ................
+ 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2e, // der Compiler 10.
+ 0x30, 0x2e, 0x31, 0x30, 0x30, 0x31, 0x31, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, 0xab, 0x01, // 0.10011.16384...
+ 0x00, 0x00, 0x02, 0x00, 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x01, // ................
+ 0x08, 0x0f, 0x80, 0x01, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x0f, 0x80, 0x02, // ................
+ 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x03, 0x08, 0x0f, 0x80, 0x03, 0x00, 0xe4, 0xa0, 0xff, // ................
+ 0xff, 0x00, 0x00, 0x00, // ....
};
static const uint8_t fs_clear7_dx11[679] =
{
@@ -161,3 +162,5 @@ static const uint8_t fs_clear7_mtl[1071] =
0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5b, 0x37, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, // color[7];. retu
0x72, 0x6e, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // rn _mtl_o;.}...
};
+extern const uint8_t* fs_clear7_pssl;
+extern const uint32_t fs_clear7_pssl_size;
diff --git a/3rdparty/bgfx/src/fs_clear7.sc b/3rdparty/bgfx/src/fs_clear7.sc
index fc8a11e4b94..4c58ba924da 100644
--- a/3rdparty/bgfx/src/fs_clear7.sc
+++ b/3rdparty/bgfx/src/fs_clear7.sc
@@ -3,6 +3,8 @@
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
+#include "bgfx_shader.sh"
+
uniform vec4 bgfx_clear_color[8];
void main()
diff --git a/3rdparty/bgfx/src/fs_debugfont.bin.h b/3rdparty/bgfx/src/fs_debugfont.bin.h
index 00e22f744cd..eaca9aaa6da 100644
--- a/3rdparty/bgfx/src/fs_debugfont.bin.h
+++ b/3rdparty/bgfx/src/fs_debugfont.bin.h
@@ -24,32 +24,32 @@ static const uint8_t fs_debugfont_glsl[354] =
0x72, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x7d, 0x0a, // r = tmpvar_1;.}.
0x0a, 0x00, // ..
};
-static const uint8_t fs_debugfont_dx9[370] =
+static const uint8_t fs_debugfont_dx9[374] =
{
0x46, 0x53, 0x48, 0x04, 0xb8, 0xbe, 0x22, 0x66, 0x01, 0x00, 0x0a, 0x73, 0x5f, 0x74, 0x65, 0x78, // FSH..."f...s_tex
- 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x01, 0x00, 0x00, 0x01, 0x00, 0x54, 0x01, 0x00, 0x03, 0xff, // Color0.....T....
- 0xff, 0xfe, 0xff, 0x22, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, // ...".CTAB....S..
+ 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x01, 0x00, 0x00, 0x01, 0x00, 0x58, 0x01, 0x00, 0x03, 0xff, // Color0.....X....
+ 0xff, 0xfe, 0xff, 0x23, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, // ...#.CTAB....S..
0x00, 0x00, 0x03, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x91, 0x00, // ................
0x00, 0x4c, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, // .L...0..........
0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, // .<.......s_texCo
0x6c, 0x6f, 0x72, 0x00, 0xab, 0x04, 0x00, 0x0c, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, // lor.............
0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x73, 0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, // .....ps_3_0.Micr
0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, // osoft (R) HLSL S
- 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, // hader Compiler 9
- 0x2e, 0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0x51, 0x00, 0x00, // .29.952.3111.Q..
- 0x05, 0x00, 0x00, 0x0f, 0xa0, 0x81, 0x80, 0x80, 0xbb, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, // ................
- 0xbf, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, // ................
- 0x90, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x01, 0x80, 0x01, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, // ................
- 0x02, 0x05, 0x00, 0x00, 0x80, 0x02, 0x00, 0x03, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // ................
- 0x90, 0x00, 0x08, 0x0f, 0xa0, 0x42, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80, 0x02, 0x00, 0xe4, // .....B..........
- 0x90, 0x00, 0x08, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x01, 0x00, 0x0f, 0x80, 0x01, 0x00, 0xe4, // ................
- 0x90, 0x02, 0x00, 0x00, 0x03, 0x01, 0x00, 0x0f, 0x80, 0x01, 0x00, 0xe4, 0x81, 0x00, 0x00, 0xe4, // ................
- 0x90, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0xe4, // ................
- 0x80, 0x01, 0x00, 0xe4, 0x90, 0x02, 0x00, 0x00, 0x03, 0x01, 0x00, 0x01, 0x80, 0x00, 0x00, 0xff, // ................
- 0x80, 0x00, 0x00, 0x00, 0xa0, 0x58, 0x00, 0x00, 0x04, 0x01, 0x00, 0x0f, 0x80, 0x01, 0x00, 0x00, // .....X..........
- 0x80, 0x00, 0x00, 0x55, 0xa0, 0x00, 0x00, 0xaa, 0xa0, 0x41, 0x00, 0x00, 0x01, 0x01, 0x00, 0x0f, // ...U.....A......
- 0x80, 0x01, 0x00, 0x00, 0x02, 0x00, 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0x80, 0xff, 0xff, 0x00, // ................
- 0x00, 0x00, // ..
+ 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, // hader Compiler 1
+ 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x30, 0x30, 0x31, 0x31, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, // 0.0.10011.16384.
+ 0xab, 0x51, 0x00, 0x00, 0x05, 0x00, 0x00, 0x0f, 0xa0, 0x81, 0x80, 0x80, 0xbb, 0x00, 0x00, 0x00, // .Q..............
+ 0x80, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, // ................
+ 0x80, 0x00, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x01, 0x80, 0x01, 0x00, 0x0f, // ................
+ 0x90, 0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x80, 0x02, 0x00, 0x03, 0x90, 0x1f, 0x00, 0x00, // ................
+ 0x02, 0x00, 0x00, 0x00, 0x90, 0x00, 0x08, 0x0f, 0xa0, 0x42, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, // .........B......
+ 0x80, 0x02, 0x00, 0xe4, 0x90, 0x00, 0x08, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x01, 0x00, 0x0f, // ................
+ 0x80, 0x01, 0x00, 0xe4, 0x90, 0x02, 0x00, 0x00, 0x03, 0x01, 0x00, 0x0f, 0x80, 0x01, 0x00, 0xe4, // ................
+ 0x81, 0x00, 0x00, 0xe4, 0x90, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x00, // ................
+ 0x80, 0x01, 0x00, 0xe4, 0x80, 0x01, 0x00, 0xe4, 0x90, 0x02, 0x00, 0x00, 0x03, 0x01, 0x00, 0x01, // ................
+ 0x80, 0x00, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00, 0xa0, 0x58, 0x00, 0x00, 0x04, 0x01, 0x00, 0x0f, // .........X......
+ 0x80, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x55, 0xa0, 0x00, 0x00, 0xaa, 0xa0, 0x41, 0x00, 0x00, // .......U.....A..
+ 0x01, 0x01, 0x00, 0x0f, 0x80, 0x01, 0x00, 0x00, 0x02, 0x00, 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, // ................
+ 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, // ......
};
static const uint8_t fs_debugfont_dx11[772] =
{
@@ -103,9 +103,9 @@ static const uint8_t fs_debugfont_dx11[772] =
0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x00, 0xab, 0xab, // ....SV_TARGET...
0x00, 0x00, 0x00, 0x00, // ....
};
-static const uint8_t fs_debugfont_mtl[810] =
+static const uint8_t fs_debugfont_mtl[820] =
{
- 0x46, 0x53, 0x48, 0x04, 0xb8, 0xbe, 0x22, 0x66, 0x00, 0x00, 0x1b, 0x03, 0x00, 0x00, 0x75, 0x73, // FSH..."f......us
+ 0x46, 0x53, 0x48, 0x04, 0xb8, 0xbe, 0x22, 0x66, 0x00, 0x00, 0x25, 0x03, 0x00, 0x00, 0x75, 0x73, // FSH..."f..%...us
0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, // ing namespace me
0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, // tal;.struct xlat
0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, // MtlShaderInput {
@@ -135,25 +135,28 @@ static const uint8_t fs_debugfont_mtl[810] =
0x6c, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x78, 0x6c, // ler(0)]]).{. xl
0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, // atMtlShaderOutpu
0x74, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x20, 0x20, 0x68, 0x61, 0x6c, 0x66, // t _mtl_o;. half
- 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, // 4 tmpvar_1;. tm
- 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x20, 0x3d, 0x20, 0x68, 0x61, 0x6c, 0x66, 0x34, 0x28, 0x73, // pvar_1 = half4(s
- 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, // _texColor.sample
- 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x73, 0x6d, 0x70, 0x5f, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, // (_mtlsmp_s_texCo
- 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x28, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x29, 0x28, 0x5f, 0x6d, // lor, (float2)(_m
- 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, // tl_i.v_texcoord0
- 0x29, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x68, 0x61, 0x6c, 0x66, 0x34, 0x20, 0x74, 0x6d, 0x70, // )));. half4 tmp
- 0x76, 0x61, 0x72, 0x5f, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // var_2;. tmpvar_
- 0x32, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x34, 0x29, 0x6d, 0x69, 0x78, 0x20, // 2 = ((half4)mix
- 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x31, // (_mtl_i.v_color1
- 0x2c, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, // , _mtl_i.v_color
- 0x30, 0x2c, 0x20, 0x28, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x29, 0x74, 0x6d, 0x70, 0x76, 0x61, // 0, (float4)tmpva
- 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x78, 0x78, 0x78, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x69, 0x66, // r_1.xxxx));. if
- 0x20, 0x28, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x2e, 0x77, 0x20, 0x3c, 0x20, // ((tmpvar_2.w <
- 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x30, 0x2e, 0x30, 0x30, 0x33, 0x39, 0x32, 0x31, 0x35, 0x36, // (half)0.00392156
- 0x39, 0x29, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x69, 0x73, 0x63, 0x61, 0x72, // 9)) {. discar
- 0x64, 0x5f, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, // d_fragment();.
- 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x46, // };. _mtl_o.gl_F
- 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // ragColor = tmpva
- 0x72, 0x5f, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, // r_2;. return _m
- 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // tl_o;.}...
+ 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x20, 0x3d, 0x20, 0x30, 0x3b, 0x0a, // 4 tmpvar_1 = 0;.
+ 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x20, 0x3d, 0x20, 0x68, 0x61, 0x6c, // tmpvar_1 = hal
+ 0x66, 0x34, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2e, 0x73, 0x61, // f4(s_texColor.sa
+ 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x73, 0x6d, 0x70, 0x5f, 0x73, 0x5f, 0x74, // mple(_mtlsmp_s_t
+ 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x28, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, // exColor, (float2
+ 0x29, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, // )(_mtl_i.v_texco
+ 0x6f, 0x72, 0x64, 0x30, 0x29, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x68, 0x61, 0x6c, 0x66, 0x34, // ord0)));. half4
+ 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x20, 0x3d, 0x20, 0x30, 0x3b, 0x0a, 0x20, // tmpvar_2 = 0;.
+ 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x68, 0x61, // tmpvar_2 = ((ha
+ 0x6c, 0x66, 0x34, 0x29, 0x6d, 0x69, 0x78, 0x20, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, // lf4)mix (_mtl_i.
+ 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x31, 0x2c, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, // v_color1, _mtl_i
+ 0x2e, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x2c, 0x20, 0x28, 0x66, 0x6c, 0x6f, 0x61, // .v_color0, (floa
+ 0x74, 0x34, 0x29, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x78, 0x78, 0x78, // t4)tmpvar_1.xxxx
+ 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, // ));. if ((tmpva
+ 0x72, 0x5f, 0x32, 0x2e, 0x77, 0x20, 0x3c, 0x20, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x28, 0x30, // r_2.w < (half)(0
+ 0x2e, 0x30, 0x30, 0x33, 0x39, 0x32, 0x31, 0x35, 0x36, 0x39, 0x29, 0x29, 0x29, 0x20, 0x7b, 0x0a, // .003921569))) {.
+ 0x20, 0x20, 0x20, 0x20, 0x64, 0x69, 0x73, 0x63, 0x61, 0x72, 0x64, 0x5f, 0x66, 0x72, 0x61, 0x67, // discard_frag
+ 0x6d, 0x65, 0x6e, 0x74, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x5f, // ment();. };. _
+ 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, // mtl_o.gl_FragCol
+ 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x3b, 0x0a, 0x20, // or = tmpvar_2;.
+ 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, // return _mtl_o;.
+ 0x7d, 0x0a, 0x0a, 0x00, // }...
};
+extern const uint8_t* fs_debugfont_pssl;
+extern const uint32_t fs_debugfont_pssl_size;
diff --git a/3rdparty/bgfx/src/glcontext_nsgl.mm b/3rdparty/bgfx/src/glcontext_nsgl.mm
index 61a39272253..50f35e42cd2 100644
--- a/3rdparty/bgfx/src/glcontext_nsgl.mm
+++ b/3rdparty/bgfx/src/glcontext_nsgl.mm
@@ -126,7 +126,7 @@ namespace bgfx { namespace gl
[glContext makeCurrentContext];
GLint interval = 0;
[glContext setValues:&interval forParameter:NSOpenGLCPSwapInterval];
-
+
// When initializing NSOpenGLView programatically (as we are), this sometimes doesn't
// get hooked up properly (especially when there are existing window elements). This ensures
// we are valid. Otherwise, you'll probably get a GL_INVALID_FRAMEBUFFER_OPERATION when
diff --git a/3rdparty/bgfx/src/glimports.h b/3rdparty/bgfx/src/glimports.h
index 40781f43da0..dfc345af7f3 100644
--- a/3rdparty/bgfx/src/glimports.h
+++ b/3rdparty/bgfx/src/glimports.h
@@ -162,6 +162,7 @@ typedef void (GL_APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, G
typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label);
typedef void (GL_APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param);
typedef void (GL_APIENTRYP PFNGLPOINTSIZEPROC) (GLfloat size);
+typedef void (GL_APIENTRYP PFNGLPOLYGONMODEPROC) (GLenum face, GLenum mode);
typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void);
typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length);
typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value);
@@ -404,7 +405,8 @@ GL_IMPORT______(false, PFNGLVIEWPORTPROC, glViewport);
# if BGFX_CONFIG_RENDERER_OPENGL
GL_IMPORT______(false, PFNGLCLEARDEPTHPROC, glClearDepth);
-GL_IMPORT______(false, PFNGLPOINTSIZEPROC, glPointSize);
+GL_IMPORT______(true, PFNGLPOINTSIZEPROC, glPointSize);
+GL_IMPORT______(true, PFNGLPOLYGONMODEPROC, glPolygonMode);
GL_IMPORT_ARB__(true, PFNGLDEBUGMESSAGECONTROLPROC, glDebugMessageControl);
GL_IMPORT_ARB__(true, PFNGLDEBUGMESSAGEINSERTPROC, glDebugMessageInsert);
@@ -467,6 +469,8 @@ GL_IMPORT______(true, PFNGLFRAMETERMINATORGREMEDYPROC, glFrameTermin
GL_IMPORT______(true, PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC, glGetTranslatedShaderSourceANGLE);
#if !BGFX_CONFIG_RENDERER_OPENGL
+GL_IMPORT______(true, PFNGLPOINTSIZEPROC, glPointSize);
+GL_IMPORT______(true, PFNGLPOLYGONMODEPROC, glPolygonMode);
GL_IMPORT_ANGLE(true, PFNGLBLITFRAMEBUFFERPROC, glBlitFramebuffer);
GL_IMPORT_ANGLE(true, PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC, glRenderbufferStorageMultisample);
diff --git a/3rdparty/bgfx/src/hmd.cpp b/3rdparty/bgfx/src/hmd.cpp
new file mode 100644
index 00000000000..fa23c3811b1
--- /dev/null
+++ b/3rdparty/bgfx/src/hmd.cpp
@@ -0,0 +1,212 @@
+/*
+ * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ */
+
+#include "hmd.h"
+
+namespace bgfx
+{
+ VR::VR()
+ : m_impl(NULL)
+ , m_framesUntilReconnect(0)
+ , m_enabled(false)
+ {
+ }
+
+ void VR::init(VRImplI* _impl)
+ {
+ if (NULL == _impl)
+ {
+ return;
+ }
+
+ if (!_impl->init() )
+ {
+ return;
+ }
+
+ m_impl = _impl;
+ m_impl->connect(&m_desc);
+
+ if (!m_impl->isConnected() )
+ {
+ connectFailed();
+ return;
+ }
+
+ m_hmdSize.m_w = m_desc.m_eyeSize[0].m_w + m_desc.m_eyeSize[1].m_w;
+ m_hmdSize.m_h = bx::uint32_max(m_desc.m_eyeSize[0].m_h, m_desc.m_eyeSize[1].m_h);
+ }
+
+ void VR::shutdown()
+ {
+ if (NULL == m_impl)
+ {
+ return;
+ }
+
+ m_impl->destroySwapChain();
+
+ if (m_impl->isConnected() )
+ {
+ m_impl->disconnect();
+ }
+
+ m_impl->shutdown();
+ m_impl = NULL;
+ m_enabled = false;
+ }
+
+ void VR::renderEyeStart(uint8_t _eye, Rect* _viewport)
+ {
+ BX_CHECK(m_enabled, "VR::renderEyeStart called while not enabled - render usage error");
+
+ _viewport->m_x = 0;
+ _viewport->m_y = 0;
+ _viewport->m_width = uint16_t(m_desc.m_eyeSize[_eye].m_w);
+ _viewport->m_height = uint16_t(m_desc.m_eyeSize[_eye].m_h);
+
+ m_impl->renderEyeStart(m_desc, _eye);
+ }
+
+ void VR::recenter()
+ {
+ if (NULL != m_impl)
+ {
+ m_impl->recenter();
+ }
+ }
+
+ void VR::preReset()
+ {
+ if (NULL != m_impl)
+ {
+ m_impl->destroyMirror();
+ }
+
+ m_enabled = false;
+ }
+
+ void VR::postReset(int _msaaSamples, int _mirrorWidth, int _mirrorHeight)
+ {
+ if (NULL != m_impl
+ && m_impl->createSwapChain(m_desc, _msaaSamples, _mirrorWidth, _mirrorHeight) )
+ {
+ m_enabled = true;
+ }
+ }
+
+ void VR::flip()
+ {
+ if (NULL == m_impl
+ || !m_enabled)
+ {
+ return;
+ }
+ else if (!m_impl->isConnected()
+ && !tryReconnect() )
+ {
+ return;
+ }
+
+ if (!m_impl->submitSwapChain(m_desc) )
+ {
+ m_impl->destroySwapChain();
+ m_impl->disconnect();
+ return;
+ }
+ }
+
+ void VR::swap(HMD& _hmd)
+ {
+ _hmd.flags = BGFX_HMD_NONE;
+
+ if (NULL == m_impl)
+ {
+ return;
+ }
+
+ _hmd.flags = BGFX_HMD_DEVICE_RESOLUTION;
+ _hmd.deviceWidth = m_desc.m_deviceSize.m_w;
+ _hmd.deviceHeight = m_desc.m_deviceSize.m_h;
+ _hmd.width = uint16_t(m_hmdSize.m_w);
+ _hmd.height = uint16_t(m_hmdSize.m_h);
+
+ if (!m_impl->updateTracking(_hmd) )
+ {
+ m_impl->destroySwapChain();
+ m_impl->disconnect();
+ }
+
+ if (!m_impl->isConnected() )
+ {
+ return;
+ }
+
+ for (int eye = 0; eye < 2; ++eye)
+ {
+ _hmd.eye[eye].fov[0] = m_desc.m_eyeFov[eye].m_up;
+ _hmd.eye[eye].fov[1] = m_desc.m_eyeFov[eye].m_down;
+ _hmd.eye[eye].fov[2] = m_desc.m_eyeFov[eye].m_left;
+ _hmd.eye[eye].fov[3] = m_desc.m_eyeFov[eye].m_right;
+ }
+
+ m_impl->updateInput(_hmd);
+ if (m_enabled)
+ {
+ _hmd.flags |= BGFX_HMD_RENDERING;
+ }
+ }
+
+ bool VR::tryReconnect()
+ {
+ if (!m_impl)
+ {
+ return false;
+ }
+
+ BX_CHECK(!m_impl->isConnected(), "VR::tryReconnect called when already connected. Usage error");
+
+ --m_framesUntilReconnect;
+ if (m_framesUntilReconnect > 0)
+ {
+ return false;
+ }
+
+ m_framesUntilReconnect = 90;
+ m_impl->connect(&m_desc);
+ if (!m_impl->isConnected() )
+ {
+ connectFailed();
+ return false;
+ }
+
+ m_hmdSize.m_w = m_desc.m_eyeSize[0].m_w + m_desc.m_eyeSize[1].m_w;
+ m_hmdSize.m_h = bx::uint32_max(m_desc.m_eyeSize[0].m_h, m_desc.m_eyeSize[1].m_h);
+ return true;
+ }
+
+ void VR::connectFailed()
+ {
+ // sane defaults
+ m_desc.m_deviceSize.m_w = 2160;
+ m_desc.m_deviceSize.m_h = 1200;
+ m_desc.m_deviceType = 0;
+ m_desc.m_refreshRate = 90.0f;
+ m_desc.m_neckOffset[0] = 0.0805f;
+ m_desc.m_neckOffset[1] = 0.075f;
+
+ for (int eye = 0; eye < 2; ++eye)
+ {
+ m_desc.m_eyeFov[eye].m_up = 1.32928634f;
+ m_desc.m_eyeFov[eye].m_down = 1.32928634f;
+ }
+
+ m_desc.m_eyeFov[0].m_left = 1.05865765f;
+ m_desc.m_eyeFov[0].m_right = 1.09236801f;
+ m_desc.m_eyeFov[1].m_left = 1.09236801f;
+ m_desc.m_eyeFov[1].m_right = 1.05865765f;
+ }
+
+} // namesapce bgfx
diff --git a/3rdparty/bgfx/src/hmd.h b/3rdparty/bgfx/src/hmd.h
new file mode 100644
index 00000000000..5832909eab7
--- /dev/null
+++ b/3rdparty/bgfx/src/hmd.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ */
+
+#ifndef BGFX_HMD_H_HEADER_GUARD
+#define BGFX_HMD_H_HEADER_GUARD
+
+#include "bgfx_p.h"
+
+namespace bgfx
+{
+ struct VRSize
+ {
+ uint32_t m_w;
+ uint32_t m_h;
+ };
+
+ struct VRFovTan
+ {
+ float m_up;
+ float m_down;
+ float m_left;
+ float m_right;
+ };
+
+ struct VRDesc
+ {
+ uint32_t m_deviceType;
+ float m_refreshRate;
+ VRSize m_deviceSize;
+ VRSize m_eyeSize[2];
+ VRFovTan m_eyeFov[2];
+ float m_neckOffset[2];
+ };
+
+ struct BX_NO_VTABLE VRImplI
+ {
+ virtual ~VRImplI() = 0;
+
+ virtual bool init() = 0;
+ virtual void shutdown() = 0;
+ virtual void connect(VRDesc* _desc) = 0;
+ virtual void disconnect() = 0;
+ virtual bool isConnected() const = 0;
+
+ virtual bool updateTracking(HMD& _hmd) = 0;
+ virtual void updateInput(HMD& _hmd) = 0;
+ virtual void recenter() = 0;
+
+ virtual bool createSwapChain(const VRDesc& _desc, int _msaaSamples, int _mirrorWidth, int _mirrorHeight);
+ virtual void destroySwapChain() = 0;
+ virtual void destroyMirror() = 0;
+ virtual void renderEyeStart(const VRDesc& _desc, uint8_t _eye) = 0;
+ virtual bool submitSwapChain(const VRDesc& _desc) = 0;
+ };
+
+ inline VRImplI::~VRImplI()
+ {
+ }
+
+ class VR
+ {
+ public:
+ VR();
+
+ void init(VRImplI* _impl);
+ void shutdown();
+
+ bool isInitialized() const
+ {
+ return NULL != m_impl;
+ }
+
+ bool isEnabled() const
+ {
+ return m_enabled;
+ }
+
+ void renderEyeStart(uint8_t _eye, Rect* _viewport);
+ void recenter();
+
+ void preReset();
+ void postReset(int _msaaSamples, int _mirrorWidth, int _mirrorHeight);
+ void flip();
+ void swap(HMD& _hmd);
+
+ private:
+ bool tryReconnect();
+ void connectFailed();
+
+ VRImplI* m_impl;
+ VRDesc m_desc;
+ VRSize m_hmdSize;
+ uint32_t m_framesUntilReconnect;
+ bool m_enabled;
+ };
+
+} // namespace bgfx
+
+#endif // BGFX_HMD_H_HEADER_GUARD
diff --git a/3rdparty/bgfx/src/hmd_openvr.cpp b/3rdparty/bgfx/src/hmd_openvr.cpp
index 59ae813afe8..9e360cbf18e 100644
--- a/3rdparty/bgfx/src/hmd_openvr.cpp
+++ b/3rdparty/bgfx/src/hmd_openvr.cpp
@@ -5,10 +5,8 @@
#include "hmd_openvr.h"
-BX_PRAGMA_DIAGNOSTIC_PUSH()
BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wunused-variable")
#include <openvr/openvr_capi.h>
-BX_PRAGMA_DIAGNOSTIC_POP()
namespace bgfx
{
diff --git a/3rdparty/bgfx/src/hmd_ovr.cpp b/3rdparty/bgfx/src/hmd_ovr.cpp
index c63f9d90c6d..648f5638121 100644
--- a/3rdparty/bgfx/src/hmd_ovr.cpp
+++ b/3rdparty/bgfx/src/hmd_ovr.cpp
@@ -3,10 +3,12 @@
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
-#include "hmd_ovr.h"
+#include "bgfx_p.h"
#if BGFX_CONFIG_USE_OVR
+#include "hmd_ovr.h"
+
namespace bgfx
{
#define _OVR_CHECK(_call) \
@@ -21,244 +23,183 @@ namespace bgfx
# define OVR_CHECK(_call) _call
#endif // BGFX_CONFIG_DEBUG
- OVR::OVR()
- : m_hmd(NULL)
- , m_enabled(false)
- , m_mirror(NULL)
- , m_frameIndex(0)
- , m_sensorSampleTime(0)
+ VRImplOVR::VRImplOVR()
+ : m_session(NULL)
{
- memset(m_eyeBuffers, 0, sizeof(m_eyeBuffers));
}
- OVR::~OVR()
+ VRImplOVR::~VRImplOVR()
{
- BX_CHECK(NULL == m_hmd, "OVR not shutdown properly.");
- }
-
- void OVR::init()
- {
- ovrResult result = ovr_Initialize(NULL);
-
- if (result != ovrSuccess)
- {
- BX_TRACE("Unable to create OVR device.");
- return;
- }
-
- ovrGraphicsLuid luid;
- result = ovr_Create(&m_hmd, &luid);
- if (result != ovrSuccess)
+ if (NULL != g_platformData.session)
{
- BX_TRACE("Unable to create OVR device.");
return;
}
- m_hmdDesc = ovr_GetHmdDesc(m_hmd);
-
- BX_TRACE("HMD: %s, %s, firmware: %d.%d"
- , m_hmdDesc.ProductName
- , m_hmdDesc.Manufacturer
- , m_hmdDesc.FirmwareMajor
- , m_hmdDesc.FirmwareMinor
- );
-
- ovrSizei sizeL = ovr_GetFovTextureSize(m_hmd, ovrEye_Left, m_hmdDesc.DefaultEyeFov[0], 1.0f);
- ovrSizei sizeR = ovr_GetFovTextureSize(m_hmd, ovrEye_Right, m_hmdDesc.DefaultEyeFov[1], 1.0f);
- m_hmdSize.w = sizeL.w + sizeR.w;
- m_hmdSize.h = bx::uint32_max(sizeL.h, sizeR.h);
+ BX_CHECK(NULL == m_session, "OVR not shutdown properly.");
}
- void OVR::shutdown()
+ bool VRImplOVR::init()
{
- BX_CHECK(!m_enabled, "HMD not disabled.");
-
- for (uint32_t ii = 0; ii < 2; ++ii)
+ if (NULL != g_platformData.session)
{
- if (NULL != m_eyeBuffers[ii])
- {
- m_eyeBuffers[ii]->destroy(m_hmd);
- m_eyeBuffers[ii] = NULL;
- }
+ return true;
}
- if (NULL != m_mirror)
+ ovrResult initialized = ovr_Initialize(NULL);
+ if (!OVR_SUCCESS(initialized))
{
- m_mirror->destroy(m_hmd);
- m_mirror = NULL;
+ BX_TRACE("Unable to initialize OVR runtime.");
+ return false;
}
- ovr_Destroy(m_hmd);
- m_hmd = NULL;
- ovr_Shutdown();
+ return true;
}
- void OVR::getViewport(uint8_t _eye, Rect* _viewport)
+ void VRImplOVR::shutdown()
{
- _viewport->m_x = 0;
- _viewport->m_y = 0;
- _viewport->m_width = m_eyeBuffers[_eye]->m_eyeTextureSize.w;
- _viewport->m_height = m_eyeBuffers[_eye]->m_eyeTextureSize.h;
- }
+ if (NULL != g_platformData.session)
+ {
+ return;
+ }
- void OVR::renderEyeStart(uint8_t _eye)
- {
- m_eyeBuffers[_eye]->render(m_hmd);
+ ovr_Shutdown();
}
- bool OVR::postReset()
+ void VRImplOVR::connect(VRDesc* _desc)
{
- if (NULL == m_hmd)
+ if (NULL == g_platformData.session)
{
- return false;
+ ovrGraphicsLuid luid;
+ ovrResult result = ovr_Create(&m_session, &luid);
+ if (!OVR_SUCCESS(result))
+ {
+ BX_TRACE("Failed to create OVR device.");
+ return;
+ }
}
-
- for (uint32_t ii = 0; ii < 2; ++ii)
+ else
{
- m_erd[ii] = ovr_GetRenderDesc(m_hmd, ovrEyeType(ii), m_hmdDesc.DefaultEyeFov[ii]);
+ m_session = (ovrSession)g_platformData.session;
}
- m_enabled = true;
-
- return true;
- }
+ ovrHmdDesc hmdDesc = ovr_GetHmdDesc(m_session);
+ _desc->m_deviceType = hmdDesc.Type;
+ _desc->m_refreshRate = hmdDesc.DisplayRefreshRate;
+ _desc->m_deviceSize.m_w = hmdDesc.Resolution.w;
+ _desc->m_deviceSize.m_h = hmdDesc.Resolution.h;
+
+ BX_TRACE("OVR HMD: %s, %s, firmware: %d.%d"
+ , hmdDesc.ProductName
+ , hmdDesc.Manufacturer
+ , hmdDesc.FirmwareMajor
+ , hmdDesc.FirmwareMinor
+ );
- void OVR::preReset()
- {
- if (m_enabled)
+ ovrSizei eyeSize[2] =
{
- // on window resize this will recreate the mirror texture in ovrPostReset
- m_mirror->destroy(m_hmd);
- m_mirror = NULL;
- m_enabled = false;
- }
- }
+ ovr_GetFovTextureSize(m_session, ovrEye_Left, hmdDesc.DefaultEyeFov[0], 1.0f),
+ ovr_GetFovTextureSize(m_session, ovrEye_Right, hmdDesc.DefaultEyeFov[0], 1.0f),
+ };
- OVR::Enum OVR::swap(HMD& _hmd, bool originBottomLeft)
- {
- _hmd.flags = BGFX_HMD_NONE;
-
- if (NULL != m_hmd)
+ for (int eye = 0; eye < 2; ++eye)
{
- _hmd.flags |= BGFX_HMD_DEVICE_RESOLUTION;
- _hmd.deviceWidth = m_hmdDesc.Resolution.w;
- _hmd.deviceHeight = m_hmdDesc.Resolution.h;
+ BX_STATIC_ASSERT(sizeof(_desc->m_eyeFov[eye]) == sizeof(hmdDesc.DefaultEyeFov[eye]));
+ memcpy(&_desc->m_eyeFov[eye], &hmdDesc.DefaultEyeFov[eye], sizeof(_desc->m_eyeFov[eye]));
+ _desc->m_eyeSize[eye].m_w = eyeSize[eye].w;
+ _desc->m_eyeSize[eye].m_h = eyeSize[eye].h;
}
- if (!m_enabled)
+ float neckOffset[2] = {OVR_DEFAULT_NECK_TO_EYE_HORIZONTAL, OVR_DEFAULT_NECK_TO_EYE_VERTICAL};
+ ovr_GetFloatArray(m_session, OVR_KEY_NECK_TO_EYE_DISTANCE, neckOffset, 2);
+ _desc->m_neckOffset[0] = neckOffset[0];
+ _desc->m_neckOffset[1] = neckOffset[1];
+
+ // build constant layer settings
+ m_renderLayer.Header.Type = ovrLayerType_EyeFov;
+ m_renderLayer.Header.Flags = 0;
+ for (int eye = 0; eye < 2; ++eye)
{
- return NotEnabled;
+ m_renderLayer.Fov[eye] = hmdDesc.DefaultEyeFov[eye];
+ m_renderLayer.Viewport[eye].Pos.x = 0;
+ m_renderLayer.Viewport[eye].Pos.y = 0;
+ m_renderLayer.Viewport[eye].Size = eyeSize[eye];
}
- ovrResult result;
-
- for (uint32_t ii = 0; ii < 2; ++ii)
+ m_viewScale.HmdSpaceToWorldScaleInMeters = 1.0f;
+ for (int eye = 0; eye < 2; ++eye)
{
- m_eyeBuffers[ii]->postRender(m_hmd);
- result = ovr_CommitTextureSwapChain(m_hmd, m_eyeBuffers[ii]->m_textureSwapChain);
- if (!OVR_SUCCESS(result) )
- {
- return DeviceLost;
- }
+ ovrEyeRenderDesc erd = ovr_GetRenderDesc(m_session, static_cast<ovrEyeType>(eye), hmdDesc.DefaultEyeFov[eye]);
+ m_viewScale.HmdToEyeOffset[eye] = erd.HmdToEyeOffset;
+ m_eyeFov[eye] = erd.Fov;
+ m_pixelsPerTanAngleAtCenter[eye] = erd.PixelsPerTanAngleAtCenter;
}
+ }
- _hmd.flags |= BGFX_HMD_RENDERING;
-
- // finish frame for current eye
- ovrViewScaleDesc viewScaleDesc;
- viewScaleDesc.HmdSpaceToWorldScaleInMeters = 1.0f;
- viewScaleDesc.HmdToEyeOffset[0] = m_hmdToEyeOffset[0];
- viewScaleDesc.HmdToEyeOffset[1] = m_hmdToEyeOffset[1];
-
- // create the main eye layer
- ovrLayerEyeFov eyeLayer;
- eyeLayer.Header.Type = ovrLayerType_EyeFov;
- eyeLayer.Header.Flags = originBottomLeft ? ovrLayerFlag_TextureOriginAtBottomLeft : 0;
-
- for (uint32_t ii = 0; ii < 2; ++ii)
+ void VRImplOVR::disconnect()
+ {
+ if (NULL != g_platformData.session)
{
- eyeLayer.ColorTexture[ii] = m_eyeBuffers[ii]->m_textureSwapChain;
- eyeLayer.Viewport[ii].Pos.x = 0;
- eyeLayer.Viewport[ii].Pos.y = 0;
- eyeLayer.Viewport[ii].Size.w = m_eyeBuffers[ii]->m_eyeTextureSize.w;
- eyeLayer.Viewport[ii].Size.h = m_eyeBuffers[ii]->m_eyeTextureSize.h;
- eyeLayer.Fov[ii] = m_hmdDesc.DefaultEyeFov[ii];
- eyeLayer.RenderPose[ii] = m_pose[ii];
- eyeLayer.SensorSampleTime = m_sensorSampleTime;
+ return;
}
- // append all the layers to global list
- ovrLayerHeader* layerList = &eyeLayer.Header;
-
- result = ovr_SubmitFrame(m_hmd, m_frameIndex, NULL, &layerList, 1);
- if (!OVR_SUCCESS(result) )
+ if (NULL != m_session)
{
- return DeviceLost;
+ ovr_Destroy(m_session);
+ m_session = NULL;
}
-
- // perform mirror texture blit right after the entire frame is submitted to HMD
- m_mirror->blit(m_hmd);
-
- m_hmdToEyeOffset[0] = m_erd[0].HmdToEyeOffset;
- m_hmdToEyeOffset[1] = m_erd[1].HmdToEyeOffset;
-
- ovr_GetEyePoses(m_hmd, m_frameIndex, ovrTrue, m_hmdToEyeOffset, m_pose, &m_sensorSampleTime);
-
- getEyePose(_hmd);
-
- return Success;
}
- void OVR::recenter()
+ bool VRImplOVR::updateTracking(HMD& _hmd)
{
- if (NULL != m_hmd)
+ if (NULL == m_session)
{
- OVR_CHECK(ovr_RecenterTrackingOrigin(m_hmd) );
+ return false;
}
- }
- void OVR::getEyePose(HMD& _hmd)
- {
- if (NULL != m_hmd)
+ ovr_GetEyePoses(m_session, 0, ovrTrue, m_viewScale.HmdToEyeOffset, m_renderLayer.RenderPose, &m_renderLayer.SensorSampleTime);
+
+ for (int eye = 0; eye < 2; ++eye)
{
- for (uint32_t ii = 0; ii < 2; ++ii)
+ const ovrPosef& pose = m_renderLayer.RenderPose[eye];
+ HMD::Eye& hmdEye = _hmd.eye[eye];
+
+ hmdEye.rotation[0] = pose.Orientation.x;
+ hmdEye.rotation[1] = pose.Orientation.y;
+ hmdEye.rotation[2] = pose.Orientation.z;
+ hmdEye.rotation[3] = pose.Orientation.w;
+ hmdEye.translation[0] = pose.Position.x;
+ hmdEye.translation[1] = pose.Position.y;
+ hmdEye.translation[2] = pose.Position.z;
+ hmdEye.viewOffset[0] = -m_viewScale.HmdToEyeOffset[eye].x;
+ hmdEye.viewOffset[1] = -m_viewScale.HmdToEyeOffset[eye].y;
+ hmdEye.viewOffset[2] = -m_viewScale.HmdToEyeOffset[eye].z;
+
+ hmdEye.pixelsPerTanAngle[0] = m_pixelsPerTanAngleAtCenter[eye].x;
+ hmdEye.pixelsPerTanAngle[1] = m_pixelsPerTanAngleAtCenter[eye].y;
+
+ ovrMatrix4f projection = ovrMatrix4f_Projection(m_eyeFov[eye], 0.1f, 1000.0f, ovrProjection_LeftHanded);
+ for (uint32_t ii = 0; ii < 4; ++ii)
{
- const ovrPosef& pose = m_pose[ii];
- HMD::Eye& eye = _hmd.eye[ii];
- eye.rotation[0] = pose.Orientation.x;
- eye.rotation[1] = pose.Orientation.y;
- eye.rotation[2] = pose.Orientation.z;
- eye.rotation[3] = pose.Orientation.w;
- eye.translation[0] = pose.Position.x;
- eye.translation[1] = pose.Position.y;
- eye.translation[2] = pose.Position.z;
-
- const ovrEyeRenderDesc& erd = m_erd[ii];
- eye.fov[0] = erd.Fov.UpTan;
- eye.fov[1] = erd.Fov.DownTan;
- eye.fov[2] = erd.Fov.LeftTan;
- eye.fov[3] = erd.Fov.RightTan;
-
- ovrMatrix4f eyeProj = ovrMatrix4f_Projection(m_erd[ii].Fov, 0.01f, 1000.0f, ovrProjection_LeftHanded);
for (uint32_t jj = 0; jj < 4; ++jj)
{
- for (uint32_t kk = 0; kk < 4; ++kk)
- {
- eye.projection[4 * jj + kk] = eyeProj.M[kk][jj];
- }
+ hmdEye.projection[4*ii + jj] = projection.M[jj][ii];
}
-
- eye.viewOffset[0] = -erd.HmdToEyeOffset.x;
- eye.viewOffset[1] = -erd.HmdToEyeOffset.y;
- eye.viewOffset[2] = -erd.HmdToEyeOffset.z;
-
- eye.pixelsPerTanAngle[0] = erd.PixelsPerTanAngleAtCenter.x;
- eye.pixelsPerTanAngle[1] = erd.PixelsPerTanAngleAtCenter.y;
}
}
- _hmd.width = uint16_t(m_hmdSize.w);
- _hmd.height = uint16_t(m_hmdSize.h);
+ return true;
+ }
+
+ void VRImplOVR::updateInput(HMD& /* _hmd */)
+ {
+ }
+
+ void VRImplOVR::recenter()
+ {
+ if (NULL != m_session)
+ {
+ ovr_RecenterTrackingOrigin(m_session);
+ }
}
} // namespace bgfx
diff --git a/3rdparty/bgfx/src/hmd_ovr.h b/3rdparty/bgfx/src/hmd_ovr.h
index 675e711c01e..a2a2d34a63b 100644
--- a/3rdparty/bgfx/src/hmd_ovr.h
+++ b/3rdparty/bgfx/src/hmd_ovr.h
@@ -10,6 +10,7 @@
#if BGFX_CONFIG_USE_OVR
+# include "hmd.h"
# include <OVR_Version.h>
# define OVR_VERSION_(_a, _b, _c) (_a * 10000 + _b * 100 + _c)
@@ -25,157 +26,41 @@
# include <OVR_CAPI_GL.h>
# endif // BGFX_CONFIG_RENDERER_OPENGL
-namespace bgfx
-{
- // single eye buffer
- struct OVRBufferI
- {
- virtual ~OVRBufferI() {};
- virtual void create(const ovrSession& _session, int _eyeIdx, int _msaaSamples) = 0;
- virtual void destroy(const ovrSession& _session) = 0;
- virtual void render(const ovrSession& _session) = 0;
- virtual void postRender(const ovrSession& _session) = 0;
- ovrSizei m_eyeTextureSize;
- ovrTextureSwapChain m_textureSwapChain;
- };
-
- // mirrored window output
- struct OVRMirrorI
- {
- virtual ~OVRMirrorI() {};
- virtual void create(const ovrSession& _session, int windowWidth, int windowHeight) = 0;
- virtual void destroy(const ovrSession& _session) = 0;
- virtual void blit(const ovrSession& _session) = 0;
-
- ovrMirrorTexture m_mirrorTexture;
- ovrMirrorTextureDesc m_mirrorTextureDesc;
- };
-
- struct OVR
- {
- enum Enum
- {
- NotEnabled,
- DeviceLost,
- Success,
-
- Count
- };
-
- OVR();
- ~OVR();
-
- bool isInitialized() const
- {
- return NULL != m_hmd;
- }
-
- bool isEnabled() const
- {
- return m_enabled;
- }
-
- void init();
- void shutdown();
-
- void getViewport(uint8_t _eye, Rect* _viewport);
- void renderEyeStart(uint8_t _eye);
- bool postReset();
- void preReset();
- Enum swap(HMD& _hmd, bool originBottomLeft);
- void recenter();
- void getEyePose(HMD& _hmd);
-
- ovrSession m_hmd;
- ovrHmdDesc m_hmdDesc;
- ovrEyeRenderDesc m_erd[2];
- ovrRecti m_rect[2];
- ovrPosef m_pose[2];
- ovrVector3f m_hmdToEyeOffset[2];
- ovrSizei m_hmdSize;
- OVRBufferI *m_eyeBuffers[2];
- OVRMirrorI *m_mirror;
- uint64_t m_frameIndex;
- double m_sensorSampleTime;
- bool m_enabled;
- };
-
-} // namespace bgfx
-
-#else
namespace bgfx
{
- struct OVR
+ class VRImplOVR : public VRImplI
{
- enum Enum
- {
- NotEnabled,
- DeviceLost,
- Success,
+ public:
+ VRImplOVR();
+ virtual ~VRImplOVR() = 0;
- Count
- };
+ virtual bool init() BX_OVERRIDE;
+ virtual void shutdown() BX_OVERRIDE;
+ virtual void connect(VRDesc* _desc) BX_OVERRIDE;
+ virtual void disconnect() BX_OVERRIDE;
- OVR()
+ virtual bool isConnected() const BX_OVERRIDE
{
+ return NULL != m_session;
}
- ~OVR()
- {
- }
-
- bool isInitialized() const
- {
- return false;
- }
-
- bool isEnabled() const
- {
- return false;
- }
-
- bool isDebug() const
- {
- return false;
- }
-
- void init()
- {
- }
-
- void shutdown()
- {
- }
-
- void getViewport(uint8_t /*_eye*/, Rect* _viewport)
- {
- _viewport->m_x = 0;
- _viewport->m_y = 0;
- _viewport->m_width = 0;
- _viewport->m_height = 0;
- }
-
- void renderEyeStart(uint8_t /*_eye*/)
- {
- }
-
- Enum swap(HMD& _hmd, bool /*originBottomLeft*/)
- {
- _hmd.flags = BGFX_HMD_NONE;
- getEyePose(_hmd);
- return NotEnabled;
- }
-
- void recenter()
- {
- }
-
- void getEyePose(HMD& _hmd)
- {
- _hmd.width = 0;
- _hmd.height = 0;
- }
+ virtual bool updateTracking(HMD& _hmd) BX_OVERRIDE;
+ virtual void updateInput(HMD& _hmd) BX_OVERRIDE;
+ virtual void recenter() BX_OVERRIDE;
+
+ virtual bool createSwapChain(const VRDesc& _desc, int _msaaSamples, int _mirrorWidth, int _mirrorHeight) BX_OVERRIDE = 0;
+ virtual void destroySwapChain() BX_OVERRIDE = 0;
+ virtual void destroyMirror() BX_OVERRIDE = 0;
+ virtual void renderEyeStart(const VRDesc& _desc, uint8_t _eye) BX_OVERRIDE = 0;
+ virtual bool submitSwapChain(const VRDesc& _desc) BX_OVERRIDE = 0;
+
+ protected:
+ ovrSession m_session;
+ ovrLayerEyeFov m_renderLayer;
+ ovrViewScaleDesc m_viewScale;
+ ovrFovPort m_eyeFov[2];
+ ovrVector2f m_pixelsPerTanAngleAtCenter[2];
};
} // namespace bgfx
diff --git a/3rdparty/bgfx/src/image.cpp b/3rdparty/bgfx/src/image.cpp
index 81557c0ea11..9284aad20b0 100644
--- a/3rdparty/bgfx/src/image.cpp
+++ b/3rdparty/bgfx/src/image.cpp
@@ -93,9 +93,9 @@ namespace bgfx
{ 24, 1, 1, 3, 1, 1, 24, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // D24
{ 32, 1, 1, 4, 1, 1, 24, 8, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // D24S8
{ 32, 1, 1, 4, 1, 1, 32, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // D32
- { 16, 1, 1, 2, 1, 1, 16, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // D16F
- { 24, 1, 1, 3, 1, 1, 24, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // D24F
- { 32, 1, 1, 4, 1, 1, 32, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // D32F
+ { 16, 1, 1, 2, 1, 1, 16, 0, 0, 0, 0, 0, uint8_t(EncodingType::Float) }, // D16F
+ { 24, 1, 1, 3, 1, 1, 24, 0, 0, 0, 0, 0, uint8_t(EncodingType::Float) }, // D24F
+ { 32, 1, 1, 4, 1, 1, 32, 0, 0, 0, 0, 0, uint8_t(EncodingType::Float) }, // D32F
{ 8, 1, 1, 1, 1, 1, 0, 8, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // D0S8
};
BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_imageBlockInfo) );
@@ -258,9 +258,9 @@ namespace bgfx
_depth = bx::uint16_max(1, _depth);
uint32_t max = bx::uint32_max(_width, bx::uint32_max(_height, _depth) );
- uint8_t numMips = uint8_t(bx::flog2(float(max) ) );
+ uint32_t numMips = bx::uint32_max(1, uint8_t(bx::flog2(float(max) ) ) );
- return numMips;
+ return uint8_t(numMips);
}
uint32_t imageGetSize(TextureFormat::Enum _format, uint16_t _width, uint16_t _height, uint16_t _depth, uint16_t _numLayers, bool _cubeMap, uint8_t _numMips)
@@ -1251,6 +1251,57 @@ namespace bgfx
_dst[3] = bx::halfToFloat(src[3]);
}
+ // R24
+ void packR24(void* _dst, const float* _src)
+ {
+ uint8_t* dst = (uint8_t*)_dst;
+ const uint32_t rr = uint32_t(toUnorm(_src[0], 16777216.0f) );
+ dst[0] = uint8_t(rr );
+ dst[1] = uint8_t(rr>> 8);
+ dst[2] = uint8_t(rr>>16);
+ }
+
+ void unpackR24(float* _dst, const void* _src)
+ {
+ const uint8_t* src = (const uint8_t*)_src;
+ const uint32_t rr = 0
+ | (src[0] )
+ | (src[1]<< 8)
+ | (src[2]<<16)
+ ;
+
+ _dst[0] = fromUnorm(rr, 16777216.0f);
+ _dst[1] = 0.0f;
+ _dst[2] = 0.0f;
+ _dst[3] = 1.0f;
+ }
+
+ // R24G8
+ void packR24G8(void* _dst, const float* _src)
+ {
+ uint8_t* dst = (uint8_t*)_dst;
+ const uint32_t rr = uint32_t(toUnorm(_src[0], 16777216.0f) );
+ dst[0] = uint8_t(rr );
+ dst[1] = uint8_t(rr>> 8);
+ dst[2] = uint8_t(rr>>16);
+ dst[3] = uint8_t(toUnorm(_src[1], 255.0f) );
+ }
+
+ void unpackR24G8(float* _dst, const void* _src)
+ {
+ const uint8_t* src = (const uint8_t*)_src;
+ const uint32_t rr = 0
+ | (src[0] )
+ | (src[1]<< 8)
+ | (src[2]<<16)
+ ;
+
+ _dst[0] = fromUnorm(rr, 16777216.0f);
+ _dst[1] = fromUnorm(src[3], 255.0f);
+ _dst[2] = 0.0f;
+ _dst[3] = 1.0f;
+ }
+
// R32I
void packR32I(void* _dst, const float* _src)
{
@@ -1632,14 +1683,14 @@ namespace bgfx
{ packRgb10A2, unpackRgb10A2 }, // RGB10A2
{ packR11G11B10F, unpackR11G11B10F }, // R11G11B10F
{ NULL, NULL }, // UnknownDepth
- { NULL, NULL }, // D16
- { NULL, NULL }, // D24
- { NULL, NULL }, // D24S8
+ { packR16, unpackR16 }, // D16
+ { packR24, unpackR24 }, // D24
+ { packR24G8, unpackR24G8 }, // D24S8
{ NULL, NULL }, // D32
- { NULL, NULL }, // D16F
+ { packR16F, unpackR16F }, // D16F
{ NULL, NULL }, // D24F
- { NULL, NULL }, // D32F
- { NULL, NULL }, // D0S8
+ { packR32F, unpackR32F }, // D32F
+ { packR8, unpackR8 }, // D0S8
};
BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_packUnpack) );
diff --git a/3rdparty/bgfx/src/image.h b/3rdparty/bgfx/src/image.h
index d9479bb82c4..4fce6d7bd1d 100644
--- a/3rdparty/bgfx/src/image.h
+++ b/3rdparty/bgfx/src/image.h
@@ -395,7 +395,7 @@ namespace bgfx
void imageDecodeToRgba32f(bx::AllocatorI* _allocator, void* _dst, const void* _src, uint32_t _width, uint32_t _height, uint32_t _pitch, TextureFormat::Enum _format);
///
- bool imageGetRawData(const ImageContainer& _imageContainer, uint16_t _side, uint8_t _index, const void* _data, uint32_t _size, ImageMip& _mip);
+ bool imageGetRawData(const ImageContainer& _imageContainer, uint16_t _side, uint8_t _lod, const void* _data, uint32_t _size, ImageMip& _mip);
} // namespace bgfx
diff --git a/3rdparty/bgfx/src/makefile b/3rdparty/bgfx/src/makefile
index 6de6e838350..3fade997ed2 100644
--- a/3rdparty/bgfx/src/makefile
+++ b/3rdparty/bgfx/src/makefile
@@ -25,7 +25,7 @@ all: $(BIN)
define shader-embedded
@echo [$(<)]
- $(SILENT) $(SHADERC) --type $(1) --platform linux -f $(<) -o $(SHADER_TMP) --bin2c $(basename $(<))_glsl
+ $(SILENT) $(SHADERC) --type $(1) --platform linux -f $(<) -o $(SHADER_TMP) --bin2c $(basename $(<))_glsl
@cat $(SHADER_TMP) > $(@)
-$(SILENT) $(SHADERC) --type $(1) --platform windows -p $(2) -O 3 -f $(<) -o $(SHADER_TMP) --bin2c $(basename $(<))_dx9
-@cat $(SHADER_TMP) >> $(@)
@@ -33,6 +33,8 @@ define shader-embedded
-@cat $(SHADER_TMP) >> $(@)
-$(SILENT) $(SHADERC) --type $(1) --platform ios -p metal -O 3 -f $(<) -o $(SHADER_TMP) --bin2c $(basename $(<))_mtl
-@cat $(SHADER_TMP) >> $(@)
+ -@echo extern const uint8_t* $(basename $(<))_pssl;>> $(@)
+ -@echo extern const uint32_t $(basename $(<))_pssl_size;>> $(@)
endef
vs_debugfont.bin.h : vs_debugfont.sc
diff --git a/3rdparty/bgfx/src/renderer.h b/3rdparty/bgfx/src/renderer.h
index a85cc9bc75c..5f0ff9ea109 100644
--- a/3rdparty/bgfx/src/renderer.h
+++ b/3rdparty/bgfx/src/renderer.h
@@ -12,7 +12,10 @@ namespace bgfx
{
struct ViewState
{
- ViewState() { }
+ ViewState()
+ {
+ }
+
ViewState(Frame* _render, bool _hmdEnabled)
{
reset(_render, _hmdEnabled);
diff --git a/3rdparty/bgfx/src/renderer_d3d11.cpp b/3rdparty/bgfx/src/renderer_d3d11.cpp
index 6bab23dd024..29b5d392511 100644
--- a/3rdparty/bgfx/src/renderer_d3d11.cpp
+++ b/3rdparty/bgfx/src/renderer_d3d11.cpp
@@ -29,6 +29,10 @@
# define BGFX_GPU_PROFILER_END() BX_NOOP()
#endif
+#if BGFX_CONFIG_USE_OVR
+# include "hmd_ovr.h"
+#endif // BGFX_CONFIG_USE_OVR
+
namespace bgfx { namespace d3d11
{
static wchar_t s_viewNameW[BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME];
@@ -601,6 +605,30 @@ namespace bgfx { namespace d3d11
static PFN_GET_DEBUG_INTERFACE1 DXGIGetDebugInterface1;
#endif // USE_D3D11_DYNAMIC_LIB
+#if BGFX_CONFIG_USE_OVR
+ class VRImplOVRD3D11 : public VRImplOVR
+ {
+ public:
+ VRImplOVRD3D11();
+
+ virtual bool createSwapChain(const VRDesc& _desc, int _msaaSamples, int _mirrorWidth, int _mirrorHeight) BX_OVERRIDE;
+ virtual void destroySwapChain() BX_OVERRIDE;
+ virtual void destroyMirror() BX_OVERRIDE;
+ virtual void renderEyeStart(const VRDesc& _desc, uint8_t _eye) BX_OVERRIDE;
+ virtual bool submitSwapChain(const VRDesc& _desc) BX_OVERRIDE;
+
+ private:
+ ID3D11RenderTargetView* m_eyeRtv[2][4];
+ ID3D11DepthStencilView* m_depthBuffer[2];
+ ID3D11Texture2D* m_msaaTexture[2];
+ ID3D11ShaderResourceView* m_msaaSv[2];
+ ID3D11RenderTargetView* m_msaaRtv[2];
+
+ ovrTextureSwapChain m_textureSwapChain[2];
+ ovrMirrorTexture m_mirrorTexture;
+ };
+#endif // BGFX_CONFIG_USE_OVR
+
struct RendererContextD3D11 : public RendererContextI
{
RendererContextD3D11()
@@ -662,7 +690,11 @@ namespace bgfx { namespace d3d11
ErrorState::Enum errorState = ErrorState::Default;
// Must be before device creation, and before RenderDoc.
- m_ovr.init();
+ VRImplI* vrImpl = NULL;
+#if BGFX_CONFIG_USE_OVR
+ vrImpl = &m_ovrRender;
+#endif // BGFX_CONFIG_USE_OVR
+ m_ovr.init(vrImpl);
if (!m_ovr.isInitialized() )
{
@@ -1231,12 +1263,6 @@ BX_PRAGMA_DIAGNOSTIC_POP();
}
{
- UniformHandle handle = BGFX_INVALID_HANDLE;
- for (uint32_t ii = 0; ii < PredefinedUniform::Count; ++ii)
- {
- m_uniformReg.add(handle, getPredefinedUniformName(PredefinedUniform::Enum(ii) ), &m_predefinedUniforms[ii]);
- }
-
g_caps.supported |= (0
| BGFX_CAPS_TEXTURE_3D
| BGFX_CAPS_VERTEX_ATTRIB_HALF
@@ -1259,19 +1285,19 @@ BX_PRAGMA_DIAGNOSTIC_POP();
if (m_featureLevel <= D3D_FEATURE_LEVEL_9_2)
{
- g_caps.maxTextureSize = D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION;
- g_caps.maxFBAttachments = uint8_t(bx::uint32_min(D3D_FL9_1_SIMULTANEOUS_RENDER_TARGET_COUNT, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS) );
+ g_caps.limits.maxTextureSize = D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION;
+ g_caps.limits.maxFBAttachments = uint8_t(bx::uint32_min(D3D_FL9_1_SIMULTANEOUS_RENDER_TARGET_COUNT, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS) );
}
else if (m_featureLevel == D3D_FEATURE_LEVEL_9_3)
{
- g_caps.maxTextureSize = D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION;
- g_caps.maxFBAttachments = uint8_t(bx::uint32_min(D3D_FL9_3_SIMULTANEOUS_RENDER_TARGET_COUNT, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS) );
+ g_caps.limits.maxTextureSize = D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION;
+ g_caps.limits.maxFBAttachments = uint8_t(bx::uint32_min(D3D_FL9_3_SIMULTANEOUS_RENDER_TARGET_COUNT, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS) );
}
else
{
g_caps.supported |= BGFX_CAPS_TEXTURE_COMPARE_ALL;
- g_caps.maxTextureSize = D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION;
- g_caps.maxFBAttachments = uint8_t(bx::uint32_min(D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS) );
+ g_caps.limits.maxTextureSize = D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION;
+ g_caps.limits.maxFBAttachments = uint8_t(bx::uint32_min(D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS) );
}
// 32-bit indices only supported on 9_2+.
@@ -1814,22 +1840,24 @@ BX_PRAGMA_DIAGNOSTIC_POP();
{
}
- void readTexture(TextureHandle _handle, void* _data) BX_OVERRIDE
+ void readTexture(TextureHandle _handle, void* _data, uint8_t _mip) BX_OVERRIDE
{
const TextureD3D11& texture = m_textures[_handle.idx];
D3D11_MAPPED_SUBRESOURCE mapped;
- DX_CHECK(m_deviceCtx->Map(texture.m_ptr, 0, D3D11_MAP_READ, 0, &mapped) );
+ DX_CHECK(m_deviceCtx->Map(texture.m_ptr, _mip, D3D11_MAP_READ, 0, &mapped) );
- uint8_t* src = (uint8_t*)mapped.pData;
- uint32_t srcPitch = mapped.RowPitch;
+ uint32_t srcWidth = bx::uint32_max(1, texture.m_width >>_mip);
+ uint32_t srcHeight = bx::uint32_max(1, texture.m_height>>_mip);
+ uint8_t* src = (uint8_t*)mapped.pData;
+ uint32_t srcPitch = mapped.RowPitch;
const uint8_t bpp = getBitsPerPixel(TextureFormat::Enum(texture.m_textureFormat) );
uint8_t* dst = (uint8_t*)_data;
- uint32_t dstPitch = texture.m_width*bpp/8;
+ uint32_t dstPitch = srcWidth*bpp/8;
uint32_t pitch = bx::uint32_min(srcPitch, dstPitch);
- for (uint32_t yy = 0, height = texture.m_height; yy < height; ++yy)
+ for (uint32_t yy = 0, height = srcHeight; yy < height; ++yy)
{
memcpy(dst, src, pitch);
@@ -1837,7 +1865,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
dst += dstPitch;
}
- m_deviceCtx->Unmap(texture.m_ptr, 0);
+ m_deviceCtx->Unmap(texture.m_ptr, _mip);
}
void resizeTexture(TextureHandle _handle, uint16_t _width, uint16_t _height, uint8_t _numMips) BX_OVERRIDE
@@ -1934,6 +1962,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
{
BX_FREE(g_allocator, m_uniforms[_handle.idx]);
m_uniforms[_handle.idx] = NULL;
+ m_uniformReg.remove(_handle);
}
void saveScreenShot(const char* _filePath) BX_OVERRIDE
@@ -2231,18 +2260,12 @@ BX_PRAGMA_DIAGNOSTIC_POP();
if (SUCCEEDED(hr) )
{
- switch (m_ovr.swap(_hmd, false) )
+ m_ovr.flip();
+ m_ovr.swap(_hmd); // TODO - move this out of end-of-frame
+
+ if (!m_ovr.isEnabled())
{
- case OVR::NotEnabled:
hr = m_swapChain->Present(syncInterval, 0);
- break;
-
- case OVR::DeviceLost:
- ovrPreReset();
- break;
-
- default:
- break;
}
}
@@ -3067,11 +3090,17 @@ BX_PRAGMA_DIAGNOSTIC_POP();
switch (texture.m_type)
{
case TextureD3D11::Texture2D:
- case TextureD3D11::TextureCube:
desc.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2D;
desc.Texture2D.MipSlice = _mip;
break;
+ case TextureD3D11::TextureCube:
+ desc.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2DARRAY;
+ desc.Texture2DArray.ArraySize = 6;
+ desc.Texture2DArray.FirstArraySlice = 0;
+ desc.Texture2DArray.MipSlice = _mip;
+ break;
+
case TextureD3D11::Texture3D:
desc.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE3D;
desc.Texture3D.MipSlice = _mip;
@@ -3153,24 +3182,8 @@ BX_PRAGMA_DIAGNOSTIC_POP();
#if BGFX_CONFIG_USE_OVR
if (m_resolution.m_flags & (BGFX_RESET_HMD|BGFX_RESET_HMD_DEBUG) )
{
- if (m_ovr.postReset() )
- {
- const uint32_t msaaSamples = 1 << ((m_resolution.m_flags&BGFX_RESET_MSAA_MASK) >> BGFX_RESET_MSAA_SHIFT);
-
- for (uint32_t ii = 0; ii < 2; ++ii)
- {
- // eye buffers need to be initialized only once during application lifetime
- if (NULL == m_ovr.m_eyeBuffers[ii])
- {
- m_ovr.m_eyeBuffers[ii] = &m_ovrBuffers[ii];
- m_ovr.m_eyeBuffers[ii]->create(m_ovr.m_hmd, ii, msaaSamples);
- }
- }
-
- // recreate mirror texture
- m_ovr.m_mirror = &m_ovrMirror;
- m_ovr.m_mirror->create(m_ovr.m_hmd, m_resolution.m_width, m_resolution.m_height);
- }
+ const uint32_t msaaSamples = 1 << ((m_resolution.m_flags&BGFX_RESET_MSAA_MASK) >> BGFX_RESET_MSAA_SHIFT);
+ m_ovr.postReset(msaaSamples, m_resolution.m_width, m_resolution.m_height);
}
#endif // BGFX_CONFIG_USE_OVR
}
@@ -3569,10 +3582,9 @@ BX_PRAGMA_DIAGNOSTIC_POP();
bool m_rtMsaa;
bool m_timerQuerySupport;
- OVR m_ovr;
+ VR m_ovr;
#if BGFX_CONFIG_USE_OVR
- OVRMirrorD3D11 m_ovrMirror;
- OVRBufferD3D11 m_ovrBuffers[2];
+ VRImplOVRD3D11 m_ovrRender;
#endif // BGFX_CONFIG_USE_OVR
};
@@ -3627,204 +3639,248 @@ BX_PRAGMA_DIAGNOSTIC_POP();
}
#if BGFX_CONFIG_USE_OVR
- void OVRBufferD3D11::create(const ovrSession& _session, int _eyeIdx, int _msaaSamples)
+
+ VRImplOVRD3D11::VRImplOVRD3D11()
+ : m_mirrorTexture(NULL)
{
- ovrHmdDesc hmdDesc = ovr_GetHmdDesc(_session);
- m_eyeTextureSize = ovr_GetFovTextureSize(_session, (ovrEyeType)_eyeIdx, hmdDesc.DefaultEyeFov[_eyeIdx], 1.0f);
- m_msaaTexture = NULL;
- m_msaaRtv = NULL;
- m_msaaSv = NULL;
-
- ovrTextureSwapChainDesc desc = {};
- desc.Type = ovrTexture_2D;
- desc.ArraySize = 1;
- desc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB;
- desc.Width = m_eyeTextureSize.w;
- desc.Height = m_eyeTextureSize.h;
- desc.MipLevels = 1;
- desc.SampleCount = 1;
- desc.MiscFlags = ovrTextureMisc_DX_Typeless;
- desc.BindFlags = ovrTextureBind_DX_RenderTarget;
- desc.StaticImage = ovrFalse;
+ memset(m_textureSwapChain, 0, sizeof(m_textureSwapChain));
+ }
+ bool VRImplOVRD3D11::createSwapChain(const VRDesc& _desc, int _msaaSamples, int _mirrorWidth, int _mirrorHeight)
+ {
ID3D11Device* device = s_renderD3D11->m_device;
- ovrResult result = ovr_CreateTextureSwapChainDX(_session, device, &desc, &m_textureSwapChain);
+ for (int eye = 0; eye < 2; ++eye)
+ {
+ if (NULL == m_textureSwapChain[eye])
+ {
+ m_msaaTexture[eye] = NULL;
+ m_msaaRtv[eye] = NULL;
+ m_msaaSv[eye] = NULL;
+
+ ovrTextureSwapChainDesc swapchainDesc = {};
+ swapchainDesc.Type = ovrTexture_2D;
+ swapchainDesc.ArraySize = 1;
+ swapchainDesc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB;
+ swapchainDesc.Width = _desc.m_eyeSize[eye].m_w;
+ swapchainDesc.Height = _desc.m_eyeSize[eye].m_h;
+ swapchainDesc.MipLevels = 1;
+ swapchainDesc.SampleCount = 1;
+ swapchainDesc.MiscFlags = ovrTextureMisc_DX_Typeless;
+ swapchainDesc.BindFlags = ovrTextureBind_DX_RenderTarget;
+ swapchainDesc.StaticImage = ovrFalse;
+
+ ovrResult result = ovr_CreateTextureSwapChainDX(m_session, device, &swapchainDesc, &m_textureSwapChain[eye]);
+ if (!OVR_SUCCESS(result))
+ {
+ destroySwapChain();
+ return false;
+ }
- if (!OVR_SUCCESS(result) )
+ memset(m_eyeRtv[eye], 0, sizeof(m_eyeRtv[eye]));
+ int textureCount;
+ ovr_GetTextureSwapChainLength(m_session, m_textureSwapChain[eye], &textureCount);
+
+ for (int ii = 0; ii < textureCount; ++ii)
+ {
+ ID3D11Texture2D* tex = NULL;
+ ovr_GetTextureSwapChainBufferDX(m_session, m_textureSwapChain[eye], ii, IID_PPV_ARGS(&tex));
+ D3D11_RENDER_TARGET_VIEW_DESC rtvd = {};
+ rtvd.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+ rtvd.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
+
+ ID3D11RenderTargetView* rtv;
+ DX_CHECK(device->CreateRenderTargetView(tex, &rtvd, &rtv));
+ m_eyeRtv[eye][ii] = rtv;
+ DX_RELEASE(tex, 1);
+ }
+
+ // setup depth buffer
+ D3D11_TEXTURE2D_DESC dbDesc;
+ dbDesc.Width = _desc.m_eyeSize[eye].m_w;
+ dbDesc.Height = _desc.m_eyeSize[eye].m_h;
+ dbDesc.MipLevels = 1;
+ dbDesc.ArraySize = 1;
+ dbDesc.Format = DXGI_FORMAT_D32_FLOAT;
+ dbDesc.SampleDesc.Count = _msaaSamples;
+ dbDesc.SampleDesc.Quality = 0;
+ dbDesc.Usage = D3D11_USAGE_DEFAULT;
+ dbDesc.CPUAccessFlags = 0;
+ dbDesc.MiscFlags = 0;
+ dbDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
+ ID3D11Texture2D* tex;
+ DX_CHECK(device->CreateTexture2D(&dbDesc, NULL, &tex));
+ DX_CHECK(device->CreateDepthStencilView(tex, NULL, &m_depthBuffer[eye]));
+ DX_RELEASE(tex, 0);
+
+ // create MSAA render target
+ if (_msaaSamples > 1)
+ {
+ D3D11_TEXTURE2D_DESC dsDesc;
+ dsDesc.Width = _desc.m_eyeSize[eye].m_w;
+ dsDesc.Height = _desc.m_eyeSize[eye].m_h;
+ dsDesc.MipLevels = 1;
+ dsDesc.ArraySize = 1;
+ dsDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+ dsDesc.SampleDesc.Count = _msaaSamples;
+ dsDesc.SampleDesc.Quality = 0;
+ dsDesc.Usage = D3D11_USAGE_DEFAULT;
+ dsDesc.CPUAccessFlags = 0;
+ dsDesc.MiscFlags = 0;
+ dsDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
+
+ DX_CHECK(device->CreateTexture2D(&dsDesc, NULL, &m_msaaTexture[eye]));
+ DX_CHECK(device->CreateShaderResourceView(m_msaaTexture[eye], NULL, &m_msaaSv[eye]));
+ DX_CHECK(device->CreateRenderTargetView(m_msaaTexture[eye], NULL, &m_msaaRtv[eye]));
+ }
+ }
+ }
+
+ if (NULL == m_mirrorTexture)
{
- BX_CHECK(false, "Could not create D3D11 OVR swap texture");
+ ovrMirrorTextureDesc mirrorDesc = {};
+ mirrorDesc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB;
+ mirrorDesc.Width = _mirrorWidth;
+ mirrorDesc.Height = _mirrorHeight;
+ ovrResult result = ovr_CreateMirrorTextureDX(m_session, device, &mirrorDesc, &m_mirrorTexture);
+ BX_WARN(OVR_SUCCESS(result), "Could not create D3D11 OVR mirror texture");
+ BX_UNUSED(result);
}
- memset(m_eyeRtv, 0, sizeof(m_eyeRtv) );
- int textureCount = 0;
- ovr_GetTextureSwapChainLength(_session, m_textureSwapChain, &textureCount);
+ m_renderLayer.ColorTexture[0] = m_textureSwapChain[0];
+ m_renderLayer.ColorTexture[1] = m_textureSwapChain[1];
+ return true;
+ }
- for (int ii = 0; ii < textureCount; ++ii)
+ void VRImplOVRD3D11::destroySwapChain()
+ {
+ for (int eye = 0; eye < 2; ++eye)
{
- ID3D11Texture2D* tex = NULL;
- ovr_GetTextureSwapChainBufferDX(_session, m_textureSwapChain, ii, IID_PPV_ARGS(&tex) );
- D3D11_RENDER_TARGET_VIEW_DESC rtvd = {};
- rtvd.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
- rtvd.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
-
- ID3D11RenderTargetView* rtv;
- DX_CHECK(device->CreateRenderTargetView(tex, &rtvd, &rtv) );
- m_eyeRtv[ii] = rtv;
- DX_RELEASE(tex, 1);
+ if (m_textureSwapChain[eye])
+ {
+ for (uint32_t ii = 0; ii < BX_COUNTOF(m_eyeRtv[eye]); ++ii)
+ {
+ DX_RELEASE(m_eyeRtv[eye][ii], 0);
+ }
+
+ ovr_DestroyTextureSwapChain(m_session, m_textureSwapChain[eye]);
+ m_textureSwapChain[eye] = NULL;
+ m_depthBuffer[eye]->Release();
+
+ if (NULL != m_msaaTexture[eye])
+ {
+ m_msaaTexture[eye]->Release();
+ m_msaaTexture[eye] = NULL;
+ }
+
+ if (NULL != m_msaaSv[eye])
+ {
+ m_msaaSv[eye]->Release();
+ m_msaaSv[eye] = NULL;
+ }
+
+ if (NULL != m_msaaRtv[eye])
+ {
+ m_msaaRtv[eye]->Release();
+ m_msaaRtv[eye] = NULL;
+ }
+ }
}
- // setup depth buffer
- D3D11_TEXTURE2D_DESC dbDesc;
- dbDesc.Width = m_eyeTextureSize.w;
- dbDesc.Height = m_eyeTextureSize.h;
- dbDesc.MipLevels = 1;
- dbDesc.ArraySize = 1;
- dbDesc.Format = DXGI_FORMAT_D32_FLOAT;
- dbDesc.SampleDesc.Count = _msaaSamples;
- dbDesc.SampleDesc.Quality = 0;
- dbDesc.Usage = D3D11_USAGE_DEFAULT;
- dbDesc.CPUAccessFlags = 0;
- dbDesc.MiscFlags = 0;
- dbDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
- ID3D11Texture2D* tex;
- DX_CHECK(device->CreateTexture2D(&dbDesc, NULL, &tex) );
- DX_CHECK(device->CreateDepthStencilView(tex, NULL, &m_depthBuffer) );
- DX_RELEASE(tex, 0);
-
- // create MSAA render target
- if (_msaaSamples > 1)
- {
- D3D11_TEXTURE2D_DESC dsDesc;
- dsDesc.Width = m_eyeTextureSize.w;
- dsDesc.Height = m_eyeTextureSize.h;
- dsDesc.MipLevels = 1;
- dsDesc.ArraySize = 1;
- dsDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
- dsDesc.SampleDesc.Count = _msaaSamples;
- dsDesc.SampleDesc.Quality = 0;
- dsDesc.Usage = D3D11_USAGE_DEFAULT;
- dsDesc.CPUAccessFlags = 0;
- dsDesc.MiscFlags = 0;
- dsDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
-
- ID3D11Device* device = s_renderD3D11->m_device;
- DX_CHECK(device->CreateTexture2D(&dsDesc, NULL, &m_msaaTexture));
- DX_CHECK(device->CreateShaderResourceView(m_msaaTexture, NULL, &m_msaaSv));
- DX_CHECK(device->CreateRenderTargetView(m_msaaTexture, NULL, &m_msaaRtv));
+ destroyMirror();
+ }
+
+ void VRImplOVRD3D11::destroyMirror()
+ {
+ if (NULL != m_mirrorTexture)
+ {
+ ovr_DestroyMirrorTexture(m_session, m_mirrorTexture);
+ m_mirrorTexture = NULL;
}
}
- void OVRBufferD3D11::render(const ovrSession& _session)
+ void VRImplOVRD3D11::renderEyeStart(const VRDesc& _desc, uint8_t _eye)
{
ID3D11DeviceContext* deviceCtx = s_renderD3D11->m_deviceCtx;
float black[] = { 0.0f, 0.0f, 0.0f, 0.0f }; // Important that alpha=0, if want pixels to be transparent, for manual layers
// render to MSAA target
- if (NULL != m_msaaTexture)
+ if (NULL != m_msaaTexture[_eye])
{
- deviceCtx->OMSetRenderTargets(1, &m_msaaRtv, m_depthBuffer);
- deviceCtx->ClearRenderTargetView(m_msaaRtv, black);
- deviceCtx->ClearDepthStencilView(m_depthBuffer, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1, 0);
+ deviceCtx->OMSetRenderTargets(1, &m_msaaRtv[_eye], m_depthBuffer[_eye]);
+ deviceCtx->ClearRenderTargetView(m_msaaRtv[_eye], black);
+ deviceCtx->ClearDepthStencilView(m_depthBuffer[_eye], D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1, 0);
}
else // MSAA disabled? render directly to eye buffer
{
int texIndex = 0;
- ovr_GetTextureSwapChainCurrentIndex(_session, m_textureSwapChain, &texIndex);
+ ovr_GetTextureSwapChainCurrentIndex(m_session, m_textureSwapChain[_eye], &texIndex);
- deviceCtx->OMSetRenderTargets(1, &m_eyeRtv[texIndex], m_depthBuffer);
- deviceCtx->ClearRenderTargetView(m_eyeRtv[texIndex], black);
- deviceCtx->ClearDepthStencilView(m_depthBuffer, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1, 0);
+ deviceCtx->OMSetRenderTargets(1, &m_eyeRtv[_eye][texIndex], m_depthBuffer[_eye]);
+ deviceCtx->ClearRenderTargetView(m_eyeRtv[_eye][texIndex], black);
+ deviceCtx->ClearDepthStencilView(m_depthBuffer[_eye], D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1, 0);
D3D11_VIEWPORT D3Dvp;
D3Dvp.TopLeftX = 0;
D3Dvp.TopLeftY = 0;
- D3Dvp.Width = (FLOAT)m_eyeTextureSize.w;
- D3Dvp.Height = (FLOAT)m_eyeTextureSize.h;
+ D3Dvp.Width = (FLOAT)_desc.m_eyeSize[_eye].m_w;
+ D3Dvp.Height = (FLOAT)_desc.m_eyeSize[_eye].m_h;
D3Dvp.MinDepth = 0;
D3Dvp.MaxDepth = 1;
deviceCtx->RSSetViewports(1, &D3Dvp);
}
}
- void OVRBufferD3D11::postRender(const ovrSession& _session)
+ bool VRImplOVRD3D11::submitSwapChain(const VRDesc& /* _desc */)
{
- if (NULL != m_msaaTexture)
- {
- ID3D11DeviceContext* deviceCtx = s_renderD3D11->m_deviceCtx;
- int destIndex = 0;
- ovr_GetTextureSwapChainCurrentIndex(_session, m_textureSwapChain, &destIndex);
- ID3D11Resource* dstTex = NULL;
- ovr_GetTextureSwapChainBufferDX(_session, m_textureSwapChain, destIndex, IID_PPV_ARGS(&dstTex));
- deviceCtx->ResolveSubresource(dstTex, 0, m_msaaTexture, 0, DXGI_FORMAT_R8G8B8A8_UNORM);
- dstTex->Release();
- }
- }
+ ID3D11DeviceContext* deviceCtx = s_renderD3D11->m_deviceCtx;
+ IDXGISwapChain* swapChain = s_renderD3D11->m_swapChain;
- void OVRBufferD3D11::destroy(const ovrSession& _session)
- {
- for (uint32_t ii = 0; ii < BX_COUNTOF(m_eyeRtv); ++ii)
+ // resolve MSAA render targets
+ for (int eye = 0; eye < 2; ++eye)
{
- DX_RELEASE(m_eyeRtv[ii], 0);
- }
+ if (NULL != m_msaaTexture[eye])
+ {
+ int destIndex = 0;
+ ovr_GetTextureSwapChainCurrentIndex(m_session, m_textureSwapChain[eye], &destIndex);
- ovr_DestroyTextureSwapChain(_session, m_textureSwapChain);
- m_depthBuffer->Release();
+ ID3D11Resource* dstTex = NULL;
+ ovr_GetTextureSwapChainBufferDX(m_session, m_textureSwapChain[eye], destIndex, IID_PPV_ARGS(&dstTex));
+ deviceCtx->ResolveSubresource(dstTex, 0, m_msaaTexture[eye], 0, DXGI_FORMAT_R8G8B8A8_UNORM);
+ dstTex->Release();
+ }
- if (NULL != m_msaaTexture)
- {
- m_msaaTexture->Release();
- m_msaaTexture = NULL;
+ ovrResult result = ovr_CommitTextureSwapChain(m_session, m_textureSwapChain[eye]);
+ if (!OVR_SUCCESS(result))
+ {
+ return false;
+ }
}
- if (NULL != m_msaaSv)
+ ovrLayerHeader* layerList = &m_renderLayer.Header;
+ ovrResult result = ovr_SubmitFrame(m_session, 0, NULL, &layerList, 1);
+ if (!OVR_SUCCESS(result))
{
- m_msaaSv->Release();
- m_msaaSv = NULL;
+ return false;
}
- if (NULL != m_msaaRtv)
+ if (result != ovrSuccess_NotVisible && NULL != m_mirrorTexture)
{
- m_msaaRtv->Release();
- m_msaaRtv = NULL;
- }
- }
+ ID3D11Texture2D* tex = NULL;
+ ovr_GetMirrorTextureBufferDX(m_session, m_mirrorTexture, IID_PPV_ARGS(&tex));
+ ID3D11Texture2D* backBuffer;
+ DX_CHECK(swapChain->GetBuffer(0, IID_PPV_ARGS(&backBuffer)));
- void OVRMirrorD3D11::create(const ovrSession& _session, int _width, int _height)
- {
- m_mirrorTextureDesc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB;
- m_mirrorTextureDesc.Width = _width;
- m_mirrorTextureDesc.Height = _height;
- ovrResult result = ovr_CreateMirrorTextureDX(_session, s_renderD3D11->m_device, &m_mirrorTextureDesc, &m_mirrorTexture);
- BX_WARN(OVR_SUCCESS(result), "Could not create D3D11 OVR mirror texture");
- BX_UNUSED(result);
- }
+ deviceCtx->CopyResource(backBuffer, tex);
+ DX_CHECK(swapChain->Present(0, 0));
- void OVRMirrorD3D11::destroy(const ovrSession& session)
- {
- if (NULL != m_mirrorTexture)
- {
- ovr_DestroyMirrorTexture(session, m_mirrorTexture);
- m_mirrorTexture = NULL;
- }
+ DX_RELEASE(tex, 1);
+ DX_RELEASE(backBuffer, 0);
}
- void OVRMirrorD3D11::blit(const ovrSession& _session)
- {
- if (NULL != m_mirrorTexture)
- {
- ID3D11Texture2D* tex = NULL;
- ovr_GetMirrorTextureBufferDX(_session, m_mirrorTexture, IID_PPV_ARGS(&tex) );
- ID3D11Texture2D* backBuffer;
- DX_CHECK(s_renderD3D11->m_swapChain->GetBuffer(0, IID_ID3D11Texture2D, (void**)&backBuffer) );
-
- s_renderD3D11->m_deviceCtx->CopyResource(backBuffer, tex);
- DX_CHECK(s_renderD3D11->m_swapChain->Present(0, 0) );
+ return true;
+ }
- DX_RELEASE(tex, 1);
- DX_RELEASE(backBuffer, 0);
- }
- }
#endif // BGFX_CONFIG_USE_OVR
struct UavFormat
@@ -4152,7 +4208,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
else if (0 == (BGFX_UNIFORM_SAMPLERBIT & type) )
{
const UniformInfo* info = s_renderD3D11->m_uniformReg.find(name);
- BX_CHECK(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
+ BX_WARN(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
if (NULL != info)
{
@@ -5181,7 +5237,8 @@ BX_PRAGMA_DIAGNOSTIC_POP();
_render->m_hmdInitialized = m_ovr.isInitialized();
const bool hmdEnabled = m_ovr.isEnabled();
- ViewState viewState(_render, hmdEnabled);
+ static ViewState viewState;
+ viewState.reset(_render, hmdEnabled);
bool wireframe = !!(_render->m_debug&BGFX_DEBUG_WIREFRAME);
bool scissorEnabled = false;
@@ -5306,8 +5363,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
if (m_ovr.isEnabled() )
{
- m_ovr.getViewport(eye, &viewState.m_rect);
- m_ovr.renderEyeStart(eye);
+ m_ovr.renderEyeStart(eye, &viewState.m_rect);
}
else
{
@@ -5821,24 +5877,26 @@ BX_PRAGMA_DIAGNOSTIC_POP();
}
if (programChanged
- || currentState.m_vertexDecl.idx != draw.m_vertexDecl.idx
- || currentState.m_vertexBuffer.idx != draw.m_vertexBuffer.idx
+ || currentState.m_streamMask != draw.m_streamMask
+ || currentState.m_stream[0].m_decl.idx != draw.m_stream[0].m_decl.idx
+ || currentState.m_stream[0].m_handle.idx != draw.m_stream[0].m_handle.idx
|| currentState.m_instanceDataBuffer.idx != draw.m_instanceDataBuffer.idx
|| currentState.m_instanceDataOffset != draw.m_instanceDataOffset
|| currentState.m_instanceDataStride != draw.m_instanceDataStride)
{
- currentState.m_vertexDecl = draw.m_vertexDecl;
- currentState.m_vertexBuffer = draw.m_vertexBuffer;
+ currentState.m_streamMask = draw.m_streamMask;
+ currentState.m_stream[0].m_decl = draw.m_stream[0].m_decl;
+ currentState.m_stream[0].m_handle = draw.m_stream[0].m_handle;
currentState.m_instanceDataBuffer.idx = draw.m_instanceDataBuffer.idx;
currentState.m_instanceDataOffset = draw.m_instanceDataOffset;
currentState.m_instanceDataStride = draw.m_instanceDataStride;
- uint16_t handle = draw.m_vertexBuffer.idx;
+ uint16_t handle = draw.m_stream[0].m_handle.idx;
if (invalidHandle != handle)
{
const VertexBufferD3D11& vb = m_vertexBuffers[handle];
- uint16_t decl = !isValid(vb.m_decl) ? draw.m_vertexDecl.idx : vb.m_decl.idx;
+ uint16_t decl = !isValid(vb.m_decl) ? draw.m_stream[0].m_decl.idx : vb.m_decl.idx;
const VertexDecl& vertexDecl = m_vertexDecls[decl];
uint32_t stride = vertexDecl.m_stride;
uint32_t offset = 0;
@@ -5882,13 +5940,13 @@ BX_PRAGMA_DIAGNOSTIC_POP();
}
}
- if (isValid(currentState.m_vertexBuffer) )
+ if (0 != currentState.m_streamMask)
{
uint32_t numVertices = draw.m_numVertices;
if (UINT32_MAX == numVertices)
{
- const VertexBufferD3D11& vb = m_vertexBuffers[currentState.m_vertexBuffer.idx];
- uint16_t decl = !isValid(vb.m_decl) ? draw.m_vertexDecl.idx : vb.m_decl.idx;
+ const VertexBufferD3D11& vb = m_vertexBuffers[currentState.m_stream[0].m_handle.idx];
+ uint16_t decl = !isValid(vb.m_decl) ? draw.m_stream[0].m_decl.idx : vb.m_decl.idx;
const VertexDecl& vertexDecl = m_vertexDecls[decl];
numVertices = vb.m_size/vertexDecl.m_stride;
}
@@ -5954,7 +6012,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
deviceCtx->DrawIndexedInstanced(numIndices
, draw.m_numInstances
, 0
- , draw.m_startVertex
+ , draw.m_stream[0].m_startVertex
, 0
);
}
@@ -5962,7 +6020,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
{
deviceCtx->DrawIndexed(numIndices
, 0
- , draw.m_startVertex
+ , draw.m_stream[0].m_startVertex
);
}
}
@@ -5978,7 +6036,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
deviceCtx->DrawIndexedInstanced(numIndices
, draw.m_numInstances
, draw.m_startIndex
- , draw.m_startVertex
+ , draw.m_stream[0].m_startVertex
, 0
);
}
@@ -5986,7 +6044,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
{
deviceCtx->DrawIndexed(numIndices
, draw.m_startIndex
- , draw.m_startVertex
+ , draw.m_stream[0].m_startVertex
);
}
}
@@ -6001,14 +6059,14 @@ BX_PRAGMA_DIAGNOSTIC_POP();
{
deviceCtx->DrawInstanced(numVertices
, draw.m_numInstances
- , draw.m_startVertex
+ , draw.m_stream[0].m_startVertex
, 0
);
}
else
{
deviceCtx->Draw(numVertices
- , draw.m_startVertex
+ , draw.m_stream[0].m_startVertex
);
}
}
diff --git a/3rdparty/bgfx/src/renderer_d3d11.h b/3rdparty/bgfx/src/renderer_d3d11.h
index 5d8614a7301..796e99c39e8 100644
--- a/3rdparty/bgfx/src/renderer_d3d11.h
+++ b/3rdparty/bgfx/src/renderer_d3d11.h
@@ -32,7 +32,7 @@ BX_PRAGMA_DIAGNOSTIC_POP()
#include "renderer.h"
#include "renderer_d3d.h"
#include "shader_dxbc.h"
-#include "hmd_ovr.h"
+#include "hmd.h"
#include "hmd_openvr.h"
#include "debug_renderdoc.h"
@@ -60,29 +60,6 @@ BX_PRAGMA_DIAGNOSTIC_POP()
namespace bgfx { namespace d3d11
{
-#if BGFX_CONFIG_USE_OVR
- struct OVRBufferD3D11 : public OVRBufferI
- {
- virtual void create(const ovrSession& _session, int _eyeIdx, int _msaaSamples) BX_OVERRIDE;
- virtual void destroy(const ovrSession& _session) BX_OVERRIDE;
- virtual void render(const ovrSession& _session) BX_OVERRIDE;
- virtual void postRender(const ovrSession& _session) BX_OVERRIDE;
-
- ID3D11RenderTargetView* m_eyeRtv[4];
- ID3D11DepthStencilView* m_depthBuffer;
- ID3D11Texture2D* m_msaaTexture;
- ID3D11ShaderResourceView* m_msaaSv;
- ID3D11RenderTargetView* m_msaaRtv;
- };
-
- struct OVRMirrorD3D11 : public OVRMirrorI
- {
- virtual void create(const ovrSession& _session, int _width, int _height) BX_OVERRIDE;
- virtual void destroy(const ovrSession& session) BX_OVERRIDE;
- virtual void blit(const ovrSession& session) BX_OVERRIDE;
- };
-#endif // BGFX_CONFIG_USE_OVR
-
struct BufferD3D11
{
BufferD3D11()
diff --git a/3rdparty/bgfx/src/renderer_d3d12.cpp b/3rdparty/bgfx/src/renderer_d3d12.cpp
index f66e735e38f..d7a449ea82d 100644
--- a/3rdparty/bgfx/src/renderer_d3d12.cpp
+++ b/3rdparty/bgfx/src/renderer_d3d12.cpp
@@ -987,12 +987,6 @@ namespace bgfx { namespace d3d12
, (void**)&m_rootSignature
) );
- UniformHandle handle = BGFX_INVALID_HANDLE;
- for (uint32_t ii = 0; ii < PredefinedUniform::Count; ++ii)
- {
- m_uniformReg.add(handle, getPredefinedUniformName(PredefinedUniform::Enum(ii) ), &m_predefinedUniforms[ii]);
- }
-
g_caps.supported |= ( 0
| BGFX_CAPS_TEXTURE_3D
| BGFX_CAPS_TEXTURE_COMPARE_ALL
@@ -1011,8 +1005,8 @@ namespace bgfx { namespace d3d12
| BGFX_CAPS_TEXTURE_2D_ARRAY
| BGFX_CAPS_TEXTURE_CUBE_ARRAY
);
- g_caps.maxTextureSize = 16384;
- g_caps.maxFBAttachments = uint8_t(bx::uint32_min(16, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS) );
+ g_caps.limits.maxTextureSize = 16384;
+ g_caps.limits.maxFBAttachments = uint8_t(bx::uint32_min(16, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS) );
for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii)
{
@@ -1407,7 +1401,7 @@ namespace bgfx { namespace d3d12
{
}
- void readTexture(TextureHandle _handle, void* _data) BX_OVERRIDE
+ void readTexture(TextureHandle _handle, void* _data, uint8_t _mip ) BX_OVERRIDE
{
const TextureD3D12& texture = m_textures[_handle.idx];
@@ -1418,7 +1412,7 @@ namespace bgfx { namespace d3d12
uint64_t total;
uint64_t srcPitch;
m_device->GetCopyableFootprints(&desc
- , 0
+ , _mip
, 1
, 0
, &layout
@@ -1444,16 +1438,18 @@ namespace bgfx { namespace d3d12
finish();
m_commandList = m_cmd.alloc();
+ uint32_t srcWidth = bx::uint32_max(1, texture.m_width >>_mip);
+ uint32_t srcHeight = bx::uint32_max(1, texture.m_height>>_mip);
uint8_t* src;
readback->Map(0, NULL, (void**)&src);
const uint8_t bpp = getBitsPerPixel(TextureFormat::Enum(texture.m_textureFormat) );
uint8_t* dst = (uint8_t*)_data;
- uint32_t dstPitch = texture.m_width*bpp/8;
+ uint32_t dstPitch = srcWidth*bpp/8;
uint32_t pitch = bx::uint32_min(uint32_t(srcPitch), dstPitch);
- for (uint32_t yy = 0, height = texture.m_height; yy < height; ++yy)
+ for (uint32_t yy = 0, height = srcHeight; yy < height; ++yy)
{
memcpy(dst, src, pitch);
@@ -1555,6 +1551,7 @@ namespace bgfx { namespace d3d12
{
BX_FREE(g_allocator, m_uniforms[_handle.idx]);
m_uniforms[_handle.idx] = NULL;
+ m_uniformReg.remove(_handle);
}
void saveScreenShot(const char* _filePath) BX_OVERRIDE
@@ -3017,6 +3014,7 @@ data.NumQualityLevels = 0;
D3D12_UNORDERED_ACCESS_VIEW_DESC tmpUavd;
D3D12_UNORDERED_ACCESS_VIEW_DESC* uavd = &_texture.m_uavd;
+
if (0 != _mip)
{
memcpy(&tmpUavd, uavd, sizeof(tmpUavd) );
@@ -3029,6 +3027,10 @@ data.NumQualityLevels = 0;
uavd->Texture2D.MipSlice = _mip;
uavd->Texture2D.PlaneSlice = 0;
break;
+ case D3D12_UAV_DIMENSION_TEXTURE2DARRAY:
+ uavd->Texture2DArray.MipSlice = _mip;
+ uavd->Texture2DArray.PlaneSlice = 0;
+ break;
case D3D12_UAV_DIMENSION_TEXTURE3D:
uavd->Texture3D.MipSlice = _mip;
@@ -3436,10 +3438,10 @@ data.NumQualityLevels = 0;
{
Enum type = Enum(!!isValid(_draw.m_indexBuffer) );
- VertexBufferD3D12& vb = s_renderD3D12->m_vertexBuffers[_draw.m_vertexBuffer.idx];
+ VertexBufferD3D12& vb = s_renderD3D12->m_vertexBuffers[_draw.m_stream[0].m_handle.idx];
vb.setState(_commandList, D3D12_RESOURCE_STATE_GENERIC_READ);
- uint16_t declIdx = !isValid(vb.m_decl) ? _draw.m_vertexDecl.idx : vb.m_decl.idx;
+ uint16_t declIdx = !isValid(vb.m_decl) ? _draw.m_stream[0].m_decl.idx : vb.m_decl.idx;
const VertexDecl& vertexDecl = s_renderD3D12->m_vertexDecls[declIdx];
uint32_t numIndices = 0;
@@ -3469,7 +3471,7 @@ data.NumQualityLevels = 0;
}
cmd.draw.InstanceCount = _draw.m_numInstances;
cmd.draw.VertexCountPerInstance = numVertices;
- cmd.draw.StartVertexLocation = _draw.m_startVertex;
+ cmd.draw.StartVertexLocation = _draw.m_stream[0].m_startVertex;
cmd.draw.StartInstanceLocation = 0;
}
else
@@ -3511,7 +3513,7 @@ data.NumQualityLevels = 0;
cmd.drawIndexed.IndexCountPerInstance = numIndices;
cmd.drawIndexed.InstanceCount = _draw.m_numInstances;
cmd.drawIndexed.StartIndexLocation = _draw.m_startIndex;
- cmd.drawIndexed.BaseVertexLocation = _draw.m_startVertex;
+ cmd.drawIndexed.BaseVertexLocation = _draw.m_stream[0].m_startVertex;
cmd.drawIndexed.StartInstanceLocation = 0;
}
@@ -3879,7 +3881,7 @@ data.NumQualityLevels = 0;
else if (0 == (BGFX_UNIFORM_SAMPLERBIT & type) )
{
const UniformInfo* info = s_renderD3D12->m_uniformReg.find(name);
- BX_CHECK(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
+ BX_WARN(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
if (NULL != info)
{
@@ -4244,6 +4246,14 @@ data.NumQualityLevels = 0;
m_uavd.Texture2D.MipSlice = 0;
m_uavd.Texture2D.PlaneSlice = 0;
}
+
+ if( m_type==TextureCube )
+ {
+ m_uavd.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY;
+ m_uavd.Texture2DArray.MipSlice = 0;
+ m_uavd.Texture2DArray.ArraySize = 6;
+ }
+
break;
case Texture3D:
@@ -4766,7 +4776,7 @@ data.NumQualityLevels = 0;
_render->m_hmdInitialized = false;
const bool hmdEnabled = false;
- ViewState viewState(_render, hmdEnabled);
+ static ViewState viewState;
viewState.reset(_render, hmdEnabled);
// bool wireframe = !!(_render->m_debug&BGFX_DEBUG_WIREFRAME);
@@ -5205,7 +5215,7 @@ data.NumQualityLevels = 0;
rendererUpdateUniforms(this, _render->m_uniformBuffer, draw.m_constBegin, draw.m_constEnd);
- if (isValid(draw.m_vertexBuffer) )
+ if (isValid(draw.m_stream[0].m_handle) )
{
const uint64_t state = draw.m_stateFlags;
bool hasFactor = 0
@@ -5215,8 +5225,8 @@ data.NumQualityLevels = 0;
|| f3 == (state & f3)
;
- const VertexBufferD3D12& vb = m_vertexBuffers[draw.m_vertexBuffer.idx];
- uint16_t declIdx = !isValid(vb.m_decl) ? draw.m_vertexDecl.idx : vb.m_decl.idx;
+ const VertexBufferD3D12& vb = m_vertexBuffers[draw.m_stream[0].m_handle.idx];
+ uint16_t declIdx = !isValid(vb.m_decl) ? draw.m_stream[0].m_decl.idx : vb.m_decl.idx;
ID3D12PipelineState* pso =
getPipelineState(state
diff --git a/3rdparty/bgfx/src/renderer_d3d9.cpp b/3rdparty/bgfx/src/renderer_d3d9.cpp
index be388785ada..1b26f9a9193 100644
--- a/3rdparty/bgfx/src/renderer_d3d9.cpp
+++ b/3rdparty/bgfx/src/renderer_d3d9.cpp
@@ -578,11 +578,10 @@ namespace bgfx { namespace d3d9
| BGFX_CAPS_TEXTURE_READ_BACK
| (m_occlusionQuerySupport ? BGFX_CAPS_OCCLUSION_QUERY : 0)
);
- g_caps.maxTextureSize = uint16_t(bx::uint32_min(m_caps.MaxTextureWidth, m_caps.MaxTextureHeight) );
-// g_caps.maxVertexIndex = m_caps.MaxVertexIndex;
+ g_caps.limits.maxTextureSize = uint16_t(bx::uint32_min(m_caps.MaxTextureWidth, m_caps.MaxTextureHeight) );
m_caps.NumSimultaneousRTs = uint8_t(bx::uint32_min(m_caps.NumSimultaneousRTs, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS) );
- g_caps.maxFBAttachments = uint8_t(m_caps.NumSimultaneousRTs);
+ g_caps.limits.maxFBAttachments = uint8_t(m_caps.NumSimultaneousRTs);
m_caps.MaxAnisotropy = bx::uint32_max(m_caps.MaxAnisotropy, 1);
@@ -988,27 +987,29 @@ namespace bgfx { namespace d3d9
m_updateTexture = NULL;
}
- void readTexture(TextureHandle _handle, void* _data) BX_OVERRIDE
+ void readTexture(TextureHandle _handle, void* _data, uint8_t _mip) BX_OVERRIDE
{
TextureD3D9& texture = m_textures[_handle.idx];
D3DLOCKED_RECT lockedRect;
- DX_CHECK(texture.m_texture2d->LockRect(0
+ DX_CHECK(texture.m_texture2d->LockRect(_mip
, &lockedRect
, NULL
, D3DLOCK_NO_DIRTY_UPDATE|D3DLOCK_NOSYSLOCK|D3DLOCK_READONLY
) );
- uint32_t srcPitch = lockedRect.Pitch;
- uint8_t* src = (uint8_t*)lockedRect.pBits;
+ uint32_t srcWidth = bx::uint32_max(1, texture.m_width >>_mip);
+ uint32_t srcHeight = bx::uint32_max(1, texture.m_height>>_mip);
+ uint32_t srcPitch = lockedRect.Pitch;
+ uint8_t* src = (uint8_t*)lockedRect.pBits;
const uint8_t bpp = getBitsPerPixel(TextureFormat::Enum(texture.m_textureFormat) );
uint8_t* dst = (uint8_t*)_data;
- uint32_t dstPitch = texture.m_width*bpp/8;
+ uint32_t dstPitch = srcWidth*bpp/8;
uint32_t pitch = bx::uint32_min(srcPitch, dstPitch);
- for (uint32_t yy = 0, height = texture.m_height; yy < height; ++yy)
+ for (uint32_t yy = 0, height = srcHeight; yy < height; ++yy)
{
memcpy(dst, src, pitch);
@@ -1016,7 +1017,7 @@ namespace bgfx { namespace d3d9
dst += dstPitch;
}
- DX_CHECK(texture.m_texture2d->UnlockRect(0) );
+ DX_CHECK(texture.m_texture2d->UnlockRect(_mip) );
}
void resizeTexture(TextureHandle _handle, uint16_t _width, uint16_t _height, uint8_t _numMips) BX_OVERRIDE
@@ -1113,6 +1114,7 @@ namespace bgfx { namespace d3d9
{
BX_FREE(g_allocator, m_uniforms[_handle.idx]);
m_uniforms[_handle.idx] = NULL;
+ m_uniformReg.remove(_handle);
}
void saveScreenShot(const char* _filePath) BX_OVERRIDE
@@ -1357,7 +1359,7 @@ namespace bgfx { namespace d3d9
if (!isValid(_fbh) )
{
DX_CHECK(m_device->SetRenderTarget(0, m_backBufferColor) );
- for (uint32_t ii = 1, num = g_caps.maxFBAttachments; ii < num; ++ii)
+ for (uint32_t ii = 1, num = g_caps.limits.maxFBAttachments; ii < num; ++ii)
{
DX_CHECK(m_device->SetRenderTarget(ii, NULL) );
}
@@ -1390,7 +1392,7 @@ namespace bgfx { namespace d3d9
}
}
- for (uint32_t ii = rtIdx, num = g_caps.maxFBAttachments; ii < num; ++ii)
+ for (uint32_t ii = rtIdx, num = g_caps.limits.maxFBAttachments; ii < num; ++ii)
{
DX_CHECK(m_device->SetRenderTarget(ii, NULL) );
}
@@ -1507,7 +1509,7 @@ namespace bgfx { namespace d3d9
}
DX_CHECK(m_device->SetRenderTarget(0, m_backBufferColor) );
- for (uint32_t ii = 1, num = g_caps.maxFBAttachments; ii < num; ++ii)
+ for (uint32_t ii = 1, num = g_caps.limits.maxFBAttachments; ii < num; ++ii)
{
DX_CHECK(m_device->SetRenderTarget(ii, NULL) );
}
@@ -2426,7 +2428,7 @@ namespace bgfx { namespace d3d9
else if (0 == (BGFX_UNIFORM_SAMPLERBIT & type) )
{
const UniformInfo* info = s_renderD3D9->m_uniformReg.find(name);
- BX_CHECK(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
+ BX_WARN(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
if (NULL != info)
{
@@ -4020,22 +4022,24 @@ namespace bgfx { namespace d3d9
}
if (programChanged
- || currentState.m_vertexBuffer.idx != draw.m_vertexBuffer.idx
+ || currentState.m_streamMask != draw.m_streamMask
+ || currentState.m_stream[0].m_handle.idx != draw.m_stream[0].m_handle.idx
|| currentState.m_instanceDataBuffer.idx != draw.m_instanceDataBuffer.idx
- || currentState.m_instanceDataOffset != draw.m_instanceDataOffset
- || currentState.m_instanceDataStride != draw.m_instanceDataStride)
+ || currentState.m_instanceDataOffset != draw.m_instanceDataOffset
+ || currentState.m_instanceDataStride != draw.m_instanceDataStride)
{
- currentState.m_vertexBuffer = draw.m_vertexBuffer;
+ currentState.m_streamMask = draw.m_streamMask;
+ currentState.m_stream[0].m_handle = draw.m_stream[0].m_handle;
currentState.m_instanceDataBuffer.idx = draw.m_instanceDataBuffer.idx;
- currentState.m_instanceDataOffset = draw.m_instanceDataOffset;
- currentState.m_instanceDataStride = draw.m_instanceDataStride;
+ currentState.m_instanceDataOffset = draw.m_instanceDataOffset;
+ currentState.m_instanceDataStride = draw.m_instanceDataStride;
- uint16_t handle = draw.m_vertexBuffer.idx;
+ uint16_t handle = draw.m_stream[0].m_handle.idx;
if (invalidHandle != handle)
{
const VertexBufferD3D9& vb = m_vertexBuffers[handle];
- uint16_t decl = !isValid(vb.m_decl) ? draw.m_vertexDecl.idx : vb.m_decl.idx;
+ uint16_t decl = !isValid(vb.m_decl) ? draw.m_stream[0].m_decl.idx : vb.m_decl.idx;
const VertexDeclD3D9& vertexDecl = m_vertexDecls[decl];
DX_CHECK(device->SetStreamSource(0, vb.m_ptr, 0, vertexDecl.m_decl.m_stride) );
@@ -4081,13 +4085,13 @@ namespace bgfx { namespace d3d9
}
}
- if (isValid(currentState.m_vertexBuffer) )
+ if (0 != currentState.m_streamMask)
{
uint32_t numVertices = draw.m_numVertices;
if (UINT32_MAX == numVertices)
{
- const VertexBufferD3D9& vb = m_vertexBuffers[currentState.m_vertexBuffer.idx];
- uint16_t decl = !isValid(vb.m_decl) ? draw.m_vertexDecl.idx : vb.m_decl.idx;
+ const VertexBufferD3D9& vb = m_vertexBuffers[currentState.m_stream[0].m_handle.idx];
+ uint16_t decl = !isValid(vb.m_decl) ? draw.m_stream[0].m_decl.idx : vb.m_decl.idx;
const VertexDeclD3D9& vertexDecl = m_vertexDecls[decl];
numVertices = vb.m_size/vertexDecl.m_decl.m_stride;
}
@@ -4114,7 +4118,7 @@ namespace bgfx { namespace d3d9
numPrimsRendered = numPrimsSubmitted*draw.m_numInstances;
DX_CHECK(device->DrawIndexedPrimitive(prim.m_type
- , draw.m_startVertex
+ , draw.m_stream[0].m_startVertex
, 0
, numVertices
, 0
@@ -4129,7 +4133,7 @@ namespace bgfx { namespace d3d9
numPrimsRendered = numPrimsSubmitted*draw.m_numInstances;
DX_CHECK(device->DrawIndexedPrimitive(prim.m_type
- , draw.m_startVertex
+ , draw.m_stream[0].m_startVertex
, 0
, numVertices
, draw.m_startIndex
@@ -4144,7 +4148,7 @@ namespace bgfx { namespace d3d9
numPrimsRendered = numPrimsSubmitted*draw.m_numInstances;
DX_CHECK(device->DrawPrimitive(prim.m_type
- , draw.m_startVertex
+ , draw.m_stream[0].m_startVertex
, numPrimsSubmitted
) );
}
diff --git a/3rdparty/bgfx/src/renderer_gl.cpp b/3rdparty/bgfx/src/renderer_gl.cpp
index 75e3a4ef3a7..73122fe74ff 100644
--- a/3rdparty/bgfx/src/renderer_gl.cpp
+++ b/3rdparty/bgfx/src/renderer_gl.cpp
@@ -9,6 +9,7 @@
# include "renderer_gl.h"
# include <bx/timer.h>
# include <bx/uint32_t.h>
+# include "hmd_ovr.h"
#if BGFX_CONFIG_PROFILER_REMOTERY
# define BGFX_GPU_PROFILER_BIND() rmt_BindOpenGL()
@@ -1014,6 +1015,10 @@ namespace bgfx { namespace gl
}
}
+ static void GL_APIENTRY stubPolygonMode(GLenum /*_face*/, GLenum /*_mode*/)
+ {
+ }
+
typedef void (*PostSwapBuffersFn)(uint32_t _width, uint32_t _height);
static const char* getGLString(GLenum _name)
@@ -1131,7 +1136,7 @@ namespace bgfx { namespace gl
void flushGlError()
{
- for (GLenum err = glGetError(); err != 0; err = glGetError());
+ for (GLenum err = glGetError(); err != 0; err = glGetError() );
}
GLenum initTestTexture(TextureFormat::Enum _format, bool _srgb, bool _mipmaps)
@@ -1352,6 +1357,47 @@ namespace bgfx { namespace gl
BX_UNUSED(supported);
}
+#if BGFX_CONFIG_USE_OVR
+ class VRImplOVRGL : public VRImplOVR
+ {
+ public:
+ VRImplOVRGL();
+
+ virtual bool createSwapChain(const VRDesc& _desc, int _msaaSamples, int _mirrorWidth, int _mirrorHeight) BX_OVERRIDE;
+ virtual void destroySwapChain() BX_OVERRIDE;
+ virtual void destroyMirror() BX_OVERRIDE;
+ virtual void renderEyeStart(const VRDesc& _desc, uint8_t _eye) BX_OVERRIDE;
+ virtual bool submitSwapChain(const VRDesc& _desc) BX_OVERRIDE;
+
+ private:
+ GLuint m_eyeFbo[2];
+ GLuint m_eyeTexId[2][4];
+ GLuint m_depthBuffer[2];
+ GLuint m_msaaEyeFbo[2];
+ GLuint m_msaaEyeTexId[2];
+ GLuint m_msaaDepthBuffer[2];
+ GLuint m_mirrorFbo;
+ GLint m_mirrorWidth;
+ GLint m_mirrorHeight;
+
+ ovrTextureSwapChain m_textureSwapChain[2];
+ ovrMirrorTexture m_mirrorTexture;
+ };
+#endif // BGFX_CONFIG_USE_OVR
+
+ struct VendorId
+ {
+ const char* name;
+ uint16_t id;
+ };
+
+ static const VendorId s_vendorIds[] =
+ {
+ { "NVIDIA Corporation", BGFX_PCI_ID_NVIDIA },
+ { "Advanced Micro Devices, Inc.", BGFX_PCI_ID_AMD },
+ { "Intel", BGFX_PCI_ID_INTEL },
+ };
+
struct RendererContextGL : public RendererContextI
{
RendererContextGL()
@@ -1401,13 +1447,27 @@ namespace bgfx { namespace gl
setRenderContextSize(BGFX_DEFAULT_WIDTH, BGFX_DEFAULT_HEIGHT);
// Must be after context is initialized?!
- m_ovr.init();
+ VRImplI* vrImpl = NULL;
+#if BGFX_CONFIG_USE_OVR
+ vrImpl = &m_ovrRender;
+#endif
+ m_ovr.init(vrImpl);
m_vendor = getGLString(GL_VENDOR);
m_renderer = getGLString(GL_RENDERER);
m_version = getGLString(GL_VERSION);
m_glslVersion = getGLString(GL_SHADING_LANGUAGE_VERSION);
+ for (uint32_t ii = 0; ii < BX_COUNTOF(s_vendorIds); ++ii)
+ {
+ const VendorId& vendorId = s_vendorIds[ii];
+ if (0 == strncmp(vendorId.name, m_vendor, strlen(vendorId.name) ) )
+ {
+ g_caps.vendorId = vendorId.id;
+ break;
+ }
+ }
+
GLint numCmpFormats = 0;
GL_CHECK(glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numCmpFormats) );
BX_TRACE("GL_NUM_COMPRESSED_TEXTURE_FORMATS %d", numCmpFormats);
@@ -1872,6 +1932,11 @@ namespace bgfx { namespace gl
: 0
;
+ if (NULL == glPolygonMode)
+ {
+ glPolygonMode = stubPolygonMode;
+ }
+
if (s_extension[Extension::ARB_copy_image].m_supported
|| s_extension[Extension::EXT_copy_image].m_supported
|| s_extension[Extension:: NV_copy_image].m_supported
@@ -1904,14 +1969,14 @@ namespace bgfx { namespace gl
: 0
;
- g_caps.maxTextureSize = uint16_t(glGet(GL_MAX_TEXTURE_SIZE) );
+ g_caps.limits.maxTextureSize = uint16_t(glGet(GL_MAX_TEXTURE_SIZE) );
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
|| BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES >= 30)
|| s_extension[Extension::EXT_draw_buffers ].m_supported
|| s_extension[Extension::WEBGL_draw_buffers].m_supported)
{
- g_caps.maxFBAttachments = uint8_t(bx::uint32_min(glGet(GL_MAX_DRAW_BUFFERS)
+ g_caps.limits.maxFBAttachments = uint8_t(bx::uint32_min(glGet(GL_MAX_DRAW_BUFFERS)
, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS)
);
}
@@ -2205,15 +2270,8 @@ namespace bgfx { namespace gl
m_glctx.swap(m_frameBuffers[m_windows[ii].idx].m_swapChain);
}
- switch (m_ovr.swap(_hmd, true) )
- {
- case OVR::DeviceLost:
- ovrPreReset();
- break;
-
- default:
- break;
- }
+ m_ovr.flip();
+ m_ovr.swap(_hmd); // TODO - move this out of end-of-frame
// need to swap GL render context even if OVR is enabled to get the mirror texture in the output
m_glctx.swap();
@@ -2321,7 +2379,7 @@ namespace bgfx { namespace gl
{
}
- void readTexture(TextureHandle _handle, void* _data) BX_OVERRIDE
+ void readTexture(TextureHandle _handle, void* _data, uint8_t _mip) BX_OVERRIDE
{
if (m_readBackSupported)
{
@@ -2333,14 +2391,14 @@ namespace bgfx { namespace gl
if (compressed)
{
GL_CHECK(glGetCompressedTexImage(texture.m_target
- , 0
+ , _mip
, _data
) );
}
else
{
GL_CHECK(glGetTexImage(texture.m_target
- , 0
+ , _mip
, texture.m_fmt
, texture.m_type
, _data
@@ -2439,6 +2497,7 @@ namespace bgfx { namespace gl
{
BX_FREE(g_allocator, m_uniforms[_handle.idx]);
m_uniforms[_handle.idx] = NULL;
+ m_uniformReg.remove(_handle);
}
void saveScreenShot(const char* _filePath) BX_OVERRIDE
@@ -2956,24 +3015,8 @@ namespace bgfx { namespace gl
#if BGFX_CONFIG_USE_OVR
if (m_resolution.m_flags & (BGFX_RESET_HMD|BGFX_RESET_HMD_DEBUG) )
{
- if (m_ovr.postReset() )
- {
- const uint32_t msaaSamples = 1 << ((m_resolution.m_flags&BGFX_RESET_MSAA_MASK) >> BGFX_RESET_MSAA_SHIFT);
-
- for (uint32_t ii = 0; ii < 2; ++ii)
- {
- // eye buffers need to be initialized only once during application lifetime
- if (NULL == m_ovr.m_eyeBuffers[ii])
- {
- m_ovr.m_eyeBuffers[ii] = &m_ovrBuffers[ii];
- m_ovr.m_eyeBuffers[ii]->create(m_ovr.m_hmd, ii, msaaSamples);
- }
- }
-
- // recreate mirror texture
- m_ovr.m_mirror = &m_ovrMirror;
- m_ovr.m_mirror->create(m_ovr.m_hmd, m_resolution.m_width, m_resolution.m_height);
- }
+ const uint32_t msaaSamples = 1 << ( (m_resolution.m_flags&BGFX_RESET_MSAA_MASK) >> BGFX_RESET_MSAA_SHIFT);
+ m_ovr.postReset(msaaSamples, m_resolution.m_width, m_resolution.m_height);
}
#endif // BGFX_CONFIG_USE_OVR
}
@@ -3404,10 +3447,9 @@ namespace bgfx { namespace gl
const char* m_version;
const char* m_glslVersion;
- OVR m_ovr;
+ VR m_ovr;
#if BGFX_CONFIG_USE_OVR
- OVRMirrorGL m_ovrMirror;
- OVRBufferGL m_ovrBuffers[2];
+ VRImplOVRGL m_ovrRender;
#endif // BGFX_CONFIG_USE_OVR
};
@@ -3428,215 +3470,247 @@ namespace bgfx { namespace gl
}
#if BGFX_CONFIG_USE_OVR
- void OVRBufferGL::create(const ovrSession& _session, int _eyeIdx, int _msaaSamples)
+
+ VRImplOVRGL::VRImplOVRGL()
+ : m_mirrorTexture(NULL)
+ {
+ memset(&m_textureSwapChain, 0, sizeof(m_textureSwapChain) );
+ }
+
+ static void setDefaultSamplerState()
{
- m_eyeFbo = 0;
- m_eyeTexId = 0;
- m_depthBuffer = 0;
- m_msaaEyeFbo = 0;
- m_msaaEyeTexId = 0;
- m_msaaDepthBuffer = 0;
+ GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) );
+ GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) );
+ GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) );
+ GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) );
+ }
- ovrHmdDesc hmdDesc = ovr_GetHmdDesc(_session);
- m_eyeTextureSize = ovr_GetFovTextureSize(_session, ovrEyeType(_eyeIdx), hmdDesc.DefaultEyeFov[_eyeIdx], 1.0f);
+ bool VRImplOVRGL::createSwapChain(const VRDesc& _desc, int _msaaSamples, int _mirrorWidth, int _mirrorHeight)
+ {
+ for (int eye = 0; eye < 2; ++eye)
+ {
+ if (NULL == m_textureSwapChain[eye])
+ {
+ m_eyeFbo[eye] = 0;
+ m_depthBuffer[eye] = 0;
+ m_msaaEyeFbo[eye] = 0;
+ m_msaaEyeTexId[eye] = 0;
+ m_msaaDepthBuffer[eye] = 0;
+ memset(&m_eyeTexId[eye], 0, sizeof(m_eyeTexId[eye]) );
+
+ ovrTextureSwapChainDesc swapchainDesc = {};
+ swapchainDesc.Type = ovrTexture_2D;
+ swapchainDesc.ArraySize = 1;
+ swapchainDesc.Width = _desc.m_eyeSize[eye].m_w;
+ swapchainDesc.Height = _desc.m_eyeSize[eye].m_h;
+ swapchainDesc.MipLevels = 1;
+ swapchainDesc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB;
+ swapchainDesc.SampleCount = 1;
+ swapchainDesc.StaticImage = ovrFalse;
+
+ ovrResult result = ovr_CreateTextureSwapChainGL(m_session, &swapchainDesc, &m_textureSwapChain[eye]);
+ if (!OVR_SUCCESS(result) )
+ {
+ destroySwapChain();
+ return false;
+ }
- ovrTextureSwapChainDesc desc = {};
- desc.Type = ovrTexture_2D;
- desc.ArraySize = 1;
- desc.Width = m_eyeTextureSize.w;
- desc.Height = m_eyeTextureSize.h;
- desc.MipLevels = 1;
- desc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB;
- desc.SampleCount = 1;
- desc.StaticImage = ovrFalse;
+ int textureCount = 0;
+ ovr_GetTextureSwapChainLength(m_session, m_textureSwapChain[eye], &textureCount);
+ for (int ii = 0; ii < textureCount; ++ii)
+ {
+ ovr_GetTextureSwapChainBufferGL(m_session, m_textureSwapChain[eye], ii, &m_eyeTexId[eye][ii]);
+ GL_CHECK(glBindTexture(GL_TEXTURE_2D, m_eyeTexId[eye][ii]) );
+ setDefaultSamplerState();
+ }
- ovr_CreateTextureSwapChainGL(_session, &desc, &m_textureSwapChain);
+ GL_CHECK(glGenFramebuffers(1, &m_eyeFbo[eye]) );
- int textureCount = 0;
- ovr_GetTextureSwapChainLength(_session, m_textureSwapChain, &textureCount);
+ // create depth buffer
+ GL_CHECK(glGenTextures(1, &m_depthBuffer[eye]) );
+ GL_CHECK(glBindTexture(GL_TEXTURE_2D, m_depthBuffer[eye]) );
+ setDefaultSamplerState();
- for (int j = 0; j < textureCount; ++j)
- {
- GLuint chainTexId;
- ovr_GetTextureSwapChainBufferGL(_session, m_textureSwapChain, j, &chainTexId);
- GL_CHECK(glBindTexture(GL_TEXTURE_2D, chainTexId) );
+ GL_CHECK(glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, _desc.m_eyeSize[eye].m_w, _desc.m_eyeSize[eye].m_h, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL) );
- GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) );
- GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) );
- GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) );
- GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) );
- }
+ GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, m_eyeFbo[eye]) );
+ GL_CHECK(glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_depthBuffer[eye], 0) );
+ GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, 0) );
- GL_CHECK(glGenFramebuffers(1, &m_eyeFbo) );
+ // create MSAA targets if needed
+ if (_msaaSamples > 1)
+ {
+ GL_CHECK(glGenFramebuffers(1, &m_msaaEyeFbo[eye]) );
+
+ // create color MSAA texture
+ GL_CHECK(glGenTextures(1, &m_msaaEyeTexId[eye]) );
+ GL_CHECK(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_msaaEyeTexId[eye]) );
+ GL_CHECK(glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, _msaaSamples, GL_RGBA, _desc.m_eyeSize[eye].m_w, _desc.m_eyeSize[eye].m_h, false) );
+ setDefaultSamplerState();
+
+ // create MSAA depth buffer
+ GL_CHECK(glGenTextures(1, &m_msaaDepthBuffer[eye]) );
+ GL_CHECK(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_depthBuffer[eye]) );
+ GL_CHECK(glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, _msaaSamples, GL_DEPTH_COMPONENT, _desc.m_eyeSize[eye].m_w, _desc.m_eyeSize[eye].m_h, false) );
+ setDefaultSamplerState();
+
+ GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, m_msaaEyeFbo[eye]) );
+ GL_CHECK(glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, m_msaaEyeTexId[eye], 0) );
+ GL_CHECK(glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0) );
+ GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, 0) );
+ }
- // create depth buffer
- GL_CHECK(glGenTextures(1, &m_depthBuffer) );
- GL_CHECK(glBindTexture(GL_TEXTURE_2D, m_depthBuffer) );
- GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) );
- GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) );
- GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) );
- GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) );
+ m_renderLayer.ColorTexture[eye] = m_textureSwapChain[eye];
+ }
+ }
- GL_CHECK(glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, m_eyeTextureSize.w, m_eyeTextureSize.h, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL) );
+ m_renderLayer.Header.Flags |= ovrLayerFlag_TextureOriginAtBottomLeft;
- // create MSAA buffers
- if (_msaaSamples > 1)
+ if (NULL == m_mirrorTexture)
{
- GL_CHECK(glGenFramebuffers(1, &m_msaaEyeFbo) );
+ m_mirrorFbo = 0;
- // create color MSAA texture
- GL_CHECK(glGenTextures(1, &m_msaaEyeTexId) );
- GL_CHECK(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_msaaEyeTexId) );
+ ovrMirrorTextureDesc mirrorDesc = {};
+ mirrorDesc.Width = _mirrorWidth;
+ mirrorDesc.Height = _mirrorHeight;
+ mirrorDesc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB;
- GL_CHECK(glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, _msaaSamples, GL_RGBA, m_eyeTextureSize.w, m_eyeTextureSize.h, false) );
- GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER) );
- GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER) );
- GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR) );
- GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) );
- GL_CHECK(glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAX_LEVEL, 0) );
+ // Fallback to doing nothing if mirror was not created. This is to prevent errors with fast window resizes
+ ovr_CreateMirrorTextureGL(m_session, &mirrorDesc, &m_mirrorTexture);
+ if (m_mirrorTexture)
+ {
+ m_mirrorWidth = _mirrorWidth;
+ m_mirrorHeight = _mirrorHeight;
- // create MSAA depth buffer
- GL_CHECK(glGenTextures(1, &m_msaaDepthBuffer) );
- GL_CHECK(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_msaaDepthBuffer) );
+ // Configure the mirror read buffer
+ GLuint texId;
+ ovr_GetMirrorTextureBufferGL(m_session, m_mirrorTexture, &texId);
+ GL_CHECK(glGenFramebuffers(1, &m_mirrorFbo) );
+ GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, m_mirrorFbo) );
+ GL_CHECK(glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texId, 0) );
+ GL_CHECK(glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0) );
+ GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, 0) );
- GL_CHECK(glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, _msaaSamples, GL_DEPTH_COMPONENT, m_eyeTextureSize.w, m_eyeTextureSize.h, false) );
- GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT) );
- GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT) );
- GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR) );
- GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) );
- GL_CHECK(glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAX_LEVEL, 0) );
+ if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
+ {
+ GL_CHECK(glDeleteFramebuffers(1, &m_mirrorFbo) );
+ ovr_DestroyMirrorTexture(m_session, m_mirrorTexture);
+ m_mirrorTexture = NULL;
+ BX_CHECK(false, "Could not initialize VR mirror buffers!");
+ }
+ }
}
- }
-
- void OVRBufferGL::render(const ovrSession& _session)
- {
- // set the current eye texture in swap chain
- int curIndex;
- ovr_GetTextureSwapChainCurrentIndex(_session, m_textureSwapChain, &curIndex);
- ovr_GetTextureSwapChainBufferGL(_session, m_textureSwapChain, curIndex, &m_eyeTexId);
- if (0 != m_msaaEyeFbo)
- {
- GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_msaaEyeFbo) );
- GL_CHECK(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, m_msaaEyeTexId, 0) );
- GL_CHECK(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D_MULTISAMPLE, m_msaaDepthBuffer, 0) );
- }
- else // MSAA disabled? render directly to eye buffer
- {
- GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_eyeFbo) );
- GL_CHECK(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_eyeTexId, 0) );
- GL_CHECK(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_depthBuffer, 0) );
- }
- GL_CHECK(glViewport(0, 0, m_eyeTextureSize.w, m_eyeTextureSize.h) );
- GL_CHECK(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) );
+ return true;
}
- void OVRBufferGL::postRender(const ovrSession& /*_sesion*/)
+ void VRImplOVRGL::destroySwapChain()
{
- if (0 != m_msaaEyeFbo && 0 != m_eyeTexId)
+ for (int eye = 0; eye < 2; ++eye)
{
- // blit the contents of MSAA FBO to the regular eye buffer "connected" to the HMD
- GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, m_msaaEyeFbo));
- GL_CHECK(glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, m_msaaEyeTexId, 0) );
- GL_CHECK(glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0) );
-
- BX_CHECK(GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_READ_FRAMEBUFFER)
- , "glCheckFramebufferStatus failed 0x%08x"
- , glCheckFramebufferStatus(GL_READ_FRAMEBUFFER) );
-
- GL_CHECK(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_eyeFbo));
- GL_CHECK(glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_eyeTexId, 0) );
- GL_CHECK(glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0) );
-
- BX_CHECK(GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER)
- , "glCheckFramebufferStatus failed 0x%08x"
- , glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) );
+ if (NULL != m_textureSwapChain[eye])
+ {
+ GL_CHECK(glDeleteFramebuffers(1, &m_eyeFbo[eye]) );
+ GL_CHECK(glDeleteTextures(1, &m_depthBuffer[eye]) );
- GL_CHECK(glBlitFramebuffer(0, 0, m_eyeTextureSize.w, m_eyeTextureSize.h,
- 0, 0, m_eyeTextureSize.w, m_eyeTextureSize.h, GL_COLOR_BUFFER_BIT, GL_NEAREST) );
+ ovr_DestroyTextureSwapChain(m_session, m_textureSwapChain[eye]);
+ m_textureSwapChain[eye] = NULL;
- GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0) );
+ if (0 != m_msaaEyeFbo[eye])
+ {
+ GL_CHECK(glDeleteFramebuffers(1, &m_msaaEyeFbo[eye]) );
+ GL_CHECK(glDeleteTextures(1, &m_msaaEyeTexId[eye]) );
+ GL_CHECK(glDeleteTextures(1, &m_msaaDepthBuffer[eye]) );
+ m_msaaEyeFbo[eye] = 0;
+ }
+ }
}
+
+ destroyMirror();
}
- void OVRBufferGL::destroy(const ovrSession& _session)
+ void VRImplOVRGL::destroyMirror()
{
- GL_CHECK(glDeleteFramebuffers(1, &m_eyeFbo) );
- GL_CHECK(glDeleteTextures(1, &m_depthBuffer) );
-
- ovr_DestroyTextureSwapChain(_session, m_textureSwapChain);
-
- if (0 != m_msaaEyeFbo)
+ if (NULL != m_mirrorTexture)
{
- GL_CHECK(glDeleteFramebuffers(1, &m_msaaEyeFbo) );
- m_msaaEyeFbo = 0;
+ GL_CHECK(glDeleteFramebuffers(1, &m_mirrorFbo) );
+ ovr_DestroyMirrorTexture(m_session, m_mirrorTexture);
+ m_mirrorTexture = NULL;
}
+ }
- if (0 != m_msaaEyeTexId)
+ void VRImplOVRGL::renderEyeStart(const VRDesc& _desc, uint8_t _eye)
+ {
+ // set the current eye texture in the swap chain
+ if (0 != m_msaaEyeFbo[_eye])
{
- GL_CHECK(glDeleteTextures(1, &m_msaaEyeTexId));
- m_msaaEyeTexId = 0;
+ GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_msaaEyeFbo[_eye]) );
}
-
- if (0 != m_msaaDepthBuffer)
+ else
{
- GL_CHECK(glDeleteTextures(1, &m_msaaDepthBuffer));
- m_msaaDepthBuffer = 0;
+ int texIndex;
+ ovr_GetTextureSwapChainCurrentIndex(m_session, m_textureSwapChain[_eye], &texIndex);
+
+ GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_eyeFbo[_eye]) );
+ GL_CHECK(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_eyeTexId[_eye][texIndex], 0) );
}
+
+ GL_CHECK(glViewport(0, 0, _desc.m_eyeSize[_eye].m_w, _desc.m_eyeSize[_eye].m_h) );
+ GL_CHECK(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) );
}
- void OVRMirrorGL::create(const ovrSession& _session, int _width, int _height)
+ bool VRImplOVRGL::submitSwapChain(const VRDesc& _desc)
{
- memset(&m_mirrorTextureDesc, 0, sizeof(m_mirrorTextureDesc) );
- m_mirrorTextureDesc.Width = _width;
- m_mirrorTextureDesc.Height = _height;
- m_mirrorTextureDesc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB;
+ for (int eye = 0; eye < 2; ++eye)
+ {
+ if (0 != m_msaaEyeFbo[eye])
+ {
+ // blit the contents of MSAA FBO to the regulare eye buffer "connected" to the HMD
+ int destIndex;
+ ovr_GetTextureSwapChainCurrentIndex(m_session, m_textureSwapChain[eye], &destIndex);
- ovr_CreateMirrorTextureGL(_session, &m_mirrorTextureDesc, &m_mirrorTexture);
+ GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, m_msaaEyeFbo[eye]) );
+ BX_CHECK(GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_READ_FRAMEBUFFER)
+ , "glCheckFramebufferStatus failed 0x%08x"
+ , glCheckFramebufferStatus(GL_READ_FRAMEBUFFER)
+ );
- // Fallback to doing nothing if mirror was not created. This is to prevent errors with fast window resizes
- if (!m_mirrorTexture)
- return;
+ GL_CHECK(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_eyeFbo[eye]) );
+ GL_CHECK(glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_eyeTexId[eye][destIndex], 0) );
+ BX_CHECK(GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER)
+ , "glCheckFramebufferStatus failed 0x%08x"
+ , glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER)
+ );
- // Configure the mirror read buffer
- GLuint texId;
- ovr_GetMirrorTextureBufferGL(_session, m_mirrorTexture, &texId);
- GL_CHECK(glGenFramebuffers(1, &m_mirrorFBO) );
- GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, m_mirrorFBO) );
- GL_CHECK(glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texId, 0) );
- GL_CHECK(glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0) );
- GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, 0) );
+ GL_CHECK(glBlitFramebuffer(0, 0, _desc.m_eyeSize[eye].m_w, _desc.m_eyeSize[eye].m_h, 0, 0, _desc.m_eyeSize[eye].m_w, _desc.m_eyeSize[eye].m_h, GL_COLOR_BUFFER_BIT, GL_NEAREST) );
+ GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, 0) );
+ }
- if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
- {
- GL_CHECK(glDeleteFramebuffers(1, &m_mirrorFBO) );
- BX_CHECK(false, "Could not initialize VR buffers!");
+ ovrResult result = ovr_CommitTextureSwapChain(m_session, m_textureSwapChain[eye]);
+ if (!OVR_SUCCESS(result) )
+ {
+ return false;
+ }
}
- }
- void OVRMirrorGL::destroy(const ovrSession& _session)
- {
- if (NULL != m_mirrorTexture)
+ ovrLayerHeader* layerList = &m_renderLayer.Header;
+ ovrResult result = ovr_SubmitFrame(m_session, 0, &m_viewScale, &layerList, 1);
+ if (!OVR_SUCCESS(result) )
{
- GL_CHECK(glDeleteFramebuffers(1, &m_mirrorFBO) );
- ovr_DestroyMirrorTexture(_session, m_mirrorTexture);
- m_mirrorTexture = NULL;
+ return false;
}
- }
- void OVRMirrorGL::blit(const ovrSession& /*_session*/)
- {
- if (NULL != m_mirrorTexture)
+ if (result != ovrSuccess_NotVisible && NULL != m_mirrorTexture)
{
- // Blit mirror texture to back buffer
- GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, m_mirrorFBO) );
+ GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, m_mirrorFbo) );
GL_CHECK(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0) );
- GLint width = m_mirrorTextureDesc.Width;
- GLint height = m_mirrorTextureDesc.Height;
- GL_CHECK(glBlitFramebuffer(0, height, width, 0, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST) );
+ GL_CHECK(glBlitFramebuffer(0, m_mirrorHeight, m_mirrorWidth, 0, 0, 0, m_mirrorWidth, m_mirrorHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST) );
GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, 0) );
}
+
+ return true;
}
+
#endif // BGFX_CONFIG_USE_OVR
const char* glslTypeName(GLuint _type)
@@ -3689,6 +3763,7 @@ namespace bgfx { namespace gl
GLSL_TYPE(GL_UNSIGNED_INT_IMAGE_1D);
GLSL_TYPE(GL_IMAGE_2D);
+ GLSL_TYPE(GL_IMAGE_2D_ARRAY);
GLSL_TYPE(GL_INT_IMAGE_2D);
GLSL_TYPE(GL_UNSIGNED_INT_IMAGE_2D);
@@ -3786,6 +3861,7 @@ namespace bgfx { namespace gl
case GL_UNSIGNED_INT_IMAGE_1D:
case GL_IMAGE_2D:
+ case GL_IMAGE_2D_ARRAY:
case GL_INT_IMAGE_2D:
case GL_UNSIGNED_INT_IMAGE_2D:
@@ -4285,6 +4361,11 @@ namespace bgfx { namespace gl
, const GLvoid* _data
)
{
+ if (NULL == _data)
+ {
+ return;
+ }
+
if (_target == GL_TEXTURE_3D
|| _target == GL_TEXTURE_2D_ARRAY
|| _target == GL_TEXTURE_CUBE_MAP_ARRAY)
@@ -4355,7 +4436,19 @@ namespace bgfx { namespace gl
else if (_target == GL_TEXTURE_2D_ARRAY
|| _target == GL_TEXTURE_CUBE_MAP_ARRAY)
{
- texSubImage(_target, _level, 0, 0, _depth, _width, _height, 1, _format, _type, _data);
+ texSubImage(
+ _target
+ , _level
+ , 0
+ , 0
+ , _depth
+ , _width
+ , _height
+ , 1
+ , _format
+ , _type
+ , _data
+ );
}
else if (_target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)
{
@@ -5456,7 +5549,7 @@ namespace bgfx { namespace gl
if (!!bx::findIdentifierMatch(code, "gl_FragData") )
{
- for (uint32_t ii = 0, num = g_caps.maxFBAttachments; ii < num; ++ii)
+ for (uint32_t ii = 0, num = g_caps.limits.maxFBAttachments; ii < num; ++ii)
{
char tmpFragData[16];
bx::snprintf(tmpFragData, BX_COUNTOF(tmpFragData), "gl_FragData[%d]", ii);
@@ -5546,7 +5639,7 @@ namespace bgfx { namespace gl
if (!!bx::findIdentifierMatch(code, "gl_FragData") )
{
- for (uint32_t ii = 0, num = g_caps.maxFBAttachments; ii < num; ++ii)
+ for (uint32_t ii = 0, num = g_caps.limits.maxFBAttachments; ii < num; ++ii)
{
char tmpFragData[16];
bx::snprintf(tmpFragData, BX_COUNTOF(tmpFragData), "gl_FragData[%d]", ii);
@@ -5568,7 +5661,7 @@ namespace bgfx { namespace gl
}
}
- if (!!bx::findIdentifierMatch(code, s_ARB_texture_multisample))
+ if (!!bx::findIdentifierMatch(code, s_ARB_texture_multisample) )
{
writeString(&writer, "#extension GL_ARB_texture_multisample : enable\n");
}
@@ -5898,7 +5991,8 @@ namespace bgfx { namespace gl
uint32_t dsFlags = _flags & (BGFX_CLEAR_DISCARD_DEPTH|BGFX_CLEAR_DISCARD_STENCIL);
if (BGFX_CLEAR_NONE != dsFlags)
{
- if ( (BGFX_CLEAR_DISCARD_DEPTH|BGFX_CLEAR_DISCARD_STENCIL) == dsFlags)
+ if (!BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES)
+ && (BGFX_CLEAR_DISCARD_DEPTH|BGFX_CLEAR_DISCARD_STENCIL) == dsFlags)
{
buffers[idx++] = GL_DEPTH_STENCIL_ATTACHMENT;
}
@@ -6035,7 +6129,8 @@ namespace bgfx { namespace gl
_render->m_hmdInitialized = m_ovr.isInitialized();
const bool hmdEnabled = m_ovr.isEnabled();
- ViewState viewState(_render, hmdEnabled);
+ static ViewState viewState;
+ viewState.reset(_render, hmdEnabled);
uint16_t programIdx = invalidHandle;
SortKey key;
@@ -6055,11 +6150,17 @@ namespace bgfx { namespace gl
uint8_t primIndex;
{
- const uint64_t pt = _render->m_debug&BGFX_DEBUG_WIREFRAME ? BGFX_STATE_PT_LINES : 0;
+ const uint64_t pt = 0;
primIndex = uint8_t(pt>>BGFX_STATE_PT_SHIFT);
}
PrimInfo prim = s_primInfo[primIndex];
+ GL_CHECK(glPolygonMode(GL_FRONT_AND_BACK
+ , _render->m_debug&BGFX_DEBUG_WIREFRAME
+ ? GL_LINE
+ : GL_FILL
+ ) );
+
uint32_t baseVertex = 0;
GLuint currentVao = 0;
bool wasCompute = false;
@@ -6171,8 +6272,7 @@ namespace bgfx { namespace gl
if (m_ovr.isEnabled() )
{
- m_ovr.getViewport(eye, &viewState.m_rect);
- m_ovr.renderEyeStart(eye);
+ m_ovr.renderEyeStart(eye, &viewState.m_rect);
}
else
{
@@ -6291,7 +6391,7 @@ namespace bgfx { namespace gl
GL_CHECK(glBindImageTexture(ii
, texture.m_id
, bind.m_un.m_compute.m_mip
- , GL_FALSE
+ , texture.isCubeMap()?GL_TRUE:GL_FALSE
, 0
, s_access[bind.m_un.m_compute.m_access]
, s_imageFormat[bind.m_un.m_compute.m_format])
@@ -6349,7 +6449,7 @@ namespace bgfx { namespace gl
uintptr_t args = compute.m_startIndirect * BGFX_CONFIG_DRAW_INDIRECT_STRIDE;
for (uint32_t ii = 0; ii < numDrawIndirect; ++ii)
{
- GL_CHECK(glDispatchComputeIndirect((GLintptr)args) );
+ GL_CHECK(glDispatchComputeIndirect( (GLintptr)args) );
args += BGFX_CONFIG_DRAW_INDIRECT_STRIDE;
}
}
@@ -6560,38 +6660,39 @@ namespace bgfx { namespace gl
viewState.m_alphaRef = ref/255.0f;
}
-#if BGFX_CONFIG_RENDERER_OPENGL
- if ( (BGFX_STATE_PT_POINTS|BGFX_STATE_POINT_SIZE_MASK) & changedFlags)
+ if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
{
- float pointSize = (float)(bx::uint32_max(1, (newFlags&BGFX_STATE_POINT_SIZE_MASK)>>BGFX_STATE_POINT_SIZE_SHIFT) );
- GL_CHECK(glPointSize(pointSize) );
- }
+ if ( (BGFX_STATE_PT_POINTS|BGFX_STATE_POINT_SIZE_MASK) & changedFlags)
+ {
+ float pointSize = (float)(bx::uint32_max(1, (newFlags&BGFX_STATE_POINT_SIZE_MASK)>>BGFX_STATE_POINT_SIZE_SHIFT) );
+ GL_CHECK(glPointSize(pointSize) );
+ }
- if (BGFX_STATE_MSAA & changedFlags)
- {
- GL_CHECK(BGFX_STATE_MSAA & newFlags
- ? glEnable(GL_MULTISAMPLE)
- : glDisable(GL_MULTISAMPLE)
- );
- }
+ if (BGFX_STATE_MSAA & changedFlags)
+ {
+ GL_CHECK(BGFX_STATE_MSAA & newFlags
+ ? glEnable(GL_MULTISAMPLE)
+ : glDisable(GL_MULTISAMPLE)
+ );
+ }
- if (BGFX_STATE_LINEAA & changedFlags)
- {
- GL_CHECK(BGFX_STATE_LINEAA & newFlags
- ? glEnable(GL_LINE_SMOOTH)
- : glDisable(GL_LINE_SMOOTH)
- );
- }
+ if (BGFX_STATE_LINEAA & changedFlags)
+ {
+ GL_CHECK(BGFX_STATE_LINEAA & newFlags
+ ? glEnable(GL_LINE_SMOOTH)
+ : glDisable(GL_LINE_SMOOTH)
+ );
+ }
- if (m_conservativeRasterSupport
- && BGFX_STATE_CONSERVATIVE_RASTER & changedFlags)
- {
- GL_CHECK(BGFX_STATE_CONSERVATIVE_RASTER & newFlags
- ? glEnable(GL_CONSERVATIVE_RASTERIZATION_NV)
- : glDisable(GL_CONSERVATIVE_RASTERIZATION_NV)
- );
+ if (m_conservativeRasterSupport
+ && BGFX_STATE_CONSERVATIVE_RASTER & changedFlags)
+ {
+ GL_CHECK(BGFX_STATE_CONSERVATIVE_RASTER & newFlags
+ ? glEnable(GL_CONSERVATIVE_RASTERIZATION_NV)
+ : glDisable(GL_CONSERVATIVE_RASTERIZATION_NV)
+ );
+ }
}
-#endif // BGFX_CONFIG_RENDERER_OPENGL
if ( (BGFX_STATE_ALPHA_WRITE|BGFX_STATE_RGB_WRITE) & changedFlags)
{
@@ -6721,7 +6822,7 @@ namespace bgfx { namespace gl
blendFactor = draw.m_rgba;
}
- const uint64_t pt = _render->m_debug&BGFX_DEBUG_WIREFRAME ? BGFX_STATE_PT_LINES : newFlags&BGFX_STATE_PT_MASK;
+ const uint64_t pt = newFlags&BGFX_STATE_PT_MASK;
primIndex = uint8_t(pt>>BGFX_STATE_PT_SHIFT);
prim = s_primInfo[primIndex];
}
@@ -6778,25 +6879,28 @@ namespace bgfx { namespace gl
}
if (0 != defaultVao
- && 0 == draw.m_startVertex
+ && 0 == draw.m_stream[0].m_startVertex
&& 0 == draw.m_instanceDataOffset)
{
if (programChanged
- || baseVertex != draw.m_startVertex
- || currentState.m_vertexBuffer.idx != draw.m_vertexBuffer.idx
- || currentState.m_indexBuffer.idx != draw.m_indexBuffer.idx
- || currentState.m_instanceDataOffset != draw.m_instanceDataOffset
- || currentState.m_instanceDataStride != draw.m_instanceDataStride
+ || baseVertex != draw.m_stream[0].m_startVertex
+ || currentState.m_streamMask != draw.m_streamMask
+ || currentState.m_stream[0].m_handle.idx != draw.m_stream[0].m_handle.idx
+ || currentState.m_indexBuffer.idx != draw.m_indexBuffer.idx
+ || currentState.m_instanceDataOffset != draw.m_instanceDataOffset
+ || currentState.m_instanceDataStride != draw.m_instanceDataStride
|| currentState.m_instanceDataBuffer.idx != draw.m_instanceDataBuffer.idx)
{
bx::HashMurmur2A murmur;
murmur.begin();
- murmur.add(draw.m_vertexBuffer.idx);
- if (isValid(draw.m_vertexBuffer) )
+ const Stream& stream = draw.m_stream[0];
+ murmur.add(stream.m_handle.idx);
+
+ if (isValid(stream.m_handle) )
{
- const VertexBufferGL& vb = m_vertexBuffers[draw.m_vertexBuffer.idx];
- uint16_t decl = !isValid(vb.m_decl) ? draw.m_vertexDecl.idx : vb.m_decl.idx;
+ const VertexBufferGL& vb = m_vertexBuffers[stream.m_handle.idx];
+ uint16_t decl = !isValid(vb.m_decl) ? stream.m_decl.idx : vb.m_decl.idx;
murmur.add(decl);
}
@@ -6807,11 +6911,13 @@ namespace bgfx { namespace gl
murmur.add(programIdx);
uint32_t hash = murmur.end();
- currentState.m_vertexBuffer = draw.m_vertexBuffer;
+ currentState.m_streamMask = draw.m_streamMask;
+ currentState.m_stream[0].m_handle = stream.m_handle;
+ baseVertex = stream.m_startVertex;
+
currentState.m_indexBuffer = draw.m_indexBuffer;
currentState.m_instanceDataOffset = draw.m_instanceDataOffset;
currentState.m_instanceDataStride = draw.m_instanceDataStride;
- baseVertex = draw.m_startVertex;
GLuint id = m_vaoStateCache.find(hash);
if (UINT32_MAX != id)
@@ -6827,14 +6933,14 @@ namespace bgfx { namespace gl
program.add(hash);
- if (isValid(draw.m_vertexBuffer) )
+ if (isValid(stream.m_handle) )
{
- VertexBufferGL& vb = m_vertexBuffers[draw.m_vertexBuffer.idx];
+ VertexBufferGL& vb = m_vertexBuffers[stream.m_handle.idx];
vb.add(hash);
GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, vb.m_id) );
- uint16_t decl = !isValid(vb.m_decl) ? draw.m_vertexDecl.idx : vb.m_decl.idx;
- program.bindAttributes(m_vertexDecls[decl], draw.m_startVertex);
+ uint16_t decl = !isValid(vb.m_decl) ? stream.m_decl.idx : vb.m_decl.idx;
+ program.bindAttributes(m_vertexDecls[decl], stream.m_startVertex);
if (isValid(draw.m_instanceDataBuffer) )
{
@@ -6868,24 +6974,27 @@ namespace bgfx { namespace gl
&& 0 != currentVao)
{
GL_CHECK(glBindVertexArray(defaultVao) );
- currentState.m_vertexBuffer.idx = invalidHandle;
- currentState.m_indexBuffer.idx = invalidHandle;
+ currentState.m_streamMask = 0;
+ currentState.m_stream[0].m_handle.idx = invalidHandle;
+ currentState.m_indexBuffer.idx = invalidHandle;
bindAttribs = true;
currentVao = 0;
}
if (programChanged
- || currentState.m_vertexBuffer.idx != draw.m_vertexBuffer.idx
+ || currentState.m_streamMask != draw.m_streamMask
+ || currentState.m_stream[0].m_handle.idx != draw.m_stream[0].m_handle.idx
|| currentState.m_instanceDataBuffer.idx != draw.m_instanceDataBuffer.idx
- || currentState.m_instanceDataOffset != draw.m_instanceDataOffset
- || currentState.m_instanceDataStride != draw.m_instanceDataStride)
+ || currentState.m_instanceDataOffset != draw.m_instanceDataOffset
+ || currentState.m_instanceDataStride != draw.m_instanceDataStride)
{
- currentState.m_vertexBuffer = draw.m_vertexBuffer;
+ currentState.m_streamMask = draw.m_streamMask;
+ currentState.m_stream[0].m_handle = draw.m_stream[0].m_handle;
currentState.m_instanceDataBuffer.idx = draw.m_instanceDataBuffer.idx;
- currentState.m_instanceDataOffset = draw.m_instanceDataOffset;
- currentState.m_instanceDataStride = draw.m_instanceDataStride;
+ currentState.m_instanceDataOffset = draw.m_instanceDataOffset;
+ currentState.m_instanceDataStride = draw.m_instanceDataStride;
- uint16_t handle = draw.m_vertexBuffer.idx;
+ uint16_t handle = draw.m_stream[0].m_handle.idx;
if (invalidHandle != handle)
{
VertexBufferGL& vb = m_vertexBuffers[handle];
@@ -6914,15 +7023,15 @@ namespace bgfx { namespace gl
}
}
- if (isValid(currentState.m_vertexBuffer) )
+ if (0 != currentState.m_streamMask)
{
- if (baseVertex != draw.m_startVertex
+ if (baseVertex != draw.m_stream[0].m_startVertex
|| bindAttribs)
{
- baseVertex = draw.m_startVertex;
- const VertexBufferGL& vb = m_vertexBuffers[draw.m_vertexBuffer.idx];
- uint16_t decl = !isValid(vb.m_decl) ? draw.m_vertexDecl.idx : vb.m_decl.idx;
- program.bindAttributes(m_vertexDecls[decl], draw.m_startVertex);
+ baseVertex = draw.m_stream[0].m_startVertex;
+ const VertexBufferGL& vb = m_vertexBuffers[draw.m_stream[0].m_handle.idx];
+ uint16_t decl = !isValid(vb.m_decl) ? draw.m_stream[0].m_decl.idx : vb.m_decl.idx;
+ program.bindAttributes(m_vertexDecls[decl], draw.m_stream[0].m_startVertex);
if (isValid(draw.m_instanceDataBuffer) )
{
@@ -6933,13 +7042,13 @@ namespace bgfx { namespace gl
}
}
- if (isValid(currentState.m_vertexBuffer) )
+ if (0 != currentState.m_streamMask)
{
uint32_t numVertices = draw.m_numVertices;
if (UINT32_MAX == numVertices)
{
- const VertexBufferGL& vb = m_vertexBuffers[currentState.m_vertexBuffer.idx];
- uint16_t decl = !isValid(vb.m_decl) ? draw.m_vertexDecl.idx : vb.m_decl.idx;
+ const VertexBufferGL& vb = m_vertexBuffers[currentState.m_stream[0].m_handle.idx];
+ uint16_t decl = !isValid(vb.m_decl) ? draw.m_stream[0].m_decl.idx : vb.m_decl.idx;
const VertexDecl& vertexDecl = m_vertexDecls[decl];
numVertices = vb.m_size/vertexDecl.m_stride;
}
diff --git a/3rdparty/bgfx/src/renderer_gl.h b/3rdparty/bgfx/src/renderer_gl.h
index 9227d0e00cf..012f90d0fe5 100644
--- a/3rdparty/bgfx/src/renderer_gl.h
+++ b/3rdparty/bgfx/src/renderer_gl.h
@@ -107,7 +107,7 @@ typedef uint64_t GLuint64;
#endif // BGFX_CONFIG_RENDERER_OPENGL
#include "renderer.h"
-#include "hmd_ovr.h"
+#include "hmd.h"
#include "hmd_openvr.h"
#include "debug_renderdoc.h"
@@ -720,6 +720,10 @@ typedef uint64_t GLuint64;
# define GL_IMAGE_2D 0x904D
#endif // GL_IMAGE_2D
+#ifndef GL_IMAGE_2D_ARRAY
+# define GL_IMAGE_2D_ARRAY 0x9053
+#endif // GL_IMAGE_2D_ARRAY
+
#ifndef GL_IMAGE_3D
# define GL_IMAGE_3D 0x904E
#endif // GL_IMAGE_3D
@@ -915,6 +919,22 @@ typedef uint64_t GLuint64;
# define GL_DEBUG_SEVERITY_NOTIFICATION 0x826b
#endif // GL_DEBUG_SEVERITY_NOTIFICATION
+#ifndef GL_LINE
+# define GL_LINE 0x1B01
+#endif // GL_LINE
+
+#ifndef GL_FILL
+# define GL_FILL 0x1B02
+#endif // GL_FILL
+
+#ifndef GL_MULTISAMPLE
+# define GL_MULTISAMPLE 0x809D
+#endif // GL_MULTISAMPLE
+
+#ifndef GL_LINE_SMOOTH
+# define GL_LINE_SMOOTH 0x0B20
+#endif // GL_LINE_SMOOTH
+
#if BX_PLATFORM_NACL
# include "glcontext_ppapi.h"
#elif BX_PLATFORM_WINDOWS
@@ -950,32 +970,6 @@ namespace bgfx
namespace bgfx { namespace gl
{
-#if BGFX_CONFIG_USE_OVR
- struct OVRBufferGL : public OVRBufferI
- {
- virtual void create(const ovrSession& _session, int _eyeIdx, int _msaaSamples) BX_OVERRIDE;
- virtual void destroy(const ovrSession& _session) BX_OVERRIDE;
- virtual void render(const ovrSession& _session) BX_OVERRIDE;
- virtual void postRender(const ovrSession& _sesion) BX_OVERRIDE;
-
- GLuint m_eyeFbo;
- GLuint m_eyeTexId;
- GLuint m_depthBuffer;
- GLuint m_msaaEyeFbo;
- GLuint m_msaaEyeTexId;
- GLuint m_msaaDepthBuffer;
- };
-
- struct OVRMirrorGL : public OVRMirrorI
- {
- virtual void create(const ovrSession& _session, int _width, int _height) BX_OVERRIDE;
- virtual void destroy(const ovrSession& _session) BX_OVERRIDE;
- virtual void blit(const ovrSession& _session) BX_OVERRIDE;
-
- GLuint m_mirrorFBO;
- };
-#endif // BGFX_CONFIG_USE_OVR
-
void dumpExtensions(const char* _extensions);
const char* glEnumName(GLenum _enum);
diff --git a/3rdparty/bgfx/src/renderer_gnm.cpp b/3rdparty/bgfx/src/renderer_gnm.cpp
new file mode 100644
index 00000000000..66e7fd30504
--- /dev/null
+++ b/3rdparty/bgfx/src/renderer_gnm.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ */
+
+#include "bgfx_p.h"
+
+namespace bgfx
+{
+
+#define BGFX_DECLARE_EMBEDDED_SHADER(_name) \
+ extern const uint8_t* BX_CONCATENATE(_name, _pssl); \
+ extern const uint32_t BX_CONCATENATE(_name, _pssl_size); \
+ static const uint8_t BX_CONCATENATE(_name, _int_pssl)[] = { 0 }; \
+ const uint8_t* BX_CONCATENATE(_name, _pssl) = &BX_CONCATENATE(_name, _int_pssl)[0]; \
+ const uint32_t BX_CONCATENATE(_name, _pssl_size) = 1
+
+BGFX_DECLARE_EMBEDDED_SHADER(vs_debugfont);
+BGFX_DECLARE_EMBEDDED_SHADER(fs_debugfont);
+BGFX_DECLARE_EMBEDDED_SHADER(vs_clear);
+BGFX_DECLARE_EMBEDDED_SHADER(fs_clear0);
+BGFX_DECLARE_EMBEDDED_SHADER(fs_clear1);
+BGFX_DECLARE_EMBEDDED_SHADER(fs_clear2);
+BGFX_DECLARE_EMBEDDED_SHADER(fs_clear3);
+BGFX_DECLARE_EMBEDDED_SHADER(fs_clear4);
+BGFX_DECLARE_EMBEDDED_SHADER(fs_clear5);
+BGFX_DECLARE_EMBEDDED_SHADER(fs_clear6);
+BGFX_DECLARE_EMBEDDED_SHADER(fs_clear7);
+
+#undef BGFX_DECLARE_EMBEDDED_SHADER
+
+} // namespace bgfx
+
+namespace bgfx { namespace gnm
+{
+ RendererContextI* rendererCreate()
+ {
+ return NULL;
+ }
+
+ void rendererDestroy()
+ {
+ }
+} /* namespace gnm */ } // namespace bgfx
diff --git a/3rdparty/bgfx/src/renderer_mtl.h b/3rdparty/bgfx/src/renderer_mtl.h
index 00981372cd0..7936d1b4897 100644
--- a/3rdparty/bgfx/src/renderer_mtl.h
+++ b/3rdparty/bgfx/src/renderer_mtl.h
@@ -12,6 +12,7 @@
#import <QuartzCore/CAMetalLayer.h>
#import <Metal/Metal.h>
+#import <MetalKit/MetalKit.h>
#if BX_PLATFORM_IOS
# import <UIKit/UIKit.h>
diff --git a/3rdparty/bgfx/src/renderer_mtl.mm b/3rdparty/bgfx/src/renderer_mtl.mm
index d3721c9062d..b45b8a2fe8b 100644
--- a/3rdparty/bgfx/src/renderer_mtl.mm
+++ b/3rdparty/bgfx/src/renderer_mtl.mm
@@ -378,8 +378,16 @@ namespace bgfx { namespace mtl
memset(m_uniforms, 0, sizeof(m_uniforms) );
memset(&m_resolution, 0, sizeof(m_resolution) );
+ if (NULL != NSClassFromString(@"MTKView")) {
+ MTKView *view = (MTKView *)g_platformData.nwh;
+ if (NULL != view && [view isKindOfClass:NSClassFromString(@"MTKView")]) {
+ m_metalLayer = (CAMetalLayer *)view.layer;
+ }
+ }
+
if (NULL != NSClassFromString(@"CAMetalLayer") )
{
+ if (NULL == m_metalLayer)
#if BX_PLATFORM_IOS
{
CAMetalLayer* metalLayer = (CAMetalLayer*)g_platformData.nwh;
@@ -496,19 +504,19 @@ namespace bgfx { namespace mtl
{
if (iOSVersionEqualOrGreater("9.0.0") )
{
- g_caps.maxTextureSize = m_device.supportsFeatureSet((MTLFeatureSet)4 /* iOS_GPUFamily3_v1 */) ? 16384 : 8192;
+ g_caps.limits.maxTextureSize = m_device.supportsFeatureSet((MTLFeatureSet)4 /* iOS_GPUFamily3_v1 */) ? 16384 : 8192;
}
else
{
- g_caps.maxTextureSize = 4096;
+ g_caps.limits.maxTextureSize = 4096;
}
- g_caps.maxFBAttachments = uint8_t(bx::uint32_min(m_device.supportsFeatureSet((MTLFeatureSet)1 /* MTLFeatureSet_iOS_GPUFamily2_v1 */) ? 8 : 4, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS));
+ g_caps.limits.maxFBAttachments = uint8_t(bx::uint32_min(m_device.supportsFeatureSet((MTLFeatureSet)1 /* MTLFeatureSet_iOS_GPUFamily2_v1 */) ? 8 : 4, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS));
}
else if (BX_ENABLED(BX_PLATFORM_OSX) )
{
- g_caps.maxTextureSize = 16384;
- g_caps.maxFBAttachments = 8;
+ g_caps.limits.maxTextureSize = 16384;
+ g_caps.limits.maxFBAttachments = 8;
g_caps.supported |= BGFX_CAPS_TEXTURE_CUBE_ARRAY;
}
@@ -788,7 +796,7 @@ namespace bgfx { namespace mtl
{
}
- void readTexture(TextureHandle _handle, void* _data) BX_OVERRIDE
+ void readTexture(TextureHandle _handle, void* _data, uint8_t _mip) BX_OVERRIDE
{
m_commandBuffer.commit();
m_commandBuffer.waitUntilCompleted();
@@ -796,13 +804,15 @@ namespace bgfx { namespace mtl
const TextureMtl& texture = m_textures[_handle.idx];
- uint32_t width = texture.m_ptr.width();
- uint32_t height = texture.m_ptr.height();
+ BX_CHECK(_mip<texture.m_numMips,"Invalid mip: %d num mips:",_mip,texture.m_numMips);
+
+ uint32_t srcWidth = bx::uint32_max(1, texture.m_ptr.width() >> _mip);
+ uint32_t srcHeight = bx::uint32_max(1, texture.m_ptr.height() >> _mip);
const uint8_t bpp = getBitsPerPixel(TextureFormat::Enum(texture.m_textureFormat) );
- MTLRegion region = { { 0, 0, 0 }, { width, height, 1 } };
+ MTLRegion region = { { 0, 0, 0 }, { srcWidth, srcHeight, 1 } };
- texture.m_ptr.getBytes(_data, width*bpp/8, 0, region, 0, 0);
+ texture.m_ptr.getBytes(_data, srcWidth*bpp/8, 0, region, _mip, 0);
m_commandBuffer = m_commandQueue.commandBuffer();
retain(m_commandBuffer); //NOTE: keep alive to be useable at 'flip'
@@ -897,6 +907,7 @@ namespace bgfx { namespace mtl
{
BX_FREE(g_allocator, m_uniforms[_handle.idx]);
m_uniforms[_handle.idx] = NULL;
+ m_uniformReg.remove(_handle);
}
//cmdPre
@@ -970,8 +981,8 @@ namespace bgfx { namespace mtl
{
RenderCommandEncoder rce = m_renderCommandEncoder;
- uint32_t width = getBufferWidth();
- uint32_t height = getBufferHeight();
+ uint32_t width = m_resolution.m_width;
+ uint32_t height = m_resolution.m_height;
//if (m_ovr.isEnabled() )
//{
@@ -1260,7 +1271,7 @@ namespace bgfx { namespace mtl
RenderPassDescriptor renderPassDescriptor = newRenderPassDescriptor();
setFrameBuffer(renderPassDescriptor, m_renderCommandEncoderFrameBufferHandle);
- for(uint32_t ii = 0; ii < g_caps.maxFBAttachments; ++ii)
+ for(uint32_t ii = 0; ii < g_caps.limits.maxFBAttachments; ++ii)
{
MTLRenderPassColorAttachmentDescriptor* desc = renderPassDescriptor.colorAttachments[ii];
if ( desc.texture != NULL)
@@ -1413,8 +1424,8 @@ namespace bgfx { namespace mtl
}
else
{
- width = getBufferWidth();
- height = getBufferHeight();
+ width = m_resolution.m_width;
+ height = m_resolution.m_height;
}
@@ -1670,7 +1681,7 @@ namespace bgfx { namespace mtl
m_samplerDescriptor.lodMinClamp = 0;
m_samplerDescriptor.lodMaxClamp = FLT_MAX;
m_samplerDescriptor.normalizedCoordinates = TRUE;
- m_samplerDescriptor.maxAnisotropy = m_maxAnisotropy;
+ m_samplerDescriptor.maxAnisotropy = (0 != (_flags & (BGFX_TEXTURE_MIN_ANISOTROPIC|BGFX_TEXTURE_MAG_ANISOTROPIC) ) ) ? m_maxAnisotropy : 1;
//NOTE: Comparison function can be specified in shader on all metal hw.
if ( m_macOS11Runtime || [m_device supportsFeatureSet:(MTLFeatureSet)4/*MTLFeatureSet_iOS_GPUFamily3_v1*/])
@@ -1692,16 +1703,6 @@ namespace bgfx { namespace mtl
return _visible == (0 != _render->m_occlusion[_handle.idx]);
}
- uint32_t getBufferWidth()
- {
- return m_backBufferDepth.width();
- }
-
- uint32_t getBufferHeight()
- {
- return m_backBufferDepth.height();
- }
-
void sync()
{
if ( m_prevCommandBuffer )
@@ -2008,6 +2009,8 @@ namespace bgfx { namespace mtl
case MTLDataTypeFloat4x4:
return UniformType::Mat4;
+ default:
+ break;
};
BX_CHECK(false, "Unrecognized Mtl Data type 0x%04x.", _type);
@@ -2278,6 +2281,8 @@ namespace bgfx { namespace mtl
else
{
const UniformInfo* info = s_renderMtl->m_uniformReg.find(name);
+ BX_WARN(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
+
if (NULL != info)
{
if (NULL == constantBuffer)
@@ -2412,7 +2417,7 @@ namespace bgfx { namespace mtl
{
if (imageContainer.m_cubeMap)
{
- desc.textureType = MTLTextureTypeCubeArray;
+ desc.textureType = MTLTextureType(6); // MTLTextureTypeCubeArray
}
else
{
@@ -2684,6 +2689,8 @@ namespace bgfx { namespace mtl
void FrameBufferMtl::create(uint8_t _num, const Attachment* _attachment)
{
m_num = 0;
+ m_width = 0;
+ m_height = 0;
for (uint32_t ii = 0; ii < _num; ++ii)
{
TextureHandle handle = _attachment[ii].handle;
@@ -2691,6 +2698,12 @@ namespace bgfx { namespace mtl
{
const TextureMtl& texture = s_renderMtl->m_textures[handle.idx];
+ if ( 0 == m_width )
+ {
+ m_width = texture.m_width;
+ m_height = texture.m_height;
+ }
+
if (isDepth( (TextureFormat::Enum)texture.m_textureFormat) )
{
m_depthHandle = handle;
@@ -2931,7 +2944,8 @@ namespace bgfx { namespace mtl
_render->m_hmdInitialized = false;
const bool hmdEnabled = false;
- ViewState viewState(_render, hmdEnabled);
+ static ViewState viewState;
+ viewState.reset(_render, hmdEnabled);
uint32_t blendFactor = 0;
bool wireframe = !!(_render->m_debug&BGFX_DEBUG_WIREFRAME);
@@ -3090,15 +3104,8 @@ namespace bgfx { namespace mtl
viewScissorRect = viewHasScissor ? scissorRect : viewState.m_rect;
Clear& clr = _render->m_clear[view];
- uint32_t width = getBufferWidth();
- uint32_t height = getBufferHeight();
Rect viewRect = viewState.m_rect;
- bool clearWithRenderPass = true
- && 0 == viewRect.m_x
- && 0 == viewRect.m_y
- && width == viewRect.m_width
- && height == viewRect.m_height
- ;
+ bool clearWithRenderPass = false;
if ( NULL == m_renderCommandEncoder || fbh.idx != _render->m_fb[view].idx )
{
@@ -3111,11 +3118,29 @@ namespace bgfx { namespace mtl
renderPassDescriptor.visibilityResultBuffer = m_occlusionQuery.m_buffer;
fbh = _render->m_fb[view];
+
+ uint32_t width = m_resolution.m_width;
+ uint32_t height = m_resolution.m_height;
+
+ if ( isValid(fbh) )
+ {
+ FrameBufferMtl& frameBuffer = m_frameBuffers[fbh.idx];
+ width = frameBuffer.m_width;
+ height = frameBuffer.m_height;
+ }
+
+ clearWithRenderPass = true
+ && 0 == viewRect.m_x
+ && 0 == viewRect.m_y
+ && width == viewRect.m_width
+ && height == viewRect.m_height;
+
setFrameBuffer(renderPassDescriptor, fbh);
if ( clearWithRenderPass )
{
- for(uint32_t ii = 0; ii < g_caps.maxFBAttachments; ++ii)
+
+ for(uint32_t ii = 0; ii < g_caps.limits.maxFBAttachments; ++ii)
{
MTLRenderPassColorAttachmentDescriptor* desc = renderPassDescriptor.colorAttachments[ii];
@@ -3177,7 +3202,7 @@ namespace bgfx { namespace mtl
}
else
{
- for(uint32_t ii = 0; ii < g_caps.maxFBAttachments; ++ii)
+ for(uint32_t ii = 0; ii < g_caps.limits.maxFBAttachments; ++ii)
{
MTLRenderPassColorAttachmentDescriptor* desc = renderPassDescriptor.colorAttachments[ii];
if ( desc.texture != NULL)
@@ -3205,10 +3230,6 @@ namespace bgfx { namespace mtl
m_renderCommandEncoderFrameBufferHandle = fbh;
MTL_RELEASE(renderPassDescriptor);
}
- else
- {
- clearWithRenderPass = false;
- }
rce.setTriangleFillMode(wireframe? MTLTriangleFillModeLines : MTLTriangleFillModeFill);
@@ -3379,13 +3400,15 @@ namespace bgfx { namespace mtl
if (key.m_program != programIdx
|| (BGFX_STATE_BLEND_MASK|BGFX_STATE_BLEND_EQUATION_MASK|BGFX_STATE_ALPHA_WRITE|BGFX_STATE_RGB_WRITE|BGFX_STATE_BLEND_INDEPENDENT|BGFX_STATE_MSAA|BGFX_STATE_BLEND_ALPHA_TO_COVERAGE) & changedFlags
- || currentState.m_vertexBuffer.idx != draw.m_vertexBuffer.idx
- || currentState.m_vertexDecl.idx != draw.m_vertexDecl.idx
- || currentState.m_instanceDataStride != draw.m_instanceDataStride
+ || currentState.m_streamMask != draw.m_streamMask
+ || currentState.m_stream[0].m_handle.idx != draw.m_stream[0].m_handle.idx
+ || currentState.m_stream[0].m_decl.idx != draw.m_stream[0].m_decl.idx
+ || currentState.m_instanceDataStride != draw.m_instanceDataStride
|| ( (blendFactor != draw.m_rgba) && !!(newFlags & BGFX_STATE_BLEND_INDEPENDENT) ) )
{
programIdx = key.m_program;
- currentState.m_vertexDecl = draw.m_vertexDecl;
+ currentState.m_streamMask = draw.m_streamMask;
+ currentState.m_stream[0].m_decl = draw.m_stream[0].m_decl;
currentState.m_instanceDataStride = draw.m_instanceDataStride;
if (invalidHandle == programIdx)
@@ -3400,18 +3423,18 @@ namespace bgfx { namespace mtl
RenderPipelineState pipelineState = NULL;
- if ( isValid(draw.m_vertexBuffer) )
+ if (isValid(draw.m_stream[0].m_handle) )
{
- uint16_t handle = draw.m_vertexBuffer.idx;
+ uint16_t handle = draw.m_stream[0].m_handle.idx;
const VertexBufferMtl& vb = m_vertexBuffers[handle];
VertexDeclHandle decl;
- decl.idx = !isValid(vb.m_decl) ? draw.m_vertexDecl.idx : vb.m_decl.idx;
+ decl.idx = !isValid(vb.m_decl) ? draw.m_stream[0].m_decl.idx : vb.m_decl.idx;
pipelineState = program.getRenderPipelineState(newFlags, draw.m_rgba, fbh, decl, draw.m_instanceDataStride/16);
}
- if (NULL == pipelineState )
- { //call with invalid program
+ if (NULL == pipelineState)
+ {
currentProgram = NULL;
programIdx = invalidHandle;
continue;
@@ -3497,24 +3520,26 @@ namespace bgfx { namespace mtl
}
}
- if (currentState.m_vertexBuffer.idx != draw.m_vertexBuffer.idx
- || currentState.m_startVertex != draw.m_startVertex
- || currentState.m_instanceDataBuffer.idx != draw.m_instanceDataBuffer.idx
- || currentState.m_instanceDataOffset != draw.m_instanceDataOffset)
+ if (currentState.m_streamMask != draw.m_streamMask
+ || currentState.m_stream[0].m_handle.idx != draw.m_stream[0].m_handle.idx
+ || currentState.m_stream[0].m_startVertex != draw.m_stream[0].m_startVertex
+ || currentState.m_instanceDataBuffer.idx != draw.m_instanceDataBuffer.idx
+ || currentState.m_instanceDataOffset != draw.m_instanceDataOffset)
{
- currentState.m_vertexBuffer = draw.m_vertexBuffer;
- currentState.m_startVertex = draw.m_startVertex;
- currentState.m_instanceDataBuffer.idx = draw.m_instanceDataBuffer.idx;
- currentState.m_instanceDataOffset = draw.m_instanceDataOffset;
+ currentState.m_streamMask = draw.m_streamMask;
+ currentState.m_stream[0].m_handle = draw.m_stream[0].m_handle;
+ currentState.m_stream[0].m_startVertex = draw.m_stream[0].m_startVertex;
+ currentState.m_instanceDataBuffer.idx = draw.m_instanceDataBuffer.idx;
+ currentState.m_instanceDataOffset = draw.m_instanceDataOffset;
- uint16_t handle = draw.m_vertexBuffer.idx;
+ uint16_t handle = draw.m_stream[0].m_handle.idx;
if (invalidHandle != handle)
{
const VertexBufferMtl& vb = m_vertexBuffers[handle];
- uint16_t decl = !isValid(vb.m_decl) ? draw.m_vertexDecl.idx : vb.m_decl.idx;
+ uint16_t decl = !isValid(vb.m_decl) ? draw.m_stream[0].m_decl.idx : vb.m_decl.idx;
const VertexDecl& vertexDecl = m_vertexDecls[decl];
- uint32_t offset = draw.m_startVertex * vertexDecl.getStride();
+ uint32_t offset = draw.m_stream[0].m_startVertex * vertexDecl.getStride();
rce.setVertexBuffer(vb.getBuffer(), offset, 1);
@@ -3526,13 +3551,13 @@ namespace bgfx { namespace mtl
}
}
- if (isValid(currentState.m_vertexBuffer) )
+ if (0 != currentState.m_streamMask)
{
uint32_t numVertices = draw.m_numVertices;
if (UINT32_MAX == numVertices)
{
- const VertexBufferMtl& vb = m_vertexBuffers[currentState.m_vertexBuffer.idx];
- uint16_t decl = !isValid(vb.m_decl) ? draw.m_vertexDecl.idx : vb.m_decl.idx;
+ const VertexBufferMtl& vb = m_vertexBuffers[currentState.m_stream[0].m_handle.idx];
+ uint16_t decl = !isValid(vb.m_decl) ? draw.m_stream[0].m_decl.idx : vb.m_decl.idx;
const VertexDecl& vertexDecl = m_vertexDecls[decl];
numVertices = vb.m_size/vertexDecl.m_stride;
}
diff --git a/3rdparty/bgfx/src/renderer_null.cpp b/3rdparty/bgfx/src/renderer_noop.cpp
index 1dcd621759a..34a198d3aef 100644
--- a/3rdparty/bgfx/src/renderer_null.cpp
+++ b/3rdparty/bgfx/src/renderer_noop.cpp
@@ -5,28 +5,51 @@
#include "bgfx_p.h"
-#if BGFX_CONFIG_RENDERER_NULL
+#if BGFX_CONFIG_RENDERER_NOOP
namespace bgfx { namespace noop
{
- struct RendererContextNULL : public RendererContextI
+ struct RendererContextNOOP : public RendererContextI
{
- RendererContextNULL()
- {
- }
-
- ~RendererContextNULL()
+ RendererContextNOOP()
+ {
+ // Pretend all features that are not returning results to CPU
+ // are available.
+ g_caps.supported = 0
+ | BGFX_CAPS_TEXTURE_COMPARE_LEQUAL
+ | BGFX_CAPS_TEXTURE_COMPARE_ALL
+ | BGFX_CAPS_TEXTURE_3D
+ | BGFX_CAPS_VERTEX_ATTRIB_HALF
+ | BGFX_CAPS_VERTEX_ATTRIB_UINT10
+ | BGFX_CAPS_INSTANCING
+ | BGFX_CAPS_FRAGMENT_DEPTH
+ | BGFX_CAPS_BLEND_INDEPENDENT
+ | BGFX_CAPS_COMPUTE
+ | BGFX_CAPS_FRAGMENT_ORDERING
+ | BGFX_CAPS_SWAP_CHAIN
+ | BGFX_CAPS_INDEX32
+ | BGFX_CAPS_DRAW_INDIRECT
+ | BGFX_CAPS_HIDPI
+ | BGFX_CAPS_TEXTURE_BLIT
+ | BGFX_CAPS_ALPHA_TO_COVERAGE
+ | BGFX_CAPS_CONSERVATIVE_RASTER
+ | BGFX_CAPS_TEXTURE_2D_ARRAY
+ | BGFX_CAPS_TEXTURE_CUBE_ARRAY
+ ;
+ }
+
+ ~RendererContextNOOP()
{
}
RendererType::Enum getRendererType() const BX_OVERRIDE
{
- return RendererType::Null;
+ return RendererType::Noop;
}
const char* getRendererName() const BX_OVERRIDE
{
- return BGFX_RENDERER_NULL_NAME;
+ return BGFX_RENDERER_NOOP_NAME;
}
void flip(HMD& /*_hmd*/) BX_OVERRIDE
@@ -113,7 +136,7 @@ namespace bgfx { namespace noop
{
}
- void readTexture(TextureHandle /*_handle*/, void* /*_data*/) BX_OVERRIDE
+ void readTexture(TextureHandle /*_handle*/, void* /*_data*/, uint8_t /*_mip*/) BX_OVERRIDE
{
}
@@ -183,18 +206,18 @@ namespace bgfx { namespace noop
}
};
- static RendererContextNULL* s_renderNULL;
+ static RendererContextNOOP* s_renderNOOP;
RendererContextI* rendererCreate()
{
- s_renderNULL = BX_NEW(g_allocator, RendererContextNULL);
- return s_renderNULL;
+ s_renderNOOP = BX_NEW(g_allocator, RendererContextNOOP);
+ return s_renderNOOP;
}
void rendererDestroy()
{
- BX_DELETE(g_allocator, s_renderNULL);
- s_renderNULL = NULL;
+ BX_DELETE(g_allocator, s_renderNOOP);
+ s_renderNOOP = NULL;
}
} /* namespace noop */ } // namespace bgfx
@@ -212,4 +235,4 @@ namespace bgfx { namespace noop
}
} /* namespace noop */ } // namespace bgfx
-#endif // BGFX_CONFIG_RENDERER_NULL
+#endif // BGFX_CONFIG_RENDERER_NOOP
diff --git a/3rdparty/bgfx/src/renderer_vk.cpp b/3rdparty/bgfx/src/renderer_vk.cpp
index e885b84e58f..252cd2db5db 100644
--- a/3rdparty/bgfx/src/renderer_vk.cpp
+++ b/3rdparty/bgfx/src/renderer_vk.cpp
@@ -5,10 +5,6 @@
#include "bgfx_p.h"
-#if BGFX_CONFIG_RENDERER_VULKAN
-# include "../../bgfx-ext/src/renderer_vk1.cpp"
-#else
-
namespace bgfx { namespace vk
{
RendererContextI* rendererCreate()
@@ -20,5 +16,3 @@ namespace bgfx { namespace vk
{
}
} /* namespace vk */ } // namespace bgfx
-
-#endif // BGFX_CONFIG_RENDERER_VULKAN
diff --git a/3rdparty/bgfx/src/vertexdecl.cpp b/3rdparty/bgfx/src/vertexdecl.cpp
index d3945cd3226..49fb683c4d5 100644
--- a/3rdparty/bgfx/src/vertexdecl.cpp
+++ b/3rdparty/bgfx/src/vertexdecl.cpp
@@ -49,6 +49,7 @@ namespace bgfx
&s_attribTypeSizeDx9, // Direct3D9
&s_attribTypeSizeDx1x, // Direct3D11
&s_attribTypeSizeDx1x, // Direct3D12
+ &s_attribTypeSizeGl, // Gnm
&s_attribTypeSizeGl, // Metal
&s_attribTypeSizeGl, // OpenGLES
&s_attribTypeSizeGl, // OpenGL
diff --git a/3rdparty/bgfx/src/vs_clear.bin.h b/3rdparty/bgfx/src/vs_clear.bin.h
index e6a0b191cb9..46160b6bb76 100644
--- a/3rdparty/bgfx/src/vs_clear.bin.h
+++ b/3rdparty/bgfx/src/vs_clear.bin.h
@@ -12,20 +12,20 @@ static const uint8_t vs_clear_glsl[164] =
0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, // ion = tmpvar_1;.
0x7d, 0x0a, 0x0a, 0x00, // }...
};
-static const uint8_t vs_clear_dx9[181] =
+static const uint8_t vs_clear_dx9[185] =
{
- 0x56, 0x53, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x03, 0xfe, 0xff, // VSH.............
- 0xfe, 0xff, 0x16, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, // ....CTAB....#...
+ 0x56, 0x53, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x03, 0xfe, 0xff, // VSH.............
+ 0xfe, 0xff, 0x17, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, // ....CTAB....#...
0x00, 0x03, 0xfe, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, // ................
0x1c, 0x00, 0x00, 0x00, 0x76, 0x73, 0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, // ....vs_3_0.Micro
0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, // soft (R) HLSL Sh
- 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, // ader Compiler 9.
- 0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0x51, 0x00, 0x00, 0x05, // 29.952.3111.Q...
- 0x00, 0x00, 0x0f, 0xa0, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .......?........
- 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0x90, // ................
- 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0xe0, 0x04, 0x00, 0x00, 0x04, // ................
- 0x00, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0x24, 0x90, 0x00, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x15, 0xa0, // ......$...@.....
- 0xff, 0xff, 0x00, 0x00, 0x00, // .....
+ 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, // ader Compiler 10
+ 0x2e, 0x30, 0x2e, 0x31, 0x30, 0x30, 0x31, 0x31, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, 0xab, // .0.10011.16384..
+ 0x51, 0x00, 0x00, 0x05, 0x00, 0x00, 0x0f, 0xa0, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, // Q..........?....
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, // ................
+ 0x00, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0xe0, // ................
+ 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0x24, 0x90, 0x00, 0x00, 0x40, 0xa0, // ..........$...@.
+ 0x00, 0x00, 0x15, 0xa0, 0xff, 0xff, 0x00, 0x00, 0x00, // .........
};
static const uint8_t vs_clear_dx11[386] =
{
@@ -55,9 +55,9 @@ static const uint8_t vs_clear_dx11[386] =
0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x00, 0x01, 0x01, 0x00, // SV_POSITION.....
0x00, 0x00, // ..
};
-static const uint8_t vs_clear_mtl[500] =
+static const uint8_t vs_clear_mtl[504] =
{
- 0x56, 0x53, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe5, 0x01, 0x00, 0x00, 0x75, 0x73, // VSH...........us
+ 0x56, 0x53, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe9, 0x01, 0x00, 0x00, 0x75, 0x73, // VSH...........us
0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, // ing namespace me
0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, // tal;.struct xlat
0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, // MtlShaderInput {
@@ -81,12 +81,14 @@ static const uint8_t vs_clear_mtl[500] =
0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, // ]).{. xlatMtlSh
0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, // aderOutput _mtl_
0x6f, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, // o;. float4 tmpv
- 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, // ar_1;. tmpvar_1
- 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, // .w = 1.0;. tmpv
- 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, // ar_1.xyz = _mtl_
- 0x69, 0x2e, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, // i.a_position;.
- 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, // _mtl_o.gl_Positi
- 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, // on = tmpvar_1;.
- 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, // return _mtl_o;.
- 0x7d, 0x0a, 0x0a, 0x00, // }...
+ 0x61, 0x72, 0x5f, 0x31, 0x20, 0x3d, 0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, // ar_1 = 0;. tmpv
+ 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, // ar_1.w = 1.0;.
+ 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x5f, // tmpvar_1.xyz = _
+ 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, // mtl_i.a_position
+ 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, // ;. _mtl_o.gl_Po
+ 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // sition = tmpvar_
+ 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, 0x74, 0x6c, // 1;. return _mtl
+ 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // _o;.}...
};
+extern const uint8_t* vs_clear_pssl;
+extern const uint32_t vs_clear_pssl_size;
diff --git a/3rdparty/bgfx/src/vs_debugfont.bin.h b/3rdparty/bgfx/src/vs_debugfont.bin.h
index dd46d56c3a2..6d54586dab7 100644
--- a/3rdparty/bgfx/src/vs_debugfont.bin.h
+++ b/3rdparty/bgfx/src/vs_debugfont.bin.h
@@ -33,11 +33,11 @@ static const uint8_t vs_debugfont_glsl[503] =
0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x31, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, // color1 = a_color
0x31, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // 1;.}...
};
-static const uint8_t vs_debugfont_dx9[391] =
+static const uint8_t vs_debugfont_dx9[395] =
{
0x56, 0x53, 0x48, 0x04, 0xb8, 0xbe, 0x22, 0x66, 0x01, 0x00, 0x0f, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // VSH..."f...u_mod
0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x01, 0x00, 0x00, 0x04, 0x00, // elViewProj......
- 0x64, 0x01, 0x00, 0x03, 0xfe, 0xff, 0xfe, 0xff, 0x23, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, // d.......#.CTAB..
+ 0x68, 0x01, 0x00, 0x03, 0xfe, 0xff, 0xfe, 0xff, 0x24, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, // h.......$.CTAB..
0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfe, 0xff, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, // ..W.............
0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, // ......P...0.....
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, // ......@.......u_
@@ -45,21 +45,21 @@ static const uint8_t vs_debugfont_dx9[391] =
0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x73, // ..............vs
0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, // _3_0.Microsoft (
0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, // R) HLSL Shader C
- 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, // ompiler 9.29.952
- 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x80, 0x00, 0x00, // .3111...........
- 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x01, 0x80, 0x01, 0x00, 0x0f, 0x90, 0x1f, 0x00, // ................
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, // ................
- 0x00, 0x80, 0x03, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, // ................
- 0x0f, 0xe0, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x80, 0x01, 0x00, 0x0f, 0xe0, 0x1f, 0x00, // ................
- 0x00, 0x02, 0x0a, 0x00, 0x01, 0x80, 0x02, 0x00, 0x0f, 0xe0, 0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, // ................
- 0x00, 0x80, 0x03, 0x00, 0x03, 0xe0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80, 0x01, 0x00, // ................
- 0xe4, 0xa0, 0x02, 0x00, 0x55, 0x90, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, // ....U...........
- 0xe4, 0xa0, 0x02, 0x00, 0x00, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, // ................
- 0x0f, 0x80, 0x02, 0x00, 0xe4, 0xa0, 0x02, 0x00, 0xaa, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x02, 0x00, // ................
- 0x00, 0x03, 0x00, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0xe4, 0x80, 0x03, 0x00, 0xe4, 0xa0, 0x01, 0x00, // ................
- 0x00, 0x02, 0x01, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0xe4, 0x90, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, // ................
- 0x0f, 0xe0, 0x01, 0x00, 0xe4, 0x90, 0x01, 0x00, 0x00, 0x02, 0x03, 0x00, 0x03, 0xe0, 0x03, 0x00, // ................
- 0xe4, 0x90, 0xff, 0xff, 0x00, 0x00, 0x00, // .......
+ 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x30, 0x30, // ompiler 10.0.100
+ 0x31, 0x31, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, 0xab, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, // 11.16384........
+ 0x00, 0x80, 0x00, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x01, 0x80, 0x01, 0x00, // ................
+ 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x0f, 0x90, 0x1f, 0x00, // ................
+ 0x00, 0x02, 0x05, 0x00, 0x00, 0x80, 0x03, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, // ................
+ 0x00, 0x80, 0x00, 0x00, 0x0f, 0xe0, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x80, 0x01, 0x00, // ................
+ 0x0f, 0xe0, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x01, 0x80, 0x02, 0x00, 0x0f, 0xe0, 0x1f, 0x00, // ................
+ 0x00, 0x02, 0x05, 0x00, 0x00, 0x80, 0x03, 0x00, 0x03, 0xe0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, // ................
+ 0x0f, 0x80, 0x01, 0x00, 0xe4, 0xa0, 0x02, 0x00, 0x55, 0x90, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, // ........U.......
+ 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x02, 0x00, 0x00, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x04, 0x00, // ................
+ 0x00, 0x04, 0x00, 0x00, 0x0f, 0x80, 0x02, 0x00, 0xe4, 0xa0, 0x02, 0x00, 0xaa, 0x90, 0x00, 0x00, // ................
+ 0xe4, 0x80, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0xe4, 0x80, 0x03, 0x00, // ................
+ 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x01, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0xe4, 0x90, 0x01, 0x00, // ................
+ 0x00, 0x02, 0x02, 0x00, 0x0f, 0xe0, 0x01, 0x00, 0xe4, 0x90, 0x01, 0x00, 0x00, 0x02, 0x03, 0x00, // ................
+ 0x03, 0xe0, 0x03, 0x00, 0xe4, 0x90, 0xff, 0xff, 0x00, 0x00, 0x00, // ...........
};
static const uint8_t vs_debugfont_dx11[974] =
{
@@ -125,9 +125,9 @@ static const uint8_t vs_debugfont_dx11[974] =
0x4e, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, // N.COLOR.TEXCOORD
0x00, 0xab, 0x00, 0x04, 0x05, 0x00, 0x06, 0x00, 0x01, 0x00, 0x10, 0x00, 0x40, 0x00, // ............@.
};
-static const uint8_t vs_debugfont_mtl[843] =
+static const uint8_t vs_debugfont_mtl[847] =
{
- 0x56, 0x53, 0x48, 0x04, 0xb8, 0xbe, 0x22, 0x66, 0x00, 0x00, 0x3c, 0x03, 0x00, 0x00, 0x75, 0x73, // VSH..."f..<...us
+ 0x56, 0x53, 0x48, 0x04, 0xb8, 0xbe, 0x22, 0x66, 0x00, 0x00, 0x40, 0x03, 0x00, 0x00, 0x75, 0x73, // VSH..."f..@...us
0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, // ing namespace me
0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, // tal;.struct xlat
0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, // MtlShaderInput {
@@ -163,21 +163,23 @@ static const uint8_t vs_debugfont_mtl[843] =
0x66, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x78, 0x6c, // fer(0)]]).{. xl
0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, // atMtlShaderOutpu
0x74, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, // t _mtl_o;. floa
- 0x74, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, // t4 tmpvar_1;. t
- 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, // mpvar_1.w = 1.0;
- 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x79, 0x7a, 0x20, // . tmpvar_1.xyz
- 0x3d, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, // = _mtl_i.a_posit
- 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x67, 0x6c, // ion;. _mtl_o.gl
- 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x6d, 0x74, // _Position = (_mt
- 0x6c, 0x5f, 0x75, 0x2e, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, // l_u.u_modelViewP
- 0x72, 0x6f, 0x6a, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x29, 0x3b, // roj * tmpvar_1);
- 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, // . _mtl_o.v_texc
- 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x3d, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, // oord0 = _mtl_i.a
- 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, // _texcoord0;. _m
- 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x20, 0x3d, 0x20, // tl_o.v_color0 =
- 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, // _mtl_i.a_color0;
- 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // . _mtl_o.v_colo
- 0x72, 0x31, 0x20, 0x3d, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x63, 0x6f, // r1 = _mtl_i.a_co
- 0x6c, 0x6f, 0x72, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, // lor1;. return _
- 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // mtl_o;.}...
+ 0x74, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x20, 0x3d, 0x20, 0x30, 0x3b, // t4 tmpvar_1 = 0;
+ 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x77, 0x20, 0x3d, 0x20, // . tmpvar_1.w =
+ 0x31, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, // 1.0;. tmpvar_1.
+ 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x70, // xyz = _mtl_i.a_p
+ 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, // osition;. _mtl_
+ 0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, // o.gl_Position =
+ 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x2e, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, // (_mtl_u.u_modelV
+ 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // iewProj * tmpvar
+ 0x5f, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x76, 0x5f, // _1);. _mtl_o.v_
+ 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x3d, 0x20, 0x5f, 0x6d, 0x74, 0x6c, // texcoord0 = _mtl
+ 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, // _i.a_texcoord0;.
+ 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, // _mtl_o.v_color
+ 0x30, 0x20, 0x3d, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x63, 0x6f, 0x6c, // 0 = _mtl_i.a_col
+ 0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x76, 0x5f, // or0;. _mtl_o.v_
+ 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x31, 0x20, 0x3d, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, // color1 = _mtl_i.
+ 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, // a_color1;. retu
+ 0x72, 0x6e, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // rn _mtl_o;.}...
};
+extern const uint8_t* vs_debugfont_pssl;
+extern const uint32_t vs_debugfont_pssl_size;