summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/src
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bgfx/src')
-rw-r--r--3rdparty/bgfx/src/amalgamated.cpp12
-rw-r--r--3rdparty/bgfx/src/amalgamated.mm2
-rw-r--r--3rdparty/bgfx/src/bgfx.cpp1773
-rw-r--r--3rdparty/bgfx/src/bgfx.idl.inl1395
-rw-r--r--3rdparty/bgfx/src/bgfx_compute.sh41
-rw-r--r--3rdparty/bgfx/src/bgfx_p.h989
-rw-r--r--3rdparty/bgfx/src/bgfx_shader.sh126
-rw-r--r--3rdparty/bgfx/src/charset.h2
-rw-r--r--3rdparty/bgfx/src/config.h71
-rw-r--r--3rdparty/bgfx/src/debug_renderdoc.cpp2
-rw-r--r--3rdparty/bgfx/src/debug_renderdoc.h2
-rw-r--r--3rdparty/bgfx/src/dxgi.cpp2
-rw-r--r--3rdparty/bgfx/src/dxgi.h2
-rw-r--r--3rdparty/bgfx/src/fs_clear0.bin.h85
-rw-r--r--3rdparty/bgfx/src/fs_clear0.sc2
-rw-r--r--3rdparty/bgfx/src/fs_clear1.bin.h101
-rw-r--r--3rdparty/bgfx/src/fs_clear1.sc2
-rw-r--r--3rdparty/bgfx/src/fs_clear2.bin.h117
-rw-r--r--3rdparty/bgfx/src/fs_clear2.sc2
-rw-r--r--3rdparty/bgfx/src/fs_clear3.bin.h133
-rw-r--r--3rdparty/bgfx/src/fs_clear3.sc2
-rw-r--r--3rdparty/bgfx/src/fs_clear4.bin.h149
-rw-r--r--3rdparty/bgfx/src/fs_clear4.sc2
-rw-r--r--3rdparty/bgfx/src/fs_clear5.bin.h165
-rw-r--r--3rdparty/bgfx/src/fs_clear5.sc2
-rw-r--r--3rdparty/bgfx/src/fs_clear6.bin.h181
-rw-r--r--3rdparty/bgfx/src/fs_clear6.sc2
-rw-r--r--3rdparty/bgfx/src/fs_clear7.bin.h197
-rw-r--r--3rdparty/bgfx/src/fs_clear7.sc2
-rw-r--r--3rdparty/bgfx/src/fs_debugfont.bin.h138
-rw-r--r--3rdparty/bgfx/src/fs_debugfont.sc2
-rw-r--r--3rdparty/bgfx/src/glcontext_eagl.h2
-rw-r--r--3rdparty/bgfx/src/glcontext_eagl.mm19
-rw-r--r--3rdparty/bgfx/src/glcontext_egl.cpp84
-rw-r--r--3rdparty/bgfx/src/glcontext_egl.h2
-rw-r--r--3rdparty/bgfx/src/glcontext_glx.cpp12
-rw-r--r--3rdparty/bgfx/src/glcontext_glx.h2
-rw-r--r--3rdparty/bgfx/src/glcontext_html5.cpp199
-rw-r--r--3rdparty/bgfx/src/glcontext_html5.h47
-rw-r--r--3rdparty/bgfx/src/glcontext_nsgl.h2
-rw-r--r--3rdparty/bgfx/src/glcontext_nsgl.mm28
-rw-r--r--3rdparty/bgfx/src/glcontext_wgl.cpp4
-rw-r--r--3rdparty/bgfx/src/glcontext_wgl.h2
-rw-r--r--3rdparty/bgfx/src/glimports.h10
-rw-r--r--3rdparty/bgfx/src/makefile2
-rw-r--r--3rdparty/bgfx/src/nvapi.cpp2
-rw-r--r--3rdparty/bgfx/src/nvapi.h2
-rw-r--r--3rdparty/bgfx/src/renderer.h121
-rw-r--r--3rdparty/bgfx/src/renderer_d3d.h30
-rw-r--r--3rdparty/bgfx/src/renderer_d3d11.cpp617
-rw-r--r--3rdparty/bgfx/src/renderer_d3d11.h60
-rw-r--r--3rdparty/bgfx/src/renderer_d3d12.cpp802
-rw-r--r--3rdparty/bgfx/src/renderer_d3d12.h29
-rw-r--r--3rdparty/bgfx/src/renderer_d3d9.cpp375
-rw-r--r--3rdparty/bgfx/src/renderer_d3d9.h24
-rw-r--r--3rdparty/bgfx/src/renderer_gl.cpp744
-rw-r--r--3rdparty/bgfx/src/renderer_gl.h55
-rw-r--r--3rdparty/bgfx/src/renderer_gnm.cpp2
-rw-r--r--3rdparty/bgfx/src/renderer_mtl.h227
-rw-r--r--3rdparty/bgfx/src/renderer_mtl.mm2024
-rw-r--r--3rdparty/bgfx/src/renderer_noop.cpp14
-rw-r--r--3rdparty/bgfx/src/renderer_nvn.cpp45
-rw-r--r--3rdparty/bgfx/src/renderer_vk.cpp4039
-rw-r--r--3rdparty/bgfx/src/renderer_vk.h333
-rw-r--r--3rdparty/bgfx/src/shader.cpp2
-rw-r--r--3rdparty/bgfx/src/shader.h2
-rw-r--r--3rdparty/bgfx/src/shader_dx9bc.cpp2
-rw-r--r--3rdparty/bgfx/src/shader_dx9bc.h2
-rw-r--r--3rdparty/bgfx/src/shader_dxbc.cpp6
-rw-r--r--3rdparty/bgfx/src/shader_dxbc.h2
-rw-r--r--3rdparty/bgfx/src/shader_spirv.cpp2
-rw-r--r--3rdparty/bgfx/src/shader_spirv.h2
-rw-r--r--3rdparty/bgfx/src/topology.cpp23
-rw-r--r--3rdparty/bgfx/src/topology.h2
-rw-r--r--3rdparty/bgfx/src/vertexdecl.cpp99
-rw-r--r--3rdparty/bgfx/src/vertexdecl.h6
-rw-r--r--3rdparty/bgfx/src/vs_clear.bin.h270
-rw-r--r--3rdparty/bgfx/src/vs_clear.sc6
-rw-r--r--3rdparty/bgfx/src/vs_debugfont.bin.h184
-rw-r--r--3rdparty/bgfx/src/vs_debugfont.sc2
80 files changed, 10150 insertions, 6125 deletions
diff --git a/3rdparty/bgfx/src/amalgamated.cpp b/3rdparty/bgfx/src/amalgamated.cpp
index 6e6ebec7c85..77bf62c2fed 100644
--- a/3rdparty/bgfx/src/amalgamated.cpp
+++ b/3rdparty/bgfx/src/amalgamated.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -9,16 +9,18 @@
#include "glcontext_egl.cpp"
#include "glcontext_glx.cpp"
#include "glcontext_wgl.cpp"
+#include "glcontext_html5.cpp"
#include "nvapi.cpp"
-#include "renderer_d3d9.cpp"
#include "renderer_d3d11.cpp"
#include "renderer_d3d12.cpp"
-#include "renderer_noop.cpp"
+#include "renderer_d3d9.cpp"
#include "renderer_gl.cpp"
-#include "renderer_vk.cpp"
#include "renderer_gnm.cpp"
-#include "shader_dxbc.cpp"
+#include "renderer_noop.cpp"
+#include "renderer_nvn.cpp"
+#include "renderer_vk.cpp"
#include "shader_dx9bc.cpp"
+#include "shader_dxbc.cpp"
#include "shader_spirv.cpp"
#include "topology.cpp"
#include "vertexdecl.cpp"
diff --git a/3rdparty/bgfx/src/amalgamated.mm b/3rdparty/bgfx/src/amalgamated.mm
index 8d1ce6416ac..c280f456703 100644
--- a/3rdparty/bgfx/src/amalgamated.mm
+++ b/3rdparty/bgfx/src/amalgamated.mm
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/bgfx.cpp b/3rdparty/bgfx/src/bgfx.cpp
index 5b58c5f55f0..7d8734bea5b 100644
--- a/3rdparty/bgfx/src/bgfx.cpp
+++ b/3rdparty/bgfx/src/bgfx.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -12,6 +12,10 @@
#include "topology.h"
+#if BX_PLATFORM_OSX || BX_PLATFORM_IOS
+# include <objc/message.h>
+#endif // BX_PLATFORM_OSX
+
BX_ERROR_RESULT(BGFX_ERROR_TEXTURE_VALIDATION, BX_MAKEFOURCC('b', 'g', 0, 1) );
namespace bgfx
@@ -22,7 +26,11 @@ namespace bgfx
# define BGFX_CHECK_API_THREAD() \
BX_CHECK(NULL != s_ctx, "Library is not initialized yet."); \
BX_CHECK(BGFX_API_THREAD_MAGIC == s_threadIndex, "Must be called from main thread.")
-# define BGFX_CHECK_RENDER_THREAD() BX_CHECK(~BGFX_API_THREAD_MAGIC == s_threadIndex, "Must be called from render thread.")
+# define BGFX_CHECK_RENDER_THREAD() \
+ BX_CHECK( (NULL != s_ctx && s_ctx->m_singleThreaded) \
+ || ~BGFX_API_THREAD_MAGIC == s_threadIndex \
+ , "Must be called from render thread." \
+ )
#else
# define BGFX_CHECK_API_THREAD()
# define BGFX_CHECK_RENDER_THREAD()
@@ -293,6 +301,21 @@ namespace bgfx
PlatformData g_platformData;
bool g_platformDataChangedSinceReset = false;
+ const char* getTypeName(Handle _handle)
+ {
+ switch (_handle.type)
+ {
+ case Handle::IndexBuffer: return "IB";
+ case Handle::Shader: return "S";
+ case Handle::Texture: return "T";
+ case Handle::VertexBuffer: return "VB";
+ default: break;
+ }
+
+ BX_CHECK(false, "You should not be here.");
+ return "?";
+ }
+
void AllocatorStub::checkLeaks()
{
#if BGFX_CONFIG_MEMORY_TRACKING
@@ -323,7 +346,6 @@ namespace bgfx
const InternalData* getInternalData()
{
- BGFX_CHECK_RENDER_THREAD();
return &g_internalData;
}
@@ -341,7 +363,7 @@ namespace bgfx
return rci->getInternal(_handle);
}
- uintptr_t overrideInternal(TextureHandle _handle, uint16_t _width, uint16_t _height, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags)
+ uintptr_t overrideInternal(TextureHandle _handle, uint16_t _width, uint16_t _height, uint8_t _numMips, TextureFormat::Enum _format, uint64_t _flags)
{
BGFX_CHECK_RENDER_THREAD();
RendererContextI* rci = s_ctx->m_renderCtx;
@@ -488,25 +510,25 @@ namespace bgfx
return handle;
}
- void dump(const VertexDecl& _decl)
+ void dump(const VertexLayout& _layout)
{
if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
{
- BX_TRACE("vertexdecl %08x (%08x), stride %d"
- , _decl.m_hash
- , bx::hash<bx::HashMurmur2A>(_decl.m_attributes)
- , _decl.m_stride
+ BX_TRACE("vertexlayout %08x (%08x), stride %d"
+ , _layout.m_hash
+ , bx::hash<bx::HashMurmur2A>(_layout.m_attributes)
+ , _layout.m_stride
);
for (uint32_t attr = 0; attr < Attrib::Count; ++attr)
{
- if (UINT16_MAX != _decl.m_attributes[attr])
+ if (UINT16_MAX != _layout.m_attributes[attr])
{
uint8_t num;
AttribType::Enum type;
bool normalized;
bool asInt;
- _decl.decode(Attrib::Enum(attr), num, type, normalized, asInt);
+ _layout.decode(Attrib::Enum(attr), num, type, normalized, asInt);
BX_TRACE("\tattr %d - %s, num %d, type %d, norm %d, asint %d, offset %d"
, attr
@@ -515,7 +537,7 @@ namespace bgfx
, type
, normalized
, asInt
- , _decl.m_offset[attr]
+ , _layout.m_offset[attr]
);
}
}
@@ -625,7 +647,7 @@ namespace bgfx
void TextVideoMemBlitter::init()
{
BGFX_CHECK_API_THREAD();
- m_decl
+ m_layout
.begin()
.add(Attrib::Position, 3, AttribType::Float)
.add(Attrib::Color0, 4, AttribType::Uint8, true)
@@ -658,7 +680,7 @@ namespace bgfx
m_program = createProgram(vsh, fsh, true);
- m_vb = s_ctx->createTransientVertexBuffer(numBatchVertices*m_decl.m_stride, &m_decl);
+ m_vb = s_ctx->createTransientVertexBuffer(numBatchVertices*m_layout.m_stride, &m_layout);
m_ib = s_ctx->createTransientIndexBuffer(numBatchIndices*2);
}
@@ -740,7 +762,9 @@ namespace bgfx
uint32_t ch = line->character;
uint8_t attr = line->attribute;
if (ch > 0xff)
- ch = 0; // todo: render unicode code point , ch > 255)
+ {
+ ch = 0;
+ }
if (0 != (ch|attr)
&& (' ' != ch || 0 != (attr&0xf0) ) )
@@ -791,9 +815,9 @@ namespace bgfx
if (RendererType::Noop != g_caps.rendererType)
{
- m_decl
+ m_layout
.begin()
- .add(Attrib::Position, 3, AttribType::Float)
+ .add(Attrib::Position, 2, AttribType::Float)
.end();
ShaderHandle vsh = createEmbeddedShader(s_embeddedShaders, g_caps.rendererType, "vs_clear");
@@ -811,7 +835,30 @@ namespace bgfx
destroy(vsh);
- m_vb = s_ctx->createTransientVertexBuffer(4*m_decl.m_stride, &m_decl);
+ struct Vertex
+ {
+ float m_x;
+ float m_y;
+ };
+
+ const uint16_t stride = m_layout.m_stride;
+ const bgfx::Memory* mem = bgfx::alloc(4 * stride);
+ Vertex* vertex = (Vertex*)mem->data;
+ BX_CHECK(stride == sizeof(Vertex), "Stride/Vertex mismatch (stride %d, sizeof(Vertex) %d)", stride, sizeof(Vertex));
+
+ vertex->m_x = -1.0f;
+ vertex->m_y = -1.0f;
+ vertex++;
+ vertex->m_x = 1.0f;
+ vertex->m_y = -1.0f;
+ vertex++;
+ vertex->m_x = -1.0f;
+ vertex->m_y = 1.0f;
+ vertex++;
+ vertex->m_x = 1.0f;
+ vertex->m_y = 1.0f;
+
+ m_vb = s_ctx->createVertexBuffer(mem, m_layout, 0);
}
}
@@ -830,13 +877,13 @@ namespace bgfx
}
}
- s_ctx->destroyTransientVertexBuffer(m_vb);
+ s_ctx->destroyVertexBuffer(m_vb);
}
}
const char* s_uniformTypeName[] =
{
- "int1",
+ "sampler1",
NULL,
"vec4",
"mat3",
@@ -1162,9 +1209,9 @@ namespace bgfx
UniformBuffer* uniformBuffer = m_frame->m_uniformBuffer[m_uniformIdx];
m_uniformEnd = uniformBuffer->getPos();
- m_key.m_program = kInvalidHandle == _program.idx
- ? 0
- : _program.idx
+ m_key.m_program = isValid(_program)
+ ? _program
+ : ProgramHandle{0}
;
m_key.m_view = _id;
@@ -1190,11 +1237,12 @@ namespace bgfx
if (UINT8_MAX != m_draw.m_streamMask)
{
uint32_t numVertices = UINT32_MAX;
- for (uint32_t idx = 0, streamMask = m_draw.m_streamMask, ntz = bx::uint32_cnttz(streamMask)
+ for (uint32_t idx = 0, streamMask = m_draw.m_streamMask
; 0 != streamMask
- ; streamMask >>= 1, idx += 1, ntz = bx::uint32_cnttz(streamMask)
+ ; streamMask >>= 1, idx += 1
)
{
+ const uint32_t ntz = bx::uint32_cnttz(streamMask);
streamMask >>= ntz;
idx += ntz;
numVertices = bx::min(numVertices, m_numVertices[idx]);
@@ -1224,7 +1272,7 @@ namespace bgfx
}
}
- void EncoderImpl::dispatch(ViewId _id, ProgramHandle _handle, uint32_t _numX, uint32_t _numY, uint32_t _numZ, uint8_t _flags)
+ void EncoderImpl::dispatch(ViewId _id, ProgramHandle _handle, uint32_t _numX, uint32_t _numY, uint32_t _numZ)
{
if (BX_ENABLED(BGFX_CONFIG_DEBUG_UNIFORM) )
{
@@ -1255,9 +1303,8 @@ namespace bgfx
m_compute.m_numX = bx::max(_numX, 1u);
m_compute.m_numY = bx::max(_numY, 1u);
m_compute.m_numZ = bx::max(_numZ, 1u);
- m_compute.m_submitFlags = _flags;
- m_key.m_program = _handle.idx;
+ m_key.m_program = _handle;
m_key.m_depth = 0;
m_key.m_view = _id;
m_key.m_seq = s_ctx->getSeqIncr(_id);
@@ -1474,30 +1521,30 @@ namespace bgfx
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);
+ BX_TRACE("\t View %016" PRIx64, kSortKeyViewMask);
+ BX_TRACE("\t Draw bit %016" PRIx64, kSortKeyDrawBit);
BX_TRACE("");
- BX_TRACE("\tD Type %016" PRIx64, SORT_KEY_DRAW_TYPE_MASK);
+ BX_TRACE("\tD Type %016" PRIx64, kSortKeyDrawTypeMask);
BX_TRACE("");
- BX_TRACE("\tD0 Trans %016" PRIx64, SORT_KEY_DRAW_0_TRANS_MASK);
- BX_TRACE("\tD0 Program %016" PRIx64, SORT_KEY_DRAW_0_PROGRAM_MASK);
- BX_TRACE("\tD0 Depth %016" PRIx64, SORT_KEY_DRAW_0_DEPTH_MASK);
+ BX_TRACE("\tD0 Trans %016" PRIx64, kSortKeyDraw0TransMask);
+ BX_TRACE("\tD0 Program %016" PRIx64, kSortKeyDraw0ProgramMask);
+ BX_TRACE("\tD0 Depth %016" PRIx64, kSortKeyDraw0DepthMask);
BX_TRACE("");
- BX_TRACE("\tD1 Depth %016" PRIx64, SORT_KEY_DRAW_1_DEPTH_MASK);
- BX_TRACE("\tD1 Trans %016" PRIx64, SORT_KEY_DRAW_1_TRANS_MASK);
- BX_TRACE("\tD1 Program %016" PRIx64, SORT_KEY_DRAW_1_PROGRAM_MASK);
+ BX_TRACE("\tD1 Depth %016" PRIx64, kSortKeyDraw1DepthMask);
+ BX_TRACE("\tD1 Trans %016" PRIx64, kSortKeyDraw1TransMask);
+ BX_TRACE("\tD1 Program %016" PRIx64, kSortKeyDraw1ProgramMask);
BX_TRACE("");
- BX_TRACE("\tD2 Seq %016" PRIx64, SORT_KEY_DRAW_2_SEQ_MASK);
- BX_TRACE("\tD2 Trans %016" PRIx64, SORT_KEY_DRAW_2_TRANS_MASK);
- BX_TRACE("\tD2 Program %016" PRIx64, SORT_KEY_DRAW_2_PROGRAM_MASK);
+ BX_TRACE("\tD2 Seq %016" PRIx64, kSortKeyDraw2SeqMask);
+ BX_TRACE("\tD2 Trans %016" PRIx64, kSortKeyDraw2TransMask);
+ BX_TRACE("\tD2 Program %016" PRIx64, kSortKeyDraw2ProgramMask);
BX_TRACE("");
- BX_TRACE("\t C Seq %016" PRIx64, SORT_KEY_COMPUTE_SEQ_MASK);
- BX_TRACE("\t C Program %016" PRIx64, SORT_KEY_COMPUTE_PROGRAM_MASK);
+ BX_TRACE("\t C Seq %016" PRIx64, kSortKeyComputeSeqMask);
+ BX_TRACE("\t C Program %016" PRIx64, kSortKeyComputeProgramMask);
BX_TRACE("");
BX_TRACE("Supported capabilities (renderer %s, vendor 0x%04x, device 0x%04x):"
@@ -1528,7 +1575,7 @@ namespace bgfx
LIMITS(maxTextures);
LIMITS(maxTextureSamplers);
LIMITS(maxComputeBindings);
- LIMITS(maxVertexDecls);
+ LIMITS(maxVertexLayouts);
LIMITS(maxVertexStreams);
LIMITS(maxIndexBuffers);
LIMITS(maxVertexBuffers);
@@ -1770,7 +1817,7 @@ namespace bgfx
m_clearColor[ii][3] = 1.0f;
}
- m_declRef.init();
+ m_vertexLayoutRef.init();
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::RendererInit);
cmdbuf.write(_init);
@@ -1799,7 +1846,7 @@ namespace bgfx
getCommandBuffer(CommandBuffer::RendererShutdownEnd);
frame();
frame();
- m_declRef.shutdown(m_vertexDeclHandle);
+ m_vertexLayoutRef.shutdown(m_layoutHandle);
m_submit->destroy();
#if BGFX_CONFIG_MULTITHREADED
m_render->destroy();
@@ -1870,7 +1917,7 @@ namespace bgfx
frame();
}
- frame(); // If any VertexDecls needs to be destroyed.
+ frame(); // If any VertexLayouts needs to be destroyed.
getCommandBuffer(CommandBuffer::RendererShutdownEnd);
frame();
@@ -1890,13 +1937,13 @@ namespace bgfx
m_dynVertexBufferAllocator.compact();
m_dynIndexBufferAllocator.compact();
- 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.getNumElements()
+ BX_CHECK(m_layoutHandle.getNumHandles() == m_vertexLayoutRef.m_layoutMap.getNumElements()
+ , "VertexLayoutRef mismatch, num handles %d, handles in hash map %d."
+ , m_layoutHandle.getNumHandles()
+ , m_vertexLayoutRef.m_layoutMap.getNumElements()
);
- m_declRef.shutdown(m_vertexDeclHandle);
+ m_vertexLayoutRef.shutdown(m_layoutHandle);
#if BGFX_CONFIG_MULTITHREADED
// Render thread shutdown sequence.
@@ -1920,11 +1967,12 @@ namespace bgfx
if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
{
-#define CHECK_HANDLE_LEAK(_handleAlloc) \
+#define CHECK_HANDLE_LEAK(_name, _handleAlloc) \
BX_MACRO_BLOCK_BEGIN \
if (0 != _handleAlloc.getNumHandles() ) \
{ \
- BX_TRACE("LEAK: " #_handleAlloc " %d (max: %d)" \
+ BX_TRACE("LEAK: %s %d (max: %d)" \
+ , _name \
, _handleAlloc.getNumHandles() \
, _handleAlloc.getMaxHandles() \
); \
@@ -1935,11 +1983,34 @@ namespace bgfx
} \
BX_MACRO_BLOCK_END
-#define CHECK_HANDLE_LEAK_NAME(_handleAlloc, _type, _ref) \
+#define CHECK_HANDLE_LEAK_NAME(_name, _handleAlloc, _type, _ref) \
BX_MACRO_BLOCK_BEGIN \
if (0 != _handleAlloc.getNumHandles() ) \
{ \
- BX_TRACE("LEAK: " #_handleAlloc " %d (max: %d)" \
+ BX_TRACE("LEAK: %s %d (max: %d)" \
+ , _name \
+ , _handleAlloc.getNumHandles() \
+ , _handleAlloc.getMaxHandles() \
+ ); \
+ for (uint16_t ii = 0, num = _handleAlloc.getNumHandles(); ii < num; ++ii) \
+ { \
+ uint16_t idx = _handleAlloc.getHandleAt(ii); \
+ const _type& ref = _ref[idx]; BX_UNUSED(ref); \
+ BX_TRACE("\t%3d: %4d %s" \
+ , ii \
+ , idx \
+ , ref.m_name.getPtr() \
+ ); \
+ } \
+ } \
+ BX_MACRO_BLOCK_END
+
+#define CHECK_HANDLE_LEAK_RC_NAME(_name, _handleAlloc, _type, _ref) \
+ BX_MACRO_BLOCK_BEGIN \
+ if (0 != _handleAlloc.getNumHandles() ) \
+ { \
+ BX_TRACE("LEAK: %s %d (max: %d)" \
+ , _name \
, _handleAlloc.getNumHandles() \
, _handleAlloc.getMaxHandles() \
); \
@@ -1948,26 +2019,26 @@ namespace bgfx
uint16_t idx = _handleAlloc.getHandleAt(ii); \
const _type& ref = _ref[idx]; BX_UNUSED(ref); \
BX_TRACE("\t%3d: %4d %s (count %d)" \
- , ii \
- , idx \
- , ref.m_name.getPtr() \
- , ref.m_refCount \
- ); \
+ , ii \
+ , idx \
+ , ref.m_name.getPtr() \
+ , ref.m_refCount \
+ ); \
} \
} \
BX_MACRO_BLOCK_END
- CHECK_HANDLE_LEAK (m_dynamicIndexBufferHandle );
- CHECK_HANDLE_LEAK (m_dynamicVertexBufferHandle );
- CHECK_HANDLE_LEAK (m_indexBufferHandle );
- CHECK_HANDLE_LEAK (m_vertexDeclHandle );
- CHECK_HANDLE_LEAK (m_vertexBufferHandle );
- CHECK_HANDLE_LEAK_NAME(m_shaderHandle, ShaderRef, m_shaderRef );
- CHECK_HANDLE_LEAK (m_programHandle );
- CHECK_HANDLE_LEAK_NAME(m_textureHandle, TextureRef, m_textureRef);
- CHECK_HANDLE_LEAK (m_frameBufferHandle );
- CHECK_HANDLE_LEAK_NAME(m_uniformHandle, UniformRef, m_uniformRef);
- CHECK_HANDLE_LEAK (m_occlusionQueryHandle );
+ CHECK_HANDLE_LEAK ("DynamicIndexBufferHandle", m_dynamicIndexBufferHandle );
+ CHECK_HANDLE_LEAK ("DynamicVertexBufferHandle", m_dynamicVertexBufferHandle );
+ CHECK_HANDLE_LEAK_NAME ("IndexBufferHandle", m_indexBufferHandle, IndexBuffer, m_indexBuffers );
+ CHECK_HANDLE_LEAK ("VertexLayoutHandle", m_layoutHandle );
+ CHECK_HANDLE_LEAK_NAME ("VertexBufferHandle", m_vertexBufferHandle, VertexBuffer, m_vertexBuffers );
+ CHECK_HANDLE_LEAK_RC_NAME("ShaderHandle", m_shaderHandle, ShaderRef, m_shaderRef );
+ CHECK_HANDLE_LEAK ("ProgramHandle", m_programHandle );
+ CHECK_HANDLE_LEAK_RC_NAME("TextureHandle", m_textureHandle, TextureRef, m_textureRef );
+ CHECK_HANDLE_LEAK_NAME ("FrameBufferHandle", m_frameBufferHandle, FrameBufferRef, m_frameBufferRef);
+ CHECK_HANDLE_LEAK_RC_NAME("UniformHandle", m_uniformHandle, UniformRef, m_uniformRef );
+ CHECK_HANDLE_LEAK ("OcclusionQueryHandle", m_occlusionQueryHandle );
#undef CHECK_HANDLE_LEAK
#undef CHECK_HANDLE_LEAK_NAME
}
@@ -2006,9 +2077,9 @@ namespace bgfx
destroyVertexBufferInternal(_frame->m_freeVertexBuffer.get(ii));
}
- for (uint16_t ii = 0, num = _frame->m_freeVertexDecl.getNumQueued(); ii < num; ++ii)
+ for (uint16_t ii = 0, num = _frame->m_freeVertexLayout.getNumQueued(); ii < num; ++ii)
{
- m_vertexDeclHandle.free(_frame->m_freeVertexDecl.get(ii).idx);
+ m_layoutHandle.free(_frame->m_freeVertexLayout.get(ii).idx);
}
for (uint16_t ii = 0, num = _frame->m_freeShader.getNumQueued(); ii < num; ++ii)
@@ -2184,10 +2255,34 @@ namespace bgfx
}
}
+#if BX_PLATFORM_OSX || BX_PLATFORM_IOS
+ struct NSAutoreleasePoolScope
+ {
+ NSAutoreleasePoolScope()
+ {
+ id obj = class_createInstance(objc_getClass("NSAutoreleasePool"), 0);
+ typedef id(*objc_msgSend_init)(void*, SEL);
+ pool = ((objc_msgSend_init)objc_msgSend)(obj, sel_getUid("init") );
+ }
+
+ ~NSAutoreleasePoolScope()
+ {
+ typedef void(*objc_msgSend_release)(void*, SEL);
+ ((objc_msgSend_release)objc_msgSend)(pool, sel_getUid("release") );
+ }
+
+ id pool;
+ };
+#endif // BX_PLATFORM_OSX
+
RenderFrame::Enum Context::renderFrame(int32_t _msecs)
{
BGFX_PROFILER_SCOPE("bgfx::renderFrame", 0xff2040ff);
+#if BX_PLATFORM_OSX || BX_PLATFORM_IOS
+ NSAutoreleasePoolScope pool;
+#endif // BX_PLATFORM_OSX
+
if (!m_flipAfterRender)
{
BGFX_PROFILER_SCOPE("bgfx/flip", 0xff2040ff);
@@ -2265,7 +2360,7 @@ namespace bgfx
}
else
{
- _renderCtx->setMarker(data, size);
+ _renderCtx->setMarker(data, uint16_t(size)-1);
}
}
}
@@ -2347,10 +2442,11 @@ namespace bgfx
BGFX_RENDERER_CONTEXT(d3d9);
BGFX_RENDERER_CONTEXT(d3d11);
BGFX_RENDERER_CONTEXT(d3d12);
+ BGFX_RENDERER_CONTEXT(gnm);
BGFX_RENDERER_CONTEXT(mtl);
+ BGFX_RENDERER_CONTEXT(nvn);
BGFX_RENDERER_CONTEXT(gl);
BGFX_RENDERER_CONTEXT(vk);
- BGFX_RENDERER_CONTEXT(gnm);
#undef BGFX_RENDERER_CONTEXT
@@ -2374,6 +2470,7 @@ namespace bgfx
#else
{ noop::rendererCreate, noop::rendererDestroy, BGFX_RENDERER_NOOP_NAME, false }, // Noop
#endif // BX_PLATFORM_OSX || BX_PLATFORM_IOS
+ { nvn::rendererCreate, nvn::rendererDestroy, BGFX_RENDERER_NVN_NAME, !!BGFX_CONFIG_RENDERER_NVN }, // NVN
{ 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
{ vk::rendererCreate, vk::rendererDestroy, BGFX_RENDERER_VULKAN_NAME, !!BGFX_CONFIG_RENDERER_VULKAN }, // Vulkan
@@ -2594,6 +2691,8 @@ namespace bgfx
case CommandBuffer::CreateIndexBuffer:
{
+ BGFX_PROFILER_SCOPE("CreateIndexBuffer", 0xff2040ff);
+
IndexBufferHandle handle;
_cmdbuf.read(handle);
@@ -2611,6 +2710,8 @@ namespace bgfx
case CommandBuffer::DestroyIndexBuffer:
{
+ BGFX_PROFILER_SCOPE("DestroyIndexBuffer", 0xff2040ff);
+
IndexBufferHandle handle;
_cmdbuf.read(handle);
@@ -2618,42 +2719,48 @@ namespace bgfx
}
break;
- case CommandBuffer::CreateVertexDecl:
+ case CommandBuffer::CreateVertexLayout:
{
- VertexDeclHandle handle;
+ BGFX_PROFILER_SCOPE("CreateVertexLayout", 0xff2040ff);
+
+ VertexLayoutHandle handle;
_cmdbuf.read(handle);
- VertexDecl decl;
- _cmdbuf.read(decl);
+ VertexLayout layout;
+ _cmdbuf.read(layout);
- m_renderCtx->createVertexDecl(handle, decl);
+ m_renderCtx->createVertexLayout(handle, layout);
}
break;
- case CommandBuffer::DestroyVertexDecl:
+ case CommandBuffer::DestroyVertexLayout:
{
- VertexDeclHandle handle;
+ BGFX_PROFILER_SCOPE("DestroyVertexLayout", 0xff2040ff);
+
+ VertexLayoutHandle handle;
_cmdbuf.read(handle);
- m_renderCtx->destroyVertexDecl(handle);
+ m_renderCtx->destroyVertexLayout(handle);
}
break;
case CommandBuffer::CreateVertexBuffer:
{
+ BGFX_PROFILER_SCOPE("CreateVertexBuffer", 0xff2040ff);
+
VertexBufferHandle handle;
_cmdbuf.read(handle);
const Memory* mem;
_cmdbuf.read(mem);
- VertexDeclHandle declHandle;
- _cmdbuf.read(declHandle);
+ VertexLayoutHandle layoutHandle;
+ _cmdbuf.read(layoutHandle);
uint16_t flags;
_cmdbuf.read(flags);
- m_renderCtx->createVertexBuffer(handle, mem, declHandle, flags);
+ m_renderCtx->createVertexBuffer(handle, mem, layoutHandle, flags);
release(mem);
}
@@ -2661,6 +2768,8 @@ namespace bgfx
case CommandBuffer::DestroyVertexBuffer:
{
+ BGFX_PROFILER_SCOPE("DestroyVertexBuffer", 0xff2040ff);
+
VertexBufferHandle handle;
_cmdbuf.read(handle);
@@ -2670,6 +2779,8 @@ namespace bgfx
case CommandBuffer::CreateDynamicIndexBuffer:
{
+ BGFX_PROFILER_SCOPE("CreateDynamicIndexBuffer", 0xff2040ff);
+
IndexBufferHandle handle;
_cmdbuf.read(handle);
@@ -2685,6 +2796,8 @@ namespace bgfx
case CommandBuffer::UpdateDynamicIndexBuffer:
{
+ BGFX_PROFILER_SCOPE("UpdateDynamicIndexBuffer", 0xff2040ff);
+
IndexBufferHandle handle;
_cmdbuf.read(handle);
@@ -2705,6 +2818,8 @@ namespace bgfx
case CommandBuffer::DestroyDynamicIndexBuffer:
{
+ BGFX_PROFILER_SCOPE("DestroyDynamicIndexBuffer", 0xff2040ff);
+
IndexBufferHandle handle;
_cmdbuf.read(handle);
@@ -2714,6 +2829,8 @@ namespace bgfx
case CommandBuffer::CreateDynamicVertexBuffer:
{
+ BGFX_PROFILER_SCOPE("CreateDynamicVertexBuffer", 0xff2040ff);
+
VertexBufferHandle handle;
_cmdbuf.read(handle);
@@ -2729,6 +2846,8 @@ namespace bgfx
case CommandBuffer::UpdateDynamicVertexBuffer:
{
+ BGFX_PROFILER_SCOPE("UpdateDynamicVertexBuffer", 0xff2040ff);
+
VertexBufferHandle handle;
_cmdbuf.read(handle);
@@ -2749,6 +2868,8 @@ namespace bgfx
case CommandBuffer::DestroyDynamicVertexBuffer:
{
+ BGFX_PROFILER_SCOPE("DestroyDynamicVertexBuffer", 0xff2040ff);
+
VertexBufferHandle handle;
_cmdbuf.read(handle);
@@ -2758,6 +2879,8 @@ namespace bgfx
case CommandBuffer::CreateShader:
{
+ BGFX_PROFILER_SCOPE("CreateShader", 0xff2040ff);
+
ShaderHandle handle;
_cmdbuf.read(handle);
@@ -2772,6 +2895,8 @@ namespace bgfx
case CommandBuffer::DestroyShader:
{
+ BGFX_PROFILER_SCOPE("DestroyShader", 0xff2040ff);
+
ShaderHandle handle;
_cmdbuf.read(handle);
@@ -2781,6 +2906,8 @@ namespace bgfx
case CommandBuffer::CreateProgram:
{
+ BGFX_PROFILER_SCOPE("CreateProgram", 0xff2040ff);
+
ProgramHandle handle;
_cmdbuf.read(handle);
@@ -2796,6 +2923,8 @@ namespace bgfx
case CommandBuffer::DestroyProgram:
{
+ BGFX_PROFILER_SCOPE("DestroyProgram", 0xff2040ff);
+
ProgramHandle handle;
_cmdbuf.read(handle);
@@ -2805,6 +2934,8 @@ namespace bgfx
case CommandBuffer::CreateTexture:
{
+ BGFX_PROFILER_SCOPE("CreateTexture", 0xff2040ff);
+
TextureHandle handle;
_cmdbuf.read(handle);
@@ -2845,6 +2976,8 @@ namespace bgfx
case CommandBuffer::UpdateTexture:
{
+ BGFX_PROFILER_SCOPE("UpdateTexture", 0xff2040ff);
+
if (m_textureUpdateBatch.isFull() )
{
flushTextureUpdateBatch(_cmdbuf);
@@ -2878,6 +3011,8 @@ namespace bgfx
case CommandBuffer::ReadTexture:
{
+ BGFX_PROFILER_SCOPE("ReadTexture", 0xff2040ff);
+
TextureHandle handle;
_cmdbuf.read(handle);
@@ -2893,6 +3028,8 @@ namespace bgfx
case CommandBuffer::ResizeTexture:
{
+ BGFX_PROFILER_SCOPE("ResizeTexture", 0xff2040ff);
+
TextureHandle handle;
_cmdbuf.read(handle);
@@ -2914,6 +3051,8 @@ namespace bgfx
case CommandBuffer::DestroyTexture:
{
+ BGFX_PROFILER_SCOPE("DestroyTexture", 0xff2040ff);
+
TextureHandle handle;
_cmdbuf.read(handle);
@@ -2923,6 +3062,8 @@ namespace bgfx
case CommandBuffer::CreateFrameBuffer:
{
+ BGFX_PROFILER_SCOPE("CreateFrameBuffer", 0xff2040ff);
+
FrameBufferHandle handle;
_cmdbuf.read(handle);
@@ -2963,6 +3104,8 @@ namespace bgfx
case CommandBuffer::DestroyFrameBuffer:
{
+ BGFX_PROFILER_SCOPE("DestroyFrameBuffer", 0xff2040ff);
+
FrameBufferHandle handle;
_cmdbuf.read(handle);
@@ -2972,6 +3115,8 @@ namespace bgfx
case CommandBuffer::CreateUniform:
{
+ BGFX_PROFILER_SCOPE("CreateUniform", 0xff2040ff);
+
UniformHandle handle;
_cmdbuf.read(handle);
@@ -2992,6 +3137,8 @@ namespace bgfx
case CommandBuffer::DestroyUniform:
{
+ BGFX_PROFILER_SCOPE("DestroyUniform", 0xff2040ff);
+
UniformHandle handle;
_cmdbuf.read(handle);
@@ -3001,6 +3148,8 @@ namespace bgfx
case CommandBuffer::RequestScreenShot:
{
+ BGFX_PROFILER_SCOPE("RequestScreenShot", 0xff2040ff);
+
FrameBufferHandle handle;
_cmdbuf.read(handle);
@@ -3015,6 +3164,8 @@ namespace bgfx
case CommandBuffer::UpdateViewName:
{
+ BGFX_PROFILER_SCOPE("UpdateViewName", 0xff2040ff);
+
ViewId id;
_cmdbuf.read(id);
@@ -3029,6 +3180,8 @@ namespace bgfx
case CommandBuffer::InvalidateOcclusionQuery:
{
+ BGFX_PROFILER_SCOPE("InvalidateOcclusionQuery", 0xff2040ff);
+
OcclusionQueryHandle handle;
_cmdbuf.read(handle);
@@ -3038,6 +3191,8 @@ namespace bgfx
case CommandBuffer::SetName:
{
+ BGFX_PROFILER_SCOPE("SetName", 0xff2040ff);
+
Handle handle;
_cmdbuf.read(handle);
@@ -3046,7 +3201,7 @@ namespace bgfx
const char* name = (const char*)_cmdbuf.skip(len);
- m_renderCtx->setName(handle, name);
+ m_renderCtx->setName(handle, name, len-1);
}
break;
@@ -3129,7 +3284,7 @@ namespace bgfx
, vendorId(BGFX_PCI_ID_NONE)
, deviceId(0)
, debug(BX_ENABLED(BGFX_CONFIG_DEBUG) )
- , profile(BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
+ , profile(BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
, callback(NULL)
, allocator(NULL)
{
@@ -3219,7 +3374,7 @@ namespace bgfx
g_caps.limits.maxTextures = BGFX_CONFIG_MAX_TEXTURES;
g_caps.limits.maxTextureSamplers = BGFX_CONFIG_MAX_TEXTURE_SAMPLERS;
g_caps.limits.maxComputeBindings = 0;
- g_caps.limits.maxVertexDecls = BGFX_CONFIG_MAX_VERTEX_DECLS;
+ g_caps.limits.maxVertexLayouts = BGFX_CONFIG_MAX_VERTEX_LAYOUTS;
g_caps.limits.maxVertexStreams = 1;
g_caps.limits.maxIndexBuffers = BGFX_CONFIG_MAX_INDEX_BUFFERS;
g_caps.limits.maxVertexBuffers = BGFX_CONFIG_MAX_VERTEX_BUFFERS;
@@ -3270,7 +3425,6 @@ namespace bgfx
s_allocatorStub = NULL;
}
- s_renderFrameCalled = false;
s_threadIndex = 0;
g_callback = NULL;
g_allocator = NULL;
@@ -3311,7 +3465,6 @@ namespace bgfx
s_allocatorStub = NULL;
}
- s_renderFrameCalled = false;
s_threadIndex = 0;
g_callback = NULL;
g_allocator = NULL;
@@ -3381,7 +3534,7 @@ namespace bgfx
void Encoder::setUniform(UniformHandle _handle, const void* _value, uint16_t _num)
{
BGFX_CHECK_HANDLE("setUniform", s_ctx->m_uniformHandle, _handle);
- const Context::UniformRef& uniform = s_ctx->m_uniformRef[_handle.idx];
+ const UniformRef& uniform = s_ctx->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);
BGFX_ENCODER(setUniform(uniform.m_type, _handle, _value, UINT16_MAX != _num ? _num : uniform.m_num) );
@@ -3422,10 +3575,17 @@ namespace bgfx
BGFX_ENCODER(setIndexBuffer(_tib, _firstIndex, _numIndices) );
}
- void Encoder::setVertexBuffer(uint8_t _stream, VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices)
+ void Encoder::setVertexBuffer(
+ uint8_t _stream
+ , VertexBufferHandle _handle
+ , uint32_t _startVertex
+ , uint32_t _numVertices
+ , VertexLayoutHandle _layoutHandle
+ )
{
BGFX_CHECK_HANDLE("setVertexBuffer", s_ctx->m_vertexBufferHandle, _handle);
- BGFX_ENCODER(setVertexBuffer(_stream, _handle, _startVertex, _numVertices) );
+ BGFX_CHECK_HANDLE_INVALID_OK("setVertexBuffer", s_ctx->m_layoutHandle, _layoutHandle);
+ BGFX_ENCODER(setVertexBuffer(_stream, _handle, _startVertex, _numVertices, _layoutHandle) );
}
void Encoder::setVertexBuffer(uint8_t _stream, VertexBufferHandle _handle)
@@ -3433,11 +3593,18 @@ namespace bgfx
setVertexBuffer(_stream, _handle, 0, UINT32_MAX);
}
- void Encoder::setVertexBuffer(uint8_t _stream, DynamicVertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices)
+ void Encoder::setVertexBuffer(
+ uint8_t _stream
+ , DynamicVertexBufferHandle _handle
+ , uint32_t _startVertex
+ , uint32_t _numVertices
+ , VertexLayoutHandle _layoutHandle
+ )
{
BGFX_CHECK_HANDLE("setVertexBuffer", s_ctx->m_dynamicVertexBufferHandle, _handle);
+ BGFX_CHECK_HANDLE_INVALID_OK("setVertexBuffer", s_ctx->m_layoutHandle, _layoutHandle);
const DynamicVertexBuffer& dvb = s_ctx->m_dynamicVertexBuffers[_handle.idx];
- BGFX_ENCODER(setVertexBuffer(_stream, dvb, _startVertex, _numVertices) );
+ BGFX_ENCODER(setVertexBuffer(_stream, dvb, _startVertex, _numVertices, _layoutHandle) );
}
void Encoder::setVertexBuffer(uint8_t _stream, DynamicVertexBufferHandle _handle)
@@ -3445,11 +3612,18 @@ namespace bgfx
setVertexBuffer(_stream, _handle, 0, UINT32_MAX);
}
- void Encoder::setVertexBuffer(uint8_t _stream, const TransientVertexBuffer* _tvb, uint32_t _startVertex, uint32_t _numVertices)
+ void Encoder::setVertexBuffer(
+ uint8_t _stream
+ , const TransientVertexBuffer* _tvb
+ , uint32_t _startVertex
+ , uint32_t _numVertices
+ , VertexLayoutHandle _layoutHandle
+ )
{
BX_CHECK(NULL != _tvb, "_tvb can't be NULL");
BGFX_CHECK_HANDLE("setVertexBuffer", s_ctx->m_vertexBufferHandle, _tvb->handle);
- BGFX_ENCODER(setVertexBuffer(_stream, _tvb, _startVertex, _numVertices) );
+ BGFX_CHECK_HANDLE_INVALID_OK("setVertexBuffer", s_ctx->m_layoutHandle, _layoutHandle);
+ BGFX_ENCODER(setVertexBuffer(_stream, _tvb, _startVertex, _numVertices, _layoutHandle) );
}
void Encoder::setVertexBuffer(uint8_t _stream, const TransientVertexBuffer* _tvb)
@@ -3590,20 +3764,20 @@ namespace bgfx
BGFX_ENCODER(setImage(_stage, _handle, _mip, _access, _format) );
}
- void Encoder::dispatch(ViewId _id, ProgramHandle _program, uint32_t _numX, uint32_t _numY, uint32_t _numZ, uint8_t _flags)
+ void Encoder::dispatch(ViewId _id, ProgramHandle _program, uint32_t _numX, uint32_t _numY, uint32_t _numZ)
{
BGFX_CHECK_CAPS(BGFX_CAPS_COMPUTE, "Compute is not supported!");
BGFX_CHECK_HANDLE_INVALID_OK("dispatch", s_ctx->m_programHandle, _program);
- BGFX_ENCODER(dispatch(_id, _program, _numX, _numY, _numZ, _flags) );
+ BGFX_ENCODER(dispatch(_id, _program, _numX, _numY, _numZ) );
}
- void Encoder::dispatch(ViewId _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, uint16_t _start, uint16_t _num, uint8_t _flags)
+ void Encoder::dispatch(ViewId _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, uint16_t _start, uint16_t _num)
{
BGFX_CHECK_CAPS(BGFX_CAPS_DRAW_INDIRECT, "Dispatch indirect is not supported!");
BGFX_CHECK_CAPS(BGFX_CAPS_COMPUTE, "Compute is not supported!");
BGFX_CHECK_HANDLE_INVALID_OK("dispatch", s_ctx->m_programHandle, _program);
BGFX_CHECK_HANDLE("dispatch", s_ctx->m_vertexBufferHandle, _indirectHandle);
- BGFX_ENCODER(dispatch(_id, _program, _indirectHandle, _start, _num, _flags) );
+ BGFX_ENCODER(dispatch(_id, _program, _indirectHandle, _start, _num) );
}
void Encoder::discard()
@@ -3621,8 +3795,8 @@ namespace bgfx
BGFX_CHECK_CAPS(BGFX_CAPS_TEXTURE_BLIT, "Texture blit is not supported!");
BGFX_CHECK_HANDLE("blit/src TextureHandle", s_ctx->m_textureHandle, _src);
BGFX_CHECK_HANDLE("blit/dst TextureHandle", s_ctx->m_textureHandle, _dst);
- const Context::TextureRef& src = s_ctx->m_textureRef[_src.idx];
- const Context::TextureRef& dst = s_ctx->m_textureRef[_dst.idx];
+ const TextureRef& src = s_ctx->m_textureRef[_src.idx];
+ const TextureRef& dst = s_ctx->m_textureRef[_dst.idx];
BX_CHECK(src.m_format == dst.m_format
, "Texture format must match (src %s, dst %s)."
, bimg::getName(bimg::TextureFormat::Enum(src.m_format) )
@@ -3752,16 +3926,36 @@ namespace bgfx
return s_ctx->createIndexBuffer(_mem, _flags);
}
+ void setName(IndexBufferHandle _handle, const char* _name, int32_t _len)
+ {
+ s_ctx->setName(_handle, bx::StringView(_name, _len) );
+ }
+
void destroy(IndexBufferHandle _handle)
{
s_ctx->destroyIndexBuffer(_handle);
}
- VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint16_t _flags)
+ VertexLayoutHandle createVertexLayout(const VertexLayout& _layout)
+ {
+ return s_ctx->createVertexLayout(_layout);
+ }
+
+ void destroy(VertexLayoutHandle _handle)
+ {
+ s_ctx->destroyVertexLayout(_handle);
+ }
+
+ VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexLayout& _layout, uint16_t _flags)
{
BX_CHECK(NULL != _mem, "_mem can't be NULL");
- BX_CHECK(isValid(_decl), "Invalid VertexDecl.");
- return s_ctx->createVertexBuffer(_mem, _decl, _flags);
+ BX_CHECK(isValid(_layout), "Invalid VertexLayout.");
+ return s_ctx->createVertexBuffer(_mem, _layout, _flags);
+ }
+
+ void setName(VertexBufferHandle _handle, const char* _name, int32_t _len)
+ {
+ s_ctx->setName(_handle, bx::StringView(_name, _len) );
}
void destroy(VertexBufferHandle _handle)
@@ -3791,17 +3985,17 @@ namespace bgfx
s_ctx->destroyDynamicIndexBuffer(_handle);
}
- DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexDecl& _decl, uint16_t _flags)
+ DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexLayout& _layout, uint16_t _flags)
{
- BX_CHECK(isValid(_decl), "Invalid VertexDecl.");
- return s_ctx->createDynamicVertexBuffer(_num, _decl, _flags);
+ BX_CHECK(isValid(_layout), "Invalid VertexLayout.");
+ return s_ctx->createDynamicVertexBuffer(_num, _layout, _flags);
}
- DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint16_t _flags)
+ DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexLayout& _layout, uint16_t _flags)
{
BX_CHECK(NULL != _mem, "_mem can't be NULL");
- BX_CHECK(isValid(_decl), "Invalid VertexDecl.");
- return s_ctx->createDynamicVertexBuffer(_mem, _decl, _flags);
+ BX_CHECK(isValid(_layout), "Invalid VertexLayout.");
+ return s_ctx->createDynamicVertexBuffer(_mem, _layout, _flags);
}
void update(DynamicVertexBufferHandle _handle, uint32_t _startVertex, const Memory* _mem)
@@ -3821,11 +4015,11 @@ namespace bgfx
return s_ctx->getAvailTransientIndexBuffer(_num);
}
- uint32_t getAvailTransientVertexBuffer(uint32_t _num, const VertexDecl& _decl)
+ uint32_t getAvailTransientVertexBuffer(uint32_t _num, const VertexLayout& _layout)
{
BX_CHECK(0 < _num, "Requesting 0 vertices.");
- BX_CHECK(isValid(_decl), "Invalid VertexDecl.");
- return s_ctx->getAvailTransientVertexBuffer(_num, _decl.m_stride);
+ BX_CHECK(isValid(_layout), "Invalid VertexLayout.");
+ return s_ctx->getAvailTransientVertexBuffer(_num, _layout.m_stride);
}
uint32_t getAvailInstanceDataBuffer(uint32_t _num, uint16_t _stride)
@@ -3847,28 +4041,28 @@ namespace bgfx
);
}
- void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint32_t _num, const VertexDecl& _decl)
+ void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint32_t _num, const VertexLayout& _layout)
{
BX_CHECK(NULL != _tvb, "_tvb can't be NULL");
BX_CHECK(0 < _num, "Requesting 0 vertices.");
- BX_CHECK(isValid(_decl), "Invalid VertexDecl.");
- s_ctx->allocTransientVertexBuffer(_tvb, _num, _decl);
- BX_CHECK(_num == _tvb->size / _decl.m_stride
+ BX_CHECK(isValid(_layout), "Invalid VertexLayout.");
+ s_ctx->allocTransientVertexBuffer(_tvb, _num, _layout);
+ BX_CHECK(_num == _tvb->size / _layout.m_stride
, "Failed to allocate transient vertex buffer (requested %d, available %d). "
"Use bgfx::getAvailTransient* functions to ensure availability."
, _num
- , _tvb->size / _decl.m_stride
+ , _tvb->size / _layout.m_stride
);
}
- bool allocTransientBuffers(bgfx::TransientVertexBuffer* _tvb, const bgfx::VertexDecl& _decl, uint32_t _numVertices, bgfx::TransientIndexBuffer* _tib, uint32_t _numIndices)
+ bool allocTransientBuffers(bgfx::TransientVertexBuffer* _tvb, const bgfx::VertexLayout& _layout, uint32_t _numVertices, bgfx::TransientIndexBuffer* _tib, uint32_t _numIndices)
{
BGFX_MUTEX_SCOPE(s_ctx->m_resourceApiLock);
- if (_numVertices == getAvailTransientVertexBuffer(_numVertices, _decl)
+ if (_numVertices == getAvailTransientVertexBuffer(_numVertices, _layout)
&& _numIndices == getAvailTransientIndexBuffer(_numIndices) )
{
- allocTransientVertexBuffer(_tvb, _numVertices, _decl);
+ allocTransientVertexBuffer(_tvb, _numVertices, _layout);
allocTransientIndexBuffer(_tib, _numIndices);
return true;
}
@@ -3908,7 +4102,19 @@ namespace bgfx
uint16_t getShaderUniforms(ShaderHandle _handle, UniformHandle* _uniforms, uint16_t _max)
{
- return s_ctx->getShaderUniforms(_handle, _uniforms, _max);
+ BX_WARN(NULL == _uniforms || 0 != _max
+ , "Passing uniforms array pointer, but array maximum capacity is set to 0."
+ );
+
+ uint16_t num = s_ctx->getShaderUniforms(_handle, _uniforms, _max);
+
+ BX_WARN(0 == _max || num <= _max
+ , "Shader has more uniforms that capacity of output array. Output is truncated (num %d, max %d)."
+ , num
+ , _max
+ );
+
+ return num;
}
void setName(ShaderHandle _handle, const char* _name, int32_t _len)
@@ -3997,6 +4203,7 @@ namespace bgfx
| BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB
) );
}
+
uint16_t srgbCaps = BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB;
if (_cubeMap)
@@ -4045,7 +4252,7 @@ namespace bgfx
}
if (0 != (_flags & BGFX_TEXTURE_SRGB)
- && 0 == (g_caps.supported & srgbCaps & (0
+ && 0 == (g_caps.formats[_format] & srgbCaps & (0
| BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB
| BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB
| BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB
@@ -4373,6 +4580,11 @@ namespace bgfx
);
}
+ void setName(FrameBufferHandle _handle, const char* _name, int32_t _len)
+ {
+ s_ctx->setName(_handle, bx::StringView(_name, _len) );
+ }
+
TextureHandle getTexture(FrameBufferHandle _handle, uint8_t _attachment)
{
return s_ctx->getTexture(_handle, _attachment);
@@ -4504,10 +4716,10 @@ namespace bgfx
s_ctx->setViewFrameBuffer(_id, _handle);
}
- void setViewTransform(ViewId _id, const void* _view, const void* _projL, uint8_t _flags, const void* _projR)
+ void setViewTransform(ViewId _id, const void* _view, const void* _proj)
{
BX_CHECK(checkView(_id), "Invalid view id: %d", _id);
- s_ctx->setViewTransform(_id, _view, _projL, _flags, _projR);
+ s_ctx->setViewTransform(_id, _view, _proj);
}
void setViewOrder(ViewId _id, uint16_t _num, const ViewId* _order)
@@ -4615,10 +4827,16 @@ namespace bgfx
s_ctx->m_encoder0->setIndexBuffer(_tib, _firstIndex, _numIndices);
}
- void setVertexBuffer(uint8_t _stream, VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices)
+ void setVertexBuffer(
+ uint8_t _stream
+ , VertexBufferHandle _handle
+ , uint32_t _startVertex
+ , uint32_t _numVertices
+ , VertexLayoutHandle _layoutHandle
+ )
{
BGFX_CHECK_API_THREAD();
- s_ctx->m_encoder0->setVertexBuffer(_stream, _handle, _startVertex, _numVertices);
+ s_ctx->m_encoder0->setVertexBuffer(_stream, _handle, _startVertex, _numVertices, _layoutHandle);
}
void setVertexBuffer(uint8_t _stream, VertexBufferHandle _handle)
@@ -4626,10 +4844,16 @@ namespace bgfx
setVertexBuffer(_stream, _handle, 0, UINT32_MAX);
}
- void setVertexBuffer(uint8_t _stream, DynamicVertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices)
+ void setVertexBuffer(
+ uint8_t _stream
+ , DynamicVertexBufferHandle _handle
+ , uint32_t _startVertex
+ , uint32_t _numVertices
+ , VertexLayoutHandle _layoutHandle
+ )
{
BGFX_CHECK_API_THREAD();
- s_ctx->m_encoder0->setVertexBuffer(_stream, _handle, _startVertex, _numVertices);
+ s_ctx->m_encoder0->setVertexBuffer(_stream, _handle, _startVertex, _numVertices, _layoutHandle);
}
void setVertexBuffer(uint8_t _stream, DynamicVertexBufferHandle _handle)
@@ -4637,10 +4861,16 @@ namespace bgfx
setVertexBuffer(_stream, _handle, 0, UINT32_MAX);
}
- void setVertexBuffer(uint8_t _stream, const TransientVertexBuffer* _tvb, uint32_t _startVertex, uint32_t _numVertices)
+ void setVertexBuffer(
+ uint8_t _stream
+ , const TransientVertexBuffer* _tvb
+ , uint32_t _startVertex
+ , uint32_t _numVertices
+ , VertexLayoutHandle _layoutHandle
+ )
{
BGFX_CHECK_API_THREAD();
- s_ctx->m_encoder0->setVertexBuffer(_stream, _tvb, _startVertex, _numVertices);
+ s_ctx->m_encoder0->setVertexBuffer(_stream, _tvb, _startVertex, _numVertices, _layoutHandle);
}
void setVertexBuffer(uint8_t _stream, const TransientVertexBuffer* _tvb)
@@ -4750,16 +4980,16 @@ namespace bgfx
s_ctx->m_encoder0->setImage(_stage, _handle, _mip, _access, _format);
}
- void dispatch(ViewId _id, ProgramHandle _handle, uint32_t _numX, uint32_t _numY, uint32_t _numZ, uint8_t _flags)
+ void dispatch(ViewId _id, ProgramHandle _handle, uint32_t _numX, uint32_t _numY, uint32_t _numZ)
{
BGFX_CHECK_API_THREAD();
- s_ctx->m_encoder0->dispatch(_id, _handle, _numX, _numY, _numZ, _flags);
+ s_ctx->m_encoder0->dispatch(_id, _handle, _numX, _numY, _numZ);
}
- void dispatch(ViewId _id, ProgramHandle _handle, IndirectBufferHandle _indirectHandle, uint16_t _start, uint16_t _num, uint8_t _flags)
+ void dispatch(ViewId _id, ProgramHandle _handle, IndirectBufferHandle _indirectHandle, uint16_t _start, uint16_t _num)
{
BGFX_CHECK_API_THREAD();
- s_ctx->m_encoder0->dispatch(_id, _handle, _indirectHandle, _start, _num, _flags);
+ s_ctx->m_encoder0->dispatch(_id, _handle, _indirectHandle, _start, _num);
}
void discard()
@@ -4897,7 +5127,6 @@ BGFX_TEXTURE_FORMAT_BIMG(Count);
#undef BGFX_TEXTURE_FORMAT_BIMG
#include <bgfx/c99/bgfx.h>
-#include <bgfx/c99/platform.h>
#define FLAGS_MASK_TEST(_flags, _mask) ( (_flags) == ( (_flags) & (_mask) ) )
@@ -5011,42 +5240,6 @@ BX_STATIC_ASSERT( (0
#undef FLAGS_MASK_TEST
-#define BGFX_C99_ENUM_CHECK(_enum, _c99enumcount) \
- BX_STATIC_ASSERT(_enum::Count == _enum::Enum(_c99enumcount) )
-
-BGFX_C99_ENUM_CHECK(bgfx::Fatal, BGFX_FATAL_COUNT);
-BGFX_C99_ENUM_CHECK(bgfx::RendererType, BGFX_RENDERER_TYPE_COUNT);
-BGFX_C99_ENUM_CHECK(bgfx::Attrib, BGFX_ATTRIB_COUNT);
-BGFX_C99_ENUM_CHECK(bgfx::AttribType, BGFX_ATTRIB_TYPE_COUNT);
-BGFX_C99_ENUM_CHECK(bgfx::TextureFormat, BGFX_TEXTURE_FORMAT_COUNT);
-BGFX_C99_ENUM_CHECK(bgfx::UniformType, BGFX_UNIFORM_TYPE_COUNT);
-BGFX_C99_ENUM_CHECK(bgfx::BackbufferRatio, BGFX_BACKBUFFER_RATIO_COUNT);
-BGFX_C99_ENUM_CHECK(bgfx::OcclusionQueryResult, BGFX_OCCLUSION_QUERY_RESULT_COUNT);
-BGFX_C99_ENUM_CHECK(bgfx::Topology, BGFX_TOPOLOGY_COUNT);
-BGFX_C99_ENUM_CHECK(bgfx::TopologyConvert, BGFX_TOPOLOGY_CONVERT_COUNT);
-BGFX_C99_ENUM_CHECK(bgfx::RenderFrame, BGFX_RENDER_FRAME_COUNT);
-#undef BGFX_C99_ENUM_CHECK
-
-#define BGFX_C99_STRUCT_SIZE_CHECK(_cppstruct, _c99struct) \
- BX_STATIC_ASSERT(sizeof(_cppstruct) == sizeof(_c99struct) )
-
-BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Memory, bgfx_memory_t);
-BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Transform, bgfx_transform_t);
-BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Stats, bgfx_stats_t);
-BGFX_C99_STRUCT_SIZE_CHECK(bgfx::VertexDecl, bgfx_vertex_decl_t);
-BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TransientIndexBuffer, bgfx_transient_index_buffer_t);
-BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TransientVertexBuffer, bgfx_transient_vertex_buffer_t);
-BGFX_C99_STRUCT_SIZE_CHECK(bgfx::InstanceDataBuffer, bgfx_instance_data_buffer_t);
-BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TextureInfo, bgfx_texture_info_t);
-BGFX_C99_STRUCT_SIZE_CHECK(bgfx::UniformInfo, bgfx_uniform_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);
-#undef BGFX_C99_STRUCT_SIZE_CHECK
-
namespace bgfx
{
struct CallbackC99 : public CallbackI
@@ -5135,1232 +5328,4 @@ namespace bgfx
} // namespace bgfx
-BGFX_C_API void bgfx_vertex_decl_begin(bgfx_vertex_decl_t* _decl, bgfx_renderer_type_t _renderer)
-{
- bgfx::VertexDecl* decl = (bgfx::VertexDecl*)_decl;
- decl->begin(bgfx::RendererType::Enum(_renderer) );
-}
-
-BGFX_C_API void bgfx_vertex_decl_add(bgfx_vertex_decl_t* _decl, bgfx_attrib_t _attrib, uint8_t _num, bgfx_attrib_type_t _type, bool _normalized, bool _asInt)
-{
- bgfx::VertexDecl* decl = (bgfx::VertexDecl*)_decl;
- decl->add(bgfx::Attrib::Enum(_attrib)
- , _num
- , bgfx::AttribType::Enum(_type)
- , _normalized
- , _asInt
- );
-}
-
-BGFX_C_API void bgfx_vertex_decl_decode(const bgfx_vertex_decl_t* _decl, bgfx_attrib_t _attrib, uint8_t* _num, bgfx_attrib_type_t* _type, bool* _normalized, bool* _asInt)
-{
- bgfx::AttribType::Enum type;
- const bgfx::VertexDecl* decl = (const bgfx::VertexDecl*)_decl;
- decl->decode(
- bgfx::Attrib::Enum(_attrib)
- , *_num
- , type
- , *_normalized
- , *_asInt
- );
- *_type = (bgfx_attrib_type_t)type;
-}
-
-BGFX_C_API bool bgfx_vertex_decl_has(const bgfx_vertex_decl_t* _decl, bgfx_attrib_t _attrib)
-{
- const bgfx::VertexDecl* decl = (const bgfx::VertexDecl*)_decl;
- return decl->has(bgfx::Attrib::Enum(_attrib));
-}
-
-BGFX_C_API void bgfx_vertex_decl_skip(bgfx_vertex_decl_t* _decl, uint8_t _num)
-{
- bgfx::VertexDecl* decl = (bgfx::VertexDecl*)_decl;
- decl->skip(_num);
-}
-
-BGFX_C_API void bgfx_vertex_decl_end(bgfx_vertex_decl_t* _decl)
-{
- bgfx::VertexDecl* decl = (bgfx::VertexDecl*)_decl;
- decl->end();
-}
-
-BGFX_C_API void bgfx_vertex_pack(const float _input[4], bool _inputNormalized, bgfx_attrib_t _attr, const bgfx_vertex_decl_t* _decl, void* _data, uint32_t _index)
-{
- bgfx::VertexDecl& decl = *(bgfx::VertexDecl*)_decl;
- bgfx::vertexPack(_input, _inputNormalized, bgfx::Attrib::Enum(_attr), decl, _data, _index);
-}
-
-BGFX_C_API void bgfx_vertex_unpack(float _output[4], bgfx_attrib_t _attr, const bgfx_vertex_decl_t* _decl, const void* _data, uint32_t _index)
-{
- bgfx::VertexDecl& decl = *(bgfx::VertexDecl*)_decl;
- bgfx::vertexUnpack(_output, bgfx::Attrib::Enum(_attr), decl, _data, _index);
-}
-
-BGFX_C_API void bgfx_vertex_convert(const bgfx_vertex_decl_t* _destDecl, void* _destData, const bgfx_vertex_decl_t* _srcDecl, const void* _srcData, uint32_t _num)
-{
- bgfx::VertexDecl& destDecl = *(bgfx::VertexDecl*)_destDecl;
- bgfx::VertexDecl& srcDecl = *(bgfx::VertexDecl*)_srcDecl;
- bgfx::vertexConvert(destDecl, _destData, srcDecl, _srcData, _num);
-}
-
-BGFX_C_API uint16_t bgfx_weld_vertices(uint16_t* _output, const bgfx_vertex_decl_t* _decl, const void* _data, uint16_t _num, float _epsilon)
-{
- bgfx::VertexDecl& decl = *(bgfx::VertexDecl*)_decl;
- return bgfx::weldVertices(_output, decl, _data, _num, _epsilon);
-}
-
-uint32_t bgfx_topology_convert(bgfx_topology_convert_t _conversion, void* _dst, uint32_t _dstSize, const void* _indices, uint32_t _numIndices, bool _index32)
-{
- return bgfx::topologyConvert(bgfx::TopologyConvert::Enum(_conversion), _dst, _dstSize, _indices, _numIndices, _index32);
-}
-
-void bgfx_topology_sort_tri_list(bgfx_topology_sort_t _sort, void* _dst, uint32_t _dstSize, const float _dir[3], const float _pos[3], const void* _vertices, uint32_t _stride, const void* _indices, uint32_t _numIndices, bool _index32)
-{
- bgfx::topologySortTriList(bgfx::TopologySort::Enum(_sort), _dst, _dstSize, _dir, _pos, _vertices, _stride, _indices, _numIndices, _index32);
-}
-
-BGFX_C_API uint8_t bgfx_get_supported_renderers(uint8_t _max, bgfx_renderer_type_t* _enum)
-{
- return bgfx::getSupportedRenderers(_max, (bgfx::RendererType::Enum*)_enum);
-}
-
-BGFX_C_API const char* bgfx_get_renderer_name(bgfx_renderer_type_t _type)
-{
- return bgfx::getRendererName(bgfx::RendererType::Enum(_type) );
-}
-
-BGFX_C_API void bgfx_init_ctor(bgfx_init_t* _init)
-{
- BX_PLACEMENT_NEW(_init, bgfx::Init);
-}
-
-BGFX_C_API bool bgfx_init(const bgfx_init_t* _init)
-{
- bgfx_init_t init = *_init;
-
- if (init.callback != NULL)
- {
- static bgfx::CallbackC99 s_callback;
- s_callback.m_interface = init.callback;
- init.callback = reinterpret_cast<bgfx_callback_interface_t *>(&s_callback);
- }
-
- if (init.allocator != NULL)
- {
- static bgfx::AllocatorC99 s_allocator;
- s_allocator.m_interface = init.allocator;
- init.allocator = reinterpret_cast<bgfx_allocator_interface_t *>(&s_allocator);
- }
-
- union { const bgfx_init_t* c; const bgfx::Init* cpp; } in;
- in.c = &init;
-
- return bgfx::init(*in.cpp);
-}
-
-BGFX_C_API void bgfx_shutdown(void)
-{
- return bgfx::shutdown();
-}
-
-BGFX_C_API void bgfx_reset(uint32_t _width, uint32_t _height, uint32_t _flags, bgfx_texture_format_t _format)
-{
- bgfx::reset(_width, _height, _flags, bgfx::TextureFormat::Enum(_format) );
-}
-
-BGFX_C_API uint32_t bgfx_frame(bool _capture)
-{
- return bgfx::frame(_capture);
-}
-
-BGFX_C_API bgfx_renderer_type_t bgfx_get_renderer_type(void)
-{
- return bgfx_renderer_type_t(bgfx::getRendererType() );
-}
-
-BGFX_C_API const bgfx_caps_t* bgfx_get_caps(void)
-{
- return (const bgfx_caps_t*)bgfx::getCaps();
-}
-
-BGFX_C_API const bgfx_stats_t* bgfx_get_stats(void)
-{
- return (const bgfx_stats_t*)bgfx::getStats();
-}
-
-BGFX_C_API const bgfx_memory_t* bgfx_alloc(uint32_t _size)
-{
- return (const bgfx_memory_t*)bgfx::alloc(_size);
-}
-
-BGFX_C_API const bgfx_memory_t* bgfx_copy(const void* _data, uint32_t _size)
-{
- return (const bgfx_memory_t*)bgfx::copy(_data, _size);
-}
-
-BGFX_C_API const bgfx_memory_t* bgfx_make_ref(const void* _data, uint32_t _size)
-{
- return (const bgfx_memory_t*)bgfx::makeRef(_data, _size);
-}
-
-BGFX_C_API const bgfx_memory_t* bgfx_make_ref_release(const void* _data, uint32_t _size, bgfx_release_fn_t _releaseFn, void* _userData)
-{
- return (const bgfx_memory_t*)bgfx::makeRef(_data, _size, _releaseFn, _userData);
-}
-
-BGFX_C_API void bgfx_set_debug(uint32_t _debug)
-{
- bgfx::setDebug(_debug);
-}
-
-BGFX_C_API void bgfx_dbg_text_clear(uint8_t _attr, bool _small)
-{
- bgfx::dbgTextClear(_attr, _small);
-}
-
-BGFX_C_API void bgfx_dbg_text_printf(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, ...)
-{
- va_list argList;
- va_start(argList, _format);
- bgfx::dbgTextPrintfVargs(_x, _y, _attr, _format, argList);
- va_end(argList);
-}
-
-BGFX_C_API void bgfx_dbg_text_vprintf(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, va_list _argList)
-{
- bgfx::dbgTextPrintfVargs(_x, _y, _attr, _format, _argList);
-}
-
-BGFX_C_API void bgfx_dbg_text_image(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const void* _data, uint16_t _pitch)
-{
- bgfx::dbgTextImage(_x, _y, _width, _height, _data, _pitch);
-}
-
-BGFX_C_API bgfx_index_buffer_handle_t bgfx_create_index_buffer(const bgfx_memory_t* _mem, uint16_t _flags)
-{
- union { bgfx_index_buffer_handle_t c; bgfx::IndexBufferHandle cpp; } handle;
- handle.cpp = bgfx::createIndexBuffer( (const bgfx::Memory*)_mem, _flags);
- return handle.c;
-}
-
-BGFX_C_API void bgfx_destroy_index_buffer(bgfx_index_buffer_handle_t _handle)
-{
- union { bgfx_index_buffer_handle_t c; bgfx::IndexBufferHandle cpp; } handle = { _handle };
- bgfx::destroy(handle.cpp);
-}
-
-BGFX_C_API bgfx_vertex_buffer_handle_t bgfx_create_vertex_buffer(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl, uint16_t _flags)
-{
- const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl;
- union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle;
- handle.cpp = bgfx::createVertexBuffer( (const bgfx::Memory*)_mem, decl, _flags);
- return handle.c;
-}
-
-BGFX_C_API void bgfx_destroy_vertex_buffer(bgfx_vertex_buffer_handle_t _handle)
-{
- union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle = { _handle };
- bgfx::destroy(handle.cpp);
-}
-
-BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer(uint32_t _num, uint16_t _flags)
-{
- union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle;
- handle.cpp = bgfx::createDynamicIndexBuffer(_num, _flags);
- return handle.c;
-}
-
-BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer_mem(const bgfx_memory_t* _mem, uint16_t _flags)
-{
- union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle;
- handle.cpp = bgfx::createDynamicIndexBuffer( (const bgfx::Memory*)_mem, _flags);
- return handle.c;
-}
-
-BGFX_C_API void bgfx_update_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _startIndex, const bgfx_memory_t* _mem)
-{
- union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle = { _handle };
- bgfx::update(handle.cpp, _startIndex, (const bgfx::Memory*)_mem);
-}
-
-BGFX_C_API void bgfx_destroy_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle)
-{
- union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle = { _handle };
- bgfx::destroy(handle.cpp);
-}
-
-BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer(uint32_t _num, const bgfx_vertex_decl_t* _decl, uint16_t _flags)
-{
- const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl;
- union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle;
- handle.cpp = bgfx::createDynamicVertexBuffer(_num, decl, _flags);
- return handle.c;
-}
-
-BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer_mem(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl, uint16_t _flags)
-{
- const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl;
- union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle;
- handle.cpp = bgfx::createDynamicVertexBuffer( (const bgfx::Memory*)_mem, decl, _flags);
- return handle.c;
-}
-
-BGFX_C_API void bgfx_update_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, const bgfx_memory_t* _mem)
-{
- union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle };
- bgfx::update(handle.cpp, _startVertex, (const bgfx::Memory*)_mem);
-}
-
-BGFX_C_API void bgfx_destroy_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle)
-{
- union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle };
- bgfx::destroy(handle.cpp);
-}
-
-BGFX_C_API uint32_t bgfx_get_avail_transient_index_buffer(uint32_t _num)
-{
- return bgfx::getAvailTransientIndexBuffer(_num);
-}
-
-BGFX_C_API uint32_t bgfx_get_avail_transient_vertex_buffer(uint32_t _num, const bgfx_vertex_decl_t* _decl)
-{
- const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl;
- return bgfx::getAvailTransientVertexBuffer(_num, decl);
-}
-
-BGFX_C_API uint32_t bgfx_get_avail_instance_data_buffer(uint32_t _num, uint16_t _stride)
-{
- return bgfx::getAvailInstanceDataBuffer(_num, _stride);
-}
-
-BGFX_C_API void bgfx_alloc_transient_index_buffer(bgfx_transient_index_buffer_t* _tib, uint32_t _num)
-{
- bgfx::allocTransientIndexBuffer( (bgfx::TransientIndexBuffer*)_tib, _num);
-}
-
-BGFX_C_API void bgfx_alloc_transient_vertex_buffer(bgfx_transient_vertex_buffer_t* _tvb, uint32_t _num, const bgfx_vertex_decl_t* _decl)
-{
- const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl;
- bgfx::allocTransientVertexBuffer( (bgfx::TransientVertexBuffer*)_tvb, _num, decl);
-}
-
-BGFX_C_API bool bgfx_alloc_transient_buffers(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_decl_t* _decl, uint32_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint32_t _numIndices)
-{
- const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl;
- return bgfx::allocTransientBuffers( (bgfx::TransientVertexBuffer*)_tvb, decl, _numVertices, (bgfx::TransientIndexBuffer*)_tib, _numIndices);
-}
-
-BGFX_C_API void bgfx_alloc_instance_data_buffer(bgfx_instance_data_buffer_t* _idb, uint32_t _num, uint16_t _stride)
-{
- bgfx::allocInstanceDataBuffer( (bgfx::InstanceDataBuffer*)_idb, _num, _stride);
-}
-
-BGFX_C_API bgfx_indirect_buffer_handle_t bgfx_create_indirect_buffer(uint32_t _num)
-{
- union { bgfx_indirect_buffer_handle_t c; bgfx::IndirectBufferHandle cpp; } handle;
- handle.cpp = bgfx::createIndirectBuffer(_num);
- return handle.c;
-}
-
-BGFX_C_API void bgfx_destroy_indirect_buffer(bgfx_indirect_buffer_handle_t _handle)
-{
- union { bgfx_indirect_buffer_handle_t c; bgfx::IndirectBufferHandle cpp; } handle = { _handle };
- bgfx::destroy(handle.cpp);
-}
-
-BGFX_C_API bgfx_shader_handle_t bgfx_create_shader(const bgfx_memory_t* _mem)
-{
- union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } handle;
- handle.cpp = bgfx::createShader( (const bgfx::Memory*)_mem);
- return handle.c;
-}
-
-BGFX_C_API uint16_t bgfx_get_shader_uniforms(bgfx_shader_handle_t _handle, bgfx_uniform_handle_t* _uniforms, uint16_t _max)
-{
- union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } handle = { _handle };
- return bgfx::getShaderUniforms(handle.cpp, (bgfx::UniformHandle*)_uniforms, _max);
-}
-
-BGFX_C_API void bgfx_set_shader_name(bgfx_shader_handle_t _handle, const char* _name, int32_t _len)
-{
- union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } handle = { _handle };
- bgfx::setName(handle.cpp, _name, _len);
-}
-
-BGFX_C_API void bgfx_destroy_shader(bgfx_shader_handle_t _handle)
-{
- union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } handle = { _handle };
- bgfx::destroy(handle.cpp);
-}
-
-BGFX_C_API bgfx_program_handle_t bgfx_create_program(bgfx_shader_handle_t _vsh, bgfx_shader_handle_t _fsh, bool _destroyShaders)
-{
- union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } vsh = { _vsh };
- union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } fsh = { _fsh };
- union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } handle;
- handle.cpp = bgfx::createProgram(vsh.cpp, fsh.cpp, _destroyShaders);
- return handle.c;
-}
-
-BGFX_C_API bgfx_program_handle_t bgfx_create_compute_program(bgfx_shader_handle_t _csh, bool _destroyShaders)
-{
- union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } csh = { _csh };
- union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } handle;
- handle.cpp = bgfx::createProgram(csh.cpp, _destroyShaders);
- return handle.c;
-}
-
-BGFX_C_API void bgfx_destroy_program(bgfx_program_handle_t _handle)
-{
- union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } handle = { _handle };
- bgfx::destroy(handle.cpp);
-}
-
-BGFX_C_API bool bgfx_is_texture_valid(uint16_t _depth, bool _cubeMap, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags)
-{
- return bgfx::isTextureValid(_depth, _cubeMap, _numLayers, bgfx::TextureFormat::Enum(_format), _flags);
-}
-
-BGFX_C_API void bgfx_calc_texture_size(bgfx_texture_info_t* _info, uint16_t _width, uint16_t _height, uint16_t _depth, bool _cubeMap, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format)
-{
- bgfx::TextureInfo& info = *(bgfx::TextureInfo*)_info;
- bgfx::calcTextureSize(info, _width, _height, _depth, _cubeMap, _hasMips, _numLayers, bgfx::TextureFormat::Enum(_format) );
-}
-
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture(const bgfx_memory_t* _mem, uint64_t _flags, uint8_t _skip, bgfx_texture_info_t* _info)
-{
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle;
- bgfx::TextureInfo* info = (bgfx::TextureInfo*)_info;
- handle.cpp = bgfx::createTexture( (const bgfx::Memory*)_mem, _flags, _skip, info);
- return handle.c;
-}
-
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d(uint16_t _width, uint16_t _height, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem)
-{
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle;
- handle.cpp = bgfx::createTexture2D(_width, _height, _hasMips, _numLayers, bgfx::TextureFormat::Enum(_format), _flags, (const bgfx::Memory*)_mem);
- return handle.c;
-}
-
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d_scaled(bgfx_backbuffer_ratio_t _ratio, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags)
-{
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle;
- handle.cpp = bgfx::createTexture2D(bgfx::BackbufferRatio::Enum(_ratio), _hasMips, _numLayers, bgfx::TextureFormat::Enum(_format), _flags);
- return handle.c;
-}
-
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_3d(uint16_t _width, uint16_t _height, uint16_t _depth, bool _hasMips, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem)
-{
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle;
- handle.cpp = bgfx::createTexture3D(_width, _height, _depth, _hasMips, bgfx::TextureFormat::Enum(_format), _flags, (const bgfx::Memory*)_mem);
- return handle.c;
-}
-
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_cube(uint16_t _size, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem)
-{
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle;
- handle.cpp = bgfx::createTextureCube(_size, _hasMips, _numLayers, bgfx::TextureFormat::Enum(_format), _flags, (const bgfx::Memory*)_mem);
- return handle.c;
-}
-
-BGFX_C_API void bgfx_update_texture_2d(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch)
-{
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
- bgfx::updateTexture2D(handle.cpp, _layer, _mip, _x, _y, _width, _height, (const bgfx::Memory*)_mem, _pitch);
-}
-
-BGFX_C_API void bgfx_update_texture_3d(bgfx_texture_handle_t _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _width, uint16_t _height, uint16_t _depth, const bgfx_memory_t* _mem)
-{
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
- bgfx::updateTexture3D(handle.cpp, _mip, _x, _y, _z, _width, _height, _depth, (const bgfx::Memory*)_mem);
-}
-
-BGFX_C_API void bgfx_update_texture_cube(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch)
-{
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
- 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, uint8_t _mip)
-{
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
- return bgfx::readTexture(handle.cpp, _data, _mip);
-}
-
-BGFX_C_API void bgfx_set_texture_name(bgfx_texture_handle_t _handle, const char* _name, int32_t _len)
-{
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
- bgfx::setName(handle.cpp, _name, _len);
-}
-
-BGFX_C_API void* bgfx_get_direct_access_ptr(bgfx_texture_handle_t _handle)
-{
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
- return bgfx::getDirectAccessPtr(handle.cpp);
-}
-
-BGFX_C_API void bgfx_destroy_texture(bgfx_texture_handle_t _handle)
-{
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
- bgfx::destroy(handle.cpp);
-}
-
-BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer(uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, uint64_t _textureFlags)
-{
- union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle;
- handle.cpp = bgfx::createFrameBuffer(_width, _height, bgfx::TextureFormat::Enum(_format), _textureFlags);
- return handle.c;
-}
-
-BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_scaled(bgfx_backbuffer_ratio_t _ratio, bgfx_texture_format_t _format, uint64_t _textureFlags)
-{
- union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle;
- handle.cpp = bgfx::createFrameBuffer(bgfx::BackbufferRatio::Enum(_ratio), bgfx::TextureFormat::Enum(_format), _textureFlags);
- return handle.c;
-}
-
-BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_handles(uint8_t _num, const bgfx_texture_handle_t* _handles, bool _destroyTextures)
-{
- union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle;
- handle.cpp = bgfx::createFrameBuffer(_num, (const bgfx::TextureHandle*)_handles, _destroyTextures);
- return handle.c;
-}
-
-BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_attachment(uint8_t _num, const bgfx_attachment_t* _attachment, bool _destroyTextures)
-{
- union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle;
- handle.cpp = bgfx::createFrameBuffer(_num, (const bgfx::Attachment*)_attachment, _destroyTextures);
- return handle.c;
-}
-
-BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_nwh(void* _nwh, uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, bgfx_texture_format_t _depthFormat)
-{
- union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle;
- handle.cpp = bgfx::createFrameBuffer(_nwh, _width, _height, bgfx::TextureFormat::Enum(_format), bgfx::TextureFormat::Enum(_depthFormat) );
- return handle.c;
-}
-
-BGFX_C_API bgfx_texture_handle_t bgfx_get_texture(bgfx_frame_buffer_handle_t _handle, uint8_t _attachment)
-{
- union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle = { _handle };
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } textureHandle;
- textureHandle.cpp = bgfx::getTexture(handle.cpp, _attachment);
- return textureHandle.c;
-}
-
-BGFX_C_API void bgfx_destroy_frame_buffer(bgfx_frame_buffer_handle_t _handle)
-{
- union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle = { _handle };
- bgfx::destroy(handle.cpp);
-}
-
-BGFX_C_API bgfx_uniform_handle_t bgfx_create_uniform(const char* _name, bgfx_uniform_type_t _type, uint16_t _num)
-{
- union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } handle;
- handle.cpp = bgfx::createUniform(_name, bgfx::UniformType::Enum(_type), _num);
- return handle.c;
-}
-
-BGFX_C_API void bgfx_get_uniform_info(bgfx_uniform_handle_t _handle, bgfx_uniform_info_t* _info)
-{
- union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } handle = { _handle };
- bgfx::UniformInfo& info = *(bgfx::UniformInfo*)_info;
- bgfx::getUniformInfo(handle.cpp, info);
-}
-
-BGFX_C_API void bgfx_destroy_uniform(bgfx_uniform_handle_t _handle)
-{
- union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } handle = { _handle };
- bgfx::destroy(handle.cpp);
-}
-
-BGFX_C_API bgfx_occlusion_query_handle_t bgfx_create_occlusion_query(void)
-{
- union { bgfx_occlusion_query_handle_t c; bgfx::OcclusionQueryHandle cpp; } handle;
- handle.cpp = bgfx::createOcclusionQuery();
- return handle.c;
-}
-
-BGFX_C_API bgfx_occlusion_query_result_t bgfx_get_result(bgfx_occlusion_query_handle_t _handle, int32_t* _result)
-{
- union { bgfx_occlusion_query_handle_t c; bgfx::OcclusionQueryHandle cpp; } handle = { _handle };
- return bgfx_occlusion_query_result_t(bgfx::getResult(handle.cpp, _result) );
-}
-
-BGFX_C_API void bgfx_destroy_occlusion_query(bgfx_occlusion_query_handle_t _handle)
-{
- union { bgfx_occlusion_query_handle_t c; bgfx::OcclusionQueryHandle cpp; } handle = { _handle };
- bgfx::destroy(handle.cpp);
-}
-
-BGFX_C_API void bgfx_set_palette_color(uint8_t _index, const float _rgba[4])
-{
- bgfx::setPaletteColor(_index, _rgba);
-}
-
-BGFX_C_API void bgfx_set_view_name(bgfx_view_id_t _id, const char* _name)
-{
- bgfx::setViewName(_id, _name);
-}
-
-BGFX_C_API void bgfx_set_view_rect(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
-{
- bgfx::setViewRect(_id, _x, _y, _width, _height);
-}
-
-BGFX_C_API void bgfx_set_view_rect_auto(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, bgfx_backbuffer_ratio_t _ratio)
-{
- bgfx::setViewRect(_id, _x, _y, bgfx::BackbufferRatio::Enum(_ratio));
-}
-
-BGFX_C_API void bgfx_set_view_scissor(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
-{
- bgfx::setViewScissor(_id, _x, _y, _width, _height);
-}
-
-BGFX_C_API void bgfx_set_view_clear(bgfx_view_id_t _id, uint16_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil)
-{
- bgfx::setViewClear(_id, _flags, _rgba, _depth, _stencil);
-}
-
-BGFX_C_API void bgfx_set_view_clear_mrt(bgfx_view_id_t _id, uint16_t _flags, float _depth, uint8_t _stencil, uint8_t _0, uint8_t _1, uint8_t _2, uint8_t _3, uint8_t _4, uint8_t _5, uint8_t _6, uint8_t _7)
-{
- bgfx::setViewClear(_id, _flags, _depth, _stencil, _0, _1, _2, _3, _4, _5, _6, _7);
-}
-
-BGFX_C_API void bgfx_set_view_mode(bgfx_view_id_t _id, bgfx_view_mode_t _mode)
-{
- bgfx::setViewMode(_id, bgfx::ViewMode::Enum(_mode) );
-}
-
-BGFX_C_API void bgfx_set_view_frame_buffer(bgfx_view_id_t _id, bgfx_frame_buffer_handle_t _handle)
-{
- union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle = { _handle };
- bgfx::setViewFrameBuffer(_id, handle.cpp);
-}
-
-BGFX_C_API void bgfx_set_view_transform(bgfx_view_id_t _id, const void* _view, const void* _proj)
-{
- bgfx::setViewTransform(_id, _view, _proj);
-}
-
-BGFX_C_API void bgfx_set_view_transform_stereo(bgfx_view_id_t _id, const void* _view, const void* _projL, uint8_t _flags, const void* _projR)
-{
- bgfx::setViewTransform(_id, _view, _projL, _flags, _projR);
-}
-
-BGFX_C_API void bgfx_set_view_order(bgfx_view_id_t _id, uint16_t _num, const bgfx_view_id_t* _order)
-{
- bgfx::setViewOrder(_id, _num, _order);
-}
-
-BGFX_C_API void bgfx_reset_view(bgfx_view_id_t _id)
-{
- bgfx::resetView(_id);
-}
-
-BGFX_C_API void bgfx_set_marker(const char* _marker)
-{
- bgfx::setMarker(_marker);
-}
-
-BGFX_C_API void bgfx_set_state(uint64_t _state, uint32_t _rgba)
-{
- bgfx::setState(_state, _rgba);
-}
-
-BGFX_C_API void bgfx_set_condition(bgfx_occlusion_query_handle_t _handle, bool _visible)
-{
- union { bgfx_occlusion_query_handle_t c; bgfx::OcclusionQueryHandle cpp; } handle = { _handle };
- bgfx::setCondition(handle.cpp, _visible);
-}
-
-BGFX_C_API void bgfx_set_stencil(uint32_t _fstencil, uint32_t _bstencil)
-{
- bgfx::setStencil(_fstencil, _bstencil);
-}
-
-BGFX_C_API uint16_t bgfx_set_scissor(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
-{
- return bgfx::setScissor(_x, _y, _width, _height);
-}
-
-BGFX_C_API void bgfx_set_scissor_cached(uint16_t _cache)
-{
- bgfx::setScissor(_cache);
-}
-
-BGFX_C_API uint32_t bgfx_set_transform(const void* _mtx, uint16_t _num)
-{
- return bgfx::setTransform(_mtx, _num);
-}
-
-BGFX_C_API uint32_t bgfx_alloc_transform(bgfx_transform_t* _transform, uint16_t _num)
-{
- return bgfx::allocTransform( (bgfx::Transform*)_transform, _num);
-}
-
-BGFX_C_API void bgfx_set_transform_cached(uint32_t _cache, uint16_t _num)
-{
- bgfx::setTransform(_cache, _num);
-}
-
-BGFX_C_API void bgfx_set_uniform(bgfx_uniform_handle_t _handle, const void* _value, uint16_t _num)
-{
- union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } handle = { _handle };
- bgfx::setUniform(handle.cpp, _value, _num);
-}
-
-BGFX_C_API void bgfx_set_index_buffer(bgfx_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices)
-{
- union { bgfx_index_buffer_handle_t c; bgfx::IndexBufferHandle cpp; } handle = { _handle };
- bgfx::setIndexBuffer(handle.cpp, _firstIndex, _numIndices);
-}
-
-BGFX_C_API void bgfx_set_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices)
-{
- union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle = { _handle };
- bgfx::setIndexBuffer(handle.cpp, _firstIndex, _numIndices);
-}
-
-BGFX_C_API void bgfx_set_transient_index_buffer(const bgfx_transient_index_buffer_t* _tib, uint32_t _firstIndex, uint32_t _numIndices)
-{
- bgfx::setIndexBuffer( (const bgfx::TransientIndexBuffer*)_tib, _firstIndex, _numIndices);
-}
-
-BGFX_C_API void bgfx_set_vertex_buffer(uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices)
-{
- union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle = { _handle };
- bgfx::setVertexBuffer(_stream, handle.cpp, _startVertex, _numVertices);
-}
-
-BGFX_C_API void bgfx_set_dynamic_vertex_buffer(uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices)
-{
- union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle };
- bgfx::setVertexBuffer(_stream, handle.cpp, _startVertex, _numVertices);
-}
-
-BGFX_C_API void bgfx_set_transient_vertex_buffer(uint8_t _stream, const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices)
-{
- bgfx::setVertexBuffer(_stream, (const bgfx::TransientVertexBuffer*)_tvb, _startVertex, _numVertices);
-}
-
-BGFX_C_API void bgfx_set_vertex_count(uint32_t _numVertices)
-{
- bgfx::setVertexCount(_numVertices);
-}
-
-BGFX_C_API void bgfx_set_instance_data_buffer(const bgfx_instance_data_buffer_t* _idb, uint32_t _start, uint32_t _num)
-{
- bgfx::setInstanceDataBuffer( (const bgfx::InstanceDataBuffer*)_idb, _start, _num);
-}
-
-BGFX_C_API void bgfx_set_instance_data_from_vertex_buffer(bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num)
-{
- union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle = { _handle };
- bgfx::setInstanceDataBuffer(handle.cpp, _startVertex, _num);
-}
-
-BGFX_C_API void bgfx_set_instance_data_from_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num)
-{
- union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle };
- bgfx::setInstanceDataBuffer(handle.cpp, _startVertex, _num);
-}
-
-BGFX_C_API void bgfx_set_instance_count(uint32_t _numInstances)
-{
- bgfx::setInstanceCount(_numInstances);
-}
-
-BGFX_C_API void bgfx_set_texture(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint32_t _flags)
-{
- union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } sampler = { _sampler };
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
- bgfx::setTexture(_stage, sampler.cpp, handle.cpp, _flags);
-}
-
-BGFX_C_API void bgfx_touch(bgfx_view_id_t _id)
-{
- return bgfx::touch(_id);
-}
-
-BGFX_C_API void bgfx_submit(bgfx_view_id_t _id, bgfx_program_handle_t _handle, uint32_t _depth, bool _preserveState)
-{
- union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } handle = { _handle };
- bgfx::submit(_id, handle.cpp, _depth, _preserveState);
-}
-
-BGFX_C_API void bgfx_submit_occlusion_query(bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_occlusion_query_handle_t _occlusionQuery, uint32_t _depth, bool _preserveState)
-{
- union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } program = { _program };
- union { bgfx_occlusion_query_handle_t c; bgfx::OcclusionQueryHandle cpp; } occlusionQuery = { _occlusionQuery };
- bgfx::submit(_id, program.cpp, occlusionQuery.cpp, _depth, _preserveState);
-}
-
-BGFX_C_API void bgfx_submit_indirect(bgfx_view_id_t _id, bgfx_program_handle_t _handle, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num, uint32_t _depth, bool _preserveState)
-{
- union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } handle = { _handle };
- union { bgfx_indirect_buffer_handle_t c; bgfx::IndirectBufferHandle cpp; } indirectHandle = { _indirectHandle };
- bgfx::submit(_id, handle.cpp, indirectHandle.cpp, _start, _num, _depth, _preserveState);
-}
-
-BGFX_C_API void bgfx_set_image(uint8_t _stage, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_access_t _access, bgfx_texture_format_t _format)
-{
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
- bgfx::setImage(_stage, handle.cpp, _mip, bgfx::Access::Enum(_access), bgfx::TextureFormat::Enum(_format) );
-}
-
-BGFX_C_API void bgfx_set_compute_index_buffer(uint8_t _stage, bgfx_index_buffer_handle_t _handle, bgfx_access_t _access)
-{
- union { bgfx_index_buffer_handle_t c; bgfx::IndexBufferHandle cpp; } handle = { _handle };
- bgfx::setBuffer(_stage, handle.cpp, bgfx::Access::Enum(_access) );
-}
-
-BGFX_C_API void bgfx_set_compute_vertex_buffer(uint8_t _stage, bgfx_vertex_buffer_handle_t _handle, bgfx_access_t _access)
-{
- union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle = { _handle };
- bgfx::setBuffer(_stage, handle.cpp, bgfx::Access::Enum(_access) );
-}
-
-BGFX_C_API void bgfx_set_compute_dynamic_index_buffer(uint8_t _stage, bgfx_dynamic_index_buffer_handle_t _handle, bgfx_access_t _access)
-{
- union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle = { _handle };
- bgfx::setBuffer(_stage, handle.cpp, bgfx::Access::Enum(_access) );
-}
-
-BGFX_C_API void bgfx_set_compute_dynamic_vertex_buffer(uint8_t _stage, bgfx_dynamic_vertex_buffer_handle_t _handle, bgfx_access_t _access)
-{
- union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle };
- bgfx::setBuffer(_stage, handle.cpp, bgfx::Access::Enum(_access) );
-}
-
-BGFX_C_API void bgfx_set_compute_indirect_buffer(uint8_t _stage, bgfx_indirect_buffer_handle_t _handle, bgfx_access_t _access)
-{
- union { bgfx_indirect_buffer_handle_t c; bgfx::IndirectBufferHandle cpp; } handle = { _handle };
- bgfx::setBuffer(_stage, handle.cpp, bgfx::Access::Enum(_access) );
-}
-
-BGFX_C_API void bgfx_dispatch(bgfx_view_id_t _id, bgfx_program_handle_t _handle, uint32_t _numX, uint32_t _numY, uint32_t _numZ, uint8_t _flags)
-{
- union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } handle = { _handle };
- bgfx::dispatch(_id, handle.cpp, _numX, _numY, _numZ, _flags);
-}
-
-BGFX_C_API void bgfx_dispatch_indirect(bgfx_view_id_t _id, bgfx_program_handle_t _handle, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num, uint8_t _flags)
-{
- union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } handle = { _handle };
- union { bgfx_indirect_buffer_handle_t c; bgfx::IndirectBufferHandle cpp; } indirectHandle = { _indirectHandle };
- bgfx::dispatch(_id, handle.cpp, indirectHandle.cpp, _start, _num, _flags);
-}
-
-BGFX_C_API void bgfx_discard(void)
-{
- bgfx::discard();
-}
-
-BGFX_C_API void bgfx_blit(bgfx_view_id_t _id, bgfx_texture_handle_t _dst, uint8_t _dstMip, uint16_t _dstX, uint16_t _dstY, uint16_t _dstZ, bgfx_texture_handle_t _src, uint8_t _srcMip, uint16_t _srcX, uint16_t _srcY, uint16_t _srcZ, uint16_t _width, uint16_t _height, uint16_t _depth)
-{
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } dst = { _dst };
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } src = { _src };
- bgfx::blit(_id, dst.cpp, _dstMip, _dstX, _dstY, _dstZ, src.cpp, _srcMip, _srcX, _srcY, _srcZ, _width, _height, _depth);
-}
-
-#define BGFX_ENCODER(_func) reinterpret_cast<bgfx::Encoder*>(_encoder)->_func
-
-BGFX_C_API void bgfx_encoder_set_marker(bgfx_encoder_s* _encoder, const char* _marker)
-{
- BGFX_ENCODER(setMarker(_marker) );
-}
-
-BGFX_C_API void bgfx_encoder_set_state(bgfx_encoder_s* _encoder, uint64_t _state, uint32_t _rgba)
-{
- BGFX_ENCODER(setState(_state, _rgba) );
-}
-
-BGFX_C_API void bgfx_encoder_set_condition(bgfx_encoder_s* _encoder, bgfx_occlusion_query_handle_t _handle, bool _visible)
-{
- union { bgfx_occlusion_query_handle_t c; bgfx::OcclusionQueryHandle cpp; } handle = { _handle };
- BGFX_ENCODER(setCondition(handle.cpp, _visible) );
-}
-
-BGFX_C_API void bgfx_encoder_set_stencil(bgfx_encoder_s* _encoder, uint32_t _fstencil, uint32_t _bstencil)
-{
- BGFX_ENCODER(setStencil(_fstencil, _bstencil) );
-}
-
-BGFX_C_API uint16_t bgfx_encoder_set_scissor(bgfx_encoder_s* _encoder, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
-{
- return BGFX_ENCODER(setScissor(_x, _y, _width, _height) );
-}
-
-BGFX_C_API void bgfx_encoder_set_scissor_cached(bgfx_encoder_s* _encoder, uint16_t _cache)
-{
- BGFX_ENCODER(setScissor(_cache) );
-}
-
-BGFX_C_API uint32_t bgfx_encoder_set_transform(bgfx_encoder_s* _encoder, const void* _mtx, uint16_t _num)
-{
- return BGFX_ENCODER(setTransform(_mtx, _num) );
-}
-
-BGFX_C_API uint32_t bgfx_encoder_alloc_transform(bgfx_encoder_s* _encoder, bgfx_transform_t* _transform, uint16_t _num)
-{
- return BGFX_ENCODER(allocTransform( (bgfx::Transform*)_transform, _num) );
-}
-
-BGFX_C_API void bgfx_encoder_set_transform_cached(bgfx_encoder_s* _encoder, uint32_t _cache, uint16_t _num)
-{
- BGFX_ENCODER(setTransform(_cache, _num) );
-}
-
-BGFX_C_API void bgfx_encoder_set_uniform(bgfx_encoder_s* _encoder, bgfx_uniform_handle_t _handle, const void* _value, uint16_t _num)
-{
- union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } handle = { _handle };
- BGFX_ENCODER(setUniform(handle.cpp, _value, _num) );
-}
-
-BGFX_C_API void bgfx_encoder_set_index_buffer(bgfx_encoder_s* _encoder, bgfx_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices)
-{
- union { bgfx_index_buffer_handle_t c; bgfx::IndexBufferHandle cpp; } handle = { _handle };
- BGFX_ENCODER(setIndexBuffer(handle.cpp, _firstIndex, _numIndices) );
-}
-
-BGFX_C_API void bgfx_encoder_set_dynamic_index_buffer(bgfx_encoder_s* _encoder, bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices)
-{
- union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle = { _handle };
- BGFX_ENCODER(setIndexBuffer(handle.cpp, _firstIndex, _numIndices) );
-}
-
-BGFX_C_API void bgfx_encoder_set_transient_index_buffer(bgfx_encoder_s* _encoder, const bgfx_transient_index_buffer_t* _tib, uint32_t _firstIndex, uint32_t _numIndices)
-{
- BGFX_ENCODER(setIndexBuffer( (const bgfx::TransientIndexBuffer*)_tib, _firstIndex, _numIndices) );
-}
-
-BGFX_C_API void bgfx_encoder_set_vertex_buffer(bgfx_encoder_s* _encoder, uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices)
-{
- union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle = { _handle };
- BGFX_ENCODER(setVertexBuffer(_stream, handle.cpp, _startVertex, _numVertices) );
-}
-
-BGFX_C_API void bgfx_encoder_set_dynamic_vertex_buffer(bgfx_encoder_s* _encoder, uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices)
-{
- union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle };
- BGFX_ENCODER(setVertexBuffer(_stream, handle.cpp, _startVertex, _numVertices) );
-}
-
-BGFX_C_API void bgfx_encoder_set_transient_vertex_buffer(bgfx_encoder_s* _encoder, uint8_t _stream, const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices)
-{
- BGFX_ENCODER(setVertexBuffer(_stream, (const bgfx::TransientVertexBuffer*)_tvb, _startVertex, _numVertices) );
-}
-
-BGFX_C_API void bgfx_encoder_set_vertex_count(bgfx_encoder_s* _encoder, uint32_t _numVertices)
-{
- BGFX_ENCODER(setVertexCount(_numVertices) );
-}
-
-BGFX_C_API void bgfx_encoder_set_instance_data_buffer(bgfx_encoder_s* _encoder, const bgfx_instance_data_buffer_t* _idb, uint32_t _start, uint32_t _num)
-{
- BGFX_ENCODER(setInstanceDataBuffer( (const bgfx::InstanceDataBuffer*)_idb, _start, _num) );
-}
-
-BGFX_C_API void bgfx_encoder_set_instance_data_from_vertex_buffer(bgfx_encoder_s* _encoder, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num)
-{
- union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle = { _handle };
- BGFX_ENCODER(setInstanceDataBuffer(handle.cpp, _startVertex, _num) );
-}
-
-BGFX_C_API void bgfx_encoder_set_instance_data_from_dynamic_vertex_buffer(bgfx_encoder_s* _encoder, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num)
-{
- union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle };
- BGFX_ENCODER(setInstanceDataBuffer(handle.cpp, _startVertex, _num) );
-}
-
-BGFX_C_API void bgfx_encoder_set_instance_count(bgfx_encoder_s* _encoder, uint32_t _numInstances)
-{
- BGFX_ENCODER(setInstanceCount(_numInstances) );
-}
-
-BGFX_C_API void bgfx_encoder_set_texture(bgfx_encoder_s* _encoder, uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint32_t _flags)
-{
- union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } sampler = { _sampler };
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
- BGFX_ENCODER(setTexture(_stage, sampler.cpp, handle.cpp, _flags) );
-}
-
-BGFX_C_API void bgfx_encoder_touch(bgfx_encoder_s* _encoder, bgfx_view_id_t _id)
-{
- return BGFX_ENCODER(touch(_id) );
-}
-
-BGFX_C_API void bgfx_encoder_submit(bgfx_encoder_s* _encoder, bgfx_view_id_t _id, bgfx_program_handle_t _handle, uint32_t _depth, bool _preserveState)
-{
- union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } handle = { _handle };
- BGFX_ENCODER(submit(_id, handle.cpp, _depth, _preserveState) );
-}
-
-BGFX_C_API void bgfx_encoder_submit_occlusion_query(bgfx_encoder_s* _encoder, bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_occlusion_query_handle_t _occlusionQuery, uint32_t _depth, bool _preserveState)
-{
- union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } program = { _program };
- union { bgfx_occlusion_query_handle_t c; bgfx::OcclusionQueryHandle cpp; } occlusionQuery = { _occlusionQuery };
- BGFX_ENCODER(submit(_id, program.cpp, occlusionQuery.cpp, _depth, _preserveState) );
-}
-
-BGFX_C_API void bgfx_encoder_submit_indirect(bgfx_encoder_s* _encoder, bgfx_view_id_t _id, bgfx_program_handle_t _handle, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num, uint32_t _depth, bool _preserveState)
-{
- union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } handle = { _handle };
- union { bgfx_indirect_buffer_handle_t c; bgfx::IndirectBufferHandle cpp; } indirectHandle = { _indirectHandle };
- BGFX_ENCODER(submit(_id, handle.cpp, indirectHandle.cpp, _start, _num, _depth, _preserveState) );
-}
-
-BGFX_C_API void bgfx_encoder_set_image(bgfx_encoder_s* _encoder, uint8_t _stage, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_access_t _access, bgfx_texture_format_t _format)
-{
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
- BGFX_ENCODER(setImage(_stage, handle.cpp, _mip, bgfx::Access::Enum(_access), bgfx::TextureFormat::Enum(_format) ) );
-}
-
-BGFX_C_API void bgfx_encoder_set_compute_index_buffer(bgfx_encoder_s* _encoder, uint8_t _stage, bgfx_index_buffer_handle_t _handle, bgfx_access_t _access)
-{
- union { bgfx_index_buffer_handle_t c; bgfx::IndexBufferHandle cpp; } handle = { _handle };
- BGFX_ENCODER(setBuffer(_stage, handle.cpp, bgfx::Access::Enum(_access) ) );
-}
-
-BGFX_C_API void bgfx_encoder_set_compute_vertex_buffer(bgfx_encoder_s* _encoder, uint8_t _stage, bgfx_vertex_buffer_handle_t _handle, bgfx_access_t _access)
-{
- union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle = { _handle };
- BGFX_ENCODER(setBuffer(_stage, handle.cpp, bgfx::Access::Enum(_access) ) );
-}
-
-BGFX_C_API void bgfx_encoder_set_compute_dynamic_index_buffer(bgfx_encoder_s* _encoder, uint8_t _stage, bgfx_dynamic_index_buffer_handle_t _handle, bgfx_access_t _access)
-{
- union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle = { _handle };
- BGFX_ENCODER(setBuffer(_stage, handle.cpp, bgfx::Access::Enum(_access) ) );
-}
-
-BGFX_C_API void bgfx_encoder_set_compute_dynamic_vertex_buffer(bgfx_encoder_s* _encoder, uint8_t _stage, bgfx_dynamic_vertex_buffer_handle_t _handle, bgfx_access_t _access)
-{
- union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle };
- BGFX_ENCODER(setBuffer(_stage, handle.cpp, bgfx::Access::Enum(_access) ) );
-}
-
-BGFX_C_API void bgfx_encoder_set_compute_indirect_buffer(bgfx_encoder_s* _encoder, uint8_t _stage, bgfx_indirect_buffer_handle_t _handle, bgfx_access_t _access)
-{
- union { bgfx_indirect_buffer_handle_t c; bgfx::IndirectBufferHandle cpp; } handle = { _handle };
- BGFX_ENCODER(setBuffer(_stage, handle.cpp, bgfx::Access::Enum(_access) ) );
-}
-
-BGFX_C_API void bgfx_encoder_dispatch(bgfx_encoder_s* _encoder, bgfx_view_id_t _id, bgfx_program_handle_t _handle, uint32_t _numX, uint32_t _numY, uint32_t _numZ, uint8_t _flags)
-{
- union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } handle = { _handle };
- BGFX_ENCODER(dispatch(_id, handle.cpp, _numX, _numY, _numZ, _flags) );
-}
-
-BGFX_C_API void bgfx_encoder_dispatch_indirect(bgfx_encoder_s* _encoder, bgfx_view_id_t _id, bgfx_program_handle_t _handle, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num, uint8_t _flags)
-{
- union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } handle = { _handle };
- union { bgfx_indirect_buffer_handle_t c; bgfx::IndirectBufferHandle cpp; } indirectHandle = { _indirectHandle };
- BGFX_ENCODER(dispatch(_id, handle.cpp, indirectHandle.cpp, _start, _num, _flags) );
-}
-
-BGFX_C_API void bgfx_encoder_discard(bgfx_encoder_s* _encoder)
-{
- BGFX_ENCODER(discard() );
-}
-
-BGFX_C_API void bgfx_encoder_blit(bgfx_encoder_s* _encoder, bgfx_view_id_t _id, bgfx_texture_handle_t _dst, uint8_t _dstMip, uint16_t _dstX, uint16_t _dstY, uint16_t _dstZ, bgfx_texture_handle_t _src, uint8_t _srcMip, uint16_t _srcX, uint16_t _srcY, uint16_t _srcZ, uint16_t _width, uint16_t _height, uint16_t _depth)
-{
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } dst = { _dst };
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } src = { _src };
- BGFX_ENCODER(blit(_id, dst.cpp, _dstMip, _dstX, _dstY, _dstZ, src.cpp, _srcMip, _srcX, _srcY, _srcZ, _width, _height, _depth) );
-}
-
-#undef BGFX_ENCODER
-
-BGFX_C_API void bgfx_request_screen_shot(bgfx_frame_buffer_handle_t _handle, const char* _filePath)
-{
- union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle = { _handle };
- bgfx::requestScreenShot(handle.cpp, _filePath);
-}
-
-BGFX_C_API bgfx_render_frame_t bgfx_render_frame(int32_t _msecs)
-{
- return bgfx_render_frame_t(bgfx::renderFrame(_msecs) );
-}
-
-BGFX_C_API void bgfx_set_platform_data(const bgfx_platform_data_t* _data)
-{
- bgfx::setPlatformData(*(const bgfx::PlatformData*)_data);
-}
-
-BGFX_C_API const bgfx_internal_data_t* bgfx_get_internal_data()
-{
- return (const bgfx_internal_data_t*)bgfx::getInternalData();
-}
-
-BGFX_C_API uintptr_t bgfx_override_internal_texture_ptr(bgfx_texture_handle_t _handle, uintptr_t _ptr)
-{
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
- return bgfx::overrideInternal(handle.cpp, _ptr);
-}
-
-BGFX_C_API uintptr_t bgfx_override_internal_texture(bgfx_texture_handle_t _handle, uint16_t _width, uint16_t _height, uint8_t _numMips, bgfx_texture_format_t _format, uint32_t _flags)
-{
- union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
- return bgfx::overrideInternal(handle.cpp, _width, _height, _numMips, bgfx::TextureFormat::Enum(_format), _flags);
-}
-
-BGFX_C_API bgfx_interface_vtbl_t* bgfx_get_interface(uint32_t _version)
-{
- if (_version == BGFX_API_VERSION)
- {
-#define BGFX_IMPORT \
- BGFX_IMPORT_FUNC(render_frame) \
- BGFX_IMPORT_FUNC(set_platform_data) \
- BGFX_IMPORT_FUNC(get_internal_data) \
- BGFX_IMPORT_FUNC(override_internal_texture_ptr) \
- BGFX_IMPORT_FUNC(override_internal_texture) \
- BGFX_IMPORT_FUNC(vertex_decl_begin) \
- BGFX_IMPORT_FUNC(vertex_decl_add) \
- BGFX_IMPORT_FUNC(vertex_decl_decode) \
- BGFX_IMPORT_FUNC(vertex_decl_has) \
- BGFX_IMPORT_FUNC(vertex_decl_skip) \
- BGFX_IMPORT_FUNC(vertex_decl_end) \
- BGFX_IMPORT_FUNC(vertex_pack) \
- BGFX_IMPORT_FUNC(vertex_unpack) \
- BGFX_IMPORT_FUNC(vertex_convert) \
- BGFX_IMPORT_FUNC(weld_vertices) \
- BGFX_IMPORT_FUNC(topology_convert) \
- BGFX_IMPORT_FUNC(topology_sort_tri_list) \
- BGFX_IMPORT_FUNC(get_supported_renderers) \
- BGFX_IMPORT_FUNC(get_renderer_name) \
- BGFX_IMPORT_FUNC(init_ctor) \
- BGFX_IMPORT_FUNC(init) \
- BGFX_IMPORT_FUNC(shutdown) \
- BGFX_IMPORT_FUNC(reset) \
- BGFX_IMPORT_FUNC(frame) \
- BGFX_IMPORT_FUNC(get_renderer_type) \
- BGFX_IMPORT_FUNC(get_caps) \
- BGFX_IMPORT_FUNC(get_stats) \
- BGFX_IMPORT_FUNC(alloc) \
- BGFX_IMPORT_FUNC(copy) \
- BGFX_IMPORT_FUNC(make_ref) \
- BGFX_IMPORT_FUNC(make_ref_release) \
- BGFX_IMPORT_FUNC(set_debug) \
- BGFX_IMPORT_FUNC(dbg_text_clear) \
- BGFX_IMPORT_FUNC(dbg_text_printf) \
- BGFX_IMPORT_FUNC(dbg_text_vprintf) \
- BGFX_IMPORT_FUNC(dbg_text_image) \
- BGFX_IMPORT_FUNC(create_index_buffer) \
- BGFX_IMPORT_FUNC(destroy_index_buffer) \
- BGFX_IMPORT_FUNC(create_vertex_buffer) \
- BGFX_IMPORT_FUNC(destroy_vertex_buffer) \
- BGFX_IMPORT_FUNC(create_dynamic_index_buffer) \
- BGFX_IMPORT_FUNC(create_dynamic_index_buffer_mem) \
- BGFX_IMPORT_FUNC(update_dynamic_index_buffer) \
- BGFX_IMPORT_FUNC(destroy_dynamic_index_buffer) \
- BGFX_IMPORT_FUNC(create_dynamic_vertex_buffer) \
- BGFX_IMPORT_FUNC(create_dynamic_vertex_buffer_mem) \
- BGFX_IMPORT_FUNC(update_dynamic_vertex_buffer) \
- BGFX_IMPORT_FUNC(destroy_dynamic_vertex_buffer) \
- BGFX_IMPORT_FUNC(get_avail_transient_index_buffer) \
- BGFX_IMPORT_FUNC(get_avail_transient_vertex_buffer) \
- BGFX_IMPORT_FUNC(get_avail_instance_data_buffer) \
- BGFX_IMPORT_FUNC(alloc_transient_index_buffer) \
- BGFX_IMPORT_FUNC(alloc_transient_vertex_buffer) \
- BGFX_IMPORT_FUNC(alloc_transient_buffers) \
- BGFX_IMPORT_FUNC(alloc_instance_data_buffer) \
- BGFX_IMPORT_FUNC(create_indirect_buffer) \
- BGFX_IMPORT_FUNC(destroy_indirect_buffer) \
- BGFX_IMPORT_FUNC(create_shader) \
- BGFX_IMPORT_FUNC(get_shader_uniforms) \
- BGFX_IMPORT_FUNC(set_shader_name) \
- BGFX_IMPORT_FUNC(destroy_shader) \
- BGFX_IMPORT_FUNC(create_program) \
- BGFX_IMPORT_FUNC(create_compute_program) \
- BGFX_IMPORT_FUNC(destroy_program) \
- BGFX_IMPORT_FUNC(is_texture_valid) \
- BGFX_IMPORT_FUNC(calc_texture_size) \
- BGFX_IMPORT_FUNC(create_texture) \
- BGFX_IMPORT_FUNC(create_texture_2d) \
- BGFX_IMPORT_FUNC(create_texture_2d_scaled) \
- BGFX_IMPORT_FUNC(create_texture_3d) \
- BGFX_IMPORT_FUNC(create_texture_cube) \
- 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(set_texture_name) \
- BGFX_IMPORT_FUNC(get_direct_access_ptr) \
- BGFX_IMPORT_FUNC(destroy_texture) \
- BGFX_IMPORT_FUNC(create_frame_buffer) \
- BGFX_IMPORT_FUNC(create_frame_buffer_scaled) \
- BGFX_IMPORT_FUNC(create_frame_buffer_from_attachment) \
- BGFX_IMPORT_FUNC(create_frame_buffer_from_nwh) \
- BGFX_IMPORT_FUNC(get_texture) \
- BGFX_IMPORT_FUNC(destroy_frame_buffer) \
- BGFX_IMPORT_FUNC(create_uniform) \
- BGFX_IMPORT_FUNC(get_uniform_info) \
- BGFX_IMPORT_FUNC(destroy_uniform) \
- BGFX_IMPORT_FUNC(create_occlusion_query) \
- BGFX_IMPORT_FUNC(get_result) \
- BGFX_IMPORT_FUNC(destroy_occlusion_query) \
- BGFX_IMPORT_FUNC(set_palette_color) \
- BGFX_IMPORT_FUNC(set_view_name) \
- BGFX_IMPORT_FUNC(set_view_rect) \
- BGFX_IMPORT_FUNC(set_view_scissor) \
- BGFX_IMPORT_FUNC(set_view_clear) \
- BGFX_IMPORT_FUNC(set_view_clear_mrt) \
- BGFX_IMPORT_FUNC(set_view_mode) \
- BGFX_IMPORT_FUNC(set_view_frame_buffer) \
- BGFX_IMPORT_FUNC(set_view_transform) \
- BGFX_IMPORT_FUNC(set_view_transform_stereo) \
- BGFX_IMPORT_FUNC(set_view_order) \
- BGFX_IMPORT_FUNC(encoder_set_marker) \
- BGFX_IMPORT_FUNC(encoder_set_state) \
- BGFX_IMPORT_FUNC(encoder_set_condition) \
- BGFX_IMPORT_FUNC(encoder_set_stencil) \
- BGFX_IMPORT_FUNC(encoder_set_scissor) \
- BGFX_IMPORT_FUNC(encoder_set_scissor_cached) \
- BGFX_IMPORT_FUNC(encoder_set_transform) \
- BGFX_IMPORT_FUNC(encoder_alloc_transform) \
- BGFX_IMPORT_FUNC(encoder_set_transform_cached) \
- BGFX_IMPORT_FUNC(encoder_set_uniform) \
- BGFX_IMPORT_FUNC(encoder_set_index_buffer) \
- BGFX_IMPORT_FUNC(encoder_set_dynamic_index_buffer) \
- BGFX_IMPORT_FUNC(encoder_set_transient_index_buffer) \
- BGFX_IMPORT_FUNC(encoder_set_vertex_buffer) \
- BGFX_IMPORT_FUNC(encoder_set_dynamic_vertex_buffer) \
- BGFX_IMPORT_FUNC(encoder_set_transient_vertex_buffer) \
- BGFX_IMPORT_FUNC(encoder_set_vertex_count) \
- BGFX_IMPORT_FUNC(encoder_set_instance_data_buffer) \
- BGFX_IMPORT_FUNC(encoder_set_instance_data_from_vertex_buffer) \
- BGFX_IMPORT_FUNC(encoder_set_instance_data_from_dynamic_vertex_buffer) \
- BGFX_IMPORT_FUNC(encoder_set_instance_count) \
- BGFX_IMPORT_FUNC(encoder_set_texture) \
- BGFX_IMPORT_FUNC(encoder_touch) \
- BGFX_IMPORT_FUNC(encoder_submit) \
- BGFX_IMPORT_FUNC(encoder_submit_occlusion_query) \
- BGFX_IMPORT_FUNC(encoder_submit_indirect) \
- BGFX_IMPORT_FUNC(encoder_set_image) \
- BGFX_IMPORT_FUNC(encoder_set_compute_index_buffer) \
- BGFX_IMPORT_FUNC(encoder_set_compute_vertex_buffer) \
- BGFX_IMPORT_FUNC(encoder_set_compute_dynamic_index_buffer) \
- BGFX_IMPORT_FUNC(encoder_set_compute_dynamic_vertex_buffer) \
- BGFX_IMPORT_FUNC(encoder_set_compute_indirect_buffer) \
- BGFX_IMPORT_FUNC(encoder_dispatch) \
- BGFX_IMPORT_FUNC(encoder_dispatch_indirect) \
- BGFX_IMPORT_FUNC(encoder_discard) \
- BGFX_IMPORT_FUNC(encoder_blit) \
- BGFX_IMPORT_FUNC(request_screen_shot)
-
- static bgfx_interface_vtbl_t s_bgfx_interface =
- {
-#define BGFX_IMPORT_FUNC(_name) BX_CONCATENATE(bgfx_, _name),
- BGFX_IMPORT
-#undef BGFX_IMPORT_FUNC
- };
-
- return &s_bgfx_interface;
- }
-
- return NULL;
-}
+#include "bgfx.idl.inl"
diff --git a/3rdparty/bgfx/src/bgfx.idl.inl b/3rdparty/bgfx/src/bgfx.idl.inl
new file mode 100644
index 00000000000..03acfae93b9
--- /dev/null
+++ b/3rdparty/bgfx/src/bgfx.idl.inl
@@ -0,0 +1,1395 @@
+/*
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ */
+
+/*
+ *
+ * AUTO GENERATED! DO NOT EDIT!
+ *
+ */
+
+#define BGFX_C99_ENUM_CHECK(_enum, _c99enumcount) \
+ BX_STATIC_ASSERT(_enum::Count == _enum::Enum(_c99enumcount) )
+
+BGFX_C99_ENUM_CHECK(bgfx::Fatal, BGFX_FATAL_COUNT);
+BGFX_C99_ENUM_CHECK(bgfx::RendererType, BGFX_RENDERER_TYPE_COUNT);
+BGFX_C99_ENUM_CHECK(bgfx::Attrib, BGFX_ATTRIB_COUNT);
+BGFX_C99_ENUM_CHECK(bgfx::AttribType, BGFX_ATTRIB_TYPE_COUNT);
+BGFX_C99_ENUM_CHECK(bgfx::TextureFormat, BGFX_TEXTURE_FORMAT_COUNT);
+BGFX_C99_ENUM_CHECK(bgfx::UniformType, BGFX_UNIFORM_TYPE_COUNT);
+BGFX_C99_ENUM_CHECK(bgfx::BackbufferRatio, BGFX_BACKBUFFER_RATIO_COUNT);
+BGFX_C99_ENUM_CHECK(bgfx::OcclusionQueryResult, BGFX_OCCLUSION_QUERY_RESULT_COUNT);
+BGFX_C99_ENUM_CHECK(bgfx::Topology, BGFX_TOPOLOGY_COUNT);
+BGFX_C99_ENUM_CHECK(bgfx::TopologyConvert, BGFX_TOPOLOGY_CONVERT_COUNT);
+BGFX_C99_ENUM_CHECK(bgfx::RenderFrame, BGFX_RENDER_FRAME_COUNT);
+
+#undef BGFX_C99_ENUM_CHECK
+
+#define BGFX_C99_STRUCT_SIZE_CHECK(_cppstruct, _c99struct) \
+ BX_STATIC_ASSERT(sizeof(_cppstruct) == sizeof(_c99struct) )
+
+BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Memory, bgfx_memory_t);
+BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Transform, bgfx_transform_t);
+BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Stats, bgfx_stats_t);
+BGFX_C99_STRUCT_SIZE_CHECK(bgfx::VertexLayout, bgfx_vertex_layout_t);
+BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TransientIndexBuffer, bgfx_transient_index_buffer_t);
+BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TransientVertexBuffer, bgfx_transient_vertex_buffer_t);
+BGFX_C99_STRUCT_SIZE_CHECK(bgfx::InstanceDataBuffer, bgfx_instance_data_buffer_t);
+BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TextureInfo, bgfx_texture_info_t);
+BGFX_C99_STRUCT_SIZE_CHECK(bgfx::UniformInfo, bgfx_uniform_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);
+
+#undef BGFX_C99_STRUCT_SIZE_CHECK
+
+BGFX_C_API void bgfx_attachment_init(bgfx_attachment_t* _this, bgfx_texture_handle_t _handle, bgfx_access_t _access, uint16_t _layer, uint16_t _mip, uint8_t _resolve)
+{
+ bgfx::Attachment* This = (bgfx::Attachment*)_this;
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
+ This->init(handle.cpp, (bgfx::Access::Enum)_access, _layer, _mip, _resolve);
+}
+
+BGFX_C_API bgfx_vertex_layout_t* bgfx_vertex_layout_begin(bgfx_vertex_layout_t* _this, bgfx_renderer_type_t _rendererType)
+{
+ bgfx::VertexLayout* This = (bgfx::VertexLayout*)_this;
+ return (bgfx_vertex_layout_t*)&This->begin((bgfx::RendererType::Enum)_rendererType);
+}
+
+BGFX_C_API bgfx_vertex_layout_t* bgfx_vertex_layout_add(bgfx_vertex_layout_t* _this, bgfx_attrib_t _attrib, uint8_t _num, bgfx_attrib_type_t _type, bool _normalized, bool _asInt)
+{
+ bgfx::VertexLayout* This = (bgfx::VertexLayout*)_this;
+ return (bgfx_vertex_layout_t*)&This->add((bgfx::Attrib::Enum)_attrib, _num, (bgfx::AttribType::Enum)_type, _normalized, _asInt);
+}
+
+BGFX_C_API void bgfx_vertex_layout_decode(const bgfx_vertex_layout_t* _this, bgfx_attrib_t _attrib, uint8_t * _num, bgfx_attrib_type_t * _type, bool * _normalized, bool * _asInt)
+{
+ const bgfx::VertexLayout* This = (const bgfx::VertexLayout*)_this;
+ bgfx::AttribType::Enum type;
+ This->decode((bgfx::Attrib::Enum)_attrib, *_num, type, *_normalized, *_asInt);
+ *_type = (bgfx_attrib_type_t)type;
+}
+
+BGFX_C_API bool bgfx_vertex_layout_has(const bgfx_vertex_layout_t* _this, bgfx_attrib_t _attrib)
+{
+ const bgfx::VertexLayout* This = (const bgfx::VertexLayout*)_this;
+ return This->has((bgfx::Attrib::Enum)_attrib);
+}
+
+BGFX_C_API bgfx_vertex_layout_t* bgfx_vertex_layout_skip(bgfx_vertex_layout_t* _this, uint8_t _num)
+{
+ bgfx::VertexLayout* This = (bgfx::VertexLayout*)_this;
+ return (bgfx_vertex_layout_t*)&This->skip(_num);
+}
+
+BGFX_C_API void bgfx_vertex_layout_end(bgfx_vertex_layout_t* _this)
+{
+ bgfx::VertexLayout* This = (bgfx::VertexLayout*)_this;
+ This->end();
+}
+
+BGFX_C_API void bgfx_vertex_pack(const float _input[4], bool _inputNormalized, bgfx_attrib_t _attr, const bgfx_vertex_layout_t * _layout, void* _data, uint32_t _index)
+{
+ const bgfx::VertexLayout & layout = *(const bgfx::VertexLayout *)_layout;
+ bgfx::vertexPack(_input, _inputNormalized, (bgfx::Attrib::Enum)_attr, layout, _data, _index);
+}
+
+BGFX_C_API void bgfx_vertex_unpack(float _output[4], bgfx_attrib_t _attr, const bgfx_vertex_layout_t * _layout, const void* _data, uint32_t _index)
+{
+ const bgfx::VertexLayout & layout = *(const bgfx::VertexLayout *)_layout;
+ bgfx::vertexUnpack(_output, (bgfx::Attrib::Enum)_attr, layout, _data, _index);
+}
+
+BGFX_C_API void bgfx_vertex_convert(const bgfx_vertex_layout_t * _dstLayout, void* _dstData, const bgfx_vertex_layout_t * _srcLayout, const void* _srcData, uint32_t _num)
+{
+ const bgfx::VertexLayout & dstLayout = *(const bgfx::VertexLayout *)_dstLayout;
+ const bgfx::VertexLayout & srcLayout = *(const bgfx::VertexLayout *)_srcLayout;
+ bgfx::vertexConvert(dstLayout, _dstData, srcLayout, _srcData, _num);
+}
+
+BGFX_C_API uint16_t bgfx_weld_vertices(uint16_t* _output, const bgfx_vertex_layout_t * _layout, const void* _data, uint16_t _num, float _epsilon)
+{
+ const bgfx::VertexLayout & layout = *(const bgfx::VertexLayout *)_layout;
+ return bgfx::weldVertices(_output, layout, _data, _num, _epsilon);
+}
+
+BGFX_C_API uint32_t bgfx_topology_convert(bgfx_topology_convert_t _conversion, void* _dst, uint32_t _dstSize, const void* _indices, uint32_t _numIndices, bool _index32)
+{
+ return bgfx::topologyConvert((bgfx::TopologyConvert::Enum)_conversion, _dst, _dstSize, _indices, _numIndices, _index32);
+}
+
+BGFX_C_API void bgfx_topology_sort_tri_list(bgfx_topology_sort_t _sort, void* _dst, uint32_t _dstSize, const float _dir[3], const float _pos[3], const void* _vertices, uint32_t _stride, const void* _indices, uint32_t _numIndices, bool _index32)
+{
+ bgfx::topologySortTriList((bgfx::TopologySort::Enum)_sort, _dst, _dstSize, _dir, _pos, _vertices, _stride, _indices, _numIndices, _index32);
+}
+
+BGFX_C_API uint8_t bgfx_get_supported_renderers(uint8_t _max, bgfx_renderer_type_t* _enum)
+{
+ return bgfx::getSupportedRenderers(_max, (bgfx::RendererType::Enum*)_enum);
+}
+
+BGFX_C_API const char* bgfx_get_renderer_name(bgfx_renderer_type_t _type)
+{
+ return bgfx::getRendererName((bgfx::RendererType::Enum)_type);
+}
+
+/* BGFX_C_API void bgfx_init_ctor(bgfx_init_t* _init) */
+
+/* BGFX_C_API bool bgfx_init(const bgfx_init_t * _init) */
+
+BGFX_C_API void bgfx_shutdown(void)
+{
+ bgfx::shutdown();
+}
+
+BGFX_C_API void bgfx_reset(uint32_t _width, uint32_t _height, uint32_t _flags, bgfx_texture_format_t _format)
+{
+ bgfx::reset(_width, _height, _flags, (bgfx::TextureFormat::Enum)_format);
+}
+
+BGFX_C_API uint32_t bgfx_frame(bool _capture)
+{
+ return bgfx::frame(_capture);
+}
+
+BGFX_C_API bgfx_renderer_type_t bgfx_get_renderer_type(void)
+{
+ return (bgfx_renderer_type_t)bgfx::getRendererType();
+}
+
+BGFX_C_API const bgfx_caps_t* bgfx_get_caps(void)
+{
+ return (const bgfx_caps_t*)bgfx::getCaps();
+}
+
+BGFX_C_API const bgfx_stats_t* bgfx_get_stats(void)
+{
+ return (const bgfx_stats_t*)bgfx::getStats();
+}
+
+BGFX_C_API const bgfx_memory_t* bgfx_alloc(uint32_t _size)
+{
+ return (const bgfx_memory_t*)bgfx::alloc(_size);
+}
+
+BGFX_C_API const bgfx_memory_t* bgfx_copy(const void* _data, uint32_t _size)
+{
+ return (const bgfx_memory_t*)bgfx::copy(_data, _size);
+}
+
+BGFX_C_API const bgfx_memory_t* bgfx_make_ref(const void* _data, uint32_t _size)
+{
+ return (const bgfx_memory_t*)bgfx::makeRef(_data, _size);
+}
+
+BGFX_C_API const bgfx_memory_t* bgfx_make_ref_release(const void* _data, uint32_t _size, bgfx_release_fn_t _releaseFn, void* _userData)
+{
+ return (const bgfx_memory_t*)bgfx::makeRef(_data, _size, (bgfx::ReleaseFn)_releaseFn, _userData);
+}
+
+BGFX_C_API void bgfx_set_debug(uint32_t _debug)
+{
+ bgfx::setDebug(_debug);
+}
+
+BGFX_C_API void bgfx_dbg_text_clear(uint8_t _attr, bool _small)
+{
+ bgfx::dbgTextClear(_attr, _small);
+}
+
+BGFX_C_API void bgfx_dbg_text_printf(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, ... )
+{
+ va_list argList;
+ va_start(argList, _format);
+ bgfx::dbgTextPrintfVargs(_x, _y, _attr, _format, argList);
+ va_end(argList);
+}
+
+BGFX_C_API void bgfx_dbg_text_vprintf(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, va_list _argList)
+{
+ bgfx::dbgTextPrintfVargs(_x, _y, _attr, _format, _argList);
+}
+
+BGFX_C_API void bgfx_dbg_text_image(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const void* _data, uint16_t _pitch)
+{
+ bgfx::dbgTextImage(_x, _y, _width, _height, _data, _pitch);
+}
+
+BGFX_C_API bgfx_index_buffer_handle_t bgfx_create_index_buffer(const bgfx_memory_t* _mem, uint16_t _flags)
+{
+ union { bgfx_index_buffer_handle_t c; bgfx::IndexBufferHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createIndexBuffer((const bgfx::Memory*)_mem, _flags);
+ return handle_ret.c;
+}
+
+BGFX_C_API void bgfx_set_index_buffer_name(bgfx_index_buffer_handle_t _handle, const char* _name, int32_t _len)
+{
+ union { bgfx_index_buffer_handle_t c; bgfx::IndexBufferHandle cpp; } handle = { _handle };
+ bgfx::setName(handle.cpp, _name, _len);
+}
+
+BGFX_C_API void bgfx_destroy_index_buffer(bgfx_index_buffer_handle_t _handle)
+{
+ union { bgfx_index_buffer_handle_t c; bgfx::IndexBufferHandle cpp; } handle = { _handle };
+ bgfx::destroy(handle.cpp);
+}
+
+BGFX_C_API bgfx_vertex_layout_handle_t bgfx_create_vertex_layout(const bgfx_vertex_layout_t * _layout)
+{
+ const bgfx::VertexLayout & layout = *(const bgfx::VertexLayout *)_layout;
+ union { bgfx_vertex_layout_handle_t c; bgfx::VertexLayoutHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createVertexLayout(layout);
+ return handle_ret.c;
+}
+
+BGFX_C_API void bgfx_destroy_vertex_layout(bgfx_vertex_layout_handle_t _layoutHandle)
+{
+ union { bgfx_vertex_layout_handle_t c; bgfx::VertexLayoutHandle cpp; } layoutHandle = { _layoutHandle };
+ bgfx::destroy(layoutHandle.cpp);
+}
+
+BGFX_C_API bgfx_vertex_buffer_handle_t bgfx_create_vertex_buffer(const bgfx_memory_t* _mem, const bgfx_vertex_layout_t * _layout, uint16_t _flags)
+{
+ const bgfx::VertexLayout & layout = *(const bgfx::VertexLayout *)_layout;
+ union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createVertexBuffer((const bgfx::Memory*)_mem, layout, _flags);
+ return handle_ret.c;
+}
+
+BGFX_C_API void bgfx_set_vertex_buffer_name(bgfx_vertex_buffer_handle_t _handle, const char* _name, int32_t _len)
+{
+ union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle = { _handle };
+ bgfx::setName(handle.cpp, _name, _len);
+}
+
+BGFX_C_API void bgfx_destroy_vertex_buffer(bgfx_vertex_buffer_handle_t _handle)
+{
+ union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle = { _handle };
+ bgfx::destroy(handle.cpp);
+}
+
+BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer(uint32_t _num, uint16_t _flags)
+{
+ union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createDynamicIndexBuffer(_num, _flags);
+ return handle_ret.c;
+}
+
+BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer_mem(const bgfx_memory_t* _mem, uint16_t _flags)
+{
+ union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createDynamicIndexBuffer((const bgfx::Memory*)_mem, _flags);
+ return handle_ret.c;
+}
+
+BGFX_C_API void bgfx_update_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _startIndex, const bgfx_memory_t* _mem)
+{
+ union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle = { _handle };
+ bgfx::update(handle.cpp, _startIndex, (const bgfx::Memory*)_mem);
+}
+
+BGFX_C_API void bgfx_destroy_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle)
+{
+ union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle = { _handle };
+ bgfx::destroy(handle.cpp);
+}
+
+BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer(uint32_t _num, const bgfx_vertex_layout_t* _layout, uint16_t _flags)
+{
+ const bgfx::VertexLayout& layout = *(const bgfx::VertexLayout*)_layout;
+ union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createDynamicVertexBuffer(_num, layout, _flags);
+ return handle_ret.c;
+}
+
+BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer_mem(const bgfx_memory_t* _mem, const bgfx_vertex_layout_t* _layout, uint16_t _flags)
+{
+ const bgfx::VertexLayout& layout = *(const bgfx::VertexLayout*)_layout;
+ union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createDynamicVertexBuffer((const bgfx::Memory*)_mem, layout, _flags);
+ return handle_ret.c;
+}
+
+BGFX_C_API void bgfx_update_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, const bgfx_memory_t* _mem)
+{
+ union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle };
+ bgfx::update(handle.cpp, _startVertex, (const bgfx::Memory*)_mem);
+}
+
+BGFX_C_API void bgfx_destroy_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle)
+{
+ union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle };
+ bgfx::destroy(handle.cpp);
+}
+
+BGFX_C_API uint32_t bgfx_get_avail_transient_index_buffer(uint32_t _num)
+{
+ return bgfx::getAvailTransientIndexBuffer(_num);
+}
+
+BGFX_C_API uint32_t bgfx_get_avail_transient_vertex_buffer(uint32_t _num, const bgfx_vertex_layout_t * _layout)
+{
+ const bgfx::VertexLayout & layout = *(const bgfx::VertexLayout *)_layout;
+ return bgfx::getAvailTransientVertexBuffer(_num, layout);
+}
+
+BGFX_C_API uint32_t bgfx_get_avail_instance_data_buffer(uint32_t _num, uint16_t _stride)
+{
+ return bgfx::getAvailInstanceDataBuffer(_num, _stride);
+}
+
+BGFX_C_API void bgfx_alloc_transient_index_buffer(bgfx_transient_index_buffer_t* _tib, uint32_t _num)
+{
+ bgfx::allocTransientIndexBuffer((bgfx::TransientIndexBuffer*)_tib, _num);
+}
+
+BGFX_C_API void bgfx_alloc_transient_vertex_buffer(bgfx_transient_vertex_buffer_t* _tvb, uint32_t _num, const bgfx_vertex_layout_t * _layout)
+{
+ const bgfx::VertexLayout & layout = *(const bgfx::VertexLayout *)_layout;
+ bgfx::allocTransientVertexBuffer((bgfx::TransientVertexBuffer*)_tvb, _num, layout);
+}
+
+BGFX_C_API bool bgfx_alloc_transient_buffers(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_layout_t * _layout, uint32_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint32_t _numIndices)
+{
+ const bgfx::VertexLayout & layout = *(const bgfx::VertexLayout *)_layout;
+ return bgfx::allocTransientBuffers((bgfx::TransientVertexBuffer*)_tvb, layout, _numVertices, (bgfx::TransientIndexBuffer*)_tib, _numIndices);
+}
+
+BGFX_C_API void bgfx_alloc_instance_data_buffer(bgfx_instance_data_buffer_t* _idb, uint32_t _num, uint16_t _stride)
+{
+ bgfx::allocInstanceDataBuffer((bgfx::InstanceDataBuffer*)_idb, _num, _stride);
+}
+
+BGFX_C_API bgfx_indirect_buffer_handle_t bgfx_create_indirect_buffer(uint32_t _num)
+{
+ union { bgfx_indirect_buffer_handle_t c; bgfx::IndirectBufferHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createIndirectBuffer(_num);
+ return handle_ret.c;
+}
+
+BGFX_C_API void bgfx_destroy_indirect_buffer(bgfx_indirect_buffer_handle_t _handle)
+{
+ union { bgfx_indirect_buffer_handle_t c; bgfx::IndirectBufferHandle cpp; } handle = { _handle };
+ bgfx::destroy(handle.cpp);
+}
+
+BGFX_C_API bgfx_shader_handle_t bgfx_create_shader(const bgfx_memory_t* _mem)
+{
+ union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createShader((const bgfx::Memory*)_mem);
+ return handle_ret.c;
+}
+
+BGFX_C_API uint16_t bgfx_get_shader_uniforms(bgfx_shader_handle_t _handle, bgfx_uniform_handle_t* _uniforms, uint16_t _max)
+{
+ union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } handle = { _handle };
+ return bgfx::getShaderUniforms(handle.cpp, (bgfx::UniformHandle*)_uniforms, _max);
+}
+
+BGFX_C_API void bgfx_set_shader_name(bgfx_shader_handle_t _handle, const char* _name, int32_t _len)
+{
+ union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } handle = { _handle };
+ bgfx::setName(handle.cpp, _name, _len);
+}
+
+BGFX_C_API void bgfx_destroy_shader(bgfx_shader_handle_t _handle)
+{
+ union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } handle = { _handle };
+ bgfx::destroy(handle.cpp);
+}
+
+BGFX_C_API bgfx_program_handle_t bgfx_create_program(bgfx_shader_handle_t _vsh, bgfx_shader_handle_t _fsh, bool _destroyShaders)
+{
+ union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } vsh = { _vsh };
+ union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } fsh = { _fsh };
+ union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createProgram(vsh.cpp, fsh.cpp, _destroyShaders);
+ return handle_ret.c;
+}
+
+BGFX_C_API bgfx_program_handle_t bgfx_create_compute_program(bgfx_shader_handle_t _csh, bool _destroyShaders)
+{
+ union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } csh = { _csh };
+ union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createProgram(csh.cpp, _destroyShaders);
+ return handle_ret.c;
+}
+
+BGFX_C_API void bgfx_destroy_program(bgfx_program_handle_t _handle)
+{
+ union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } handle = { _handle };
+ bgfx::destroy(handle.cpp);
+}
+
+BGFX_C_API bool bgfx_is_texture_valid(uint16_t _depth, bool _cubeMap, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags)
+{
+ return bgfx::isTextureValid(_depth, _cubeMap, _numLayers, (bgfx::TextureFormat::Enum)_format, _flags);
+}
+
+BGFX_C_API void bgfx_calc_texture_size(bgfx_texture_info_t * _info, uint16_t _width, uint16_t _height, uint16_t _depth, bool _cubeMap, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format)
+{
+ bgfx::TextureInfo & info = *(bgfx::TextureInfo *)_info;
+ bgfx::calcTextureSize(info, _width, _height, _depth, _cubeMap, _hasMips, _numLayers, (bgfx::TextureFormat::Enum)_format);
+}
+
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture(const bgfx_memory_t* _mem, uint64_t _flags, uint8_t _skip, bgfx_texture_info_t* _info)
+{
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createTexture((const bgfx::Memory*)_mem, _flags, _skip, (bgfx::TextureInfo*)_info);
+ return handle_ret.c;
+}
+
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d(uint16_t _width, uint16_t _height, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem)
+{
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createTexture2D(_width, _height, _hasMips, _numLayers, (bgfx::TextureFormat::Enum)_format, _flags, (const bgfx::Memory*)_mem);
+ return handle_ret.c;
+}
+
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d_scaled(bgfx_backbuffer_ratio_t _ratio, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags)
+{
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createTexture2D((bgfx::BackbufferRatio::Enum)_ratio, _hasMips, _numLayers, (bgfx::TextureFormat::Enum)_format, _flags);
+ return handle_ret.c;
+}
+
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_3d(uint16_t _width, uint16_t _height, uint16_t _depth, bool _hasMips, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem)
+{
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createTexture3D(_width, _height, _depth, _hasMips, (bgfx::TextureFormat::Enum)_format, _flags, (const bgfx::Memory*)_mem);
+ return handle_ret.c;
+}
+
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_cube(uint16_t _size, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem)
+{
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createTextureCube(_size, _hasMips, _numLayers, (bgfx::TextureFormat::Enum)_format, _flags, (const bgfx::Memory*)_mem);
+ return handle_ret.c;
+}
+
+BGFX_C_API void bgfx_update_texture_2d(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch)
+{
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
+ bgfx::updateTexture2D(handle.cpp, _layer, _mip, _x, _y, _width, _height, (const bgfx::Memory*)_mem, _pitch);
+}
+
+BGFX_C_API void bgfx_update_texture_3d(bgfx_texture_handle_t _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _width, uint16_t _height, uint16_t _depth, const bgfx_memory_t* _mem)
+{
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
+ bgfx::updateTexture3D(handle.cpp, _mip, _x, _y, _z, _width, _height, _depth, (const bgfx::Memory*)_mem);
+}
+
+BGFX_C_API void bgfx_update_texture_cube(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch)
+{
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
+ 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, uint8_t _mip)
+{
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
+ return bgfx::readTexture(handle.cpp, _data, _mip);
+}
+
+BGFX_C_API void bgfx_set_texture_name(bgfx_texture_handle_t _handle, const char* _name, int32_t _len)
+{
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
+ bgfx::setName(handle.cpp, _name, _len);
+}
+
+BGFX_C_API void* bgfx_get_direct_access_ptr(bgfx_texture_handle_t _handle)
+{
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
+ return bgfx::getDirectAccessPtr(handle.cpp);
+}
+
+BGFX_C_API void bgfx_destroy_texture(bgfx_texture_handle_t _handle)
+{
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
+ bgfx::destroy(handle.cpp);
+}
+
+BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer(uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, uint64_t _textureFlags)
+{
+ union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createFrameBuffer(_width, _height, (bgfx::TextureFormat::Enum)_format, _textureFlags);
+ return handle_ret.c;
+}
+
+BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_scaled(bgfx_backbuffer_ratio_t _ratio, bgfx_texture_format_t _format, uint64_t _textureFlags)
+{
+ union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createFrameBuffer((bgfx::BackbufferRatio::Enum)_ratio, (bgfx::TextureFormat::Enum)_format, _textureFlags);
+ return handle_ret.c;
+}
+
+BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_handles(uint8_t _num, const bgfx_texture_handle_t* _handles, bool _destroyTexture)
+{
+ union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createFrameBuffer(_num, (const bgfx::TextureHandle*)_handles, _destroyTexture);
+ return handle_ret.c;
+}
+
+BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_attachment(uint8_t _num, const bgfx_attachment_t* _attachment, bool _destroyTexture)
+{
+ union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createFrameBuffer(_num, (const bgfx::Attachment*)_attachment, _destroyTexture);
+ return handle_ret.c;
+}
+
+BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_nwh(void* _nwh, uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, bgfx_texture_format_t _depthFormat)
+{
+ union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createFrameBuffer(_nwh, _width, _height, (bgfx::TextureFormat::Enum)_format, (bgfx::TextureFormat::Enum)_depthFormat);
+ return handle_ret.c;
+}
+
+BGFX_C_API void bgfx_set_frame_buffer_name(bgfx_frame_buffer_handle_t _handle, const char* _name, int32_t _len)
+{
+ union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle = { _handle };
+ bgfx::setName(handle.cpp, _name, _len);
+}
+
+BGFX_C_API bgfx_texture_handle_t bgfx_get_texture(bgfx_frame_buffer_handle_t _handle, uint8_t _attachment)
+{
+ union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle = { _handle };
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::getTexture(handle.cpp, _attachment);
+ return handle_ret.c;
+}
+
+BGFX_C_API void bgfx_destroy_frame_buffer(bgfx_frame_buffer_handle_t _handle)
+{
+ union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle = { _handle };
+ bgfx::destroy(handle.cpp);
+}
+
+BGFX_C_API bgfx_uniform_handle_t bgfx_create_uniform(const char* _name, bgfx_uniform_type_t _type, uint16_t _num)
+{
+ union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createUniform(_name, (bgfx::UniformType::Enum)_type, _num);
+ return handle_ret.c;
+}
+
+BGFX_C_API void bgfx_get_uniform_info(bgfx_uniform_handle_t _handle, bgfx_uniform_info_t * _info)
+{
+ union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } handle = { _handle };
+ bgfx::UniformInfo & info = *(bgfx::UniformInfo *)_info;
+ bgfx::getUniformInfo(handle.cpp, info);
+}
+
+BGFX_C_API void bgfx_destroy_uniform(bgfx_uniform_handle_t _handle)
+{
+ union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } handle = { _handle };
+ bgfx::destroy(handle.cpp);
+}
+
+BGFX_C_API bgfx_occlusion_query_handle_t bgfx_create_occlusion_query(void)
+{
+ union { bgfx_occlusion_query_handle_t c; bgfx::OcclusionQueryHandle cpp; } handle_ret;
+ handle_ret.cpp = bgfx::createOcclusionQuery();
+ return handle_ret.c;
+}
+
+BGFX_C_API bgfx_occlusion_query_result_t bgfx_get_result(bgfx_occlusion_query_handle_t _handle, int32_t* _result)
+{
+ union { bgfx_occlusion_query_handle_t c; bgfx::OcclusionQueryHandle cpp; } handle = { _handle };
+ return (bgfx_occlusion_query_result_t)bgfx::getResult(handle.cpp, _result);
+}
+
+BGFX_C_API void bgfx_destroy_occlusion_query(bgfx_occlusion_query_handle_t _handle)
+{
+ union { bgfx_occlusion_query_handle_t c; bgfx::OcclusionQueryHandle cpp; } handle = { _handle };
+ bgfx::destroy(handle.cpp);
+}
+
+BGFX_C_API void bgfx_set_palette_color(uint8_t _index, const float _rgba[4])
+{
+ bgfx::setPaletteColor(_index, _rgba);
+}
+
+BGFX_C_API void bgfx_set_palette_color_rgba8(uint8_t _index, uint32_t _rgba)
+{
+ bgfx::setPaletteColor(_index, _rgba);
+}
+
+BGFX_C_API void bgfx_set_view_name(bgfx_view_id_t _id, const char* _name)
+{
+ bgfx::setViewName((bgfx::ViewId)_id, _name);
+}
+
+BGFX_C_API void bgfx_set_view_rect(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
+{
+ bgfx::setViewRect((bgfx::ViewId)_id, _x, _y, _width, _height);
+}
+
+BGFX_C_API void bgfx_set_view_rect_ratio(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, bgfx_backbuffer_ratio_t _ratio)
+{
+ bgfx::setViewRect((bgfx::ViewId)_id, _x, _y, (bgfx::BackbufferRatio::Enum)_ratio);
+}
+
+BGFX_C_API void bgfx_set_view_scissor(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
+{
+ bgfx::setViewScissor((bgfx::ViewId)_id, _x, _y, _width, _height);
+}
+
+BGFX_C_API void bgfx_set_view_clear(bgfx_view_id_t _id, uint16_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil)
+{
+ bgfx::setViewClear((bgfx::ViewId)_id, _flags, _rgba, _depth, _stencil);
+}
+
+BGFX_C_API void bgfx_set_view_clear_mrt(bgfx_view_id_t _id, uint16_t _flags, float _depth, uint8_t _stencil, uint8_t _c0, uint8_t _c1, uint8_t _c2, uint8_t _c3, uint8_t _c4, uint8_t _c5, uint8_t _c6, uint8_t _c7)
+{
+ bgfx::setViewClear((bgfx::ViewId)_id, _flags, _depth, _stencil, _c0, _c1, _c2, _c3, _c4, _c5, _c6, _c7);
+}
+
+BGFX_C_API void bgfx_set_view_mode(bgfx_view_id_t _id, bgfx_view_mode_t _mode)
+{
+ bgfx::setViewMode((bgfx::ViewId)_id, (bgfx::ViewMode::Enum)_mode);
+}
+
+BGFX_C_API void bgfx_set_view_frame_buffer(bgfx_view_id_t _id, bgfx_frame_buffer_handle_t _handle)
+{
+ union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle = { _handle };
+ bgfx::setViewFrameBuffer((bgfx::ViewId)_id, handle.cpp);
+}
+
+BGFX_C_API void bgfx_set_view_transform(bgfx_view_id_t _id, const void* _view, const void* _proj)
+{
+ bgfx::setViewTransform((bgfx::ViewId)_id, _view, _proj);
+}
+
+BGFX_C_API void bgfx_set_view_order(bgfx_view_id_t _id, uint16_t _num, const bgfx_view_id_t* _order)
+{
+ bgfx::setViewOrder((bgfx::ViewId)_id, _num, (const bgfx::ViewId*)_order);
+}
+
+BGFX_C_API bgfx_encoder_t* bgfx_encoder_begin(bool _forThread)
+{
+ return (bgfx_encoder_t*)bgfx::begin(_forThread);
+}
+
+BGFX_C_API void bgfx_encoder_end(bgfx_encoder_t* _encoder)
+{
+ bgfx::end((bgfx::Encoder*)_encoder);
+}
+
+BGFX_C_API void bgfx_encoder_set_marker(bgfx_encoder_t* _this, const char* _marker)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ This->setMarker(_marker);
+}
+
+BGFX_C_API void bgfx_encoder_set_state(bgfx_encoder_t* _this, uint64_t _state, uint32_t _rgba)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ This->setState(_state, _rgba);
+}
+
+BGFX_C_API void bgfx_encoder_set_condition(bgfx_encoder_t* _this, bgfx_occlusion_query_handle_t _handle, bool _visible)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_occlusion_query_handle_t c; bgfx::OcclusionQueryHandle cpp; } handle = { _handle };
+ This->setCondition(handle.cpp, _visible);
+}
+
+BGFX_C_API void bgfx_encoder_set_stencil(bgfx_encoder_t* _this, uint32_t _fstencil, uint32_t _bstencil)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ This->setStencil(_fstencil, _bstencil);
+}
+
+BGFX_C_API uint16_t bgfx_encoder_set_scissor(bgfx_encoder_t* _this, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ return This->setScissor(_x, _y, _width, _height);
+}
+
+BGFX_C_API void bgfx_encoder_set_scissor_cached(bgfx_encoder_t* _this, uint16_t _cache)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ This->setScissor(_cache);
+}
+
+BGFX_C_API uint32_t bgfx_encoder_set_transform(bgfx_encoder_t* _this, const void* _mtx, uint16_t _num)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ return This->setTransform(_mtx, _num);
+}
+
+BGFX_C_API void bgfx_encoder_set_transform_cached(bgfx_encoder_t* _this, uint32_t _cache, uint16_t _num)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ This->setTransform(_cache, _num);
+}
+
+BGFX_C_API uint32_t bgfx_encoder_alloc_transform(bgfx_encoder_t* _this, bgfx_transform_t* _transform, uint16_t _num)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ return This->allocTransform((bgfx::Transform*)_transform, _num);
+}
+
+BGFX_C_API void bgfx_encoder_set_uniform(bgfx_encoder_t* _this, bgfx_uniform_handle_t _handle, const void* _value, uint16_t _num)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } handle = { _handle };
+ This->setUniform(handle.cpp, _value, _num);
+}
+
+BGFX_C_API void bgfx_encoder_set_index_buffer(bgfx_encoder_t* _this, bgfx_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_index_buffer_handle_t c; bgfx::IndexBufferHandle cpp; } handle = { _handle };
+ This->setIndexBuffer(handle.cpp, _firstIndex, _numIndices);
+}
+
+BGFX_C_API void bgfx_encoder_set_dynamic_index_buffer(bgfx_encoder_t* _this, bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle = { _handle };
+ This->setIndexBuffer(handle.cpp, _firstIndex, _numIndices);
+}
+
+BGFX_C_API void bgfx_encoder_set_transient_index_buffer(bgfx_encoder_t* _this, const bgfx_transient_index_buffer_t* _tib, uint32_t _firstIndex, uint32_t _numIndices)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ This->setIndexBuffer((const bgfx::TransientIndexBuffer*)_tib, _firstIndex, _numIndices);
+}
+
+BGFX_C_API void bgfx_encoder_set_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _layoutHandle)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle = { _handle };
+ union { bgfx_vertex_layout_handle_t c; bgfx::VertexLayoutHandle cpp; } layoutHandle = { _layoutHandle };
+ This->setVertexBuffer(_stream, handle.cpp, _startVertex, _numVertices, layoutHandle.cpp);
+}
+
+BGFX_C_API void bgfx_encoder_set_dynamic_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _layoutHandle)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle };
+ union { bgfx_vertex_layout_handle_t c; bgfx::VertexLayoutHandle cpp; } layoutHandle = { _layoutHandle };
+ This->setVertexBuffer(_stream, handle.cpp, _startVertex, _numVertices, layoutHandle.cpp);
+}
+
+BGFX_C_API void bgfx_encoder_set_transient_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _layoutHandle)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_vertex_layout_handle_t c; bgfx::VertexLayoutHandle cpp; } layoutHandle = { _layoutHandle };
+ This->setVertexBuffer(_stream, (const bgfx::TransientVertexBuffer*)_tvb, _startVertex, _numVertices, layoutHandle.cpp);
+}
+
+BGFX_C_API void bgfx_encoder_set_vertex_count(bgfx_encoder_t* _this, uint32_t _numVertices)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ This->setVertexCount(_numVertices);
+}
+
+BGFX_C_API void bgfx_encoder_set_instance_data_buffer(bgfx_encoder_t* _this, const bgfx_instance_data_buffer_t* _idb, uint32_t _start, uint32_t _num)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ This->setInstanceDataBuffer((const bgfx::InstanceDataBuffer*)_idb, _start, _num);
+}
+
+BGFX_C_API void bgfx_encoder_set_instance_data_from_vertex_buffer(bgfx_encoder_t* _this, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle = { _handle };
+ This->setInstanceDataBuffer(handle.cpp, _startVertex, _num);
+}
+
+BGFX_C_API void bgfx_encoder_set_instance_data_from_dynamic_vertex_buffer(bgfx_encoder_t* _this, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle };
+ This->setInstanceDataBuffer(handle.cpp, _startVertex, _num);
+}
+
+BGFX_C_API void bgfx_encoder_set_instance_count(bgfx_encoder_t* _this, uint32_t _numInstances)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ This->setInstanceCount(_numInstances);
+}
+
+BGFX_C_API void bgfx_encoder_set_texture(bgfx_encoder_t* _this, uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint32_t _flags)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } sampler = { _sampler };
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
+ This->setTexture(_stage, sampler.cpp, handle.cpp, _flags);
+}
+
+BGFX_C_API void bgfx_encoder_touch(bgfx_encoder_t* _this, bgfx_view_id_t _id)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ This->touch((bgfx::ViewId)_id);
+}
+
+BGFX_C_API void bgfx_encoder_submit(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _depth, bool _preserveState)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } program = { _program };
+ This->submit((bgfx::ViewId)_id, program.cpp, _depth, _preserveState);
+}
+
+BGFX_C_API void bgfx_encoder_submit_occlusion_query(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_occlusion_query_handle_t _occlusionQuery, uint32_t _depth, bool _preserveState)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } program = { _program };
+ union { bgfx_occlusion_query_handle_t c; bgfx::OcclusionQueryHandle cpp; } occlusionQuery = { _occlusionQuery };
+ This->submit((bgfx::ViewId)_id, program.cpp, occlusionQuery.cpp, _depth, _preserveState);
+}
+
+BGFX_C_API void bgfx_encoder_submit_indirect(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num, uint32_t _depth, bool _preserveState)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } program = { _program };
+ union { bgfx_indirect_buffer_handle_t c; bgfx::IndirectBufferHandle cpp; } indirectHandle = { _indirectHandle };
+ This->submit((bgfx::ViewId)_id, program.cpp, indirectHandle.cpp, _start, _num, _depth, _preserveState);
+}
+
+BGFX_C_API void bgfx_encoder_set_compute_index_buffer(bgfx_encoder_t* _this, uint8_t _stage, bgfx_index_buffer_handle_t _handle, bgfx_access_t _access)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_index_buffer_handle_t c; bgfx::IndexBufferHandle cpp; } handle = { _handle };
+ This->setBuffer(_stage, handle.cpp, (bgfx::Access::Enum)_access);
+}
+
+BGFX_C_API void bgfx_encoder_set_compute_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stage, bgfx_vertex_buffer_handle_t _handle, bgfx_access_t _access)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle = { _handle };
+ This->setBuffer(_stage, handle.cpp, (bgfx::Access::Enum)_access);
+}
+
+BGFX_C_API void bgfx_encoder_set_compute_dynamic_index_buffer(bgfx_encoder_t* _this, uint8_t _stage, bgfx_dynamic_index_buffer_handle_t _handle, bgfx_access_t _access)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle = { _handle };
+ This->setBuffer(_stage, handle.cpp, (bgfx::Access::Enum)_access);
+}
+
+BGFX_C_API void bgfx_encoder_set_compute_dynamic_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stage, bgfx_dynamic_vertex_buffer_handle_t _handle, bgfx_access_t _access)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle };
+ This->setBuffer(_stage, handle.cpp, (bgfx::Access::Enum)_access);
+}
+
+BGFX_C_API void bgfx_encoder_set_compute_indirect_buffer(bgfx_encoder_t* _this, uint8_t _stage, bgfx_indirect_buffer_handle_t _handle, bgfx_access_t _access)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_indirect_buffer_handle_t c; bgfx::IndirectBufferHandle cpp; } handle = { _handle };
+ This->setBuffer(_stage, handle.cpp, (bgfx::Access::Enum)_access);
+}
+
+BGFX_C_API void bgfx_encoder_set_image(bgfx_encoder_t* _this, uint8_t _stage, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_access_t _access, bgfx_texture_format_t _format)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
+ This->setImage(_stage, handle.cpp, _mip, (bgfx::Access::Enum)_access, (bgfx::TextureFormat::Enum)_format);
+}
+
+BGFX_C_API void bgfx_encoder_dispatch(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _numX, uint32_t _numY, uint32_t _numZ)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } program = { _program };
+ This->dispatch((bgfx::ViewId)_id, program.cpp, _numX, _numY, _numZ);
+}
+
+BGFX_C_API void bgfx_encoder_dispatch_indirect(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } program = { _program };
+ union { bgfx_indirect_buffer_handle_t c; bgfx::IndirectBufferHandle cpp; } indirectHandle = { _indirectHandle };
+ This->dispatch((bgfx::ViewId)_id, program.cpp, indirectHandle.cpp, _start, _num);
+}
+
+BGFX_C_API void bgfx_encoder_discard(bgfx_encoder_t* _this)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ This->discard();
+}
+
+BGFX_C_API void bgfx_encoder_blit(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_texture_handle_t _dst, uint8_t _dstMip, uint16_t _dstX, uint16_t _dstY, uint16_t _dstZ, bgfx_texture_handle_t _src, uint8_t _srcMip, uint16_t _srcX, uint16_t _srcY, uint16_t _srcZ, uint16_t _width, uint16_t _height, uint16_t _depth)
+{
+ bgfx::Encoder* This = (bgfx::Encoder*)_this;
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } dst = { _dst };
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } src = { _src };
+ This->blit((bgfx::ViewId)_id, dst.cpp, _dstMip, _dstX, _dstY, _dstZ, src.cpp, _srcMip, _srcX, _srcY, _srcZ, _width, _height, _depth);
+}
+
+BGFX_C_API void bgfx_request_screen_shot(bgfx_frame_buffer_handle_t _handle, const char* _filePath)
+{
+ union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle = { _handle };
+ bgfx::requestScreenShot(handle.cpp, _filePath);
+}
+
+BGFX_C_API bgfx_render_frame_t bgfx_render_frame(int32_t _msecs)
+{
+ return (bgfx_render_frame_t)bgfx::renderFrame(_msecs);
+}
+
+BGFX_C_API void bgfx_set_platform_data(const bgfx_platform_data_t * _data)
+{
+ const bgfx::PlatformData & data = *(const bgfx::PlatformData *)_data;
+ bgfx::setPlatformData(data);
+}
+
+BGFX_C_API const bgfx_internal_data_t* bgfx_get_internal_data(void)
+{
+ return (const bgfx_internal_data_t*)bgfx::getInternalData();
+}
+
+BGFX_C_API uintptr_t bgfx_override_internal_texture_ptr(bgfx_texture_handle_t _handle, uintptr_t _ptr)
+{
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
+ return bgfx::overrideInternal(handle.cpp, _ptr);
+}
+
+BGFX_C_API uintptr_t bgfx_override_internal_texture(bgfx_texture_handle_t _handle, uint16_t _width, uint16_t _height, uint8_t _numMips, bgfx_texture_format_t _format, uint64_t _flags)
+{
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
+ return bgfx::overrideInternal(handle.cpp, _width, _height, _numMips, (bgfx::TextureFormat::Enum)_format, _flags);
+}
+
+BGFX_C_API void bgfx_set_marker(const char* _marker)
+{
+ bgfx::setMarker(_marker);
+}
+
+BGFX_C_API void bgfx_set_state(uint64_t _state, uint32_t _rgba)
+{
+ bgfx::setState(_state, _rgba);
+}
+
+BGFX_C_API void bgfx_set_condition(bgfx_occlusion_query_handle_t _handle, bool _visible)
+{
+ union { bgfx_occlusion_query_handle_t c; bgfx::OcclusionQueryHandle cpp; } handle = { _handle };
+ bgfx::setCondition(handle.cpp, _visible);
+}
+
+BGFX_C_API void bgfx_set_stencil(uint32_t _fstencil, uint32_t _bstencil)
+{
+ bgfx::setStencil(_fstencil, _bstencil);
+}
+
+BGFX_C_API uint16_t bgfx_set_scissor(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
+{
+ return bgfx::setScissor(_x, _y, _width, _height);
+}
+
+BGFX_C_API void bgfx_set_scissor_cached(uint16_t _cache)
+{
+ bgfx::setScissor(_cache);
+}
+
+BGFX_C_API uint32_t bgfx_set_transform(const void* _mtx, uint16_t _num)
+{
+ return bgfx::setTransform(_mtx, _num);
+}
+
+BGFX_C_API void bgfx_set_transform_cached(uint32_t _cache, uint16_t _num)
+{
+ bgfx::setTransform(_cache, _num);
+}
+
+BGFX_C_API uint32_t bgfx_alloc_transform(bgfx_transform_t* _transform, uint16_t _num)
+{
+ return bgfx::allocTransform((bgfx::Transform*)_transform, _num);
+}
+
+BGFX_C_API void bgfx_set_uniform(bgfx_uniform_handle_t _handle, const void* _value, uint16_t _num)
+{
+ union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } handle = { _handle };
+ bgfx::setUniform(handle.cpp, _value, _num);
+}
+
+BGFX_C_API void bgfx_set_index_buffer(bgfx_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices)
+{
+ union { bgfx_index_buffer_handle_t c; bgfx::IndexBufferHandle cpp; } handle = { _handle };
+ bgfx::setIndexBuffer(handle.cpp, _firstIndex, _numIndices);
+}
+
+BGFX_C_API void bgfx_set_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices)
+{
+ union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle = { _handle };
+ bgfx::setIndexBuffer(handle.cpp, _firstIndex, _numIndices);
+}
+
+BGFX_C_API void bgfx_set_transient_index_buffer(const bgfx_transient_index_buffer_t* _tib, uint32_t _firstIndex, uint32_t _numIndices)
+{
+ bgfx::setIndexBuffer((const bgfx::TransientIndexBuffer*)_tib, _firstIndex, _numIndices);
+}
+
+BGFX_C_API void bgfx_set_vertex_buffer(uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices)
+{
+ union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle = { _handle };
+ bgfx::setVertexBuffer(_stream, handle.cpp, _startVertex, _numVertices);
+}
+
+BGFX_C_API void bgfx_set_dynamic_vertex_buffer(uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices)
+{
+ union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle };
+ bgfx::setVertexBuffer(_stream, handle.cpp, _startVertex, _numVertices);
+}
+
+BGFX_C_API void bgfx_set_transient_vertex_buffer(uint8_t _stream, const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices)
+{
+ bgfx::setVertexBuffer(_stream, (const bgfx::TransientVertexBuffer*)_tvb, _startVertex, _numVertices);
+}
+
+BGFX_C_API void bgfx_set_vertex_count(uint32_t _numVertices)
+{
+ bgfx::setVertexCount(_numVertices);
+}
+
+BGFX_C_API void bgfx_set_instance_data_buffer(const bgfx_instance_data_buffer_t* _idb, uint32_t _start, uint32_t _num)
+{
+ bgfx::setInstanceDataBuffer((const bgfx::InstanceDataBuffer*)_idb, _start, _num);
+}
+
+BGFX_C_API void bgfx_set_instance_data_from_vertex_buffer(bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num)
+{
+ union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle = { _handle };
+ bgfx::setInstanceDataBuffer(handle.cpp, _startVertex, _num);
+}
+
+BGFX_C_API void bgfx_set_instance_data_from_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num)
+{
+ union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle };
+ bgfx::setInstanceDataBuffer(handle.cpp, _startVertex, _num);
+}
+
+BGFX_C_API void bgfx_set_instance_count(uint32_t _numInstances)
+{
+ bgfx::setInstanceCount(_numInstances);
+}
+
+BGFX_C_API void bgfx_set_texture(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint32_t _flags)
+{
+ union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } sampler = { _sampler };
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
+ bgfx::setTexture(_stage, sampler.cpp, handle.cpp, _flags);
+}
+
+BGFX_C_API void bgfx_touch(bgfx_view_id_t _id)
+{
+ bgfx::touch((bgfx::ViewId)_id);
+}
+
+BGFX_C_API void bgfx_submit(bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _depth, bool _preserveState)
+{
+ union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } program = { _program };
+ bgfx::submit((bgfx::ViewId)_id, program.cpp, _depth, _preserveState);
+}
+
+BGFX_C_API void bgfx_submit_occlusion_query(bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_occlusion_query_handle_t _occlusionQuery, uint32_t _depth, bool _preserveState)
+{
+ union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } program = { _program };
+ union { bgfx_occlusion_query_handle_t c; bgfx::OcclusionQueryHandle cpp; } occlusionQuery = { _occlusionQuery };
+ bgfx::submit((bgfx::ViewId)_id, program.cpp, occlusionQuery.cpp, _depth, _preserveState);
+}
+
+BGFX_C_API void bgfx_submit_indirect(bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num, uint32_t _depth, bool _preserveState)
+{
+ union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } program = { _program };
+ union { bgfx_indirect_buffer_handle_t c; bgfx::IndirectBufferHandle cpp; } indirectHandle = { _indirectHandle };
+ bgfx::submit((bgfx::ViewId)_id, program.cpp, indirectHandle.cpp, _start, _num, _depth, _preserveState);
+}
+
+BGFX_C_API void bgfx_set_compute_index_buffer(uint8_t _stage, bgfx_index_buffer_handle_t _handle, bgfx_access_t _access)
+{
+ union { bgfx_index_buffer_handle_t c; bgfx::IndexBufferHandle cpp; } handle = { _handle };
+ bgfx::setBuffer(_stage, handle.cpp, (bgfx::Access::Enum)_access);
+}
+
+BGFX_C_API void bgfx_set_compute_vertex_buffer(uint8_t _stage, bgfx_vertex_buffer_handle_t _handle, bgfx_access_t _access)
+{
+ union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle = { _handle };
+ bgfx::setBuffer(_stage, handle.cpp, (bgfx::Access::Enum)_access);
+}
+
+BGFX_C_API void bgfx_set_compute_dynamic_index_buffer(uint8_t _stage, bgfx_dynamic_index_buffer_handle_t _handle, bgfx_access_t _access)
+{
+ union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle = { _handle };
+ bgfx::setBuffer(_stage, handle.cpp, (bgfx::Access::Enum)_access);
+}
+
+BGFX_C_API void bgfx_set_compute_dynamic_vertex_buffer(uint8_t _stage, bgfx_dynamic_vertex_buffer_handle_t _handle, bgfx_access_t _access)
+{
+ union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle };
+ bgfx::setBuffer(_stage, handle.cpp, (bgfx::Access::Enum)_access);
+}
+
+BGFX_C_API void bgfx_set_compute_indirect_buffer(uint8_t _stage, bgfx_indirect_buffer_handle_t _handle, bgfx_access_t _access)
+{
+ union { bgfx_indirect_buffer_handle_t c; bgfx::IndirectBufferHandle cpp; } handle = { _handle };
+ bgfx::setBuffer(_stage, handle.cpp, (bgfx::Access::Enum)_access);
+}
+
+BGFX_C_API void bgfx_set_image(uint8_t _stage, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_access_t _access, bgfx_texture_format_t _format)
+{
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
+ bgfx::setImage(_stage, handle.cpp, _mip, (bgfx::Access::Enum)_access, (bgfx::TextureFormat::Enum)_format);
+}
+
+BGFX_C_API void bgfx_dispatch(bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _numX, uint32_t _numY, uint32_t _numZ)
+{
+ union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } program = { _program };
+ bgfx::dispatch((bgfx::ViewId)_id, program.cpp, _numX, _numY, _numZ);
+}
+
+BGFX_C_API void bgfx_dispatch_indirect(bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num)
+{
+ union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } program = { _program };
+ union { bgfx_indirect_buffer_handle_t c; bgfx::IndirectBufferHandle cpp; } indirectHandle = { _indirectHandle };
+ bgfx::dispatch((bgfx::ViewId)_id, program.cpp, indirectHandle.cpp, _start, _num);
+}
+
+BGFX_C_API void bgfx_discard(void)
+{
+ bgfx::discard();
+}
+
+BGFX_C_API void bgfx_blit(bgfx_view_id_t _id, bgfx_texture_handle_t _dst, uint8_t _dstMip, uint16_t _dstX, uint16_t _dstY, uint16_t _dstZ, bgfx_texture_handle_t _src, uint8_t _srcMip, uint16_t _srcX, uint16_t _srcY, uint16_t _srcZ, uint16_t _width, uint16_t _height, uint16_t _depth)
+{
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } dst = { _dst };
+ union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } src = { _src };
+ bgfx::blit((bgfx::ViewId)_id, dst.cpp, _dstMip, _dstX, _dstY, _dstZ, src.cpp, _srcMip, _srcX, _srcY, _srcZ, _width, _height, _depth);
+}
+
+
+/* user define functions */
+BGFX_C_API void bgfx_init_ctor(bgfx_init_t* _init)
+{
+ BX_PLACEMENT_NEW(_init, bgfx::Init);
+
+}
+
+BGFX_C_API bool bgfx_init(const bgfx_init_t * _init)
+{
+ bgfx_init_t init =*_init;
+
+ if (init.callback != NULL)
+ {
+ static bgfx::CallbackC99 s_callback;
+ s_callback.m_interface = init.callback;
+ init.callback = reinterpret_cast<bgfx_callback_interface_t*>(&s_callback);
+ }
+
+ if (init.allocator != NULL)
+ {
+ static bgfx::AllocatorC99 s_allocator;
+ s_allocator.m_interface = init.allocator;
+ init.allocator = reinterpret_cast<bgfx_allocator_interface_t*>(&s_allocator);
+ }
+
+ union { const bgfx_init_t* c; const bgfx::Init* cpp; } in;
+ in.c = &init;
+
+ return bgfx::init(*in.cpp);
+
+}
+
+/**/
+BGFX_C_API bgfx_interface_vtbl_t* bgfx_get_interface(uint32_t _version)
+{
+ if (_version == BGFX_API_VERSION)
+ {
+ static bgfx_interface_vtbl_t s_bgfx_interface =
+ {
+ bgfx_attachment_init,
+ bgfx_vertex_layout_begin,
+ bgfx_vertex_layout_add,
+ bgfx_vertex_layout_decode,
+ bgfx_vertex_layout_has,
+ bgfx_vertex_layout_skip,
+ bgfx_vertex_layout_end,
+ bgfx_vertex_pack,
+ bgfx_vertex_unpack,
+ bgfx_vertex_convert,
+ bgfx_weld_vertices,
+ bgfx_topology_convert,
+ bgfx_topology_sort_tri_list,
+ bgfx_get_supported_renderers,
+ bgfx_get_renderer_name,
+ bgfx_init_ctor,
+ bgfx_init,
+ bgfx_shutdown,
+ bgfx_reset,
+ bgfx_frame,
+ bgfx_get_renderer_type,
+ bgfx_get_caps,
+ bgfx_get_stats,
+ bgfx_alloc,
+ bgfx_copy,
+ bgfx_make_ref,
+ bgfx_make_ref_release,
+ bgfx_set_debug,
+ bgfx_dbg_text_clear,
+ bgfx_dbg_text_printf,
+ bgfx_dbg_text_vprintf,
+ bgfx_dbg_text_image,
+ bgfx_create_index_buffer,
+ bgfx_set_index_buffer_name,
+ bgfx_destroy_index_buffer,
+ bgfx_create_vertex_layout,
+ bgfx_destroy_vertex_layout,
+ bgfx_create_vertex_buffer,
+ bgfx_set_vertex_buffer_name,
+ bgfx_destroy_vertex_buffer,
+ bgfx_create_dynamic_index_buffer,
+ bgfx_create_dynamic_index_buffer_mem,
+ bgfx_update_dynamic_index_buffer,
+ bgfx_destroy_dynamic_index_buffer,
+ bgfx_create_dynamic_vertex_buffer,
+ bgfx_create_dynamic_vertex_buffer_mem,
+ bgfx_update_dynamic_vertex_buffer,
+ bgfx_destroy_dynamic_vertex_buffer,
+ bgfx_get_avail_transient_index_buffer,
+ bgfx_get_avail_transient_vertex_buffer,
+ bgfx_get_avail_instance_data_buffer,
+ bgfx_alloc_transient_index_buffer,
+ bgfx_alloc_transient_vertex_buffer,
+ bgfx_alloc_transient_buffers,
+ bgfx_alloc_instance_data_buffer,
+ bgfx_create_indirect_buffer,
+ bgfx_destroy_indirect_buffer,
+ bgfx_create_shader,
+ bgfx_get_shader_uniforms,
+ bgfx_set_shader_name,
+ bgfx_destroy_shader,
+ bgfx_create_program,
+ bgfx_create_compute_program,
+ bgfx_destroy_program,
+ bgfx_is_texture_valid,
+ bgfx_calc_texture_size,
+ bgfx_create_texture,
+ bgfx_create_texture_2d,
+ bgfx_create_texture_2d_scaled,
+ bgfx_create_texture_3d,
+ bgfx_create_texture_cube,
+ bgfx_update_texture_2d,
+ bgfx_update_texture_3d,
+ bgfx_update_texture_cube,
+ bgfx_read_texture,
+ bgfx_set_texture_name,
+ bgfx_get_direct_access_ptr,
+ bgfx_destroy_texture,
+ bgfx_create_frame_buffer,
+ bgfx_create_frame_buffer_scaled,
+ bgfx_create_frame_buffer_from_handles,
+ bgfx_create_frame_buffer_from_attachment,
+ bgfx_create_frame_buffer_from_nwh,
+ bgfx_set_frame_buffer_name,
+ bgfx_get_texture,
+ bgfx_destroy_frame_buffer,
+ bgfx_create_uniform,
+ bgfx_get_uniform_info,
+ bgfx_destroy_uniform,
+ bgfx_create_occlusion_query,
+ bgfx_get_result,
+ bgfx_destroy_occlusion_query,
+ bgfx_set_palette_color,
+ bgfx_set_palette_color_rgba8,
+ bgfx_set_view_name,
+ bgfx_set_view_rect,
+ bgfx_set_view_rect_ratio,
+ bgfx_set_view_scissor,
+ bgfx_set_view_clear,
+ bgfx_set_view_clear_mrt,
+ bgfx_set_view_mode,
+ bgfx_set_view_frame_buffer,
+ bgfx_set_view_transform,
+ bgfx_set_view_order,
+ bgfx_encoder_begin,
+ bgfx_encoder_end,
+ bgfx_encoder_set_marker,
+ bgfx_encoder_set_state,
+ bgfx_encoder_set_condition,
+ bgfx_encoder_set_stencil,
+ bgfx_encoder_set_scissor,
+ bgfx_encoder_set_scissor_cached,
+ bgfx_encoder_set_transform,
+ bgfx_encoder_set_transform_cached,
+ bgfx_encoder_alloc_transform,
+ bgfx_encoder_set_uniform,
+ bgfx_encoder_set_index_buffer,
+ bgfx_encoder_set_dynamic_index_buffer,
+ bgfx_encoder_set_transient_index_buffer,
+ bgfx_encoder_set_vertex_buffer,
+ bgfx_encoder_set_dynamic_vertex_buffer,
+ bgfx_encoder_set_transient_vertex_buffer,
+ bgfx_encoder_set_vertex_count,
+ bgfx_encoder_set_instance_data_buffer,
+ bgfx_encoder_set_instance_data_from_vertex_buffer,
+ bgfx_encoder_set_instance_data_from_dynamic_vertex_buffer,
+ bgfx_encoder_set_instance_count,
+ bgfx_encoder_set_texture,
+ bgfx_encoder_touch,
+ bgfx_encoder_submit,
+ bgfx_encoder_submit_occlusion_query,
+ bgfx_encoder_submit_indirect,
+ bgfx_encoder_set_compute_index_buffer,
+ bgfx_encoder_set_compute_vertex_buffer,
+ bgfx_encoder_set_compute_dynamic_index_buffer,
+ bgfx_encoder_set_compute_dynamic_vertex_buffer,
+ bgfx_encoder_set_compute_indirect_buffer,
+ bgfx_encoder_set_image,
+ bgfx_encoder_dispatch,
+ bgfx_encoder_dispatch_indirect,
+ bgfx_encoder_discard,
+ bgfx_encoder_blit,
+ bgfx_request_screen_shot,
+ bgfx_render_frame,
+ bgfx_set_platform_data,
+ bgfx_get_internal_data,
+ bgfx_override_internal_texture_ptr,
+ bgfx_override_internal_texture,
+ bgfx_set_marker,
+ bgfx_set_state,
+ bgfx_set_condition,
+ bgfx_set_stencil,
+ bgfx_set_scissor,
+ bgfx_set_scissor_cached,
+ bgfx_set_transform,
+ bgfx_set_transform_cached,
+ bgfx_alloc_transform,
+ bgfx_set_uniform,
+ bgfx_set_index_buffer,
+ bgfx_set_dynamic_index_buffer,
+ bgfx_set_transient_index_buffer,
+ bgfx_set_vertex_buffer,
+ bgfx_set_dynamic_vertex_buffer,
+ bgfx_set_transient_vertex_buffer,
+ bgfx_set_vertex_count,
+ bgfx_set_instance_data_buffer,
+ bgfx_set_instance_data_from_vertex_buffer,
+ bgfx_set_instance_data_from_dynamic_vertex_buffer,
+ bgfx_set_instance_count,
+ bgfx_set_texture,
+ bgfx_touch,
+ bgfx_submit,
+ bgfx_submit_occlusion_query,
+ bgfx_submit_indirect,
+ bgfx_set_compute_index_buffer,
+ bgfx_set_compute_vertex_buffer,
+ bgfx_set_compute_dynamic_index_buffer,
+ bgfx_set_compute_dynamic_vertex_buffer,
+ bgfx_set_compute_indirect_buffer,
+ bgfx_set_image,
+ bgfx_dispatch,
+ bgfx_dispatch_indirect,
+ bgfx_discard,
+ bgfx_blit
+ };
+
+ return &s_bgfx_interface;
+ }
+
+ return NULL;
+}
diff --git a/3rdparty/bgfx/src/bgfx_compute.sh b/3rdparty/bgfx/src/bgfx_compute.sh
index 05eefd88713..f7ebb3758f3 100644
--- a/3rdparty/bgfx/src/bgfx_compute.sh
+++ b/3rdparty/bgfx/src/bgfx_compute.sh
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -11,6 +11,20 @@
#ifndef __cplusplus
#if BGFX_SHADER_LANGUAGE_GLSL
+# define FRAMEBUFFER_IMAGE2D_RW_0(_name, _format) IMAGE2D_RW(_name, _format, 4)
+# define FRAMEBUFFER_IMAGE2D_RW_1(_name, _format) IMAGE2D_RW(_name, _format, 5)
+# define FRAMEBUFFER_IMAGE2D_RW_2(_name, _format) IMAGE2D_RW(_name, _format, 6)
+# define FRAMEBUFFER_IMAGE2D_RW_3(_name, _format) IMAGE2D_RW(_name, _format, 7)
+#else
+# define FRAMEBUFFER_IMAGE2D_RW_0(_name, _format) IMAGE2D_RW(_name, _format, 16)
+# define FRAMEBUFFER_IMAGE2D_RW_1(_name, _format) IMAGE2D_RW(_name, _format, 17)
+# define FRAMEBUFFER_IMAGE2D_RW_2(_name, _format) IMAGE2D_RW(_name, _format, 18)
+# define FRAMEBUFFER_IMAGE2D_RW_3(_name, _format) IMAGE2D_RW(_name, _format, 19)
+#endif // BGFX_SHADER_LANGUAGE_GLSL
+
+#define FRAMEBUFFER_IMAGE2D_RW(_name, _format, _reg) FRAMEBUFFER_IMAGE2D_RW_ ## _reg(_name, _format)
+
+#if BGFX_SHADER_LANGUAGE_GLSL
#define SHARED shared
@@ -68,12 +82,17 @@
#define rg32ui uint2
#define rgba32ui uint4
#define r32f float
+#define r16f float
#define rg16f float2
#define rgba16f float4
#if BGFX_SHADER_LANGUAGE_HLSL
# define rgba8 unorm float4
+# define rg8 unorm float2
+# define r8 unorm float
#else
# define rgba8 float4
+# define rg8 float2
+# define r8 float
#endif // BGFX_SHADER_LANGUAGE_HLSL
#define rgba32f float4
@@ -119,9 +138,15 @@
#define IMAGE3D_WR( _name, _format, _reg) IMAGE3D_RW(_name, _format, _reg)
#define UIMAGE3D_WR(_name, _format, _reg) IMAGE3D_RW(_name, _format, _reg)
+#if BGFX_SHADER_LANGUAGE_METAL || BGFX_SHADER_LANGUAGE_SPIRV
+#define BUFFER_RO(_name, _struct, _reg) StructuredBuffer<_struct> _name : REGISTER(t, _reg)
+#define BUFFER_RW(_name, _struct, _reg) RWStructuredBuffer <_struct> _name : REGISTER(u, _reg)
+#define BUFFER_WR(_name, _struct, _reg) BUFFER_RW(_name, _struct, _reg)
+#else
#define BUFFER_RO(_name, _struct, _reg) Buffer<_struct> _name : REGISTER(t, _reg)
#define BUFFER_RW(_name, _struct, _reg) RWBuffer<_struct> _name : REGISTER(u, _reg)
#define BUFFER_WR(_name, _struct, _reg) BUFFER_RW(_name, _struct, _reg)
+#endif
#define NUM_THREADS(_x, _y, _z) [numthreads(_x, _y, _z)]
@@ -247,12 +272,24 @@
_image.m_texture[_uvw] = _value._storeComponents; \
}
+#define __IMAGE_IMPL_ATOMIC(_format, _storeComponents, _type, _loadComponents) \
+ \
+ void imageAtomicAdd(BgfxRWImage2D_ ## _format _image, ivec2 _uv, _type _value) \
+ { \
+ InterlockedAdd(_image.m_texture[_uv], _value._storeComponents); \
+ } \
+
+
__IMAGE_IMPL_A(rgba8, xyzw, vec4, xyzw)
+__IMAGE_IMPL_A(rg8, xy, vec4, xyyy)
+__IMAGE_IMPL_A(r8, x, vec4, xxxx)
__IMAGE_IMPL_A(rg16f, xy, vec4, xyyy)
#if BGFX_SHADER_LANGUAGE_HLSL
__IMAGE_IMPL_S(rgba16f, xyzw, vec4, xyzw)
+__IMAGE_IMPL_S(r16f, x, vec4, xxxx)
#else
__IMAGE_IMPL_A(rgba16f, xyzw, vec4, xyzw)
+__IMAGE_IMPL_A(r16f, x, vec4, xxxx)
#endif // BGFX_SHADER_LANGUAGE_HLSL
__IMAGE_IMPL_A(r32f, x, vec4, xxxx)
__IMAGE_IMPL_A(rgba32f, xyzw, vec4, xyzw)
@@ -260,6 +297,8 @@ __IMAGE_IMPL_A(r32ui, x, uvec4, xxxx)
__IMAGE_IMPL_A(rg32ui, xy, uvec4, xyyy)
__IMAGE_IMPL_A(rgba32ui, xyzw, uvec4, xyzw)
+__IMAGE_IMPL_ATOMIC(r32ui, x, uvec4, xxxx)
+
#define atomicAdd(_mem, _data) InterlockedAdd(_mem, _data)
#define atomicAnd(_mem, _data) InterlockedAnd(_mem, _data)
#define atomicMax(_mem, _data) InterlockedMax(_mem, _data)
diff --git a/3rdparty/bgfx/src/bgfx_p.h b/3rdparty/bgfx/src/bgfx_p.h
index f6dfc434b19..2e422bf6542 100644
--- a/3rdparty/bgfx/src/bgfx_p.h
+++ b/3rdparty/bgfx/src/bgfx_p.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -25,24 +25,24 @@
#include <inttypes.h>
// Check handle, cannot be bgfx::kInvalidHandle and must be valid.
-#define BGFX_CHECK_HANDLE(_desc, _handleAlloc, _handle) \
- BX_CHECK(isValid(_handle) \
- && _handleAlloc.isValid(_handle.idx) \
- , "Invalid handle. %s handle: %d (max %d)" \
- , _desc \
- , _handle.idx \
- , _handleAlloc.getMaxHandles() \
- )
+#define BGFX_CHECK_HANDLE(_desc, _handleAlloc, _handle) \
+ BX_CHECK(isValid(_handle) \
+ && _handleAlloc.isValid(_handle.idx) \
+ , "Invalid handle. %s handle: %d (max %d)" \
+ , _desc \
+ , _handle.idx \
+ , _handleAlloc.getMaxHandles() \
+ )
// Check handle, it's ok to be bgfx::kInvalidHandle or must be valid.
#define BGFX_CHECK_HANDLE_INVALID_OK(_desc, _handleAlloc, _handle) \
- BX_CHECK(!isValid(_handle) \
- || _handleAlloc.isValid(_handle.idx) \
- , "Invalid handle. %s handle: %d (max %d)" \
- , _desc \
- , _handle.idx \
- , _handleAlloc.getMaxHandles() \
- )
+ BX_CHECK(!isValid(_handle) \
+ || _handleAlloc.isValid(_handle.idx) \
+ , "Invalid handle. %s handle: %d (max %d)" \
+ , _desc \
+ , _handle.idx \
+ , _handleAlloc.getMaxHandles() \
+ )
#if BGFX_CONFIG_MULTITHREADED
# define BGFX_MUTEX_SCOPE(_mutex) bx::MutexScope BX_CONCATENATE(mutexScope, __LINE__)(_mutex)
@@ -51,14 +51,16 @@
#endif // BGFX_CONFIG_MULTITHREADED
#if BGFX_CONFIG_PROFILER
-# define BGFX_PROFILER_SCOPE(_name, _abgr) ProfilerScope BX_CONCATENATE(profilerScope, __LINE__)(_name, _abgr, __FILE__, uint16_t(__LINE__) )
-# define BGFX_PROFILER_BEGIN(_name, _abgr) g_callback->profilerBeginLiteral(_name, _abgr, __FILE__, uint16_t(__LINE__) )
-# define BGFX_PROFILER_END() g_callback->profilerEnd()
+# define BGFX_PROFILER_SCOPE(_name, _abgr) ProfilerScope BX_CONCATENATE(profilerScope, __LINE__)(_name, _abgr, __FILE__, uint16_t(__LINE__) )
+# define BGFX_PROFILER_BEGIN(_name, _abgr) g_callback->profilerBegin(_name, _abgr, __FILE__, uint16_t(__LINE__) )
+# define BGFX_PROFILER_BEGIN_LITERAL(_name, _abgr) g_callback->profilerBeginLiteral(_name, _abgr, __FILE__, uint16_t(__LINE__) )
+# define BGFX_PROFILER_END() g_callback->profilerEnd()
# define BGFX_PROFILER_SET_CURRENT_THREAD_NAME(_name) BX_NOOP()
#else
-# define BGFX_PROFILER_SCOPE(_name, _abgr) BX_NOOP()
-# define BGFX_PROFILER_BEGIN(_name, _abgr) BX_NOOP()
-# define BGFX_PROFILER_END() BX_NOOP()
+# define BGFX_PROFILER_SCOPE(_name, _abgr) BX_NOOP()
+# define BGFX_PROFILER_BEGIN(_name, _abgr) BX_NOOP()
+# define BGFX_PROFILER_BEGIN_LITERAL(_name, _abgr) BX_NOOP()
+# define BGFX_PROFILER_END() BX_NOOP()
# define BGFX_PROFILER_SET_CURRENT_THREAD_NAME(_name) BX_NOOP()
#endif // BGFX_PROFILER_SCOPE
@@ -72,7 +74,7 @@ namespace bgfx
void trace(const char* _filePath, uint16_t _line, const char* _format, ...);
- inline bool operator==(const VertexDeclHandle& _lhs, const VertexDeclHandle& _rhs) { return _lhs.idx == _rhs.idx; }
+ inline bool operator==(const VertexLayoutHandle& _lhs, const VertexLayoutHandle& _rhs) { return _lhs.idx == _rhs.idx; }
inline bool operator==(const UniformHandle& _lhs, const UniformHandle& _rhs) { return _lhs.idx == _rhs.idx; }
}
@@ -213,14 +215,16 @@ namespace stl = std;
#define BGFX_STATE_INTERNAL_SCISSOR UINT64_C(0x2000000000000000)
#define BGFX_STATE_INTERNAL_OCCLUSION_QUERY UINT64_C(0x4000000000000000)
+#define BGFX_SUBMIT_RESERVED_MASK UINT8_C(0xff)
#define BGFX_SUBMIT_INTERNAL_OCCLUSION_VISIBLE UINT8_C(0x80)
#define BGFX_RENDERER_DIRECT3D9_NAME "Direct3D 9"
#define BGFX_RENDERER_DIRECT3D11_NAME "Direct3D 11"
#define BGFX_RENDERER_DIRECT3D12_NAME "Direct3D 12"
+#define BGFX_RENDERER_GNM_NAME "GNM"
#define BGFX_RENDERER_METAL_NAME "Metal"
+#define BGFX_RENDERER_NVN_NAME "NVN"
#define BGFX_RENDERER_VULKAN_NAME "Vulkan"
-#define BGFX_RENDERER_GNM_NAME "GNM"
#define BGFX_RENDERER_NOOP_NAME "Noop"
#if BGFX_CONFIG_RENDERER_OPENGL
@@ -232,7 +236,7 @@ namespace stl = std;
# else
# define BGFX_RENDERER_OPENGL_NAME "OpenGL 3.3"
# endif // 31+
-# elif BGFX_CONFIG_RENDERER_OPENGL >= 40 && BGFX_CONFIG_RENDERER_OPENGL <= 45
+# elif BGFX_CONFIG_RENDERER_OPENGL >= 40 && BGFX_CONFIG_RENDERER_OPENGL <= 46
# if BGFX_CONFIG_RENDERER_OPENGL == 40
# define BGFX_RENDERER_OPENGL_NAME "OpenGL 4.0"
# elif BGFX_CONFIG_RENDERER_OPENGL == 41
@@ -243,8 +247,10 @@ namespace stl = std;
# define BGFX_RENDERER_OPENGL_NAME "OpenGL 4.3"
# elif BGFX_CONFIG_RENDERER_OPENGL == 44
# define BGFX_RENDERER_OPENGL_NAME "OpenGL 4.4"
-# else
+# elif BGFX_CONFIG_RENDERER_OPENGL == 45
# define BGFX_RENDERER_OPENGL_NAME "OpenGL 4.5"
+# else
+# define BGFX_RENDERER_OPENGL_NAME "OpenGL 4.6"
# endif // 40+
# else
# define BGFX_RENDERER_OPENGL_NAME "OpenGL 2.1"
@@ -252,8 +258,10 @@ namespace stl = std;
#elif BGFX_CONFIG_RENDERER_OPENGLES
# if BGFX_CONFIG_RENDERER_OPENGLES == 30
# define BGFX_RENDERER_OPENGL_NAME "OpenGL ES 3.0"
-# elif BGFX_CONFIG_RENDERER_OPENGLES >= 31
+# elif BGFX_CONFIG_RENDERER_OPENGLES == 31
# define BGFX_RENDERER_OPENGL_NAME "OpenGL ES 3.1"
+# elif BGFX_CONFIG_RENDERER_OPENGLES >= 32
+# define BGFX_RENDERER_OPENGL_NAME "OpenGL ES 3.2"
# else
# define BGFX_RENDERER_OPENGL_NAME "OpenGL ES 2.0"
# endif // BGFX_CONFIG_RENDERER_OPENGLES
@@ -277,8 +285,10 @@ namespace bgfx
{
enum Enum
{
+ IndexBuffer,
Shader,
Texture,
+ VertexBuffer,
Count
};
@@ -287,21 +297,25 @@ namespace bgfx
uint16_t idx;
};
- inline Handle convert(ShaderHandle _handle)
- {
- Handle handle = { Handle::Shader, _handle.idx };
- return handle;
+#define CONVERT_HANDLE(_name) \
+ inline Handle convert(_name##Handle _handle) \
+ { \
+ Handle handle = { Handle::_name, _handle.idx }; \
+ return handle; \
}
- inline Handle convert(TextureHandle _handle)
- {
- Handle handle = { Handle::Texture, _handle.idx };
- return handle;
- }
+ CONVERT_HANDLE(IndexBuffer);
+ CONVERT_HANDLE(Shader);
+ CONVERT_HANDLE(Texture);
+ CONVERT_HANDLE(VertexBuffer);
+
+#undef CONVERT_HANDLE
- inline bool isValid(const VertexDecl& _decl)
+ const char* getTypeName(Handle _handle);
+
+ inline bool isValid(const VertexLayout& _layout)
{
- return 0 != _decl.m_stride;
+ return 0 != _layout.m_stride;
}
struct Condition
@@ -507,7 +521,7 @@ namespace bgfx
return uint32_t( (_stencil >> (32*_0or1) ) );
}
- inline bool needBorderColor(uint32_t _flags)
+ inline bool needBorderColor(uint64_t _flags)
{
return BGFX_SAMPLER_U_BORDER == (_flags & BGFX_SAMPLER_U_BORDER)
|| BGFX_SAMPLER_V_BORDER == (_flags & BGFX_SAMPLER_V_BORDER)
@@ -528,8 +542,8 @@ namespace bgfx
return 1;
}
- /// Dump vertex declaration into debug output.
- void dump(const VertexDecl& _decl);
+ /// Dump vertex layout into debug output.
+ void dump(const VertexLayout& _layout);
struct TextVideoMem
{
@@ -643,7 +657,7 @@ namespace bgfx
TextureHandle m_texture;
TransientVertexBuffer* m_vb;
TransientIndexBuffer* m_ib;
- VertexDecl m_decl;
+ VertexLayout m_layout;
ProgramHandle m_program;
};
@@ -712,8 +726,8 @@ namespace bgfx
void init();
void shutdown();
- TransientVertexBuffer* m_vb;
- VertexDecl m_decl;
+ VertexBufferHandle m_vb;
+ VertexLayout m_layout;
ProgramHandle m_program[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
};
@@ -765,7 +779,7 @@ namespace bgfx
{
RendererInit,
RendererShutdownBegin,
- CreateVertexDecl,
+ CreateVertexLayout,
CreateIndexBuffer,
CreateVertexBuffer,
CreateDynamicIndexBuffer,
@@ -784,7 +798,7 @@ namespace bgfx
SetName,
End,
RendererShutdownEnd,
- DestroyVertexDecl,
+ DestroyVertexLayout,
DestroyIndexBuffer,
DestroyVertexBuffer,
DestroyDynamicIndexBuffer,
@@ -801,7 +815,12 @@ namespace bgfx
void write(const void* _data, uint32_t _size)
{
BX_CHECK(m_size == BGFX_CONFIG_MAX_COMMAND_BUFFER_SIZE, "Called write outside start/finish?");
- BX_CHECK(m_pos < m_size, "CommandBuffer::write error (pos: %d, size: %d).", m_pos, m_size);
+ BX_CHECK(m_pos + _size <= m_size
+ , "CommandBuffer::write error (pos: %d-%d, size: %d)."
+ , m_pos
+ , m_pos + _size
+ , m_size
+ );
bx::memCopy(&m_buffer[m_pos], _data, _size);
m_pos += _size;
}
@@ -815,7 +834,12 @@ namespace bgfx
void read(void* _data, uint32_t _size)
{
- BX_CHECK(m_pos < m_size, "CommandBuffer::read error (pos: %d, size: %d).", m_pos, m_size);
+ BX_CHECK(m_pos + _size <= m_size
+ , "CommandBuffer::read error (pos: %d-%d, size: %d)."
+ , m_pos
+ , m_pos + _size
+ , m_size
+ );
bx::memCopy(_data, &m_buffer[m_pos], _size);
m_pos += _size;
}
@@ -829,7 +853,12 @@ namespace bgfx
const uint8_t* skip(uint32_t _size)
{
- BX_CHECK(m_pos < m_size, "CommandBuffer::skip error (pos: %d, size: %d).", m_pos, m_size);
+ BX_CHECK(m_pos + _size <= m_size
+ , "CommandBuffer::skip error (pos: %d-%d, size: %d)."
+ , m_pos
+ , m_pos + _size
+ , m_size
+ );
const uint8_t* result = &m_buffer[m_pos];
m_pos += _size;
return result;
@@ -874,120 +903,118 @@ namespace bgfx
};
//
-#define SORT_KEY_NUM_BITS_VIEW 10
+constexpr uint8_t kSortKeyViewNumBits = 10;
+constexpr uint8_t kSortKeyViewBitShift = 64-kSortKeyViewNumBits;
+constexpr uint64_t kSortKeyViewMask = uint64_t(BGFX_CONFIG_MAX_VIEWS-1)<<kSortKeyViewBitShift;
-#define SORT_KEY_VIEW_SHIFT (64-SORT_KEY_NUM_BITS_VIEW)
-#define SORT_KEY_VIEW_MASK ( (uint64_t(BGFX_CONFIG_MAX_VIEWS-1) )<<SORT_KEY_VIEW_SHIFT)
-
-#define SORT_KEY_DRAW_BIT_SHIFT (SORT_KEY_VIEW_SHIFT - 1)
-#define SORT_KEY_DRAW_BIT (UINT64_C(1)<<SORT_KEY_DRAW_BIT_SHIFT)
+constexpr uint8_t kSortKeyDrawBitShift = kSortKeyViewBitShift - 1;
+constexpr uint64_t kSortKeyDrawBit = uint64_t(1)<<kSortKeyDrawBitShift;
//
-#define SORT_KEY_NUM_BITS_DRAW_TYPE 2
-
-#define SORT_KEY_DRAW_TYPE_BIT_SHIFT (SORT_KEY_DRAW_BIT_SHIFT - SORT_KEY_NUM_BITS_DRAW_TYPE)
-#define SORT_KEY_DRAW_TYPE_MASK (UINT64_C(3)<<SORT_KEY_DRAW_TYPE_BIT_SHIFT)
+constexpr uint8_t kSortKeyDrawTypeNumBits = 2;
+constexpr uint8_t kSortKeyDrawTypeBitShift = kSortKeyDrawBitShift - kSortKeyDrawTypeNumBits;
+constexpr uint64_t kSortKeyDrawTypeMask = uint64_t(3)<<kSortKeyDrawTypeBitShift;
-#define SORT_KEY_DRAW_TYPE_PROGRAM (UINT64_C(0)<<SORT_KEY_DRAW_TYPE_BIT_SHIFT)
-#define SORT_KEY_DRAW_TYPE_DEPTH (UINT64_C(1)<<SORT_KEY_DRAW_TYPE_BIT_SHIFT)
-#define SORT_KEY_DRAW_TYPE_SEQUENCE (UINT64_C(2)<<SORT_KEY_DRAW_TYPE_BIT_SHIFT)
+constexpr uint64_t kSortKeyDrawTypeProgram = uint64_t(0)<<kSortKeyDrawTypeBitShift;
+constexpr uint64_t kSortKeyDrawTypeDepth = uint64_t(1)<<kSortKeyDrawTypeBitShift;
+constexpr uint64_t kSortKeyDrawTypeSequence = uint64_t(2)<<kSortKeyDrawTypeBitShift;
//
-#define SORT_KEY_NUM_BITS_TRANS 2
+constexpr uint8_t kSortKeyTransNumBits = 2;
-#define SORT_KEY_DRAW_0_TRANS_SHIFT (SORT_KEY_DRAW_TYPE_BIT_SHIFT - SORT_KEY_NUM_BITS_TRANS)
-#define SORT_KEY_DRAW_0_TRANS_MASK (UINT64_C(0x3)<<SORT_KEY_DRAW_0_TRANS_SHIFT)
+constexpr uint8_t kSortKeyDraw0TransShift = kSortKeyDrawTypeBitShift - kSortKeyTransNumBits;
+constexpr uint64_t kSortKeyDraw0TransMask = uint64_t(0x3)<<kSortKeyDraw0TransShift;
-#define SORT_KEY_DRAW_0_PROGRAM_SHIFT (SORT_KEY_DRAW_0_TRANS_SHIFT - BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM)
-#define SORT_KEY_DRAW_0_PROGRAM_MASK ( (uint64_t(BGFX_CONFIG_MAX_PROGRAMS-1) )<<SORT_KEY_DRAW_0_PROGRAM_SHIFT)
+constexpr uint8_t kSortKeyDraw0ProgramShift = kSortKeyDraw0TransShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM;
+constexpr uint64_t kSortKeyDraw0ProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRAMS-1)<<kSortKeyDraw0ProgramShift;
-#define SORT_KEY_DRAW_0_DEPTH_SHIFT (SORT_KEY_DRAW_0_PROGRAM_SHIFT - BGFX_CONFIG_SORT_KEY_NUM_BITS_DEPTH)
-#define SORT_KEY_DRAW_0_DEPTH_MASK ( ( (UINT64_C(1)<<BGFX_CONFIG_SORT_KEY_NUM_BITS_DEPTH)-1)<<SORT_KEY_DRAW_0_DEPTH_SHIFT)
+constexpr uint8_t kSortKeyDraw0DepthShift = kSortKeyDraw0ProgramShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_DEPTH;
+constexpr uint64_t kSortKeyDraw0DepthMask = ( (uint64_t(1)<<BGFX_CONFIG_SORT_KEY_NUM_BITS_DEPTH)-1)<<kSortKeyDraw0DepthShift;
//
-#define SORT_KEY_DRAW_1_DEPTH_SHIFT (SORT_KEY_DRAW_TYPE_BIT_SHIFT - BGFX_CONFIG_SORT_KEY_NUM_BITS_DEPTH)
-#define SORT_KEY_DRAW_1_DEPTH_MASK ( ( (UINT64_C(1)<<BGFX_CONFIG_SORT_KEY_NUM_BITS_DEPTH)-1)<<SORT_KEY_DRAW_1_DEPTH_SHIFT)
+constexpr uint8_t kSortKeyDraw1DepthShift = kSortKeyDrawTypeBitShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_DEPTH;
+constexpr uint64_t kSortKeyDraw1DepthMask = ( (uint64_t(1)<<BGFX_CONFIG_SORT_KEY_NUM_BITS_DEPTH)-1)<<kSortKeyDraw1DepthShift;
-#define SORT_KEY_DRAW_1_TRANS_SHIFT (SORT_KEY_DRAW_1_DEPTH_SHIFT - SORT_KEY_NUM_BITS_TRANS)
-#define SORT_KEY_DRAW_1_TRANS_MASK (UINT64_C(0x3)<<SORT_KEY_DRAW_1_TRANS_SHIFT)
+constexpr uint8_t kSortKeyDraw1TransShift = kSortKeyDraw1DepthShift - kSortKeyTransNumBits;
+constexpr uint64_t kSortKeyDraw1TransMask = uint64_t(0x3)<<kSortKeyDraw1TransShift;
-#define SORT_KEY_DRAW_1_PROGRAM_SHIFT (SORT_KEY_DRAW_1_TRANS_SHIFT - BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM)
-#define SORT_KEY_DRAW_1_PROGRAM_MASK ( (uint64_t(BGFX_CONFIG_MAX_PROGRAMS-1) )<<SORT_KEY_DRAW_1_PROGRAM_SHIFT)
+constexpr uint8_t kSortKeyDraw1ProgramShift = kSortKeyDraw1TransShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM;
+constexpr uint64_t kSortKeyDraw1ProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRAMS-1)<<kSortKeyDraw1ProgramShift;
//
-#define SORT_KEY_DRAW_2_SEQ_SHIFT (SORT_KEY_DRAW_TYPE_BIT_SHIFT - BGFX_CONFIG_SORT_KEY_NUM_BITS_SEQ)
-#define SORT_KEY_DRAW_2_SEQ_MASK ( ( (UINT64_C(1)<<BGFX_CONFIG_SORT_KEY_NUM_BITS_SEQ)-1)<<SORT_KEY_DRAW_2_SEQ_SHIFT)
+constexpr uint8_t kSortKeyDraw2SeqShift = kSortKeyDrawTypeBitShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_SEQ;
+constexpr uint64_t kSortKeyDraw2SeqMask = ( (uint64_t(1)<<BGFX_CONFIG_SORT_KEY_NUM_BITS_SEQ)-1)<<kSortKeyDraw2SeqShift;
-#define SORT_KEY_DRAW_2_TRANS_SHIFT (SORT_KEY_DRAW_2_SEQ_SHIFT - SORT_KEY_NUM_BITS_TRANS)
-#define SORT_KEY_DRAW_2_TRANS_MASK (UINT64_C(0x3)<<SORT_KEY_DRAW_2_TRANS_SHIFT)
+constexpr uint8_t kSortKeyDraw2TransShift = kSortKeyDraw2SeqShift - kSortKeyTransNumBits;
+constexpr uint64_t kSortKeyDraw2TransMask = uint64_t(0x3)<<kSortKeyDraw2TransShift;
-#define SORT_KEY_DRAW_2_PROGRAM_SHIFT (SORT_KEY_DRAW_2_TRANS_SHIFT - BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM)
-#define SORT_KEY_DRAW_2_PROGRAM_MASK ( (uint64_t(BGFX_CONFIG_MAX_PROGRAMS-1) )<<SORT_KEY_DRAW_2_PROGRAM_SHIFT)
+constexpr uint8_t kSortKeyDraw2ProgramShift = kSortKeyDraw2TransShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM;
+constexpr uint64_t kSortKeyDraw2ProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRAMS-1)<<kSortKeyDraw2ProgramShift;
//
-#define SORT_KEY_COMPUTE_SEQ_SHIFT (SORT_KEY_DRAW_BIT_SHIFT - BGFX_CONFIG_SORT_KEY_NUM_BITS_SEQ)
-#define SORT_KEY_COMPUTE_SEQ_MASK ( ( (UINT64_C(1)<<BGFX_CONFIG_SORT_KEY_NUM_BITS_SEQ)-1)<<SORT_KEY_COMPUTE_SEQ_SHIFT)
+constexpr uint8_t kSortKeyComputeSeqShift = kSortKeyDrawBitShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_SEQ;
+constexpr uint64_t kSortKeyComputeSeqMask = ( (uint64_t(1)<<BGFX_CONFIG_SORT_KEY_NUM_BITS_SEQ)-1)<<kSortKeyComputeSeqShift;
-#define SORT_KEY_COMPUTE_PROGRAM_SHIFT (SORT_KEY_COMPUTE_SEQ_SHIFT - BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM)
-#define SORT_KEY_COMPUTE_PROGRAM_MASK ( (uint64_t(BGFX_CONFIG_MAX_PROGRAMS-1) )<<SORT_KEY_COMPUTE_PROGRAM_SHIFT)
+constexpr uint8_t kSortKeyComputeProgramShift = kSortKeyComputeSeqShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM;
+constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRAMS-1)<<kSortKeyComputeProgramShift;
- BX_STATIC_ASSERT(BGFX_CONFIG_MAX_VIEWS <= (1<<SORT_KEY_NUM_BITS_VIEW) );
+ BX_STATIC_ASSERT(BGFX_CONFIG_MAX_VIEWS <= (1<<kSortKeyViewNumBits) );
BX_STATIC_ASSERT( (BGFX_CONFIG_MAX_PROGRAMS & (BGFX_CONFIG_MAX_PROGRAMS-1) ) == 0); // Must be power of 2.
BX_STATIC_ASSERT( (0 // Render key mask shouldn't overlap.
- | SORT_KEY_VIEW_MASK
- | SORT_KEY_DRAW_BIT
- | SORT_KEY_DRAW_TYPE_MASK
- | SORT_KEY_DRAW_0_TRANS_MASK
- | SORT_KEY_DRAW_0_PROGRAM_MASK
- | SORT_KEY_DRAW_0_DEPTH_MASK
+ | kSortKeyViewMask
+ | kSortKeyDrawBit
+ | kSortKeyDrawTypeMask
+ | kSortKeyDraw0TransMask
+ | kSortKeyDraw0ProgramMask
+ | kSortKeyDraw0DepthMask
) == (0
- ^ SORT_KEY_VIEW_MASK
- ^ SORT_KEY_DRAW_BIT
- ^ SORT_KEY_DRAW_TYPE_MASK
- ^ SORT_KEY_DRAW_0_TRANS_MASK
- ^ SORT_KEY_DRAW_0_PROGRAM_MASK
- ^ SORT_KEY_DRAW_0_DEPTH_MASK
+ ^ kSortKeyViewMask
+ ^ kSortKeyDrawBit
+ ^ kSortKeyDrawTypeMask
+ ^ kSortKeyDraw0TransMask
+ ^ kSortKeyDraw0ProgramMask
+ ^ kSortKeyDraw0DepthMask
) );
BX_STATIC_ASSERT( (0 // Render key mask shouldn't overlap.
- | SORT_KEY_VIEW_MASK
- | SORT_KEY_DRAW_BIT
- | SORT_KEY_DRAW_TYPE_MASK
- | SORT_KEY_DRAW_1_DEPTH_MASK
- | SORT_KEY_DRAW_1_TRANS_MASK
- | SORT_KEY_DRAW_1_PROGRAM_MASK
+ | kSortKeyViewMask
+ | kSortKeyDrawBit
+ | kSortKeyDrawTypeMask
+ | kSortKeyDraw1DepthMask
+ | kSortKeyDraw1TransMask
+ | kSortKeyDraw1ProgramMask
) == (0
- ^ SORT_KEY_VIEW_MASK
- ^ SORT_KEY_DRAW_BIT
- ^ SORT_KEY_DRAW_TYPE_MASK
- ^ SORT_KEY_DRAW_1_DEPTH_MASK
- ^ SORT_KEY_DRAW_1_TRANS_MASK
- ^ SORT_KEY_DRAW_1_PROGRAM_MASK
+ ^ kSortKeyViewMask
+ ^ kSortKeyDrawBit
+ ^ kSortKeyDrawTypeMask
+ ^ kSortKeyDraw1DepthMask
+ ^ kSortKeyDraw1TransMask
+ ^ kSortKeyDraw1ProgramMask
) );
BX_STATIC_ASSERT( (0 // Render key mask shouldn't overlap.
- | SORT_KEY_VIEW_MASK
- | SORT_KEY_DRAW_BIT
- | SORT_KEY_DRAW_TYPE_MASK
- | SORT_KEY_DRAW_2_SEQ_MASK
- | SORT_KEY_DRAW_2_TRANS_MASK
- | SORT_KEY_DRAW_2_PROGRAM_MASK
+ | kSortKeyViewMask
+ | kSortKeyDrawBit
+ | kSortKeyDrawTypeMask
+ | kSortKeyDraw2SeqMask
+ | kSortKeyDraw2TransMask
+ | kSortKeyDraw2ProgramMask
) == (0
- ^ SORT_KEY_VIEW_MASK
- ^ SORT_KEY_DRAW_BIT
- ^ SORT_KEY_DRAW_TYPE_MASK
- ^ SORT_KEY_DRAW_2_SEQ_MASK
- ^ SORT_KEY_DRAW_2_TRANS_MASK
- ^ SORT_KEY_DRAW_2_PROGRAM_MASK
+ ^ kSortKeyViewMask
+ ^ kSortKeyDrawBit
+ ^ kSortKeyDrawTypeMask
+ ^ kSortKeyDraw2SeqMask
+ ^ kSortKeyDraw2TransMask
+ ^ kSortKeyDraw2ProgramMask
) );
BX_STATIC_ASSERT( (0 // Compute key mask shouldn't overlap.
- | SORT_KEY_VIEW_MASK
- | SORT_KEY_DRAW_BIT
- | SORT_KEY_COMPUTE_SEQ_SHIFT
- | SORT_KEY_COMPUTE_PROGRAM_MASK
+ | kSortKeyViewMask
+ | kSortKeyDrawBit
+ | kSortKeyComputeSeqShift
+ | kSortKeyComputeProgramMask
) == (0
- ^ SORT_KEY_VIEW_MASK
- ^ SORT_KEY_DRAW_BIT
- ^ SORT_KEY_COMPUTE_SEQ_SHIFT
- ^ SORT_KEY_COMPUTE_PROGRAM_MASK
+ ^ kSortKeyViewMask
+ ^ kSortKeyDrawBit
+ ^ kSortKeyComputeSeqShift
+ ^ kSortKeyComputeProgramMask
) );
// | 3 2 1 0|
@@ -1034,49 +1061,61 @@ namespace bgfx
uint64_t encodeDraw(Enum _type)
{
- if (SortDepth == _type)
+ switch (_type)
{
- const uint64_t depth = (uint64_t(m_depth ) << SORT_KEY_DRAW_1_DEPTH_SHIFT ) & SORT_KEY_DRAW_1_DEPTH_MASK;
- const uint64_t program = (uint64_t(m_program) << SORT_KEY_DRAW_1_PROGRAM_SHIFT) & SORT_KEY_DRAW_1_PROGRAM_MASK;
- const uint64_t trans = (uint64_t(m_trans ) << SORT_KEY_DRAW_1_TRANS_SHIFT ) & SORT_KEY_DRAW_1_TRANS_MASK;
- const uint64_t view = (uint64_t(m_view ) << SORT_KEY_VIEW_SHIFT ) & SORT_KEY_VIEW_MASK;
- const uint64_t key = view|SORT_KEY_DRAW_BIT|SORT_KEY_DRAW_TYPE_DEPTH|depth|trans|program;
+ case SortProgram:
+ {
+ const uint64_t depth = (uint64_t(m_depth ) << kSortKeyDraw0DepthShift ) & kSortKeyDraw0DepthMask;
+ const uint64_t program = (uint64_t(m_program.idx) << kSortKeyDraw0ProgramShift) & kSortKeyDraw0ProgramMask;
+ const uint64_t trans = (uint64_t(m_trans ) << kSortKeyDraw0TransShift ) & kSortKeyDraw0TransMask;
+ const uint64_t view = (uint64_t(m_view ) << kSortKeyViewBitShift ) & kSortKeyViewMask;
+ const uint64_t key = view|kSortKeyDrawBit|kSortKeyDrawTypeProgram|trans|program|depth;
- return key;
- }
- else if (SortSequence == _type)
- {
- const uint64_t seq = (uint64_t(m_seq ) << SORT_KEY_DRAW_2_SEQ_SHIFT ) & SORT_KEY_DRAW_2_SEQ_MASK;
- const uint64_t program = (uint64_t(m_program) << SORT_KEY_DRAW_2_PROGRAM_SHIFT) & SORT_KEY_DRAW_2_PROGRAM_MASK;
- const uint64_t trans = (uint64_t(m_trans ) << SORT_KEY_DRAW_2_TRANS_SHIFT ) & SORT_KEY_DRAW_2_TRANS_MASK;
- const uint64_t view = (uint64_t(m_view ) << SORT_KEY_VIEW_SHIFT ) & SORT_KEY_VIEW_MASK;
- const uint64_t key = view|SORT_KEY_DRAW_BIT|SORT_KEY_DRAW_TYPE_SEQUENCE|seq|trans|program;
+ return key;
+ }
+ break;
- BX_CHECK(seq == (uint64_t(m_seq) << SORT_KEY_DRAW_2_SEQ_SHIFT)
- , "SortKey error, sequence is truncated (m_seq: %d)."
- , m_seq
- );
+ case SortDepth:
+ {
+ const uint64_t depth = (uint64_t(m_depth ) << kSortKeyDraw1DepthShift ) & kSortKeyDraw1DepthMask;
+ const uint64_t program = (uint64_t(m_program.idx) << kSortKeyDraw1ProgramShift) & kSortKeyDraw1ProgramMask;
+ const uint64_t trans = (uint64_t(m_trans ) << kSortKeyDraw1TransShift) & kSortKeyDraw1TransMask;
+ const uint64_t view = (uint64_t(m_view ) << kSortKeyViewBitShift ) & kSortKeyViewMask;
+ const uint64_t key = view|kSortKeyDrawBit|kSortKeyDrawTypeDepth|depth|trans|program;
+ return key;
+ }
+ break;
- return key;
- }
+ case SortSequence:
+ {
+ const uint64_t seq = (uint64_t(m_seq ) << kSortKeyDraw2SeqShift ) & kSortKeyDraw2SeqMask;
+ const uint64_t program = (uint64_t(m_program.idx) << kSortKeyDraw2ProgramShift) & kSortKeyDraw2ProgramMask;
+ const uint64_t trans = (uint64_t(m_trans ) << kSortKeyDraw2TransShift ) & kSortKeyDraw2TransMask;
+ const uint64_t view = (uint64_t(m_view ) << kSortKeyViewBitShift ) & kSortKeyViewMask;
+ const uint64_t key = view|kSortKeyDrawBit|kSortKeyDrawTypeSequence|seq|trans|program;
+
+ BX_CHECK(seq == (uint64_t(m_seq) << kSortKeyDraw2SeqShift)
+ , "SortKey error, sequence is truncated (m_seq: %d)."
+ , m_seq
+ );
- const uint64_t depth = (uint64_t(m_depth ) << SORT_KEY_DRAW_0_DEPTH_SHIFT ) & SORT_KEY_DRAW_0_DEPTH_MASK;
- const uint64_t program = (uint64_t(m_program) << SORT_KEY_DRAW_0_PROGRAM_SHIFT) & SORT_KEY_DRAW_0_PROGRAM_MASK;
- const uint64_t trans = (uint64_t(m_trans ) << SORT_KEY_DRAW_0_TRANS_SHIFT ) & SORT_KEY_DRAW_0_TRANS_MASK;
- const uint64_t view = (uint64_t(m_view ) << SORT_KEY_VIEW_SHIFT ) & SORT_KEY_VIEW_MASK;
- const uint64_t key = view|SORT_KEY_DRAW_BIT|SORT_KEY_DRAW_TYPE_PROGRAM|trans|program|depth;
+ return key;
+ }
+ break;
+ }
- return key;
+ BX_CHECK(false, "You should not be here.");
+ return 0;
}
uint64_t encodeCompute()
{
- const uint64_t program = (uint64_t(m_program) << SORT_KEY_COMPUTE_PROGRAM_SHIFT) & SORT_KEY_COMPUTE_PROGRAM_MASK;
- const uint64_t seq = (uint64_t(m_seq ) << SORT_KEY_COMPUTE_SEQ_SHIFT ) & SORT_KEY_COMPUTE_SEQ_MASK;
- const uint64_t view = (uint64_t(m_view ) << SORT_KEY_VIEW_SHIFT ) & SORT_KEY_VIEW_MASK;
+ const uint64_t program = (uint64_t(m_program.idx) << kSortKeyComputeProgramShift) & kSortKeyComputeProgramMask;
+ const uint64_t seq = (uint64_t(m_seq ) << kSortKeyComputeSeqShift ) & kSortKeyComputeSeqMask;
+ const uint64_t view = (uint64_t(m_view ) << kSortKeyViewBitShift ) & kSortKeyViewMask;
const uint64_t key = program|seq|view;
- BX_CHECK(seq == (uint64_t(m_seq) << SORT_KEY_COMPUTE_SEQ_SHIFT)
+ BX_CHECK(seq == (uint64_t(m_seq) << kSortKeyComputeSeqShift)
, "SortKey error, sequence is truncated (m_seq: %d)."
, m_seq
);
@@ -1087,39 +1126,39 @@ namespace bgfx
/// Returns true if item is compute command.
bool decode(uint64_t _key, ViewId _viewRemap[BGFX_CONFIG_MAX_VIEWS])
{
- m_view = _viewRemap[(_key & SORT_KEY_VIEW_MASK) >> SORT_KEY_VIEW_SHIFT];
- if (_key & SORT_KEY_DRAW_BIT)
+ m_view = _viewRemap[(_key & kSortKeyViewMask) >> kSortKeyViewBitShift];
+ if (_key & kSortKeyDrawBit)
{
- uint64_t type = _key & SORT_KEY_DRAW_TYPE_MASK;
- if (type == SORT_KEY_DRAW_TYPE_DEPTH)
+ uint64_t type = _key & kSortKeyDrawTypeMask;
+ if (type == kSortKeyDrawTypeDepth)
{
- m_program = uint16_t( (_key & SORT_KEY_DRAW_1_PROGRAM_MASK) >> SORT_KEY_DRAW_1_PROGRAM_SHIFT);
+ m_program.idx = uint16_t( (_key & kSortKeyDraw1ProgramMask) >> kSortKeyDraw1ProgramShift);
return false;
}
- else if (type == SORT_KEY_DRAW_TYPE_SEQUENCE)
+ else if (type == kSortKeyDrawTypeSequence)
{
- m_program = uint16_t( (_key & SORT_KEY_DRAW_2_PROGRAM_MASK) >> SORT_KEY_DRAW_2_PROGRAM_SHIFT);
+ m_program.idx = uint16_t( (_key & kSortKeyDraw2ProgramMask) >> kSortKeyDraw2ProgramShift);
return false;
}
- m_program = uint16_t( (_key & SORT_KEY_DRAW_0_PROGRAM_MASK) >> SORT_KEY_DRAW_0_PROGRAM_SHIFT);
+ m_program.idx = uint16_t( (_key & kSortKeyDraw0ProgramMask) >> kSortKeyDraw0ProgramShift);
return false; // draw
}
- m_program = uint16_t( (_key & SORT_KEY_COMPUTE_PROGRAM_MASK) >> SORT_KEY_COMPUTE_PROGRAM_SHIFT);
+ m_program.idx = uint16_t( (_key & kSortKeyComputeProgramMask) >> kSortKeyComputeProgramShift);
return true; // compute
}
static ViewId decodeView(uint64_t _key)
{
- return ViewId( (_key & SORT_KEY_VIEW_MASK) >> SORT_KEY_VIEW_SHIFT);
+ return ViewId( (_key & kSortKeyViewMask) >> kSortKeyViewBitShift);
}
static uint64_t remapView(uint64_t _key, ViewId _viewRemap[BGFX_CONFIG_MAX_VIEWS])
{
const ViewId oldView = decodeView(_key);
- const uint64_t view = uint64_t(_viewRemap[oldView]) << SORT_KEY_VIEW_SHIFT;
- const uint64_t key = (_key & ~SORT_KEY_VIEW_MASK) | view;
+ const uint64_t view = uint64_t(_viewRemap[oldView]) << kSortKeyViewBitShift;
+ const uint64_t key = (_key & ~kSortKeyViewMask) | view;
return key;
}
@@ -1127,16 +1166,16 @@ namespace bgfx
{
m_depth = 0;
m_seq = 0;
- m_program = 0;
+ m_program = {0};
m_view = 0;
m_trans = 0;
}
- uint32_t m_depth;
- uint32_t m_seq;
- uint16_t m_program;
- ViewId m_view;
- uint8_t m_trans;
+ uint32_t m_depth;
+ uint32_t m_seq;
+ ProgramHandle m_program;
+ ViewId m_view;
+ uint8_t m_trans;
};
#undef SORT_KEY_RENDER_DRAW
@@ -1492,14 +1531,14 @@ namespace bgfx
{
void clear()
{
- m_startVertex = 0;
- m_handle.idx = kInvalidHandle;
- m_decl.idx = kInvalidHandle;
+ m_startVertex = 0;
+ m_handle.idx = kInvalidHandle;
+ m_layoutHandle.idx = kInvalidHandle;
}
uint32_t m_startVertex;
VertexBufferHandle m_handle;
- VertexDeclHandle m_decl;
+ VertexLayoutHandle m_layoutHandle;
};
BX_ALIGN_DECL_CACHE_LINE(struct) RenderBind
@@ -1537,7 +1576,7 @@ namespace bgfx
m_startIndirect = 0;
m_numIndirect = UINT16_MAX;
m_numMatrices = 1;
- m_submitFlags = BGFX_SUBMIT_EYE_FIRST;
+ m_submitFlags = 0;
m_scissor = UINT16_MAX;
m_streamMask = 0;
m_stream[0].clear();
@@ -1595,7 +1634,7 @@ namespace bgfx
m_numY = 0;
m_numZ = 0;
m_numMatrices = 0;
- m_submitFlags = BGFX_SUBMIT_EYE_FIRST;
+ m_submitFlags = 0;
m_uniformIdx = UINT8_MAX;
m_indirectBuffer.idx = kInvalidHandle;
@@ -1643,11 +1682,13 @@ namespace bgfx
struct IndexBuffer
{
+ String m_name;
uint32_t m_size;
};
struct VertexBuffer
{
+ String m_name;
uint32_t m_size;
uint16_t m_stride;
};
@@ -1669,10 +1710,86 @@ namespace bgfx
uint32_t m_startVertex;
uint32_t m_numVertices;
uint16_t m_stride;
- VertexDeclHandle m_decl;
+ VertexLayoutHandle m_layoutHandle;
uint16_t m_flags;
};
+ struct ShaderRef
+ {
+ UniformHandle* m_uniforms;
+ String m_name;
+ uint32_t m_hashIn;
+ uint32_t m_hashOut;
+ uint16_t m_num;
+ int16_t m_refCount;
+ };
+
+ struct ProgramRef
+ {
+ ShaderHandle m_vsh;
+ ShaderHandle m_fsh;
+ int16_t m_refCount;
+ };
+
+ struct UniformRef
+ {
+ String m_name;
+ UniformType::Enum m_type;
+ uint16_t m_num;
+ int16_t m_refCount;
+ };
+
+ struct TextureRef
+ {
+ void init(
+ BackbufferRatio::Enum _ratio
+ , TextureFormat::Enum _format
+ , uint32_t _storageSize
+ , uint8_t _numMips
+ , uint16_t _numLayers
+ , bool _ptrPending
+ , bool _immutable
+ , bool _rt
+ )
+ {
+ m_ptr = _ptrPending ? (void*)UINTPTR_MAX : NULL;
+ m_storageSize = _storageSize;
+ m_refCount = 1;
+ m_bbRatio = uint8_t(_ratio);
+ m_format = uint8_t(_format);
+ m_numMips = _numMips;
+ m_numLayers = _numLayers;
+ m_owned = false;
+ m_immutable = _immutable;
+ m_rt = _rt;
+ }
+
+ String m_name;
+ void* m_ptr;
+ uint32_t m_storageSize;
+ int16_t m_refCount;
+ uint8_t m_bbRatio;
+ uint8_t m_format;
+ uint8_t m_numMips;
+ uint16_t m_numLayers;
+ bool m_owned;
+ bool m_immutable;
+ bool m_rt;
+ };
+
+ struct FrameBufferRef
+ {
+ String m_name;
+
+ union un
+ {
+ TextureHandle m_th[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
+ void* m_nwh;
+ } un;
+
+ bool m_window;
+ };
+
BX_ALIGN_DECL_CACHE_LINE(struct) View
{
void reset()
@@ -1682,7 +1799,7 @@ namespace bgfx
setClear(BGFX_CLEAR_NONE, 0, 0.0f, 0);
setMode(ViewMode::Default);
setFrameBuffer(BGFX_INVALID_HANDLE);
- setTransform(NULL, NULL, BGFX_VIEW_NONE, NULL);
+ setTransform(NULL, NULL);
}
void setRect(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
@@ -1721,10 +1838,8 @@ namespace bgfx
m_fbh = _handle;
}
- void setTransform(const void* _view, const void* _proj, uint8_t _flags, const void* _proj1)
+ void setTransform(const void* _view, const void* _proj)
{
- m_flags = _flags;
-
if (NULL != _view)
{
bx::memCopy(m_view.un.val, _view, sizeof(Matrix4) );
@@ -1736,20 +1851,11 @@ namespace bgfx
if (NULL != _proj)
{
- bx::memCopy(m_proj[0].un.val, _proj, sizeof(Matrix4) );
+ bx::memCopy(m_proj.un.val, _proj, sizeof(Matrix4) );
}
else
{
- m_proj[0].setIdentity();
- }
-
- if (NULL != _proj1)
- {
- bx::memCopy(m_proj[1].un.val, _proj1, sizeof(Matrix4) );
- }
- else
- {
- bx::memCopy(m_proj[1].un.val, m_proj[0].un.val, sizeof(Matrix4) );
+ m_proj.setIdentity();
}
}
@@ -1757,10 +1863,9 @@ namespace bgfx
Rect m_rect;
Rect m_scissor;
Matrix4 m_view;
- Matrix4 m_proj[2];
+ Matrix4 m_proj;
FrameBufferHandle m_fbh;
uint8_t m_mode;
- uint8_t m_flags;
};
struct FrameCache
@@ -1796,7 +1901,7 @@ namespace bgfx
{
SortKey term;
term.reset();
- term.m_program = kInvalidHandle;
+ term.m_program = BGFX_INVALID_HANDLE;
m_sortKeys[BGFX_CONFIG_MAX_DRAW_CALLS] = term.encodeDraw(SortKey::SortProgram);
m_sortValues[BGFX_CONFIG_MAX_DRAW_CALLS] = BGFX_CONFIG_MAX_DRAW_CALLS;
bx::memSet(m_occlusion, 0xff, sizeof(m_occlusion) );
@@ -1919,9 +2024,9 @@ namespace bgfx
return m_freeIndexBuffer.queue(_handle);
}
- bool free(VertexDeclHandle _handle)
+ bool free(VertexLayoutHandle _handle)
{
- return m_freeVertexDecl.queue(_handle);
+ return m_freeVertexLayout.queue(_handle);
}
bool free(VertexBufferHandle _handle)
@@ -1957,7 +2062,7 @@ namespace bgfx
void resetFreeHandles()
{
m_freeIndexBuffer.reset();
- m_freeVertexDecl.reset();
+ m_freeVertexLayout.reset();
m_freeVertexBuffer.reset();
m_freeShader.reset();
m_freeProgram.reset();
@@ -2055,7 +2160,7 @@ namespace bgfx
};
FreeHandle<IndexBufferHandle, BGFX_CONFIG_MAX_INDEX_BUFFERS> m_freeIndexBuffer;
- FreeHandle<VertexDeclHandle, BGFX_CONFIG_MAX_VERTEX_DECLS> m_freeVertexDecl;
+ FreeHandle<VertexLayoutHandle, BGFX_CONFIG_MAX_VERTEX_LAYOUTS> m_freeVertexLayout;
FreeHandle<VertexBufferHandle, BGFX_CONFIG_MAX_VERTEX_BUFFERS> m_freeVertexBuffer;
FreeHandle<ShaderHandle, BGFX_CONFIG_MAX_SHADERS> m_freeShader;
FreeHandle<ProgramHandle, BGFX_CONFIG_MAX_PROGRAMS> m_freeProgram;
@@ -2229,7 +2334,13 @@ namespace bgfx
m_discard = 0 == numIndices;
}
- void setVertexBuffer(uint8_t _stream, VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices)
+ void setVertexBuffer(
+ uint8_t _stream
+ , VertexBufferHandle _handle
+ , uint32_t _startVertex
+ , uint32_t _numVertices
+ , VertexLayoutHandle _layoutHandle
+ )
{
BX_CHECK(UINT8_MAX != m_draw.m_streamMask, "");
BX_CHECK(_stream < BGFX_CONFIG_MAX_VERTEX_STREAMS, "Invalid stream %d (max %d).", _stream, BGFX_CONFIG_MAX_VERTEX_STREAMS);
@@ -2238,12 +2349,18 @@ namespace bgfx
Stream& stream = m_draw.m_stream[_stream];
stream.m_startVertex = _startVertex;
stream.m_handle = _handle;
- stream.m_decl.idx = kInvalidHandle;
+ stream.m_layoutHandle = _layoutHandle;
m_numVertices[_stream] = _numVertices;
}
}
- void setVertexBuffer(uint8_t _stream, const DynamicVertexBuffer& _dvb, uint32_t _startVertex, uint32_t _numVertices)
+ void setVertexBuffer(
+ uint8_t _stream
+ , const DynamicVertexBuffer& _dvb
+ , uint32_t _startVertex
+ , uint32_t _numVertices
+ , VertexLayoutHandle _layoutHandle
+ )
{
BX_CHECK(UINT8_MAX != m_draw.m_streamMask, "");
BX_CHECK(_stream < BGFX_CONFIG_MAX_VERTEX_STREAMS, "Invalid stream %d (max %d).", _stream, BGFX_CONFIG_MAX_VERTEX_STREAMS);
@@ -2252,14 +2369,20 @@ namespace bgfx
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;
+ stream.m_layoutHandle = isValid(_layoutHandle) ? _layoutHandle : _dvb.m_layoutHandle;
m_numVertices[_stream] =
bx::min(bx::uint32_imax(0, _dvb.m_numVertices - _startVertex), _numVertices)
;
}
}
- void setVertexBuffer(uint8_t _stream, const TransientVertexBuffer* _tvb, uint32_t _startVertex, uint32_t _numVertices)
+ void setVertexBuffer(
+ uint8_t _stream
+ , const TransientVertexBuffer* _tvb
+ , uint32_t _startVertex
+ , uint32_t _numVertices
+ , VertexLayoutHandle _layoutHandle
+ )
{
BX_CHECK(UINT8_MAX != m_draw.m_streamMask, "");
BX_CHECK(_stream < BGFX_CONFIG_MAX_VERTEX_STREAMS, "Invalid stream %d (max %d).", _stream, BGFX_CONFIG_MAX_VERTEX_STREAMS);
@@ -2268,10 +2391,8 @@ namespace bgfx
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::min(bx::uint32_imax(0, _tvb->size/_tvb->stride - _startVertex), _numVertices)
- ;
+ stream.m_layoutHandle = isValid(_layoutHandle) ? _layoutHandle : _tvb->layoutHandle;
+ m_numVertices[_stream] = bx::min(bx::uint32_imax(0, _tvb->size/_tvb->stride - _startVertex), _numVertices);
}
}
@@ -2280,10 +2401,10 @@ namespace bgfx
BX_CHECK(0 == m_draw.m_streamMask, "Vertex buffer already set.");
m_draw.m_streamMask = UINT8_MAX;
Stream& stream = m_draw.m_stream[0];
- stream.m_startVertex = 0;
- stream.m_handle.idx = kInvalidHandle;
- stream.m_decl.idx = kInvalidHandle;
- m_numVertices[0] = _numVertices;
+ stream.m_startVertex = 0;
+ stream.m_handle.idx = kInvalidHandle;
+ stream.m_layoutHandle.idx = kInvalidHandle;
+ m_numVertices[0] = _numVertices;
}
void setInstanceDataBuffer(const InstanceDataBuffer* _idb, uint32_t _start, uint32_t _num)
@@ -2323,7 +2444,7 @@ namespace bgfx
if (isValid(_sampler) )
{
uint32_t stage = _stage;
- setUniform(UniformType::Int1, _sampler, &stage, 1);
+ setUniform(UniformType::Sampler, _sampler, &stage, 1);
}
}
@@ -2381,14 +2502,14 @@ namespace bgfx
submit(_id, _program, handle, _depth, _preserveState);
}
- void dispatch(ViewId _id, ProgramHandle _handle, uint32_t _ngx, uint32_t _ngy, uint32_t _ngz, uint8_t _flags);
+ void dispatch(ViewId _id, ProgramHandle _handle, uint32_t _ngx, uint32_t _ngy, uint32_t _ngz);
- void dispatch(ViewId _id, ProgramHandle _handle, IndirectBufferHandle _indirectHandle, uint16_t _start, uint16_t _num, uint8_t _flags)
+ void dispatch(ViewId _id, ProgramHandle _handle, IndirectBufferHandle _indirectHandle, uint16_t _start, uint16_t _num)
{
m_compute.m_indirectBuffer = _indirectHandle;
m_compute.m_startIndirect = _start;
m_compute.m_numIndirect = _num;
- dispatch(_id, _handle, 0, 0, 0, _flags);
+ dispatch(_id, _handle, 0, 0, 0);
}
void blit(ViewId _id, TextureHandle _dst, uint8_t _dstMip, uint16_t _dstX, uint16_t _dstY, uint16_t _dstZ, TextureHandle _src, uint8_t _srcMip, uint16_t _srcX, uint16_t _srcY, uint16_t _srcZ, uint16_t _width, uint16_t _height, uint16_t _depth);
@@ -2418,15 +2539,15 @@ namespace bgfx
int64_t m_cpuTimeEnd;
};
- struct VertexDeclRef
+ struct VertexLayoutRef
{
- VertexDeclRef()
+ VertexLayoutRef()
{
}
void init()
{
- bx::memSet(m_vertexDeclRef, 0, sizeof(m_vertexDeclRef) );
+ bx::memSet(m_layoutRef, 0, sizeof(m_layoutRef) );
bx::memSet(m_vertexBufferRef, 0xff, sizeof(m_vertexBufferRef) );
bx::memSet(m_dynamicVertexBufferRef, 0xff, sizeof(m_dynamicVertexBufferRef) );
}
@@ -2436,83 +2557,83 @@ namespace bgfx
{
for (uint16_t ii = 0, num = _handleAlloc.getNumHandles(); ii < num; ++ii)
{
- VertexDeclHandle handle = { _handleAlloc.getHandleAt(ii) };
- m_vertexDeclRef[handle.idx] = 0;
- m_vertexDeclMap.removeByHandle(handle.idx);
+ VertexLayoutHandle handle = { _handleAlloc.getHandleAt(ii) };
+ m_layoutRef[handle.idx] = 0;
+ m_layoutMap.removeByHandle(handle.idx);
_handleAlloc.free(handle.idx);
}
- m_vertexDeclMap.reset();
+ m_layoutMap.reset();
}
- VertexDeclHandle find(uint32_t _hash)
+ VertexLayoutHandle find(uint32_t _hash)
{
- VertexDeclHandle handle = { m_vertexDeclMap.find(_hash) };
+ VertexLayoutHandle handle = { m_layoutMap.find(_hash) };
return handle;
}
- void add(VertexDeclHandle _declHandle, uint32_t _hash)
+ void add(VertexLayoutHandle _layoutHandle, uint32_t _hash)
{
- m_vertexDeclRef[_declHandle.idx]++;
- m_vertexDeclMap.insert(_hash, _declHandle.idx);
+ m_layoutRef[_layoutHandle.idx]++;
+ m_layoutMap.insert(_hash, _layoutHandle.idx);
}
- void add(VertexBufferHandle _handle, VertexDeclHandle _declHandle, uint32_t _hash)
+ void add(VertexBufferHandle _handle, VertexLayoutHandle _layoutHandle, uint32_t _hash)
{
BX_CHECK(m_vertexBufferRef[_handle.idx].idx == kInvalidHandle, "");
- m_vertexBufferRef[_handle.idx] = _declHandle;
- m_vertexDeclRef[_declHandle.idx]++;
- m_vertexDeclMap.insert(_hash, _declHandle.idx);
+ m_vertexBufferRef[_handle.idx] = _layoutHandle;
+ m_layoutRef[_layoutHandle.idx]++;
+ m_layoutMap.insert(_hash, _layoutHandle.idx);
}
- void add(DynamicVertexBufferHandle _handle, VertexDeclHandle _declHandle, uint32_t _hash)
+ void add(DynamicVertexBufferHandle _handle, VertexLayoutHandle _layoutHandle, uint32_t _hash)
{
BX_CHECK(m_dynamicVertexBufferRef[_handle.idx].idx == kInvalidHandle, "");
- m_dynamicVertexBufferRef[_handle.idx] = _declHandle;
- m_vertexDeclRef[_declHandle.idx]++;
- m_vertexDeclMap.insert(_hash, _declHandle.idx);
+ m_dynamicVertexBufferRef[_handle.idx] = _layoutHandle;
+ m_layoutRef[_layoutHandle.idx]++;
+ m_layoutMap.insert(_hash, _layoutHandle.idx);
}
- VertexDeclHandle release(VertexDeclHandle _declHandle)
+ VertexLayoutHandle release(VertexLayoutHandle _layoutHandle)
{
- if (isValid(_declHandle) )
+ if (isValid(_layoutHandle) )
{
- m_vertexDeclRef[_declHandle.idx]--;
+ m_layoutRef[_layoutHandle.idx]--;
- if (0 == m_vertexDeclRef[_declHandle.idx])
+ if (0 == m_layoutRef[_layoutHandle.idx])
{
- m_vertexDeclMap.removeByHandle(_declHandle.idx);
- return _declHandle;
+ m_layoutMap.removeByHandle(_layoutHandle.idx);
+ return _layoutHandle;
}
}
return BGFX_INVALID_HANDLE;
}
- VertexDeclHandle release(VertexBufferHandle _handle)
+ VertexLayoutHandle release(VertexBufferHandle _handle)
{
- VertexDeclHandle declHandle = m_vertexBufferRef[_handle.idx];
- declHandle = release(declHandle);
+ VertexLayoutHandle layoutHandle = m_vertexBufferRef[_handle.idx];
+ layoutHandle = release(layoutHandle);
m_vertexBufferRef[_handle.idx].idx = kInvalidHandle;
- return declHandle;
+ return layoutHandle;
}
- VertexDeclHandle release(DynamicVertexBufferHandle _handle)
+ VertexLayoutHandle release(DynamicVertexBufferHandle _handle)
{
- VertexDeclHandle declHandle = m_dynamicVertexBufferRef[_handle.idx];
- declHandle = release(declHandle);
+ VertexLayoutHandle layoutHandle = m_dynamicVertexBufferRef[_handle.idx];
+ layoutHandle = release(layoutHandle);
m_dynamicVertexBufferRef[_handle.idx].idx = kInvalidHandle;
- return declHandle;
+ return layoutHandle;
}
- typedef bx::HandleHashMapT<BGFX_CONFIG_MAX_VERTEX_DECLS*2> VertexDeclMap;
- VertexDeclMap m_vertexDeclMap;
+ typedef bx::HandleHashMapT<BGFX_CONFIG_MAX_VERTEX_LAYOUTS*2> VertexLayoutMap;
+ VertexLayoutMap m_layoutMap;
- uint16_t m_vertexDeclRef[BGFX_CONFIG_MAX_VERTEX_DECLS];
- VertexDeclHandle m_vertexBufferRef[BGFX_CONFIG_MAX_VERTEX_BUFFERS];
- VertexDeclHandle m_dynamicVertexBufferRef[BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS];
+ uint16_t m_layoutRef[BGFX_CONFIG_MAX_VERTEX_LAYOUTS];
+ VertexLayoutHandle m_vertexBufferRef[BGFX_CONFIG_MAX_VERTEX_BUFFERS];
+ VertexLayoutHandle m_dynamicVertexBufferRef[BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS];
};
// First-fit non-local allocator.
@@ -2649,9 +2770,9 @@ namespace bgfx
virtual void flip() = 0;
virtual void createIndexBuffer(IndexBufferHandle _handle, const Memory* _mem, uint16_t _flags) = 0;
virtual void destroyIndexBuffer(IndexBufferHandle _handle) = 0;
- virtual void createVertexDecl(VertexDeclHandle _handle, const VertexDecl& _decl) = 0;
- virtual void destroyVertexDecl(VertexDeclHandle _handle) = 0;
- virtual void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexDeclHandle _declHandle, uint16_t _flags) = 0;
+ virtual void createVertexLayout(VertexLayoutHandle _handle, const VertexLayout& _layout) = 0;
+ virtual void destroyVertexLayout(VertexLayoutHandle _handle) = 0;
+ virtual void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexLayoutHandle _layoutHandle, uint16_t _flags) = 0;
virtual void destroyVertexBuffer(VertexBufferHandle _handle) = 0;
virtual void createDynamicIndexBuffer(IndexBufferHandle _handle, uint32_t _size, uint16_t _flags) = 0;
virtual void updateDynamicIndexBuffer(IndexBufferHandle _handle, uint32_t _offset, uint32_t _size, const Memory* _mem) = 0;
@@ -2680,9 +2801,9 @@ namespace bgfx
virtual void requestScreenShot(FrameBufferHandle _handle, const char* _filePath) = 0;
virtual void updateViewName(ViewId _id, const char* _name) = 0;
virtual void updateUniform(uint16_t _loc, const void* _data, uint32_t _size) = 0;
- virtual void setMarker(const char* _marker, uint32_t _size) = 0;
virtual void invalidateOcclusionQuery(OcclusionQueryHandle _handle) = 0;
- virtual void setName(Handle _handle, const char* _name) = 0;
+ virtual void setMarker(const char* _marker, uint16_t _len) = 0;
+ virtual void setName(Handle _handle, const char* _name, uint16_t _len) = 0;
virtual void submit(Frame* _render, ClearQuad& _clearQuad, TextVideoMemBlitter& _textVideoMemBlitter) = 0;
virtual void blitSetup(TextVideoMemBlitter& _blitter) = 0;
virtual void blitRender(TextVideoMemBlitter& _blitter, uint32_t _numIndices) = 0;
@@ -2841,7 +2962,7 @@ namespace bgfx
stats.numTextures = m_textureHandle.getNumHandles();
stats.numUniforms = m_uniformHandle.getNumHandles();
stats.numVertexBuffers = m_vertexBufferHandle.getNumHandles();
- stats.numVertexDecls = m_vertexDeclHandle.getNumHandles();
+ stats.numVertexLayouts = m_layoutHandle.getNumHandles();
stats.textureMemoryUsed = m_textureMemoryUsed;
stats.rtMemoryUsed = m_rtMemoryUsed;
@@ -2865,6 +2986,8 @@ namespace bgfx
cmdbuf.write(handle);
cmdbuf.write(_mem);
cmdbuf.write(_flags);
+
+ setDebugName(convert(handle) );
}
else
{
@@ -2874,6 +2997,18 @@ namespace bgfx
return handle;
}
+ BGFX_API_FUNC(void setName(IndexBufferHandle _handle, const bx::StringView& _name) )
+ {
+ BGFX_MUTEX_SCOPE(m_resourceApiLock);
+
+ BGFX_CHECK_HANDLE("setName", m_indexBufferHandle, _handle);
+
+ IndexBuffer& ref = m_indexBuffers[_handle.idx];
+ ref.m_name.set(_name);
+
+ setName(convert(_handle), _name);
+ }
+
BGFX_API_FUNC(void destroyIndexBuffer(IndexBufferHandle _handle) )
{
BGFX_MUTEX_SCOPE(m_resourceApiLock);
@@ -2882,31 +3017,56 @@ namespace bgfx
bool ok = m_submit->free(_handle); BX_UNUSED(ok);
BX_CHECK(ok, "Index buffer handle %d is already destroyed!", _handle.idx);
+ IndexBuffer& ref = m_indexBuffers[_handle.idx];
+ ref.m_name.clear();
+
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyIndexBuffer);
cmdbuf.write(_handle);
}
- VertexDeclHandle findVertexDecl(const VertexDecl& _decl)
+ VertexLayoutHandle findVertexLayout(const VertexLayout& _layout)
{
- VertexDeclHandle declHandle = m_declRef.find(_decl.m_hash);
+ VertexLayoutHandle layoutHandle = m_vertexLayoutRef.find(_layout.m_hash);
- if (!isValid(declHandle) )
+ if (!isValid(layoutHandle) )
{
- declHandle.idx = m_vertexDeclHandle.alloc();
- if (!isValid(declHandle) )
+ layoutHandle.idx = m_layoutHandle.alloc();
+ if (!isValid(layoutHandle) )
{
- return declHandle;
+ return layoutHandle;
}
- CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateVertexDecl);
- cmdbuf.write(declHandle);
- cmdbuf.write(_decl);
+ CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateVertexLayout);
+ cmdbuf.write(layoutHandle);
+ cmdbuf.write(_layout);
+ }
+
+ return layoutHandle;
+ }
+
+ BGFX_API_FUNC(VertexLayoutHandle createVertexLayout(const VertexLayout& _layout) )
+ {
+ BGFX_MUTEX_SCOPE(m_resourceApiLock);
+
+ VertexLayoutHandle handle = findVertexLayout(_layout);
+ if (!isValid(handle) )
+ {
+ BX_TRACE("WARNING: Failed to allocate vertex layout handle (BGFX_CONFIG_MAX_VERTEX_LAYOUTS, max: %d).", BGFX_CONFIG_MAX_VERTEX_LAYOUTS);
+ return BGFX_INVALID_HANDLE;
}
- return declHandle;
+ m_vertexLayoutRef.add(handle, _layout.m_hash);
+
+ return handle;
+ }
+
+ BGFX_API_FUNC(void destroyVertexLayout(VertexLayoutHandle _handle) )
+ {
+ BGFX_MUTEX_SCOPE(m_resourceApiLock);
+ m_vertexLayoutRef.release(_handle);
}
- BGFX_API_FUNC(VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint16_t _flags) )
+ BGFX_API_FUNC(VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexLayout& _layout, uint16_t _flags) )
{
BGFX_MUTEX_SCOPE(m_resourceApiLock);
@@ -2914,26 +3074,28 @@ namespace bgfx
if (isValid(handle) )
{
- VertexDeclHandle declHandle = findVertexDecl(_decl);
- if (!isValid(declHandle) )
+ VertexLayoutHandle layoutHandle = findVertexLayout(_layout);
+ if (!isValid(layoutHandle) )
{
- BX_TRACE("WARNING: Failed to allocate vertex decl handle (BGFX_CONFIG_MAX_VERTEX_DECLS, max: %d).", BGFX_CONFIG_MAX_VERTEX_DECLS);
+ BX_TRACE("WARNING: Failed to allocate vertex layout handle (BGFX_CONFIG_MAX_VERTEX_LAYOUTS, max: %d).", BGFX_CONFIG_MAX_VERTEX_LAYOUTS);
m_vertexBufferHandle.free(handle.idx);
return BGFX_INVALID_HANDLE;
}
- m_declRef.add(handle, declHandle, _decl.m_hash);
+ m_vertexLayoutRef.add(handle, layoutHandle, _layout.m_hash);
VertexBuffer& vb = m_vertexBuffers[handle.idx];
vb.m_size = _mem->size;
- vb.m_stride = _decl.m_stride;
+ vb.m_stride = _layout.m_stride;
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateVertexBuffer);
cmdbuf.write(handle);
cmdbuf.write(_mem);
- cmdbuf.write(declHandle);
+ cmdbuf.write(layoutHandle);
cmdbuf.write(_flags);
+ setDebugName(convert(handle) );
+
return handle;
}
@@ -2943,6 +3105,18 @@ namespace bgfx
return BGFX_INVALID_HANDLE;
}
+ BGFX_API_FUNC(void setName(VertexBufferHandle _handle, const bx::StringView& _name) )
+ {
+ BGFX_MUTEX_SCOPE(m_resourceApiLock);
+
+ BGFX_CHECK_HANDLE("setName", m_vertexBufferHandle, _handle);
+
+ VertexBuffer& ref = m_vertexBuffers[_handle.idx];
+ ref.m_name.set(_name);
+
+ setName(convert(_handle), _name);
+ }
+
BGFX_API_FUNC(void destroyVertexBuffer(VertexBufferHandle _handle) )
{
BGFX_MUTEX_SCOPE(m_resourceApiLock);
@@ -2951,18 +3125,21 @@ namespace bgfx
bool ok = m_submit->free(_handle); BX_UNUSED(ok);
BX_CHECK(ok, "Vertex buffer handle %d is already destroyed!", _handle.idx);
+ VertexBuffer& ref = m_vertexBuffers[_handle.idx];
+ ref.m_name.clear();
+
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyVertexBuffer);
cmdbuf.write(_handle);
}
void destroyVertexBufferInternal(VertexBufferHandle _handle)
{
- VertexDeclHandle declHandle = m_declRef.release(_handle);
- if (isValid(declHandle) )
+ VertexLayoutHandle layoutHandle = m_vertexLayoutRef.release(_handle);
+ if (isValid(layoutHandle) )
{
- CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyVertexDecl);
- cmdbuf.write(declHandle);
- m_render->free(declHandle);
+ CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyVertexLayout);
+ cmdbuf.write(layoutHandle);
+ m_render->free(layoutHandle);
}
m_vertexBufferHandle.free(_handle.idx);
@@ -3029,6 +3206,8 @@ namespace bgfx
cmdbuf.write(size);
cmdbuf.write(_flags);
+ setDebugName(convert(indexBufferHandle), "Dynamic Index Buffer");
+
ptr = uint64_t(indexBufferHandle.idx) << 32;
}
else
@@ -3172,14 +3351,14 @@ namespace bgfx
return ptr;
}
- BGFX_API_FUNC(DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexDecl& _decl, uint16_t _flags) )
+ BGFX_API_FUNC(DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexLayout& _layout, uint16_t _flags) )
{
BGFX_MUTEX_SCOPE(m_resourceApiLock);
- VertexDeclHandle declHandle = findVertexDecl(_decl);
- if (!isValid(declHandle) )
+ VertexLayoutHandle layoutHandle = findVertexLayout(_layout);
+ if (!isValid(layoutHandle) )
{
- BX_TRACE("WARNING: Failed to allocate vertex decl handle (BGFX_CONFIG_MAX_VERTEX_DECLS, max: %d).", BGFX_CONFIG_MAX_VERTEX_DECLS);
+ BX_TRACE("WARNING: Failed to allocate vertex layout handle (BGFX_CONFIG_MAX_VERTEX_LAYOUTS, max: %d).", BGFX_CONFIG_MAX_VERTEX_LAYOUTS);
return BGFX_INVALID_HANDLE;
}
@@ -3190,7 +3369,7 @@ namespace bgfx
return BGFX_INVALID_HANDLE;
}
- uint32_t size = bx::strideAlign16(_num*_decl.m_stride, _decl.m_stride);
+ const uint32_t size = bx::strideAlign<16>(_num*_layout.m_stride, _layout.m_stride)+_layout.m_stride;
uint64_t ptr = 0;
if (0 != (_flags & BGFX_BUFFER_COMPUTE_READ_WRITE) )
@@ -3212,6 +3391,8 @@ namespace bgfx
cmdbuf.write(size);
cmdbuf.write(_flags);
+ setDebugName(convert(vertexBufferHandle), "Dynamic Vertex Buffer");
+
ptr = uint64_t(vertexBufferHandle.idx)<<32;
}
else
@@ -3225,25 +3406,25 @@ namespace bgfx
}
DynamicVertexBuffer& dvb = m_dynamicVertexBuffers[handle.idx];
- dvb.m_handle.idx = uint16_t(ptr>>32);
- dvb.m_offset = uint32_t(ptr);
- dvb.m_size = _num * _decl.m_stride;
- dvb.m_startVertex = bx::strideAlign(dvb.m_offset, _decl.m_stride)/_decl.m_stride;
- dvb.m_numVertices = _num;
- dvb.m_stride = _decl.m_stride;
- dvb.m_decl = declHandle;
- dvb.m_flags = _flags;
- m_declRef.add(handle, declHandle, _decl.m_hash);
+ dvb.m_handle.idx = uint16_t(ptr>>32);
+ dvb.m_offset = uint32_t(ptr);
+ dvb.m_size = _num * _layout.m_stride;
+ dvb.m_startVertex = bx::strideAlign(dvb.m_offset, _layout.m_stride)/_layout.m_stride;
+ dvb.m_numVertices = _num;
+ dvb.m_stride = _layout.m_stride;
+ dvb.m_layoutHandle = layoutHandle;
+ dvb.m_flags = _flags;
+ m_vertexLayoutRef.add(handle, layoutHandle, _layout.m_hash);
return handle;
}
- BGFX_API_FUNC(DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint16_t _flags) )
+ BGFX_API_FUNC(DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexLayout& _layout, uint16_t _flags) )
{
BGFX_MUTEX_SCOPE(m_resourceApiLock);
- uint32_t numVertices = _mem->size/_decl.m_stride;
- DynamicVertexBufferHandle handle = createDynamicVertexBuffer(numVertices, _decl, _flags);
+ uint32_t numVertices = _mem->size/_layout.m_stride;
+ DynamicVertexBufferHandle handle = createDynamicVertexBuffer(numVertices, _layout, _flags);
if (!isValid(handle) )
{
@@ -3271,11 +3452,13 @@ namespace bgfx
m_dynVertexBufferAllocator.free(uint64_t(dvb.m_handle.idx)<<32 | dvb.m_offset);
m_dynVertexBufferAllocator.compact();
- uint64_t ptr = allocDynamicVertexBuffer(_mem->size, dvb.m_flags);
+ const uint32_t size = bx::strideAlign<16>(_mem->size, dvb.m_stride)+dvb.m_stride;
+ const uint64_t ptr = allocDynamicVertexBuffer(size, dvb.m_flags);
+
dvb.m_handle.idx = uint16_t(ptr>>32);
dvb.m_offset = uint32_t(ptr);
- dvb.m_size = _mem->size;
- dvb.m_numVertices = dvb.m_size / dvb.m_stride;
+ dvb.m_size = size;
+ dvb.m_numVertices = _mem->size / dvb.m_stride;
dvb.m_startVertex = bx::strideAlign(dvb.m_offset, dvb.m_stride)/dvb.m_stride;
}
@@ -3307,14 +3490,14 @@ namespace bgfx
void destroyDynamicVertexBufferInternal(DynamicVertexBufferHandle _handle)
{
- VertexDeclHandle declHandle = m_declRef.release(_handle);
- BGFX_CHECK_HANDLE_INVALID_OK("destroyDynamicVertexBufferInternal", m_vertexDeclHandle, declHandle);
+ VertexLayoutHandle layoutHandle = m_vertexLayoutRef.release(_handle);
+ BGFX_CHECK_HANDLE_INVALID_OK("destroyDynamicVertexBufferInternal", m_layoutHandle, layoutHandle);
- if (isValid(declHandle) )
+ if (isValid(layoutHandle) )
{
- CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyVertexDecl);
- cmdbuf.write(declHandle);
- m_render->free(declHandle);
+ CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyVertexLayout);
+ cmdbuf.write(layoutHandle);
+ m_render->free(layoutHandle);
}
DynamicVertexBuffer& dvb = m_dynamicVertexBuffers[_handle.idx];
@@ -3372,6 +3555,8 @@ namespace bgfx
tib->data = (uint8_t *)tib + BX_ALIGN_16(sizeof(TransientIndexBuffer) );
tib->size = _size;
tib->handle = handle;
+
+ setDebugName(convert(handle), "Transient Index Buffer");
}
return tib;
@@ -3400,7 +3585,7 @@ namespace bgfx
_tib->startIndex = bx::strideAlign(offset, 2)/2;
}
- TransientVertexBuffer* createTransientVertexBuffer(uint32_t _size, const VertexDecl* _decl = NULL)
+ TransientVertexBuffer* createTransientVertexBuffer(uint32_t _size, const VertexLayout* _layout = NULL)
{
TransientVertexBuffer* tvb = NULL;
@@ -3410,14 +3595,14 @@ namespace bgfx
if (isValid(handle) )
{
uint16_t stride = 0;
- VertexDeclHandle declHandle = BGFX_INVALID_HANDLE;
+ VertexLayoutHandle layoutHandle = BGFX_INVALID_HANDLE;
- if (NULL != _decl)
+ if (NULL != _layout)
{
- declHandle = findVertexDecl(*_decl);
- m_declRef.add(handle, declHandle, _decl->m_hash);
+ layoutHandle = findVertexLayout(*_layout);
+ m_vertexLayoutRef.add(handle, layoutHandle, _layout->m_hash);
- stride = _decl->m_stride;
+ stride = _layout->m_stride;
}
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateDynamicVertexBuffer);
@@ -3433,7 +3618,9 @@ namespace bgfx
tvb->startVertex = 0;
tvb->stride = stride;
tvb->handle = handle;
- tvb->decl = declHandle;
+ tvb->layoutHandle = layoutHandle;
+
+ setDebugName(convert(handle), "Transient Vertex Buffer");
}
return tvb;
@@ -3448,32 +3635,32 @@ namespace bgfx
BX_ALIGNED_FREE(g_allocator, _tvb, 16);
}
- BGFX_API_FUNC(void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint32_t _num, const VertexDecl& _decl) )
+ BGFX_API_FUNC(void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint32_t _num, const VertexLayout& _layout) )
{
BGFX_MUTEX_SCOPE(m_resourceApiLock);
- VertexDeclHandle declHandle = m_declRef.find(_decl.m_hash);
+ VertexLayoutHandle layoutHandle = m_vertexLayoutRef.find(_layout.m_hash);
TransientVertexBuffer& dvb = *m_submit->m_transientVb;
- if (!isValid(declHandle) )
+ if (!isValid(layoutHandle) )
{
- VertexDeclHandle temp = { m_vertexDeclHandle.alloc() };
- declHandle = temp;
- CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateVertexDecl);
- cmdbuf.write(declHandle);
- cmdbuf.write(_decl);
- m_declRef.add(declHandle, _decl.m_hash);
+ VertexLayoutHandle temp = { m_layoutHandle.alloc() };
+ layoutHandle = temp;
+ CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateVertexLayout);
+ cmdbuf.write(layoutHandle);
+ cmdbuf.write(_layout);
+ m_vertexLayoutRef.add(layoutHandle, _layout.m_hash);
}
- uint32_t offset = m_submit->allocTransientVertexBuffer(_num, _decl.m_stride);
+ uint32_t offset = m_submit->allocTransientVertexBuffer(_num, _layout.m_stride);
_tvb->data = &dvb.data[offset];
- _tvb->size = _num * _decl.m_stride;
- _tvb->startVertex = bx::strideAlign(offset, _decl.m_stride)/_decl.m_stride;
- _tvb->stride = _decl.m_stride;
+ _tvb->size = _num * _layout.m_stride;
+ _tvb->startVertex = bx::strideAlign(offset, _layout.m_stride)/_layout.m_stride;
+ _tvb->stride = _layout.m_stride;
_tvb->handle = dvb.handle;
- _tvb->decl = declHandle;
+ _tvb->layoutHandle = layoutHandle;
}
BGFX_API_FUNC(void allocInstanceDataBuffer(InstanceDataBuffer* _idb, uint32_t _num, uint16_t _stride) )
@@ -3647,7 +3834,7 @@ namespace bgfx
bx::read(&reader, regCount, &err);
PredefinedUniform::Enum predefined = nameToPredefinedUniformEnum(name);
- if (PredefinedUniform::Count == predefined)
+ if (PredefinedUniform::Count == predefined && UniformType::End != UniformType::Enum(type))
{
uniforms[sr.m_num] = createUniform(name, UniformType::Enum(type), regCount);
sr.m_num++;
@@ -3665,6 +3852,8 @@ namespace bgfx
cmdbuf.write(handle);
cmdbuf.write(_mem);
+ setDebugName(convert(handle) );
+
return handle;
}
@@ -3689,12 +3878,21 @@ namespace bgfx
void setName(Handle _handle, const bx::StringView& _name)
{
+ char tmp[1024];
+ uint16_t len = 1+(uint16_t)bx::snprintf(tmp, BX_COUNTOF(tmp), "%sH %d: %.*s", getTypeName(_handle), _handle.idx, _name.getLength(), _name.getPtr() );
+
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::SetName);
cmdbuf.write(_handle);
- uint16_t len = uint16_t(_name.getLength()+1);
cmdbuf.write(len);
- cmdbuf.write(_name.getPtr(), len-1);
- cmdbuf.write('\0');
+ cmdbuf.write(tmp, len);
+ }
+
+ void setDebugName(Handle _handle, const bx::StringView& _name = "")
+ {
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
+ {
+ setName(_handle, _name);
+ }
}
BGFX_API_FUNC(void setName(ShaderHandle _handle, const bx::StringView& _name) )
@@ -3975,6 +4173,8 @@ namespace bgfx
cmdbuf.write(_flags);
cmdbuf.write(_skip);
+ setDebugName(convert(handle) );
+
return handle;
}
@@ -4237,6 +4437,18 @@ namespace bgfx
return handle;
}
+ BGFX_API_FUNC(void setName(FrameBufferHandle _handle, const bx::StringView& _name) )
+ {
+ BGFX_MUTEX_SCOPE(m_resourceApiLock);
+
+ BGFX_CHECK_HANDLE("setName", m_frameBufferHandle, _handle);
+
+ FrameBufferRef& ref = m_frameBufferRef[_handle.idx];
+ ref.m_name.set(_name);
+
+// setName(convert(_handle), _name);
+ }
+
BGFX_API_FUNC(TextureHandle getTexture(FrameBufferHandle _handle, uint8_t _attachment) )
{
BGFX_MUTEX_SCOPE(m_resourceApiLock);
@@ -4265,6 +4477,8 @@ namespace bgfx
cmdbuf.write(_handle);
FrameBufferRef& ref = m_frameBufferRef[_handle.idx];
+ ref.m_name.clear();
+
if (!ref.m_window)
{
for (uint32_t ii = 0; ii < BX_COUNTOF(ref.un.m_th); ++ii)
@@ -4521,9 +4735,9 @@ namespace bgfx
m_view[_id].setFrameBuffer(_handle);
}
- BGFX_API_FUNC(void setViewTransform(ViewId _id, const void* _view, const void* _proj, uint8_t _flags, const void* _proj1) )
+ BGFX_API_FUNC(void setViewTransform(ViewId _id, const void* _view, const void* _proj) )
{
- m_view[_id].setTransform(_view, _proj, _flags, _proj1);
+ m_view[_id].setTransform(_view, _proj);
}
BGFX_API_FUNC(void resetView(ViewId _id) )
@@ -4709,7 +4923,7 @@ namespace bgfx
bx::HandleAllocT<BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS> m_dynamicVertexBufferHandle;
bx::HandleAllocT<BGFX_CONFIG_MAX_INDEX_BUFFERS> m_indexBufferHandle;
- bx::HandleAllocT<BGFX_CONFIG_MAX_VERTEX_DECLS > m_vertexDeclHandle;
+ bx::HandleAllocT<BGFX_CONFIG_MAX_VERTEX_LAYOUTS > m_layoutHandle;
bx::HandleAllocT<BGFX_CONFIG_MAX_VERTEX_BUFFERS> m_vertexBufferHandle;
bx::HandleAllocT<BGFX_CONFIG_MAX_SHADERS> m_shaderHandle;
@@ -4719,94 +4933,21 @@ namespace bgfx
bx::HandleAllocT<BGFX_CONFIG_MAX_UNIFORMS> m_uniformHandle;
bx::HandleAllocT<BGFX_CONFIG_MAX_OCCLUSION_QUERIES> m_occlusionQueryHandle;
- struct ShaderRef
- {
- UniformHandle* m_uniforms;
- String m_name;
- uint32_t m_hashIn;
- uint32_t m_hashOut;
- int16_t m_refCount;
- uint16_t m_num;
- };
-
- struct ProgramRef
- {
- ShaderHandle m_vsh;
- ShaderHandle m_fsh;
- int16_t m_refCount;
- };
-
- struct UniformRef
- {
- String m_name;
- UniformType::Enum m_type;
- uint16_t m_num;
- int16_t m_refCount;
- };
-
- struct TextureRef
- {
- void init(
- BackbufferRatio::Enum _ratio
- , TextureFormat::Enum _format
- , uint32_t _storageSize
- , uint8_t _numMips
- , uint16_t _numLayers
- , bool _ptrPending
- , bool _immutable
- , bool _rt
- )
- {
- m_ptr = _ptrPending ? (void*)UINTPTR_MAX : NULL;
- m_storageSize = _storageSize;
- m_refCount = 1;
- m_bbRatio = uint8_t(_ratio);
- m_format = uint8_t(_format);
- m_numMips = _numMips;
- m_numLayers = _numLayers;
- m_owned = false;
- m_immutable = _immutable;
- m_rt = _rt;
- }
-
- String m_name;
- void* m_ptr;
- uint32_t m_storageSize;
- int16_t m_refCount;
- uint8_t m_bbRatio;
- uint8_t m_format;
- uint8_t m_numMips;
- uint16_t m_numLayers;
- bool m_owned;
- bool m_immutable;
- bool m_rt;
- };
-
- struct FrameBufferRef
- {
- union un
- {
- TextureHandle m_th[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
- void* m_nwh;
- } un;
- bool m_window;
- };
-
typedef bx::HandleHashMapT<BGFX_CONFIG_MAX_UNIFORMS*2> UniformHashMap;
UniformHashMap m_uniformHashMap;
- UniformRef m_uniformRef[BGFX_CONFIG_MAX_UNIFORMS];
+ UniformRef m_uniformRef[BGFX_CONFIG_MAX_UNIFORMS];
typedef bx::HandleHashMapT<BGFX_CONFIG_MAX_SHADERS*2> ShaderHashMap;
ShaderHashMap m_shaderHashMap;
- ShaderRef m_shaderRef[BGFX_CONFIG_MAX_SHADERS];
+ ShaderRef m_shaderRef[BGFX_CONFIG_MAX_SHADERS];
typedef bx::HandleHashMapT<BGFX_CONFIG_MAX_PROGRAMS*2> ProgramHashMap;
ProgramHashMap m_programHashMap;
- ProgramRef m_programRef[BGFX_CONFIG_MAX_PROGRAMS];
+ ProgramRef m_programRef[BGFX_CONFIG_MAX_PROGRAMS];
- TextureRef m_textureRef[BGFX_CONFIG_MAX_TEXTURES];
+ TextureRef m_textureRef[BGFX_CONFIG_MAX_TEXTURES];
FrameBufferRef m_frameBufferRef[BGFX_CONFIG_MAX_FRAME_BUFFERS];
- VertexDeclRef m_declRef;
+ VertexLayoutRef m_vertexLayoutRef;
ViewId m_viewRemap[BGFX_CONFIG_MAX_VIEWS];
uint32_t m_seq[BGFX_CONFIG_MAX_VIEWS];
diff --git a/3rdparty/bgfx/src/bgfx_shader.sh b/3rdparty/bgfx/src/bgfx_shader.sh
index ce8761ed10a..5349404311d 100644
--- a/3rdparty/bgfx/src/bgfx_shader.sh
+++ b/3rdparty/bgfx/src/bgfx_shader.sh
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -36,7 +36,10 @@
# define ARRAY_END() }
#endif // BGFX_SHADER_LANGUAGE_GLSL
-#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_SPIRV
+#if BGFX_SHADER_LANGUAGE_HLSL \
+ || BGFX_SHADER_LANGUAGE_PSSL \
+ || BGFX_SHADER_LANGUAGE_SPIRV \
+ || BGFX_SHADER_LANGUAGE_METAL
# define CONST(_x) static const _x
# define dFdx(_x) ddx(_x)
# define dFdy(_y) ddy(-_y)
@@ -47,26 +50,27 @@
# define bvec3 bool3
# define bvec4 bool4
+
# 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 || BGFX_SHADER_LANGUAGE_SPIRV
-# if BGFX_SHADER_LANGUAGE_HLSL > 4 || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_SPIRV
+# if BGFX_SHADER_LANGUAGE_HLSL > 3 || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_SPIRV || BGFX_SHADER_LANGUAGE_METAL
+# if BGFX_SHADER_LANGUAGE_HLSL > 4 || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_SPIRV || BGFX_SHADER_LANGUAGE_METAL
# 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
+# if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_SPIRV || BGFX_SHADER_LANGUAGE_METAL
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
+# endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_SPIRV || BGFX_SHADER_LANGUAGE_METAL
float uintBitsToFloat(uint _x) { return asfloat(_x); }
vec2 uintBitsToFloat(uint2 _x) { return asfloat(_x); }
@@ -128,6 +132,12 @@ struct BgfxSampler2DShadow
Texture2D m_texture;
};
+struct BgfxSampler2DArrayShadow
+{
+ SamplerComparisonState m_sampler;
+ Texture2DArray m_texture;
+};
+
struct BgfxSampler3D
{
SamplerState m_sampler;
@@ -150,6 +160,12 @@ struct BgfxSamplerCube
TextureCube m_texture;
};
+struct BgfxSamplerCubeShadow
+{
+ SamplerComparisonState m_sampler;
+ TextureCube m_texture;
+};
+
struct BgfxSampler2DMS
{
Texture2DMS<vec4> m_texture;
@@ -160,11 +176,21 @@ vec4 bgfxTexture2D(BgfxSampler2D _sampler, vec2 _coord)
return _sampler.m_texture.Sample(_sampler.m_sampler, _coord);
}
+vec4 bgfxTexture2DBias(BgfxSampler2D _sampler, vec2 _coord, float _bias)
+{
+ return _sampler.m_texture.SampleBias(_sampler.m_sampler, _coord, _bias);
+}
+
vec4 bgfxTexture2DLod(BgfxSampler2D _sampler, vec2 _coord, float _level)
{
return _sampler.m_texture.SampleLevel(_sampler.m_sampler, _coord, _level);
}
+vec4 bgfxTexture2DLodOffset(BgfxSampler2D _sampler, vec2 _coord, float _level, ivec2 _offset)
+{
+ return _sampler.m_texture.SampleLevel(_sampler.m_sampler, _coord, _level, _offset);
+}
+
vec4 bgfxTexture2DProj(BgfxSampler2D _sampler, vec3 _coord)
{
vec2 coord = _coord.xy * rcp(_coord.z);
@@ -192,6 +218,11 @@ vec4 bgfxTexture2DArrayLod(BgfxSampler2DArray _sampler, vec3 _coord, float _lod)
return _sampler.m_texture.SampleLevel(_sampler.m_sampler, _coord, _lod);
}
+vec4 bgfxTexture2DArrayLodOffset(BgfxSampler2DArray _sampler, vec3 _coord, float _level, ivec2 _offset)
+{
+ return _sampler.m_texture.SampleLevel(_sampler.m_sampler, _coord, _level, _offset);
+}
+
float bgfxShadow2D(BgfxSampler2DShadow _sampler, vec3 _coord)
{
return _sampler.m_texture.SampleCmpLevelZero(_sampler.m_sampler, _coord.xy, _coord.z);
@@ -203,6 +234,11 @@ float bgfxShadow2DProj(BgfxSampler2DShadow _sampler, vec4 _coord)
return _sampler.m_texture.SampleCmpLevelZero(_sampler.m_sampler, coord.xy, coord.z);
}
+vec4 bgfxShadow2DArray(BgfxSampler2DArrayShadow _sampler, vec4 _coord)
+{
+ return _sampler.m_texture.SampleCmpLevelZero(_sampler.m_sampler, _coord.xyz, _coord.w);
+}
+
vec4 bgfxTexture3D(BgfxSampler3D _sampler, vec3 _coord)
{
return _sampler.m_texture.Sample(_sampler.m_sampler, _coord);
@@ -232,16 +268,31 @@ vec4 bgfxTextureCube(BgfxSamplerCube _sampler, vec3 _coord)
return _sampler.m_texture.Sample(_sampler.m_sampler, _coord);
}
+vec4 bgfxTextureCubeBias(BgfxSamplerCube _sampler, vec3 _coord, float _bias)
+{
+ return _sampler.m_texture.SampleBias(_sampler.m_sampler, _coord, _bias);
+}
+
vec4 bgfxTextureCubeLod(BgfxSamplerCube _sampler, vec3 _coord, float _level)
{
return _sampler.m_texture.SampleLevel(_sampler.m_sampler, _coord, _level);
}
+float bgfxShadowCube(BgfxSamplerCubeShadow _sampler, vec4 _coord)
+{
+ return _sampler.m_texture.SampleCmpLevelZero(_sampler.m_sampler, _coord.xyz, _coord.w);
+}
+
vec4 bgfxTexelFetch(BgfxSampler2D _sampler, ivec2 _coord, int _lod)
{
return _sampler.m_texture.Load(ivec3(_coord, _lod) );
}
+vec4 bgfxTexelFetchOffset(BgfxSampler2D _sampler, ivec2 _coord, int _lod, ivec2 _offset)
+{
+ return _sampler.m_texture.Load(ivec3(_coord, _lod), _offset );
+}
+
vec2 bgfxTextureSize(BgfxSampler2D _sampler, int _lod)
{
vec2 result;
@@ -249,6 +300,19 @@ vec2 bgfxTextureSize(BgfxSampler2D _sampler, int _lod)
return result;
}
+vec4 bgfxTextureGather(BgfxSampler2D _sampler, vec2 _coord)
+{
+ return _sampler.m_texture.GatherRed(_sampler.m_sampler, _coord );
+}
+vec4 bgfxTextureGatherOffset(BgfxSampler2D _sampler, vec2 _coord, ivec2 _offset)
+{
+ return _sampler.m_texture.GatherRed(_sampler.m_sampler, _coord, _offset );
+}
+vec4 bgfxTextureGather(BgfxSampler2DArray _sampler, vec3 _coord)
+{
+ return _sampler.m_texture.GatherRed(_sampler.m_sampler, _coord );
+}
+
ivec4 bgfxTexelFetch(BgfxISampler2D _sampler, ivec2 _coord, int _lod)
{
return _sampler.m_texture.Load(ivec3(_coord, _lod) );
@@ -264,6 +328,11 @@ vec4 bgfxTexelFetch(BgfxSampler2DMS _sampler, ivec2 _coord, int _sampleIdx)
return _sampler.m_texture.Load(_coord, _sampleIdx);
}
+vec4 bgfxTexelFetch(BgfxSampler2DArray _sampler, ivec3 _coord, int _lod)
+{
+ return _sampler.m_texture.Load(ivec4(_coord, _lod) );
+}
+
vec4 bgfxTexelFetch(BgfxSampler3D _sampler, ivec3 _coord, int _lod)
{
return _sampler.m_texture.Load(ivec4(_coord, _lod) );
@@ -288,7 +357,9 @@ vec3 bgfxTextureSize(BgfxSampler3D _sampler, int _lod)
static BgfxUSampler2D _name = { _name ## Texture }
# define sampler2D BgfxSampler2D
# define texture2D(_sampler, _coord) bgfxTexture2D(_sampler, _coord)
+# define texture2DBias(_sampler, _coord, _bias) bgfxTexture2DBias(_sampler, _coord, _bias)
# define texture2DLod(_sampler, _coord, _level) bgfxTexture2DLod(_sampler, _coord, _level)
+# define texture2DLodOffset(_sampler, _coord, _level, _offset) bgfxTexture2DLodOffset(_sampler, _coord, _level, _offset)
# define texture2DProj(_sampler, _coord) bgfxTexture2DProj(_sampler, _coord)
# define texture2DGrad(_sampler, _coord, _dPdx, _dPdy) bgfxTexture2DGrad(_sampler, _coord, _dPdx, _dPdy)
@@ -299,6 +370,7 @@ vec3 bgfxTextureSize(BgfxSampler3D _sampler, int _lod)
# define sampler2DArray BgfxSampler2DArray
# define texture2DArray(_sampler, _coord) bgfxTexture2DArray(_sampler, _coord)
# define texture2DArrayLod(_sampler, _coord, _lod) bgfxTexture2DArrayLod(_sampler, _coord, _lod)
+# define texture2DArrayLodOffset(_sampler, _coord, _level, _offset) bgfxTexture2DArrayLodOffset(_sampler, _coord, _level, _offset)
# define SAMPLER2DMS(_name, _reg) \
uniform Texture2DMS<vec4> _name ## Texture : REGISTER(t, _reg); \
@@ -313,6 +385,13 @@ vec3 bgfxTextureSize(BgfxSampler3D _sampler, int _lod)
# define shadow2D(_sampler, _coord) bgfxShadow2D(_sampler, _coord)
# define shadow2DProj(_sampler, _coord) bgfxShadow2DProj(_sampler, _coord)
+# define SAMPLER2DARRAYSHADOW(_name, _reg) \
+ uniform SamplerComparisonState _name ## SamplerComparison : REGISTER(s, _reg); \
+ uniform Texture2DArray _name ## Texture : REGISTER(t, _reg); \
+ static BgfxSampler2DArrayShadow _name = { _name ## SamplerComparison, _name ## Texture }
+# define sampler2DArrayShadow BgfxSampler2DArrayShadow
+# define shadow2DArray(_sampler, _coord) bgfxShadow2DArray(_sampler, _coord)
+
# define SAMPLER3D(_name, _reg) \
uniform SamplerState _name ## Sampler : REGISTER(s, _reg); \
uniform Texture3D _name ## Texture : REGISTER(t, _reg); \
@@ -333,10 +412,21 @@ vec3 bgfxTextureSize(BgfxSampler3D _sampler, int _lod)
static BgfxSamplerCube _name = { _name ## Sampler, _name ## Texture }
# define samplerCube BgfxSamplerCube
# define textureCube(_sampler, _coord) bgfxTextureCube(_sampler, _coord)
+# define textureCubeBias(_sampler, _coord, _bias) bgfxTextureCubeBias(_sampler, _coord, _bias)
# define textureCubeLod(_sampler, _coord, _level) bgfxTextureCubeLod(_sampler, _coord, _level)
+# define SAMPLERCUBESHADOW(_name, _reg) \
+ uniform SamplerComparisonState _name ## SamplerComparison : REGISTER(s, _reg); \
+ uniform TextureCube _name ## Texture : REGISTER(t, _reg); \
+ static BgfxSamplerCubeShadow _name = { _name ## SamplerComparison, _name ## Texture }
+# define samplerCubeShadow BgfxSamplerCubeShadow
+# define shadowCube(_sampler, _coord) bgfxShadowCube(_sampler, _coord)
+
# define texelFetch(_sampler, _coord, _lod) bgfxTexelFetch(_sampler, _coord, _lod)
+# define texelFetchOffset(_sampler, _coord, _lod, _offset) bgfxTexelFetchOffset(_sampler, _coord, _lod, _offset)
# define textureSize(_sampler, _lod) bgfxTextureSize(_sampler, _lod)
+# define textureGather(_sampler, _coord) bgfxTextureGather(_sampler, _coord)
+# define textureGatherOffset(_sampler, _coord, _offset) bgfxTextureGatherOffset(_sampler, _coord, _offset)
# else
# define sampler2DShadow sampler2D
@@ -465,6 +555,9 @@ vec4 mod(vec4 _a, vec4 _b) { return _a - _b * floor(_a / _b); }
# define ISAMPLER3D(_name, _reg) uniform isampler3D _name
# define USAMPLER3D(_name, _reg) uniform usampler3D _name
+# define texture2DBias(_sampler, _coord, _bias) texture2D(_sampler, _coord, _bias)
+# define textureCubeBias(_sampler, _coord, _bias) textureCube(_sampler, _coord, _bias)
+
# if BGFX_SHADER_LANGUAGE_GLSL >= 130
# define texture2D(_sampler, _coord) texture(_sampler, _coord)
# define texture2DArray(_sampler, _coord) texture(_sampler, _coord)
@@ -486,27 +579,36 @@ 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 || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_SPIRV
+#if BGFX_SHADER_LANGUAGE_GLSL >= 130 || BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_SPIRV || BGFX_SHADER_LANGUAGE_METAL
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 || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_SPIRV
+#endif // BGFX_SHADER_LANGUAGE_GLSL >= 130 || BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_SPIRV || BGFX_SHADER_LANGUAGE_METAL
mat4 mtxFromRows(vec4 _0, vec4 _1, vec4 _2, vec4 _3)
{
#if BGFX_SHADER_LANGUAGE_GLSL
- return transpose(mat4(_0, _1, _2, _3) );
+ return transpose(mat4(_0, _1, _2, _3) );
#else
- return mat4(_0, _1, _2, _3);
+ return mat4(_0, _1, _2, _3);
#endif // BGFX_SHADER_LANGUAGE_GLSL
}
mat4 mtxFromCols(vec4 _0, vec4 _1, vec4 _2, vec4 _3)
{
#if BGFX_SHADER_LANGUAGE_GLSL
- return mat4(_0, _1, _2, _3);
+ return mat4(_0, _1, _2, _3);
+#else
+ return transpose(mat4(_0, _1, _2, _3) );
+#endif // BGFX_SHADER_LANGUAGE_GLSL
+}
+
+mat3 mtxFromCols(vec3 _0, vec3 _1, vec3 _2)
+{
+#if BGFX_SHADER_LANGUAGE_GLSL
+ return mat3(_0, _1, _2);
#else
- return transpose(mat4(_0, _1, _2, _3) );
+ return transpose(mat3(_0, _1, _2) );
#endif // BGFX_SHADER_LANGUAGE_GLSL
}
diff --git a/3rdparty/bgfx/src/charset.h b/3rdparty/bgfx/src/charset.h
index e9233a32e70..6e41643a6a7 100644
--- a/3rdparty/bgfx/src/charset.h
+++ b/3rdparty/bgfx/src/charset.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/config.h b/3rdparty/bgfx/src/config.h
index d8a1ab97164..dbf746e638d 100644
--- a/3rdparty/bgfx/src/config.h
+++ b/3rdparty/bgfx/src/config.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -15,11 +15,12 @@
#if !defined(BGFX_CONFIG_RENDERER_DIRECT3D9) \
&& !defined(BGFX_CONFIG_RENDERER_DIRECT3D11) \
&& !defined(BGFX_CONFIG_RENDERER_DIRECT3D12) \
+ && !defined(BGFX_CONFIG_RENDERER_GNM) \
&& !defined(BGFX_CONFIG_RENDERER_METAL) \
+ && !defined(BGFX_CONFIG_RENDERER_NVN) \
&& !defined(BGFX_CONFIG_RENDERER_OPENGL) \
&& !defined(BGFX_CONFIG_RENDERER_OPENGLES) \
- && !defined(BGFX_CONFIG_RENDERER_VULKAN) \
- && !defined(BGFX_CONFIG_RENDERER_GNM)
+ && !defined(BGFX_CONFIG_RENDERER_VULKAN)
# ifndef BGFX_CONFIG_RENDERER_DIRECT3D9
# define BGFX_CONFIG_RENDERER_DIRECT3D9 (0 \
@@ -43,6 +44,12 @@
? 1 : 0)
# endif // BGFX_CONFIG_RENDERER_DIRECT3D12
+# 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_METAL
# define BGFX_CONFIG_RENDERER_METAL (0 \
|| (BX_PLATFORM_IOS && BX_CPU_ARM) \
@@ -50,15 +57,29 @@
? 1 : 0)
# endif // BGFX_CONFIG_RENDERER_METAL
+# ifndef BGFX_CONFIG_RENDERER_NVN
+# define BGFX_CONFIG_RENDERER_NVN (0 \
+ || BX_PLATFORM_NX \
+ ? 1 : 0)
+# endif // BGFX_CONFIG_RENDERER_NVN
+
+# ifndef BGFX_CONFIG_RENDERER_OPENGL_MIN_VERSION
+# define BGFX_CONFIG_RENDERER_OPENGL_MIN_VERSION 1
+# endif // BGFX_CONFIG_RENDERER_OPENGL_MIN_VERSION
+
# ifndef BGFX_CONFIG_RENDERER_OPENGL
# define BGFX_CONFIG_RENDERER_OPENGL (0 \
|| BX_PLATFORM_BSD \
|| BX_PLATFORM_LINUX \
|| BX_PLATFORM_OSX \
|| BX_PLATFORM_WINDOWS \
- ? 1 : 0)
+ ? BGFX_CONFIG_RENDERER_OPENGL_MIN_VERSION : 0)
# endif // BGFX_CONFIG_RENDERER_OPENGL
+# ifndef BGFX_CONFIG_RENDERER_OPENGLES_MIN_VERSION
+# define BGFX_CONFIG_RENDERER_OPENGLES_MIN_VERSION 1
+# endif // BGFX_CONFIG_RENDERER_OPENGLES_MIN_VERSION
+
# ifndef BGFX_CONFIG_RENDERER_OPENGLES
# define BGFX_CONFIG_RENDERER_OPENGLES (0 \
|| BX_PLATFORM_ANDROID \
@@ -67,7 +88,7 @@
|| BX_PLATFORM_RPI \
|| BX_PLATFORM_STEAMLINK \
|| BX_PLATFORM_NX \
- ? 1 : 0)
+ ? BGFX_CONFIG_RENDERER_OPENGLES_MIN_VERSION : 0)
# endif // BGFX_CONFIG_RENDERER_OPENGLES
# ifndef BGFX_CONFIG_RENDERER_VULKAN
@@ -76,15 +97,10 @@
|| BX_PLATFORM_LINUX \
|| BX_PLATFORM_WINDOWS \
|| BX_PLATFORM_NX \
+ || BX_PLATFORM_OSX \
? 1 : 0)
# endif // BGFX_CONFIG_RENDERER_VULKAN
-# ifndef BGFX_CONFIG_RENDERER_GNM
-# define BGFX_CONFIG_RENDERER_GNM (0 \
- || BX_PLATFORM_PS4 \
- ? 1 : 0)
-# endif // BGFX_CONFIG_RENDERER_GNM
-
#else
# ifndef BGFX_CONFIG_RENDERER_DIRECT3D9
# define BGFX_CONFIG_RENDERER_DIRECT3D9 0
@@ -98,10 +114,18 @@
# define BGFX_CONFIG_RENDERER_DIRECT3D12 0
# endif // BGFX_CONFIG_RENDERER_DIRECT3D12
+# ifndef BGFX_CONFIG_RENDERER_GNM
+# define BGFX_CONFIG_RENDERER_GNM 0
+# endif // BGFX_CONFIG_RENDERER_GNM
+
# ifndef BGFX_CONFIG_RENDERER_METAL
# define BGFX_CONFIG_RENDERER_METAL 0
# endif // BGFX_CONFIG_RENDERER_METAL
+# ifndef BGFX_CONFIG_RENDERER_NVN
+# define BGFX_CONFIG_RENDERER_NVN 0
+# endif // BGFX_CONFIG_RENDERER_NVN
+
# ifndef BGFX_CONFIG_RENDERER_OPENGL
# define BGFX_CONFIG_RENDERER_OPENGL 0
# endif // BGFX_CONFIG_RENDERER_OPENGL
@@ -113,10 +137,6 @@
# ifndef BGFX_CONFIG_RENDERER_VULKAN
# define BGFX_CONFIG_RENDERER_VULKAN 0
# endif // BGFX_CONFIG_RENDERER_VULKAN
-
-# ifndef BGFX_CONFIG_RENDERER_GNM
-# define BGFX_CONFIG_RENDERER_GNM 0
-# endif // BGFX_CONFIG_RENDERER_GNM
#endif // !defined...
#if BGFX_CONFIG_RENDERER_OPENGL && BGFX_CONFIG_RENDERER_OPENGL < 21
@@ -148,21 +168,16 @@
# define BGFX_CONFIG_DEBUG_PERFHUD 0
#endif // BGFX_CONFIG_DEBUG_NVPERFHUD
-/// Enable PIX markers.
-#ifndef BGFX_CONFIG_DEBUG_PIX
-# define BGFX_CONFIG_DEBUG_PIX BGFX_CONFIG_DEBUG
-#endif // BGFX_CONFIG_DEBUG_PIX
+/// Enable annotation for graphics debuggers.
+#ifndef BGFX_CONFIG_DEBUG_ANNOTATION
+# define BGFX_CONFIG_DEBUG_ANNOTATION BGFX_CONFIG_DEBUG
+#endif // BGFX_CONFIG_DEBUG_ANNOTATION
/// Enable DX11 object names.
#ifndef BGFX_CONFIG_DEBUG_OBJECT_NAME
-# define BGFX_CONFIG_DEBUG_OBJECT_NAME BGFX_CONFIG_DEBUG
+# define BGFX_CONFIG_DEBUG_OBJECT_NAME BGFX_CONFIG_DEBUG_ANNOTATION
#endif // BGFX_CONFIG_DEBUG_OBJECT_NAME
-/// Enable Metal markers.
-#ifndef BGFX_CONFIG_DEBUG_MTL
-# define BGFX_CONFIG_DEBUG_MTL BGFX_CONFIG_DEBUG
-#endif // BGFX_CONFIG_DEBUG_MTL
-
/// Enable uniform debug checks.
#ifndef BGFX_CONFIG_DEBUG_UNIFORM
# define BGFX_CONFIG_DEBUG_UNIFORM BGFX_CONFIG_DEBUG
@@ -220,9 +235,9 @@ BX_STATIC_ASSERT(bx::isPowerOf2(BGFX_CONFIG_MAX_VIEWS), "BGFX_CONFIG_MAX_VIEWS m
# define BGFX_CONFIG_MAX_VIEW_NAME 256
#endif // BGFX_CONFIG_MAX_VIEW_NAME
-#ifndef BGFX_CONFIG_MAX_VERTEX_DECLS
-# define BGFX_CONFIG_MAX_VERTEX_DECLS 64
-#endif // BGFX_CONFIG_MAX_VERTEX_DECLS
+#ifndef BGFX_CONFIG_MAX_VERTEX_LAYOUTS
+# define BGFX_CONFIG_MAX_VERTEX_LAYOUTS 64
+#endif // BGFX_CONFIG_MAX_VERTEX_LAYOUTS
#ifndef BGFX_CONFIG_MAX_INDEX_BUFFERS
# define BGFX_CONFIG_MAX_INDEX_BUFFERS (4<<10)
diff --git a/3rdparty/bgfx/src/debug_renderdoc.cpp b/3rdparty/bgfx/src/debug_renderdoc.cpp
index c802806e485..35fc2ab05ce 100644
--- a/3rdparty/bgfx/src/debug_renderdoc.cpp
+++ b/3rdparty/bgfx/src/debug_renderdoc.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/debug_renderdoc.h b/3rdparty/bgfx/src/debug_renderdoc.h
index 0c62e777532..6a2ac978f74 100644
--- a/3rdparty/bgfx/src/debug_renderdoc.h
+++ b/3rdparty/bgfx/src/debug_renderdoc.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/dxgi.cpp b/3rdparty/bgfx/src/dxgi.cpp
index 4f2bc7c0984..512dcda4c95 100644
--- a/3rdparty/bgfx/src/dxgi.cpp
+++ b/3rdparty/bgfx/src/dxgi.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/dxgi.h b/3rdparty/bgfx/src/dxgi.h
index 604a50eb984..7b7a95e784f 100644
--- a/3rdparty/bgfx/src/dxgi.h
+++ b/3rdparty/bgfx/src/dxgi.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/fs_clear0.bin.h b/3rdparty/bgfx/src/fs_clear0.bin.h
index 346466213ff..508c5ecf075 100644
--- a/3rdparty/bgfx/src/fs_clear0.bin.h
+++ b/3rdparty/bgfx/src/fs_clear0.bin.h
@@ -9,49 +9,50 @@ 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_spv[641] =
+static const uint8_t fs_clear0_spv[661] =
{
- 0x46, 0x53, 0x48, 0x05, 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, 0x01, 0x00, 0x00, 0x01, // clear_color.....
- 0x00, 0x58, 0x02, 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x08, // .X.....#........
- 0x00, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, // .F..............
- 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, // .........GLSL.st
- 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, // d.450...........
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // ................
- 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, // .main....-......
- 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, // ................
- 0x00, 0xf4, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, // .............mai
- 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6c, // n........ ...$Gl
- 0x6f, 0x62, 0x61, 0x6c, 0x00, 0x06, 0x00, 0x08, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // obal..... ......
- 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // .bgfx_clear_colo
- 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // r........"......
- 0x00, 0x05, 0x00, 0x06, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, // .....-...bgfx_Fr
- 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x30, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x1f, 0x00, 0x00, // agData0..G......
- 0x00, 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x20, 0x00, 0x00, // .........H... ..
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, // .....#.......G..
- 0x00, 0x20, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, // . .......G..."..
- 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x2d, 0x00, 0x00, // .".......G...-..
- 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, // ................
- 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, // .!..............
- 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // ..... ..........
- 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x1d, 0x00, 0x00, // ................
- 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x1d, 0x00, 0x00, // . .......+......
- 0x00, 0x1e, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, 0x00, 0x1f, 0x00, 0x00, // ................
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x20, 0x00, 0x00, // ............. ..
- 0x00, 0x1f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x21, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // ..... ...!......
- 0x00, 0x20, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x21, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, // . ...;...!..."..
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // .........#... ..
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, // .....+...#...$..
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x25, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // ..... ...%......
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // ..... ...,......
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, // .....;...,...-..
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // .....6..........
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, // ................
- 0x00, 0x41, 0x00, 0x06, 0x00, 0x25, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, // .A...%...D..."..
- 0x00, 0x24, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // .$...$...=......
- 0x00, 0x45, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x2d, 0x00, 0x00, // .E...D...>...-..
- 0x00, 0x45, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, // .E.......8......
- 0x00, // .
+ 0x46, 0x53, 0x48, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, // FSH............b
+ 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x12, // gfx_clear_color.
+ 0x01, 0x00, 0x00, 0x01, 0x00, 0x68, 0x02, 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, // .....h.....#....
+ 0x00, 0x07, 0x00, 0x08, 0x00, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, // .....F..........
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, // .............GLS
+ 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, // L.std.450.......
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x06, 0x00, 0x04, 0x00, 0x00, // ................
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, // .....main....-..
+ 0x00, 0x10, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, // ................
+ 0x00, 0x05, 0x00, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, // ................
+ 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x20, 0x00, 0x00, // .main........ ..
+ 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x00, 0x06, 0x00, 0x08, 0x00, 0x20, 0x00, 0x00, // .$Global..... ..
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, // .....bgfx_clear_
+ 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x22, 0x00, 0x00, // color........"..
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // .........-...bgf
+ 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x30, 0x00, 0x00, 0x47, 0x00, 0x04, // x_FragData0..G..
+ 0x00, 0x1f, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, // .............H..
+ 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // . .......#......
+ 0x00, 0x47, 0x00, 0x03, 0x00, 0x20, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .G... .......G..
+ 0x00, 0x22, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // ."...".......G..
+ 0x00, 0x22, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // ."...!...0...G..
+ 0x00, 0x2d, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, // .-..............
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .....!..........
+ 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, // ......... ......
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, // ................
+ 0x00, 0x1d, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // ..... .......+..
+ 0x00, 0x1d, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, // ................
+ 0x00, 0x1f, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, // ................
+ 0x00, 0x20, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x21, 0x00, 0x00, // . ....... ...!..
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x21, 0x00, 0x00, // ..... ...;...!..
+ 0x00, 0x22, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, // ."...........#..
+ 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, // . .......+...#..
+ 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x25, 0x00, 0x00, // .$....... ...%..
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x2c, 0x00, 0x00, // ......... ...,..
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x2c, 0x00, 0x00, // .........;...,..
+ 0x00, 0x2d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, // .-.......6......
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, // ................
+ 0x00, 0x05, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x25, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, // .....A...%...D..
+ 0x00, 0x22, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, // ."...$...$...=..
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .....E...D...>..
+ 0x00, 0x2d, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, // .-...E.......8..
+ 0x00, 0x00, 0x00, 0x10, 0x00, // .....
};
static const uint8_t fs_clear0_dx9[198] =
{
diff --git a/3rdparty/bgfx/src/fs_clear0.sc b/3rdparty/bgfx/src/fs_clear0.sc
index c3e1572ec44..b631e090bd1 100644
--- a/3rdparty/bgfx/src/fs_clear0.sc
+++ b/3rdparty/bgfx/src/fs_clear0.sc
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/fs_clear1.bin.h b/3rdparty/bgfx/src/fs_clear1.bin.h
index 9d90ec80e99..312341cc175 100644
--- a/3rdparty/bgfx/src/fs_clear1.bin.h
+++ b/3rdparty/bgfx/src/fs_clear1.bin.h
@@ -12,57 +12,58 @@ 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_spv[769] =
+static const uint8_t fs_clear1_spv[789] =
{
- 0x46, 0x53, 0x48, 0x05, 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, 0x02, 0x00, 0x00, 0x02, // clear_color.....
- 0x00, 0xd8, 0x02, 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x08, // .......#........
- 0x00, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, // .Q..............
- 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, // .........GLSL.st
- 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, // d.450...........
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // ................
- 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, // .main....4...6..
- 0x00, 0x10, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, // ................
- 0x00, 0x05, 0x00, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, // ................
- 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x21, 0x00, 0x00, // .main........!..
- 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x00, 0x06, 0x00, 0x08, 0x00, 0x21, 0x00, 0x00, // .$Global.....!..
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, // .....bgfx_clear_
- 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x23, 0x00, 0x00, // color........#..
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x34, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // .........4...bgf
- 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x30, 0x00, 0x00, 0x05, 0x00, 0x06, // x_FragData0.....
- 0x00, 0x36, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, // .6...bgfx_FragDa
- 0x74, 0x61, 0x31, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, // ta1..G... ......
- 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .....H...!......
- 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x21, 0x00, 0x00, // .#.......G...!..
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, // .....G...#..."..
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x34, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G...4......
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x36, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G...6......
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, // .............!..
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, // ................
- 0x00, 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, // . ..............
- 0x00, 0x04, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // ............. ..
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, // .....+..........
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // ......... ......
- 0x00, 0x1f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x21, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // .........!... ..
- 0x00, 0x20, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, // . ...".......!..
- 0x00, 0x3b, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .;..."...#......
- 0x00, 0x15, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .....$... ......
- 0x00, 0x2b, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .+...$...%......
- 0x00, 0x20, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // . ...&..........
- 0x00, 0x2b, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .+...$...)......
- 0x00, 0x20, 0x00, 0x04, 0x00, 0x33, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // . ...3..........
- 0x00, 0x3b, 0x00, 0x04, 0x00, 0x33, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .;...3...4......
- 0x00, 0x3b, 0x00, 0x04, 0x00, 0x33, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .;...3...6......
- 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .6..............
- 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, // .............A..
- 0x00, 0x26, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, // .&...M...#...%..
- 0x00, 0x25, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, // .%...=.......N..
- 0x00, 0x4d, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x26, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, // .M...A...&...O..
- 0x00, 0x23, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, // .#...%...)...=..
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .....P...O...>..
- 0x00, 0x34, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x36, 0x00, 0x00, // .4...N...>...6..
- 0x00, 0x50, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, // .P.......8.....
- 0x00, // .
+ 0x46, 0x53, 0x48, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, // FSH............b
+ 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x12, // gfx_clear_color.
+ 0x02, 0x00, 0x00, 0x02, 0x00, 0xe8, 0x02, 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, // ...........#....
+ 0x00, 0x07, 0x00, 0x08, 0x00, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, // .....Q..........
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, // .............GLS
+ 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, // L.std.450.......
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, // ................
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, // .....main....4..
+ 0x00, 0x36, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, // .6..............
+ 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, // ................
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, // .....main.......
+ 0x00, 0x21, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x00, 0x06, 0x00, 0x08, // .!...$Global....
+ 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, // .!.......bgfx_cl
+ 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, // ear_color.......
+ 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x34, 0x00, 0x00, // .#...........4..
+ 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x30, 0x00, // .bgfx_FragData0.
+ 0x00, 0x05, 0x00, 0x06, 0x00, 0x36, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, // .....6...bgfx_Fr
+ 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x31, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x20, 0x00, 0x00, // agData1..G... ..
+ 0x00, 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x21, 0x00, 0x00, // .........H...!..
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, // .....#.......G..
+ 0x00, 0x21, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, // .!.......G...#..
+ 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, // .".......G...#..
+ 0x00, 0x21, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x34, 0x00, 0x00, // .!...0...G...4..
+ 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x36, 0x00, 0x00, // .........G...6..
+ 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, // ................
+ 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, // .!..............
+ 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // ..... ..........
+ 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x1e, 0x00, 0x00, // ................
+ 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x1e, 0x00, 0x00, // . .......+......
+ 0x00, 0x1f, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, 0x00, 0x20, 0x00, 0x00, // ............. ..
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x21, 0x00, 0x00, // .............!..
+ 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // . ... ..."......
+ 0x00, 0x21, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, // .!...;..."...#..
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // .........$... ..
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, // .....+...$...%..
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // ..... ...&......
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, // .....+...$...)..
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x33, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // ..... ...3......
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x33, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, // .....;...3...4..
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x33, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, // .....;...3...6..
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // .....6..........
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, // ................
+ 0x00, 0x41, 0x00, 0x06, 0x00, 0x26, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, // .A...&...M...#..
+ 0x00, 0x25, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // .%...%...=......
+ 0x00, 0x4e, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x26, 0x00, 0x00, // .N...M...A...&..
+ 0x00, 0x4f, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, // .O...#...%...)..
+ 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, // .=.......P...O..
+ 0x00, 0x3e, 0x00, 0x03, 0x00, 0x34, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .>...4...N...>..
+ 0x00, 0x36, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, // .6...P.......8..
+ 0x00, 0x00, 0x00, 0x20, 0x00, // ... .
};
static const uint8_t fs_clear1_dx9[210] =
{
diff --git a/3rdparty/bgfx/src/fs_clear1.sc b/3rdparty/bgfx/src/fs_clear1.sc
index 81701cdd247..f84bdebc40a 100644
--- a/3rdparty/bgfx/src/fs_clear1.sc
+++ b/3rdparty/bgfx/src/fs_clear1.sc
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/fs_clear2.bin.h b/3rdparty/bgfx/src/fs_clear2.bin.h
index 19d9d0a6632..14e1c553220 100644
--- a/3rdparty/bgfx/src/fs_clear2.bin.h
+++ b/3rdparty/bgfx/src/fs_clear2.bin.h
@@ -15,65 +15,66 @@ 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_spv[897] =
+static const uint8_t fs_clear2_spv[917] =
{
- 0x46, 0x53, 0x48, 0x05, 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, 0x03, 0x00, 0x00, 0x03, // clear_color.....
- 0x00, 0x58, 0x03, 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x08, // .X.....#........
- 0x00, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, // ................
- 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, // .........GLSL.st
- 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, // d.450...........
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // ................
- 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, // .main....;...=..
- 0x00, 0x3f, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, // .?..............
- 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, // ................
- 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, // .....main.......
- 0x00, 0x22, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x00, 0x06, 0x00, 0x08, // ."...$Global....
- 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, // .".......bgfx_cl
- 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, // ear_color.......
- 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x3b, 0x00, 0x00, // .$...........;..
- 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x30, 0x00, // .bgfx_FragData0.
- 0x00, 0x05, 0x00, 0x06, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, // .....=...bgfx_Fr
- 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x31, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x3f, 0x00, 0x00, // agData1......?..
- 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x32, 0x00, // .bgfx_FragData2.
- 0x00, 0x47, 0x00, 0x04, 0x00, 0x21, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, // .G...!..........
- 0x00, 0x48, 0x00, 0x05, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, // .H...".......#..
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x22, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .....G..."......
- 0x00, 0x47, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .G...$..."......
- 0x00, 0x47, 0x00, 0x04, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .G...;..........
- 0x00, 0x47, 0x00, 0x04, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .G...=..........
- 0x00, 0x47, 0x00, 0x04, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .G...?..........
- 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, // .........!......
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // ............. ..
- 0x00, 0x17, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // ................
- 0x00, 0x15, 0x00, 0x04, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ......... ......
- 0x00, 0x2b, 0x00, 0x04, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // .+....... ......
- 0x00, 0x1c, 0x00, 0x04, 0x00, 0x21, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // .....!....... ..
- 0x00, 0x1e, 0x00, 0x03, 0x00, 0x22, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // ....."...!... ..
- 0x00, 0x23, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .#......."...;..
- 0x00, 0x23, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, // .#...$..........
- 0x00, 0x25, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .%... .......+..
- 0x00, 0x25, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // .%...&....... ..
- 0x00, 0x27, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .'...........+..
- 0x00, 0x25, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .%...*.......+..
- 0x00, 0x25, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // .%...-....... ..
- 0x00, 0x3a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .:...........;..
- 0x00, 0x3a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .:...;.......;..
- 0x00, 0x3a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .:...=.......;..
- 0x00, 0x3a, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, // .:...?.......6..
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // ................
- 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x27, 0x00, 0x00, // .........A...'..
- 0x00, 0x56, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, // .V...$...&...&..
- 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, // .=.......W...V..
- 0x00, 0x41, 0x00, 0x06, 0x00, 0x27, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, // .A...'...X...$..
- 0x00, 0x26, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // .&...*...=......
- 0x00, 0x59, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x27, 0x00, 0x00, // .Y...X...A...'..
- 0x00, 0x5a, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, // .Z...$...&...-..
- 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, // .=.......[...Z..
- 0x00, 0x3e, 0x00, 0x03, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .>...;...W...>..
- 0x00, 0x3d, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x3f, 0x00, 0x00, // .=...Y...>...?..
- 0x00, 0x5b, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x00, 0x00, 0x30, // .[.......8.....0
- 0x00, // .
+ 0x46, 0x53, 0x48, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, // FSH............b
+ 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x12, // gfx_clear_color.
+ 0x03, 0x00, 0x00, 0x03, 0x00, 0x68, 0x03, 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, // .....h.....#....
+ 0x00, 0x07, 0x00, 0x08, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, // ................
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, // .............GLS
+ 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, // L.std.450.......
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x08, 0x00, 0x04, 0x00, 0x00, // ................
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, // .....main....;..
+ 0x00, 0x3d, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, // .=...?..........
+ 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0xf4, 0x01, 0x00, // ................
+ 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, // .........main...
+ 0x00, 0x05, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, // ....."...$Global
+ 0x00, 0x06, 0x00, 0x08, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // .....".......bgf
+ 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, // x_clear_color...
+ 0x00, 0x05, 0x00, 0x03, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, // .....$..........
+ 0x00, 0x3b, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, // .;...bgfx_FragDa
+ 0x74, 0x61, 0x30, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // ta0......=...bgf
+ 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x31, 0x00, 0x00, 0x05, 0x00, 0x06, // x_FragData1.....
+ 0x00, 0x3f, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, // .?...bgfx_FragDa
+ 0x74, 0x61, 0x32, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x21, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, // ta2..G...!......
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .....H..."......
+ 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x22, 0x00, 0x00, // .#.......G..."..
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, // .....G...$..."..
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, // .....G...$...!..
+ 0x00, 0x30, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .0...G...;......
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G...=......
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G...?......
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, // .............!..
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, // ................
+ 0x00, 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, // . ..............
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // ............. ..
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // .....+....... ..
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, 0x00, 0x21, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // .........!......
+ 0x00, 0x20, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x22, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, // . ......."...!..
+ 0x00, 0x20, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, // . ...#......."..
+ 0x00, 0x3b, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .;...#...$......
+ 0x00, 0x15, 0x00, 0x04, 0x00, 0x25, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .....%... ......
+ 0x00, 0x2b, 0x00, 0x04, 0x00, 0x25, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .+...%...&......
+ 0x00, 0x20, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // . ...'..........
+ 0x00, 0x2b, 0x00, 0x04, 0x00, 0x25, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .+...%...*......
+ 0x00, 0x2b, 0x00, 0x04, 0x00, 0x25, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .+...%...-......
+ 0x00, 0x20, 0x00, 0x04, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // . ...:..........
+ 0x00, 0x3b, 0x00, 0x04, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .;...:...;......
+ 0x00, 0x3b, 0x00, 0x04, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .;...:...=......
+ 0x00, 0x3b, 0x00, 0x04, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .;...:...?......
+ 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .6..............
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, // .............A..
+ 0x00, 0x27, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, // .'...V...$...&..
+ 0x00, 0x26, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, // .&...=.......W..
+ 0x00, 0x56, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x27, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, // .V...A...'...X..
+ 0x00, 0x24, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, // .$...&...*...=..
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, // .....Y...X...A..
+ 0x00, 0x27, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, // .'...Z...$...&..
+ 0x00, 0x2d, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, // .-...=.......[..
+ 0x00, 0x5a, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, // .Z...>...;...W..
+ 0x00, 0x3e, 0x00, 0x03, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .>...=...Y...>..
+ 0x00, 0x3f, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, // .?...[.......8..
+ 0x00, 0x00, 0x00, 0x30, 0x00, // ...0.
};
static const uint8_t fs_clear2_dx9[222] =
{
diff --git a/3rdparty/bgfx/src/fs_clear2.sc b/3rdparty/bgfx/src/fs_clear2.sc
index 90a9e4beccb..a3f56904841 100644
--- a/3rdparty/bgfx/src/fs_clear2.sc
+++ b/3rdparty/bgfx/src/fs_clear2.sc
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/fs_clear3.bin.h b/3rdparty/bgfx/src/fs_clear3.bin.h
index 1bf05f08031..828c9c277c0 100644
--- a/3rdparty/bgfx/src/fs_clear3.bin.h
+++ b/3rdparty/bgfx/src/fs_clear3.bin.h
@@ -17,73 +17,74 @@ 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_spv[1025] =
+static const uint8_t fs_clear3_spv[1045] =
{
- 0x46, 0x53, 0x48, 0x05, 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, 0x04, 0x00, 0x00, 0x04, // clear_color.....
- 0x00, 0xd8, 0x03, 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x08, // .......#........
- 0x00, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, // .g..............
- 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, // .........GLSL.st
- 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, // d.450...........
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x09, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // ................
- 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, // .main....B...D..
- 0x00, 0x46, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, // .F...H..........
- 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0xf4, 0x01, 0x00, // ................
- 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, // .........main...
- 0x00, 0x05, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, // .....#...$Global
- 0x00, 0x06, 0x00, 0x08, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // .....#.......bgf
- 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, // x_clear_color...
- 0x00, 0x05, 0x00, 0x03, 0x00, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, // .....%..........
- 0x00, 0x42, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, // .B...bgfx_FragDa
- 0x74, 0x61, 0x30, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x44, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // ta0......D...bgf
- 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x31, 0x00, 0x00, 0x05, 0x00, 0x06, // x_FragData1.....
- 0x00, 0x46, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, // .F...bgfx_FragDa
- 0x74, 0x61, 0x32, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x48, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // ta2......H...bgf
- 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x33, 0x00, 0x00, 0x47, 0x00, 0x04, // x_FragData3..G..
- 0x00, 0x22, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, // ."...........H..
- 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .#.......#......
- 0x00, 0x47, 0x00, 0x03, 0x00, 0x23, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .G...#.......G..
- 0x00, 0x25, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .%...".......G..
- 0x00, 0x42, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .B...........G..
- 0x00, 0x44, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .D...........G..
- 0x00, 0x46, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .F...........G..
- 0x00, 0x48, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, // .H..............
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .....!..........
- 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, // ......... ......
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, // ................
- 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // . ... .......+..
- 0x00, 0x20, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, // . ...!..........
- 0x00, 0x22, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, // .".......!......
- 0x00, 0x23, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, // .#..."... ...$..
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, // .....#...;...$..
- 0x00, 0x25, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, // .%...........&..
- 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, // . .......+...&..
- 0x00, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, // .'....... ...(..
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, // .........+...&..
- 0x00, 0x2b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, // .+.......+...&..
- 0x00, 0x2e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, // .........+...&..
- 0x00, 0x31, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x41, 0x00, 0x00, // .1....... ...A..
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x41, 0x00, 0x00, // .........;...A..
- 0x00, 0x42, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x41, 0x00, 0x00, // .B.......;...A..
- 0x00, 0x44, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x41, 0x00, 0x00, // .D.......;...A..
- 0x00, 0x46, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x41, 0x00, 0x00, // .F.......;...A..
- 0x00, 0x48, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, // .H.......6......
- 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, // ................
- 0x00, 0x05, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x28, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, // .....A...(..._..
- 0x00, 0x25, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, // .%...'...'...=..
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, // .....`..._...A..
- 0x00, 0x28, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, // .(...a...%...'..
- 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, // .+...=.......b..
- 0x00, 0x61, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x28, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, // .a...A...(...c..
- 0x00, 0x25, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, // .%...'.......=..
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, // .....d...c...A..
- 0x00, 0x28, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, // .(...e...%...'..
- 0x00, 0x31, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, // .1...=.......f..
- 0x00, 0x65, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x42, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, // .e...>...B...`..
- 0x00, 0x3e, 0x00, 0x03, 0x00, 0x44, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .>...D...b...>..
- 0x00, 0x46, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x48, 0x00, 0x00, // .F...d...>...H..
- 0x00, 0x66, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x00, 0x00, 0x40, // .f.......8.....@
- 0x00, // .
+ 0x46, 0x53, 0x48, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, // FSH............b
+ 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x12, // gfx_clear_color.
+ 0x04, 0x00, 0x00, 0x04, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, // ...........#....
+ 0x00, 0x07, 0x00, 0x08, 0x00, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, // .....g..........
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, // .............GLS
+ 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, // L.std.450.......
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x09, 0x00, 0x04, 0x00, 0x00, // ................
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, // .....main....B..
+ 0x00, 0x44, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, // .D...F...H......
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, // ................
+ 0x00, 0xf4, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, // .............mai
+ 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6c, // n........#...$Gl
+ 0x6f, 0x62, 0x61, 0x6c, 0x00, 0x06, 0x00, 0x08, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // obal.....#......
+ 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // .bgfx_clear_colo
+ 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // r........%......
+ 0x00, 0x05, 0x00, 0x06, 0x00, 0x42, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, // .....B...bgfx_Fr
+ 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x30, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x44, 0x00, 0x00, // agData0......D..
+ 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x31, 0x00, // .bgfx_FragData1.
+ 0x00, 0x05, 0x00, 0x06, 0x00, 0x46, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, // .....F...bgfx_Fr
+ 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x32, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x48, 0x00, 0x00, // agData2......H..
+ 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x33, 0x00, // .bgfx_FragData3.
+ 0x00, 0x47, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, // .G..."..........
+ 0x00, 0x48, 0x00, 0x05, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, // .H...#.......#..
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x23, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .....G...#......
+ 0x00, 0x47, 0x00, 0x04, 0x00, 0x25, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .G...%..."......
+ 0x00, 0x47, 0x00, 0x04, 0x00, 0x25, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, // .G...%...!...0..
+ 0x00, 0x47, 0x00, 0x04, 0x00, 0x42, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .G...B..........
+ 0x00, 0x47, 0x00, 0x04, 0x00, 0x44, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .G...D..........
+ 0x00, 0x47, 0x00, 0x04, 0x00, 0x46, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .G...F..........
+ 0x00, 0x47, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .G...H..........
+ 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, // .........!......
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // ............. ..
+ 0x00, 0x17, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // ................
+ 0x00, 0x15, 0x00, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ..... ... ......
+ 0x00, 0x2b, 0x00, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // .+... ...!......
+ 0x00, 0x1c, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, // .....".......!..
+ 0x00, 0x1e, 0x00, 0x03, 0x00, 0x23, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // .....#..."... ..
+ 0x00, 0x24, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .$.......#...;..
+ 0x00, 0x24, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, // .$...%..........
+ 0x00, 0x26, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .&... .......+..
+ 0x00, 0x26, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // .&...'....... ..
+ 0x00, 0x28, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .(...........+..
+ 0x00, 0x26, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .&...+.......+..
+ 0x00, 0x26, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .&...........+..
+ 0x00, 0x26, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // .&...1....... ..
+ 0x00, 0x41, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .A...........;..
+ 0x00, 0x41, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .A...B.......;..
+ 0x00, 0x41, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .A...D.......;..
+ 0x00, 0x41, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .A...F.......;..
+ 0x00, 0x41, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, // .A...H.......6..
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // ................
+ 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x28, 0x00, 0x00, // .........A...(..
+ 0x00, 0x5f, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, // ._...%...'...'..
+ 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, // .=.......`..._..
+ 0x00, 0x41, 0x00, 0x06, 0x00, 0x28, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, // .A...(...a...%..
+ 0x00, 0x27, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // .'...+...=......
+ 0x00, 0x62, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x28, 0x00, 0x00, // .b...a...A...(..
+ 0x00, 0x63, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, // .c...%...'......
+ 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, // .=.......d...c..
+ 0x00, 0x41, 0x00, 0x06, 0x00, 0x28, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, // .A...(...e...%..
+ 0x00, 0x27, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // .'...1...=......
+ 0x00, 0x66, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x42, 0x00, 0x00, // .f...e...>...B..
+ 0x00, 0x60, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x44, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, // .`...>...D...b..
+ 0x00, 0x3e, 0x00, 0x03, 0x00, 0x46, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .>...F...d...>..
+ 0x00, 0x48, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, // .H...f.......8..
+ 0x00, 0x00, 0x00, 0x40, 0x00, // ...@.
};
static const uint8_t fs_clear3_dx9[234] =
{
diff --git a/3rdparty/bgfx/src/fs_clear3.sc b/3rdparty/bgfx/src/fs_clear3.sc
index 3dd4accb4c3..252a2c2877c 100644
--- a/3rdparty/bgfx/src/fs_clear3.sc
+++ b/3rdparty/bgfx/src/fs_clear3.sc
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/fs_clear4.bin.h b/3rdparty/bgfx/src/fs_clear4.bin.h
index 70e1266808a..737f2a721c6 100644
--- a/3rdparty/bgfx/src/fs_clear4.bin.h
+++ b/3rdparty/bgfx/src/fs_clear4.bin.h
@@ -20,81 +20,82 @@ 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_spv[1153] =
+static const uint8_t fs_clear4_spv[1173] =
{
- 0x46, 0x53, 0x48, 0x05, 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, 0x05, 0x00, 0x00, 0x05, // clear_color.....
- 0x00, 0x58, 0x04, 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x08, // .X.....#........
- 0x00, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, // .r..............
- 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, // .........GLSL.st
- 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, // d.450...........
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x0a, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // ................
- 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, // .main....I...K..
- 0x00, 0x4d, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, // .M...O...Q......
- 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, // ................
- 0x00, 0xf4, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, // .............mai
- 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6c, // n........$...$Gl
- 0x6f, 0x62, 0x61, 0x6c, 0x00, 0x06, 0x00, 0x08, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // obal.....$......
- 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // .bgfx_clear_colo
- 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // r........&......
- 0x00, 0x05, 0x00, 0x06, 0x00, 0x49, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, // .....I...bgfx_Fr
- 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x30, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x4b, 0x00, 0x00, // agData0......K..
- 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x31, 0x00, // .bgfx_FragData1.
- 0x00, 0x05, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, // .....M...bgfx_Fr
- 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x32, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x4f, 0x00, 0x00, // agData2......O..
- 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x33, 0x00, // .bgfx_FragData3.
- 0x00, 0x05, 0x00, 0x06, 0x00, 0x51, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, // .....Q...bgfx_Fr
- 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x34, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, // agData4..G...#..
- 0x00, 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x24, 0x00, 0x00, // .........H...$..
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, // .....#.......G..
- 0x00, 0x24, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, // .$.......G...&..
- 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x49, 0x00, 0x00, // .".......G...I..
- 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4b, 0x00, 0x00, // .........G...K..
- 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4d, 0x00, 0x00, // .........G...M..
- 0x00, 0x1e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4f, 0x00, 0x00, // .........G...O..
- 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x51, 0x00, 0x00, // .........G...Q..
- 0x00, 0x1e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, // ................
- 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, // .!..............
- 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // ..... ..........
- 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x21, 0x00, 0x00, // .............!..
- 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x21, 0x00, 0x00, // . .......+...!..
- 0x00, 0x22, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, // ."...........#..
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x24, 0x00, 0x00, // .....".......$..
- 0x00, 0x23, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x25, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .#... ...%......
- 0x00, 0x24, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x25, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, // .$...;...%...&..
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // .........'... ..
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, // .....+...'...(..
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // ..... ...)......
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, // .....+...'...,..
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, // .....+...'.../..
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, // .....+...'...2..
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, // .....+...'...5..
- 0x00, 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // ..... ...H......
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, // .....;...H...I..
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, // .....;...H...K..
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, // .....;...H...M..
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, // .....;...H...O..
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, // .....;...H...Q..
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // .....6..........
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, // ................
- 0x00, 0x41, 0x00, 0x06, 0x00, 0x29, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, // .A...)...h...&..
- 0x00, 0x28, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // .(...(...=......
- 0x00, 0x69, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x29, 0x00, 0x00, // .i...h...A...)..
- 0x00, 0x6a, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, // .j...&...(...,..
- 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, // .=.......k...j..
- 0x00, 0x41, 0x00, 0x06, 0x00, 0x29, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, // .A...)...l...&..
- 0x00, 0x28, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // .(.../...=......
- 0x00, 0x6d, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x29, 0x00, 0x00, // .m...l...A...)..
- 0x00, 0x6e, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, // .n...&...(...2..
- 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, // .=.......o...n..
- 0x00, 0x41, 0x00, 0x06, 0x00, 0x29, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, // .A...)...p...&..
- 0x00, 0x28, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // .(...5...=......
- 0x00, 0x71, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x49, 0x00, 0x00, // .q...p...>...I..
- 0x00, 0x69, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, // .i...>...K...k..
- 0x00, 0x3e, 0x00, 0x03, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .>...M...m...>..
- 0x00, 0x4f, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x51, 0x00, 0x00, // .O...o...>...Q..
- 0x00, 0x71, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x00, 0x00, 0x50, // .q.......8.....P
- 0x00, // .
+ 0x46, 0x53, 0x48, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, // FSH............b
+ 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x12, // gfx_clear_color.
+ 0x05, 0x00, 0x00, 0x05, 0x00, 0x68, 0x04, 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, // .....h.....#....
+ 0x00, 0x07, 0x00, 0x08, 0x00, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, // .....r..........
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, // .............GLS
+ 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, // L.std.450.......
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x0a, 0x00, 0x04, 0x00, 0x00, // ................
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, // .....main....I..
+ 0x00, 0x4b, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, // .K...M...O...Q..
+ 0x00, 0x10, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, // ................
+ 0x00, 0x05, 0x00, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, // ................
+ 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, // .main........$..
+ 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x00, 0x06, 0x00, 0x08, 0x00, 0x24, 0x00, 0x00, // .$Global.....$..
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, // .....bgfx_clear_
+ 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x26, 0x00, 0x00, // color........&..
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x49, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // .........I...bgf
+ 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x30, 0x00, 0x00, 0x05, 0x00, 0x06, // x_FragData0.....
+ 0x00, 0x4b, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, // .K...bgfx_FragDa
+ 0x74, 0x61, 0x31, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // ta1......M...bgf
+ 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x32, 0x00, 0x00, 0x05, 0x00, 0x06, // x_FragData2.....
+ 0x00, 0x4f, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, // .O...bgfx_FragDa
+ 0x74, 0x61, 0x33, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x51, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // ta3......Q...bgf
+ 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x34, 0x00, 0x00, 0x47, 0x00, 0x04, // x_FragData4..G..
+ 0x00, 0x23, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, // .#...........H..
+ 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .$.......#......
+ 0x00, 0x47, 0x00, 0x03, 0x00, 0x24, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .G...$.......G..
+ 0x00, 0x26, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .&...".......G..
+ 0x00, 0x26, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .&...!...0...G..
+ 0x00, 0x49, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .I...........G..
+ 0x00, 0x4b, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .K...........G..
+ 0x00, 0x4d, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .M...........G..
+ 0x00, 0x4f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .O...........G..
+ 0x00, 0x51, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, // .Q..............
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .....!..........
+ 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, // ......... ......
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, // ................
+ 0x00, 0x21, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .!... .......+..
+ 0x00, 0x21, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, // .!..."..........
+ 0x00, 0x23, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, // .#......."......
+ 0x00, 0x24, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x25, 0x00, 0x00, // .$...#... ...%..
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x25, 0x00, 0x00, // .....$...;...%..
+ 0x00, 0x26, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, // .&...........'..
+ 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, // . .......+...'..
+ 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, // .(....... ...)..
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, // .........+...'..
+ 0x00, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, // .,.......+...'..
+ 0x00, 0x2f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, // ./.......+...'..
+ 0x00, 0x32, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, // .2.......+...'..
+ 0x00, 0x35, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, // .5....... ...H..
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, // .........;...H..
+ 0x00, 0x49, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, // .I.......;...H..
+ 0x00, 0x4b, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, // .K.......;...H..
+ 0x00, 0x4d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, // .M.......;...H..
+ 0x00, 0x4f, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, // .O.......;...H..
+ 0x00, 0x51, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, // .Q.......6......
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, // ................
+ 0x00, 0x05, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x29, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, // .....A...)...h..
+ 0x00, 0x26, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, // .&...(...(...=..
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, // .....i...h...A..
+ 0x00, 0x29, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, // .)...j...&...(..
+ 0x00, 0x2c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, // .,...=.......k..
+ 0x00, 0x6a, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x29, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, // .j...A...)...l..
+ 0x00, 0x26, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, // .&...(.../...=..
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, // .....m...l...A..
+ 0x00, 0x29, 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, // .)...n...&...(..
+ 0x00, 0x32, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, // .2...=.......o..
+ 0x00, 0x6e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x29, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, // .n...A...)...p..
+ 0x00, 0x26, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, // .&...(...5...=..
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .....q...p...>..
+ 0x00, 0x49, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x4b, 0x00, 0x00, // .I...i...>...K..
+ 0x00, 0x6b, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, // .k...>...M...m..
+ 0x00, 0x3e, 0x00, 0x03, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .>...O...o...>..
+ 0x00, 0x51, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, // .Q...q.......8..
+ 0x00, 0x00, 0x00, 0x50, 0x00, // ...P.
};
static const uint8_t fs_clear4_dx9[234] =
{
diff --git a/3rdparty/bgfx/src/fs_clear4.sc b/3rdparty/bgfx/src/fs_clear4.sc
index 7390a02ca11..68d89acccef 100644
--- a/3rdparty/bgfx/src/fs_clear4.sc
+++ b/3rdparty/bgfx/src/fs_clear4.sc
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/fs_clear5.bin.h b/3rdparty/bgfx/src/fs_clear5.bin.h
index 26d53fe54b4..9f3b7cc44ca 100644
--- a/3rdparty/bgfx/src/fs_clear5.bin.h
+++ b/3rdparty/bgfx/src/fs_clear5.bin.h
@@ -22,89 +22,90 @@ 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_spv[1281] =
+static const uint8_t fs_clear5_spv[1301] =
{
- 0x46, 0x53, 0x48, 0x05, 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, 0x06, 0x00, 0x00, 0x06, // clear_color.....
- 0x00, 0xd8, 0x04, 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x08, // .......#........
- 0x00, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, // .}..............
- 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, // .........GLSL.st
- 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, // d.450...........
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x0b, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // ................
- 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, // .main....P...R..
- 0x00, 0x54, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, // .T...V...X...Z..
- 0x00, 0x10, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, // ................
- 0x00, 0x05, 0x00, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, // ................
- 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x25, 0x00, 0x00, // .main........%..
- 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x00, 0x06, 0x00, 0x08, 0x00, 0x25, 0x00, 0x00, // .$Global.....%..
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, // .....bgfx_clear_
- 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x27, 0x00, 0x00, // color........'..
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x50, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // .........P...bgf
- 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x30, 0x00, 0x00, 0x05, 0x00, 0x06, // x_FragData0.....
- 0x00, 0x52, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, // .R...bgfx_FragDa
- 0x74, 0x61, 0x31, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x54, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // ta1......T...bgf
- 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x32, 0x00, 0x00, 0x05, 0x00, 0x06, // x_FragData2.....
- 0x00, 0x56, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, // .V...bgfx_FragDa
- 0x74, 0x61, 0x33, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x58, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // ta3......X...bgf
- 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x34, 0x00, 0x00, 0x05, 0x00, 0x06, // x_FragData4.....
- 0x00, 0x5a, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, // .Z...bgfx_FragDa
- 0x74, 0x61, 0x35, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, // ta5..G...$......
- 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .....H...%......
- 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x25, 0x00, 0x00, // .#.......G...%..
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, // .....G...'..."..
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x50, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G...P......
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x52, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G...R......
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x54, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G...T......
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x56, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G...V......
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x58, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G...X......
- 0x00, 0x04, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G...Z......
- 0x00, 0x05, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, // .............!..
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, // ................
- 0x00, 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, // . ..............
- 0x00, 0x04, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // ........."... ..
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, // .....+..."...#..
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // .........$......
- 0x00, 0x23, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x25, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, // .#.......%...$..
- 0x00, 0x20, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, // . ...&.......%..
- 0x00, 0x3b, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .;...&...'......
- 0x00, 0x15, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .....(... ......
- 0x00, 0x2b, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .+...(...)......
- 0x00, 0x20, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // . ...*..........
- 0x00, 0x2b, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .+...(...-......
- 0x00, 0x2b, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .+...(...0......
- 0x00, 0x2b, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .+...(...3......
- 0x00, 0x2b, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // .+...(...6......
- 0x00, 0x2b, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, // .+...(...9......
- 0x00, 0x20, 0x00, 0x04, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // . ...O..........
- 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .;...O...P......
- 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .;...O...R......
- 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .;...O...T......
- 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .;...O...V......
- 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .;...O...X......
- 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .;...O...Z......
- 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .6..............
- 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, // .............A..
- 0x00, 0x2a, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, // .*...q...'...)..
- 0x00, 0x29, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, // .)...=.......r..
- 0x00, 0x71, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, // .q...A...*...s..
- 0x00, 0x27, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, // .'...)...-...=..
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, // .....t...s...A..
- 0x00, 0x2a, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, // .*...u...'...)..
- 0x00, 0x30, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, // .0...=.......v..
- 0x00, 0x75, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, // .u...A...*...w..
- 0x00, 0x27, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, // .'...)...3...=..
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, // .....x...w...A..
- 0x00, 0x2a, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, // .*...y...'...)..
- 0x00, 0x36, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, // .6...=.......z..
- 0x00, 0x79, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, // .y...A...*...{..
- 0x00, 0x27, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, // .'...)...9...=..
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .....|...{...>..
- 0x00, 0x50, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x52, 0x00, 0x00, // .P...r...>...R..
- 0x00, 0x74, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x54, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, // .t...>...T...v..
- 0x00, 0x3e, 0x00, 0x03, 0x00, 0x56, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .>...V...x...>..
- 0x00, 0x58, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x5a, 0x00, 0x00, // .X...z...>...Z..
- 0x00, 0x7c, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x00, 0x00, 0x60, // .|.......8.....`
- 0x00, // .
+ 0x46, 0x53, 0x48, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, // FSH............b
+ 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x12, // gfx_clear_color.
+ 0x06, 0x00, 0x00, 0x06, 0x00, 0xe8, 0x04, 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, // ...........#....
+ 0x00, 0x07, 0x00, 0x08, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, // .....}..........
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, // .............GLS
+ 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, // L.std.450.......
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x0b, 0x00, 0x04, 0x00, 0x00, // ................
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, // .....main....P..
+ 0x00, 0x52, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, // .R...T...V...X..
+ 0x00, 0x5a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, // .Z..............
+ 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, // ................
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, // .....main.......
+ 0x00, 0x25, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x00, 0x06, 0x00, 0x08, // .%...$Global....
+ 0x00, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, // .%.......bgfx_cl
+ 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, // ear_color.......
+ 0x00, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x50, 0x00, 0x00, // .'...........P..
+ 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x30, 0x00, // .bgfx_FragData0.
+ 0x00, 0x05, 0x00, 0x06, 0x00, 0x52, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, // .....R...bgfx_Fr
+ 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x31, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x54, 0x00, 0x00, // agData1......T..
+ 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x32, 0x00, // .bgfx_FragData2.
+ 0x00, 0x05, 0x00, 0x06, 0x00, 0x56, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, // .....V...bgfx_Fr
+ 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x33, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x58, 0x00, 0x00, // agData3......X..
+ 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x34, 0x00, // .bgfx_FragData4.
+ 0x00, 0x05, 0x00, 0x06, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, // .....Z...bgfx_Fr
+ 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x35, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, // agData5..G...$..
+ 0x00, 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x25, 0x00, 0x00, // .........H...%..
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, // .....#.......G..
+ 0x00, 0x25, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, // .%.......G...'..
+ 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, // .".......G...'..
+ 0x00, 0x21, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x50, 0x00, 0x00, // .!...0...G...P..
+ 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x52, 0x00, 0x00, // .........G...R..
+ 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x54, 0x00, 0x00, // .........G...T..
+ 0x00, 0x1e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x56, 0x00, 0x00, // .........G...V..
+ 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x58, 0x00, 0x00, // .........G...X..
+ 0x00, 0x1e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x5a, 0x00, 0x00, // .........G...Z..
+ 0x00, 0x1e, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, // ................
+ 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, // .!..............
+ 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // ..... ..........
+ 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, // ............."..
+ 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, // . .......+..."..
+ 0x00, 0x23, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, // .#...........$..
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x25, 0x00, 0x00, // .....#.......%..
+ 0x00, 0x24, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .$... ...&......
+ 0x00, 0x25, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, // .%...;...&...'..
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // .........(... ..
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, // .....+...(...)..
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // ..... ...*......
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, // .....+...(...-..
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, // .....+...(...0..
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, // .....+...(...3..
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, // .....+...(...6..
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, // .....+...(...9..
+ 0x00, 0x05, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // ..... ...O......
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, // .....;...O...P..
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, // .....;...O...R..
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, // .....;...O...T..
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, // .....;...O...V..
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, // .....;...O...X..
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, // .....;...O...Z..
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // .....6..........
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, // ................
+ 0x00, 0x41, 0x00, 0x06, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, // .A...*...q...'..
+ 0x00, 0x29, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // .)...)...=......
+ 0x00, 0x72, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2a, 0x00, 0x00, // .r...q...A...*..
+ 0x00, 0x73, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, // .s...'...)...-..
+ 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, // .=.......t...s..
+ 0x00, 0x41, 0x00, 0x06, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, // .A...*...u...'..
+ 0x00, 0x29, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // .)...0...=......
+ 0x00, 0x76, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2a, 0x00, 0x00, // .v...u...A...*..
+ 0x00, 0x77, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, // .w...'...)...3..
+ 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, // .=.......x...w..
+ 0x00, 0x41, 0x00, 0x06, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, // .A...*...y...'..
+ 0x00, 0x29, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // .)...6...=......
+ 0x00, 0x7a, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2a, 0x00, 0x00, // .z...y...A...*..
+ 0x00, 0x7b, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, // .{...'...)...9..
+ 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, // .=.......|...{..
+ 0x00, 0x3e, 0x00, 0x03, 0x00, 0x50, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .>...P...r...>..
+ 0x00, 0x52, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x54, 0x00, 0x00, // .R...t...>...T..
+ 0x00, 0x76, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x56, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, // .v...>...V...x..
+ 0x00, 0x3e, 0x00, 0x03, 0x00, 0x58, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .>...X...z...>..
+ 0x00, 0x5a, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, // .Z...|.......8..
+ 0x00, 0x00, 0x00, 0x60, 0x00, // ...`.
};
static const uint8_t fs_clear5_dx9[234] =
{
diff --git a/3rdparty/bgfx/src/fs_clear5.sc b/3rdparty/bgfx/src/fs_clear5.sc
index 0deb9ff95e0..20233ec4ac3 100644
--- a/3rdparty/bgfx/src/fs_clear5.sc
+++ b/3rdparty/bgfx/src/fs_clear5.sc
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/fs_clear6.bin.h b/3rdparty/bgfx/src/fs_clear6.bin.h
index bc0561c8b52..a15d1b89c07 100644
--- a/3rdparty/bgfx/src/fs_clear6.bin.h
+++ b/3rdparty/bgfx/src/fs_clear6.bin.h
@@ -25,97 +25,98 @@ 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_spv[1409] =
+static const uint8_t fs_clear6_spv[1429] =
{
- 0x46, 0x53, 0x48, 0x05, 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, 0x07, 0x00, 0x00, 0x07, // clear_color.....
- 0x00, 0x58, 0x05, 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x08, // .X.....#........
- 0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, // ................
- 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, // .........GLSL.st
- 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, // d.450...........
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x0c, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // ................
- 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, // .main....W...Y..
- 0x00, 0x5b, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, // .[...]..._...a..
- 0x00, 0x63, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, // .c..............
- 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, // ................
- 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, // .....main.......
- 0x00, 0x26, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x00, 0x06, 0x00, 0x08, // .&...$Global....
- 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, // .&.......bgfx_cl
- 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, // ear_color.......
- 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x57, 0x00, 0x00, // .(...........W..
- 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x30, 0x00, // .bgfx_FragData0.
- 0x00, 0x05, 0x00, 0x06, 0x00, 0x59, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, // .....Y...bgfx_Fr
- 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x31, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x5b, 0x00, 0x00, // agData1......[..
- 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x32, 0x00, // .bgfx_FragData2.
- 0x00, 0x05, 0x00, 0x06, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, // .....]...bgfx_Fr
- 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x33, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x5f, 0x00, 0x00, // agData3......_..
- 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x34, 0x00, // .bgfx_FragData4.
- 0x00, 0x05, 0x00, 0x06, 0x00, 0x61, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, // .....a...bgfx_Fr
- 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x35, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x63, 0x00, 0x00, // agData5......c..
- 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x36, 0x00, // .bgfx_FragData6.
- 0x00, 0x47, 0x00, 0x04, 0x00, 0x25, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, // .G...%..........
- 0x00, 0x48, 0x00, 0x05, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, // .H...&.......#..
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x26, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .....G...&......
- 0x00, 0x47, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .G...(..."......
- 0x00, 0x47, 0x00, 0x04, 0x00, 0x57, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .G...W..........
- 0x00, 0x47, 0x00, 0x04, 0x00, 0x59, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .G...Y..........
- 0x00, 0x47, 0x00, 0x04, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .G...[..........
- 0x00, 0x47, 0x00, 0x04, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .G...]..........
- 0x00, 0x47, 0x00, 0x04, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // .G..._..........
- 0x00, 0x47, 0x00, 0x04, 0x00, 0x61, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, // .G...a..........
- 0x00, 0x47, 0x00, 0x04, 0x00, 0x63, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, // .G...c..........
- 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, // .........!......
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // ............. ..
- 0x00, 0x17, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // ................
- 0x00, 0x15, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .....#... ......
- 0x00, 0x2b, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // .+...#...$......
- 0x00, 0x1c, 0x00, 0x04, 0x00, 0x25, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, // .....%.......$..
- 0x00, 0x1e, 0x00, 0x03, 0x00, 0x26, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // .....&...%... ..
- 0x00, 0x27, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .'.......&...;..
- 0x00, 0x27, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, // .'...(..........
- 0x00, 0x29, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .)... .......+..
- 0x00, 0x29, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // .)...*....... ..
- 0x00, 0x2b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .+...........+..
- 0x00, 0x29, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .)...........+..
- 0x00, 0x29, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .)...1.......+..
- 0x00, 0x29, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .)...4.......+..
- 0x00, 0x29, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .)...7.......+..
- 0x00, 0x29, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .)...:.......+..
- 0x00, 0x29, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // .)...=....... ..
- 0x00, 0x56, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .V...........;..
- 0x00, 0x56, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .V...W.......;..
- 0x00, 0x56, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .V...Y.......;..
- 0x00, 0x56, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .V...[.......;..
- 0x00, 0x56, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .V...].......;..
- 0x00, 0x56, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .V..._.......;..
- 0x00, 0x56, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .V...a.......;..
- 0x00, 0x56, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, // .V...c.......6..
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // ................
- 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2b, 0x00, 0x00, // .........A...+..
- 0x00, 0x7a, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, // .z...(...*...*..
- 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, // .=.......{...z..
- 0x00, 0x41, 0x00, 0x06, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, // .A...+...|...(..
- 0x00, 0x2a, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // .*.......=......
- 0x00, 0x7d, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2b, 0x00, 0x00, // .}...|...A...+..
- 0x00, 0x7e, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, // .~...(...*...1..
- 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, // .=...........~..
- 0x00, 0x41, 0x00, 0x06, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, // .A...+.......(..
- 0x00, 0x2a, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // .*...4...=......
- 0x00, 0x81, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2b, 0x00, 0x00, // .........A...+..
- 0x00, 0x82, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, // .....(...*...7..
- 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, // .=..............
- 0x00, 0x41, 0x00, 0x06, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, // .A...+.......(..
- 0x00, 0x2a, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // .*...:...=......
- 0x00, 0x85, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2b, 0x00, 0x00, // .........A...+..
- 0x00, 0x86, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, // .....(...*...=..
- 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, // .=..............
- 0x00, 0x3e, 0x00, 0x03, 0x00, 0x57, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .>...W...{...>..
- 0x00, 0x59, 0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x5b, 0x00, 0x00, // .Y...}...>...[..
- 0x00, 0x7f, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, // .....>...]......
- 0x00, 0x3e, 0x00, 0x03, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .>..._.......>..
- 0x00, 0x61, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x63, 0x00, 0x00, // .a.......>...c..
- 0x00, 0x87, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x00, 0x00, 0x70, // .........8.....p
- 0x00, // .
+ 0x46, 0x53, 0x48, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, // FSH............b
+ 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x12, // gfx_clear_color.
+ 0x07, 0x00, 0x00, 0x07, 0x00, 0x68, 0x05, 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, // .....h.....#....
+ 0x00, 0x07, 0x00, 0x08, 0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, // ................
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, // .............GLS
+ 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, // L.std.450.......
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x0c, 0x00, 0x04, 0x00, 0x00, // ................
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, // .....main....W..
+ 0x00, 0x59, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, // .Y...[...]..._..
+ 0x00, 0x61, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, // .a...c..........
+ 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0xf4, 0x01, 0x00, // ................
+ 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, // .........main...
+ 0x00, 0x05, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, // .....&...$Global
+ 0x00, 0x06, 0x00, 0x08, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // .....&.......bgf
+ 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, // x_clear_color...
+ 0x00, 0x05, 0x00, 0x03, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, // .....(..........
+ 0x00, 0x57, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, // .W...bgfx_FragDa
+ 0x74, 0x61, 0x30, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x59, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // ta0......Y...bgf
+ 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x31, 0x00, 0x00, 0x05, 0x00, 0x06, // x_FragData1.....
+ 0x00, 0x5b, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, // .[...bgfx_FragDa
+ 0x74, 0x61, 0x32, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // ta2......]...bgf
+ 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x33, 0x00, 0x00, 0x05, 0x00, 0x06, // x_FragData3.....
+ 0x00, 0x5f, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, // ._...bgfx_FragDa
+ 0x74, 0x61, 0x34, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x61, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // ta4......a...bgf
+ 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x35, 0x00, 0x00, 0x05, 0x00, 0x06, // x_FragData5.....
+ 0x00, 0x63, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, // .c...bgfx_FragDa
+ 0x74, 0x61, 0x36, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x25, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, // ta6..G...%......
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .....H...&......
+ 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x26, 0x00, 0x00, // .#.......G...&..
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, // .....G...(..."..
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, // .....G...(...!..
+ 0x00, 0x30, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x57, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .0...G...W......
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x59, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G...Y......
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G...[......
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G...]......
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G..._......
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x61, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G...a......
+ 0x00, 0x05, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x63, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G...c......
+ 0x00, 0x06, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, // .............!..
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, // ................
+ 0x00, 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, // . ..............
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // .........#... ..
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, // .....+...#...$..
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, 0x00, 0x25, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // .........%......
+ 0x00, 0x24, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x26, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, // .$.......&...%..
+ 0x00, 0x20, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, // . ...'.......&..
+ 0x00, 0x3b, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .;...'...(......
+ 0x00, 0x15, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .....)... ......
+ 0x00, 0x2b, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .+...)...*......
+ 0x00, 0x20, 0x00, 0x04, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // . ...+..........
+ 0x00, 0x2b, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .+...)..........
+ 0x00, 0x2b, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .+...)...1......
+ 0x00, 0x2b, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .+...)...4......
+ 0x00, 0x2b, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // .+...)...7......
+ 0x00, 0x2b, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, // .+...)...:......
+ 0x00, 0x2b, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, // .+...)...=......
+ 0x00, 0x20, 0x00, 0x04, 0x00, 0x56, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // . ...V..........
+ 0x00, 0x3b, 0x00, 0x04, 0x00, 0x56, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .;...V...W......
+ 0x00, 0x3b, 0x00, 0x04, 0x00, 0x56, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .;...V...Y......
+ 0x00, 0x3b, 0x00, 0x04, 0x00, 0x56, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .;...V...[......
+ 0x00, 0x3b, 0x00, 0x04, 0x00, 0x56, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .;...V...]......
+ 0x00, 0x3b, 0x00, 0x04, 0x00, 0x56, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .;...V..._......
+ 0x00, 0x3b, 0x00, 0x04, 0x00, 0x56, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .;...V...a......
+ 0x00, 0x3b, 0x00, 0x04, 0x00, 0x56, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .;...V...c......
+ 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .6..............
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, // .............A..
+ 0x00, 0x2b, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, // .+...z...(...*..
+ 0x00, 0x2a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, // .*...=.......{..
+ 0x00, 0x7a, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, // .z...A...+...|..
+ 0x00, 0x28, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, // .(...*.......=..
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, // .....}...|...A..
+ 0x00, 0x2b, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, // .+...~...(...*..
+ 0x00, 0x31, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, // .1...=..........
+ 0x00, 0x7e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, // .~...A...+......
+ 0x00, 0x28, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, // .(...*...4...=..
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, // .............A..
+ 0x00, 0x2b, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, // .+.......(...*..
+ 0x00, 0x37, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, // .7...=..........
+ 0x00, 0x82, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, // .....A...+......
+ 0x00, 0x28, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, // .(...*...:...=..
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, // .............A..
+ 0x00, 0x2b, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, // .+.......(...*..
+ 0x00, 0x3d, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, // .=...=..........
+ 0x00, 0x86, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x57, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, // .....>...W...{..
+ 0x00, 0x3e, 0x00, 0x03, 0x00, 0x59, 0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .>...Y...}...>..
+ 0x00, 0x5b, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x5d, 0x00, 0x00, // .[.......>...]..
+ 0x00, 0x81, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, // .....>..._......
+ 0x00, 0x3e, 0x00, 0x03, 0x00, 0x61, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .>...a.......>..
+ 0x00, 0x63, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, // .c...........8..
+ 0x00, 0x00, 0x00, 0x70, 0x00, // ...p.
};
static const uint8_t fs_clear6_dx9[234] =
{
diff --git a/3rdparty/bgfx/src/fs_clear6.sc b/3rdparty/bgfx/src/fs_clear6.sc
index 971f5b4e3d1..9b7a1b1139c 100644
--- a/3rdparty/bgfx/src/fs_clear6.sc
+++ b/3rdparty/bgfx/src/fs_clear6.sc
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/fs_clear7.bin.h b/3rdparty/bgfx/src/fs_clear7.bin.h
index 29a984ad7c1..60e9532cf73 100644
--- a/3rdparty/bgfx/src/fs_clear7.bin.h
+++ b/3rdparty/bgfx/src/fs_clear7.bin.h
@@ -27,105 +27,106 @@ 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_spv[1537] =
+static const uint8_t fs_clear7_spv[1557] =
{
- 0x46, 0x53, 0x48, 0x05, 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, 0x08, // clear_color.....
- 0x00, 0xd8, 0x05, 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x08, // .......#........
- 0x00, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, // ................
- 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, // .........GLSL.st
- 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, // d.450...........
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x0d, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // ................
- 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, // .main....^...`..
- 0x00, 0x62, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, // .b...d...f...h..
- 0x00, 0x6a, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, // .j...l..........
- 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0xf4, 0x01, 0x00, // ................
- 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, // .........main...
- 0x00, 0x05, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, // .....'...$Global
- 0x00, 0x06, 0x00, 0x08, 0x00, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // .....'.......bgf
- 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, // x_clear_color...
- 0x00, 0x05, 0x00, 0x03, 0x00, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, // .....)..........
- 0x00, 0x5e, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, // .^...bgfx_FragDa
- 0x74, 0x61, 0x30, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x60, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // ta0......`...bgf
- 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x31, 0x00, 0x00, 0x05, 0x00, 0x06, // x_FragData1.....
- 0x00, 0x62, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, // .b...bgfx_FragDa
- 0x74, 0x61, 0x32, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x64, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // ta2......d...bgf
- 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x33, 0x00, 0x00, 0x05, 0x00, 0x06, // x_FragData3.....
- 0x00, 0x66, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, // .f...bgfx_FragDa
- 0x74, 0x61, 0x34, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x68, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // ta4......h...bgf
- 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x35, 0x00, 0x00, 0x05, 0x00, 0x06, // x_FragData5.....
- 0x00, 0x6a, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, // .j...bgfx_FragDa
- 0x74, 0x61, 0x36, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // ta6......l...bgf
- 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x37, 0x00, 0x00, 0x47, 0x00, 0x04, // x_FragData7..G..
- 0x00, 0x26, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, // .&...........H..
- 0x00, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .'.......#......
- 0x00, 0x47, 0x00, 0x03, 0x00, 0x27, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .G...'.......G..
- 0x00, 0x29, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .)...".......G..
- 0x00, 0x5e, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .^...........G..
- 0x00, 0x60, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .`...........G..
- 0x00, 0x62, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .b...........G..
- 0x00, 0x64, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .d...........G..
- 0x00, 0x66, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .f...........G..
- 0x00, 0x68, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .h...........G..
- 0x00, 0x6a, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, // .j...........G..
- 0x00, 0x6c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, // .l..............
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .....!..........
- 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, // ......... ......
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, // ................
- 0x00, 0x24, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .$... .......+..
- 0x00, 0x24, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, // .$...%..........
- 0x00, 0x26, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, // .&.......%......
- 0x00, 0x27, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, // .'...&... ...(..
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, // .....'...;...(..
- 0x00, 0x29, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, // .)...........*..
- 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, // . .......+...*..
- 0x00, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x2c, 0x00, 0x00, // .+....... ...,..
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, // .........+...*..
- 0x00, 0x2f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, // ./.......+...*..
- 0x00, 0x32, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, // .2.......+...*..
- 0x00, 0x35, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, // .5.......+...*..
- 0x00, 0x38, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, // .8.......+...*..
- 0x00, 0x3b, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, // .;.......+...*..
- 0x00, 0x3e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, // .>.......+...*..
- 0x00, 0x41, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x5d, 0x00, 0x00, // .A....... ...]..
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x5d, 0x00, 0x00, // .........;...]..
- 0x00, 0x5e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x5d, 0x00, 0x00, // .^.......;...]..
- 0x00, 0x60, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x5d, 0x00, 0x00, // .`.......;...]..
- 0x00, 0x62, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x5d, 0x00, 0x00, // .b.......;...]..
- 0x00, 0x64, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x5d, 0x00, 0x00, // .d.......;...]..
- 0x00, 0x66, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x5d, 0x00, 0x00, // .f.......;...]..
- 0x00, 0x68, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x5d, 0x00, 0x00, // .h.......;...]..
- 0x00, 0x6a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x5d, 0x00, 0x00, // .j.......;...]..
- 0x00, 0x6c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, // .l.......6......
- 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, // ................
- 0x00, 0x05, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, // .....A...,......
- 0x00, 0x29, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, // .)...+...+...=..
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, // .............A..
- 0x00, 0x2c, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, // .,.......)...+..
- 0x00, 0x2f, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, // ./...=..........
- 0x00, 0x85, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, // .....A...,......
- 0x00, 0x29, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, // .)...+...2...=..
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, // .............A..
- 0x00, 0x2c, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, // .,.......)...+..
- 0x00, 0x35, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, // .5...=..........
- 0x00, 0x89, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, // .....A...,......
- 0x00, 0x29, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, // .)...+...8...=..
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, // .............A..
- 0x00, 0x2c, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, // .,.......)...+..
- 0x00, 0x3b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, // .;...=..........
- 0x00, 0x8d, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x8f, 0x00, 0x00, // .....A...,......
- 0x00, 0x29, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, // .)...+...>...=..
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, // .............A..
- 0x00, 0x2c, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, // .,.......)...+..
- 0x00, 0x41, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, // .A...=..........
- 0x00, 0x91, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, // .....>...^......
- 0x00, 0x3e, 0x00, 0x03, 0x00, 0x60, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .>...`.......>..
- 0x00, 0x62, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x64, 0x00, 0x00, // .b.......>...d..
- 0x00, 0x8a, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x66, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, // .....>...f......
- 0x00, 0x3e, 0x00, 0x03, 0x00, 0x68, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .>...h.......>..
- 0x00, 0x6a, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x6c, 0x00, 0x00, // .j.......>...l..
- 0x00, 0x92, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x00, 0x00, 0x80, // .........8......
- 0x00, // .
+ 0x46, 0x53, 0x48, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, // FSH............b
+ 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x12, // gfx_clear_color.
+ 0x08, 0x00, 0x00, 0x08, 0x00, 0xe8, 0x05, 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, // ...........#....
+ 0x00, 0x07, 0x00, 0x08, 0x00, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, // ................
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, // .............GLS
+ 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, // L.std.450.......
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x0d, 0x00, 0x04, 0x00, 0x00, // ................
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, // .....main....^..
+ 0x00, 0x60, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, // .`...b...d...f..
+ 0x00, 0x68, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, // .h...j...l......
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, // ................
+ 0x00, 0xf4, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, // .............mai
+ 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6c, // n........'...$Gl
+ 0x6f, 0x62, 0x61, 0x6c, 0x00, 0x06, 0x00, 0x08, 0x00, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // obal.....'......
+ 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // .bgfx_clear_colo
+ 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // r........)......
+ 0x00, 0x05, 0x00, 0x06, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, // .....^...bgfx_Fr
+ 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x30, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x60, 0x00, 0x00, // agData0......`..
+ 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x31, 0x00, // .bgfx_FragData1.
+ 0x00, 0x05, 0x00, 0x06, 0x00, 0x62, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, // .....b...bgfx_Fr
+ 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x32, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x64, 0x00, 0x00, // agData2......d..
+ 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x33, 0x00, // .bgfx_FragData3.
+ 0x00, 0x05, 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, // .....f...bgfx_Fr
+ 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x34, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x68, 0x00, 0x00, // agData4......h..
+ 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x35, 0x00, // .bgfx_FragData5.
+ 0x00, 0x05, 0x00, 0x06, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, // .....j...bgfx_Fr
+ 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x36, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x6c, 0x00, 0x00, // agData6......l..
+ 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x37, 0x00, // .bgfx_FragData7.
+ 0x00, 0x47, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, // .G...&..........
+ 0x00, 0x48, 0x00, 0x05, 0x00, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, // .H...'.......#..
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x27, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .....G...'......
+ 0x00, 0x47, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .G...)..."......
+ 0x00, 0x47, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, // .G...)...!...0..
+ 0x00, 0x47, 0x00, 0x04, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .G...^..........
+ 0x00, 0x47, 0x00, 0x04, 0x00, 0x60, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .G...`..........
+ 0x00, 0x47, 0x00, 0x04, 0x00, 0x62, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .G...b..........
+ 0x00, 0x47, 0x00, 0x04, 0x00, 0x64, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .G...d..........
+ 0x00, 0x47, 0x00, 0x04, 0x00, 0x66, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // .G...f..........
+ 0x00, 0x47, 0x00, 0x04, 0x00, 0x68, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, // .G...h..........
+ 0x00, 0x47, 0x00, 0x04, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, // .G...j..........
+ 0x00, 0x47, 0x00, 0x04, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, // .G...l..........
+ 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, // .........!......
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // ............. ..
+ 0x00, 0x17, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // ................
+ 0x00, 0x15, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .....$... ......
+ 0x00, 0x2b, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // .+...$...%......
+ 0x00, 0x1c, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, // .....&.......%..
+ 0x00, 0x1e, 0x00, 0x03, 0x00, 0x27, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // .....'...&... ..
+ 0x00, 0x28, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .(.......'...;..
+ 0x00, 0x28, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, // .(...)..........
+ 0x00, 0x2a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .*... .......+..
+ 0x00, 0x2a, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // .*...+....... ..
+ 0x00, 0x2c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .,...........+..
+ 0x00, 0x2a, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .*.../.......+..
+ 0x00, 0x2a, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .*...2.......+..
+ 0x00, 0x2a, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .*...5.......+..
+ 0x00, 0x2a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .*...8.......+..
+ 0x00, 0x2a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .*...;.......+..
+ 0x00, 0x2a, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .*...>.......+..
+ 0x00, 0x2a, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // .*...A....... ..
+ 0x00, 0x5d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .]...........;..
+ 0x00, 0x5d, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .]...^.......;..
+ 0x00, 0x5d, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .]...`.......;..
+ 0x00, 0x5d, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .]...b.......;..
+ 0x00, 0x5d, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .]...d.......;..
+ 0x00, 0x5d, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .]...f.......;..
+ 0x00, 0x5d, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .]...h.......;..
+ 0x00, 0x5d, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .]...j.......;..
+ 0x00, 0x5d, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, // .]...l.......6..
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // ................
+ 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2c, 0x00, 0x00, // .........A...,..
+ 0x00, 0x83, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, // .....)...+...+..
+ 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, // .=..............
+ 0x00, 0x41, 0x00, 0x06, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, // .A...,.......)..
+ 0x00, 0x2b, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // .+.../...=......
+ 0x00, 0x86, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2c, 0x00, 0x00, // .........A...,..
+ 0x00, 0x87, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, // .....)...+...2..
+ 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, // .=..............
+ 0x00, 0x41, 0x00, 0x06, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, // .A...,.......)..
+ 0x00, 0x2b, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // .+...5...=......
+ 0x00, 0x8a, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2c, 0x00, 0x00, // .........A...,..
+ 0x00, 0x8b, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, // .....)...+...8..
+ 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, // .=..............
+ 0x00, 0x41, 0x00, 0x06, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, // .A...,.......)..
+ 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // .+...;...=......
+ 0x00, 0x8e, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2c, 0x00, 0x00, // .........A...,..
+ 0x00, 0x8f, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, // .....)...+...>..
+ 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x8f, 0x00, 0x00, // .=..............
+ 0x00, 0x41, 0x00, 0x06, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, // .A...,.......)..
+ 0x00, 0x2b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, // .+...A...=......
+ 0x00, 0x92, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x5e, 0x00, 0x00, // .........>...^..
+ 0x00, 0x84, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x60, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, // .....>...`......
+ 0x00, 0x3e, 0x00, 0x03, 0x00, 0x62, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .>...b.......>..
+ 0x00, 0x64, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x66, 0x00, 0x00, // .d.......>...f..
+ 0x00, 0x8c, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x68, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, // .....>...h......
+ 0x00, 0x3e, 0x00, 0x03, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .>...j.......>..
+ 0x00, 0x6c, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, // .l...........8..
+ 0x00, 0x00, 0x00, 0x80, 0x00, // .....
};
static const uint8_t fs_clear7_dx9[234] =
{
diff --git a/3rdparty/bgfx/src/fs_clear7.sc b/3rdparty/bgfx/src/fs_clear7.sc
index 946eb2fe188..bb1549c2fe5 100644
--- a/3rdparty/bgfx/src/fs_clear7.sc
+++ b/3rdparty/bgfx/src/fs_clear7.sc
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/fs_debugfont.bin.h b/3rdparty/bgfx/src/fs_debugfont.bin.h
index d491d4d3b66..be4a8ceb091 100644
--- a/3rdparty/bgfx/src/fs_debugfont.bin.h
+++ b/3rdparty/bgfx/src/fs_debugfont.bin.h
@@ -24,75 +24,77 @@ 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_spv[1070] =
+static const uint8_t fs_debugfont_spv[1091] =
{
- 0x46, 0x53, 0x48, 0x05, 0xb8, 0xbe, 0x22, 0x66, 0x00, 0x00, 0x1c, 0x04, 0x00, 0x00, 0x03, 0x02, // FSH..."f........
- 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x08, 0x00, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, // #...............
- 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, // ................
- 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, // ..GLSL.std.450..
- 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, // ................
- 0x09, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, // ..........main..
- 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x7d, 0x00, // ..i...l...p...}.
- 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, // ................
- 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, // ................
- 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x29, 0x00, // ..main........).
- 0x00, 0x00, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x53, 0x61, 0x6d, 0x70, // ..s_texColorSamp
- 0x6c, 0x65, 0x72, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x73, 0x5f, // ler.......,...s_
- 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, // texColorTexture.
- 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x69, 0x00, 0x00, 0x00, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // ......i...v_colo
- 0x72, 0x30, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x76, 0x5f, // r0........l...v_
- 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x31, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x70, 0x00, // color1........p.
- 0x00, 0x00, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x00, 0x05, 0x00, // ..v_texcoord0...
- 0x06, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, // ..}...bgfx_FragD
- 0x61, 0x74, 0x61, 0x30, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, 0x22, 0x00, // ata0..G...)...".
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, 0x21, 0x00, // ......G...)...!.
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x22, 0x00, // ......G...,...".
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x21, 0x00, // ......G...,...!.
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x69, 0x00, 0x00, 0x00, 0x1e, 0x00, // ......G...i.....
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x1e, 0x00, // ......G...l.....
- 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x70, 0x00, 0x00, 0x00, 0x1e, 0x00, // ......G...p.....
- 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x1e, 0x00, // ......G...}.....
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, // ..............!.
- 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x02, 0x00, 0x06, 0x00, // ................
- 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x19, 0x00, // .......... .....
- 0x09, 0x00, 0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
- 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x02, 0x00, // ................
- 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x00, // ................
- 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, // .. ...(.........
- 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, // ..;...(...).....
- 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, // .. ...+.........
- 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, // ..;...+...,.....
- 0x00, 0x00, 0x1b, 0x00, 0x03, 0x00, 0x38, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x2b, 0x00, // ......8.......+.
- 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x81, 0x80, 0x80, 0x3b, 0x14, 0x00, // ......`......;..
- 0x02, 0x00, 0x61, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x68, 0x00, 0x00, 0x00, 0x01, 0x00, // ..a... ...h.....
- 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x68, 0x00, 0x00, 0x00, 0x69, 0x00, // ......;...h...i.
- 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x68, 0x00, 0x00, 0x00, 0x6c, 0x00, // ......;...h...l.
- 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x01, 0x00, // ...... ...o.....
- 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x70, 0x00, // ......;...o...p.
- 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x03, 0x00, // ...... ...|.....
- 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x7d, 0x00, // ......;...|...}.
- 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, // ......6.........
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, // ................
- 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x29, 0x00, // ..=.......*...).
- 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x2c, 0x00, // ..=.......-...,.
- 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x69, 0x00, // ..=.......j...i.
- 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x6c, 0x00, // ..=.......m...l.
- 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x70, 0x00, // ..=.......q...p.
- 0x00, 0x00, 0x56, 0x00, 0x05, 0x00, 0x38, 0x00, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x00, 0x2d, 0x00, // ..V...8.......-.
- 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x57, 0x00, 0x05, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xa8, 0x00, // ..*...W.........
- 0x00, 0x00, 0xa6, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x09, 0x00, 0x0d, 0x00, // ......q...O.....
- 0x00, 0x00, 0x93, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, // ................
- 0x08, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, // ................
- 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x93, 0x00, 0x00, 0x00, 0x51, 0x00, // ..m...j.......Q.
- 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xb3, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, 0x00, 0x03, 0x00, // ................
- 0x00, 0x00, 0xb8, 0x00, 0x05, 0x00, 0x61, 0x00, 0x00, 0x00, 0x97, 0x00, 0x00, 0x00, 0xb3, 0x00, // ......a.........
- 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x03, 0x00, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, // ..`.............
- 0x00, 0x00, 0xfa, 0x00, 0x04, 0x00, 0x97, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x98, 0x00, // ................
- 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x99, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x01, 0x00, 0xf8, 0x00, // ................
- 0x02, 0x00, 0x98, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x7d, 0x00, 0x00, 0x00, 0xad, 0x00, // ......>...}.....
- 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // ......8.......
+ 0x46, 0x53, 0x48, 0x06, 0xb8, 0xbe, 0x22, 0x66, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0a, 0x73, // FSH..."f.......s
+ 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x10, 0x00, 0x40, 0x00, 0x50, 0x00, 0x1c, // _texColor..@.P..
+ 0x04, 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x07, 0x00, 0x08, 0x00, 0xbb, // .....#..........
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, // ................
+ 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, // .......GLSL.std.
+ 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, // 450.............
+ 0x00, 0x00, 0x00, 0x0f, 0x00, 0x09, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, // ...............m
+ 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x70, // ain....i...l...p
+ 0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, // ...}............
+ 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x00, 0x05, // ................
+ 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, // .......main.....
+ 0x00, 0x07, 0x00, 0x29, 0x00, 0x00, 0x00, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, // ...)...s_texColo
+ 0x72, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x2c, // rSampler.......,
+ 0x00, 0x00, 0x00, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x54, 0x65, 0x78, // ...s_texColorTex
+ 0x74, 0x75, 0x72, 0x65, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x69, 0x00, 0x00, 0x00, 0x76, // ture.......i...v
+ 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x6c, // _color0........l
+ 0x00, 0x00, 0x00, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x31, 0x00, 0x00, 0x00, 0x00, 0x05, // ...v_color1.....
+ 0x00, 0x05, 0x00, 0x70, 0x00, 0x00, 0x00, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, // ...p...v_texcoor
+ 0x64, 0x30, 0x00, 0x05, 0x00, 0x06, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, // d0.....}...bgfx_
+ 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x30, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x29, // FragData0..G...)
+ 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x29, // ...".......G...)
+ 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x2c, // ...!...P...G...,
+ 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x2c, // ...".......G...,
+ 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x69, // ...!...@...G...i
+ 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x6c, // ...........G...l
+ 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x70, // ...........G...p
+ 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x7d, // ...........G...}
+ 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, // ................
+ 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1a, // ...!............
+ 0x00, 0x02, 0x00, 0x06, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, 0x20, // ...............
+ 0x00, 0x00, 0x00, 0x19, 0x00, 0x09, 0x00, 0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, // ................
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, // ................
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x07, // ................
+ 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x07, // ................
+ 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, // ....... ...(....
+ 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x29, // .......;...(...)
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x00, // ....... ...+....
+ 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x2c, // .......;...+...,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x03, 0x00, 0x38, 0x00, 0x00, 0x00, 0x08, // ...........8....
+ 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x81, // ...+.......`....
+ 0x80, 0x80, 0x3b, 0x14, 0x00, 0x02, 0x00, 0x61, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x68, // ..;....a... ...h
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x68, // ...........;...h
+ 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x68, // ...i.......;...h
+ 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x6f, // ...l....... ...o
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x6f, // ...........;...o
+ 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x7c, // ...p....... ...|
+ 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x7c, // ...........;...|
+ 0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, // ...}.......6....
+ 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, // ................
+ 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2a, // .......=.......*
+ 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x2d, // ...)...=.......-
+ 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x6a, // ...,...=.......j
+ 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x6d, // ...i...=.......m
+ 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x71, // ...l...=.......q
+ 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x56, 0x00, 0x05, 0x00, 0x38, 0x00, 0x00, 0x00, 0xb3, // ...p...V...8....
+ 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x57, 0x00, 0x05, 0x00, 0x0d, // ...-...*...W....
+ 0x00, 0x00, 0x00, 0xb5, 0x00, 0x00, 0x00, 0xb3, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x4f, // ...........q...O
+ 0x00, 0x09, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x9f, 0x00, 0x00, 0x00, 0xb5, 0x00, 0x00, 0x00, 0xb5, // ................
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+ 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xba, 0x00, 0x00, 0x00, 0x01, // ................
+ 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x9f, // .......m...j....
+ 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, 0xba, // ...Q............
+ 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xb8, 0x00, 0x05, 0x00, 0x61, 0x00, 0x00, 0x00, 0xa3, // ...........a....
+ 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x03, 0x00, 0xa4, // .......`........
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x04, 0x00, 0xa3, 0x00, 0x00, 0x00, 0xa5, // ................
+ 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0xa5, 0x00, 0x00, 0x00, 0xfc, // ................
+ 0x00, 0x01, 0x00, 0xf8, 0x00, 0x02, 0x00, 0xa4, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x7d, // ...........>...}
+ 0x00, 0x00, 0x00, 0xba, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x00, // ...........8....
+ 0x00, 0x00, 0x00, // ...
};
static const uint8_t fs_debugfont_dx9[364] =
{
diff --git a/3rdparty/bgfx/src/fs_debugfont.sc b/3rdparty/bgfx/src/fs_debugfont.sc
index 8d9c04b5a40..16f4f060064 100644
--- a/3rdparty/bgfx/src/fs_debugfont.sc
+++ b/3rdparty/bgfx/src/fs_debugfont.sc
@@ -1,7 +1,7 @@
$input v_color0, v_color1, v_texcoord0
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/glcontext_eagl.h b/3rdparty/bgfx/src/glcontext_eagl.h
index 5e816b4e675..c519623eb02 100644
--- a/3rdparty/bgfx/src/glcontext_eagl.h
+++ b/3rdparty/bgfx/src/glcontext_eagl.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/glcontext_eagl.mm b/3rdparty/bgfx/src/glcontext_eagl.mm
index a9e49a3a8ba..a03a64998ac 100644
--- a/3rdparty/bgfx/src/glcontext_eagl.mm
+++ b/3rdparty/bgfx/src/glcontext_eagl.mm
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -165,7 +165,7 @@ namespace bgfx { namespace gl
BX_CHECK(NULL != s_opengles, "OpenGLES dynamic library is not found!");
BX_UNUSED(_width, _height);
- CAEAGLLayer* layer = (CAEAGLLayer*)g_platformData.nwh;
+ CAEAGLLayer* layer = (__bridge CAEAGLLayer*)g_platformData.nwh;
layer.opaque = [layer.style valueForKey:@"opaque"] == nil ? true : [[layer.style valueForKey:@"opaque"] boolValue];
layer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys
@@ -176,7 +176,7 @@ namespace bgfx { namespace gl
, nil
];
- EAGLContext* context = (EAGLContext*)g_platformData.context;
+ EAGLContext* context = (__bridge EAGLContext*)g_platformData.context;
if (NULL == context)
{
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
@@ -187,7 +187,7 @@ namespace bgfx { namespace gl
}
BX_CHECK(NULL != context, "No valid OpenGLES context.");
- m_context = (void*)context;
+ m_context = (__bridge void*)context;
[EAGLContext setCurrentContext:context];
[CATransaction flush];
@@ -249,8 +249,7 @@ namespace bgfx { namespace gl
m_depthStencilRbo = 0;
}
- EAGLContext* context = (EAGLContext*)m_context;
- [context release];
+ EAGLContext* context = (__bridge EAGLContext*)m_context;
bx::dlclose(s_opengles);
}
@@ -284,7 +283,7 @@ namespace bgfx { namespace gl
GL_CHECK(glGenRenderbuffers(1, &m_colorRbo) );
GL_CHECK(glBindRenderbuffer(GL_RENDERBUFFER, m_colorRbo) );
- [((EAGLContext*)m_context) renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer*)g_platformData.nwh];
+ [((__bridge EAGLContext*)m_context) renderbufferStorage:GL_RENDERBUFFER fromDrawable:(__bridge CAEAGLLayer*)g_platformData.nwh];
GL_CHECK(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_colorRbo) );
GLint width;
@@ -312,7 +311,7 @@ namespace bgfx { namespace gl
SwapChainGL* GlContext::createSwapChain(void* _nwh)
{
- return BX_NEW(g_allocator, SwapChainGL)(/*m_display, m_config,*/ (EAGLContext*)m_context, (CAEAGLLayer*)_nwh);
+ return BX_NEW(g_allocator, SwapChainGL)(/*m_display, m_config,*/ (__bridge EAGLContext*)m_context, (__bridge CAEAGLLayer*)_nwh);
}
void GlContext::destroySwapChain(SwapChainGL* _swapChain)
@@ -327,7 +326,7 @@ namespace bgfx { namespace gl
if (NULL == _swapChain)
{
GL_CHECK(glBindRenderbuffer(GL_RENDERBUFFER, m_colorRbo) );
- EAGLContext* context = (EAGLContext*)m_context;
+ EAGLContext* context = (__bridge EAGLContext*)m_context;
[context presentRenderbuffer:GL_RENDERBUFFER];
}
else
@@ -344,7 +343,7 @@ namespace bgfx { namespace gl
if (NULL == _swapChain)
{
- [EAGLContext setCurrentContext:(EAGLContext*)m_context];
+ [EAGLContext setCurrentContext:(__bridge EAGLContext*)m_context];
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_fbo) );
}
else
diff --git a/3rdparty/bgfx/src/glcontext_egl.cpp b/3rdparty/bgfx/src/glcontext_egl.cpp
index 67e643262b1..15de208b703 100644
--- a/3rdparty/bgfx/src/glcontext_egl.cpp
+++ b/3rdparty/bgfx/src/glcontext_egl.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -40,21 +40,21 @@ namespace bgfx { namespace gl
typedef EGLBoolean (EGLAPIENTRY* PFNEGLSWAPINTERVALPROC)(EGLDisplay dpy, EGLint interval);
typedef EGLBoolean (EGLAPIENTRY* PFNEGLTERMINATEPROC)(EGLDisplay dpy);
-#define EGL_IMPORT \
- EGL_IMPORT_FUNC(PFNEGLCHOOSECONFIGPROC, eglChooseConfig); \
- EGL_IMPORT_FUNC(PFNEGLCREATECONTEXTPROC, eglCreateContext); \
- EGL_IMPORT_FUNC(PFNEGLCREATEWINDOWSURFACEPROC, eglCreateWindowSurface); \
- EGL_IMPORT_FUNC(PFNEGLGETDISPLAYPROC, eglGetDisplay); \
- EGL_IMPORT_FUNC(PFNEGLGETERRORPROC, eglGetError); \
- EGL_IMPORT_FUNC(PFNEGLGETPROCADDRESSPROC, eglGetProcAddress); \
- EGL_IMPORT_FUNC(PFNEGLDESTROYCONTEXTPROC, eglDestroyContext); \
- EGL_IMPORT_FUNC(PFNEGLDESTROYSURFACEPROC, eglDestroySurface); \
- EGL_IMPORT_FUNC(PFNEGLINITIALIZEPROC, eglInitialize); \
- EGL_IMPORT_FUNC(PFNEGLMAKECURRENTPROC, eglMakeCurrent); \
- EGL_IMPORT_FUNC(PGNEGLQUERYSTRINGPROC, eglQueryString); \
- EGL_IMPORT_FUNC(PFNEGLSWAPBUFFERSPROC, eglSwapBuffers); \
- EGL_IMPORT_FUNC(PFNEGLSWAPINTERVALPROC, eglSwapInterval); \
- EGL_IMPORT_FUNC(PFNEGLTERMINATEPROC, eglTerminate);
+#define EGL_IMPORT \
+ EGL_IMPORT_FUNC(PFNEGLCHOOSECONFIGPROC, eglChooseConfig); \
+ EGL_IMPORT_FUNC(PFNEGLCREATECONTEXTPROC, eglCreateContext); \
+ EGL_IMPORT_FUNC(PFNEGLCREATEWINDOWSURFACEPROC, eglCreateWindowSurface); \
+ EGL_IMPORT_FUNC(PFNEGLGETDISPLAYPROC, eglGetDisplay); \
+ EGL_IMPORT_FUNC(PFNEGLGETERRORPROC, eglGetError); \
+ EGL_IMPORT_FUNC(PFNEGLGETPROCADDRESSPROC, eglGetProcAddress); \
+ EGL_IMPORT_FUNC(PFNEGLDESTROYCONTEXTPROC, eglDestroyContext); \
+ EGL_IMPORT_FUNC(PFNEGLDESTROYSURFACEPROC, eglDestroySurface); \
+ EGL_IMPORT_FUNC(PFNEGLINITIALIZEPROC, eglInitialize); \
+ EGL_IMPORT_FUNC(PFNEGLMAKECURRENTPROC, eglMakeCurrent); \
+ EGL_IMPORT_FUNC(PGNEGLQUERYSTRINGPROC, eglQueryString); \
+ EGL_IMPORT_FUNC(PFNEGLSWAPBUFFERSPROC, eglSwapBuffers); \
+ EGL_IMPORT_FUNC(PFNEGLSWAPINTERVALPROC, eglSwapInterval); \
+ EGL_IMPORT_FUNC(PFNEGLTERMINATEPROC, eglTerminate);
#define EGL_IMPORT_FUNC(_proto, _func) _proto _func
EGL_IMPORT
@@ -65,10 +65,10 @@ EGL_IMPORT
void* handle = bx::dlopen("libEGL." BX_DL_EXT);
BGFX_FATAL(NULL != handle, Fatal::UnableToInitialize, "Failed to load libEGL dynamic library.");
-#define EGL_IMPORT_FUNC(_proto, _func) \
- _func = (_proto)bx::dlsym(handle, #_func); \
- BX_TRACE("%p " #_func, _func); \
- BGFX_FATAL(NULL != _func, Fatal::UnableToInitialize, "Failed get " #_func ".")
+#define EGL_IMPORT_FUNC(_proto, _func) \
+ _func = (_proto)bx::dlsym(handle, #_func); \
+ BX_TRACE("%p " #_func, _func); \
+ BGFX_FATAL(NULL != _func, Fatal::UnableToInitialize, "Failed get " #_func ".")
EGL_IMPORT
#undef EGL_IMPORT_FUNC
@@ -107,6 +107,8 @@ EGL_IMPORT
: m_nwh(_nwh)
, m_display(_display)
{
+ EGLSurface defaultSurface = eglGetCurrentSurface(EGL_DRAW);
+
m_surface = eglCreateWindowSurface(m_display, _config, _nwh, NULL);
BGFX_FATAL(m_surface != EGL_NO_SURFACE, Fatal::UnableToInitialize, "Failed to create surface.");
@@ -119,13 +121,18 @@ EGL_IMPORT
swapBuffers();
GL_CHECK(glClear(GL_COLOR_BUFFER_BIT) );
swapBuffers();
+ eglMakeCurrent(m_display, defaultSurface, defaultSurface, _context);
}
~SwapChainGL()
{
+ EGLSurface defaultSurface = eglGetCurrentSurface(EGL_DRAW);
+ EGLContext defaultContext = eglGetCurrentContext();
+
eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroyContext(m_display, m_context);
eglDestroySurface(m_display, m_surface);
+ eglMakeCurrent(m_display, defaultSurface, defaultSurface, defaultContext);
}
void makeCurrent()
@@ -439,26 +446,27 @@ EGL_IMPORT
BX_TRACE("Import:");
# if BX_PLATFORM_WINDOWS || BX_PLATFORM_LINUX
void* glesv2 = bx::dlopen("libGLESv2." BX_DL_EXT);
-# define GL_EXTENSION(_optional, _proto, _func, _import) \
- { \
- if (NULL == _func) \
- { \
- _func = (_proto)bx::dlsym(glesv2, #_import); \
- BX_TRACE("\t%p " #_func " (" #_import ")", _func); \
- BGFX_FATAL(_optional || NULL != _func, Fatal::UnableToInitialize, "Failed to create OpenGLES context. eglGetProcAddress(\"%s\")", #_import); \
- } \
- }
+# define GL_EXTENSION(_optional, _proto, _func, _import) \
+ { \
+ if (NULL == _func) \
+ { \
+ _func = (_proto)bx::dlsym(glesv2, #_import); \
+ BX_TRACE("\t%p " #_func " (" #_import ")", _func); \
+ BGFX_FATAL(_optional || NULL != _func, Fatal::UnableToInitialize, "Failed to create OpenGLES context. eglGetProcAddress(\"%s\")", #_import); \
+ } \
+ }
# else
-# define GL_EXTENSION(_optional, _proto, _func, _import) \
- { \
- if (NULL == _func) \
- { \
- _func = (_proto)eglGetProcAddress(#_import); \
- BX_TRACE("\t%p " #_func " (" #_import ")", _func); \
- BGFX_FATAL(_optional || NULL != _func, Fatal::UnableToInitialize, "Failed to create OpenGLES context. eglGetProcAddress(\"%s\")", #_import); \
- } \
- }
+# define GL_EXTENSION(_optional, _proto, _func, _import) \
+ { \
+ if (NULL == _func) \
+ { \
+ _func = (_proto)eglGetProcAddress(#_import); \
+ BX_TRACE("\t%p " #_func " (" #_import ")", _func); \
+ BGFX_FATAL(_optional || NULL != _func, Fatal::UnableToInitialize, "Failed to create OpenGLES context. eglGetProcAddress(\"%s\")", #_import); \
+ } \
+ }
# endif // BX_PLATFORM_
+
# include "glimports.h"
}
diff --git a/3rdparty/bgfx/src/glcontext_egl.h b/3rdparty/bgfx/src/glcontext_egl.h
index ac7275666f4..245cd7ad3b6 100644
--- a/3rdparty/bgfx/src/glcontext_egl.h
+++ b/3rdparty/bgfx/src/glcontext_egl.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/glcontext_glx.cpp b/3rdparty/bgfx/src/glcontext_glx.cpp
index b968267e9c0..df7c18536f7 100644
--- a/3rdparty/bgfx/src/glcontext_glx.cpp
+++ b/3rdparty/bgfx/src/glcontext_glx.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -164,17 +164,16 @@ namespace bgfx { namespace gl
m_context = glXCreateContext(m_display, m_visualInfo, 0, GL_TRUE);
BGFX_FATAL(NULL != m_context, Fatal::UnableToInitialize, "Failed to create GL 2.1 context.");
-#if BGFX_CONFIG_RENDERER_OPENGL >= 31
glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress( (const GLubyte*)"glXCreateContextAttribsARB");
if (NULL != glXCreateContextAttribsARB)
{
- BX_TRACE("Create GL 3.1 context.");
+ BX_TRACE("Create GL %d.%d context.", BGFX_CONFIG_RENDERER_OPENGL / 10, BGFX_CONFIG_RENDERER_OPENGL % 10);
int32_t flags = BGFX_CONFIG_DEBUG ? GLX_CONTEXT_DEBUG_BIT_ARB : 0;
const int contextAttrs[] =
{
- GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
- GLX_CONTEXT_MINOR_VERSION_ARB, 1,
+ GLX_CONTEXT_MAJOR_VERSION_ARB, BGFX_CONFIG_RENDERER_OPENGL / 10,
+ GLX_CONTEXT_MINOR_VERSION_ARB, BGFX_CONFIG_RENDERER_OPENGL % 10,
GLX_CONTEXT_FLAGS_ARB, flags,
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
0,
@@ -188,9 +187,6 @@ namespace bgfx { namespace gl
m_context = context;
}
}
-#else
- BX_UNUSED(bestConfig);
-#endif // BGFX_CONFIG_RENDERER_OPENGL >= 31
XUnlockDisplay(m_display);
}
diff --git a/3rdparty/bgfx/src/glcontext_glx.h b/3rdparty/bgfx/src/glcontext_glx.h
index 622f6ab98de..7b8d7441d44 100644
--- a/3rdparty/bgfx/src/glcontext_glx.h
+++ b/3rdparty/bgfx/src/glcontext_glx.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/glcontext_html5.cpp b/3rdparty/bgfx/src/glcontext_html5.cpp
new file mode 100644
index 00000000000..c9f15922e4c
--- /dev/null
+++ b/3rdparty/bgfx/src/glcontext_html5.cpp
@@ -0,0 +1,199 @@
+/*
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ */
+
+#include "bgfx_p.h"
+
+#if BGFX_CONFIG_RENDERER_OPENGLES
+# include "renderer_gl.h"
+
+# if BGFX_USE_HTML5
+
+#include <emscripten/emscripten.h>
+#include <emscripten/html5.h>
+
+// from emscripten gl.c, because we're not going to go
+// through egl
+extern "C" void* emscripten_GetProcAddress(const char *name_);
+extern "C" void* emscripten_webgl1_get_proc_address(const char *name_);
+extern "C" void* emscripten_webgl2_get_proc_address(const char *name_);
+
+namespace bgfx { namespace gl
+{
+
+# define GL_IMPORT(_optional, _proto, _func, _import) _proto _func = NULL
+# include "glimports.h"
+
+ static EmscriptenWebGLContextAttributes s_attrs;
+
+ struct SwapChainGL
+ {
+ SwapChainGL(int _context, const char* _canvas)
+ : m_context(_context)
+ {
+ m_canvas = (char*)BX_ALLOC(g_allocator, strlen(_canvas) + 1);
+ strcpy(m_canvas, _canvas);
+
+ makeCurrent();
+ GL_CHECK(glClearColor(0.0f, 0.0f, 0.0f, 0.0f) );
+ GL_CHECK(glClear(GL_COLOR_BUFFER_BIT) );
+ swapBuffers();
+ GL_CHECK(glClear(GL_COLOR_BUFFER_BIT) );
+ swapBuffers();
+ }
+
+ ~SwapChainGL()
+ {
+ emscripten_webgl_destroy_context(m_context);
+ BX_FREE(g_allocator, m_canvas);
+ }
+
+ void makeCurrent()
+ {
+ emscripten_webgl_make_context_current(m_context);
+ }
+
+ void swapBuffers()
+ {
+ // There is no swapBuffers equivalent. A swap happens whenever control is returned back
+ // to the browser.
+ }
+
+ int m_context;
+ char* m_canvas;
+ };
+
+ void GlContext::create(uint32_t _width, uint32_t _height)
+ {
+ // assert?
+ if (m_primary != NULL)
+ return;
+
+ const char* canvas = (const char*) g_platformData.nwh; // if 0, Module.canvas is used
+
+ m_primary = createSwapChain((void*)canvas);
+
+ if (_width && _height)
+ emscripten_set_canvas_element_size(canvas, (int)_width, (int)_height);
+
+ makeCurrent(m_primary);
+ }
+
+ void GlContext::destroy()
+ {
+ if (m_primary)
+ {
+ if (m_current == m_primary)
+ {
+ m_current = NULL;
+ }
+
+ BX_DELETE(g_allocator, m_primary);
+ m_primary = NULL;
+ }
+ }
+
+ void GlContext::resize(uint32_t _width, uint32_t _height, uint32_t /* _flags */)
+ {
+ if (m_primary == NULL)
+ {
+ return;
+ }
+
+ emscripten_set_canvas_element_size(m_primary->m_canvas, (int) _width, (int) _height);
+ }
+
+ SwapChainGL* GlContext::createSwapChain(void* _nwh)
+ {
+ emscripten_webgl_init_context_attributes(&s_attrs);
+
+ s_attrs.alpha = false;
+ s_attrs.depth = true;
+ s_attrs.stencil = true;
+ s_attrs.enableExtensionsByDefault = true;
+
+ // let emscripten figure out the best WebGL context to create
+ s_attrs.majorVersion = 0;
+ s_attrs.majorVersion = 0;
+
+ const char* canvas = (const char*) _nwh;
+
+ int context = emscripten_webgl_create_context(canvas, &s_attrs);
+
+ if (context <= 0)
+ {
+ BX_TRACE("Failed to create WebGL context. (Canvas handle: '%s', error %d)", canvas, (int)context);
+ return NULL;
+ }
+
+ int result = emscripten_webgl_make_context_current(context);
+ if (EMSCRIPTEN_RESULT_SUCCESS != result)
+ {
+ BX_TRACE("emscripten_webgl_make_context_current failed (%d)", result);
+ return NULL;
+ }
+
+ SwapChainGL* swapChain = BX_NEW(g_allocator, SwapChainGL)(context, canvas);
+
+ import(1);
+
+ return swapChain;
+ }
+
+ uint64_t GlContext::getCaps() const
+ {
+ return BGFX_CAPS_SWAP_CHAIN;
+ }
+
+ void GlContext::destroySwapChain(SwapChainGL* _swapChain)
+ {
+ BX_DELETE(g_allocator, _swapChain);
+ }
+
+ void GlContext::swap(SwapChainGL* /* _swapChain */)
+ {
+ }
+
+ void GlContext::makeCurrent(SwapChainGL* _swapChain)
+ {
+ if (m_current != _swapChain)
+ {
+ m_current = _swapChain;
+
+ if (NULL == _swapChain)
+ {
+ if (NULL != m_primary)
+ {
+ m_primary->makeCurrent();
+ }
+ }
+ else
+ {
+ _swapChain->makeCurrent();
+ }
+ }
+ }
+
+ void GlContext::import(int webGLVersion)
+ {
+ BX_TRACE("Import:");
+# define GL_EXTENSION(_optional, _proto, _func, _import) \
+ { \
+ if (NULL == _func) \
+ { \
+ _func = (_proto)emscripten_webgl1_get_proc_address(#_import); \
+ if (!_func && webGLVersion >= 2) \
+ _func = (_proto)emscripten_webgl2_get_proc_address(#_import); \
+ BX_TRACE("\t%p " #_func " (" #_import ")", _func); \
+ BGFX_FATAL(_optional || NULL != _func, Fatal::UnableToInitialize, "Failed to create WebGL/OpenGLES context. GetProcAddress(\"%s\")", #_import); \
+ } \
+ }
+
+# include "glimports.h"
+ }
+
+} /* namespace gl */ } // namespace bgfx
+
+# endif // BGFX_USE_EGL
+#endif // (BGFX_CONFIG_RENDERER_OPENGLES || BGFX_CONFIG_RENDERER_OPENGL)
diff --git a/3rdparty/bgfx/src/glcontext_html5.h b/3rdparty/bgfx/src/glcontext_html5.h
new file mode 100644
index 00000000000..7907cede904
--- /dev/null
+++ b/3rdparty/bgfx/src/glcontext_html5.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ */
+
+#ifndef BGFX_GLCONTEXT_HTML5_H_HEADER_GUARD
+#define BGFX_GLCONTEXT_HTML5_H_HEADER_GUARD
+
+#if BGFX_USE_HTML5
+
+namespace bgfx { namespace gl
+{
+ struct SwapChainGL;
+
+ struct GlContext
+ {
+ GlContext()
+ : m_current(NULL)
+ , m_primary(NULL)
+ {
+ }
+
+ void create(uint32_t _width, uint32_t _height);
+ void destroy();
+ void resize(uint32_t _width, uint32_t _height, uint32_t _flags);
+
+ uint64_t getCaps() const;
+ SwapChainGL* createSwapChain(void* _nwh);
+ void destroySwapChain(SwapChainGL* _swapChain);
+ void swap(SwapChainGL* _swapChain = NULL);
+ void makeCurrent(SwapChainGL* _swapChain = NULL);
+
+ void import(int webGLVersion);
+
+ bool isValid() const
+ {
+ return NULL != m_primary;
+ }
+
+ SwapChainGL* m_current;
+ SwapChainGL* m_primary;
+ };
+} /* namespace gl */ } // namespace bgfx
+
+#endif // BGFX_USE_HTML5
+
+#endif // BGFX_GLCONTEXT_HTML5_H_HEADER_GUARD
diff --git a/3rdparty/bgfx/src/glcontext_nsgl.h b/3rdparty/bgfx/src/glcontext_nsgl.h
index e6a6db9a223..59bf8e70de0 100644
--- a/3rdparty/bgfx/src/glcontext_nsgl.h
+++ b/3rdparty/bgfx/src/glcontext_nsgl.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/glcontext_nsgl.mm b/3rdparty/bgfx/src/glcontext_nsgl.mm
index af35e9c5ebf..db483528644 100644
--- a/3rdparty/bgfx/src/glcontext_nsgl.mm
+++ b/3rdparty/bgfx/src/glcontext_nsgl.mm
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -11,6 +11,8 @@
# include <Cocoa/Cocoa.h>
# include <bx/os.h>
+BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG("-Wdeprecated-declarations")
+
namespace bgfx { namespace gl
{
@@ -65,9 +67,21 @@ namespace bgfx { namespace gl
BX_CHECK(NULL != s_opengl, "OpenGL dynamic library is not found!");
const AutoreleasePoolHolder pool;
- NSWindow* nsWindow = (NSWindow*)g_platformData.nwh;
+ NSObject* nwh = (NSObject*)g_platformData.nwh;
m_context = g_platformData.context;
+ NSWindow* nsWindow = nil;
+ NSView* contentView = nil;
+ if ([nwh isKindOfClass:[NSView class]])
+ {
+ contentView = (NSView*)nwh;
+ }
+ else if ([nwh isKindOfClass:[NSWindow class]])
+ {
+ nsWindow = (NSWindow*)nwh;
+ contentView = [nsWindow contentView];
+ }
+
if (NULL == g_platformData.context)
{
#if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)
@@ -97,14 +111,13 @@ namespace bgfx { namespace gl
NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes];
BGFX_FATAL(NULL != pixelFormat, Fatal::UnableToInitialize, "Failed to initialize pixel format.");
- NSRect glViewRect = [[nsWindow contentView] bounds];
+ NSRect glViewRect = [contentView bounds];
NSOpenGLView* glView = [[NSOpenGLView alloc] initWithFrame:glViewRect pixelFormat:pixelFormat];
[pixelFormat release];
// GLFW creates a helper contentView that handles things like keyboard and drag and
// drop events. We don't want to clobber that view if it exists. Instead we just
// add ourselves as a subview and make the view resize automatically.
- NSView *contentView = [nsWindow contentView];
if (nil != contentView)
{
[glView setAutoresizingMask:( NSViewHeightSizable |
@@ -117,7 +130,8 @@ namespace bgfx { namespace gl
}
else
{
- [nsWindow setContentView:glView];
+ if (nil != nsWindow)
+ [nsWindow setContentView:glView];
}
NSOpenGLContext* glContext = [glView openGLContext];
@@ -177,8 +191,8 @@ namespace bgfx { namespace gl
{
uint64_t caps = 0;
#if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)
- NSWindow* nsWindow = (NSWindow*)g_platformData.nwh;
- if ([nsWindow respondsToSelector:@selector(backingScaleFactor)] && (1.0f < [nsWindow backingScaleFactor]))
+ NSObject* nwh = (NSObject*)g_platformData.nwh;
+ if ([nwh respondsToSelector:@selector(backingScaleFactor)] && (1.0f < [(id)nwh backingScaleFactor]))
caps |= BGFX_CAPS_HIDPI;
#endif // defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)
return caps;
diff --git a/3rdparty/bgfx/src/glcontext_wgl.cpp b/3rdparty/bgfx/src/glcontext_wgl.cpp
index 859203dccdd..704e3eae94e 100644
--- a/3rdparty/bgfx/src/glcontext_wgl.cpp
+++ b/3rdparty/bgfx/src/glcontext_wgl.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -134,7 +134,7 @@ namespace bgfx { namespace gl
//
// An application can only set the pixel format of a window one time.
// Once a window's pixel format is set, it cannot be changed.
- // MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/dd369049%28v=vs.85%29.aspx
+ // MSDN: https://web.archive.org/web/20190207230357/https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-setpixelformat
HWND hwnd = CreateWindowA("STATIC"
, ""
, WS_POPUP|WS_DISABLED
diff --git a/3rdparty/bgfx/src/glcontext_wgl.h b/3rdparty/bgfx/src/glcontext_wgl.h
index 275a114364d..74f579ac7f3 100644
--- a/3rdparty/bgfx/src/glcontext_wgl.h
+++ b/3rdparty/bgfx/src/glcontext_wgl.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/glimports.h b/3rdparty/bgfx/src/glimports.h
index 24e25c055f9..e86679b46b1 100644
--- a/3rdparty/bgfx/src/glimports.h
+++ b/3rdparty/bgfx/src/glimports.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -423,8 +423,6 @@ GL_IMPORT_ARB__(true, PFNGLDEBUGMESSAGECONTROLPROC, glDebugMessag
GL_IMPORT_ARB__(true, PFNGLDEBUGMESSAGEINSERTPROC, glDebugMessageInsert);
GL_IMPORT_ARB__(true, PFNGLDEBUGMESSAGECALLBACKPROC, glDebugMessageCallback);
GL_IMPORT_ARB__(true, PFNGLGETDEBUGMESSAGELOGPROC, glGetDebugMessageLog);
-GL_IMPORT_ARB__(true, PFNGLPUSHDEBUGGROUPPROC, glPushDebugGroup);
-GL_IMPORT_ARB__(true, PFNGLPOPDEBUGGROUPPROC, glPopDebugGroup);
GL_IMPORT_ARB__(true, PFNGLOBJECTLABELPROC, glObjectLabel);
GL_IMPORT_ARB__(true, PFNGLGETOBJECTLABELPROC, glGetObjectLabel);
GL_IMPORT_ARB__(true, PFNGLOBJECTPTRLABELPROC, glObjectPtrLabel);
@@ -468,6 +466,8 @@ GL_IMPORT______(false, PFNGLCLEARDEPTHFPROC, glClearDepthf
# endif // BGFX_CONFIG_RENDERER_OPENGL
GL_IMPORT______(true, PFNGLINSERTEVENTMARKEREXTPROC, glInsertEventMarker);
+GL_IMPORT_ARB__(true, PFNGLPUSHDEBUGGROUPPROC, glPushDebugGroup);
+GL_IMPORT_ARB__(true, PFNGLPOPDEBUGGROUPPROC, glPopDebugGroup);
GL_IMPORT______(true, PFNGLPUSHGROUPMARKEREXTPROC, glPushGroupMarker);
GL_IMPORT______(true, PFNGLPOPGROUPMARKEREXTPROC, glPopGroupMarker);
#else
@@ -512,6 +512,8 @@ GL_IMPORT______(true, PFNGLTEXIMAGE3DMULTISAMPLEPROC, glTexImage3DM
GL_IMPORT_EXT__(true, PFNGLFRAMEBUFFERTEXTURELAYERPROC, glFramebufferTextureLayer);
GL_IMPORT_EXT__(true, PFNGLINSERTEVENTMARKEREXTPROC, glInsertEventMarker);
+GL_IMPORT_ARB__(true, PFNGLPUSHDEBUGGROUPPROC, glPushDebugGroup);
+GL_IMPORT_ARB__(true, PFNGLPOPDEBUGGROUPPROC, glPopDebugGroup);
GL_IMPORT_EXT__(true, PFNGLPUSHGROUPMARKEREXTPROC, glPushGroupMarker);
GL_IMPORT_EXT__(true, PFNGLPOPGROUPMARKEREXTPROC, glPopGroupMarker);
GL_IMPORT_EXT__(true, PFNGLOBJECTLABELPROC, glObjectLabel);
@@ -596,6 +598,8 @@ GL_IMPORT______(true, PFNGLTEXIMAGE3DMULTISAMPLEPROC, glTexImage3DM
GL_IMPORT______(true, PFNGLFRAMEBUFFERTEXTURELAYERPROC, glFramebufferTextureLayer);
GL_IMPORT______(true, PFNGLINSERTEVENTMARKEREXTPROC, glInsertEventMarker);
+GL_IMPORT_ARB__(true, PFNGLPUSHDEBUGGROUPPROC, glPushDebugGroup);
+GL_IMPORT_ARB__(true, PFNGLPOPDEBUGGROUPPROC, glPopDebugGroup);
GL_IMPORT______(true, PFNGLPUSHGROUPMARKEREXTPROC, glPushGroupMarker);
GL_IMPORT______(true, PFNGLPOPGROUPMARKEREXTPROC, glPopGroupMarker);
GL_IMPORT______(true, PFNGLOBJECTLABELPROC, glObjectLabel);
diff --git a/3rdparty/bgfx/src/makefile b/3rdparty/bgfx/src/makefile
index 8dccda6ab3f..18e21ddf0d9 100644
--- a/3rdparty/bgfx/src/makefile
+++ b/3rdparty/bgfx/src/makefile
@@ -1,5 +1,5 @@
#
-# Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+# Copyright 2011-2019 Branimir Karadzic. All rights reserved.
# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
diff --git a/3rdparty/bgfx/src/nvapi.cpp b/3rdparty/bgfx/src/nvapi.cpp
index 3ece9c7fc03..d2e0dd56e6d 100644
--- a/3rdparty/bgfx/src/nvapi.cpp
+++ b/3rdparty/bgfx/src/nvapi.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/nvapi.h b/3rdparty/bgfx/src/nvapi.h
index 8fe5b967d8c..adb11bab44a 100644
--- a/3rdparty/bgfx/src/nvapi.h
+++ b/3rdparty/bgfx/src/nvapi.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/renderer.h b/3rdparty/bgfx/src/renderer.h
index ef45002a7a0..025c6f7e927 100644
--- a/3rdparty/bgfx/src/renderer.h
+++ b/3rdparty/bgfx/src/renderer.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -10,6 +10,23 @@
namespace bgfx
{
+ inline constexpr uint32_t toAbgr8(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a = 0xff)
+ {
+ return 0
+ | (uint32_t(_r)<<24)
+ | (uint32_t(_g)<<16)
+ | (uint32_t(_b)<< 8)
+ | (uint32_t(_a) )
+ ;
+ }
+
+ constexpr uint32_t kColorFrame = toAbgr8(0xff, 0xd7, 0xc9);
+ constexpr uint32_t kColorView = toAbgr8(0xe4, 0xb4, 0x8e);
+ constexpr uint32_t kColorDraw = toAbgr8(0xc6, 0xe5, 0xb9);
+ constexpr uint32_t kColorCompute = toAbgr8(0xa7, 0xdb, 0xd8);
+ constexpr uint32_t kColorMarker = toAbgr8(0xff, 0x00, 0x00);
+ constexpr uint32_t kColorResource = toAbgr8(0xff, 0x40, 0x20);
+
struct BlitState
{
BlitState(const Frame* _frame)
@@ -47,74 +64,36 @@ namespace bgfx
{
}
- ViewState(Frame* _frame, bool _stereo)
+ ViewState(Frame* _frame)
{
- reset(_frame, _stereo);
+ reset(_frame);
}
- void reset(Frame* _frame, bool _stereo)
+ void reset(Frame* _frame)
{
m_alphaRef = 0.0f;
m_invViewCached = UINT16_MAX;
m_invProjCached = UINT16_MAX;
m_invViewProjCached = UINT16_MAX;
- m_view[0] = m_viewTmp[0];
- m_view[1] = m_viewTmp[1];
-
- if (_stereo)
- {
- m_view[0] = m_viewTmp[0];
- Matrix4 viewAdjust;
- bx::mtxIdentity(viewAdjust.un.val);
-
- for (uint32_t eye = 0; eye < 2; ++eye)
- {
-/*
- const HMD::Eye& hmdEye = hmd.eye[eye];
- viewAdjust.un.val[12] = hmdEye.viewOffset[0];
- viewAdjust.un.val[13] = hmdEye.viewOffset[1];
- viewAdjust.un.val[14] = hmdEye.viewOffset[2];
+ m_view = m_viewTmp;
- for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_VIEWS; ++ii)
- {
- if (BGFX_VIEW_STEREO == (_frame->m_view[ii].m_flags & BGFX_VIEW_STEREO) )
- {
- bx::float4x4_mul(&m_view[eye][ii].un.f4x4
- , &_frame->m_view[ii].m_view.un.f4x4
- , &viewAdjust.un.f4x4
- );
- }
- else
- {
- bx::memCopy(&m_view[0][ii].un.f4x4, &_frame->m_view[ii].m_view.un.f4x4, sizeof(Matrix4) );
- }
- }
-*/
- }
- }
- else
+ for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_VIEWS; ++ii)
{
- for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_VIEWS; ++ii)
- {
- bx::memCopy(&m_view[0][ii].un.f4x4, &_frame->m_view[ii].m_view.un.f4x4, sizeof(Matrix4) );
- }
+ bx::memCopy(&m_view[ii].un.f4x4, &_frame->m_view[ii].m_view.un.f4x4, sizeof(Matrix4) );
}
for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_VIEWS; ++ii)
{
- for (uint32_t eye = 0; eye < uint32_t(_stereo)+1; ++eye)
- {
- bx::float4x4_mul(&m_viewProj[eye][ii].un.f4x4
- , &m_view[eye][ii].un.f4x4
- , &_frame->m_view[ii].m_proj[eye].un.f4x4
- );
- }
+ bx::float4x4_mul(&m_viewProj[ii].un.f4x4
+ , &m_view[ii].un.f4x4
+ , &_frame->m_view[ii].m_proj.un.f4x4
+ );
}
}
template<uint16_t mtxRegs, typename RendererContext, typename Program, typename Draw>
- void setPredefined(RendererContext* _renderer, uint16_t _view, uint8_t _eye, const Program& _program, const Frame* _frame, const Draw& _draw)
+ void setPredefined(RendererContext* _renderer, uint16_t _view, const Program& _program, const Frame* _frame, const Draw& _draw)
{
const FrameCache& frameCache = _frame->m_frameCache;
@@ -158,7 +137,7 @@ namespace bgfx
{
_renderer->setShaderUniform4x4f(flags
, predefined.m_loc
- , m_view[_eye][_view].un.val
+ , m_view[_view].un.val
, bx::uint32_min(mtxRegs, predefined.m_count)
);
}
@@ -166,12 +145,11 @@ namespace bgfx
case PredefinedUniform::InvView:
{
- uint16_t viewEye = (_view << 1) | _eye;
- if (viewEye != m_invViewCached)
+ if (_view != m_invViewCached)
{
- m_invViewCached = viewEye;
+ m_invViewCached = _view;
bx::float4x4_inverse(&m_invView.un.f4x4
- , &m_view[_eye][_view].un.f4x4
+ , &m_view[_view].un.f4x4
);
}
@@ -187,7 +165,7 @@ namespace bgfx
{
_renderer->setShaderUniform4x4f(flags
, predefined.m_loc
- , _frame->m_view[_view].m_proj[_eye].un.val
+ , _frame->m_view[_view].m_proj.un.val
, bx::uint32_min(mtxRegs, predefined.m_count)
);
}
@@ -195,12 +173,11 @@ namespace bgfx
case PredefinedUniform::InvProj:
{
- uint16_t viewEye = (_view << 1) | _eye;
- if (viewEye != m_invProjCached)
+ if (_view != m_invProjCached)
{
- m_invProjCached = viewEye;
+ m_invProjCached = _view;
bx::float4x4_inverse(&m_invProj.un.f4x4
- , &_frame->m_view[_view].m_proj[_eye].un.f4x4
+ , &_frame->m_view[_view].m_proj.un.f4x4
);
}
@@ -216,7 +193,7 @@ namespace bgfx
{
_renderer->setShaderUniform4x4f(flags
, predefined.m_loc
- , m_viewProj[_eye][_view].un.val
+ , m_viewProj[_view].un.val
, bx::uint32_min(mtxRegs, predefined.m_count)
);
}
@@ -224,12 +201,11 @@ namespace bgfx
case PredefinedUniform::InvViewProj:
{
- uint16_t viewEye = (_view << 1) | _eye;
- if (viewEye != m_invViewProjCached)
+ if (_view != m_invViewProjCached)
{
- m_invViewProjCached = viewEye;
+ m_invViewProjCached = _view;
bx::float4x4_inverse(&m_invViewProj.un.f4x4
- , &m_viewProj[_eye][_view].un.f4x4
+ , &m_viewProj[_view].un.f4x4
);
}
@@ -258,7 +234,7 @@ namespace bgfx
const Matrix4& model = frameCache.m_matrixCache.m_cache[_draw.m_startMatrix];
bx::float4x4_mul(&modelView.un.f4x4
, &model.un.f4x4
- , &m_view[_eye][_view].un.f4x4
+ , &m_view[_view].un.f4x4
);
_renderer->setShaderUniform4x4f(flags
, predefined.m_loc
@@ -274,7 +250,7 @@ namespace bgfx
const Matrix4& model = frameCache.m_matrixCache.m_cache[_draw.m_startMatrix];
bx::float4x4_mul(&modelViewProj.un.f4x4
, &model.un.f4x4
- , &m_viewProj[_eye][_view].un.f4x4
+ , &m_viewProj[_view].un.f4x4
);
_renderer->setShaderUniform4x4f(flags
, predefined.m_loc
@@ -301,9 +277,9 @@ namespace bgfx
}
}
- Matrix4 m_viewTmp[2][BGFX_CONFIG_MAX_VIEWS];
- Matrix4 m_viewProj[2][BGFX_CONFIG_MAX_VIEWS];
- Matrix4* m_view[2];
+ Matrix4 m_viewTmp[BGFX_CONFIG_MAX_VIEWS];
+ Matrix4 m_viewProj[BGFX_CONFIG_MAX_VIEWS];
+ Matrix4* m_view;
Rect m_rect;
Matrix4 m_invView;
Matrix4 m_invProj;
@@ -481,11 +457,12 @@ namespace bgfx
return true;
}
- for (uint32_t idx = 0, streamMask = _new.m_streamMask, ntz = bx::uint32_cnttz(streamMask)
+ for (uint32_t idx = 0, streamMask = _new.m_streamMask
; 0 != streamMask
- ; streamMask >>= 1, idx += 1, ntz = bx::uint32_cnttz(streamMask)
+ ; streamMask >>= 1, idx += 1
)
{
+ const uint32_t ntz = bx::uint32_cnttz(streamMask);
streamMask >>= ntz;
idx += ntz;
diff --git a/3rdparty/bgfx/src/renderer_d3d.h b/3rdparty/bgfx/src/renderer_d3d.h
index 25983d6dcd6..c94e2f364d3 100644
--- a/3rdparty/bgfx/src/renderer_d3d.h
+++ b/3rdparty/bgfx/src/renderer_d3d.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -64,16 +64,6 @@
namespace bgfx
{
- constexpr uint32_t toRgba8(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a)
- {
- return 0
- | (uint32_t(_r)<<24)
- | (uint32_t(_g)<<16)
- | (uint32_t(_b)<< 8)
- | (uint32_t(_a) )
- ;
- }
-
#if BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT
typedef ::IUnknown IUnknown;
#else
@@ -133,11 +123,11 @@ namespace bgfx
typedef void (WINAPI* PFN_D3DPERF_SET_OPTIONS)(DWORD _options);
typedef DWORD (WINAPI* PFN_D3DPERF_GET_STATUS)();
-#define _PIX_SETMARKER(_col, _name) D3DPERF_SetMarker(_col, _name)
-#define _PIX_BEGINEVENT(_col, _name) D3DPERF_BeginEvent(_col, _name)
-#define _PIX_ENDEVENT() D3DPERF_EndEvent()
+#define _PIX_SETMARKER(_color, _name) D3DPERF_SetMarker(_color, _name)
+#define _PIX_BEGINEVENT(_color, _name) D3DPERF_BeginEvent(_color, _name)
+#define _PIX_ENDEVENT() D3DPERF_EndEvent()
-#if BGFX_CONFIG_DEBUG_PIX
+#if BGFX_CONFIG_DEBUG_ANNOTATION
# define PIX_SETMARKER(_color, _name) _PIX_SETMARKER(_color, _name)
# define PIX_BEGINEVENT(_color, _name) _PIX_BEGINEVENT(_color, _name)
# define PIX_ENDEVENT() _PIX_ENDEVENT()
@@ -145,15 +135,7 @@ namespace bgfx
# define PIX_SETMARKER(_color, _name) BX_UNUSED(_name)
# define PIX_BEGINEVENT(_color, _name) BX_UNUSED(_name)
# define PIX_ENDEVENT()
-#endif // BGFX_CONFIG_DEBUG_PIX
-
-#define D3DCOLOR_FRAME toRgba8(0xff, 0xd7, 0xc9, 0xff)
-#define D3DCOLOR_VIEW toRgba8(0xe4, 0xb4, 0x8e, 0xff)
-#define D3DCOLOR_VIEW_L toRgba8(0xf9, 0xee, 0xe5, 0xff)
-#define D3DCOLOR_VIEW_R toRgba8(0xe8, 0xd3, 0xc0, 0xff)
-#define D3DCOLOR_DRAW toRgba8(0xc6, 0xe5, 0xb9, 0xff)
-#define D3DCOLOR_COMPUTE toRgba8(0xa7, 0xdb, 0xd8, 0xff)
-#define D3DCOLOR_MARKER toRgba8(0xff, 0x00, 0x00, 0xff)
+#endif // BGFX_CONFIG_DEBUG_ANNOTATION
inline bool isType(IUnknown* _interface, const GUID& _id)
{
diff --git a/3rdparty/bgfx/src/renderer_d3d11.cpp b/3rdparty/bgfx/src/renderer_d3d11.cpp
index 7fc4e8777e4..bf1f13622b9 100644
--- a/3rdparty/bgfx/src/renderer_d3d11.cpp
+++ b/3rdparty/bgfx/src/renderer_d3d11.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -11,7 +11,22 @@
namespace bgfx { namespace d3d11
{
static wchar_t s_viewNameW[BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME];
- static char s_viewName[BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME];
+ static char s_viewName [BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME];
+
+ inline void setViewType(ViewId _view, const bx::StringView _str)
+ {
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION | BGFX_CONFIG_PROFILER) )
+ {
+ const uint32_t len = _str.getLength();
+
+ bx::memCopy(&s_viewName[_view][3], _str.getPtr(), len);
+
+ wchar_t tmpW[16];
+ mbstowcs(tmpW, _str.getPtr(), len);
+
+ bx::memCopy(&s_viewNameW[_view][3], tmpW, len*2);
+ }
+ }
struct PrimInfo
{
@@ -333,19 +348,19 @@ namespace bgfx { namespace d3d11
};
BX_STATIC_ASSERT(AttribType::Count == BX_COUNTOF(s_attribType) );
- static D3D11_INPUT_ELEMENT_DESC* fillVertexDecl(uint8_t _stream, D3D11_INPUT_ELEMENT_DESC* _out, const VertexDecl& _decl)
+ static D3D11_INPUT_ELEMENT_DESC* fillVertexLayout(uint8_t _stream, D3D11_INPUT_ELEMENT_DESC* _out, const VertexLayout& _layout)
{
D3D11_INPUT_ELEMENT_DESC* elem = _out;
for (uint32_t attr = 0; attr < Attrib::Count; ++attr)
{
- if (UINT16_MAX != _decl.m_attributes[attr])
+ if (UINT16_MAX != _layout.m_attributes[attr])
{
bx::memCopy(elem, &s_attrib[attr], sizeof(D3D11_INPUT_ELEMENT_DESC) );
elem->InputSlot = _stream;
- if (0 == _decl.m_attributes[attr])
+ if (0 == _layout.m_attributes[attr])
{
elem->AlignedByteOffset = 0;
}
@@ -355,9 +370,9 @@ namespace bgfx { namespace d3d11
AttribType::Enum type;
bool normalized;
bool asInt;
- _decl.decode(Attrib::Enum(attr), num, type, normalized, asInt);
+ _layout.decode(Attrib::Enum(attr), num, type, normalized, asInt);
elem->Format = s_attribType[type][num-1][normalized];
- elem->AlignedByteOffset = _decl.m_offset[attr];
+ elem->AlignedByteOffset = _layout.m_offset[attr];
}
++elem;
@@ -376,12 +391,14 @@ namespace bgfx { namespace d3d11
void clear()
{
- bx::memSet(m_srv, 0, sizeof(m_srv) );
+ bx::memSet(m_uav, 0, sizeof(m_uav) );
+ bx::memSet(m_srv, 0, sizeof(m_srv) );
bx::memSet(m_sampler, 0, sizeof(m_sampler) );
}
- ID3D11ShaderResourceView* m_srv[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
- ID3D11SamplerState* m_sampler[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
+ ID3D11UnorderedAccessView* m_uav[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
+ ID3D11ShaderResourceView* m_srv[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
+ ID3D11SamplerState* m_sampler[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
};
BX_PRAGMA_DIAGNOSTIC_PUSH();
@@ -798,21 +815,30 @@ namespace bgfx { namespace d3d11
m_d3d9Dll = NULL;
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
{
// D3D11_1.h has ID3DUserDefinedAnnotation
- // http://msdn.microsoft.com/en-us/library/windows/desktop/hh446881%28v=vs.85%29.aspx
+ // https://web.archive.org/web/20190207230424/https://docs.microsoft.com/en-us/windows/desktop/api/d3d11_1/nn-d3d11_1-id3duserdefinedannotation
m_d3d9Dll = bx::dlopen("d3d9.dll");
if (NULL != m_d3d9Dll)
{
D3DPERF_SetMarker = (PFN_D3DPERF_SET_MARKER )bx::dlsym(m_d3d9Dll, "D3DPERF_SetMarker" );
D3DPERF_BeginEvent = (PFN_D3DPERF_BEGIN_EVENT)bx::dlsym(m_d3d9Dll, "D3DPERF_BeginEvent");
D3DPERF_EndEvent = (PFN_D3DPERF_END_EVENT )bx::dlsym(m_d3d9Dll, "D3DPERF_EndEvent" );
- BX_CHECK(NULL != D3DPERF_SetMarker
- && NULL != D3DPERF_BeginEvent
- && NULL != D3DPERF_EndEvent
- , "Failed to initialize PIX events."
- );
+
+ if (NULL == D3DPERF_SetMarker
+ || NULL == D3DPERF_BeginEvent
+ || NULL == D3DPERF_EndEvent)
+ {
+ BX_TRACE("Failed to initialize PIX events.");
+
+ D3DPERF_SetMarker = NULL;
+ D3DPERF_BeginEvent = NULL;
+ D3DPERF_EndEvent = NULL;
+
+ bx::dlclose(m_d3d9Dll);
+ m_d3d9Dll = NULL;
+ }
}
}
@@ -980,7 +1006,10 @@ namespace bgfx { namespace d3d11
bx::memSet(&m_scd, 0, sizeof(m_scd) );
m_scd.width = _init.resolution.width;
m_scd.height = _init.resolution.height;
- m_scd.format = s_textureFormat[_init.resolution.format].m_fmt;
+ m_scd.format = (_init.resolution.reset & BGFX_RESET_SRGB_BACKBUFFER)
+ ? s_textureFormat[_init.resolution.format].m_fmtSrgb
+ : s_textureFormat[_init.resolution.format].m_fmt
+ ;
updateMsaa(m_scd.format);
m_scd.sampleDesc = s_msaa[(_init.resolution.reset&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT];
@@ -1081,7 +1110,7 @@ namespace bgfx { namespace d3d11
m_numWindows = 1;
#if USE_D3D11_DYNAMIC_LIB
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
{
HRESULT hr = m_deviceCtx->QueryInterface(IID_ID3DUserDefinedAnnotation, (void**)&m_annotation);
@@ -1154,6 +1183,9 @@ namespace bgfx { namespace d3d11
: 0)
| BGFX_CAPS_TEXTURE_2D_ARRAY
| BGFX_CAPS_TEXTURE_CUBE_ARRAY
+ | ((m_featureLevel >= D3D_FEATURE_LEVEL_11_1)
+ ? BGFX_CAPS_FRAMEBUFFER_RW
+ : 0)
);
m_timerQuerySupport = m_featureLevel >= D3D_FEATURE_LEVEL_10_0;
@@ -1656,20 +1688,20 @@ namespace bgfx { namespace d3d11
m_indexBuffers[_handle.idx].destroy();
}
- void createVertexDecl(VertexDeclHandle _handle, const VertexDecl& _decl) override
+ void createVertexLayout(VertexLayoutHandle _handle, const VertexLayout& _layout) override
{
- VertexDecl& decl = m_vertexDecls[_handle.idx];
- bx::memCopy(&decl, &_decl, sizeof(VertexDecl) );
- dump(decl);
+ VertexLayout& layout = m_vertexLayouts[_handle.idx];
+ bx::memCopy(&layout, &_layout, sizeof(VertexLayout) );
+ dump(layout);
}
- void destroyVertexDecl(VertexDeclHandle /*_handle*/) override
+ void destroyVertexLayout(VertexLayoutHandle /*_handle*/) override
{
}
- void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexDeclHandle _declHandle, uint16_t _flags) override
+ void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexLayoutHandle _layoutHandle, uint16_t _flags) override
{
- m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _declHandle, _flags);
+ m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _layoutHandle, _flags);
}
void destroyVertexBuffer(VertexBufferHandle _handle) override
@@ -1694,8 +1726,8 @@ namespace bgfx { namespace d3d11
void createDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size, uint16_t _flags) override
{
- VertexDeclHandle decl = BGFX_INVALID_HANDLE;
- m_vertexBuffers[_handle.idx].create(_size, NULL, decl, _flags);
+ VertexLayoutHandle layoutHandle = BGFX_INVALID_HANDLE;
+ m_vertexBuffers[_handle.idx].create(_size, NULL, layoutHandle, _flags);
}
void updateDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _offset, uint32_t _size, const Memory* _mem) override
@@ -1962,7 +1994,7 @@ namespace bgfx { namespace d3d11
void updateViewName(ViewId _id, const char* _name) override
{
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
{
mbstowcs(&s_viewNameW[_id][BGFX_CONFIG_MAX_VIEW_NAME_RESERVED]
, _name
@@ -1981,32 +2013,41 @@ namespace bgfx { namespace d3d11
bx::memCopy(m_uniforms[_loc], _data, _size);
}
- void setMarker(const char* _marker, uint32_t _size) override
+ void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override
{
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
- {
- uint32_t size = _size*sizeof(wchar_t);
- wchar_t* name = (wchar_t*)alloca(size);
- mbstowcs(name, _marker, size-2);
- PIX_SETMARKER(D3DCOLOR_MARKER, name);
- }
+ m_occlusionQuery.invalidate(_handle);
}
- void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override
+ void setMarker(const char* _marker, uint16_t _len) override
{
- m_occlusionQuery.invalidate(_handle);
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
+ {
+ uint32_t size = _len*sizeof(wchar_t);
+ wchar_t* name = (wchar_t*)alloca(size+2);
+ name[_len] = L'\0';
+ mbstowcs(name, _marker, _len);
+ PIX_SETMARKER(kColorMarker, name);
+ }
}
- virtual void setName(Handle _handle, const char* _name) override
+ virtual void setName(Handle _handle, const char* _name, uint16_t _len) override
{
switch (_handle.type)
{
+ case Handle::IndexBuffer:
+ setDebugObjectName(m_indexBuffers[_handle.idx].m_ptr, "%.*s", _len, _name);
+ break;
+
case Handle::Shader:
- setDebugObjectName(m_shaders[_handle.idx].m_ptr, "%s", _name);
+ setDebugObjectName(m_shaders[_handle.idx].m_ptr, "%.*s", _len, _name);
break;
case Handle::Texture:
- setDebugObjectName(m_textures[_handle.idx].m_ptr, "%s", _name);
+ setDebugObjectName(m_textures[_handle.idx].m_ptr, "%.*s", _len, _name);
+ break;
+
+ case Handle::VertexBuffer:
+ setDebugObjectName(m_vertexBuffers[_handle.idx].m_ptr, "%.*s", _len, _name);
break;
default:
@@ -2054,11 +2095,11 @@ namespace bgfx { namespace d3d11
deviceCtx->PSSetConstantBuffers(0, 1, &program.m_fsh->m_buffer);
VertexBufferD3D11& vb = m_vertexBuffers[_blitter.m_vb->handle.idx];
- VertexDecl& vertexDecl = m_vertexDecls[_blitter.m_vb->decl.idx];
- uint32_t stride = vertexDecl.m_stride;
+ VertexLayout& layout = m_vertexLayouts[_blitter.m_vb->layoutHandle.idx];
+ uint32_t stride = layout.m_stride;
uint32_t offset = 0;
deviceCtx->IASetVertexBuffers(0, 1, &vb.m_ptr, &stride, &offset);
- setInputLayout(vertexDecl, program, 0);
+ setInputLayout(layout, program, 0);
IndexBufferD3D11& ib = m_indexBuffers[_blitter.m_ib->handle.idx];
deviceCtx->IASetIndexBuffer(ib.m_ptr, DXGI_FORMAT_R16_UINT, 0);
@@ -2083,7 +2124,7 @@ namespace bgfx { namespace d3d11
ID3D11DeviceContext* deviceCtx = m_deviceCtx;
m_indexBuffers [_blitter.m_ib->handle.idx].update(0, _numIndices*2, _blitter.m_ib->data, true);
- m_vertexBuffers[_blitter.m_vb->handle.idx].update(0, numVertices*_blitter.m_decl.m_stride, _blitter.m_vb->data, true);
+ m_vertexBuffers[_blitter.m_vb->handle.idx].update(0, numVertices*_blitter.m_layout.m_stride, _blitter.m_vb->data, true);
deviceCtx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
deviceCtx->DrawIndexed(_numIndices, 0, 0);
@@ -2470,7 +2511,15 @@ namespace bgfx { namespace d3d11
m_currentColor = m_backBufferColor;
m_currentDepthStencil = m_backBufferDepthStencil;
- m_deviceCtx->OMSetRenderTargets(1, &m_currentColor, m_currentDepthStencil);
+ m_deviceCtx->OMSetRenderTargetsAndUnorderedAccessViews(
+ 1
+ , &m_currentColor
+ , m_currentDepthStencil
+ , 1
+ , 0
+ , NULL
+ , NULL
+ );
m_needPresent |= _needPresent;
}
else
@@ -2529,19 +2578,19 @@ namespace bgfx { namespace d3d11
}
}
- void setInputLayout(uint8_t _numStreams, const VertexDecl** _vertexDecls, const ProgramD3D11& _program, uint16_t _numInstanceData)
+ void setInputLayout(uint8_t _numStreams, const VertexLayout** _layouts, const ProgramD3D11& _program, uint16_t _numInstanceData)
{
bx::HashMurmur2A murmur;
murmur.begin();
murmur.add(_numInstanceData);
for (uint8_t stream = 0; stream < _numStreams; ++stream)
{
- murmur.add(_vertexDecls[stream]->m_hash);
+ murmur.add(_layouts[stream]->m_hash);
}
uint64_t layoutHash = (uint64_t(_program.m_vsh->m_hash)<<32) | murmur.end();
- ID3D11InputLayout* layout = m_inputLayoutCache.find(layoutHash);
- if (NULL == layout)
+ ID3D11InputLayout* inputLayout = m_inputLayoutCache.find(layoutHash);
+ if (NULL == inputLayout)
{
D3D11_INPUT_ELEMENT_DESC vertexElements[Attrib::Count+1+BGFX_CONFIG_MAX_INSTANCE_DATA_COUNT];
D3D11_INPUT_ELEMENT_DESC* elem = vertexElements;
@@ -2551,19 +2600,19 @@ namespace bgfx { namespace d3d11
for (uint8_t stream = 0; stream < _numStreams; ++stream)
{
- VertexDecl decl;
- bx::memCopy(&decl, _vertexDecls[stream], sizeof(VertexDecl) );
+ VertexLayout layout;
+ bx::memCopy(&layout, _layouts[stream], sizeof(VertexLayout) );
const bool last = stream == _numStreams-1;
for (uint32_t ii = 0; ii < Attrib::Count; ++ii)
{
uint16_t mask = attrMask[ii];
- uint16_t attr = (decl.m_attributes[ii] & mask);
+ uint16_t attr = (layout.m_attributes[ii] & mask);
if (0 == attr
|| UINT16_MAX == attr)
{
- decl.m_attributes[ii] = last ? ~attr : UINT16_MAX;
+ layout.m_attributes[ii] = last ? ~attr : UINT16_MAX;
}
else
{
@@ -2571,7 +2620,7 @@ namespace bgfx { namespace d3d11
}
}
- elem = fillVertexDecl(stream, elem, decl);
+ elem = fillVertexLayout(stream, elem, layout);
}
uint32_t num = uint32_t(elem-vertexElements);
@@ -2611,18 +2660,18 @@ namespace bgfx { namespace d3d11
, num
, _program.m_vsh->m_code->data
, _program.m_vsh->m_code->size
- , &layout
+ , &inputLayout
) );
- m_inputLayoutCache.add(layoutHash, layout);
+ m_inputLayoutCache.add(layoutHash, inputLayout);
}
- m_deviceCtx->IASetInputLayout(layout);
+ m_deviceCtx->IASetInputLayout(inputLayout);
}
- void setInputLayout(const VertexDecl& _vertexDecl, const ProgramD3D11& _program, uint16_t _numInstanceData)
+ void setInputLayout(const VertexLayout& _layout, const ProgramD3D11& _program, uint16_t _numInstanceData)
{
- const VertexDecl* decls[1] = { &_vertexDecl };
- setInputLayout(BX_COUNTOF(decls), decls, _program, _numInstanceData);
+ const VertexLayout* layouts[1] = { &_layout };
+ setInputLayout(BX_COUNTOF(layouts), layouts, _program, _numInstanceData);
}
void setBlendState(uint64_t _state, uint32_t _rgba = 0)
@@ -3036,16 +3085,16 @@ namespace bgfx { namespace d3d11
switch (texture.m_type)
{
case TextureD3D11::Texture2D:
- if (1 < texture.m_depth)
+ if (1 < texture.m_numLayers)
{
desc.ViewDimension = msaaSample
? D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY
: D3D11_SRV_DIMENSION_TEXTURE2DARRAY
;
desc.Texture2DArray.MostDetailedMip = _mip;
- desc.Texture2DArray.MipLevels = 1;
+ desc.Texture2DArray.MipLevels = 1;
desc.Texture2DArray.FirstArraySlice = 0;
- desc.Texture2DArray.ArraySize = texture.m_depth;
+ desc.Texture2DArray.ArraySize = texture.m_numLayers;
}
else
{
@@ -3054,7 +3103,7 @@ namespace bgfx { namespace d3d11
: D3D11_SRV_DIMENSION_TEXTURE2D
;
desc.Texture2D.MostDetailedMip = _mip;
- desc.Texture2D.MipLevels = 1;
+ desc.Texture2D.MipLevels = 1;
}
break;
@@ -3242,9 +3291,9 @@ namespace bgfx { namespace d3d11
}
break;
- CASE_IMPLEMENT_UNIFORM(Int1, I, int);
- CASE_IMPLEMENT_UNIFORM(Vec4, F, float);
- CASE_IMPLEMENT_UNIFORM(Mat4, F, float);
+ CASE_IMPLEMENT_UNIFORM(Sampler, I, int);
+ CASE_IMPLEMENT_UNIFORM(Vec4, F, float);
+ CASE_IMPLEMENT_UNIFORM(Mat4, F, float);
case UniformType::End:
break;
@@ -3314,24 +3363,27 @@ namespace bgfx { namespace d3d11
ProgramD3D11& program = m_program[_clearQuad.m_program[numMrt-1].idx];
m_currentProgram = &program;
- deviceCtx->VSSetShader(program.m_vsh->m_vertexShader, NULL, 0);
- deviceCtx->VSSetConstantBuffers(0, 1, s_zero.m_buffer);
+
+ const ShaderD3D11* vsh = program.m_vsh;
+ deviceCtx->VSSetShader(vsh->m_vertexShader, NULL, 0);
+ deviceCtx->VSSetConstantBuffers(0, 1, &vsh->m_buffer);
+ float mrtClearDepth[4] = { _clear.m_depth };
+ deviceCtx->UpdateSubresource(vsh->m_buffer, 0, 0, mrtClearDepth, 0, 0);
+
if (NULL != m_currentColor)
{
const ShaderD3D11* fsh = program.m_fsh;
deviceCtx->PSSetShader(fsh->m_pixelShader, NULL, 0);
deviceCtx->PSSetConstantBuffers(0, 1, &fsh->m_buffer);
+ float mrtClearColor[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS][4];
if (BGFX_CLEAR_COLOR_USE_PALETTE & _clear.m_flags)
{
- float mrtClear[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS][4];
for (uint32_t ii = 0; ii < numMrt; ++ii)
{
uint8_t index = (uint8_t)bx::uint32_min(BGFX_CONFIG_MAX_COLOR_PALETTE-1, _clear.m_index[ii]);
- bx::memCopy(mrtClear[ii], _palette[index], 16);
+ bx::memCopy(mrtClearColor[ii], _palette[index], 16);
}
-
- deviceCtx->UpdateSubresource(fsh->m_buffer, 0, 0, mrtClear, 0, 0);
}
else
{
@@ -3343,52 +3395,27 @@ namespace bgfx { namespace d3d11
_clear.m_index[3]*1.0f/255.0f,
};
- deviceCtx->UpdateSubresource(fsh->m_buffer, 0, 0, rgba, 0, 0);
+ for (uint32_t ii = 0; ii < numMrt; ++ii)
+ {
+ bx::memCopy(mrtClearColor[ii], rgba, 16);
+ }
}
+
+ deviceCtx->UpdateSubresource(fsh->m_buffer, 0, 0, mrtClearColor, 0, 0);
}
else
{
deviceCtx->PSSetShader(NULL, NULL, 0);
}
- VertexBufferD3D11& vb = m_vertexBuffers[_clearQuad.m_vb->handle.idx];
- const VertexDecl& vertexDecl = m_vertexDecls[_clearQuad.m_vb->decl.idx];
- const uint32_t stride = vertexDecl.m_stride;
- const uint32_t offset = 0;
-
- {
- struct Vertex
- {
- float m_x;
- float m_y;
- float m_z;
- };
+ VertexBufferD3D11& vb = m_vertexBuffers[_clearQuad.m_vb.idx];
+ const VertexLayout& layout = _clearQuad.m_layout;
- Vertex* vertex = (Vertex*)_clearQuad.m_vb->data;
- BX_CHECK(stride == sizeof(Vertex), "Stride/Vertex mismatch (stride %d, sizeof(Vertex) %d)", stride, sizeof(Vertex) );
-
- const float depth = _clear.m_depth;
-
- vertex->m_x = -1.0f;
- vertex->m_y = -1.0f;
- vertex->m_z = depth;
- vertex++;
- vertex->m_x = 1.0f;
- vertex->m_y = -1.0f;
- vertex->m_z = depth;
- vertex++;
- vertex->m_x = -1.0f;
- vertex->m_y = 1.0f;
- vertex->m_z = depth;
- vertex++;
- vertex->m_x = 1.0f;
- vertex->m_y = 1.0f;
- vertex->m_z = depth;
- }
+ const uint32_t stride = layout.m_stride;
+ const uint32_t offset = 0;
- m_vertexBuffers[_clearQuad.m_vb->handle.idx].update(0, 4*_clearQuad.m_decl.m_stride, _clearQuad.m_vb->data);
deviceCtx->IASetVertexBuffers(0, 1, &vb.m_ptr, &stride, &offset);
- setInputLayout(vertexDecl, program, 0);
+ setInputLayout(layout, program, 0);
deviceCtx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
deviceCtx->Draw(4, 0);
@@ -3446,7 +3473,7 @@ namespace bgfx { namespace d3d11
ShaderD3D11 m_shaders[BGFX_CONFIG_MAX_SHADERS];
ProgramD3D11 m_program[BGFX_CONFIG_MAX_PROGRAMS];
TextureD3D11 m_textures[BGFX_CONFIG_MAX_TEXTURES];
- VertexDecl m_vertexDecls[BGFX_CONFIG_MAX_VERTEX_DECLS];
+ VertexLayout m_vertexLayouts[BGFX_CONFIG_MAX_VERTEX_LAYOUTS];
FrameBufferD3D11 m_frameBuffers[BGFX_CONFIG_MAX_FRAME_BUFFERS];
void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS];
Matrix4 m_predefinedUniforms[PredefinedUniform::Count];
@@ -3562,15 +3589,15 @@ namespace bgfx { namespace d3d11
static const UavFormat s_uavFormat[] =
{ // BGFX_BUFFER_COMPUTE_TYPE_INT, BGFX_BUFFER_COMPUTE_TYPE_UINT, BGFX_BUFFER_COMPUTE_TYPE_FLOAT
{ { DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, 0 }, // ignored
- { { DXGI_FORMAT_R8_SINT, DXGI_FORMAT_R8_UINT, DXGI_FORMAT_UNKNOWN }, 1 }, // BGFX_BUFFER_COMPUTE_FORMAT_8x1
- { { DXGI_FORMAT_R8G8_SINT, DXGI_FORMAT_R8G8_UINT, DXGI_FORMAT_UNKNOWN }, 2 }, // BGFX_BUFFER_COMPUTE_FORMAT_8x2
- { { DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_UNKNOWN }, 4 }, // BGFX_BUFFER_COMPUTE_FORMAT_8x4
- { { DXGI_FORMAT_R16_SINT, DXGI_FORMAT_R16_UINT, DXGI_FORMAT_R16_FLOAT }, 2 }, // BGFX_BUFFER_COMPUTE_FORMAT_16x1
- { { DXGI_FORMAT_R16G16_SINT, DXGI_FORMAT_R16G16_UINT, DXGI_FORMAT_R16G16_FLOAT }, 4 }, // BGFX_BUFFER_COMPUTE_FORMAT_16x2
- { { DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_R16G16B16A16_FLOAT }, 8 }, // BGFX_BUFFER_COMPUTE_FORMAT_16x4
- { { DXGI_FORMAT_R32_SINT, DXGI_FORMAT_R32_UINT, DXGI_FORMAT_R32_FLOAT }, 4 }, // BGFX_BUFFER_COMPUTE_FORMAT_32x1
- { { DXGI_FORMAT_R32G32_SINT, DXGI_FORMAT_R32G32_UINT, DXGI_FORMAT_R32G32_FLOAT }, 8 }, // BGFX_BUFFER_COMPUTE_FORMAT_32x2
- { { DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_R32G32B32A32_FLOAT }, 16 }, // BGFX_BUFFER_COMPUTE_FORMAT_32x4
+ { { DXGI_FORMAT_R8_SINT, DXGI_FORMAT_R8_UINT, DXGI_FORMAT_UNKNOWN }, 1 }, // BGFX_BUFFER_COMPUTE_FORMAT_8X1
+ { { DXGI_FORMAT_R8G8_SINT, DXGI_FORMAT_R8G8_UINT, DXGI_FORMAT_UNKNOWN }, 2 }, // BGFX_BUFFER_COMPUTE_FORMAT_8X2
+ { { DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_UNKNOWN }, 4 }, // BGFX_BUFFER_COMPUTE_FORMAT_8X4
+ { { DXGI_FORMAT_R16_SINT, DXGI_FORMAT_R16_UINT, DXGI_FORMAT_R16_FLOAT }, 2 }, // BGFX_BUFFER_COMPUTE_FORMAT_16X1
+ { { DXGI_FORMAT_R16G16_SINT, DXGI_FORMAT_R16G16_UINT, DXGI_FORMAT_R16G16_FLOAT }, 4 }, // BGFX_BUFFER_COMPUTE_FORMAT_16X2
+ { { DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_R16G16B16A16_FLOAT }, 8 }, // BGFX_BUFFER_COMPUTE_FORMAT_16X4
+ { { DXGI_FORMAT_R32_SINT, DXGI_FORMAT_R32_UINT, DXGI_FORMAT_R32_FLOAT }, 4 }, // BGFX_BUFFER_COMPUTE_FORMAT_32X1
+ { { DXGI_FORMAT_R32G32_SINT, DXGI_FORMAT_R32G32_UINT, DXGI_FORMAT_R32G32_FLOAT }, 8 }, // BGFX_BUFFER_COMPUTE_FORMAT_32X2
+ { { DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_R32G32B32A32_FLOAT }, 16 }, // BGFX_BUFFER_COMPUTE_FORMAT_32X4
};
void BufferD3D11::create(uint32_t _size, void* _data, uint16_t _flags, uint16_t _stride, bool _vertex)
@@ -3800,11 +3827,11 @@ namespace bgfx { namespace d3d11
#endif // 0
}
- void VertexBufferD3D11::create(uint32_t _size, void* _data, VertexDeclHandle _declHandle, uint16_t _flags)
+ void VertexBufferD3D11::create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle, uint16_t _flags)
{
- m_decl = _declHandle;
- uint16_t stride = isValid(_declHandle)
- ? s_renderD3D11->m_vertexDecls[_declHandle.idx].m_stride
+ m_layoutHandle = _layoutHandle;
+ uint16_t stride = isValid(_layoutHandle)
+ ? s_renderD3D11->m_vertexLayouts[_layoutHandle.idx].m_stride
: 0
;
@@ -4086,21 +4113,28 @@ namespace bgfx { namespace d3d11
if (bimg::imageParse(imageContainer, _mem->data, _mem->size) )
{
- uint8_t numMips = imageContainer.m_numMips;
- const uint8_t startLod = uint8_t(bx::uint32_min(_skip, numMips-1) );
- numMips -= startLod;
const bimg::ImageBlockInfo& blockInfo = bimg::getBlockInfo(bimg::TextureFormat::Enum(imageContainer.m_format) );
- const uint32_t textureWidth = bx::uint32_max(blockInfo.blockWidth, imageContainer.m_width >>startLod);
- const uint32_t textureHeight = bx::uint32_max(blockInfo.blockHeight, imageContainer.m_height>>startLod);
- const uint16_t numLayers = imageContainer.m_numLayers;
-
- m_flags = _flags;
- m_width = textureWidth;
- m_height = textureHeight;
- m_depth = 1 < imageContainer.m_depth
- ? imageContainer.m_depth
- : imageContainer.m_numLayers
- ;
+ const uint8_t startLod = bx::min<uint8_t>(_skip, imageContainer.m_numMips-1);
+
+ bimg::TextureInfo ti;
+ bimg::imageGetSize(
+ &ti
+ , uint16_t(imageContainer.m_width >>startLod)
+ , uint16_t(imageContainer.m_height>>startLod)
+ , uint16_t(imageContainer.m_depth >>startLod)
+ , imageContainer.m_cubeMap
+ , 1 < imageContainer.m_numMips
+ , imageContainer.m_numLayers
+ , imageContainer.m_format
+ );
+ ti.numMips = bx::min<uint8_t>(imageContainer.m_numMips-startLod, ti.numMips);
+
+ m_flags = _flags;
+ m_width = ti.width;
+ m_height = ti.height;
+ m_depth = ti.depth;
+ m_numLayers = ti.numLayers;
+
m_requestedFormat = uint8_t(imageContainer.m_format);
m_textureFormat = uint8_t(getViableTextureFormat(imageContainer) );
const bool convert = m_textureFormat != m_requestedFormat;
@@ -4119,10 +4153,10 @@ namespace bgfx { namespace d3d11
m_type = Texture2D;
}
- m_numMips = numMips;
+ m_numMips = ti.numMips;
- const uint16_t numSides = numLayers * (imageContainer.m_cubeMap ? 6 : 1);
- const uint32_t numSrd = numSides * numMips;
+ const uint16_t numSides = ti.numLayers * (imageContainer.m_cubeMap ? 6 : 1);
+ const uint32_t numSrd = numSides * ti.numMips;
D3D11_SUBRESOURCE_DATA* srd = (D3D11_SUBRESOURCE_DATA*)alloca(numSrd*sizeof(D3D11_SUBRESOURCE_DATA) );
uint32_t kk = 0;
@@ -4134,9 +4168,9 @@ namespace bgfx { namespace d3d11
, getHandle()
, getName( (TextureFormat::Enum)m_textureFormat)
, getName( (TextureFormat::Enum)m_requestedFormat)
- , numLayers
- , textureWidth
- , textureHeight
+ , ti.numLayers
+ , ti.width
+ , ti.height
, imageContainer.m_cubeMap ? "x6" : ""
, 0 != (m_flags&BGFX_TEXTURE_RT_MASK) ? " (render target)" : ""
, swizzle ? " (swizzle BGRA8 -> RGBA8)" : ""
@@ -4144,7 +4178,7 @@ namespace bgfx { namespace d3d11
for (uint16_t side = 0; side < numSides; ++side)
{
- for (uint8_t lod = 0, num = numMips; lod < num; ++lod)
+ for (uint8_t lod = 0, num = ti.numMips; lod < num; ++lod)
{
bimg::ImageMip mip;
if (bimg::imageGetRawData(imageContainer, side, lod+startLod, _mem->data, _mem->size, mip) )
@@ -4154,7 +4188,7 @@ namespace bgfx { namespace d3d11
if (convert)
{
uint32_t srcpitch = mip.m_width*bpp/8;
- uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, mip.m_width*mip.m_height*bpp/8);
+ uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, srcpitch*mip.m_height);
bimg::imageDecodeToBgra8(g_allocator, temp, mip.m_data, mip.m_width, mip.m_height, srcpitch, mip.m_format);
srd[kk].pSysMem = temp;
@@ -4231,9 +4265,9 @@ namespace bgfx { namespace d3d11
case TextureCube:
{
D3D11_TEXTURE2D_DESC desc = {};
- desc.Width = textureWidth;
- desc.Height = textureHeight;
- desc.MipLevels = numMips;
+ desc.Width = ti.width;
+ desc.Height = ti.height;
+ desc.MipLevels = ti.numMips;
desc.ArraySize = numSides;
desc.Format = format;
desc.SampleDesc = msaa;
@@ -4252,7 +4286,7 @@ namespace bgfx { namespace d3d11
desc.BindFlags |= D3D11_BIND_RENDER_TARGET;
desc.Usage = D3D11_USAGE_DEFAULT;
desc.MiscFlags |= 0
- | (1 < numMips ? D3D11_RESOURCE_MISC_GENERATE_MIPS : 0)
+ | (1 < ti.numMips ? D3D11_RESOURCE_MISC_GENERATE_MIPS : 0)
;
}
@@ -4272,26 +4306,26 @@ namespace bgfx { namespace d3d11
if (imageContainer.m_cubeMap)
{
desc.MiscFlags |= D3D11_RESOURCE_MISC_TEXTURECUBE;
- if (1 < numLayers)
+ if (1 < ti.numLayers)
{
srvd.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBEARRAY;
- srvd.TextureCubeArray.MipLevels = numMips;
- srvd.TextureCubeArray.NumCubes = numLayers;
+ srvd.TextureCubeArray.MipLevels = ti.numMips;
+ srvd.TextureCubeArray.NumCubes = ti.numLayers;
}
else
{
srvd.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
- srvd.TextureCube.MipLevels = numMips;
+ srvd.TextureCube.MipLevels = ti.numMips;
}
}
else
{
if (msaaSample)
{
- if (1 < numLayers)
+ if (1 < ti.numLayers)
{
srvd.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY;
- srvd.Texture2DMSArray.ArraySize = numLayers;
+ srvd.Texture2DMSArray.ArraySize = ti.numLayers;
}
else
{
@@ -4300,16 +4334,16 @@ namespace bgfx { namespace d3d11
}
else
{
- if (1 < numLayers)
+ if (1 < ti.numLayers)
{
srvd.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
- srvd.Texture2DArray.MipLevels = numMips;
- srvd.Texture2DArray.ArraySize = numLayers;
+ srvd.Texture2DArray.MipLevels = ti.numMips;
+ srvd.Texture2DArray.ArraySize = ti.numLayers;
}
else
{
srvd.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
- srvd.Texture2D.MipLevels = numMips;
+ srvd.Texture2D.MipLevels = ti.numMips;
}
}
}
@@ -4335,10 +4369,10 @@ namespace bgfx { namespace d3d11
case Texture3D:
{
D3D11_TEXTURE3D_DESC desc = {};
- desc.Width = textureWidth;
- desc.Height = textureHeight;
- desc.Depth = imageContainer.m_depth;
- desc.MipLevels = imageContainer.m_numMips;
+ desc.Width = ti.width;
+ desc.Height = ti.height;
+ desc.Depth = ti.depth;
+ desc.MipLevels = ti.numMips;
desc.Format = format;
desc.Usage = kk == 0 || blit ? D3D11_USAGE_DEFAULT : D3D11_USAGE_IMMUTABLE;
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
@@ -4350,7 +4384,7 @@ namespace bgfx { namespace d3d11
desc.BindFlags |= D3D11_BIND_RENDER_TARGET;
desc.Usage = D3D11_USAGE_DEFAULT;
desc.MiscFlags |= 0
- | (1 < numMips ? D3D11_RESOURCE_MISC_GENERATE_MIPS : 0)
+ | (1 < ti.numMips ? D3D11_RESOURCE_MISC_GENERATE_MIPS : 0)
;
}
@@ -4368,7 +4402,7 @@ namespace bgfx { namespace d3d11
}
srvd.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D;
- srvd.Texture3D.MipLevels = numMips;
+ srvd.Texture3D.MipLevels = ti.numMips;
if (directAccess)
{
@@ -4398,7 +4432,7 @@ namespace bgfx { namespace d3d11
kk = 0;
for (uint16_t side = 0; side < numSides; ++side)
{
- for (uint32_t lod = 0, num = numMips; lod < num; ++lod)
+ for (uint32_t lod = 0, num = ti.numMips; lod < num; ++lod)
{
BX_FREE(g_allocator, const_cast<void*>(srd[kk].pSysMem) );
++kk;
@@ -4561,6 +4595,12 @@ namespace bgfx { namespace d3d11
{
m_rtv[ii] = NULL;
}
+
+ for (uint32_t ii = 0; ii < BX_COUNTOF(m_uav); ++ii)
+ {
+ m_uav[ii] = NULL;
+ }
+
m_dsv = NULL;
m_swapChain = NULL;
@@ -4576,11 +4616,12 @@ namespace bgfx { namespace d3d11
{
SwapChainDesc scd;
bx::memCopy(&scd, &s_renderD3D11->m_scd, sizeof(SwapChainDesc) );
- scd.format = TextureFormat::Count == _format ? scd.format : s_textureFormat[_format].m_fmt;
- scd.width = _width;
- scd.height = _height;
- scd.nwh = _nwh;
- scd.ndt = NULL;
+ scd.format = TextureFormat::Count == _format ? scd.format : s_textureFormat[_format].m_fmt;
+ scd.width = _width;
+ scd.height = _height;
+ scd.nwh = _nwh;
+ scd.ndt = NULL;
+ scd.sampleDesc = s_msaa[0];
ID3D11Device* device = s_renderD3D11->m_device;
@@ -4670,7 +4711,9 @@ namespace bgfx { namespace d3d11
if (0 < m_numTh)
{
- m_num = 0;
+ m_num = 0;
+ m_numUav = 0;
+
for (uint32_t ii = 0; ii < m_numTh; ++ii)
{
const Attachment& at = m_attachment[ii];
@@ -4765,11 +4808,11 @@ namespace bgfx { namespace d3d11
case TextureD3D11::Texture2D:
if (1 < msaa.Count)
{
- if (1 < texture.m_depth)
+ if (1 < texture.m_numLayers)
{
desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY;
desc.Texture2DMSArray.FirstArraySlice = at.layer;
- desc.Texture2DMSArray.ArraySize = 1;
+ desc.Texture2DMSArray.ArraySize = 1;
}
else
{
@@ -4778,12 +4821,12 @@ namespace bgfx { namespace d3d11
}
else
{
- if (1 < texture.m_depth)
+ if (1 < texture.m_numLayers)
{
desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
desc.Texture2DArray.FirstArraySlice = at.layer;
- desc.Texture2DArray.ArraySize = 1;
- desc.Texture2DArray.MipSlice = at.mip;
+ desc.Texture2DArray.ArraySize = 1;
+ desc.Texture2DArray.MipSlice = at.mip;
}
else
{
@@ -4813,6 +4856,7 @@ namespace bgfx { namespace d3d11
desc.Texture2DArray.FirstArraySlice = at.layer;
desc.Texture2DArray.MipSlice = at.mip;
}
+
DX_CHECK(s_renderD3D11->m_device->CreateRenderTargetView(texture.m_ptr, &desc, &m_rtv[m_num]) );
break;
@@ -4821,6 +4865,7 @@ namespace bgfx { namespace d3d11
desc.Texture3D.MipSlice = at.mip;
desc.Texture3D.WSize = 1;
desc.Texture3D.FirstWSlice = at.layer;
+
DX_CHECK(s_renderD3D11->m_device->CreateRenderTargetView(texture.m_ptr, &desc, &m_rtv[m_num]) );
break;
}
@@ -4830,7 +4875,7 @@ namespace bgfx { namespace d3d11
}
else
{
- BX_CHECK(false, "");
+ m_uav[m_numUav++] = texture.m_uav;
}
}
}
@@ -4903,7 +4948,23 @@ namespace bgfx { namespace d3d11
void FrameBufferD3D11::set()
{
- s_renderD3D11->m_deviceCtx->OMSetRenderTargets(m_num, m_rtv, m_dsv);
+ if (0 < m_numUav)
+ {
+ s_renderD3D11->m_deviceCtx->OMSetRenderTargetsAndUnorderedAccessViews(
+ m_num
+ , m_rtv
+ , m_dsv
+ , 16
+ , m_numUav
+ , m_uav
+ , NULL
+ );
+ }
+ else
+ {
+ s_renderD3D11->m_deviceCtx->OMSetRenderTargets(m_num, m_rtv, m_dsv);
+ }
+
m_needPresent = UINT16_MAX != m_denseIdx;
s_renderD3D11->m_currentColor = m_rtv[0];
s_renderD3D11->m_currentDepthStencil = m_dsv;
@@ -5213,7 +5274,7 @@ namespace bgfx { namespace d3d11
renderDocTriggerCapture();
}
- PIX_BEGINEVENT(D3DCOLOR_FRAME, L"rendererSubmit");
+ BGFX_D3D11_PROFILER_BEGIN_LITERAL("rendererSubmit", kColorView);
ID3D11DeviceContext* deviceCtx = m_deviceCtx;
@@ -5229,12 +5290,14 @@ namespace bgfx { namespace d3d11
if (0 < _render->m_iboffset)
{
+ BGFX_PROFILER_SCOPE("bgfx/Update transient index buffer", kColorResource);
TransientIndexBuffer* ib = _render->m_transientIb;
m_indexBuffers[ib->handle.idx].update(0, _render->m_iboffset, ib->data, true);
}
if (0 < _render->m_vboffset)
{
+ BGFX_PROFILER_SCOPE("bgfx/Update transient vertex buffer", kColorResource);
TransientVertexBuffer* vb = _render->m_transientVb;
m_vertexBuffers[vb->handle.idx].update(0, _render->m_vboffset, vb->data, true);
}
@@ -5249,15 +5312,14 @@ namespace bgfx { namespace d3d11
RenderBind currentBind;
currentBind.clear();
- const bool hmdEnabled = false;
static ViewState viewState;
- viewState.reset(_render, hmdEnabled);
+ viewState.reset(_render);
bool wireframe = !!(_render->m_debug&BGFX_DEBUG_WIREFRAME);
bool scissorEnabled = false;
setDebugWireframe(wireframe);
- uint16_t programIdx = kInvalidHandle;
+ ProgramHandle currentProgram = BGFX_INVALID_HANDLE;
SortKey key;
uint16_t view = UINT16_MAX;
FrameBufferHandle fbh = { BGFX_CONFIG_MAX_FRAME_BUFFERS };
@@ -5299,13 +5361,10 @@ namespace bgfx { namespace d3d11
// if we don't do this we'll only see one frame of output and then nothing
setFrameBuffer(BGFX_INVALID_HANDLE, true, false);
- bool viewRestart = false;
- uint8_t eye = 0;
- uint8_t restartState = 0;
viewState.m_rect = _render->m_view[0].m_rect;
-
int32_t numItems = _render->m_numRenderItems;
- for (int32_t item = 0, restartItem = numItems; item < numItems || restartItem < numItems;)
+
+ for (int32_t item = 0; item < numItems;)
{
const uint64_t encodedKey = _render->m_sortKeys[item];
const bool isCompute = key.decode(encodedKey, _render->m_viewRemap);
@@ -5323,77 +5382,27 @@ namespace bgfx { namespace d3d11
if (viewChanged)
{
- if (1 == restartState)
- {
- restartState = 2;
- item = restartItem;
- restartItem = numItems;
- view = UINT16_MAX;
- continue;
- }
-
view = key.m_view;
- programIdx = kInvalidHandle;
+ currentProgram = BGFX_INVALID_HANDLE;
- if (_render->m_view[view].m_fbh.idx != fbh.idx)
+ if (item > 1)
{
- fbh = _render->m_view[view].m_fbh;
- setFrameBuffer(fbh);
+ profiler.end();
}
- viewRestart = ( (BGFX_VIEW_STEREO == (_render->m_view[view].m_flags & BGFX_VIEW_STEREO) ) );
- viewRestart &= hmdEnabled;
- if (viewRestart)
- {
- if (0 == restartState)
- {
- restartState = 1;
- restartItem = item - 1;
- }
+ BGFX_D3D11_PROFILER_END();
+ setViewType(view, " ");
+ BGFX_D3D11_PROFILER_BEGIN(view, kColorView);
- eye = (restartState - 1) & 1;
- restartState &= 1;
- }
- else
- {
- eye = 0;
- }
+ profiler.begin(view);
- PIX_ENDEVENT();
- if (item > 1)
+ if (_render->m_view[view].m_fbh.idx != fbh.idx)
{
- profiler.end();
+ fbh = _render->m_view[view].m_fbh;
+ setFrameBuffer(fbh);
}
- profiler.begin(view);
viewState.m_rect = _render->m_view[view].m_rect;
- if (viewRestart)
- {
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
- {
- wchar_t* viewNameW = s_viewNameW[view];
- viewNameW[3] = L' ';
- viewNameW[4] = eye ? L'R' : L'L';
- PIX_BEGINEVENT(0 == ( (view*2+eye)&1)
- ? D3DCOLOR_VIEW_L
- : D3DCOLOR_VIEW_R
- , viewNameW
- );
- }
-
- viewState.m_rect.m_x = eye * (viewState.m_rect.m_width+1)/2;
- viewState.m_rect.m_width /= 2;
- }
- else
- {
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
- {
- wchar_t* viewNameW = s_viewNameW[view];
- viewNameW[3] = L' ';
- viewNameW[4] = L' ';
- PIX_BEGINEVENT(D3DCOLOR_VIEW, viewNameW);
- }
- }
const Rect& scissorRect = _render->m_view[view].m_scissor;
viewHasScissor = !scissorRect.isZero();
@@ -5424,13 +5433,9 @@ namespace bgfx { namespace d3d11
{
wasCompute = true;
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
- {
- wchar_t* viewNameW = s_viewNameW[view];
- viewNameW[3] = L'C';
- PIX_ENDEVENT();
- PIX_BEGINEVENT(D3DCOLOR_COMPUTE, viewNameW);
- }
+ setViewType(view, "C");
+ BGFX_D3D11_PROFILER_END();
+ BGFX_D3D11_PROFILER_BEGIN(view, kColorCompute);
deviceCtx->IASetVertexBuffers(0, 2, s_zero.m_buffer, s_zero.m_zero, s_zero.m_zero);
deviceCtx->IASetIndexBuffer(NULL, DXGI_FORMAT_R16_UINT, 0);
@@ -5444,21 +5449,15 @@ namespace bgfx { namespace d3d11
const RenderCompute& compute = renderItem.compute;
- if (0 != eye
- && BGFX_SUBMIT_EYE_LEFT == (compute.m_submitFlags&BGFX_SUBMIT_EYE_MASK) )
- {
- continue;
- }
-
bool programChanged = false;
bool constantsChanged = compute.m_uniformBegin < compute.m_uniformEnd;
rendererUpdateUniforms(this, _render->m_uniformBuffer[compute.m_uniformIdx], compute.m_uniformBegin, compute.m_uniformEnd);
- if (key.m_program != programIdx)
+ if (key.m_program.idx != currentProgram.idx)
{
- programIdx = key.m_program;
+ currentProgram = key.m_program;
- ProgramD3D11& program = m_program[key.m_program];
+ ProgramD3D11& program = m_program[currentProgram.idx];
m_currentProgram = &program;
deviceCtx->CSSetShader(program.m_vsh->m_computeShader, NULL, 0);
@@ -5468,9 +5467,9 @@ namespace bgfx { namespace d3d11
constantsChanged = true;
}
- if (kInvalidHandle != programIdx)
+ if (isValid(currentProgram) )
{
- ProgramD3D11& program = m_program[programIdx];
+ ProgramD3D11& program = m_program[currentProgram.idx];
if (constantsChanged)
{
@@ -5481,7 +5480,7 @@ namespace bgfx { namespace d3d11
}
}
- viewState.setPredefined<4>(this, view, eye, program, _render, compute);
+ viewState.setPredefined<4>(this, view, program, _render, compute);
if (constantsChanged
|| program.m_numPredefined > 0)
@@ -5543,6 +5542,11 @@ namespace bgfx { namespace d3d11
break;
}
}
+ else
+ {
+ m_textureStage.m_srv[stage] = NULL;
+ m_textureStage.m_sampler[stage] = NULL;
+ }
}
if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
@@ -5584,15 +5588,11 @@ namespace bgfx { namespace d3d11
if (wasCompute)
{
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
- {
- wchar_t* viewNameW = s_viewNameW[view];
- viewNameW[3] = L' ';
- PIX_ENDEVENT();
- PIX_BEGINEVENT(D3DCOLOR_DRAW, viewNameW);
- }
+ setViewType(view, " ");
+ BGFX_D3D11_PROFILER_END();
+ BGFX_D3D11_PROFILER_BEGIN(view, kColorDraw);
- programIdx = kInvalidHandle;
+ currentProgram = BGFX_INVALID_HANDLE;
m_currentProgram = NULL;
invalidateCompute();
@@ -5743,11 +5743,11 @@ namespace bgfx { namespace d3d11
bool constantsChanged = draw.m_uniformBegin < draw.m_uniformEnd;
rendererUpdateUniforms(this, _render->m_uniformBuffer[draw.m_uniformIdx], draw.m_uniformBegin, draw.m_uniformEnd);
- if (key.m_program != programIdx)
+ if (key.m_program.idx != currentProgram.idx)
{
- programIdx = key.m_program;
+ currentProgram = key.m_program;
- if (kInvalidHandle == programIdx)
+ if (!isValid(currentProgram) )
{
m_currentProgram = NULL;
@@ -5756,7 +5756,7 @@ namespace bgfx { namespace d3d11
}
else
{
- ProgramD3D11& program = m_program[programIdx];
+ ProgramD3D11& program = m_program[currentProgram.idx];
m_currentProgram = &program;
const ShaderD3D11* vsh = program.m_vsh;
@@ -5780,9 +5780,9 @@ namespace bgfx { namespace d3d11
constantsChanged = true;
}
- if (kInvalidHandle != programIdx)
+ if (isValid(currentProgram) )
{
- ProgramD3D11& program = m_program[programIdx];
+ ProgramD3D11& program = m_program[currentProgram.idx];
if (constantsChanged)
{
@@ -5802,7 +5802,7 @@ namespace bgfx { namespace d3d11
}
}
- viewState.setPredefined<4>(this, view, eye, program, _render, draw);
+ viewState.setPredefined<4>(this, view, program, _render, draw);
if (constantsChanged
|| program.m_numPredefined > 0)
@@ -5877,35 +5877,38 @@ namespace bgfx { namespace d3d11
ID3D11Buffer* buffers[BGFX_CONFIG_MAX_VERTEX_STREAMS];
uint32_t strides[BGFX_CONFIG_MAX_VERTEX_STREAMS];
uint32_t offsets[BGFX_CONFIG_MAX_VERTEX_STREAMS];
- const VertexDecl* decls[BGFX_CONFIG_MAX_VERTEX_STREAMS];
+ const VertexLayout* layouts[BGFX_CONFIG_MAX_VERTEX_STREAMS];
uint32_t numVertices = draw.m_numVertices;
uint8_t numStreams = 0;
if (UINT8_MAX != draw.m_streamMask)
{
- for (uint32_t idx = 0, streamMask = draw.m_streamMask, ntz = bx::uint32_cnttz(streamMask)
+ for (uint32_t idx = 0, streamMask = draw.m_streamMask
; 0 != streamMask
- ; streamMask >>= 1, idx += 1, ntz = bx::uint32_cnttz(streamMask), ++numStreams
+ ; streamMask >>= 1, idx += 1, ++numStreams
)
{
+ const uint32_t ntz = bx::uint32_cnttz(streamMask);
streamMask >>= ntz;
idx += ntz;
- currentState.m_stream[idx].m_decl = draw.m_stream[idx].m_decl;
- currentState.m_stream[idx].m_handle = draw.m_stream[idx].m_handle;
- currentState.m_stream[idx].m_startVertex = draw.m_stream[idx].m_startVertex;
+ currentState.m_stream[idx].m_layoutHandle = draw.m_stream[idx].m_layoutHandle;
+ currentState.m_stream[idx].m_handle = draw.m_stream[idx].m_handle;
+ currentState.m_stream[idx].m_startVertex = draw.m_stream[idx].m_startVertex;
const uint16_t handle = draw.m_stream[idx].m_handle.idx;
const VertexBufferD3D11& vb = m_vertexBuffers[handle];
- const uint16_t decl = !isValid(vb.m_decl) ? draw.m_stream[idx].m_decl.idx : vb.m_decl.idx;
- const VertexDecl& vertexDecl = m_vertexDecls[decl];
- const uint32_t stride = vertexDecl.m_stride;
+ const uint16_t layoutIdx = isValid(draw.m_stream[idx].m_layoutHandle)
+ ? draw.m_stream[idx].m_layoutHandle.idx
+ : vb.m_layoutHandle.idx;
+ const VertexLayout& layout = m_vertexLayouts[layoutIdx];
+ const uint32_t stride = layout.m_stride;
buffers[numStreams] = vb.m_ptr;
strides[numStreams] = stride;
offsets[numStreams] = draw.m_stream[idx].m_startVertex * stride;
- decls[numStreams] = &vertexDecl;
+ layouts[numStreams] = &layout;
numVertices = bx::uint32_min(UINT32_MAX == draw.m_numVertices
? vb.m_size/stride
@@ -5926,12 +5929,12 @@ namespace bgfx { namespace d3d11
const VertexBufferD3D11& inst = m_vertexBuffers[draw.m_instanceDataBuffer.idx];
const uint32_t instStride = draw.m_instanceDataStride;
deviceCtx->IASetVertexBuffers(numStreams, 1, &inst.m_ptr, &instStride, &draw.m_instanceDataOffset);
- setInputLayout(numStreams, decls, m_program[programIdx], uint16_t(instStride/16) );
+ setInputLayout(numStreams, layouts, m_program[currentProgram.idx], uint16_t(instStride/16) );
}
else
{
deviceCtx->IASetVertexBuffers(numStreams, 1, s_zero.m_buffer, s_zero.m_zero, s_zero.m_zero);
- setInputLayout(numStreams, decls, m_program[programIdx], 0);
+ setInputLayout(numStreams, layouts, m_program[currentProgram.idx], 0);
}
}
else
@@ -5943,7 +5946,7 @@ namespace bgfx { namespace d3d11
const VertexBufferD3D11& inst = m_vertexBuffers[draw.m_instanceDataBuffer.idx];
const uint32_t instStride = draw.m_instanceDataStride;
deviceCtx->IASetVertexBuffers(0, 1, &inst.m_ptr, &instStride, &draw.m_instanceDataOffset);
- setInputLayout(0, NULL, m_program[programIdx], uint16_t(instStride/16) );
+ setInputLayout(0, NULL, m_program[currentProgram.idx], uint16_t(instStride/16) );
}
else
{
@@ -6112,13 +6115,9 @@ namespace bgfx { namespace d3d11
if (wasCompute)
{
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
- {
- wchar_t* viewNameW = s_viewNameW[view];
- viewNameW[3] = L'C';
- PIX_ENDEVENT();
- PIX_BEGINEVENT(D3DCOLOR_DRAW, viewNameW);
- }
+ setViewType(view, "C");
+ BGFX_D3D11_PROFILER_END();
+ BGFX_D3D11_PROFILER_BEGIN(view, kColorCompute);
invalidateCompute();
}
@@ -6140,7 +6139,7 @@ namespace bgfx { namespace d3d11
}
}
- PIX_ENDEVENT();
+ BGFX_D3D11_PROFILER_END();
int64_t timeEnd = bx::getHPCounter();
int64_t frameTime = timeEnd - timeBegin;
@@ -6185,7 +6184,7 @@ namespace bgfx { namespace d3d11
if (_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) )
{
- PIX_BEGINEVENT(D3DCOLOR_FRAME, L"debugstats");
+ BGFX_D3D11_PROFILER_BEGIN_LITERAL("debugstats", kColorFrame);
m_needPresent = true;
TextVideoMem& tvm = m_textVideoMem;
@@ -6313,15 +6312,15 @@ namespace bgfx { namespace d3d11
blit(this, _textVideoMemBlitter, tvm);
- PIX_ENDEVENT();
+ BGFX_D3D11_PROFILER_END();
}
else if (_render->m_debug & BGFX_DEBUG_TEXT)
{
- PIX_BEGINEVENT(D3DCOLOR_FRAME, L"debugtext");
+ BGFX_D3D11_PROFILER_BEGIN_LITERAL("debugtext", kColorFrame);
blit(this, _textVideoMemBlitter, _render->m_textVideoMem);
- PIX_ENDEVENT();
+ BGFX_D3D11_PROFILER_END();
}
m_deviceCtx->OMSetRenderTargets(1, s_zero.m_rtv, NULL);
diff --git a/3rdparty/bgfx/src/renderer_d3d11.h b/3rdparty/bgfx/src/renderer_d3d11.h
index 2e021c4aa2f..a6efe141f05 100644
--- a/3rdparty/bgfx/src/renderer_d3d11.h
+++ b/3rdparty/bgfx/src/renderer_d3d11.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -10,8 +10,8 @@
#define USE_D3D11_STAGING_BUFFER 0
#if !USE_D3D11_DYNAMIC_LIB
-# undef BGFX_CONFIG_DEBUG_PIX
-# define BGFX_CONFIG_DEBUG_PIX 0
+# undef BGFX_CONFIG_DEBUG_ANNOTATION
+# define BGFX_CONFIG_DEBUG_ANNOTATION 0
#endif // !USE_D3D11_DYNAMIC_LIB
BX_PRAGMA_DIAGNOSTIC_PUSH();
@@ -40,19 +40,37 @@ BX_PRAGMA_DIAGNOSTIC_POP()
#include "nvapi.h"
#include "dxgi.h"
-#define BGFX_D3D11_BLEND_STATE_MASK (0 \
- | BGFX_STATE_BLEND_MASK \
- | BGFX_STATE_BLEND_EQUATION_MASK \
- | BGFX_STATE_BLEND_INDEPENDENT \
- | BGFX_STATE_BLEND_ALPHA_TO_COVERAGE \
- | BGFX_STATE_WRITE_A \
- | BGFX_STATE_WRITE_RGB \
- )
+#define BGFX_D3D11_BLEND_STATE_MASK (0 \
+ | BGFX_STATE_BLEND_MASK \
+ | BGFX_STATE_BLEND_EQUATION_MASK \
+ | BGFX_STATE_BLEND_INDEPENDENT \
+ | BGFX_STATE_BLEND_ALPHA_TO_COVERAGE \
+ | BGFX_STATE_WRITE_A \
+ | BGFX_STATE_WRITE_RGB \
+ )
#define BGFX_D3D11_DEPTH_STENCIL_MASK (0 \
- | BGFX_STATE_WRITE_Z \
- | BGFX_STATE_DEPTH_TEST_MASK \
- )
+ | BGFX_STATE_WRITE_Z \
+ | BGFX_STATE_DEPTH_TEST_MASK \
+ )
+
+#define BGFX_D3D11_PROFILER_BEGIN(_view, _abgr) \
+ BX_MACRO_BLOCK_BEGIN \
+ PIX_BEGINEVENT(_abgr, s_viewNameW[_view]); \
+ BGFX_PROFILER_BEGIN(s_viewName[view], _abgr); \
+ BX_MACRO_BLOCK_END
+
+#define BGFX_D3D11_PROFILER_BEGIN_LITERAL(_name, _abgr) \
+ BX_MACRO_BLOCK_BEGIN \
+ PIX_BEGINEVENT(_abgr, L"" # _name); \
+ BGFX_PROFILER_BEGIN_LITERAL("" # _name, _abgr); \
+ BX_MACRO_BLOCK_END
+
+#define BGFX_D3D11_PROFILER_END() \
+ BX_MACRO_BLOCK_BEGIN \
+ BGFX_PROFILER_END(); \
+ PIX_ENDEVENT(); \
+ BX_MACRO_BLOCK_END
namespace bgfx { namespace d3d11
{
@@ -109,9 +127,9 @@ namespace bgfx { namespace d3d11
{
}
- void create(uint32_t _size, void* _data, VertexDeclHandle _declHandle, uint16_t _flags);
+ void create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle, uint16_t _flags);
- VertexDeclHandle m_decl;
+ VertexLayoutHandle m_layoutHandle;
};
struct ShaderD3D11
@@ -294,6 +312,7 @@ namespace bgfx { namespace d3d11
uint32_t m_width;
uint32_t m_height;
uint32_t m_depth;
+ uint32_t m_numLayers;
uint8_t m_type;
uint8_t m_requestedFormat;
uint8_t m_textureFormat;
@@ -311,6 +330,7 @@ namespace bgfx { namespace d3d11
, m_denseIdx(UINT16_MAX)
, m_num(0)
, m_numTh(0)
+ , m_numUav(0)
, m_needPresent(false)
{
}
@@ -325,9 +345,10 @@ namespace bgfx { namespace d3d11
void set();
HRESULT present(uint32_t _syncInterval);
- ID3D11RenderTargetView* m_rtv[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS-1];
- ID3D11ShaderResourceView* m_srv[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS-1];
- ID3D11DepthStencilView* m_dsv;
+ ID3D11RenderTargetView* m_rtv[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS-1];
+ ID3D11UnorderedAccessView* m_uav[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS-1];
+ ID3D11ShaderResourceView* m_srv[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS-1];
+ ID3D11DepthStencilView* m_dsv;
Dxgi::SwapChainI* m_swapChain;
void* m_nwh;
uint32_t m_width;
@@ -337,6 +358,7 @@ namespace bgfx { namespace d3d11
uint16_t m_denseIdx;
uint8_t m_num;
uint8_t m_numTh;
+ uint8_t m_numUav;
bool m_needPresent;
};
diff --git a/3rdparty/bgfx/src/renderer_d3d12.cpp b/3rdparty/bgfx/src/renderer_d3d12.cpp
index d577e63b609..64b43d0b9df 100644
--- a/3rdparty/bgfx/src/renderer_d3d12.cpp
+++ b/3rdparty/bgfx/src/renderer_d3d12.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -15,15 +15,23 @@
# endif // BX_PLATFORM_WINRT
#endif // !BX_PLATFORM_WINDOWS
-#if BGFX_CONFIG_DEBUG_PIX && (BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT)
+#if BGFX_CONFIG_DEBUG_ANNOTATION && (BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT)
PFN_PIX_GET_THREAD_INFO bgfx_PIXGetThreadInfo;
PFN_PIX_EVENTS_REPLACE_BLOCK bgfx_PIXEventsReplaceBlock;
-#endif // BGFX_CONFIG_DEBUG_PIX && BX_PLATFORM_WINDOWS
+#endif // BGFX_CONFIG_DEBUG_ANNOTATION && (BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT)
namespace bgfx { namespace d3d12
{
static char s_viewName[BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME];
+ inline void setViewType(ViewId _view, const bx::StringView _str)
+ {
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION || BGFX_CONFIG_PROFILER) )
+ {
+ bx::memCopy(&s_viewName[_view][3], _str.getPtr(), _str.getLength() );
+ }
+ }
+
struct PrimInfo
{
D3D_PRIMITIVE_TOPOLOGY m_topology;
@@ -324,19 +332,19 @@ namespace bgfx { namespace d3d12
};
BX_STATIC_ASSERT(AttribType::Count == BX_COUNTOF(s_attribType) );
- static D3D12_INPUT_ELEMENT_DESC* fillVertexDecl(uint8_t _stream, D3D12_INPUT_ELEMENT_DESC* _out, const VertexDecl& _decl)
+ static D3D12_INPUT_ELEMENT_DESC* fillVertexLayout(uint8_t _stream, D3D12_INPUT_ELEMENT_DESC* _out, const VertexLayout& _layout)
{
D3D12_INPUT_ELEMENT_DESC* elem = _out;
for (uint32_t attr = 0; attr < Attrib::Count; ++attr)
{
- if (UINT16_MAX != _decl.m_attributes[attr])
+ if (UINT16_MAX != _layout.m_attributes[attr])
{
bx::memCopy(elem, &s_attrib[attr], sizeof(D3D12_INPUT_ELEMENT_DESC) );
elem->InputSlot = _stream;
- if (0 == _decl.m_attributes[attr])
+ if (0 == _layout.m_attributes[attr])
{
elem->AlignedByteOffset = 0;
}
@@ -346,9 +354,9 @@ namespace bgfx { namespace d3d12
AttribType::Enum type;
bool normalized;
bool asInt;
- _decl.decode(Attrib::Enum(attr), num, type, normalized, asInt);
+ _layout.decode(Attrib::Enum(attr), num, type, normalized, asInt);
elem->Format = s_attribType[type][num-1][normalized];
- elem->AlignedByteOffset = _decl.m_offset[attr];
+ elem->AlignedByteOffset = _layout.m_offset[attr];
}
++elem;
@@ -623,7 +631,7 @@ namespace bgfx { namespace d3d12
#endif // BX_COMPILER_MSVC
}
-#if BGFX_CONFIG_DEBUG_PIX && (BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT)
+#if BGFX_CONFIG_DEBUG_ANNOTATION && (BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT)
static PIXEventsThreadInfo s_pixEventsThreadInfo;
PIXEventsThreadInfo* WINAPI stubPIXGetThreadInfo()
@@ -636,7 +644,7 @@ namespace bgfx { namespace d3d12
BX_UNUSED(_getEarliestTime);
return 0;
}
-#endif // BGFX_CONFIG_DEBUG_PIX && BX_PLATFORM_WINDOWS
+#endif // BGFX_CONFIG_DEBUG_ANNOTATION && (BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT)
struct RendererContextD3D12 : public RendererContextI
{
@@ -680,7 +688,7 @@ namespace bgfx { namespace d3d12
ErrorState::Enum errorState = ErrorState::Default;
// LUID luid;
-#if BGFX_CONFIG_DEBUG_PIX && (BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT)
+#if BGFX_CONFIG_DEBUG_ANNOTATION && (BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT)
m_winPixEvent = bx::dlopen("WinPixEventRuntime.dll");
if (NULL != m_winPixEvent)
@@ -695,7 +703,7 @@ namespace bgfx { namespace d3d12
bgfx_PIXGetThreadInfo = stubPIXGetThreadInfo;
bgfx_PIXEventsReplaceBlock = stubPIXEventsReplaceBlock;
}
-#endif // BGFX_CONFIG_DEBUG_PIX && BX_PLATFORM_WINDOWS
+#endif // BGFX_CONFIG_DEBUG_ANNOTATION && (BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT)
if (_init.debug
|| _init.profile)
@@ -767,54 +775,40 @@ namespace bgfx { namespace d3d12
HRESULT hr;
- if (_init.debug
- || _init.profile)
{
- ID3D12Debug* debug0;
- hr = D3D12GetDebugInterface(IID_ID3D12Debug, (void**)&debug0);
-
- if (SUCCEEDED(hr) )
+#if BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT
+ if (_init.debug
+ || _init.profile)
{
- uint32_t debugFlags = 0;
+ ID3D12Debug* debug0;
+ hr = D3D12GetDebugInterface(IID_ID3D12Debug, (void**)&debug0);
- if (_init.debug)
+ if (SUCCEEDED(hr) )
{
-#if BX_PLATFORM_WINDOWS
- debug0->EnableDebugLayer();
-
+ if (_init.debug)
{
- ID3D12Debug1* debug1;
- hr = debug0->QueryInterface(IID_ID3D12Debug1, (void**)&debug1);
+#if BX_PLATFORM_WINDOWS
+ debug0->EnableDebugLayer();
- if (SUCCEEDED(hr) )
{
-// debug1->SetEnableGPUBasedValidation(true);
-// debug1->SetEnableSynchronizedCommandQueueValidation(true);
- }
+ ID3D12Debug1* debug1;
+ hr = debug0->QueryInterface(IID_ID3D12Debug1, (void**)&debug1);
- DX_RELEASE(debug1, 1);
- }
-#elif BX_PLATFORM_XBOXONE
- debugFlags |= D3D12_PROCESS_DEBUG_FLAG_DEBUG_LAYER_ENABLED;
-#endif // BX_PLATFORM_WINDOWS
- }
+ if (SUCCEEDED(hr))
+ {
+// debug1->SetEnableGPUBasedValidation(true);
+// debug1->SetEnableSynchronizedCommandQueueValidation(true);
+ }
-#if BX_PLATFORM_XBOXONE
- // https://github.com/Microsoft/Xbox-ATG-Samples/blob/76d236e3bd372aceec18b2ad0556a7879dbd9628/XDKSamples/IntroGraphics/SimpleTriangle12/DeviceResources.cpp#L67
- debugFlags |= _init.profile ? D3D12XBOX_PROCESS_DEBUG_FLAG_INSTRUMENTED : 0;
+ DX_RELEASE(debug1, 1);
+ }
+#endif // BX_PLATFORM_WINDOWS
+ }
- if (0 != debugFlags)
- {
- debug0->SetProcessDebugFlags(D3D12XBOX_PROCESS_DEBUG_FLAGS(debugFlags) );
+ DX_RELEASE(debug0, 0);
}
-#endif // BX_PLATFORM_XBOXONE
- BX_UNUSED(debugFlags);
-
- DX_RELEASE(debug0, 0);
}
- }
- {
D3D_FEATURE_LEVEL featureLevel[] =
{
D3D_FEATURE_LEVEL_12_1,
@@ -837,6 +831,35 @@ namespace bgfx { namespace d3d12
);
m_featureLevel = featureLevel[ii];
}
+#else
+ // Reference(s):
+ // - https://github.com/Microsoft/Xbox-ATG-Samples/blob/1271bfd61b4883c775f395b6f13aeabea70290ca/XDKSamples/Graphics/AdvancedESRAM12/DeviceResources.cpp#L64
+ D3D12XBOX_CREATE_DEVICE_PARAMETERS params = {};
+ params.Version = D3D12_SDK_VERSION;
+ params.ProcessDebugFlags = D3D12XBOX_PROCESS_DEBUG_FLAGS(0
+ | (_init.debug ? D3D12XBOX_PROCESS_DEBUG_FLAG_DEBUG : 0)
+ | (_init.profile ? D3D12XBOX_PROCESS_DEBUG_FLAG_INSTRUMENTED : 0)
+ );
+ params.GraphicsCommandQueueRingSizeBytes = UINT32_MAX;
+ params.GraphicsScratchMemorySizeBytes = UINT32_MAX;
+ params.ComputeScratchMemorySizeBytes = UINT32_MAX;
+ params.DisableGeometryShaderAllocations = true;
+ params.DisableTessellationShaderAllocations = true;
+
+ hr = D3D12XboxCreateDevice(
+ m_dxgi.m_adapter
+ , &params
+ , IID_ID3D12Device
+ , (void**)&m_device
+ );
+ m_featureLevel = D3D_FEATURE_LEVEL_12_1;
+
+ if (SUCCEEDED(hr) )
+ {
+ m_device->SetDebugErrorFilterX(0x73EC9EAF, D3D12XBOX_DEBUG_FILTER_FLAG_DISABLE_BREAKS);
+ m_device->SetDebugErrorFilterX(0x8EC9B15C, D3D12XBOX_DEBUG_FILTER_FLAG_DISABLE_OUTPUT);
+ }
+#endif // BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT
}
if (FAILED(hr) )
@@ -866,11 +889,6 @@ namespace bgfx { namespace d3d12
}
}
-#if BX_PLATFORM_XBOXONE
- m_device->SetDebugErrorFilterX(0x73EC9EAF, D3D12XBOX_DEBUG_FILTER_FLAG_DISABLE_BREAKS);
- m_device->SetDebugErrorFilterX(0x8EC9B15C, D3D12XBOX_DEBUG_FILTER_FLAG_DISABLE_OUTPUT);
-#endif // BX_PLATFORM_XBOXONE
-
if (BGFX_PCI_ID_NVIDIA != m_dxgi.m_adapterDesc.VendorId)
{
m_nvapi.shutdown();
@@ -916,7 +934,10 @@ namespace bgfx { namespace d3d12
bx::memSet(&m_scd, 0, sizeof(m_scd) );
m_scd.width = _init.resolution.width;
m_scd.height = _init.resolution.height;
- m_scd.format = s_textureFormat[_init.resolution.format].m_fmt;
+ m_scd.format = (_init.resolution.reset & BGFX_RESET_SRGB_BACKBUFFER)
+ ? s_textureFormat[_init.resolution.format].m_fmtSrgb
+ : s_textureFormat[_init.resolution.format].m_fmt
+ ;
m_scd.stereo = false;
updateMsaa(m_scd.format);
@@ -1509,20 +1530,20 @@ namespace bgfx { namespace d3d12
m_indexBuffers[_handle.idx].destroy();
}
- void createVertexDecl(VertexDeclHandle _handle, const VertexDecl& _decl) override
+ void createVertexLayout(VertexLayoutHandle _handle, const VertexLayout& _layout) override
{
- VertexDecl& decl = m_vertexDecls[_handle.idx];
- bx::memCopy(&decl, &_decl, sizeof(VertexDecl) );
- dump(decl);
+ VertexLayout& layout = m_vertexLayouts[_handle.idx];
+ bx::memCopy(&layout, &_layout, sizeof(VertexLayout) );
+ dump(layout);
}
- void destroyVertexDecl(VertexDeclHandle /*_handle*/) override
+ void destroyVertexLayout(VertexLayoutHandle /*_handle*/) override
{
}
- void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexDeclHandle _declHandle, uint16_t _flags) override
+ void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexLayoutHandle _layoutHandle, uint16_t _flags) override
{
- m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _declHandle, _flags);
+ m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _layoutHandle, _flags);
}
void destroyVertexBuffer(VertexBufferHandle _handle) override
@@ -1547,8 +1568,8 @@ namespace bgfx { namespace d3d12
void createDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size, uint16_t _flags) override
{
- VertexDeclHandle decl = BGFX_INVALID_HANDLE;
- m_vertexBuffers[_handle.idx].create(_size, NULL, decl, _flags);
+ VertexLayoutHandle layoutHandle = BGFX_INVALID_HANDLE;
+ m_vertexBuffers[_handle.idx].create(_size, NULL, layoutHandle, _flags);
}
void updateDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _offset, uint32_t _size, const Memory* _mem) override
@@ -1859,29 +1880,39 @@ namespace bgfx { namespace d3d12
bx::memCopy(m_uniforms[_loc], _data, _size);
}
- void setMarker(const char* _marker, uint32_t /*_size*/) override
+ void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override
{
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
- {
- PIX3_SETMARKER(m_commandList, D3DCOLOR_MARKER, _marker);
- }
+ m_occlusionQuery.invalidate(_handle);
}
- void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override
+ void setMarker(const char* _marker, uint16_t _len) override
{
- m_occlusionQuery.invalidate(_handle);
+ BX_UNUSED(_len);
+
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
+ {
+ PIX3_SETMARKER(m_commandList, kColorMarker, _marker);
+ }
}
- virtual void setName(Handle _handle, const char* _name) override
+ virtual void setName(Handle _handle, const char* _name, uint16_t _len) override
{
switch (_handle.type)
{
+ case Handle::IndexBuffer:
+ setDebugObjectName(m_indexBuffers[_handle.idx].m_ptr, "%.*s", _len, _name);
+ break;
+
case Handle::Shader:
-// setDebugObjectName(m_shaders[_handle.idx].m_ptr, "%s", _name);
+// setDebugObjectName(m_shaders[_handle.idx].m_ptr, "%.*s", _len, _name);
break;
case Handle::Texture:
- setDebugObjectName(m_textures[_handle.idx].m_ptr, "%s", _name);
+ setDebugObjectName(m_textures[_handle.idx].m_ptr, "%.*s", _len, _name);
+ break;
+
+ case Handle::VertexBuffer:
+ setDebugObjectName(m_vertexBuffers[_handle.idx].m_ptr, "%.*s", _len, _name);
break;
default:
@@ -1923,12 +1954,12 @@ namespace bgfx { namespace d3d12
| BGFX_STATE_DEPTH_TEST_ALWAYS
;
- const VertexDecl* decls[1] = { &m_vertexDecls[_blitter.m_vb->decl.idx] };
+ const VertexLayout* layouts[1] = { &m_vertexLayouts[_blitter.m_vb->layoutHandle.idx] };
ID3D12PipelineState* pso = getPipelineState(state
, packStencil(BGFX_STENCIL_DEFAULT, BGFX_STENCIL_DEFAULT)
, 1
- , decls
- , _blitter.m_program.idx
+ , layouts
+ , _blitter.m_program
, 0
);
m_commandList->SetPipelineState(pso);
@@ -1942,7 +1973,7 @@ namespace bgfx { namespace d3d12
setShaderUniform(flags, predefined.m_loc, proj, 4);
D3D12_GPU_VIRTUAL_ADDRESS gpuAddress;
- commitShaderConstants(_blitter.m_program.idx, gpuAddress);
+ commitShaderConstants(_blitter.m_program, gpuAddress);
ScratchBufferD3D12& scratchBuffer = m_scratchBuffer[m_backBufferColorIdx];
ID3D12DescriptorHeap* heaps[] =
@@ -1961,11 +1992,11 @@ namespace bgfx { namespace d3d12
scratchBuffer.allocSrv(srvHandle, texture);
m_commandList->SetGraphicsRootDescriptorTable(Rdt::SRV, srvHandle);
- VertexBufferD3D12& vb = m_vertexBuffers[_blitter.m_vb->handle.idx];
- const VertexDecl& vertexDecl = m_vertexDecls[_blitter.m_vb->decl.idx];
+ VertexBufferD3D12& vb = m_vertexBuffers[_blitter.m_vb->handle.idx];
+ const VertexLayout& layout = m_vertexLayouts[_blitter.m_vb->layoutHandle.idx];
D3D12_VERTEX_BUFFER_VIEW viewDesc;
viewDesc.BufferLocation = vb.m_gpuVA;
- viewDesc.StrideInBytes = vertexDecl.m_stride;
+ viewDesc.StrideInBytes = layout.m_stride;
viewDesc.SizeInBytes = vb.m_size;
m_commandList->IASetVertexBuffers(0, 1, &viewDesc);
@@ -1985,7 +2016,7 @@ namespace bgfx { namespace d3d12
if (0 < numVertices)
{
m_indexBuffers [_blitter.m_ib->handle.idx].update(m_commandList, 0, _numIndices*2, _blitter.m_ib->data);
- m_vertexBuffers[_blitter.m_vb->handle.idx].update(m_commandList, 0, numVertices*_blitter.m_decl.m_stride, _blitter.m_vb->data, true);
+ m_vertexBuffers[_blitter.m_vb->handle.idx].update(m_commandList, 0, numVertices*_blitter.m_layout.m_stride, _blitter.m_vb->data, true);
m_commandList->DrawIndexedInstanced(_numIndices
, 1
@@ -2216,7 +2247,7 @@ namespace bgfx { namespace d3d12
BX_STATIC_ASSERT(BX_COUNTOF(m_backBufferColor) == BX_COUNTOF(presentQueue) );
DX_CHECK(m_dxgi.resizeBuffers(m_swapChain, m_scd, nodeMask, presentQueue) );
#elif BX_PLATFORM_WINRT
- DX_CHECK(m_dxgi.resizeBuffers(m_swapChain, m_scd);
+ DX_CHECK(m_dxgi.resizeBuffers(m_swapChain, m_scd));
m_backBufferColorIdx = m_scd.bufferCount-1;
#endif // BX_PLATFORM_WINDOWS
}
@@ -2292,9 +2323,9 @@ namespace bgfx { namespace d3d12
setShaderUniform(_flags, _regIndex, _val, _numRegs);
}
- void commitShaderConstants(uint16_t _programIdx, D3D12_GPU_VIRTUAL_ADDRESS& _gpuAddress)
+ void commitShaderConstants(ProgramHandle _program, D3D12_GPU_VIRTUAL_ADDRESS& _gpuAddress)
{
- const ProgramD3D12& program = m_program[_programIdx];
+ const ProgramD3D12& program = m_program[_program.idx];
uint32_t total = bx::strideAlign(0
+ program.m_vsh->m_size
+ (NULL != program.m_fsh ? program.m_fsh->m_size : 0)
@@ -2573,7 +2604,7 @@ namespace bgfx { namespace d3d12
_desc.BackFace.StencilFunc = s_cmpFunc[(bstencil&BGFX_STENCIL_TEST_MASK) >> BGFX_STENCIL_TEST_SHIFT];
}
- uint32_t setInputLayout(D3D12_INPUT_ELEMENT_DESC* _vertexElements, uint8_t _numStreams, const VertexDecl** _vertexDecls, const ProgramD3D12& _program, uint16_t _numInstanceData)
+ uint32_t setInputLayout(D3D12_INPUT_ELEMENT_DESC* _vertexElements, uint8_t _numStreams, const VertexLayout** _layouts, const ProgramD3D12& _program, uint16_t _numInstanceData)
{
uint16_t attrMask[Attrib::Count];
bx::memCopy(attrMask, _program.m_vsh->m_attrMask, sizeof(attrMask));
@@ -2582,19 +2613,19 @@ namespace bgfx { namespace d3d12
for (uint8_t stream = 0; stream < _numStreams; ++stream)
{
- VertexDecl decl;
- bx::memCopy(&decl, _vertexDecls[stream], sizeof(VertexDecl));
+ VertexLayout layout;
+ bx::memCopy(&layout, _layouts[stream], sizeof(VertexLayout));
const bool last = stream == _numStreams-1;
for (uint32_t ii = 0; ii < Attrib::Count; ++ii)
{
uint16_t mask = attrMask[ii];
- uint16_t attr = (decl.m_attributes[ii] & mask);
+ uint16_t attr = (layout.m_attributes[ii] & mask);
if (0 == attr
|| UINT16_MAX == attr)
{
- decl.m_attributes[ii] = last ? ~attr : UINT16_MAX;
+ layout.m_attributes[ii] = last ? ~attr : UINT16_MAX;
}
else
{
@@ -2602,7 +2633,7 @@ namespace bgfx { namespace d3d12
}
}
- elem = fillVertexDecl(stream, elem, decl);
+ elem = fillVertexLayout(stream, elem, layout);
}
uint32_t num = uint32_t(elem-_vertexElements);
@@ -2640,10 +2671,10 @@ namespace bgfx { namespace d3d12
return uint32_t(elem-_vertexElements);
}
- uint32_t setInputLayout(D3D12_INPUT_ELEMENT_DESC* _vertexElements, const VertexDecl& _vertexDecl, const ProgramD3D12& _program, uint16_t _numInstanceData)
+ uint32_t setInputLayout(D3D12_INPUT_ELEMENT_DESC* _vertexElements, const VertexLayout& _layout, const ProgramD3D12& _program, uint16_t _numInstanceData)
{
- const VertexDecl* decls[1] = { &_vertexDecl };
- return setInputLayout(_vertexElements, BX_COUNTOF(decls), decls, _program, _numInstanceData);
+ const VertexLayout* layouts[1] = { &_layout };
+ return setInputLayout(_vertexElements, BX_COUNTOF(layouts), layouts, _program, _numInstanceData);
}
static void patchCb0(DxbcInstruction& _instruction, void* _userData)
@@ -2677,9 +2708,9 @@ namespace bgfx { namespace d3d12
}
}
- ID3D12PipelineState* getPipelineState(uint16_t _programIdx)
+ ID3D12PipelineState* getPipelineState(ProgramHandle _program)
{
- ProgramD3D12& program = m_program[_programIdx];
+ ProgramD3D12& program = m_program[_program.idx];
const uint32_t hash = program.m_vsh->m_hash;
@@ -2693,17 +2724,67 @@ namespace bgfx { namespace d3d12
D3D12_COMPUTE_PIPELINE_STATE_DESC desc;
bx::memSet(&desc, 0, sizeof(desc) );
- desc.pRootSignature = m_rootSignature;
-
+ desc.pRootSignature = m_rootSignature;
desc.CS.pShaderBytecode = program.m_vsh->m_code->data;
desc.CS.BytecodeLength = program.m_vsh->m_code->size;
+ desc.NodeMask = 1;
+ desc.Flags = D3D12_PIPELINE_STATE_FLAG_NONE;
+
+ uint32_t length = g_callback->cacheReadSize(hash);
+ const bool cached = length > 0;
+
+ void* cachedData = NULL;
+
+ if (cached)
+ {
+ cachedData = BX_ALLOC(g_allocator, length);
+ if (g_callback->cacheRead(hash, cachedData, length) )
+ {
+ BX_TRACE("Loading cached compute PSO (size %d).", length);
+ bx::MemoryReader reader(cachedData, length);
+
+ desc.CachedPSO.pCachedBlob = reader.getDataPtr();
+ desc.CachedPSO.CachedBlobSizeInBytes = (size_t)reader.remaining();
+
+ HRESULT hr = m_device->CreateComputePipelineState(&desc
+ , IID_ID3D12PipelineState
+ , (void**)&pso
+ );
+ if (FAILED(hr) )
+ {
+ BX_TRACE("Failed to load cached compute PSO (HRESULT 0x%08x).", hr);
+ bx::memSet(&desc.CachedPSO, 0, sizeof(desc.CachedPSO) );
+ }
+ }
+ }
+
+ if (NULL == pso)
+ {
+ DX_CHECK(m_device->CreateComputePipelineState(&desc
+ , IID_ID3D12PipelineState
+ , (void**)&pso
+ ) );
+ }
- DX_CHECK(m_device->CreateComputePipelineState(&desc
- , IID_ID3D12PipelineState
- , (void**)&pso
- ) );
m_pipelineStateCache.add(hash, pso);
+ ID3DBlob* blob;
+ HRESULT hr = pso->GetCachedBlob(&blob);
+ if (SUCCEEDED(hr) )
+ {
+ void* data = blob->GetBufferPointer();
+ length = (uint32_t)blob->GetBufferSize();
+
+ g_callback->cacheWrite(hash, data, length);
+
+ DX_RELEASE(blob, 0);
+ }
+
+ if (NULL != cachedData)
+ {
+ BX_FREE(g_allocator, cachedData);
+ }
+
return pso;
}
@@ -2711,12 +2792,12 @@ namespace bgfx { namespace d3d12
uint64_t _state
, uint64_t _stencil
, uint8_t _numStreams
- , const VertexDecl** _vertexDecls
- , uint16_t _programIdx
+ , const VertexLayout** _layouts
+ , ProgramHandle _program
, uint8_t _numInstanceData
)
{
- ProgramD3D12& program = m_program[_programIdx];
+ ProgramD3D12& program = m_program[_program.idx];
_state &= 0
| BGFX_STATE_WRITE_RGB
@@ -2736,17 +2817,17 @@ namespace bgfx { namespace d3d12
_stencil &= packStencil(~BGFX_STENCIL_FUNC_REF_MASK, ~BGFX_STENCIL_FUNC_REF_MASK);
- VertexDecl decl;
+ VertexLayout layout;
if (0 < _numStreams)
{
- bx::memCopy(&decl, _vertexDecls[0], sizeof(VertexDecl) );
+ bx::memCopy(&layout, _layouts[0], sizeof(VertexLayout) );
const uint16_t* attrMask = program.m_vsh->m_attrMask;
for (uint32_t ii = 0; ii < Attrib::Count; ++ii)
{
uint16_t mask = attrMask[ii];
- uint16_t attr = (decl.m_attributes[ii] & mask);
- decl.m_attributes[ii] = attr == 0 ? UINT16_MAX : attr == UINT16_MAX ? 0 : attr;
+ uint16_t attr = (layout.m_attributes[ii] & mask);
+ layout.m_attributes[ii] = attr == 0 ? UINT16_MAX : attr == UINT16_MAX ? 0 : attr;
}
}
@@ -2764,10 +2845,10 @@ namespace bgfx { namespace d3d12
for (uint32_t ii = 0; ii < _numStreams; ++ii)
{
- murmur.add(_vertexDecls[ii]->m_hash);
+ murmur.add(_layouts[ii]->m_hash);
}
- murmur.add(decl.m_attributes, sizeof(decl.m_attributes) );
+ murmur.add(layout.m_attributes, sizeof(layout.m_attributes) );
murmur.add(m_fbh.idx);
murmur.add(_numInstanceData);
const uint32_t hash = murmur.end();
@@ -2883,7 +2964,7 @@ namespace bgfx { namespace d3d12
setDepthStencilState(desc.DepthStencilState, _state, _stencil);
D3D12_INPUT_ELEMENT_DESC vertexElements[Attrib::Count + 1 + BGFX_CONFIG_MAX_INSTANCE_DATA_COUNT];
- desc.InputLayout.NumElements = setInputLayout(vertexElements, _numStreams, _vertexDecls, program, _numInstanceData);
+ desc.InputLayout.NumElements = setInputLayout(vertexElements, _numStreams, _layouts, program, _numInstanceData);
desc.InputLayout.pInputElementDescs = 0 == desc.InputLayout.NumElements
? NULL
: vertexElements
@@ -2930,7 +3011,7 @@ namespace bgfx { namespace d3d12
desc.SampleDesc = m_scd.sampleDesc;
uint32_t length = g_callback->cacheReadSize(hash);
- bool cached = length > 0;
+ const bool cached = length > 0;
void* cachedData = NULL;
@@ -2939,7 +3020,7 @@ namespace bgfx { namespace d3d12
cachedData = BX_ALLOC(g_allocator, length);
if (g_callback->cacheRead(hash, cachedData, length) )
{
- BX_TRACE("Loading cached PSO (size %d).", length);
+ BX_TRACE("Loading cached graphics PSO (size %d).", length);
bx::MemoryReader reader(cachedData, length);
desc.CachedPSO.pCachedBlob = reader.getDataPtr();
@@ -2951,7 +3032,7 @@ namespace bgfx { namespace d3d12
);
if (FAILED(hr) )
{
- BX_TRACE("Failed to load cached PSO (HRESULT 0x%08x).", hr);
+ BX_TRACE("Failed to load cached graphics PSO (HRESULT 0x%08x).", hr);
bx::memSet(&desc.CachedPSO, 0, sizeof(desc.CachedPSO) );
}
}
@@ -3081,9 +3162,9 @@ namespace bgfx { namespace d3d12
}
break;
- CASE_IMPLEMENT_UNIFORM(Int1, I, int);
- CASE_IMPLEMENT_UNIFORM(Vec4, F, float);
- CASE_IMPLEMENT_UNIFORM(Mat4, F, float);
+ CASE_IMPLEMENT_UNIFORM(Sampler, I, int);
+ CASE_IMPLEMENT_UNIFORM(Vec4, F, float);
+ CASE_IMPLEMENT_UNIFORM(Mat4, F, float);
case UniformType::End:
break;
@@ -3275,7 +3356,7 @@ namespace bgfx { namespace d3d12
ShaderD3D12 m_shaders[BGFX_CONFIG_MAX_SHADERS];
ProgramD3D12 m_program[BGFX_CONFIG_MAX_PROGRAMS];
TextureD3D12 m_textures[BGFX_CONFIG_MAX_TEXTURES];
- VertexDecl m_vertexDecls[BGFX_CONFIG_MAX_VERTEX_DECLS];
+ VertexLayout m_vertexLayouts[BGFX_CONFIG_MAX_VERTEX_LAYOUTS];
FrameBufferD3D12 m_frameBuffers[BGFX_CONFIG_MAX_FRAME_BUFFERS];
void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS];
Matrix4 m_predefinedUniforms[PredefinedUniform::Count];
@@ -3874,13 +3955,14 @@ namespace bgfx { namespace d3d12
if (UINT8_MAX != _draw.m_streamMask)
{
- for (uint32_t idx = 0, streamMask = _draw.m_streamMask, ntz = bx::uint32_cnttz(streamMask)
+ for (uint32_t idx = 0, streamMask = _draw.m_streamMask
; 0 != streamMask
- ; streamMask >>= 1, idx += 1, ntz = bx::uint32_cnttz(streamMask), ++numStreams
+ ; streamMask >>= 1, idx += 1, ++numStreams
)
{
+ const uint32_t ntz = bx::uint32_cnttz(streamMask);
streamMask >>= ntz;
- idx += ntz;
+ idx += ntz;
const Stream& stream = _draw.m_stream[idx];
@@ -3888,13 +3970,13 @@ namespace bgfx { namespace d3d12
VertexBufferD3D12& vb = s_renderD3D12->m_vertexBuffers[handle];
vb.setState(_commandList, D3D12_RESOURCE_STATE_GENERIC_READ);
- uint16_t decl = !isValid(vb.m_decl) ? stream.m_decl.idx : vb.m_decl.idx;
- const VertexDecl& vertexDecl = s_renderD3D12->m_vertexDecls[decl];
- uint32_t stride = vertexDecl.m_stride;
+ const uint16_t layoutIdx = !isValid(vb.m_layoutHandle) ? stream.m_layoutHandle.idx : vb.m_layoutHandle.idx;
+ const VertexLayout& layout = s_renderD3D12->m_vertexLayouts[layoutIdx];
+ uint32_t stride = layout.m_stride;
D3D12_VERTEX_BUFFER_VIEW& vbv = _vbv[numStreams];
vbv.BufferLocation = vb.m_gpuVA + stream.m_startVertex * stride;
- vbv.StrideInBytes = vertexDecl.m_stride;
+ vbv.StrideInBytes = layout.m_stride;
vbv.SizeInBytes = vb.m_size;
_outNumVertices = bx::uint32_min(UINT32_MAX == _draw.m_numVertices
@@ -4214,15 +4296,15 @@ namespace bgfx { namespace d3d12
static const UavFormat s_uavFormat[] =
{ // BGFX_BUFFER_COMPUTE_TYPE_INT, BGFX_BUFFER_COMPUTE_TYPE_UINT, BGFX_BUFFER_COMPUTE_TYPE_FLOAT
{ { DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, 0 }, // ignored
- { { DXGI_FORMAT_R8_SINT, DXGI_FORMAT_R8_UINT, DXGI_FORMAT_UNKNOWN }, 1 }, // BGFX_BUFFER_COMPUTE_FORMAT_8x1
- { { DXGI_FORMAT_R8G8_SINT, DXGI_FORMAT_R8G8_UINT, DXGI_FORMAT_UNKNOWN }, 2 }, // BGFX_BUFFER_COMPUTE_FORMAT_8x2
- { { DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_UNKNOWN }, 4 }, // BGFX_BUFFER_COMPUTE_FORMAT_8x4
- { { DXGI_FORMAT_R16_SINT, DXGI_FORMAT_R16_UINT, DXGI_FORMAT_R16_FLOAT }, 2 }, // BGFX_BUFFER_COMPUTE_FORMAT_16x1
- { { DXGI_FORMAT_R16G16_SINT, DXGI_FORMAT_R16G16_UINT, DXGI_FORMAT_R16G16_FLOAT }, 4 }, // BGFX_BUFFER_COMPUTE_FORMAT_16x2
- { { DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_R16G16B16A16_FLOAT }, 8 }, // BGFX_BUFFER_COMPUTE_FORMAT_16x4
- { { DXGI_FORMAT_R32_SINT, DXGI_FORMAT_R32_UINT, DXGI_FORMAT_R32_FLOAT }, 4 }, // BGFX_BUFFER_COMPUTE_FORMAT_32x1
- { { DXGI_FORMAT_R32G32_SINT, DXGI_FORMAT_R32G32_UINT, DXGI_FORMAT_R32G32_FLOAT }, 8 }, // BGFX_BUFFER_COMPUTE_FORMAT_32x2
- { { DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_R32G32B32A32_FLOAT }, 16 }, // BGFX_BUFFER_COMPUTE_FORMAT_32x4
+ { { DXGI_FORMAT_R8_SINT, DXGI_FORMAT_R8_UINT, DXGI_FORMAT_UNKNOWN }, 1 }, // BGFX_BUFFER_COMPUTE_FORMAT_8X1
+ { { DXGI_FORMAT_R8G8_SINT, DXGI_FORMAT_R8G8_UINT, DXGI_FORMAT_UNKNOWN }, 2 }, // BGFX_BUFFER_COMPUTE_FORMAT_8X2
+ { { DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_UNKNOWN }, 4 }, // BGFX_BUFFER_COMPUTE_FORMAT_8X4
+ { { DXGI_FORMAT_R16_SINT, DXGI_FORMAT_R16_UINT, DXGI_FORMAT_R16_FLOAT }, 2 }, // BGFX_BUFFER_COMPUTE_FORMAT_16X1
+ { { DXGI_FORMAT_R16G16_SINT, DXGI_FORMAT_R16G16_UINT, DXGI_FORMAT_R16G16_FLOAT }, 4 }, // BGFX_BUFFER_COMPUTE_FORMAT_16X2
+ { { DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_R16G16B16A16_FLOAT }, 8 }, // BGFX_BUFFER_COMPUTE_FORMAT_16X4
+ { { DXGI_FORMAT_R32_SINT, DXGI_FORMAT_R32_UINT, DXGI_FORMAT_R32_FLOAT }, 4 }, // BGFX_BUFFER_COMPUTE_FORMAT_32X1
+ { { DXGI_FORMAT_R32G32_SINT, DXGI_FORMAT_R32G32_UINT, DXGI_FORMAT_R32G32_FLOAT }, 8 }, // BGFX_BUFFER_COMPUTE_FORMAT_32X2
+ { { DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_R32G32B32A32_FLOAT }, 16 }, // BGFX_BUFFER_COMPUTE_FORMAT_32X4
};
void BufferD3D12::create(uint32_t _size, void* _data, uint16_t _flags, bool _vertex, uint32_t _stride)
@@ -4360,10 +4442,10 @@ namespace bgfx { namespace d3d12
return _state;
}
- void VertexBufferD3D12::create(uint32_t _size, void* _data, VertexDeclHandle _declHandle, uint16_t _flags)
+ void VertexBufferD3D12::create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle, uint16_t _flags)
{
BufferD3D12::create(_size, _data, _flags, true);
- m_decl = _declHandle;
+ m_layoutHandle = _layoutHandle;
}
void ShaderD3D12::create(const Memory* _mem)
@@ -4518,18 +4600,27 @@ namespace bgfx { namespace d3d12
if (bimg::imageParse(imageContainer, _mem->data, _mem->size) )
{
- uint8_t numMips = imageContainer.m_numMips;
- const uint8_t startLod = uint8_t(bx::uint32_min(_skip, numMips-1) );
- numMips -= startLod;
const bimg::ImageBlockInfo& blockInfo = bimg::getBlockInfo(imageContainer.m_format);
- const uint32_t textureWidth = bx::uint32_max(blockInfo.blockWidth, imageContainer.m_width >>startLod);
- const uint32_t textureHeight = bx::uint32_max(blockInfo.blockHeight, imageContainer.m_height>>startLod);
- const uint16_t numLayers = imageContainer.m_numLayers;
-
- m_flags = _flags;
- m_width = textureWidth;
- m_height = textureHeight;
- m_depth = imageContainer.m_depth;
+ const uint8_t startLod = bx::min<uint8_t>(_skip, imageContainer.m_numMips-1);
+
+ bimg::TextureInfo ti;
+ bimg::imageGetSize(
+ &ti
+ , uint16_t(imageContainer.m_width >>startLod)
+ , uint16_t(imageContainer.m_height>>startLod)
+ , uint16_t(imageContainer.m_depth >>startLod)
+ , imageContainer.m_cubeMap
+ , 1 < imageContainer.m_numMips
+ , imageContainer.m_numLayers
+ , imageContainer.m_format
+ );
+ ti.numMips = bx::min<uint8_t>(imageContainer.m_numMips-startLod, ti.numMips);
+
+ m_flags = _flags;
+ m_width = ti.width;
+ m_height = ti.height;
+ m_depth = ti.depth;
+ m_numLayers = ti.numLayers;
m_requestedFormat = uint8_t(imageContainer.m_format);
m_textureFormat = uint8_t(getViableTextureFormat(imageContainer) );
const bool convert = m_textureFormat != m_requestedFormat;
@@ -4548,9 +4639,9 @@ namespace bgfx { namespace d3d12
m_type = Texture2D;
}
- m_numMips = numMips;
- const uint16_t numSides = numLayers * (imageContainer.m_cubeMap ? 6 : 1);
- const uint32_t numSrd = numSides * numMips;
+ m_numMips = ti.numMips;
+ const uint16_t numSides = ti.numLayers * (imageContainer.m_cubeMap ? 6 : 1);
+ const uint32_t numSrd = numSides * ti.numMips;
D3D12_SUBRESOURCE_DATA* srd = (D3D12_SUBRESOURCE_DATA*)alloca(numSrd*sizeof(D3D12_SUBRESOURCE_DATA) );
uint32_t kk = 0;
@@ -4567,8 +4658,8 @@ namespace bgfx { namespace d3d12
, this - s_renderD3D12->m_textures
, getName( (TextureFormat::Enum)m_textureFormat)
, getName( (TextureFormat::Enum)m_requestedFormat)
- , textureWidth
- , textureHeight
+ , ti.width
+ , ti.height
, imageContainer.m_cubeMap ? "x6" : ""
, renderTarget ? 'x' : ' '
, writeOnly ? 'x' : ' '
@@ -4578,7 +4669,7 @@ namespace bgfx { namespace d3d12
for (uint8_t side = 0; side < numSides; ++side)
{
- for (uint8_t lod = 0; lod < numMips; ++lod)
+ for (uint8_t lod = 0; lod < ti.numMips; ++lod)
{
bimg::ImageMip mip;
if (bimg::imageGetRawData(imageContainer, side, lod+startLod, _mem->data, _mem->size, mip) )
@@ -4667,9 +4758,9 @@ namespace bgfx { namespace d3d12
D3D12_RESOURCE_DESC resourceDesc;
resourceDesc.Alignment = 1 < msaa.Count ? D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT : 0;
- resourceDesc.Width = textureWidth;
- resourceDesc.Height = textureHeight;
- resourceDesc.MipLevels = numMips;
+ resourceDesc.Width = ti.width;
+ resourceDesc.Height = ti.height;
+ resourceDesc.MipLevels = ti.numMips;
resourceDesc.Format = format;
resourceDesc.SampleDesc = msaa;
resourceDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
@@ -4730,56 +4821,40 @@ namespace bgfx { namespace d3d12
switch (m_type)
{
case Texture2D:
- case TextureCube:
resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
- if (imageContainer.m_cubeMap)
+
+ if (1 < ti.numLayers)
{
- if (1 < numLayers)
- {
- m_srvd.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBEARRAY;
- m_srvd.TextureCubeArray.MostDetailedMip = 0;
- m_srvd.TextureCubeArray.MipLevels = numMips;
- m_srvd.TextureCubeArray.ResourceMinLODClamp = 0.0f;
- m_srvd.TextureCubeArray.NumCubes = numLayers;
- }
- else
- {
- m_srvd.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBE;
- m_srvd.TextureCube.MostDetailedMip = 0;
- m_srvd.TextureCube.MipLevels = numMips;
- m_srvd.TextureCube.ResourceMinLODClamp = 0.0f;
- }
+ m_srvd.ViewDimension = 1 < msaa.Count
+ ? D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY
+ : D3D12_SRV_DIMENSION_TEXTURE2DARRAY
+ ;
+ m_srvd.Texture2DArray.MostDetailedMip = 0;
+ m_srvd.Texture2DArray.MipLevels = ti.numMips;
+ m_srvd.Texture2DArray.FirstArraySlice = 0;
+ m_srvd.Texture2DArray.ArraySize = ti.numLayers;
+ m_srvd.Texture2DArray.PlaneSlice = 0;
+ m_srvd.Texture2DArray.ResourceMinLODClamp = 0.0f;
}
else
{
- if (1 < numLayers)
- {
- m_srvd.ViewDimension = 1 < msaa.Count
- ? D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY
- : D3D12_SRV_DIMENSION_TEXTURE2DARRAY
- ;
- m_srvd.Texture2DArray.MostDetailedMip = 0;
- m_srvd.Texture2DArray.MipLevels = numMips;
- m_srvd.Texture2DArray.ResourceMinLODClamp = 0.0f;
- m_srvd.Texture2DArray.ArraySize = numLayers;
- }
- else
- {
- m_srvd.ViewDimension = 1 < msaa.Count
- ? D3D12_SRV_DIMENSION_TEXTURE2DMS
- : D3D12_SRV_DIMENSION_TEXTURE2D
- ;
- m_srvd.Texture2D.MostDetailedMip = 0;
- m_srvd.Texture2D.MipLevels = numMips;
- m_srvd.Texture2D.ResourceMinLODClamp = 0.0f;
- }
+ m_srvd.ViewDimension = 1 < msaa.Count
+ ? D3D12_SRV_DIMENSION_TEXTURE2DMS
+ : D3D12_SRV_DIMENSION_TEXTURE2D
+ ;
+ m_srvd.Texture2D.MostDetailedMip = 0;
+ m_srvd.Texture2D.MipLevels = ti.numMips;
+ m_srvd.Texture2D.PlaneSlice = 0;
+ m_srvd.Texture2D.ResourceMinLODClamp = 0.0f;
}
- if (1 < numLayers)
+ if (1 < ti.numLayers)
{
m_uavd.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY;
- m_uavd.Texture2DArray.MipSlice = 0;
- m_uavd.Texture2DArray.PlaneSlice = 0;
+ m_uavd.Texture2DArray.MipSlice = 0;
+ m_uavd.Texture2DArray.FirstArraySlice = 0;
+ m_uavd.Texture2DArray.ArraySize = ti.numLayers;
+ m_uavd.Texture2DArray.PlaneSlice = 0;
}
else
{
@@ -4787,14 +4862,6 @@ namespace bgfx { namespace d3d12
m_uavd.Texture2D.MipSlice = 0;
m_uavd.Texture2D.PlaneSlice = 0;
}
-
- if (TextureCube == m_type)
- {
- m_uavd.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY;
- m_uavd.Texture2DArray.MipSlice = 0;
- m_uavd.Texture2DArray.ArraySize = 6;
- }
-
break;
case Texture3D:
@@ -4802,13 +4869,39 @@ namespace bgfx { namespace d3d12
resourceDesc.DepthOrArraySize = uint16_t(m_depth);
m_srvd.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE3D;
m_srvd.Texture3D.MostDetailedMip = 0;
- m_srvd.Texture3D.MipLevels = numMips;
+ m_srvd.Texture3D.MipLevels = ti.numMips;
m_srvd.Texture3D.ResourceMinLODClamp = 0.0f;
m_uavd.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE3D;
m_uavd.Texture3D.MipSlice = 0;
m_uavd.Texture3D.FirstWSlice = 0;
- m_uavd.Texture3D.WSize = 0;
+ m_uavd.Texture3D.WSize = m_depth;
+ break;
+
+ case TextureCube:
+ resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
+
+ if (1 < ti.numLayers)
+ {
+ m_srvd.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBEARRAY;
+ m_srvd.TextureCubeArray.MostDetailedMip = 0;
+ m_srvd.TextureCubeArray.MipLevels = ti.numMips;
+ m_srvd.TextureCubeArray.ResourceMinLODClamp = 0.0f;
+ m_srvd.TextureCubeArray.NumCubes = ti.numLayers;
+ }
+ else
+ {
+ m_srvd.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBE;
+ m_srvd.TextureCube.MostDetailedMip = 0;
+ m_srvd.TextureCube.MipLevels = ti.numMips;
+ m_srvd.TextureCube.ResourceMinLODClamp = 0.0f;
+ }
+
+ m_uavd.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY;
+ m_uavd.Texture2DArray.MipSlice = 0;
+ m_uavd.Texture2DArray.FirstArraySlice = 0;
+ m_uavd.Texture2DArray.ArraySize = 6;
+ m_uavd.Texture2DArray.PlaneSlice = 0;
break;
}
@@ -4853,7 +4946,7 @@ namespace bgfx { namespace d3d12
kk = 0;
for (uint8_t side = 0; side < numSides; ++side)
{
- for (uint32_t lod = 0, num = numMips; lod < num; ++lod)
+ for (uint32_t lod = 0, num = ti.numMips; lod < num; ++lod)
{
BX_FREE(g_allocator, const_cast<void*>(srd[kk].pData) );
++kk;
@@ -4977,10 +5070,11 @@ namespace bgfx { namespace d3d12
#if BX_PLATFORM_WINDOWS
SwapChainDesc scd;
bx::memCopy(&scd, &s_renderD3D12->m_scd, sizeof(DXGI_SWAP_CHAIN_DESC) );
- scd.format = TextureFormat::Count == _format ? scd.format : s_textureFormat[_format].m_fmt;
- scd.width = _width;
- scd.height = _height;
- scd.nwh = _nwh;
+ scd.format = TextureFormat::Count == _format ? scd.format : s_textureFormat[_format].m_fmt;
+ scd.width = _width;
+ scd.height = _height;
+ scd.nwh = _nwh;
+ scd.sampleDesc = s_msaa[0];
HRESULT hr;
hr = s_renderD3D12->m_dxgi.createSwapChain(
@@ -5135,9 +5229,20 @@ namespace bgfx { namespace d3d12
// }
// else
{
- desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
- desc.Texture2D.MipSlice = at.mip;
- desc.Texture2D.PlaneSlice = 0;
+ if (1 < texture.m_numLayers)
+ {
+ desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DARRAY;
+ desc.Texture2DArray.FirstArraySlice = at.layer;
+ desc.Texture2DArray.ArraySize = 1;
+ desc.Texture2DArray.MipSlice = at.mip;
+ desc.Texture2DArray.PlaneSlice = 0;
+ }
+ else
+ {
+ desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
+ desc.Texture2D.MipSlice = at.mip;
+ desc.Texture2D.PlaneSlice = 0;
+ }
}
break;
@@ -5613,8 +5718,6 @@ namespace bgfx { namespace d3d12
void RendererContextD3D12::submit(Frame* _render, ClearQuad& /*_clearQuad*/, TextVideoMemBlitter& _textVideoMemBlitter)
{
- PIX3_BEGINEVENT(m_commandList, D3DCOLOR_FRAME, "rendererSubmit");
-
if (m_lost
|| updateResolution(_render->m_resolution) )
{
@@ -5626,6 +5729,8 @@ namespace bgfx { namespace d3d12
renderDocTriggerCapture();
}
+ BGFX_D3D12_PROFILER_BEGIN_LITERAL("rendererSubmit", kColorFrame);
+
int64_t timeBegin = bx::getHPCounter();
int64_t captureElapsed = 0;
@@ -5633,12 +5738,14 @@ namespace bgfx { namespace d3d12
if (0 < _render->m_iboffset)
{
+ BGFX_PROFILER_SCOPE("bgfx/Update transient index buffer", kColorResource);
TransientIndexBuffer* ib = _render->m_transientIb;
m_indexBuffers[ib->handle.idx].update(m_commandList, 0, _render->m_iboffset, ib->data);
}
if (0 < _render->m_vboffset)
{
+ BGFX_PROFILER_SCOPE("bgfx/Update transient vertex buffer", kColorResource);
TransientVertexBuffer* vb = _render->m_transientVb;
m_vertexBuffers[vb->handle.idx].update(m_commandList, 0, _render->m_vboffset, vb->data);
}
@@ -5653,15 +5760,14 @@ namespace bgfx { namespace d3d12
RenderBind currentBind;
currentBind.clear();
- const bool hmdEnabled = false;
static ViewState viewState;
- viewState.reset(_render, hmdEnabled);
+ viewState.reset(_render);
// bool wireframe = !!(_render->m_debug&BGFX_DEBUG_WIREFRAME);
// setDebugWireframe(wireframe);
uint16_t currentSamplerStateIdx = kInvalidHandle;
- uint16_t currentProgramIdx = kInvalidHandle;
+ ProgramHandle currentProgram = BGFX_INVALID_HANDLE;
uint32_t currentBindHash = 0;
bool hasPredefined = false;
bool commandListChanged = false;
@@ -5753,12 +5859,10 @@ namespace bgfx { namespace d3d12
m_batch.begin();
-// uint8_t eye = 0;
-// uint8_t restartState = 0;
viewState.m_rect = _render->m_view[0].m_rect;
-
int32_t numItems = _render->m_numRenderItems;
- for (int32_t item = 0, restartItem = numItems; item < numItems || restartItem < numItems;)
+
+ for (int32_t item = 0; item < numItems;)
{
const uint64_t encodedKey = _render->m_sortKeys[item];
const bool isCompute = key.decode(encodedKey, _render->m_viewRemap);
@@ -5784,19 +5888,23 @@ namespace bgfx { namespace d3d12
view = key.m_view;
currentPso = NULL;
currentSamplerStateIdx = kInvalidHandle;
- currentProgramIdx = kInvalidHandle;
+ currentProgram = BGFX_INVALID_HANDLE;
hasPredefined = false;
- fbh = _render->m_view[view].m_fbh;
- setFrameBuffer(fbh);
-
if (item > 1)
{
profiler.end();
}
+ BGFX_D3D12_PROFILER_END();
+ setViewType(view, " ");
+ BGFX_D3D12_PROFILER_BEGIN(view, kColorView);
+
profiler.begin(view);
+ fbh = _render->m_view[view].m_fbh;
+ setFrameBuffer(fbh);
+
viewState.m_rect = _render->m_view[view].m_rect;
const Rect& rect = _render->m_view[view].m_rect;
const Rect& scissorRect = _render->m_view[view].m_scissor;
@@ -5839,13 +5947,9 @@ namespace bgfx { namespace d3d12
{
wasCompute = true;
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
- {
- char* viewName = s_viewName[view];
- viewName[3] = L'C';
- PIX3_ENDEVENT(m_commandList);
- PIX3_BEGINEVENT(m_commandList, D3DCOLOR_COMPUTE, viewName);
- }
+ setViewType(view, "C");
+ BGFX_D3D12_PROFILER_END();
+ BGFX_D3D12_PROFILER_BEGIN(view, kColorCompute);
commandListChanged = true;
}
@@ -5880,90 +5984,100 @@ namespace bgfx { namespace d3d12
Bind* bindCached = bindLru.find(bindHash);
if (NULL == bindCached)
{
+ uint32_t numSet = 0;
D3D12_GPU_DESCRIPTOR_HANDLE srvHandle[BGFX_MAX_COMPUTE_BINDINGS] = {};
uint32_t samplerFlags[BGFX_MAX_COMPUTE_BINDINGS] = {};
-
- for (uint8_t stage = 0; stage < maxComputeBindings; ++stage)
{
- const Binding& bind = renderBind.m_bind[stage];
- if (kInvalidHandle != bind.m_idx)
+ for (uint8_t stage = 0; stage < maxComputeBindings; ++stage)
{
- switch (bind.m_type)
+ const Binding& bind = renderBind.m_bind[stage];
+ if (kInvalidHandle != bind.m_idx)
{
- case Binding::Image:
+ switch (bind.m_type)
{
- TextureD3D12& texture = m_textures[bind.m_idx];
-
- if (Access::Read != bind.m_access)
+ case Binding::Image:
{
- texture.setState(m_commandList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
- scratchBuffer.allocUav(srvHandle[stage], texture, bind.m_mip);
+ TextureD3D12& texture = m_textures[bind.m_idx];
+
+ if (Access::Read != bind.m_access)
+ {
+ texture.setState(m_commandList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
+ scratchBuffer.allocUav(srvHandle[stage], texture, bind.m_mip);
+ }
+ else
+ {
+ texture.setState(m_commandList, D3D12_RESOURCE_STATE_GENERIC_READ);
+ scratchBuffer.allocSrv(srvHandle[stage], texture, bind.m_mip);
+ samplerFlags[stage] = uint32_t(texture.m_flags);
+ }
+
+ ++numSet;
}
- else
+ break;
+
+ case Binding::Texture:
{
+ TextureD3D12& texture = m_textures[bind.m_idx];
texture.setState(m_commandList, D3D12_RESOURCE_STATE_GENERIC_READ);
- scratchBuffer.allocSrv(srvHandle[stage], texture, bind.m_mip);
- samplerFlags[stage] = uint32_t(texture.m_flags);
+ scratchBuffer.allocSrv(srvHandle[stage], texture);
+ samplerFlags[stage] = (0 == (BGFX_SAMPLER_INTERNAL_DEFAULT & bind.m_samplerFlags)
+ ? bind.m_samplerFlags
+ : texture.m_flags
+ ) & (BGFX_SAMPLER_BITS_MASK | BGFX_SAMPLER_BORDER_COLOR_MASK | BGFX_SAMPLER_COMPARE_MASK)
+ ;
+
+ ++numSet;
}
- }
- break;
+ break;
- case Binding::Texture:
- {
- TextureD3D12& texture = m_textures[bind.m_idx];
- texture.setState(m_commandList, D3D12_RESOURCE_STATE_GENERIC_READ);
- scratchBuffer.allocSrv(srvHandle[stage], texture);
- samplerFlags[stage] = (0 == (BGFX_SAMPLER_INTERNAL_DEFAULT & bind.m_samplerFlags)
- ? bind.m_samplerFlags
- : texture.m_flags
- ) & (BGFX_SAMPLER_BITS_MASK | BGFX_SAMPLER_BORDER_COLOR_MASK | BGFX_SAMPLER_COMPARE_MASK)
- ;
- }
- break;
+ case Binding::IndexBuffer:
+ case Binding::VertexBuffer:
+ {
+ BufferD3D12& buffer = Binding::IndexBuffer == bind.m_type
+ ? m_indexBuffers[bind.m_idx]
+ : m_vertexBuffers[bind.m_idx]
+ ;
- case Binding::IndexBuffer:
- case Binding::VertexBuffer:
- {
- BufferD3D12& buffer = Binding::IndexBuffer == bind.m_type
- ? m_indexBuffers[bind.m_idx]
- : m_vertexBuffers[bind.m_idx]
- ;
+ if (Access::Read != bind.m_access)
+ {
+ buffer.setState(m_commandList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
+ scratchBuffer.allocUav(srvHandle[stage], buffer);
+ }
+ else
+ {
+ buffer.setState(m_commandList, D3D12_RESOURCE_STATE_GENERIC_READ);
+ scratchBuffer.allocSrv(srvHandle[stage], buffer);
+ }
- if (Access::Read != bind.m_access)
- {
- buffer.setState(m_commandList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
- scratchBuffer.allocUav(srvHandle[stage], buffer);
- }
- else
- {
- buffer.setState(m_commandList, D3D12_RESOURCE_STATE_GENERIC_READ);
- scratchBuffer.allocSrv(srvHandle[stage], buffer);
+ ++numSet;
}
+ break;
}
- break;
+ }
+ else
+ {
+ samplerFlags[stage] = 0;
+ scratchBuffer.allocEmpty(srvHandle[stage]);
}
}
- else
+
+ if (0 != numSet)
{
- samplerFlags[stage] = 0;
- scratchBuffer.allocEmpty(srvHandle[stage]);
- }
- }
+ Bind bind;
+ bind.m_srvHandle = srvHandle[0];
+ bind.m_samplerStateIdx = getSamplerState(samplerFlags, maxComputeBindings, _render->m_colorPalette);
+ bindCached = bindLru.add(bindHash, bind, 0);
- uint16_t samplerStateIdx = getSamplerState(samplerFlags, maxComputeBindings, _render->m_colorPalette);
- if (samplerStateIdx != currentSamplerStateIdx)
- {
- currentSamplerStateIdx = samplerStateIdx;
- m_commandList->SetComputeRootDescriptorTable(Rdt::Sampler, m_samplerAllocator.get(samplerStateIdx) );
+ uint16_t samplerStateIdx = bindCached->m_samplerStateIdx;
+ if (samplerStateIdx != currentSamplerStateIdx)
+ {
+ currentSamplerStateIdx = samplerStateIdx;
+ m_commandList->SetComputeRootDescriptorTable(Rdt::Sampler, m_samplerAllocator.get(samplerStateIdx) );
+ }
+ m_commandList->SetComputeRootDescriptorTable(Rdt::SRV, bindCached->m_srvHandle);
+ m_commandList->SetComputeRootDescriptorTable(Rdt::UAV, bindCached->m_srvHandle);
+ }
}
-
- m_commandList->SetComputeRootDescriptorTable(Rdt::SRV, srvHandle[0]);
- m_commandList->SetComputeRootDescriptorTable(Rdt::UAV, srvHandle[0]);
-
- Bind bind;
- bind.m_srvHandle = srvHandle[0];
- bind.m_samplerStateIdx = samplerStateIdx;
- bindLru.add(bindHash, bind, 0);
}
else
{
@@ -5980,12 +6094,12 @@ namespace bgfx { namespace d3d12
bool constantsChanged = false;
if (compute.m_uniformBegin < compute.m_uniformEnd
- || currentProgramIdx != key.m_program)
+ || currentProgram.idx != key.m_program.idx)
{
rendererUpdateUniforms(this, _render->m_uniformBuffer[compute.m_uniformIdx], compute.m_uniformBegin, compute.m_uniformEnd);
- currentProgramIdx = key.m_program;
- ProgramD3D12& program = m_program[currentProgramIdx];
+ currentProgram = key.m_program;
+ ProgramD3D12& program = m_program[currentProgram.idx];
UniformBuffer* vcb = program.m_vsh->m_constantBuffer;
if (NULL != vcb)
@@ -6000,8 +6114,8 @@ namespace bgfx { namespace d3d12
if (constantsChanged
|| hasPredefined)
{
- ProgramD3D12& program = m_program[currentProgramIdx];
- viewState.setPredefined<4>(this, view, 0, program, _render, compute);
+ ProgramD3D12& program = m_program[currentProgram.idx];
+ viewState.setPredefined<4>(this, view, program, _render, compute);
commitShaderConstants(key.m_program, gpuAddress);
m_commandList->SetComputeRootConstantBufferView(Rdt::CBV, gpuAddress);
}
@@ -6038,14 +6152,9 @@ namespace bgfx { namespace d3d12
{
wasCompute = false;
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
- {
- BX_UNUSED(s_viewName);
- char* viewName = s_viewName[view];
- viewName[3] = ' ';
- PIX3_ENDEVENT(m_commandList);
- PIX3_BEGINEVENT(m_commandList, D3DCOLOR_DRAW, viewName);
- }
+ setViewType(view, " ");
+ BGFX_D3D12_PROFILER_END();
+ BGFX_D3D12_PROFILER_BEGIN(view, kColorDraw);
commandListChanged = true;
}
@@ -6113,7 +6222,7 @@ namespace bgfx { namespace d3d12
currentPso = NULL;
currentBindHash = 0;
currentSamplerStateIdx = kInvalidHandle;
- currentProgramIdx = kInvalidHandle;
+ currentProgram = BGFX_INVALID_HANDLE;
currentState.clear();
currentState.m_scissor = !draw.m_scissor;
changedFlags = BGFX_STATE_MASK;
@@ -6145,29 +6254,32 @@ namespace bgfx { namespace d3d12
|| f3 == (state & f3)
;
- const VertexDecl* decls[BGFX_CONFIG_MAX_VERTEX_STREAMS];
+ const VertexLayout* layouts[BGFX_CONFIG_MAX_VERTEX_STREAMS];
uint8_t numStreams = 0;
if (UINT8_MAX != draw.m_streamMask)
{
- for (uint32_t idx = 0, streamMask = draw.m_streamMask, ntz = bx::uint32_cnttz(streamMask)
+ for (uint32_t idx = 0, streamMask = draw.m_streamMask
; 0 != streamMask
- ; streamMask >>= 1, idx += 1, ntz = bx::uint32_cnttz(streamMask), ++numStreams
+ ; streamMask >>= 1, idx += 1, ++numStreams
)
{
+ const uint32_t ntz = bx::uint32_cnttz(streamMask);
streamMask >>= ntz;
- idx += ntz;
+ idx += ntz;
- currentState.m_stream[idx].m_decl = draw.m_stream[idx].m_decl;
- currentState.m_stream[idx].m_handle = draw.m_stream[idx].m_handle;
- currentState.m_stream[idx].m_startVertex = draw.m_stream[idx].m_startVertex;
+ currentState.m_stream[idx].m_layoutHandle = draw.m_stream[idx].m_layoutHandle;
+ currentState.m_stream[idx].m_handle = draw.m_stream[idx].m_handle;
+ currentState.m_stream[idx].m_startVertex = draw.m_stream[idx].m_startVertex;
uint16_t handle = draw.m_stream[idx].m_handle.idx;
const VertexBufferD3D12& vb = m_vertexBuffers[handle];
- uint16_t decl = !isValid(vb.m_decl) ? draw.m_stream[idx].m_decl.idx : vb.m_decl.idx;
- const VertexDecl& vertexDecl = m_vertexDecls[decl];
+ const uint16_t layoutIdx = isValid(draw.m_stream[idx].m_layoutHandle)
+ ? draw.m_stream[idx].m_layoutHandle.idx
+ : vb.m_layoutHandle.idx;
+ const VertexLayout& layout = m_vertexLayouts[layoutIdx];
- decls[numStreams] = &vertexDecl;
+ layouts[numStreams] = &layout;
}
}
@@ -6175,7 +6287,7 @@ namespace bgfx { namespace d3d12
getPipelineState(state
, draw.m_stencil
, numStreams
- , decls
+ , layouts
, key.m_program
, uint8_t(draw.m_instanceDataStride/16)
);
@@ -6263,20 +6375,20 @@ namespace bgfx { namespace d3d12
if (0 != numSet)
{
- uint16_t samplerStateIdx = getSamplerState(samplerFlags, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, _render->m_colorPalette);
+ Bind bind;
+ bind.m_srvHandle = srvHandle[0];
+ bind.m_samplerStateIdx = getSamplerState(samplerFlags, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, _render->m_colorPalette);
+ bindCached = bindLru.add(bindHash, bind, 0);
+
+ uint16_t samplerStateIdx = bindCached->m_samplerStateIdx;
if (samplerStateIdx != currentSamplerStateIdx)
{
currentSamplerStateIdx = samplerStateIdx;
m_commandList->SetGraphicsRootDescriptorTable(Rdt::Sampler, m_samplerAllocator.get(samplerStateIdx) );
}
- m_commandList->SetGraphicsRootDescriptorTable(Rdt::SRV, srvHandle[0]);
- m_commandList->SetGraphicsRootDescriptorTable(Rdt::UAV, srvHandle[0]);
-
- Bind bind;
- bind.m_srvHandle = srvHandle[0];
- bind.m_samplerStateIdx = samplerStateIdx;
- bindLru.add(bindHash, bind, 0);
+ m_commandList->SetGraphicsRootDescriptorTable(Rdt::SRV, bindCached->m_srvHandle);
+ m_commandList->SetGraphicsRootDescriptorTable(Rdt::UAV, bindCached->m_srvHandle);
}
}
else
@@ -6366,11 +6478,11 @@ namespace bgfx { namespace d3d12
}
if (constantsChanged
- || currentProgramIdx != key.m_program
+ || currentProgram.idx != key.m_program.idx
|| BGFX_STATE_ALPHA_REF_MASK & changedFlags)
{
- currentProgramIdx = key.m_program;
- ProgramD3D12& program = m_program[currentProgramIdx];
+ currentProgram = key.m_program;
+ ProgramD3D12& program = m_program[currentProgram.idx];
UniformBuffer* vcb = program.m_vsh->m_constantBuffer;
if (NULL != vcb)
@@ -6394,10 +6506,10 @@ namespace bgfx { namespace d3d12
if (constantsChanged
|| hasPredefined)
{
- ProgramD3D12& program = m_program[currentProgramIdx];
+ ProgramD3D12& program = m_program[currentProgram.idx];
uint32_t ref = (newFlags&BGFX_STATE_ALPHA_REF_MASK)>>BGFX_STATE_ALPHA_REF_SHIFT;
viewState.m_alphaRef = ref/255.0f;
- viewState.setPredefined<4>(this, view, 0, program, _render, draw);
+ viewState.setPredefined<4>(this, view, program, _render, draw);
commitShaderConstants(key.m_program, gpuAddress);
}
@@ -6424,13 +6536,9 @@ namespace bgfx { namespace d3d12
if (wasCompute)
{
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
- {
- char* viewName = s_viewName[view];
- viewName[3] = L'C';
- PIX3_ENDEVENT(m_commandList);
- PIX3_BEGINEVENT(m_commandList, D3DCOLOR_DRAW, viewName);
- }
+ setViewType(view, "C");
+ BGFX_D3D12_PROFILER_END();
+ BGFX_D3D12_PROFILER_BEGIN(view, kColorCompute);
}
submitBlit(bs, BGFX_CONFIG_MAX_VIEWS);
@@ -6450,7 +6558,7 @@ namespace bgfx { namespace d3d12
}
}
- PIX3_ENDEVENT(m_commandList);
+ BGFX_D3D12_PROFILER_END();
int64_t timeEnd = bx::getHPCounter();
int64_t frameTime = timeEnd - timeBegin;
@@ -6512,7 +6620,7 @@ namespace bgfx { namespace d3d12
if (_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) )
{
- PIX3_BEGINEVENT(m_commandList, D3DCOLOR_FRAME, "debugstats");
+ BGFX_D3D12_PROFILER_BEGIN_LITERAL("debugstats", kColorFrame);
// m_needPresent = true;
TextVideoMem& tvm = m_textVideoMem;
@@ -6676,15 +6784,15 @@ namespace bgfx { namespace d3d12
blit(this, _textVideoMemBlitter, tvm);
- PIX3_ENDEVENT(m_commandList);
+ BGFX_D3D12_PROFILER_END();
}
else if (_render->m_debug & BGFX_DEBUG_TEXT)
{
- PIX3_BEGINEVENT(m_commandList, D3DCOLOR_FRAME, "debugtext");
+ BGFX_D3D12_PROFILER_BEGIN_LITERAL("debugtext", kColorFrame);
blit(this, _textVideoMemBlitter, _render->m_textVideoMem);
- PIX3_ENDEVENT(m_commandList);
+ BGFX_D3D12_PROFILER_END();
}
m_commandList->OMSetRenderTargets(0, NULL, false, NULL);
diff --git a/3rdparty/bgfx/src/renderer_d3d12.h b/3rdparty/bgfx/src/renderer_d3d12.h
index 216159f37d4..aee806db3ca 100644
--- a/3rdparty/bgfx/src/renderer_d3d12.h
+++ b/3rdparty/bgfx/src/renderer_d3d12.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -52,7 +52,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
#include "nvapi.h"
#include "dxgi.h"
-#if BGFX_CONFIG_DEBUG_PIX
+#if BGFX_CONFIG_DEBUG_ANNOTATION
# if BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT
typedef struct PIXEventsThreadInfo* (WINAPI* PFN_PIX_GET_THREAD_INFO)();
typedef uint64_t (WINAPI* PFN_PIX_EVENTS_REPLACE_BLOCK)(bool _getEarliestTime);
@@ -80,7 +80,25 @@ extern "C" uint64_t WINAPI bgfx_PIXEventsReplaceBlock(bool _g
# define PIX3_BEGINEVENT(_commandList, _color, _name) BX_UNUSED(_commandList, _color, _name)
# define PIX3_SETMARKER(_commandList, _color, _name) BX_UNUSED(_commandList, _color, _name)
# define PIX3_ENDEVENT(_commandList) BX_UNUSED(_commandList)
-#endif // BGFX_CONFIG_DEBUG_PIX
+#endif // BGFX_CONFIG_DEBUG_ANNOTATION
+
+#define BGFX_D3D12_PROFILER_BEGIN(_view, _abgr) \
+ BX_MACRO_BLOCK_BEGIN \
+ PIX3_BEGINEVENT(m_commandList, _abgr, s_viewName[_view]); \
+ BGFX_PROFILER_BEGIN(s_viewName[view], _abgr); \
+ BX_MACRO_BLOCK_END
+
+#define BGFX_D3D12_PROFILER_BEGIN_LITERAL(_name, _abgr) \
+ BX_MACRO_BLOCK_BEGIN \
+ PIX3_BEGINEVENT(m_commandList, _abgr, "" # _name); \
+ BGFX_PROFILER_BEGIN_LITERAL("" # _name, _abgr); \
+ BX_MACRO_BLOCK_END
+
+#define BGFX_D3D12_PROFILER_END() \
+ BX_MACRO_BLOCK_BEGIN \
+ BGFX_PROFILER_END(); \
+ PIX3_ENDEVENT(m_commandList); \
+ BX_MACRO_BLOCK_END
namespace bgfx { namespace d3d12
{
@@ -206,9 +224,9 @@ namespace bgfx { namespace d3d12
struct VertexBufferD3D12 : public BufferD3D12
{
- void create(uint32_t _size, void* _data, VertexDeclHandle _declHandle, uint16_t _flags);
+ void create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle, uint16_t _flags);
- VertexDeclHandle m_decl;
+ VertexLayoutHandle m_layoutHandle;
};
struct ShaderD3D12
@@ -326,6 +344,7 @@ namespace bgfx { namespace d3d12
uint32_t m_width;
uint32_t m_height;
uint32_t m_depth;
+ uint32_t m_numLayers;
uint16_t m_samplerIdx;
uint8_t m_type;
uint8_t m_requestedFormat;
diff --git a/3rdparty/bgfx/src/renderer_d3d9.cpp b/3rdparty/bgfx/src/renderer_d3d9.cpp
index 21dbef68ff2..3f4273a778b 100644
--- a/3rdparty/bgfx/src/renderer_d3d9.cpp
+++ b/3rdparty/bgfx/src/renderer_d3d9.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -12,7 +12,7 @@
namespace bgfx { namespace d3d9
{
static wchar_t s_viewNameW[BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME];
- static char s_viewName[BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME];
+ static char s_viewName [BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME];
struct PrimInfo
{
@@ -335,25 +335,25 @@ namespace bgfx { namespace d3d9
};
BX_STATIC_ASSERT(AttribType::Count == BX_COUNTOF(s_attribType) );
- static D3DVERTEXELEMENT9* fillVertexDecl(uint8_t _stream, D3DVERTEXELEMENT9* _out, const VertexDecl& _decl)
+ static D3DVERTEXELEMENT9* fillVertexLayout(uint8_t _stream, D3DVERTEXELEMENT9* _out, const VertexLayout& _layout)
{
D3DVERTEXELEMENT9* elem = _out;
for (uint32_t attr = 0; attr < Attrib::Count; ++attr)
{
- if (UINT16_MAX != _decl.m_attributes[attr])
+ if (UINT16_MAX != _layout.m_attributes[attr])
{
uint8_t num;
AttribType::Enum type;
bool normalized;
bool asInt;
- _decl.decode(Attrib::Enum(attr), num, type, normalized, asInt);
+ _layout.decode(Attrib::Enum(attr), num, type, normalized, asInt);
bx::memCopy(elem, &s_attrib[attr], sizeof(D3DVERTEXELEMENT9) );
elem->Stream = _stream;
elem->Type = s_attribType[type][num-1][normalized];
- elem->Offset = _decl.m_offset[attr];
+ elem->Offset = _layout.m_offset[attr];
++elem;
}
}
@@ -373,6 +373,35 @@ namespace bgfx { namespace d3d9
;
}
+ inline bool useD3D9Pitch(bimg::TextureFormat::Enum _format)
+ {
+ // Reference(s):
+ // - For BC4 and B5 in DX9 LockRect returns wrong number of
+ // bytes. If actual mip size is used it causes memory corruption.
+ // https://web.archive.org/web/20190207230133/http://www.aras-p.info/texts/D3D9GPUHacks.html
+ return true
+ && _format != bimg::TextureFormat::BC4
+ && _format != bimg::TextureFormat::BC5
+ ;
+ }
+
+ static inline uint32_t calcRowPitch(const bimg::ImageBlockInfo& _blockInfo, uint8_t _lod, uint32_t _width)
+ {
+ const uint8_t blockWidth = _blockInfo.blockWidth;
+ const uint8_t blockHeight = _blockInfo.blockHeight;
+ const uint8_t minBlockX = _blockInfo.minBlockX;
+ const uint8_t bitsPerPixel = _blockInfo.bitsPerPixel;
+
+ // Calculate the row pitch
+ const uint32_t minBlkWidth = minBlockX;
+ const uint32_t lodBlkWidth = (((_width >> _lod) + blockWidth - 1) / blockWidth);
+ const uint32_t rowBlkWidth = bx::max<uint32_t>(minBlkWidth, lodBlkWidth);
+ const uint32_t pixBlkWidth = rowBlkWidth * blockWidth * blockHeight;
+ const uint32_t rowPitch = pixBlkWidth * bitsPerPixel / 8u;
+
+ return rowPitch;
+ }
+
struct RendererContextD3D9 : public RendererContextI
{
RendererContextD3D9()
@@ -420,7 +449,8 @@ namespace bgfx { namespace d3d9
D3DFORMAT adapterFormat = D3DFMT_X8R8G8B8;
- // http://msdn.microsoft.com/en-us/library/windows/desktop/bb172588%28v=vs.85%29.aspx
+ // Reference(s):
+ // - https://web.archive.org/web/20190207230309/https://docs.microsoft.com/en-us/windows/desktop/direct3d9/d3dpresent-parameters
bx::memSet(&m_params, 0, sizeof(m_params) );
m_params.BackBufferWidth = _init.resolution.width;
m_params.BackBufferHeight = _init.resolution.height;
@@ -455,17 +485,22 @@ namespace bgfx { namespace d3d9
m_nvapi.init();
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
{
D3DPERF_SetMarker = (PFN_D3DPERF_SET_MARKER )bx::dlsym(m_d3d9Dll, "D3DPERF_SetMarker");
D3DPERF_BeginEvent = (PFN_D3DPERF_BEGIN_EVENT)bx::dlsym(m_d3d9Dll, "D3DPERF_BeginEvent");
D3DPERF_EndEvent = (PFN_D3DPERF_END_EVENT )bx::dlsym(m_d3d9Dll, "D3DPERF_EndEvent");
- BX_CHECK(NULL != D3DPERF_SetMarker
- && NULL != D3DPERF_BeginEvent
- && NULL != D3DPERF_EndEvent
- , "Failed to initialize PIX events."
- );
+ if (NULL == D3DPERF_SetMarker
+ || NULL == D3DPERF_BeginEvent
+ || NULL == D3DPERF_EndEvent)
+ {
+ BX_TRACE("Failed to initialize PIX events.");
+
+ D3DPERF_SetMarker = NULL;
+ D3DPERF_BeginEvent = NULL;
+ D3DPERF_EndEvent = NULL;
+ }
}
m_d3d9ex = NULL;
@@ -963,20 +998,20 @@ namespace bgfx { namespace d3d9
m_indexBuffers[_handle.idx].destroy();
}
- void createVertexDecl(VertexDeclHandle _handle, const VertexDecl& _decl) override
+ void createVertexLayout(VertexLayoutHandle _handle, const VertexLayout& _layout) override
{
- VertexDecl& decl = m_vertexDecls[_handle.idx];
- bx::memCopy(&decl, &_decl, sizeof(VertexDecl) );
- dump(decl);
+ VertexLayout& layout = m_vertexLayouts[_handle.idx];
+ bx::memCopy(&layout, &_layout, sizeof(VertexLayout) );
+ dump(layout);
}
- void destroyVertexDecl(VertexDeclHandle /*_handle*/) override
+ void destroyVertexLayout(VertexLayoutHandle /*_handle*/) override
{
}
- void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexDeclHandle _declHandle, uint16_t /*_flags*/) override
+ void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexLayoutHandle _layoutHandle, uint16_t /*_flags*/) override
{
- m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _declHandle);
+ m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _layoutHandle);
}
void destroyVertexBuffer(VertexBufferHandle _handle) override
@@ -1001,8 +1036,8 @@ namespace bgfx { namespace d3d9
void createDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size, uint16_t /*_flags*/) override
{
- VertexDeclHandle decl = BGFX_INVALID_HANDLE;
- m_vertexBuffers[_handle.idx].create(_size, NULL, decl);
+ VertexLayoutHandle layoutHandle = BGFX_INVALID_HANDLE;
+ m_vertexBuffers[_handle.idx].create(_size, NULL, layoutHandle);
}
void updateDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _offset, uint32_t _size, const Memory* _mem) override
@@ -1261,7 +1296,7 @@ namespace bgfx { namespace d3d9
void updateViewName(ViewId _id, const char* _name) override
{
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
{
mbstowcs(&s_viewNameW[_id][BGFX_CONFIG_MAX_VIEW_NAME_RESERVED]
, _name
@@ -1280,25 +1315,26 @@ namespace bgfx { namespace d3d9
bx::memCopy(m_uniforms[_loc], _data, _size);
}
- void setMarker(const char* _marker, uint32_t _size) override
+ void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override
{
-#if BGFX_CONFIG_DEBUG_PIX
- uint32_t size = _size*sizeof(wchar_t);
- wchar_t* name = (wchar_t*)alloca(size);
- mbstowcs(name, _marker, size-2);
- PIX_SETMARKER(D3DCOLOR_MARKER, name);
-#endif // BGFX_CONFIG_DEBUG_PIX
- BX_UNUSED(_marker, _size);
+ m_occlusionQuery.invalidate(_handle);
}
- void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override
+ void setMarker(const char* _marker, uint16_t _len) override
{
- m_occlusionQuery.invalidate(_handle);
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
+ {
+ uint32_t size = _len*sizeof(wchar_t);
+ wchar_t* name = (wchar_t*)alloca(size+2);
+ mbstowcs(name, _marker, size);
+ name[_len] = L'\0';
+ PIX_SETMARKER(kColorMarker, name);
+ }
}
- virtual void setName(Handle _handle, const char* _name) override
+ virtual void setName(Handle _handle, const char* _name, uint16_t _len) override
{
- BX_UNUSED(_handle, _name)
+ BX_UNUSED(_handle, _name, _len)
}
void submitBlit(BlitState& _bs, uint16_t _view);
@@ -1337,9 +1373,9 @@ namespace bgfx { namespace d3d9
DX_CHECK(device->SetPixelShader(program.m_fsh->m_pixelShader) );
VertexBufferD3D9& vb = m_vertexBuffers[_blitter.m_vb->handle.idx];
- VertexDecl& vertexDecl = m_vertexDecls[_blitter.m_vb->decl.idx];
- DX_CHECK(device->SetStreamSource(0, vb.m_ptr, 0, vertexDecl.m_stride) );
- setInputLayout(vertexDecl, 0);
+ VertexLayout& layout = m_vertexLayouts[_blitter.m_vb->layoutHandle.idx];
+ DX_CHECK(device->SetStreamSource(0, vb.m_ptr, 0, layout.m_stride) );
+ setInputLayout(layout, 0);
IndexBufferD3D9& ib = m_indexBuffers[_blitter.m_ib->handle.idx];
DX_CHECK(device->SetIndices(ib.m_ptr) );
@@ -1360,7 +1396,7 @@ namespace bgfx { namespace d3d9
if (0 < numVertices)
{
m_indexBuffers[_blitter.m_ib->handle.idx].update(0, _numIndices * 2, _blitter.m_ib->data, true);
- m_vertexBuffers[_blitter.m_vb->handle.idx].update(0, numVertices*_blitter.m_decl.m_stride, _blitter.m_vb->data, true);
+ m_vertexBuffers[_blitter.m_vb->handle.idx].update(0, numVertices*_blitter.m_layout.m_stride, _blitter.m_vb->data, true);
DX_CHECK(m_device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST
, 0
@@ -1698,9 +1734,9 @@ namespace bgfx { namespace d3d9
}
}
- void setSamplerState(uint8_t _stage, uint32_t _flags, const float _rgba[4])
+ void setSamplerState(uint8_t _stage, uint64_t _flags, const float _rgba[4])
{
- const uint32_t flags = _flags&( (~BGFX_SAMPLER_RESERVED_MASK) | BGFX_SAMPLER_BITS_MASK | BGFX_TEXTURE_SRGB);
+ const uint64_t flags = _flags&( (~BGFX_SAMPLER_RESERVED_MASK) | BGFX_SAMPLER_BITS_MASK | BGFX_TEXTURE_SRGB);
BX_CHECK(_stage < BX_COUNTOF(m_samplerFlags), "");
if (m_samplerFlags[_stage] != flags)
{
@@ -1921,9 +1957,9 @@ namespace bgfx { namespace d3d9
}
break;
- CASE_IMPLEMENT_UNIFORM(Int1, I, int);
- CASE_IMPLEMENT_UNIFORM(Vec4, F, float);
- CASE_IMPLEMENT_UNIFORM(Mat4, F, float);
+ CASE_IMPLEMENT_UNIFORM(Sampler, I, int);
+ CASE_IMPLEMENT_UNIFORM(Vec4, F, float);
+ CASE_IMPLEMENT_UNIFORM(Mat4, F, float);
case UniformType::End:
break;
@@ -2051,54 +2087,25 @@ namespace bgfx { namespace d3d9
DX_CHECK(device->SetRenderState(D3DRS_STENCILENABLE, FALSE) );
}
- VertexBufferD3D9& vb = m_vertexBuffers[_clearQuad.m_vb->handle.idx];
- VertexDecl& vertexDecl = m_vertexDecls[_clearQuad.m_vb->decl.idx];
- uint32_t stride = _clearQuad.m_decl.m_stride;
-
- {
- struct Vertex
- {
- float m_x;
- float m_y;
- float m_z;
- };
-
- Vertex* vertex = (Vertex*)_clearQuad.m_vb->data;
- BX_CHECK(stride == sizeof(Vertex), "Stride/Vertex mismatch (stride %d, sizeof(Vertex) %d)", stride, sizeof(Vertex) );
-
- const float depth = _clear.m_depth;
-
- vertex->m_x = -1.0f;
- vertex->m_y = -1.0f;
- vertex->m_z = depth;
- vertex++;
- vertex->m_x = 1.0f;
- vertex->m_y = -1.0f;
- vertex->m_z = depth;
- vertex++;
- vertex->m_x = -1.0f;
- vertex->m_y = 1.0f;
- vertex->m_z = depth;
- vertex++;
- vertex->m_x = 1.0f;
- vertex->m_y = 1.0f;
- vertex->m_z = depth;
- }
-
- vb.update(0, 4*stride, _clearQuad.m_vb->data);
+ VertexBufferD3D9& vb = m_vertexBuffers[_clearQuad.m_vb.idx];
+ VertexLayout& layout = _clearQuad.m_layout;
+ uint32_t stride = _clearQuad.m_layout.m_stride;
ProgramD3D9& program = m_program[_clearQuad.m_program[numMrt-1].idx];
device->SetVertexShader(program.m_vsh->m_vertexShader);
device->SetPixelShader(program.m_fsh->m_pixelShader);
- float mrtClear[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS][4];
+ float mrtClearDepth[4] = { _clear.m_depth };
+ DX_CHECK(device->SetVertexShaderConstantF(0, mrtClearDepth, 1));
+
+ float mrtClearColor[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS][4];
if (BGFX_CLEAR_COLOR_USE_PALETTE & _clear.m_flags)
{
for (uint32_t ii = 0; ii < numMrt; ++ii)
{
uint8_t index = (uint8_t)bx::uint32_min(BGFX_CONFIG_MAX_COLOR_PALETTE - 1, _clear.m_index[ii]);
- bx::memCopy(mrtClear[ii], _palette[index], 16);
+ bx::memCopy(mrtClearColor[ii], _palette[index], 16);
}
}
else
@@ -2113,16 +2120,16 @@ namespace bgfx { namespace d3d9
for (uint32_t ii = 0; ii < numMrt; ++ii)
{
- bx::memCopy(mrtClear[ii], rgba, 16);
+ bx::memCopy(mrtClearColor[ii], rgba, 16);
}
}
- DX_CHECK(device->SetPixelShaderConstantF(0, mrtClear[0], numMrt));
+ DX_CHECK(device->SetPixelShaderConstantF(0, mrtClearColor[0], numMrt));
DX_CHECK(device->SetStreamSource(0, vb.m_ptr, 0, stride) );
DX_CHECK(device->SetStreamSourceFreq(0, 1) );
DX_CHECK(device->SetStreamSource(1, NULL, 0, 0) );
- setInputLayout(vertexDecl, 0);
+ setInputLayout(layout, 0);
DX_CHECK(device->SetIndices(NULL) );
DX_CHECK(device->DrawPrimitive(D3DPT_TRIANGLESTRIP
, 0
@@ -2131,14 +2138,14 @@ namespace bgfx { namespace d3d9
}
}
- void setInputLayout(uint8_t _numStreams, const VertexDecl** _vertexDecls, uint16_t _numInstanceData)
+ void setInputLayout(uint8_t _numStreams, const VertexLayout** _layouts, uint16_t _numInstanceData)
{
bx::HashMurmur2A murmur;
murmur.begin();
murmur.add(_numInstanceData);
for (uint8_t stream = 0; stream < _numStreams; ++stream)
{
- murmur.add(_vertexDecls[stream]->m_hash);
+ murmur.add(_layouts[stream]->m_hash);
}
uint64_t layoutHash = murmur.end();
@@ -2150,7 +2157,7 @@ namespace bgfx { namespace d3d9
for (uint8_t stream = 0; stream < _numStreams; ++stream)
{
- elem = fillVertexDecl(stream, elem, *_vertexDecls[stream]);
+ elem = fillVertexLayout(stream, elem, *_layouts[stream]);
}
const D3DVERTEXELEMENT9 inst = { _numStreams, 0, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 };
@@ -2173,10 +2180,10 @@ namespace bgfx { namespace d3d9
DX_CHECK(m_device->SetVertexDeclaration(layout) );
}
- void setInputLayout(const VertexDecl& _vertexDecl, uint16_t _numInstanceData)
+ void setInputLayout(const VertexLayout& _layout, uint16_t _numInstanceData)
{
- const VertexDecl* decls[1] = { &_vertexDecl };
- setInputLayout(BX_COUNTOF(decls), decls, _numInstanceData);
+ const VertexLayout* layouts[1] = { &_layout };
+ setInputLayout(BX_COUNTOF(layouts), layouts, _numInstanceData);
}
D3DCAPS9 m_caps;
@@ -2230,12 +2237,12 @@ namespace bgfx { namespace d3d9
ShaderD3D9 m_shaders[BGFX_CONFIG_MAX_SHADERS];
ProgramD3D9 m_program[BGFX_CONFIG_MAX_PROGRAMS];
TextureD3D9 m_textures[BGFX_CONFIG_MAX_TEXTURES];
- VertexDecl m_vertexDecls[BGFX_CONFIG_MAX_VERTEX_DECLS];
+ VertexLayout m_vertexLayouts[BGFX_CONFIG_MAX_VERTEX_LAYOUTS];
FrameBufferD3D9 m_frameBuffers[BGFX_CONFIG_MAX_FRAME_BUFFERS];
UniformRegistry m_uniformReg;
void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS];
- uint32_t m_samplerFlags[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
+ uint64_t m_samplerFlags[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
TextureD3D9* m_updateTexture;
uint8_t* m_updateTextureBits;
@@ -2334,10 +2341,10 @@ namespace bgfx { namespace d3d9
}
}
- void VertexBufferD3D9::create(uint32_t _size, void* _data, VertexDeclHandle _declHandle)
+ void VertexBufferD3D9::create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle)
{
m_size = _size;
- m_decl = _declHandle;
+ m_layoutHandle = _layoutHandle;
uint32_t usage = D3DUSAGE_WRITEONLY;
D3DPOOL pool = s_renderD3D9->m_pool;
@@ -2904,18 +2911,28 @@ namespace bgfx { namespace d3d9
if (bimg::imageParse(imageContainer, _mem->data, _mem->size) )
{
- uint8_t numMips = imageContainer.m_numMips;
- const uint8_t startLod = uint8_t(bx::uint32_min(_skip, numMips-1) );
- numMips -= startLod;
const bimg::ImageBlockInfo& blockInfo = bimg::getBlockInfo(bimg::TextureFormat::Enum(imageContainer.m_format) );
- const uint32_t textureWidth = bx::uint32_max(blockInfo.blockWidth, imageContainer.m_width >>startLod);
- const uint32_t textureHeight = bx::uint32_max(blockInfo.blockHeight, imageContainer.m_height>>startLod);
+
+ const uint8_t startLod = bx::min<uint8_t>(_skip, imageContainer.m_numMips-1);
+
+ bimg::TextureInfo ti;
+ bimg::imageGetSize(
+ &ti
+ , uint16_t(imageContainer.m_width >>startLod)
+ , uint16_t(imageContainer.m_height>>startLod)
+ , uint16_t(imageContainer.m_depth >>startLod)
+ , imageContainer.m_cubeMap
+ , 1 < imageContainer.m_numMips
+ , imageContainer.m_numLayers
+ , imageContainer.m_format
+ );
+ ti.numMips = bx::min<uint8_t>(imageContainer.m_numMips-startLod, ti.numMips);
m_flags = _flags;
- m_width = textureWidth;
- m_height = textureHeight;
- m_depth = imageContainer.m_depth;
- m_numMips = numMips;
+ m_width = ti.width;
+ m_height = ti.height;
+ m_depth = ti.depth;
+ m_numMips = ti.numMips;
m_requestedFormat = uint8_t(imageContainer.m_format);
m_textureFormat = uint8_t(getViableTextureFormat(imageContainer) );
const bool convert = m_textureFormat != m_requestedFormat;
@@ -2924,23 +2941,23 @@ namespace bgfx { namespace d3d9
if (imageContainer.m_cubeMap)
{
- createCubeTexture(textureWidth, numMips);
+ createCubeTexture(ti.width, ti.numMips);
}
else if (imageContainer.m_depth > 1)
{
- createVolumeTexture(textureWidth, textureHeight, imageContainer.m_depth, numMips);
+ createVolumeTexture(ti.width, ti.height, ti.depth, ti.numMips);
}
else
{
- createTexture(textureWidth, textureHeight, numMips);
+ createTexture(ti.width, ti.height, ti.numMips);
}
BX_TRACE("Texture %3d: %s (requested: %s), %dx%d%s%s."
, this - s_renderD3D9->m_textures
, getName( (TextureFormat::Enum)m_textureFormat)
, getName( (TextureFormat::Enum)m_requestedFormat)
- , textureWidth
- , textureHeight
+ , ti.width
+ , ti.height
, imageContainer.m_cubeMap ? "x6" : ""
, 0 != (m_flags&BGFX_TEXTURE_RT_MASK) ? " (render target)" : ""
);
@@ -2950,29 +2967,22 @@ namespace bgfx { namespace d3d9
return;
}
- // For BC4 and B5 in DX9 LockRect returns wrong number of
- // bytes. If actual mip size is used it causes memory corruption.
- // http://www.aras-p.info/texts/D3D9GPUHacks.html#3dc
- const bool useMipSize = true
- && imageContainer.m_format != bimg::TextureFormat::BC4
- && imageContainer.m_format != bimg::TextureFormat::BC5
- ;
-
+ const bool useMipSize = useD3D9Pitch(imageContainer.m_format);
for (uint8_t side = 0, numSides = imageContainer.m_cubeMap ? 6 : 1; side < numSides; ++side)
{
- uint32_t width = textureWidth;
- uint32_t height = textureHeight;
- uint32_t depth = imageContainer.m_depth;
- uint32_t mipWidth = imageContainer.m_width;
- uint32_t mipHeight = imageContainer.m_height;
+ uint32_t width = ti.width;
+ uint32_t height = ti.height;
+ uint32_t depth = ti.depth;
+ uint32_t mipWidth = ti.width;
+ uint32_t mipHeight = ti.height;
- for (uint8_t lod = 0, num = numMips; lod < num; ++lod)
+ for (uint8_t lod = 0, num = ti.numMips; lod < num; ++lod)
{
- width = bx::uint32_max(1, width);
- height = bx::uint32_max(1, height);
- depth = bx::uint32_max(1, depth);
- mipWidth = bx::uint32_max(blockInfo.blockWidth, mipWidth);
- mipHeight = bx::uint32_max(blockInfo.blockHeight, mipHeight);
+ width = bx::max<uint32_t>(1, width);
+ height = bx::max<uint32_t>(1, height);
+ depth = bx::max<uint32_t>(1, depth);
+ mipWidth = bx::max<uint32_t>(blockInfo.blockWidth, mipWidth);
+ mipHeight = bx::max<uint32_t>(blockInfo.blockHeight, mipHeight);
uint32_t mipSize = width*height*depth*bpp/8;
bimg::ImageMip mip;
@@ -3000,7 +3010,7 @@ namespace bgfx { namespace d3d9
, mip.m_format
);
- bx::memCopy(bits, temp, pitch, height, srcpitch, pitch);
+ bx::memCopy(bits, pitch, temp, srcpitch, pitch, height);
BX_FREE(g_allocator, temp);
}
@@ -3051,11 +3061,14 @@ namespace bgfx { namespace d3d9
void TextureD3D9::update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem)
{
- const uint32_t bpp = bimg::getBitsPerPixel(bimg::TextureFormat::Enum(m_textureFormat) );
- const uint32_t rectpitch = _rect.m_width*bpp/8;
- const uint32_t srcpitch = UINT16_MAX == _pitch ? rectpitch : _pitch;
- const uint32_t dstpitch = s_renderD3D9->m_updateTexturePitch;
- uint8_t* bits = s_renderD3D9->m_updateTextureBits + _rect.m_y*dstpitch + _rect.m_x*bpp/8;
+ const bimg::ImageBlockInfo & blockInfo = bimg::getBlockInfo(bimg::TextureFormat::Enum(m_textureFormat) );
+ const uint16_t blockHeight = blockInfo.blockHeight;
+ const uint16_t bpp = blockInfo.bitsPerPixel;
+ const bool useLockedPitch = useD3D9Pitch(bimg::TextureFormat::Enum(m_textureFormat) );
+ const uint32_t rectpitch = calcRowPitch(blockInfo, 0, _rect.m_width);
+ const uint32_t srcpitch = UINT16_MAX == _pitch ? rectpitch : _pitch;
+ const uint32_t dstpitch = (useLockedPitch) ? s_renderD3D9->m_updateTexturePitch : calcRowPitch(blockInfo, _mip, m_width);
+ uint8_t* bits = s_renderD3D9->m_updateTextureBits + _rect.m_y*dstpitch/blockHeight + _rect.m_x*blockHeight*bpp/8;
const bool convert = m_textureFormat != m_requestedFormat;
@@ -3072,7 +3085,7 @@ namespace bgfx { namespace d3d9
{
uint8_t* src = data;
uint8_t* dst = bits;
- for (uint32_t yy = 0, height = _rect.m_height; yy < height; ++yy)
+ for (uint32_t yy = 0, height = _rect.m_height; yy < height; yy += blockHeight)
{
switch (m_textureFormat)
{
@@ -3111,9 +3124,8 @@ namespace bgfx { namespace d3d9
void TextureD3D9::commit(uint8_t _stage, uint32_t _flags, const float _palette[][4])
{
- const uint32_t flags = 0 == (BGFX_SAMPLER_INTERNAL_DEFAULT & _flags)
- ? _flags
- : uint32_t(m_flags)
+ const uint64_t flags = (m_flags & BGFX_TEXTURE_SRGB)
+ | (0 == (BGFX_SAMPLER_INTERNAL_DEFAULT & _flags) ? _flags : uint32_t(m_flags) )
;
uint32_t index = (flags & BGFX_SAMPLER_BORDER_COLOR_MASK) >> BGFX_SAMPLER_BORDER_COLOR_SHIFT;
s_renderD3D9->setSamplerState(_stage, flags, _palette[index]);
@@ -3252,9 +3264,11 @@ namespace bgfx { namespace d3d9
D3DPRESENT_PARAMETERS params;
bx::memCopy(&params, &s_renderD3D9->m_params, sizeof(D3DPRESENT_PARAMETERS) );
- params.BackBufferFormat = TextureFormat::Count == _format ? params.BackBufferFormat : s_textureFormat[_format].m_fmt;
- params.BackBufferWidth = m_width;
- params.BackBufferHeight = m_height;
+ params.BackBufferFormat = TextureFormat::Count == _format ? params.BackBufferFormat : s_textureFormat[_format].m_fmt;
+ params.BackBufferWidth = m_width;
+ params.BackBufferHeight = m_height;
+ params.MultiSampleType = s_msaa[0].m_type;
+ params.MultiSampleQuality = s_msaa[0].m_quality;
DX_CHECK(s_renderD3D9->m_device->CreateAdditionalSwapChain(&params, &m_swapChain) );
DX_CHECK(m_swapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &m_surface[0]) );
@@ -3708,10 +3722,10 @@ namespace bgfx { namespace d3d9
{
IDirect3DDevice9* device = m_device;
- PIX_BEGINEVENT(D3DCOLOR_FRAME, L"rendererSubmit");
-
updateResolution(_render->m_resolution);
+ BGFX_D3D9_PROFILER_BEGIN_LITERAL("rendererSubmit", kColorView);
+
int64_t timeBegin = bx::getHPCounter();
int64_t captureElapsed = 0;
@@ -3725,12 +3739,14 @@ namespace bgfx { namespace d3d9
if (0 < _render->m_iboffset)
{
+ BGFX_PROFILER_SCOPE("bgfx/Update transient index buffer", kColorResource);
TransientIndexBuffer* ib = _render->m_transientIb;
m_indexBuffers[ib->handle.idx].update(0, _render->m_iboffset, ib->data, true);
}
if (0 < _render->m_vboffset)
{
+ BGFX_PROFILER_SCOPE("bgfx/Update transient vertex buffer", kColorResource);
TransientVertexBuffer* vb = _render->m_transientVb;
m_vertexBuffers[vb->handle.idx].update(0, _render->m_vboffset, vb->data, true);
}
@@ -3745,10 +3761,11 @@ namespace bgfx { namespace d3d9
RenderBind currentBind;
currentBind.clear();
- ViewState viewState(_render, false);
+ static ViewState viewState;
+ viewState.reset(_render);
DX_CHECK(device->SetRenderState(D3DRS_FILLMODE, _render->m_debug&BGFX_DEBUG_WIREFRAME ? D3DFILL_WIREFRAME : D3DFILL_SOLID) );
- uint16_t programIdx = kInvalidHandle;
+ ProgramHandle currentProgram = BGFX_INVALID_HANDLE;
SortKey key;
uint16_t view = UINT16_MAX;
FrameBufferHandle fbh = { BGFX_CONFIG_MAX_FRAME_BUFFERS };
@@ -3838,22 +3855,23 @@ namespace bgfx { namespace d3d9
currentState.m_stencil = newStencil;
view = key.m_view;
- programIdx = kInvalidHandle;
+ currentProgram = BGFX_INVALID_HANDLE;
- if (_render->m_view[view].m_fbh.idx != fbh.idx)
- {
- fbh = _render->m_view[view].m_fbh;
- setFrameBuffer(fbh);
- }
-
- PIX_ENDEVENT();
if (item > 0)
{
profiler.end();
}
+ BGFX_D3D9_PROFILER_END();
+ BGFX_D3D9_PROFILER_BEGIN(view, kColorView);
+
profiler.begin(view);
- PIX_BEGINEVENT(D3DCOLOR_VIEW, s_viewNameW[view]);
+
+ if (_render->m_view[view].m_fbh.idx != fbh.idx)
+ {
+ fbh = _render->m_view[view].m_fbh;
+ setFrameBuffer(fbh);
+ }
viewState.m_rect = _render->m_view[view].m_rect;
const Rect& scissorRect = _render->m_view[view].m_scissor;
@@ -4114,18 +4132,18 @@ namespace bgfx { namespace d3d9
bool constantsChanged = draw.m_uniformBegin < draw.m_uniformEnd;
rendererUpdateUniforms(this, _render->m_uniformBuffer[draw.m_uniformIdx], draw.m_uniformBegin, draw.m_uniformEnd);
- if (key.m_program != programIdx)
+ if (key.m_program.idx != currentProgram.idx)
{
- programIdx = key.m_program;
+ currentProgram = key.m_program;
- if (kInvalidHandle == programIdx)
+ if (!isValid(currentProgram) )
{
device->SetVertexShader(NULL);
device->SetPixelShader(NULL);
}
else
{
- ProgramD3D9& program = m_program[programIdx];
+ ProgramD3D9& program = m_program[currentProgram.idx];
device->SetVertexShader(program.m_vsh->m_vertexShader);
device->SetPixelShader(NULL == program.m_fsh
? NULL
@@ -4137,9 +4155,9 @@ namespace bgfx { namespace d3d9
constantsChanged = true;
}
- if (kInvalidHandle != programIdx)
+ if (isValid(currentProgram) )
{
- ProgramD3D9& program = m_program[programIdx];
+ ProgramD3D9& program = m_program[currentProgram.idx];
if (constantsChanged)
{
@@ -4159,7 +4177,7 @@ namespace bgfx { namespace d3d9
}
}
- viewState.setPredefined<4>(this, view, 0, program, _render, draw);
+ viewState.setPredefined<4>(this, view, program, _render, draw);
}
{
@@ -4196,7 +4214,7 @@ namespace bgfx { namespace d3d9
currentState.m_instanceDataOffset = draw.m_instanceDataOffset;
currentState.m_instanceDataStride = draw.m_instanceDataStride;
- const VertexDecl* decls[BGFX_CONFIG_MAX_VERTEX_STREAMS];
+ const VertexLayout* layouts[BGFX_CONFIG_MAX_VERTEX_STREAMS];
const bool instanced = true
&& isValid(draw.m_instanceDataBuffer)
@@ -4210,25 +4228,28 @@ namespace bgfx { namespace d3d9
uint32_t numVertices = draw.m_numVertices;
uint8_t numStreams = 0;
- for (uint32_t idx = 0, streamMask = draw.m_streamMask, ntz = bx::uint32_cnttz(streamMask)
+ for (uint32_t idx = 0, streamMask = draw.m_streamMask
; 0 != streamMask
- ; streamMask >>= 1, idx += 1, ntz = bx::uint32_cnttz(streamMask), ++numStreams
+ ; streamMask >>= 1, idx += 1, ++numStreams
)
{
+ const uint32_t ntz = bx::uint32_cnttz(streamMask);
streamMask >>= ntz;
idx += ntz;
- currentState.m_stream[idx].m_decl = draw.m_stream[idx].m_decl;
- currentState.m_stream[idx].m_handle = draw.m_stream[idx].m_handle;
- currentState.m_stream[idx].m_startVertex = draw.m_stream[idx].m_startVertex;
+ currentState.m_stream[idx].m_layoutHandle = draw.m_stream[idx].m_layoutHandle;
+ currentState.m_stream[idx].m_handle = draw.m_stream[idx].m_handle;
+ currentState.m_stream[idx].m_startVertex = draw.m_stream[idx].m_startVertex;
const uint16_t handle = draw.m_stream[idx].m_handle.idx;
const VertexBufferD3D9& vb = m_vertexBuffers[handle];
- const uint16_t decl = !isValid(vb.m_decl) ? draw.m_stream[idx].m_decl.idx : vb.m_decl.idx;
- const VertexDecl& vertexDecl = m_vertexDecls[decl];
- const uint32_t stride = vertexDecl.m_stride;
+ const uint16_t layoutIdx = isValid(draw.m_stream[idx].m_layoutHandle)
+ ? draw.m_stream[idx].m_layoutHandle.idx
+ : vb.m_layoutHandle.idx;
+ const VertexLayout& layout = m_vertexLayouts[layoutIdx];
+ const uint32_t stride = layout.m_stride;
- decls[numStreams] = &vertexDecl;
+ layouts[numStreams] = &layout;
numVertices = bx::uint32_min(UINT32_MAX == draw.m_numVertices
? vb.m_size/stride
@@ -4249,12 +4270,12 @@ namespace bgfx { namespace d3d9
const VertexBufferD3D9& inst = m_vertexBuffers[draw.m_instanceDataBuffer.idx];
DX_CHECK(device->SetStreamSourceFreq(numStreams, UINT(D3DSTREAMSOURCE_INSTANCEDATA|1) ) );
DX_CHECK(device->SetStreamSource(numStreams, inst.m_ptr, draw.m_instanceDataOffset, draw.m_instanceDataStride) );
- setInputLayout(numStreams, decls, draw.m_instanceDataStride/16);
+ setInputLayout(numStreams, layouts, draw.m_instanceDataStride/16);
}
else
{
DX_CHECK(device->SetStreamSource(numStreams, NULL, 0, 0) );
- setInputLayout(numStreams, decls, 0);
+ setInputLayout(numStreams, layouts, 0);
}
}
else
@@ -4369,7 +4390,7 @@ namespace bgfx { namespace d3d9
}
}
- PIX_ENDEVENT();
+ BGFX_D3D9_PROFILER_END();
int64_t timeEnd = bx::getHPCounter();
int64_t frameTime = timeEnd - timeBegin;
@@ -4414,7 +4435,7 @@ namespace bgfx { namespace d3d9
if (_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) )
{
- PIX_BEGINEVENT(D3DCOLOR_FRAME, L"debugstats");
+ BGFX_D3D9_PROFILER_BEGIN_LITERAL("debugstats", kColorFrame);
m_needPresent = true;
TextVideoMem& tvm = m_textVideoMem;
@@ -4512,15 +4533,15 @@ namespace bgfx { namespace d3d9
blit(this, _textVideoMemBlitter, tvm);
- PIX_ENDEVENT();
+ BGFX_D3D9_PROFILER_END();
}
else if (_render->m_debug & BGFX_DEBUG_TEXT)
{
- PIX_BEGINEVENT(D3DCOLOR_FRAME, L"debugtext");
+ BGFX_D3D9_PROFILER_BEGIN_LITERAL("debugtext", kColorFrame);
blit(this, _textVideoMemBlitter, _render->m_textVideoMem);
- PIX_ENDEVENT();
+ BGFX_D3D9_PROFILER_END();
}
device->EndScene();
diff --git a/3rdparty/bgfx/src/renderer_d3d9.h b/3rdparty/bgfx/src/renderer_d3d9.h
index 06cd320b96f..198b54b8776 100644
--- a/3rdparty/bgfx/src/renderer_d3d9.h
+++ b/3rdparty/bgfx/src/renderer_d3d9.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -25,6 +25,24 @@
#include "renderer_d3d.h"
#include "nvapi.h"
+#define BGFX_D3D9_PROFILER_BEGIN(_view, _abgr) \
+ BX_MACRO_BLOCK_BEGIN \
+ PIX_BEGINEVENT(_abgr, s_viewNameW[_view]); \
+ BGFX_PROFILER_BEGIN(s_viewName[view], _abgr); \
+ BX_MACRO_BLOCK_END
+
+#define BGFX_D3D9_PROFILER_BEGIN_LITERAL(_name, _abgr) \
+ BX_MACRO_BLOCK_BEGIN \
+ PIX_BEGINEVENT(_abgr, L"" # _name); \
+ BGFX_PROFILER_BEGIN_LITERAL("" # _name, _abgr); \
+ BX_MACRO_BLOCK_END
+
+#define BGFX_D3D9_PROFILER_END() \
+ BX_MACRO_BLOCK_BEGIN \
+ BGFX_PROFILER_END(); \
+ PIX_ENDEVENT(); \
+ BX_MACRO_BLOCK_END
+
namespace bgfx { namespace d3d9
{
# if defined(D3D_DISABLE_9EX)
@@ -173,7 +191,7 @@ namespace bgfx { namespace d3d9
{
}
- void create(uint32_t _size, void* _data, VertexDeclHandle _declHandle);
+ void create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle);
void update(uint32_t _offset, uint32_t _size, void* _data, bool _discard = false)
{
if (NULL != m_dynamic
@@ -214,7 +232,7 @@ namespace bgfx { namespace d3d9
IDirect3DVertexBuffer9* m_ptr;
uint8_t* m_dynamic;
uint32_t m_size;
- VertexDeclHandle m_decl;
+ VertexLayoutHandle m_layoutHandle;
};
struct ShaderD3D9
diff --git a/3rdparty/bgfx/src/renderer_gl.cpp b/3rdparty/bgfx/src/renderer_gl.cpp
index 7f0afda9a04..3fe8afcba0f 100644
--- a/3rdparty/bgfx/src/renderer_gl.cpp
+++ b/3rdparty/bgfx/src/renderer_gl.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -14,6 +14,14 @@ namespace bgfx { namespace gl
{
static char s_viewName[BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME];
+ inline void setViewType(ViewId _view, const bx::StringView _str)
+ {
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION || BGFX_CONFIG_PROFILER) )
+ {
+ bx::memCopy(&s_viewName[_view][3], _str.getPtr(), _str.getLength() );
+ }
+ }
+
struct PrimInfo
{
GLenum m_type;
@@ -1005,6 +1013,14 @@ namespace bgfx { namespace gl
{
}
+ static void GL_APIENTRY stubPushDebugGroup(GLenum /*_source*/, GLuint /*_id*/, GLsizei /*_length*/, const char* /*_message*/)
+ {
+ }
+
+ static void GL_APIENTRY stubPopDebugGroup()
+ {
+ }
+
static void GL_APIENTRY stubObjectLabel(GLenum /*_identifier*/, GLuint /*_name*/, GLsizei /*_length*/, const char* /*_label*/)
{
}
@@ -1039,10 +1055,22 @@ namespace bgfx { namespace gl
typedef void (*PostSwapBuffersFn)(uint32_t _width, uint32_t _height);
+ void flushGlError()
+ {
+ for (GLenum err = glGetError(); err != 0; err = glGetError() );
+ }
+
+ GLenum getGlError()
+ {
+ GLenum err = glGetError();
+ flushGlError();
+ return err;
+ }
+
static const char* getGLString(GLenum _name)
{
const char* str = (const char*)glGetString(_name);
- glGetError(); // ignore error if glGetString returns NULL.
+ getGlError(); // ignore error if glGetString returns NULL.
if (NULL != str)
{
return str;
@@ -1054,7 +1082,7 @@ namespace bgfx { namespace gl
static uint32_t getGLStringHash(GLenum _name)
{
const char* str = (const char*)glGetString(_name);
- glGetError(); // ignore error if glGetString returns NULL.
+ getGlError(); // ignore error if glGetString returns NULL.
if (NULL != str)
{
return bx::hash<bx::HashMurmur2A>(str, (uint32_t)bx::strLen(str) );
@@ -1139,7 +1167,7 @@ namespace bgfx { namespace gl
{
GLint result = 0;
glGetIntegerv(_pname, &result);
- GLenum err = glGetError();
+ GLenum err = getGlError();
BX_WARN(0 == err, "glGetIntegerv(0x%04x, ...) failed with GL error: 0x%04x.", _pname, err);
return 0 == err ? result : 0;
}
@@ -1152,11 +1180,6 @@ namespace bgfx { namespace gl
tfi.m_type = _type;
}
- void flushGlError()
- {
- for (GLenum err = glGetError(); err != 0; err = glGetError() );
- }
-
static void texSubImage(
GLenum _target
, GLint _level
@@ -1441,7 +1464,7 @@ namespace bgfx { namespace gl
uint32_t block = bx::uint32_max(4, dim);
size = (block*block*bpp)/8;
compressedTexImage(target, ii, internalFmt, dim, dim, 0, 0, size, data);
- err |= glGetError();
+ err |= getGlError();
}
}
else
@@ -1451,7 +1474,7 @@ namespace bgfx { namespace gl
dim = bx::uint32_max(1, dim);
size = (dim*dim*bpp)/8;
texImage(target, 0, ii, internalFmt, dim, dim, 0, 0, tfi.m_fmt, tfi.m_type, data);
- err |= glGetError();
+ err |= getGlError();
}
}
@@ -1497,7 +1520,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
, _dim
, _dim
);
- err = glGetError();
+ err = getGlError();
}
if (0 == err)
@@ -1516,7 +1539,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
&& _mipAutogen)
{
glGenerateMipmap(target);
- err = glGetError();
+ err = getGlError();
}
}
@@ -1540,7 +1563,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
GLenum err = 0;
glTexStorage2D(GL_TEXTURE_2D, 1, s_imageFormat[_format], _dim, _dim);
- err |= glGetError();
+ err |= getGlError();
if (0 == err)
{
glBindImageTexture(0
@@ -1551,7 +1574,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
, GL_READ_WRITE
, s_imageFormat[_format]
);
- err |= glGetError();
+ err |= getGlError();
}
GL_CHECK(glDeleteTextures(1, &id) );
@@ -1590,7 +1613,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
glBindRenderbuffer(GL_RENDERBUFFER, 0);
glDeleteRenderbuffers(1, &rbo);
- GLenum err = glGetError();
+ GLenum err = getGlError();
return 0 == err;
}
@@ -1632,7 +1655,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
, id
, 0
);
- err = glGetError();
+ err = getGlError();
if (0 == err)
{
@@ -1656,8 +1679,14 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
_minFilter = s_textureFilterMin[min][_hasMips ? mip+1 : 0];
}
- void updateExtension(const char* _name)
+ void updateExtension(const bx::StringView& _name)
{
+ bx::StringView ext(_name);
+ if (0 == bx::strCmp(ext, "GL_", 3) ) // skip GL_
+ {
+ ext.set(ext.getPtr()+3, ext.getTerm() );
+ }
+
bool supported = false;
for (uint32_t ii = 0; ii < Extension::Count; ++ii)
{
@@ -1665,12 +1694,6 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
if (!extension.m_supported
&& extension.m_initialize)
{
- const char* ext = _name;
- if (0 == bx::strCmp(ext, "GL_", 3) ) // skip GL_
- {
- ext += 3;
- }
-
if (0 == bx::strCmp(ext, extension.m_name) )
{
extension.m_supported = true;
@@ -1680,7 +1703,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
}
}
- BX_TRACE("GL_EXTENSION %s: %s", supported ? " (supported)" : "", _name);
+ BX_TRACE("GL_EXTENSION %s: %.*s", supported ? " (supported)" : "", _name.getLength(), _name.getPtr() );
BX_UNUSED(supported);
}
@@ -1738,6 +1761,8 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
, m_hash( (BX_PLATFORM_WINDOWS<<1) | BX_ARCH_64BIT)
, m_backBufferFbo(0)
, m_msaaBackBufferFbo(0)
+ , m_clearQuadColor(BGFX_INVALID_HANDLE)
+ , m_clearQuadDepth(BGFX_INVALID_HANDLE)
{
bx::memSet(m_msaaBackBufferRbos, 0, sizeof(m_msaaBackBufferRbos) );
}
@@ -1838,6 +1863,8 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
GL_GET(GL_MAX_RENDERBUFFER_SIZE, 1);
GL_GET(GL_MAX_COLOR_ATTACHMENTS, 1);
GL_GET(GL_MAX_DRAW_BUFFERS, 1);
+ GL_GET(GL_MAX_LABEL_LENGTH, 0);
+
#undef GL_GET
BX_TRACE(" Vendor: %s", m_vendor);
@@ -1872,32 +1899,19 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
if (BX_ENABLED(BGFX_CONFIG_RENDERER_USE_EXTENSIONS) )
{
const char* extensions = (const char*)glGetString(GL_EXTENSIONS);
- glGetError(); // ignore error if glGetString returns NULL.
+ getGlError(); // ignore error if glGetString returns NULL.
if (NULL != extensions)
{
- char name[1024];
- const char* pos = extensions;
- const char* end = extensions + bx::strLen(extensions);
+ bx::StringView ext(extensions);
uint32_t index = 0;
- while (pos < end)
+ while (!ext.isEmpty() )
{
- uint32_t len;
- const bx::StringView space = bx::strFind(pos, ' ');
- if (!space.isEmpty() )
- {
- len = bx::uint32_min(sizeof(name), (uint32_t)(space.getPtr() - pos) );
- }
- else
- {
- len = bx::uint32_min(sizeof(name), (uint32_t)bx::strLen(pos) );
- }
-
- bx::strCopy(name, BX_COUNTOF(name), pos, len);
- name[len] = '\0';
+ const bx::StringView space = bx::strFind(ext, ' ');
+ const bx::StringView token = bx::StringView(ext.getPtr(), space.getPtr() );
+ updateExtension(token);
- updateExtension(name);
+ ext.set(space.getPtr() + (space.isEmpty() ? 0 : 1), ext.getTerm() );
- pos += len+1;
++index;
}
}
@@ -1905,7 +1919,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
{
GLint numExtensions = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
- glGetError(); // ignore error if glGetIntegerv returns NULL.
+ getGlError(); // ignore error if glGetIntegerv returns NULL.
for (GLint index = 0; index < numExtensions; ++index)
{
@@ -2148,6 +2162,8 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii)
{
+ const TextureFormat::Enum fmt = TextureFormat::Enum(ii);
+
uint16_t supported = BGFX_CAPS_FORMAT_TEXTURE_NONE;
supported |= s_textureFormat[ii].m_supported
? BGFX_CAPS_FORMAT_TEXTURE_2D
@@ -2156,30 +2172,33 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
: BGFX_CAPS_FORMAT_TEXTURE_NONE
;
- supported |= isTextureFormatValid(TextureFormat::Enum(ii), true)
+ supported |= isTextureFormatValid(fmt, true)
? BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB
| BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB
| BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB
: BGFX_CAPS_FORMAT_TEXTURE_NONE
;
- supported |= isTextureFormatValid(TextureFormat::Enum(ii), false, true)
- ? BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN
- : BGFX_CAPS_FORMAT_TEXTURE_NONE
- ;
+ if (!bimg::isCompressed(bimg::TextureFormat::Enum(fmt) ) )
+ {
+ supported |= isTextureFormatValid(fmt, false, true)
+ ? BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN
+ : BGFX_CAPS_FORMAT_TEXTURE_NONE
+ ;
+ }
supported |= computeSupport
- && isImageFormatValid(TextureFormat::Enum(ii) )
+ && isImageFormatValid(fmt)
? BGFX_CAPS_FORMAT_TEXTURE_IMAGE
: BGFX_CAPS_FORMAT_TEXTURE_NONE
;
- supported |= isFramebufferFormatValid(TextureFormat::Enum(ii) )
+ supported |= isFramebufferFormatValid(fmt)
? BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER
: BGFX_CAPS_FORMAT_TEXTURE_NONE
;
- supported |= isFramebufferFormatValid(TextureFormat::Enum(ii), false, true)
+ supported |= isFramebufferFormatValid(fmt, false, true)
? BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER
: BGFX_CAPS_FORMAT_TEXTURE_NONE
;
@@ -2193,7 +2212,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
, 1
, &maxSamples
);
- GLenum err = glGetError();
+ GLenum err = getGlError();
supported |= 0 == err && maxSamples > 0
? BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA
: BGFX_CAPS_FORMAT_TEXTURE_NONE
@@ -2205,7 +2224,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
, 1
, &maxSamples
);
- err = glGetError();
+ err = getGlError();
supported |= 0 == err && maxSamples > 0
? BGFX_CAPS_FORMAT_TEXTURE_MSAA
: BGFX_CAPS_FORMAT_TEXTURE_NONE
@@ -2422,12 +2441,18 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
m_atocSupport = s_extension[Extension::ARB_multisample].m_supported;
m_conservativeRasterSupport = s_extension[Extension::NV_conservative_raster].m_supported;
+ m_imageLoadStoreSupport = false
+ || s_extension[Extension::ARB_shader_image_load_store].m_supported
+ || s_extension[Extension::EXT_shader_image_load_store].m_supported
+ ;
+
g_caps.supported |= 0
| (m_atocSupport ? BGFX_CAPS_ALPHA_TO_COVERAGE : 0)
| (m_conservativeRasterSupport ? BGFX_CAPS_CONSERVATIVE_RASTER : 0)
| (m_occlusionQuerySupport ? BGFX_CAPS_OCCLUSION_QUERY : 0)
| (m_depthTextureSupport ? BGFX_CAPS_TEXTURE_COMPARE_LEQUAL : 0)
| (computeSupport ? BGFX_CAPS_COMPUTE : 0)
+ | (m_imageLoadStoreSupport ? BGFX_CAPS_FRAMEBUFFER_RW : 0)
;
g_caps.supported |= m_glctx.getCaps();
@@ -2509,6 +2534,13 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
}
}
+ if (NULL == glPushDebugGroup
+ || NULL == glPopDebugGroup)
+ {
+ glPushDebugGroup = stubPushDebugGroup;
+ glPopDebugGroup = stubPopDebugGroup;
+ }
+
if (s_extension[Extension::ARB_seamless_cube_map].m_supported)
{
GL_CHECK(glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS) );
@@ -2520,6 +2552,8 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
glInsertEventMarker = stubInsertEventMarker;
}
+ m_maxLabelLen = uint16_t(glGet(GL_MAX_LABEL_LENGTH) );
+
setGraphicsDebuggerPresent(s_extension[Extension::EXT_debug_tool].m_supported);
if (NULL == glObjectLabel)
@@ -2652,20 +2686,20 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
m_indexBuffers[_handle.idx].destroy();
}
- void createVertexDecl(VertexDeclHandle _handle, const VertexDecl& _decl) override
+ void createVertexLayout(VertexLayoutHandle _handle, const VertexLayout& _layout) override
{
- VertexDecl& decl = m_vertexDecls[_handle.idx];
- bx::memCopy(&decl, &_decl, sizeof(VertexDecl) );
- dump(decl);
+ VertexLayout& layout = m_vertexLayouts[_handle.idx];
+ bx::memCopy(&layout, &_layout, sizeof(VertexLayout) );
+ dump(layout);
}
- void destroyVertexDecl(VertexDeclHandle /*_handle*/) override
+ void destroyVertexLayout(VertexLayoutHandle /*_handle*/) override
{
}
- void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexDeclHandle _declHandle, uint16_t _flags) override
+ void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexLayoutHandle _layoutHandle, uint16_t _flags) override
{
- m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _declHandle, _flags);
+ m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _layoutHandle, _flags);
}
void destroyVertexBuffer(VertexBufferHandle _handle) override
@@ -2690,8 +2724,8 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
void createDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size, uint16_t _flags) override
{
- VertexDeclHandle decl = BGFX_INVALID_HANDLE;
- m_vertexBuffers[_handle.idx].create(_size, NULL, decl, _flags);
+ VertexLayoutHandle layoutHandle = BGFX_INVALID_HANDLE;
+ m_vertexBuffers[_handle.idx].create(_size, NULL, layoutHandle, _flags);
}
void updateDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _offset, uint32_t _size, const Memory* _mem) override
@@ -2777,26 +2811,24 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
const TextureGL& texture = m_textures[_handle.idx];
const bool compressed = bimg::isCompressed(bimg::TextureFormat::Enum(texture.m_textureFormat) );
- if(!compressed)
+ if (!compressed)
{
- Attachment attachment[1];
- attachment[0].handle = _handle;
- attachment[0].mip = 0;
- attachment[0].layer = 0;
+ Attachment at[1];
+ at[0].init(_handle);
FrameBufferGL frameBuffer;
- frameBuffer.create(1, attachment);
+ frameBuffer.create(BX_COUNTOF(at), at);
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer.m_fbo[0]) );
GL_CHECK(glFramebufferTexture2D(
GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, texture.m_id
- , attachment[0].mip
+ , at[0].mip
) );
if (!BX_ENABLED(BX_PLATFORM_EMSCRIPTEN)
- && !BX_ENABLED(BX_PLATFORM_IOS))
+ && !BX_ENABLED(BX_PLATFORM_IOS) )
{
GL_CHECK(glReadBuffer(GL_COLOR_ATTACHMENT0) );
}
@@ -2927,6 +2959,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
width = frameBuffer.m_width;
height = frameBuffer.m_height;
}
+
m_glctx.makeCurrent(swapChain);
uint32_t length = width*height*4;
@@ -2970,26 +3003,46 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
bx::memCopy(m_uniforms[_loc], _data, _size);
}
- void setMarker(const char* _marker, uint32_t _size) override
+ void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override
{
- GL_CHECK(glInsertEventMarker(_size, _marker) );
+ m_occlusionQuery.invalidate(_handle);
}
- void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override
+ void setMarker(const char* _marker, uint16_t _len) override
{
- m_occlusionQuery.invalidate(_handle);
+ GL_CHECK(glInsertEventMarker(_len, _marker) );
}
- virtual void setName(Handle _handle, const char* _name) override
+ virtual void setName(Handle _handle, const char* _name, uint16_t _len) override
{
+ uint16_t len = bx::min(_len, m_maxLabelLen);
+
switch (_handle.type)
{
+ case Handle::IndexBuffer:
+ GL_CHECK(glObjectLabel(GL_BUFFER, m_indexBuffers[_handle.idx].m_id, len, _name) );
+ break;
+
case Handle::Shader:
- GL_CHECK(glObjectLabel(GL_SHADER, m_shaders[_handle.idx].m_id, -1, _name) );
+ GL_CHECK(glObjectLabel(GL_SHADER, m_shaders[_handle.idx].m_id, len, _name) );
break;
case Handle::Texture:
- GL_CHECK(glObjectLabel(GL_TEXTURE, m_textures[_handle.idx].m_id, -1, _name) );
+ {
+ GLint id = m_textures[_handle.idx].m_id;
+ if (0 != id)
+ {
+ GL_CHECK(glObjectLabel(GL_TEXTURE, id, len, _name) );
+ }
+ else
+ {
+ GL_CHECK(glObjectLabel(GL_RENDERBUFFER, m_textures[_handle.idx].m_rbo, len, _name) );
+ }
+ }
+ break;
+
+ case Handle::VertexBuffer:
+ GL_CHECK(glObjectLabel(GL_BUFFER, m_vertexBuffers[_handle.idx].m_id, len, _name) );
break;
default:
@@ -3028,7 +3081,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
GL_CHECK(glUniform1i(program.m_sampler[0], 0) );
float proj[16];
- bx::mtxOrtho(proj, 0.0f, (float)width, (float)height, 0.0f, 0.0f, 1000.0f, 0.0f, true);
+ bx::mtxOrtho(proj, 0.0f, (float)width, (float)height, 0.0f, 0.0f, 1000.0f, 0.0f, g_caps.homogeneousDepth);
GL_CHECK(glUniformMatrix4fv(program.m_predefined[0].m_loc
, 1
@@ -3058,7 +3111,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
if (0 < numVertices)
{
m_indexBuffers[_blitter.m_ib->handle.idx].update(0, _numIndices*2, _blitter.m_ib->data);
- m_vertexBuffers[_blitter.m_vb->handle.idx].update(0, numVertices*_blitter.m_decl.m_stride, _blitter.m_vb->data);
+ m_vertexBuffers[_blitter.m_vb->handle.idx].update(0, numVertices*_blitter.m_layout.m_stride, _blitter.m_vb->data);
VertexBufferGL& vb = m_vertexBuffers[_blitter.m_vb->handle.idx];
GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, vb.m_id) );
@@ -3068,7 +3121,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
ProgramGL& program = m_program[_blitter.m_program.idx];
program.bindAttributesBegin();
- program.bindAttributes(_blitter.m_decl, 0);
+ program.bindAttributes(_blitter.m_layout, 0);
program.bindAttributesEnd();
GL_CHECK(glDrawElements(GL_TRIANGLES
@@ -3192,6 +3245,8 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
if (UINT16_MAX != frameBuffer.m_denseIdx)
{
m_glctx.makeCurrent(frameBuffer.m_swapChain);
+ GL_CHECK(glFrontFace(GL_CW) );
+
frameBuffer.m_needPresent = true;
m_currentFbo = 0;
}
@@ -3200,6 +3255,8 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
m_glctx.makeCurrent(NULL);
m_currentFbo = frameBuffer.m_fbo[0];
}
+
+ frameBuffer.set();
}
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_currentFbo) );
@@ -3227,11 +3284,16 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
if (0 == m_msaaBackBufferFbo // iOS
&& 1 < _msaa)
{
+ GLenum storageFormat = (m_resolution.reset & BGFX_RESET_SRGB_BACKBUFFER)
+ ? GL_SRGB8_ALPHA8
+ : GL_RGBA8
+ ;
+
GL_CHECK(glGenFramebuffers(1, &m_msaaBackBufferFbo) );
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_msaaBackBufferFbo) );
GL_CHECK(glGenRenderbuffers(BX_COUNTOF(m_msaaBackBufferRbos), m_msaaBackBufferRbos) );
GL_CHECK(glBindRenderbuffer(GL_RENDERBUFFER, m_msaaBackBufferRbos[0]) );
- GL_CHECK(glRenderbufferStorageMultisample(GL_RENDERBUFFER, _msaa, GL_RGBA8, _width, _height) );
+ GL_CHECK(glRenderbufferStorageMultisample(GL_RENDERBUFFER, _msaa, storageFormat, _width, _height) );
GL_CHECK(glBindRenderbuffer(GL_RENDERBUFFER, m_msaaBackBufferRbos[1]) );
GL_CHECK(glRenderbufferStorageMultisample(GL_RENDERBUFFER, _msaa, GL_DEPTH24_STENCIL8, _width, _height) );
GL_CHECK(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_msaaBackBufferRbos[0]) );
@@ -3616,16 +3678,8 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
switch (type)
{
-// case ConstantType::Int1:
-// {
-// int* value = (int*)data;
-// BX_TRACE("Int1 sampler %d, loc %d (num %d, copy %d)", *value, loc, num, copy);
-// GL_CHECK(glUniform1iv(loc, num, value) );
-// }
-// break;
-
- CASE_IMPLEMENT_UNIFORM(Int1, 1iv, I, int);
- CASE_IMPLEMENT_UNIFORM(Vec4, 4fv, F, float);
+ CASE_IMPLEMENT_UNIFORM(Sampler, 1iv, I, int);
+ CASE_IMPLEMENT_UNIFORM(Vec4, 4fv, F, float);
CASE_IMPLEMENT_UNIFORM_T(Mat3, Matrix3fv, F, float);
CASE_IMPLEMENT_UNIFORM_T(Mat4, Matrix4fv, F, float);
@@ -3739,57 +3793,42 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
GL_CHECK(glDisable(GL_STENCIL_TEST) );
}
- VertexBufferGL& vb = m_vertexBuffers[_clearQuad.m_vb->handle.idx];
- VertexDecl& vertexDecl = m_vertexDecls[_clearQuad.m_vb->decl.idx];
-
- {
- struct Vertex
- {
- float m_x;
- float m_y;
- float m_z;
- };
-
- Vertex* vertex = (Vertex*)_clearQuad.m_vb->data;
- BX_CHECK(vertexDecl.m_stride == sizeof(Vertex), "Stride/Vertex mismatch (stride %d, sizeof(Vertex) %d)", vertexDecl.m_stride, sizeof(Vertex) );
-
- const float depth = _clear.m_depth * 2.0f - 1.0f;
-
- vertex->m_x = -1.0f;
- vertex->m_y = -1.0f;
- vertex->m_z = depth;
- vertex++;
- vertex->m_x = 1.0f;
- vertex->m_y = -1.0f;
- vertex->m_z = depth;
- vertex++;
- vertex->m_x = -1.0f;
- vertex->m_y = 1.0f;
- vertex->m_z = depth;
- vertex++;
- vertex->m_x = 1.0f;
- vertex->m_y = 1.0f;
- vertex->m_z = depth;
- }
-
- vb.update(0, 4*_clearQuad.m_decl.m_stride, _clearQuad.m_vb->data);
+ VertexBufferGL& vb = m_vertexBuffers[_clearQuad.m_vb.idx];
+ VertexLayout& layout = _clearQuad.m_layout;
GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, vb.m_id) );
ProgramGL& program = m_program[_clearQuad.m_program[numMrt-1].idx];
GL_CHECK(glUseProgram(program.m_id) );
program.bindAttributesBegin();
- program.bindAttributes(vertexDecl, 0);
+ program.bindAttributes(layout, 0);
program.bindAttributesEnd();
- float mrtClear[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS][4];
+ if (m_clearQuadColor.idx == kInvalidHandle)
+ {
+ const UniformRegInfo* infoClearColor = m_uniformReg.find("bgfx_clear_color");
+ if (NULL != infoClearColor)
+ m_clearQuadColor = infoClearColor->m_handle;
+ }
+
+ if (m_clearQuadDepth.idx == kInvalidHandle)
+ {
+ const UniformRegInfo* infoClearDepth = m_uniformReg.find("bgfx_clear_depth");
+ if (NULL != infoClearDepth)
+ m_clearQuadDepth = infoClearDepth->m_handle;
+ }
+
+ float mrtClearDepth[4] = { g_caps.homogeneousDepth ? (_clear.m_depth * 2.0f - 1.0f) : _clear.m_depth };
+ updateUniform(m_clearQuadDepth.idx, mrtClearDepth, sizeof(float)*4);
+
+ float mrtClearColor[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS][4];
if (BGFX_CLEAR_COLOR_USE_PALETTE & _clear.m_flags)
{
for (uint32_t ii = 0; ii < numMrt; ++ii)
{
uint8_t index = (uint8_t)bx::uint32_min(BGFX_CONFIG_MAX_COLOR_PALETTE-1, _clear.m_index[ii]);
- bx::memCopy(mrtClear[ii], _palette[index], 16);
+ bx::memCopy(mrtClearColor[ii], _palette[index], 16);
}
}
else
@@ -3804,11 +3843,13 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
for (uint32_t ii = 0; ii < numMrt; ++ii)
{
- bx::memCopy(mrtClear[ii], rgba, 16);
+ bx::memCopy(mrtClearColor[ii], rgba, 16);
}
}
- GL_CHECK(glUniform4fv(0, numMrt, mrtClear[0]) );
+ updateUniform(m_clearQuadColor.idx, mrtClearColor[0], numMrt * sizeof(float) * 4);
+
+ commit(*program.m_constantBuffer);
GL_CHECK(glDrawArrays(GL_TRIANGLE_STRIP
, 0
@@ -3827,7 +3868,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
ShaderGL m_shaders[BGFX_CONFIG_MAX_SHADERS];
ProgramGL m_program[BGFX_CONFIG_MAX_PROGRAMS];
TextureGL m_textures[BGFX_CONFIG_MAX_TEXTURES];
- VertexDecl m_vertexDecls[BGFX_CONFIG_MAX_VERTEX_DECLS];
+ VertexLayout m_vertexLayouts[BGFX_CONFIG_MAX_VERTEX_LAYOUTS];
FrameBufferGL m_frameBuffers[BGFX_CONFIG_MAX_FRAME_BUFFERS];
UniformRegistry m_uniformReg;
void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS];
@@ -3850,6 +3891,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
float m_maxAnisotropyDefault;
int32_t m_maxMsaa;
GLuint m_vao;
+ uint16_t m_maxLabelLen;
bool m_blitSupported;
bool m_readBackSupported;
bool m_vaoSupport;
@@ -3864,6 +3906,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
bool m_occlusionQuerySupport;
bool m_atocSupport;
bool m_conservativeRasterSupport;
+ bool m_imageLoadStoreSupport;
bool m_flip;
uint64_t m_hash;
@@ -3875,6 +3918,9 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
GlContext m_glctx;
bool m_needPresent;
+ UniformHandle m_clearQuadColor;
+ UniformHandle m_clearQuadDepth;
+
const char* m_vendor;
const char* m_renderer;
const char* m_version;
@@ -4020,7 +4066,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
{
case GL_INT:
case GL_UNSIGNED_INT:
- return UniformType::Int1;
+ return UniformType::Sampler;
case GL_FLOAT:
case GL_FLOAT_VEC2:
@@ -4076,7 +4122,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
case GL_IMAGE_CUBE:
case GL_INT_IMAGE_CUBE:
case GL_UNSIGNED_INT_IMAGE_CUBE:
- return UniformType::Int1;
+ return UniformType::Sampler;
};
BX_CHECK(false, "Unrecognized GL type 0x%04x.", _type);
@@ -4462,7 +4508,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
m_instanceData[used] = 0xffff;
}
- void ProgramGL::bindAttributes(const VertexDecl& _vertexDecl, uint32_t _baseVertex)
+ void ProgramGL::bindAttributes(const VertexLayout& _layout, uint32_t _baseVertex)
{
for (uint32_t ii = 0, iiEnd = m_usedCount; ii < iiEnd; ++ii)
{
@@ -4473,16 +4519,16 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
AttribType::Enum type;
bool normalized;
bool asInt;
- _vertexDecl.decode(attr, num, type, normalized, asInt);
+ _layout.decode(attr, num, type, normalized, asInt);
if (-1 != loc)
{
- if (UINT16_MAX != _vertexDecl.m_attributes[attr])
+ if (UINT16_MAX != _layout.m_attributes[attr])
{
GL_CHECK(glEnableVertexAttribArray(loc) );
GL_CHECK(glVertexAttribDivisor(loc, 0) );
- uint32_t baseVertex = _baseVertex*_vertexDecl.m_stride + _vertexDecl.m_offset[attr];
+ uint32_t baseVertex = _baseVertex*_layout.m_stride + _layout.m_offset[attr];
if ( (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL >= 30) || BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES >= 31) )
&& (AttribType::Uint8 == type || AttribType::Int16 == type)
&& !normalized)
@@ -4490,7 +4536,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
GL_CHECK(glVertexAttribIPointer(loc
, num
, s_attribType[type]
- , _vertexDecl.m_stride
+ , _layout.m_stride
, (void*)(uintptr_t)baseVertex)
);
}
@@ -4500,7 +4546,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
, num
, s_attribType[type]
, normalized
- , _vertexDecl.m_stride
+ , _layout.m_stride
, (void*)(uintptr_t)baseVertex)
);
}
@@ -4554,7 +4600,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
void VertexBufferGL::destroy()
{
- GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, 0) );
+ GL_CHECK(glBindBuffer(m_target, 0) );
GL_CHECK(glDeleteBuffers(1, &m_id) );
}
@@ -4709,22 +4755,20 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
if (bimg::imageParse(imageContainer, _mem->data, _mem->size) )
{
- uint8_t numMips = imageContainer.m_numMips;
- const uint8_t startLod = uint8_t(bx::uint32_min(_skip, numMips-1) );
- numMips -= startLod;
- const uint16_t numLayers = imageContainer.m_numLayers;
- uint32_t textureWidth;
- uint32_t textureHeight;
- uint32_t textureDepth;
- {
- const bimg::ImageBlockInfo& ibi = bimg::getBlockInfo(bimg::TextureFormat::Enum(imageContainer.m_format) );
- textureWidth = bx::uint32_max(ibi.blockWidth, imageContainer.m_width >>startLod);
- textureHeight = bx::uint32_max(ibi.blockHeight, imageContainer.m_height>>startLod);
- textureDepth = 1 < imageContainer.m_depth
- ? imageContainer.m_depth
- : imageContainer.m_numLayers
- ;
- }
+ const uint8_t startLod = bx::min<uint8_t>(_skip, imageContainer.m_numMips-1);
+
+ bimg::TextureInfo ti;
+ bimg::imageGetSize(
+ &ti
+ , uint16_t(imageContainer.m_width >>startLod)
+ , uint16_t(imageContainer.m_height>>startLod)
+ , uint16_t(imageContainer.m_depth >>startLod)
+ , imageContainer.m_cubeMap
+ , 1 < imageContainer.m_numMips
+ , imageContainer.m_numLayers
+ , imageContainer.m_format
+ );
+ ti.numMips = bx::min<uint8_t>(imageContainer.m_numMips-startLod, ti.numMips);
m_requestedFormat = uint8_t(imageContainer.m_format);
m_textureFormat = uint8_t(getViableTextureFormat(imageContainer) );
@@ -4746,7 +4790,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
target = GL_TEXTURE_3D;
}
- const bool textureArray = 1 < numLayers;
+ const bool textureArray = 1 < ti.numLayers;
if (textureArray)
{
switch (target)
@@ -4758,16 +4802,18 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
}
if (!init(target
- , textureWidth
- , textureHeight
- , textureDepth
- , numMips
- , _flags
- ) )
+ , ti.width
+ , ti.height
+ , textureArray ? ti.numLayers : ti.depth
+ , ti.numMips
+ , _flags
+ ) )
{
return;
}
+ m_numLayers = ti.numLayers;
+
target = isCubeMap()
? GL_TEXTURE_CUBE_MAP_POSITIVE_X
: m_target
@@ -4795,9 +4841,9 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
, getName( (TextureFormat::Enum)m_textureFormat)
, srgb ? "+sRGB " : ""
, getName( (TextureFormat::Enum)m_requestedFormat)
- , numLayers
- , textureWidth
- , textureHeight
+ , ti.numLayers
+ , ti.width
+ , ti.height
, imageContainer.m_cubeMap ? 6 : (1 < imageContainer.m_depth ? imageContainer.m_depth : 0)
, 0 != (m_flags&BGFX_TEXTURE_RT_MASK) ? " (render target)" : ""
);
@@ -4813,22 +4859,22 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
uint8_t* temp = NULL;
if (convert)
{
- temp = (uint8_t*)BX_ALLOC(g_allocator, textureWidth*textureHeight*4);
+ temp = (uint8_t*)BX_ALLOC(g_allocator, ti.width*ti.height*4);
}
- const uint16_t numSides = numLayers * (imageContainer.m_cubeMap ? 6 : 1);
+ const uint16_t numSides = ti.numLayers * (imageContainer.m_cubeMap ? 6 : 1);
for (uint16_t side = 0; side < numSides; ++side)
{
- uint32_t width = textureWidth;
- uint32_t height = textureHeight;
- uint32_t depth = imageContainer.m_depth;
+ uint32_t width = ti.width;
+ uint32_t height = ti.height;
+ uint32_t depth = ti.depth;
GLenum imageTarget = imageContainer.m_cubeMap && !textureArray
? target+side
: target
;
- for (uint8_t lod = 0, num = numMips; lod < num; ++lod)
+ for (uint8_t lod = 0, num = ti.numMips; lod < num; ++lod)
{
width = bx::uint32_max(1, width);
height = bx::uint32_max(1, height);
@@ -4890,8 +4936,8 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
{
if (compressed)
{
- uint32_t size = bx::uint32_max(1, (width + 3)>>2)
- * bx::uint32_max(1, (height + 3)>>2)
+ uint32_t size = bx::max<uint32_t>(1, (width + 3)>>2)
+ * bx::max<uint32_t>(1, (height + 3)>>2)
* 4*4* bimg::getBitsPerPixel(bimg::TextureFormat::Enum(m_textureFormat) )/8
;
@@ -5300,8 +5346,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
if (0 != m_id)
{
- if (GL_COMPUTE_SHADER != m_type
- && 0 != bx::strCmp(code, "#version 430", 12) )
+ if (GL_COMPUTE_SHADER != m_type)
{
int32_t tempLen = code.getLength() + (4<<10);
char* temp = (char*)alloca(tempLen);
@@ -5493,7 +5538,22 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
&& s_extension[Extension::ARB_shader_texture_lod].m_supported
&& !bx::findIdentifierMatch(code, s_ARB_shader_texture_lod).isEmpty()
;
- const bool usesGpuShader4 = !bx::findIdentifierMatch(code, s_EXT_gpu_shader4).isEmpty();
+
+ const bool usesVertexID = true
+ && !s_extension[Extension::EXT_gpu_shader4].m_supported
+ && !bx::findIdentifierMatch(code, "gl_VertexID").isEmpty()
+ ;
+
+ const bool usesInstanceID = true
+ && !s_extension[Extension::EXT_gpu_shader4].m_supported
+ && !bx::findIdentifierMatch(code, "gl_InstanceID").isEmpty()
+ ;
+
+ const bool usesGpuShader4 = true
+ && s_extension[Extension::EXT_gpu_shader4].m_supported
+ && !bx::findIdentifierMatch(code, s_EXT_gpu_shader4).isEmpty()
+ ;
+
const bool usesGpuShader5 = !bx::findIdentifierMatch(code, s_ARB_gpu_shader5).isEmpty();
const bool usesIUsamplers = !bx::findIdentifierMatch(code, s_uisamplers).isEmpty();
const bool usesUint = !bx::findIdentifierMatch(code, s_uint).isEmpty();
@@ -5508,6 +5568,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
: usesTextureArray
|| usesTexture3D
|| usesIUsamplers
+ || usesVertexID
|| usesUint
|| usesTexelFetch
|| usesGpuShader5
@@ -5516,12 +5577,11 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
: 120
;
- if (0 != version)
- {
- bx::write(&writer, &err, "#version %d\n", version);
- }
+ version = 0 == bx::strCmp(code, "#version 430", 12) ? 430 : version;
- if (usesTextureLod)
+ bx::write(&writer, &err, "#version %d\n", version);
+
+ if (430 > version && usesTextureLod)
{
if (m_type == GL_FRAGMENT_SHADER)
{
@@ -5534,6 +5594,11 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
}
}
+ if (usesInstanceID)
+ {
+ bx::write(&writer, "#extension GL_ARB_draw_instanced : enable\n");
+ }
+
if (usesGpuShader4)
{
bx::write(&writer, "#extension GL_EXT_gpu_shader4 : enable\n");
@@ -5560,7 +5625,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
if (BX_ENABLED(BX_PLATFORM_OSX) )
{
- bx::write(&writer, "#define texture2DArrayLodEXT texture2DArray\n");
+ bx::write(&writer, "#define texture2DArrayLod texture2DArray\n");
}
else
{
@@ -5584,14 +5649,17 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
if (130 <= version)
{
- if (m_type == GL_FRAGMENT_SHADER)
- {
- bx::write(&writer, "#define varying in\n");
- }
- else
+ if (430 > version)
{
- bx::write(&writer, "#define attribute in\n");
- bx::write(&writer, "#define varying out\n");
+ if (m_type == GL_FRAGMENT_SHADER)
+ {
+ bx::write(&writer, "#define varying in\n");
+ }
+ else
+ {
+ bx::write(&writer, "#define attribute in\n");
+ bx::write(&writer, "#define varying out\n");
+ }
}
uint32_t fragData = 0;
@@ -5613,7 +5681,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
bx::write(&writer, &err, "out vec4 bgfx_FragData[%d];\n", fragData);
bx::write(&writer, "#define gl_FragData bgfx_FragData\n");
}
- else
+ else if (!bx::findIdentifierMatch(code, "gl_FragColor").isEmpty() )
{
bx::write(&writer, "out vec4 bgfx_FragColor;\n");
bx::write(&writer, "#define gl_FragColor bgfx_FragColor\n");
@@ -5650,7 +5718,16 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
);
}
- bx::write(&writer, code);
+ if (version == 430)
+ {
+ int32_t verLen = bx::strLen("#version 430\n");
+ bx::write(&writer, code.getPtr()+verLen, code.getLength()-verLen);
+ }
+ else
+ {
+ bx::write(&writer, code);
+ }
+
bx::write(&writer, '\0');
}
else if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL >= 31)
@@ -5767,7 +5844,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
code.set(temp);
}
- else if (GL_COMPUTE_SHADER == m_type)
+ else // GL_COMPUTE_SHADER
{
int32_t codeLen = (int32_t)bx::strLen(code);
int32_t tempLen = codeLen + (4<<10);
@@ -5776,15 +5853,19 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
bx::write(&writer
, "#version 430\n"
- "#define texture2DLod textureLod\n"
- "#define texture3DLod textureLod\n"
- "#define textureCubeLod textureLod\n"
- "#define texture2DGrad textureGrad\n"
- "#define texture3DGrad textureGrad\n"
- "#define textureCubeGrad textureGrad\n"
+ "#define texture2DLod textureLod\n"
+ "#define texture2DLodOffset textureLodOffset\n"
+ "#define texture2DArrayLod textureLod\n"
+ "#define texture2DArrayLodOffset textureLodOffset\n"
+ "#define texture3DLod textureLod\n"
+ "#define textureCubeLod textureLod\n"
+ "#define texture2DGrad textureGrad\n"
+ "#define texture3DGrad textureGrad\n"
+ "#define textureCubeGrad textureGrad\n"
);
- bx::write(&writer, code.getPtr()+bx::strLen("#version 430"), codeLen);
+ int32_t verLen = bx::strLen("#version 430\n");
+ bx::write(&writer, code.getPtr()+verLen, codeLen-verLen);
bx::write(&writer, '\0');
code = temp;
@@ -5906,7 +5987,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
attachment = GL_DEPTH_ATTACHMENT;
}
}
- else
+ else if (Access::Write == at.access)
{
buffers[colorIdx] = attachment;
++colorIdx;
@@ -5938,9 +6019,9 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
) );
}
}
- else if (Access::Write == at.access)
+ else
{
- if (1 < texture.m_depth
+ if (1 < texture.m_numLayers
&& !texture.isCubeMap())
{
GL_CHECK(glFramebufferTextureLayer(GL_FRAMEBUFFER
@@ -5965,10 +6046,6 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
) );
}
}
- else
- {
- BX_CHECK(false, "");
- }
needResolve |= (0 != texture.m_rbo) && (0 != texture.m_id);
}
@@ -6166,6 +6243,36 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
GL_CHECK(glInvalidateFramebuffer(GL_FRAMEBUFFER, idx, buffers) );
}
+ void FrameBufferGL::set()
+ {
+ for(uint32_t ii = 0; ii < m_numTh; ++ii)
+ {
+ const Attachment& at = m_attachment[ii];
+
+ if (at.access == Access::Write)
+ {
+ continue;
+ }
+
+ if (isValid(at.handle) )
+ {
+ const TextureGL& texture = s_renderGL->m_textures[at.handle.idx];
+
+ if(0 != (texture.m_flags&BGFX_TEXTURE_COMPUTE_WRITE))
+ {
+ GL_CHECK(glBindImageTexture(ii
+ , texture.m_id
+ , at.mip
+ , GL_FALSE //texture.isLayered() ? GL_TRUE : GL_FALSE
+ , at.layer
+ , s_access[Access::ReadWrite]
+ , s_imageFormat[texture.m_textureFormat])
+ );
+ }
+ }
+ }
+ }
+
void OcclusionQueryGL::create()
{
for (uint32_t ii = 0; ii < BX_COUNTOF(m_query); ++ii)
@@ -6292,6 +6399,10 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
renderDocTriggerCapture();
}
+ m_glctx.makeCurrent(NULL);
+
+ BGFX_GL_PROFILER_BEGIN_LITERAL("rendererSubmit", kColorView);
+
if (1 < m_numWindows
&& m_vaoSupport)
{
@@ -6301,8 +6412,6 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
m_vao = 0;
}
- m_glctx.makeCurrent(NULL);
-
const GLuint defaultVao = m_vao;
if (0 != defaultVao)
{
@@ -6327,12 +6436,14 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
if (0 < _render->m_iboffset)
{
+ BGFX_PROFILER_SCOPE("bgfx/Update transient index buffer", kColorResource);
TransientIndexBuffer* ib = _render->m_transientIb;
m_indexBuffers[ib->handle.idx].update(0, _render->m_iboffset, ib->data, true);
}
if (0 < _render->m_vboffset)
{
+ BGFX_PROFILER_SCOPE("bgfx/Update transient vertex buffer", kColorResource);
TransientVertexBuffer* vb = _render->m_transientVb;
m_vertexBuffers[vb->handle.idx].update(0, _render->m_vboffset, vb->data, true);
}
@@ -6347,12 +6458,11 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
RenderBind currentBind;
currentBind.clear();
- const bool hmdEnabled = false;
static ViewState viewState;
- viewState.reset(_render, hmdEnabled);
+ viewState.reset(_render);
- uint16_t programIdx = kInvalidHandle;
- uint16_t boundProgramIdx = kInvalidHandle;
+ ProgramHandle currentProgram = BGFX_INVALID_HANDLE;
+ ProgramHandle boundProgram = BGFX_INVALID_HANDLE;
SortKey key;
uint16_t view = UINT16_MAX;
FrameBufferHandle fbh = { BGFX_CONFIG_MAX_FRAME_BUFFERS };
@@ -6406,18 +6516,14 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
m_occlusionQuery.resolve(_render);
}
- uint8_t eye = 0;
-
if (0 == (_render->m_debug&BGFX_DEBUG_IFH) )
{
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_msaaBackBufferFbo) );
- bool viewRestart = false;
- uint8_t restartState = 0;
viewState.m_rect = _render->m_view[0].m_rect;
-
int32_t numItems = _render->m_numRenderItems;
- for (int32_t item = 0, restartItem = numItems; item < numItems || restartItem < numItems;)
+
+ for (int32_t item = 0; item < numItems;)
{
const uint64_t encodedKey = _render->m_sortKeys[item];
const bool isCompute = key.decode(encodedKey, _render->m_viewRemap);
@@ -6435,17 +6541,15 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
if (viewChanged)
{
- if (1 == restartState)
+ view = key.m_view;
+ currentProgram = BGFX_INVALID_HANDLE;
+
+ if (item > 1)
{
- restartState = 2;
- item = restartItem;
- restartItem = numItems;
- view = UINT16_MAX;
- continue;
+ profiler.end();
}
- view = key.m_view;
- programIdx = kInvalidHandle;
+ BGFX_GL_PROFILER_END();
if (_render->m_view[view].m_fbh.idx != fbh.idx)
{
@@ -6454,55 +6558,12 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
resolutionHeight = setFrameBuffer(fbh, resolutionHeight, discardFlags);
}
- viewRestart = ( (BGFX_VIEW_STEREO == (_render->m_view[view].m_flags & BGFX_VIEW_STEREO) ) );
- viewRestart &= hmdEnabled;
- if (viewRestart)
- {
- if (0 == restartState)
- {
- restartState = 1;
- restartItem = item - 1;
- }
-
- eye = (restartState - 1) & 1;
- restartState &= 1;
- }
- else
- {
- eye = 0;
- }
-
- if (item > 1)
- {
- profiler.end();
- }
+ setViewType(view, " ");
+ BGFX_GL_PROFILER_BEGIN(view, kColorView);
profiler.begin(view);
viewState.m_rect = _render->m_view[view].m_rect;
- if (viewRestart)
- {
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
- {
- char* viewName = s_viewName[view];
- viewName[3] = ' ';
- viewName[4] = eye ? 'R' : 'L';
- GL_CHECK(glInsertEventMarker(0, viewName) );
- }
-
- viewState.m_rect.m_x = eye * (viewState.m_rect.m_width+1)/2;
- viewState.m_rect.m_width /= 2;
- }
- else
- {
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
- {
- char* viewName = s_viewName[view];
- viewName[3] = ' ';
- viewName[4] = ' ';
- GL_CHECK(glInsertEventMarker(0, viewName) );
- }
- }
const Rect& scissorRect = _render->m_view[view].m_scissor;
viewHasScissor = !scissorRect.isZero();
@@ -6537,19 +6598,16 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
{
wasCompute = true;
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
- {
- char* viewName = s_viewName[view];
- viewName[3] = 'C';
- GL_CHECK(glInsertEventMarker(0, viewName) );
- }
+ setViewType(view, "C");
+ BGFX_GL_PROFILER_END();
+ BGFX_GL_PROFILER_BEGIN(view, kColorCompute);
}
if (computeSupported)
{
const RenderCompute& compute = renderItem.compute;
- ProgramGL& program = m_program[key.m_program];
+ ProgramGL& program = m_program[key.m_program.idx];
GL_CHECK(glUseProgram(program.m_id) );
GLbitfield barrier = 0;
@@ -6569,24 +6627,16 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
case Binding::Image:
{
- if (Access::Read == bind.m_access)
- {
- TextureGL& texture = m_textures[bind.m_idx];
- texture.commit(ii, uint32_t(texture.m_flags), _render->m_colorPalette);
- }
- else
- {
- const TextureGL& texture = m_textures[bind.m_idx];
- GL_CHECK(glBindImageTexture(ii
- , texture.m_id
- , bind.m_mip
- , texture.isCubeMap() ? GL_TRUE : GL_FALSE
- , 0
- , s_access[bind.m_access]
- , s_imageFormat[bind.m_format])
- );
- barrier |= GL_SHADER_IMAGE_ACCESS_BARRIER_BIT;
- }
+ const TextureGL& texture = m_textures[bind.m_idx];
+ GL_CHECK(glBindImageTexture(ii
+ , texture.m_id
+ , bind.m_mip
+ , texture.isCubeMap() || texture.m_target == GL_TEXTURE_2D_ARRAY ? GL_TRUE : GL_FALSE
+ , 0
+ , s_access[bind.m_access]
+ , s_imageFormat[bind.m_format])
+ );
+ barrier |= GL_SHADER_IMAGE_ACCESS_BARRIER_BIT;
}
break;
@@ -6620,10 +6670,11 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
commit(*program.m_constantBuffer);
}
- viewState.setPredefined<1>(this, view, eye, program, _render, compute);
+ viewState.setPredefined<1>(this, view, program, _render, compute);
if (isValid(compute.m_indirectBuffer) )
{
+ barrier |= GL_COMMAND_BARRIER_BIT;
const VertexBufferGL& vb = m_vertexBuffers[compute.m_indirectBuffer.idx];
if (currentState.m_indirectBuffer.idx != compute.m_indirectBuffer.idx)
{
@@ -6667,12 +6718,9 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
{
wasCompute = false;
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
- {
- char* viewName = s_viewName[view];
- viewName[3] = ' ';
- GL_CHECK(glInsertEventMarker(0, viewName) );
- }
+ setViewType(view, " ");
+ BGFX_GL_PROFILER_END();
+ BGFX_GL_PROFILER_BEGIN(view, kColorDraw);
}
const RenderDraw& draw = renderItem.draw;
@@ -7041,13 +7089,13 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
bool bindAttribs = false;
rendererUpdateUniforms(this, _render->m_uniformBuffer[draw.m_uniformIdx], draw.m_uniformBegin, draw.m_uniformEnd);
- if (key.m_program != programIdx)
+ if (key.m_program.idx != currentProgram.idx)
{
- programIdx = key.m_program;
- GLuint id = kInvalidHandle == programIdx ? 0 : m_program[programIdx].m_id;
+ currentProgram = key.m_program;
+ GLuint id = isValid(currentProgram) ? m_program[currentProgram.idx].m_id : 0;
// Skip rendering if program index is valid, but program is invalid.
- programIdx = 0 == id ? kInvalidHandle : programIdx;
+ currentProgram = 0 == id ? ProgramHandle{kInvalidHandle} : currentProgram;
GL_CHECK(glUseProgram(id) );
programChanged =
@@ -7055,9 +7103,9 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
bindAttribs = true;
}
- if (kInvalidHandle != programIdx)
+ if (isValid(currentProgram) )
{
- ProgramGL& program = m_program[programIdx];
+ ProgramGL& program = m_program[currentProgram.idx];
if (constantsChanged
&& NULL != program.m_constantBuffer)
@@ -7065,7 +7113,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
commit(*program.m_constantBuffer);
}
- viewState.setPredefined<1>(this, view, eye, program, _render, draw);
+ viewState.setPredefined<1>(this, view, program, _render, draw);
{
for (uint32_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage)
@@ -7111,11 +7159,12 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
{
bool diffStreamHandles = false;
- for (uint32_t idx = 0, streamMask = draw.m_streamMask, ntz = bx::uint32_cnttz(streamMask)
+ for (uint32_t idx = 0, streamMask = draw.m_streamMask
; 0 != streamMask
- ; streamMask >>= 1, idx += 1, ntz = bx::uint32_cnttz(streamMask)
+ ; streamMask >>= 1, idx += 1
)
{
+ const uint32_t ntz = bx::uint32_cnttz(streamMask);
streamMask >>= ntz;
idx += ntz;
@@ -7138,11 +7187,12 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
currentState.m_instanceDataOffset = draw.m_instanceDataOffset;
currentState.m_instanceDataStride = draw.m_instanceDataStride;
- for (uint32_t idx = 0, streamMask = draw.m_streamMask, ntz = bx::uint32_cnttz(streamMask)
+ for (uint32_t idx = 0, streamMask = draw.m_streamMask
; 0 != streamMask
- ; streamMask >>= 1, idx += 1, ntz = bx::uint32_cnttz(streamMask)
+ ; streamMask >>= 1, idx += 1
)
{
+ const uint32_t ntz = bx::uint32_cnttz(streamMask);
streamMask >>= ntz;
idx += ntz;
@@ -7171,11 +7221,12 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
if (0 != currentState.m_streamMask)
{
bool diffStartVertex = false;
- for (uint32_t idx = 0, streamMask = draw.m_streamMask, ntz = bx::uint32_cnttz(streamMask)
+ for (uint32_t idx = 0, streamMask = draw.m_streamMask
; 0 != streamMask
- ; streamMask >>= 1, idx += 1, ntz = bx::uint32_cnttz(streamMask)
+ ; streamMask >>= 1, idx += 1
)
{
+ const uint32_t ntz = bx::uint32_cnttz(streamMask);
streamMask >>= ntz;
idx += ntz;
@@ -7188,32 +7239,35 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
if (bindAttribs || diffStartVertex)
{
- if(kInvalidHandle != boundProgramIdx)
+ if (isValid(boundProgram) )
{
- ProgramGL& boundProgram = m_program[boundProgramIdx];
- boundProgram.unbindAttributes();
+ m_program[boundProgram.idx].unbindAttributes();
+ boundProgram = BGFX_INVALID_HANDLE;
}
- boundProgramIdx = programIdx;
+ boundProgram = currentProgram;
program.bindAttributesBegin();
if (UINT8_MAX != draw.m_streamMask)
{
- for (uint32_t idx = 0, streamMask = draw.m_streamMask, ntz = bx::uint32_cnttz(streamMask)
+ for (uint32_t idx = 0, streamMask = draw.m_streamMask
; 0 != streamMask
- ; streamMask >>= 1, idx += 1, ntz = bx::uint32_cnttz(streamMask)
+ ; streamMask >>= 1, idx += 1
)
{
+ const uint32_t ntz = bx::uint32_cnttz(streamMask);
streamMask >>= ntz;
idx += ntz;
currentState.m_stream[idx].m_startVertex = draw.m_stream[idx].m_startVertex;
const VertexBufferGL& vb = m_vertexBuffers[draw.m_stream[idx].m_handle.idx];
- uint16_t decl = !isValid(vb.m_decl) ? draw.m_stream[idx].m_decl.idx : vb.m_decl.idx;
+ const uint16_t decl = isValid(draw.m_stream[idx].m_layoutHandle)
+ ? draw.m_stream[idx].m_layoutHandle.idx
+ : vb.m_layoutHandle.idx;
GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, vb.m_id) );
- program.bindAttributes(m_vertexDecls[decl], draw.m_stream[idx].m_startVertex);
+ program.bindAttributes(m_vertexLayouts[decl], draw.m_stream[idx].m_startVertex);
}
}
@@ -7233,19 +7287,20 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
uint32_t numVertices = draw.m_numVertices;
if (UINT32_MAX == numVertices)
{
- for (uint32_t idx = 0, streamMask = draw.m_streamMask, ntz = bx::uint32_cnttz(streamMask)
+ for (uint32_t idx = 0, streamMask = draw.m_streamMask
; 0 != streamMask
- ; streamMask >>= 1, idx += 1, ntz = bx::uint32_cnttz(streamMask)
+ ; streamMask >>= 1, idx += 1
)
{
+ const uint32_t ntz = bx::uint32_cnttz(streamMask);
streamMask >>= ntz;
idx += ntz;
const VertexBufferGL& vb = m_vertexBuffers[draw.m_stream[idx].m_handle.idx];
- uint16_t decl = !isValid(vb.m_decl) ? draw.m_stream[idx].m_decl.idx : vb.m_decl.idx;
- const VertexDecl& vertexDecl = m_vertexDecls[decl];
+ uint16_t decl = !isValid(vb.m_layoutHandle) ? draw.m_stream[idx].m_layoutHandle.idx : vb.m_layoutHandle.idx;
+ const VertexLayout& layout = m_vertexLayouts[decl];
- numVertices = bx::uint32_min(numVertices, vb.m_size/vertexDecl.m_stride);
+ numVertices = bx::uint32_min(numVertices, vb.m_size/layout.m_stride);
}
}
@@ -7384,10 +7439,17 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
}
}
- if(kInvalidHandle != boundProgramIdx)
+ if (isValid(boundProgram) )
+ {
+ m_program[boundProgram.idx].unbindAttributes();
+ boundProgram = BGFX_INVALID_HANDLE;
+ }
+
+ if (wasCompute)
{
- ProgramGL& boundProgram = m_program[boundProgramIdx];
- boundProgram.unbindAttributes();
+ setViewType(view, "C");
+ BGFX_GL_PROFILER_END();
+ BGFX_GL_PROFILER_BEGIN(view, kColorCompute);
}
submitBlit(bs, BGFX_CONFIG_MAX_VIEWS);
@@ -7414,6 +7476,8 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
}
}
+ BGFX_GL_PROFILER_END();
+
m_glctx.makeCurrent(NULL);
int64_t timeEnd = bx::getHPCounter();
int64_t frameTime = timeEnd - timeBegin;
@@ -7459,6 +7523,8 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
if (_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) )
{
+ BGFX_GL_PROFILER_BEGIN_LITERAL("debugstats", kColorFrame);
+
m_needPresent = true;
TextVideoMem& tvm = m_textVideoMem;
@@ -7627,10 +7693,16 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
}
blit(this, _textVideoMemBlitter, tvm);
+
+ BGFX_GL_PROFILER_END();
}
else if (_render->m_debug & BGFX_DEBUG_TEXT)
{
+ BGFX_GL_PROFILER_BEGIN_LITERAL("debugtext", kColorFrame);
+
blit(this, _textVideoMemBlitter, _render->m_textVideoMem);
+
+ BGFX_GL_PROFILER_END();
}
}
} } // namespace bgfx
diff --git a/3rdparty/bgfx/src/renderer_gl.h b/3rdparty/bgfx/src/renderer_gl.h
index bccee98fe48..e8d653c93ce 100644
--- a/3rdparty/bgfx/src/renderer_gl.h
+++ b/3rdparty/bgfx/src/renderer_gl.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -9,7 +9,6 @@
#define BGFX_USE_EGL (BGFX_CONFIG_RENDERER_OPENGLES && (0 \
|| BX_PLATFORM_ANDROID \
|| BX_PLATFORM_BSD \
- || BX_PLATFORM_EMSCRIPTEN \
|| BX_PLATFORM_LINUX \
|| BX_PLATFORM_NX \
|| BX_PLATFORM_RPI \
@@ -17,6 +16,10 @@
|| BX_PLATFORM_WINDOWS \
) )
+#define BGFX_USE_HTML5 (BGFX_CONFIG_RENDERER_OPENGLES && (0 \
+ || BX_PLATFORM_EMSCRIPTEN \
+ ) )
+
#define BGFX_USE_WGL (BGFX_CONFIG_RENDERER_OPENGL && BX_PLATFORM_WINDOWS)
#define BGFX_USE_GLX (BGFX_CONFIG_RENDERER_OPENGL && (0 \
|| BX_PLATFORM_BSD \
@@ -30,6 +33,24 @@
|| BX_PLATFORM_WINDOWS \
)
+#define BGFX_GL_PROFILER_BEGIN(_view, _abgr) \
+ BX_MACRO_BLOCK_BEGIN \
+ GL_CHECK(glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, s_viewName[view]) ); \
+ BGFX_PROFILER_BEGIN(s_viewName[view], _abgr); \
+ BX_MACRO_BLOCK_END
+
+#define BGFX_GL_PROFILER_BEGIN_LITERAL(_name, _abgr) \
+ BX_MACRO_BLOCK_BEGIN \
+ GL_CHECK(glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "" # _name) ); \
+ BGFX_PROFILER_BEGIN_LITERAL("" # _name, _abgr); \
+ BX_MACRO_BLOCK_END
+
+#define BGFX_GL_PROFILER_END() \
+ BX_MACRO_BLOCK_BEGIN \
+ BGFX_PROFILER_END(); \
+ GL_CHECK(glPopDebugGroup() ); \
+ BX_MACRO_BLOCK_END
+
#if BGFX_CONFIG_RENDERER_OPENGL
# if BGFX_CONFIG_RENDERER_OPENGL >= 31
# include <gl/glcorearb.h>
@@ -107,6 +128,10 @@ typedef uint64_t GLuint64;
# include "glcontext_egl.h"
# endif // BGFX_USE_EGL
+# if BGFX_USE_HTML5
+# include "glcontext_html5.h"
+# endif // BGFX_USE_EGL
+
# if BX_PLATFORM_EMSCRIPTEN
# include <emscripten/emscripten.h>
# endif // BX_PLATFORM_EMSCRIPTEN
@@ -587,6 +612,10 @@ typedef uint64_t GLuint64;
# define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF
#endif // GL_MAX_ARRAY_TEXTURE_LAYERS
+#ifndef GL_MAX_LABEL_LENGTH
+# define GL_MAX_LABEL_LENGTH 0x82E8
+#endif // GL_MAX_LABEL_LENGTH
+
#ifndef GL_QUERY_RESULT
# define GL_QUERY_RESULT 0x8866
#endif // GL_QUERY_RESULT
@@ -631,7 +660,7 @@ typedef uint64_t GLuint64;
# define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD
#endif // GL_RENDERBUFFER_FREE_MEMORY_ATI
-// http://developer.download.nvidia.com/opengl/specs/GL_NVX_gpu_memory_info.txt
+// https://web.archive.org/web/20190207230448/http://developer.download.nvidia.com/opengl/specs/GL_NVX_gpu_memory_info.txt
#ifndef GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
# define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047
#endif // GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
@@ -916,6 +945,14 @@ typedef uint64_t GLuint64;
# define GL_TEXTURE 0x1702
#endif // GL_TEXTURE
+#ifndef GL_BUFFER
+# define GL_BUFFER 0x82E0
+#endif // GL_BUFFER
+
+#ifndef GL_COMMAND_BARRIER_BIT
+# define GL_COMMAND_BARRIER_BIT 0x00000040
+#endif // GL_COMMAND_BARRIER_BIT
+
// _KHR or _ARB...
#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243
@@ -1177,10 +1214,10 @@ namespace bgfx { namespace gl
struct VertexBufferGL
{
- void create(uint32_t _size, void* _data, VertexDeclHandle _declHandle, uint16_t _flags)
+ void create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle, uint16_t _flags)
{
m_size = _size;
- m_decl = _declHandle;
+ m_layoutHandle = _layoutHandle;
const bool drawIndirect = 0 != (_flags & BGFX_BUFFER_DRAW_INDIRECT);
m_target = drawIndirect ? GL_DRAW_INDIRECT_BUFFER : GL_ARRAY_BUFFER;
@@ -1204,7 +1241,7 @@ namespace bgfx { namespace gl
{
// orphan buffer...
destroy();
- create(m_size, NULL, m_decl, 0);
+ create(m_size, NULL, m_layoutHandle, 0);
}
GL_CHECK(glBindBuffer(m_target, m_id) );
@@ -1221,7 +1258,7 @@ namespace bgfx { namespace gl
GLuint m_id;
GLenum m_target;
uint32_t m_size;
- VertexDeclHandle m_decl;
+ VertexLayoutHandle m_layoutHandle;
};
struct TextureGL
@@ -1265,6 +1302,7 @@ namespace bgfx { namespace gl
uint32_t m_width;
uint32_t m_height;
uint32_t m_depth;
+ uint32_t m_numLayers;
uint8_t m_numMips;
uint8_t m_requestedFormat;
uint8_t m_textureFormat;
@@ -1304,6 +1342,7 @@ namespace bgfx { namespace gl
uint16_t destroy();
void resolve();
void discard(uint16_t _flags);
+ void set();
SwapChainGL* m_swapChain;
GLuint m_fbo[2];
@@ -1336,7 +1375,7 @@ namespace bgfx { namespace gl
bx::memCopy(m_unboundUsedAttrib, m_used, sizeof(m_unboundUsedAttrib) );
}
- void bindAttributes(const VertexDecl& _vertexDecl, uint32_t _baseVertex = 0);
+ void bindAttributes(const VertexLayout& _layout, uint32_t _baseVertex = 0);
void bindAttributesEnd()
{
diff --git a/3rdparty/bgfx/src/renderer_gnm.cpp b/3rdparty/bgfx/src/renderer_gnm.cpp
index cb34386bc56..39c7fc44452 100644
--- a/3rdparty/bgfx/src/renderer_gnm.cpp
+++ b/3rdparty/bgfx/src/renderer_gnm.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/renderer_mtl.h b/3rdparty/bgfx/src/renderer_mtl.h
index 95e038405dc..2f536c037b1 100644
--- a/3rdparty/bgfx/src/renderer_mtl.h
+++ b/3rdparty/bgfx/src/renderer_mtl.h
@@ -18,6 +18,21 @@
# import <UIKit/UIKit.h>
#endif // BX_PLATFORM_*
+#define BGFX_MTL_PROFILER_BEGIN(_view, _abgr) \
+ BX_MACRO_BLOCK_BEGIN \
+ BGFX_PROFILER_BEGIN(s_viewName[view], _abgr); \
+ BX_MACRO_BLOCK_END
+
+#define BGFX_MTL_PROFILER_BEGIN_LITERAL(_name, _abgr) \
+ BX_MACRO_BLOCK_BEGIN \
+ BGFX_PROFILER_BEGIN_LITERAL("" # _name, _abgr); \
+ BX_MACRO_BLOCK_END
+
+#define BGFX_MTL_PROFILER_END() \
+ BX_MACRO_BLOCK_BEGIN \
+ BGFX_PROFILER_END(); \
+ BX_MACRO_BLOCK_END
+
namespace bgfx { namespace mtl
{
//runtime os check
@@ -64,7 +79,7 @@ namespace bgfx { namespace mtl
#define MTL_CLASS_END };
- typedef void (*mtlCallback)(void* userData);
+ typedef void (*mtlCallback)(void* userData);
MTL_CLASS(BlitCommandEncoder)
void copyFromTexture(
@@ -140,6 +155,11 @@ namespace bgfx { namespace mtl
{
return (uint32_t)m_obj.length;
}
+
+ void setLabel(const char* _label)
+ {
+ [m_obj setLabel:@(_label)];
+ }
MTL_CLASS_END
MTL_CLASS(CommandBuffer)
@@ -223,10 +243,31 @@ namespace bgfx { namespace mtl
[m_obj setSamplerState:_sampler atIndex:_index];
}
+ void dispatchThreadgroups(MTLSize _threadgroupsPerGrid, MTLSize _threadsPerThreadgroup)
+ {
+ [m_obj dispatchThreadgroups:_threadgroupsPerGrid threadsPerThreadgroup:_threadsPerThreadgroup];
+ }
+
+ void dispatchThreadgroupsWithIndirectBuffer(id <MTLBuffer> _indirectBuffer,
+ NSUInteger _indirectBufferOffset, MTLSize _threadsPerThreadgroup)
+ {
+ [m_obj dispatchThreadgroupsWithIndirectBuffer:_indirectBuffer indirectBufferOffset:_indirectBufferOffset threadsPerThreadgroup:_threadsPerThreadgroup];
+ }
+
void endEncoding()
{
[m_obj endEncoding];
}
+
+ void pushDebugGroup(const char* _string)
+ {
+ [m_obj pushDebugGroup:@(_string)];
+ }
+
+ void popDebugGroup()
+ {
+ [m_obj popDebugGroup];
+ }
MTL_CLASS_END
MTL_CLASS(Device)
@@ -322,10 +363,14 @@ namespace bgfx { namespace mtl
}
// Creating Command Objects Needed to Perform Computational Tasks
- id <MTLComputePipelineState> newComputePipelineStateWithFunction(id <MTLFunction> _computeFunction)
+ id <MTLComputePipelineState> newComputePipelineStateWithFunction(
+ id <MTLFunction> _computeFunction
+ , MTLPipelineOption _options
+ , MTLComputePipelineReflection** _reflection
+ )
{
NSError* error;
- id <MTLComputePipelineState> state = [m_obj newComputePipelineStateWithFunction:_computeFunction error:&error];
+ id <MTLComputePipelineState> state = [m_obj newComputePipelineStateWithFunction:_computeFunction options:_options reflection:_reflection error:&error];
BX_WARN(NULL == error
, "newComputePipelineStateWithFunction failed: %s"
@@ -487,6 +532,25 @@ namespace bgfx { namespace mtl
[m_obj drawPrimitives:_primitiveType vertexStart:_vertexStart vertexCount:_vertexCount instanceCount:_instanceCount];
}
+ void drawPrimitives(
+ MTLPrimitiveType _primitiveType
+ , id <MTLBuffer> _indirectBuffer
+ , NSUInteger _indirectBufferOffset)
+ {
+ [m_obj drawPrimitives:_primitiveType indirectBuffer:_indirectBuffer indirectBufferOffset:_indirectBufferOffset];
+ }
+
+ void drawIndexedPrimitives(
+ MTLPrimitiveType _primitiveType
+ , MTLIndexType _indexType
+ , id <MTLBuffer> _indexBuffer
+ , NSUInteger _indexBufferOffset
+ , id <MTLBuffer> _indirectBuffer
+ , NSUInteger _indirectBufferOffset)
+ {
+ [m_obj drawIndexedPrimitives:_primitiveType indexType:_indexType indexBuffer:_indexBuffer indexBufferOffset:_indexBufferOffset indirectBuffer:_indirectBuffer indirectBufferOffset:_indirectBufferOffset];
+ }
+
void insertDebugSignpost(const char* _string)
{
[m_obj insertDebugSignpost:@(_string)];
@@ -527,6 +591,11 @@ namespace bgfx { namespace mtl
return [m_obj newTextureViewWithPixelFormat:_pixelFormat];
}
+ id<MTLTexture> newTextureViewWithPixelFormat(MTLPixelFormat _pixelFormat, MTLTextureType _textureType, NSRange _levelRange, NSRange _sliceRange)
+ {
+ return [m_obj newTextureViewWithPixelFormat:_pixelFormat textureType:_textureType levels:_levelRange slices:_sliceRange];
+ }
+
//properties
uint32_t width() const
{
@@ -538,6 +607,11 @@ namespace bgfx { namespace mtl
return (uint32_t)m_obj.height;
}
+ uint32_t arrayLength() const
+ {
+ return (uint32_t)m_obj.arrayLength;
+ }
+
MTLPixelFormat pixelFormat() const
{
return m_obj.pixelFormat;
@@ -567,6 +641,7 @@ namespace bgfx { namespace mtl
//descriptors
//NOTE: [class new] is same as [[class alloc] init]
typedef MTLRenderPipelineDescriptor* RenderPipelineDescriptor;
+ typedef MTLComputePipelineReflection* ComputePipelineReflection;
inline RenderPipelineDescriptor newRenderPipelineDescriptor()
{
@@ -683,7 +758,7 @@ namespace bgfx { namespace mtl
typename HashMap::iterator it = m_hashMap.find(_id);
if (it != m_hashMap.end() )
{
- MTL_RELEASE(it->second);
+ release(it->second);
m_hashMap.erase(it);
}
}
@@ -712,13 +787,8 @@ namespace bgfx { namespace mtl
{
BufferMtl()
: m_flags(BGFX_BUFFER_NONE)
- , m_dynamic(false)
- , m_bufferIndex(0)
+ , m_dynamic(NULL)
{
- for (uint32_t ii = 0; ii < MTL_MAX_FRAMES_IN_FLIGHT; ++ii)
- {
- m_buffers[ii] = NULL;
- }
}
void create(uint32_t _size, void* _data, uint16_t _flags, uint16_t _stride = 0, bool _vertex = false);
@@ -726,23 +796,21 @@ namespace bgfx { namespace mtl
void destroy()
{
- for (uint32_t ii = 0; ii < MTL_MAX_FRAMES_IN_FLIGHT; ++ii)
+ MTL_RELEASE(m_ptr);
+
+ if (NULL != m_dynamic)
{
- MTL_RELEASE(m_buffers[ii]);
+ BX_DELETE(g_allocator, m_dynamic);
+ m_dynamic = NULL;
}
-
- m_dynamic = false;
}
- Buffer getBuffer() const { return m_buffers[m_bufferIndex]; }
-
uint32_t m_size;
uint16_t m_flags;
+ bool m_vertex;
- bool m_dynamic;
- private:
- uint8_t m_bufferIndex;
- Buffer m_buffers[MTL_MAX_FRAMES_IN_FLIGHT];
+ Buffer m_ptr;
+ uint8_t* m_dynamic;
};
typedef BufferMtl IndexBufferMtl;
@@ -754,9 +822,9 @@ namespace bgfx { namespace mtl
{
}
- void create(uint32_t _size, void* _data, VertexDeclHandle _declHandle, uint16_t _flags);
+ void create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle, uint16_t _flags);
- VertexDeclHandle m_decl;
+ VertexLayoutHandle m_layoutHandle;
};
@@ -776,22 +844,17 @@ namespace bgfx { namespace mtl
Function m_function;
uint32_t m_hash;
+ uint16_t m_numThreads[3];
};
+ struct PipelineStateMtl;
+
struct ProgramMtl
{
ProgramMtl()
: m_vsh(NULL)
, m_fsh(NULL)
- , m_vshConstantBuffer(NULL)
- , m_fshConstantBuffer(NULL)
- , m_vshConstantBufferSize(0)
- , m_vshConstantBufferAlignmentMask(0)
- , m_fshConstantBufferSize(0)
- , m_fshConstantBufferAlignmentMask(0)
- , m_samplerCount(0)
- , m_numPredefined(0)
- , m_processedUniforms(false)
+ , m_computePS(NULL)
{
}
@@ -804,6 +867,48 @@ namespace bgfx { namespace mtl
const ShaderMtl* m_vsh;
const ShaderMtl* m_fsh;
+
+ PipelineStateMtl* m_computePS;
+ };
+
+ struct PipelineStateMtl
+ {
+ PipelineStateMtl()
+ : m_vshConstantBuffer(NULL)
+ , m_fshConstantBuffer(NULL)
+ , m_vshConstantBufferSize(0)
+ , m_vshConstantBufferAlignmentMask(0)
+ , m_fshConstantBufferSize(0)
+ , m_fshConstantBufferAlignmentMask(0)
+ , m_numPredefined(0)
+ , m_rps(NULL)
+ , m_cps(NULL)
+ {
+ m_numThreads[0] = 1;
+ m_numThreads[1] = 1;
+ m_numThreads[2] = 1;
+ for(uint32_t i=0; i<BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++i)
+ m_bindingTypes[i] = 0;
+ }
+
+ ~PipelineStateMtl()
+ {
+ if (NULL != m_vshConstantBuffer)
+ {
+ UniformBuffer::destroy(m_vshConstantBuffer);
+ m_vshConstantBuffer = NULL;
+ }
+
+ if (NULL != m_fshConstantBuffer)
+ {
+ UniformBuffer::destroy(m_fshConstantBuffer);
+ m_fshConstantBuffer = NULL;
+ }
+
+ release(m_rps);
+ release(m_cps);
+ }
+
UniformBuffer* m_vshConstantBuffer;
UniformBuffer* m_fshConstantBuffer;
@@ -812,21 +917,27 @@ namespace bgfx { namespace mtl
uint32_t m_fshConstantBufferSize;
uint32_t m_fshConstantBufferAlignmentMask;
- struct SamplerInfo
+ enum
{
- uint32_t m_index;
- bgfx::UniformHandle m_uniform;
- bool m_fragment;
+ BindToVertexShader = 1 << 0,
+ BindToFragmentShader = 1 << 1,
};
+ uint8_t m_bindingTypes[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
- SamplerInfo m_samplers[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
- uint32_t m_samplerCount;
+ uint16_t m_numThreads[3];
PredefinedUniform m_predefined[PredefinedUniform::Count*2];
uint8_t m_numPredefined;
- bool m_processedUniforms;
+
+ RenderPipelineState m_rps;
+ ComputePipelineState m_cps;
};
+ void release(PipelineStateMtl* _ptr)
+ {
+ BX_DELETE(g_allocator, _ptr);
+ }
+
struct TextureMtl
{
enum Enum
@@ -847,6 +958,10 @@ namespace bgfx { namespace mtl
, m_depth(0)
, m_numMips(0)
{
+ for(uint32_t ii = 0; ii < BX_COUNTOF(m_ptrMips); ++ii)
+ {
+ m_ptrMips[ii] = NULL;
+ }
}
void create(const Memory* _mem, uint64_t _flags, uint8_t _skip);
@@ -855,6 +970,10 @@ namespace bgfx { namespace mtl
{
MTL_RELEASE(m_ptr);
MTL_RELEASE(m_ptrStencil);
+ for (uint32_t ii = 0; ii < m_numMips; ++ii)
+ {
+ MTL_RELEASE(m_ptrMips[ii]);
+ }
}
void update(
@@ -874,9 +993,12 @@ namespace bgfx { namespace mtl
, uint32_t _flags = BGFX_SAMPLER_INTERNAL_DEFAULT
);
+ Texture getTextureMipLevel(int _mip);
+
Texture m_ptr;
Texture m_ptrMsaa;
Texture m_ptrStencil; // for emulating packed depth/stencil formats - only for iOS8...
+ Texture m_ptrMips[14];
SamplerState m_sampler;
uint64_t m_flags;
uint32_t m_width;
@@ -895,6 +1017,7 @@ namespace bgfx { namespace mtl
SwapChainMtl()
: m_metalLayer(nil)
, m_drawable(nil)
+ , m_drawableTexture(nil)
, m_backBufferColorMsaa()
, m_backBufferDepth()
, m_backBufferStencil()
@@ -907,10 +1030,11 @@ namespace bgfx { namespace mtl
void init(void* _nwh);
void resize(FrameBufferMtl &_frameBuffer, uint32_t _width, uint32_t _height, uint32_t _flags);
- id<CAMetalDrawable> currentDrawable();
+ id <MTLTexture> currentDrawableTexture();
CAMetalLayer* m_metalLayer;
id <CAMetalDrawable> m_drawable;
+ id <MTLTexture> m_drawableTexture;
Texture m_backBufferColorMsaa;
Texture m_backBufferDepth;
Texture m_backBufferStencil;
@@ -920,7 +1044,9 @@ namespace bgfx { namespace mtl
struct FrameBufferMtl
{
FrameBufferMtl()
- : m_denseIdx(UINT16_MAX)
+ : m_swapChain(NULL)
+ , m_nwh(NULL)
+ , m_denseIdx(UINT16_MAX)
, m_pixelFormatHash(0)
, m_num(0)
{
@@ -940,6 +1066,7 @@ namespace bgfx { namespace mtl
uint16_t destroy();
SwapChainMtl* m_swapChain;
+ void* m_nwh;
uint32_t m_width;
uint32_t m_height;
uint16_t m_denseIdx;
@@ -948,6 +1075,8 @@ namespace bgfx { namespace mtl
TextureHandle m_colorHandle[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS-1];
TextureHandle m_depthHandle;
+ Attachment m_colorAttachment[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS-1];
+ Attachment m_depthAttachment;
uint8_t m_num; // number of color handles
};
@@ -987,15 +1116,31 @@ namespace bgfx { namespace mtl
void init();
void shutdown();
+ uint32_t begin(uint32_t _resultIdx);
+ void end(uint32_t _idx);
void addHandlers(CommandBuffer& _commandBuffer);
bool get();
+ struct Result
+ {
+ void reset()
+ {
+ m_begin = 0;
+ m_end = 0;
+ m_pending = 0;
+ }
+
+ uint64_t m_begin;
+ uint64_t m_end;
+ uint32_t m_pending;
+ };
+
uint64_t m_begin;
uint64_t m_end;
uint64_t m_elapsed;
uint64_t m_frequency;
- uint64_t m_result[4*2];
+ Result m_result[4*2];
bx::RingBufferControl m_control;
};
diff --git a/3rdparty/bgfx/src/renderer_mtl.mm b/3rdparty/bgfx/src/renderer_mtl.mm
index d104f7130d6..2cbb902f566 100644
--- a/3rdparty/bgfx/src/renderer_mtl.mm
+++ b/3rdparty/bgfx/src/renderer_mtl.mm
@@ -22,6 +22,14 @@ namespace bgfx { namespace mtl
{
static char s_viewName[BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME];
+ inline void setViewType(ViewId _view, const bx::StringView _str)
+ {
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION || BGFX_CONFIG_PROFILER) )
+ {
+ bx::memCopy(&s_viewName[_view][3], _str.getPtr(), _str.getLength() );
+ }
+ }
+
struct PrimInfo
{
MTLPrimitiveType m_type;
@@ -304,7 +312,7 @@ namespace bgfx { namespace mtl
};
BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_textureFormat) );
- int s_msaa[] =
+ int32_t s_msaa[] =
{
1,
2,
@@ -319,7 +327,7 @@ namespace bgfx { namespace mtl
{
case MTLDataTypeUInt:
case MTLDataTypeInt:
- return UniformType::Int1;
+ return UniformType::Sampler;
case MTLDataTypeFloat:
case MTLDataTypeFloat2:
@@ -358,6 +366,7 @@ namespace bgfx { namespace mtl
, m_captureSize(0)
, m_saveScreenshot(false)
{
+ bx::memSet(&m_windows, 0xff, sizeof(m_windows) );
}
~RendererContextMtl()
@@ -387,7 +396,22 @@ namespace bgfx { namespace mtl
}
retain(m_device);
- createFrameBuffer(m_fbh, g_platformData.nwh, 0, 0, TextureFormat::Unknown, TextureFormat::UnknownDepth);
+
+ m_mainFrameBuffer.create(
+ 0
+ , g_platformData.nwh
+ , _init.resolution.width
+ , _init.resolution.height
+ , TextureFormat::Unknown
+ , TextureFormat::UnknownDepth
+ );
+ m_numWindows = 1;
+
+ if (NULL == m_mainFrameBuffer.m_swapChain->m_metalLayer)
+ {
+ release(m_device);
+ return false;
+ }
m_cmd.init(m_device);
BGFX_FATAL(NULL != m_cmd.m_commandQueue, Fatal::UnableToInitialize, "Unable to create Metal device.");
@@ -434,16 +458,17 @@ namespace bgfx { namespace mtl
if (NULL != lib)
{
m_screenshotBlitProgramVsh.m_function = lib.newFunctionWithName(SHADER_FUNCTION_NAME);
+ release(lib);
}
lib = m_device.newLibraryWithSource(fshSource);
if (NULL != lib)
{
m_screenshotBlitProgramFsh.m_function = lib.newFunctionWithName(SHADER_FUNCTION_NAME);
+ release(lib);
}
m_screenshotBlitProgram.create(&m_screenshotBlitProgramVsh, &m_screenshotBlitProgramFsh);
- release(lib);
reset(m_renderPipelineDescriptor);
m_renderPipelineDescriptor.colorAttachments[0].pixelFormat = m_mainFrameBuffer.m_swapChain->m_metalLayer.pixelFormat;
@@ -467,6 +492,7 @@ namespace bgfx { namespace mtl
| BGFX_CAPS_TEXTURE_READ_BACK
| BGFX_CAPS_VERTEX_ATTRIB_HALF
| BGFX_CAPS_VERTEX_ATTRIB_UINT10
+ | BGFX_CAPS_COMPUTE
);
if (BX_ENABLED(BX_PLATFORM_IOS) )
@@ -481,16 +507,34 @@ namespace bgfx { namespace mtl
}
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) );
+
+ if ( m_device.supportsFeatureSet( (MTLFeatureSet)4 /* MTLFeatureSet_iOS_GPUFamily3_v1 */ ))
+ {
+ g_caps.supported |= BGFX_CAPS_DRAW_INDIRECT;
+ }
+
+ if ( m_device.supportsFeatureSet( (MTLFeatureSet)11 /* MTLFeatureSet_iOS_GPUFamily4_v1 */ ))
+ {
+ g_caps.supported |= BGFX_CAPS_TEXTURE_CUBE_ARRAY;
+ }
}
else if (BX_ENABLED(BX_PLATFORM_OSX) )
{
g_caps.limits.maxTextureSize = 16384;
g_caps.limits.maxFBAttachments = 8;
g_caps.supported |= BGFX_CAPS_TEXTURE_CUBE_ARRAY;
+
+ if ( m_device.supportsFeatureSet( (MTLFeatureSet)10001 /* MTLFeatureSet_macOS_GPUFamily1_v2 */ ))
+ {
+ g_caps.supported |= BGFX_CAPS_DRAW_INDIRECT;
+ }
}
g_caps.limits.maxTextureLayers = 2048;
g_caps.limits.maxVertexStreams = BGFX_CONFIG_MAX_VERTEX_STREAMS;
+ // Maximum number of entries in the buffer argument table, per graphics or compute function are 31.
+ // It is decremented by 1 because 1 entry is used for uniforms.
+ g_caps.limits.maxComputeBindings = bx::uint32_min(30, BGFX_MAX_COMPUTE_BINDINGS);
m_hasPixelFormatDepth32Float_Stencil8 = false
|| BX_ENABLED(BX_PLATFORM_OSX)
@@ -594,11 +638,17 @@ namespace bgfx { namespace mtl
}
}
- for (uint32_t ii = 1; ii < 5; ++ii)
+ for (uint32_t ii = 1, last = 0; ii < BX_COUNTOF(s_msaa); ++ii)
{
- if (!m_device.supportsTextureSampleCount(s_msaa[ii]) )
+ const int32_t sampleCount = 1; //1<<ii;
+ if (m_device.supportsTextureSampleCount(sampleCount) )
+ {
+ s_msaa[ii] = sampleCount;
+ last = ii;
+ }
+ else
{
- s_msaa[ii] = s_msaa[ii-1];
+ s_msaa[ii] = s_msaa[last];
}
}
@@ -612,6 +662,7 @@ namespace bgfx { namespace mtl
m_gpuTimer.init();
g_internalData.context = m_device;
+
return true;
}
@@ -621,6 +672,10 @@ namespace bgfx { namespace mtl
m_gpuTimer.shutdown();
m_pipelineStateCache.invalidate();
+ m_pipelineProgram.clear();
+
+ m_depthStencilStateCache.invalidate();
+ m_samplerStateCache.invalidate();
for (uint32_t ii = 0; ii < BX_COUNTOF(m_shaders); ++ii)
{
@@ -647,11 +702,7 @@ namespace bgfx { namespace mtl
MTL_RELEASE(m_textureDescriptor);
MTL_RELEASE(m_samplerDescriptor);
- MTL_RELEASE(m_mainFrameBuffer.m_swapChain->m_backBufferDepth);
- if (BX_ENABLED(BX_PLATFORM_IOS) )
- {
- MTL_RELEASE(m_mainFrameBuffer.m_swapChain->m_backBufferStencil);
- }
+ m_mainFrameBuffer.destroy();
for (uint8_t i=0; i < MTL_MAX_FRAMES_IN_FLIGHT; ++i)
{
@@ -681,20 +732,20 @@ namespace bgfx { namespace mtl
m_indexBuffers[_handle.idx].destroy();
}
- void createVertexDecl(VertexDeclHandle _handle, const VertexDecl& _decl) override
+ void createVertexLayout(VertexLayoutHandle _handle, const VertexLayout& _layout) override
{
- VertexDecl& decl = m_vertexDecls[_handle.idx];
- bx::memCopy(&decl, &_decl, sizeof(VertexDecl) );
- dump(decl);
+ VertexLayout& layout = m_vertexLayouts[_handle.idx];
+ bx::memCopy(&layout, &_layout, sizeof(VertexLayout) );
+ dump(layout);
}
- void destroyVertexDecl(VertexDeclHandle /*_handle*/) override
+ void destroyVertexLayout(VertexLayoutHandle /*_handle*/) override
{
}
- void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexDeclHandle _declHandle, uint16_t _flags) override
+ void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexLayoutHandle _layoutHandle, uint16_t _flags) override
{
- m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _declHandle, _flags);
+ m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _layoutHandle, _flags);
}
void destroyVertexBuffer(VertexBufferHandle _handle) override
@@ -719,8 +770,8 @@ namespace bgfx { namespace mtl
void createDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size, uint16_t _flags) override
{
- VertexDeclHandle decl = BGFX_INVALID_HANDLE;
- m_vertexBuffers[_handle.idx].create(_size, NULL, decl, _flags);
+ VertexLayoutHandle layoutHandle = BGFX_INVALID_HANDLE;
+ m_vertexBuffers[_handle.idx].create(_size, NULL, layoutHandle, _flags);
}
void updateDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _offset, uint32_t _size, const Memory* _mem) override
@@ -745,11 +796,24 @@ namespace bgfx { namespace mtl
void createProgram(ProgramHandle _handle, ShaderHandle _vsh, ShaderHandle _fsh) override
{
- m_program[_handle.idx].create(&m_shaders[_vsh.idx], &m_shaders[_fsh.idx]);
+ m_program[_handle.idx].create(&m_shaders[_vsh.idx], isValid(_fsh) ? &m_shaders[_fsh.idx] : NULL);
}
void destroyProgram(ProgramHandle _handle) override
{
+ for (PipelineProgramArray::iterator it = m_pipelineProgram.begin(); it != m_pipelineProgram.end();)
+ {
+ if (it->program.idx == _handle.idx)
+ {
+ m_pipelineStateCache.invalidate(it->key);
+ it = m_pipelineProgram.erase(it);
+ }
+ else
+ {
+ ++it;
+ }
+ }
+
m_program[_handle.idx].destroy();
}
@@ -774,11 +838,17 @@ namespace bgfx { namespace mtl
void readTexture(TextureHandle _handle, void* _data, uint8_t _mip) override
{
- m_cmd.kick(false, true);
- m_commandBuffer = m_cmd.alloc();
-
const TextureMtl& texture = m_textures[_handle.idx];
+
+#if BX_PLATFORM_OSX
+ BlitCommandEncoder bce = s_renderMtl->getBlitCommandEncoder();
+ bce.synchronizeTexture(texture.m_ptr, 0, _mip);
+ endEncoding();
+#endif // BX_PLATFORM_OSX
+ m_cmd.kick(false, true);
+ m_commandBuffer = m_cmd.alloc();
+
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);
@@ -845,29 +915,37 @@ namespace bgfx { namespace mtl
void createFrameBuffer(FrameBufferHandle _handle, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _format, TextureFormat::Enum _depthFormat) override
{
- uint16_t denseIdx = m_numWindows++;
- m_windows[denseIdx] = _handle;
- if (!isValid(_handle))
- {
- m_mainFrameBuffer.create(denseIdx, _nwh, _width, _height, _format, _depthFormat);
- }
- else
+ for (uint32_t ii = 0, num = m_numWindows; ii < num; ++ii)
{
- m_frameBuffers[_handle.idx].create(denseIdx, _nwh, _width, _height, _format, _depthFormat);
- m_frameBuffers[_handle.idx].m_swapChain->resize(m_frameBuffers[_handle.idx], _width, _height, 0);//_resolution.reset);
+ FrameBufferHandle handle = m_windows[ii];
+ if (isValid(handle)
+ && m_frameBuffers[handle.idx].m_nwh == _nwh)
+ {
+ destroyFrameBuffer(handle);
+ }
}
+
+ uint16_t denseIdx = m_numWindows++;
+ m_windows[denseIdx] = _handle;
+
+ FrameBufferMtl& fb = m_frameBuffers[_handle.idx];
+ fb.create(denseIdx, _nwh, _width, _height, _format, _depthFormat);
+ fb.m_swapChain->resize(m_frameBuffers[_handle.idx], _width, _height, 0);
}
void destroyFrameBuffer(FrameBufferHandle _handle) override
{
uint16_t denseIdx = m_frameBuffers[_handle.idx].destroy();
+
if (UINT16_MAX != denseIdx)
{
--m_numWindows;
+
if (m_numWindows > 1)
{
FrameBufferHandle handle = m_windows[m_numWindows];
m_windows[m_numWindows] = {kInvalidHandle};
+
if (m_numWindows != denseIdx)
{
m_windows[denseIdx] = handle;
@@ -942,14 +1020,11 @@ namespace bgfx { namespace mtl
void updateViewName(ViewId _id, const char* _name) override
{
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
- {
- bx::strCopy(
- &s_viewName[_id][BGFX_CONFIG_MAX_VIEW_NAME_RESERVED]
- , BX_COUNTOF(s_viewName[0])-BGFX_CONFIG_MAX_VIEW_NAME_RESERVED
- , _name
- );
- }
+ bx::strCopy(
+ &s_viewName[_id][BGFX_CONFIG_MAX_VIEW_NAME_RESERVED]
+ , BX_COUNTOF(s_viewName[0])-BGFX_CONFIG_MAX_VIEW_NAME_RESERVED
+ , _name
+ );
}
void updateUniform(uint16_t _loc, const void* _data, uint32_t _size) override
@@ -957,23 +1032,31 @@ namespace bgfx { namespace mtl
bx::memCopy(m_uniforms[_loc], _data, _size);
}
- void setMarker(const char* _marker, uint32_t /*_size*/) override
+ void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override
+ {
+ m_occlusionQuery.invalidate(_handle);
+ }
+
+ void setMarker(const char* _marker, uint16_t _len) override
{
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_MTL) )
+ BX_UNUSED(_len);
+
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
{
m_renderCommandEncoder.insertDebugSignpost(_marker);
}
}
- void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override
+ virtual void setName(Handle _handle, const char* _name, uint16_t _len) override
{
- m_occlusionQuery.invalidate(_handle);
- }
+ BX_UNUSED(_len);
- virtual void setName(Handle _handle, const char* _name) override
- {
switch (_handle.type)
{
+ case Handle::IndexBuffer:
+ m_indexBuffers[_handle.idx].m_ptr.setLabel(_name);
+ break;
+
case Handle::Shader:
m_shaders[_handle.idx].m_function.setLabel(_name);
break;
@@ -982,6 +1065,10 @@ namespace bgfx { namespace mtl
m_textures[_handle.idx].m_ptr.setLabel(_name);
break;
+ case Handle::VertexBuffer:
+ m_vertexBuffers[_handle.idx].m_ptr.setLabel(_name);
+ break;
+
default:
BX_CHECK(false, "Invalid handle type?! %d", _handle.type);
break;
@@ -994,20 +1081,33 @@ namespace bgfx { namespace mtl
void blitSetup(TextVideoMemBlitter& _blitter) override
{
- RenderCommandEncoder rce = m_renderCommandEncoder;
+ BX_UNUSED(_blitter);
+ }
+
+ void blitRender(TextVideoMemBlitter& _blitter, uint32_t _numIndices) override
+ {
+ const uint32_t numVertices = _numIndices*4/6;
+ if (0 < numVertices)
+ {
+ m_indexBuffers [_blitter.m_ib->handle.idx].update(
+ 0
+ , bx::strideAlign(_numIndices*2, 4)
+ , _blitter.m_ib->data
+ , true
+ );
+ m_vertexBuffers[_blitter.m_vb->handle.idx].update(
+ 0
+ , numVertices*_blitter.m_layout.m_stride
+ , _blitter.m_vb->data
+ , true
+ );
- uint32_t width = m_resolution.width;
- uint32_t height = m_resolution.height;
+ endEncoding();
- FrameBufferHandle fbh = BGFX_INVALID_HANDLE;
+ uint32_t width = m_resolution.width;
+ uint32_t height = m_resolution.height;
- if (NULL == rce
- || m_renderCommandEncoderFrameBufferHandle.idx != kInvalidHandle)
- {
- if (m_renderCommandEncoder)
- {
- m_renderCommandEncoder.endEncoding();
- }
+ FrameBufferHandle fbh = BGFX_INVALID_HANDLE;
RenderPassDescriptor renderPassDescriptor = newRenderPassDescriptor();
@@ -1015,80 +1115,77 @@ namespace bgfx { namespace mtl
renderPassDescriptor.colorAttachments[0].loadAction = MTLLoadActionLoad;
renderPassDescriptor.colorAttachments[0].storeAction =
- NULL != renderPassDescriptor.colorAttachments[0].resolveTexture
- ? MTLStoreActionMultisampleResolve
- : MTLStoreActionStore
- ;
+ NULL != renderPassDescriptor.colorAttachments[0].resolveTexture
+ ? MTLStoreActionMultisampleResolve
+ : MTLStoreActionStore
+ ;
- rce = m_commandBuffer.renderCommandEncoderWithDescriptor(renderPassDescriptor);
+ RenderCommandEncoder rce = m_commandBuffer.renderCommandEncoderWithDescriptor(renderPassDescriptor);
m_renderCommandEncoder = rce;
m_renderCommandEncoderFrameBufferHandle = fbh;
MTL_RELEASE(renderPassDescriptor);
- }
- MTLViewport viewport = { 0.0f, 0.0f, (float)width, (float)height, 0.0f, 1.0f};
- rce.setViewport(viewport);
- MTLScissorRect rc = { 0,0,width,height };
- rce.setScissorRect(rc);
- rce.setCullMode(MTLCullModeNone);
+ MTLViewport viewport = { 0.0f, 0.0f, (float)width, (float)height, 0.0f, 1.0f};
+ rce.setViewport(viewport);
+ MTLScissorRect rc = { 0,0,width,height };
+ rce.setScissorRect(rc);
+ rce.setCullMode(MTLCullModeNone);
- uint64_t state = 0
+ uint64_t state = 0
| BGFX_STATE_WRITE_RGB
| BGFX_STATE_WRITE_A
| BGFX_STATE_DEPTH_TEST_ALWAYS
;
- setDepthStencilState(state);
+ setDepthStencilState(state);
- RenderPipelineState pso = getPipelineState(
- state
- , 0
- , fbh
- , _blitter.m_vb->decl
- , _blitter.m_program.idx
- , 0
- );
- rce.setRenderPipelineState(pso);
+ PipelineStateMtl* pso = getPipelineState(
+ state
+ , 0
+ , fbh
+ , _blitter.m_vb->layoutHandle
+ , _blitter.m_program
+ , 0
+ );
+ rce.setRenderPipelineState(pso->m_rps);
- ProgramMtl& program = m_program[_blitter.m_program.idx];
- uint32_t vertexUniformBufferSize = program.m_vshConstantBufferSize;
- uint32_t fragmentUniformBufferSize = program.m_fshConstantBufferSize;
+ const uint32_t vertexUniformBufferSize = pso->m_vshConstantBufferSize;
+ const uint32_t fragmentUniformBufferSize = pso->m_fshConstantBufferSize;
- if (vertexUniformBufferSize )
- {
- m_uniformBufferVertexOffset = BX_ALIGN_MASK(m_uniformBufferVertexOffset, program.m_vshConstantBufferAlignmentMask);
- rce.setVertexBuffer(m_uniformBuffer, m_uniformBufferVertexOffset, 0);
- }
+ if (vertexUniformBufferSize)
+ {
+ m_uniformBufferVertexOffset = BX_ALIGN_MASK(m_uniformBufferVertexOffset, pso->m_vshConstantBufferAlignmentMask);
+ rce.setVertexBuffer(m_uniformBuffer, m_uniformBufferVertexOffset, 0);
+ }
- m_uniformBufferFragmentOffset = m_uniformBufferVertexOffset + vertexUniformBufferSize;
- if (fragmentUniformBufferSize )
- {
- m_uniformBufferFragmentOffset = BX_ALIGN_MASK(m_uniformBufferFragmentOffset, program.m_fshConstantBufferAlignmentMask);
- rce.setFragmentBuffer(m_uniformBuffer, m_uniformBufferFragmentOffset, 0);
- }
+ m_uniformBufferFragmentOffset = m_uniformBufferVertexOffset + vertexUniformBufferSize;
- float proj[16];
- bx::mtxOrtho(proj, 0.0f, (float)width, (float)height, 0.0f, 0.0f, 1000.0f, 0.0f, false);
+ if (0 != fragmentUniformBufferSize)
+ {
+ m_uniformBufferFragmentOffset = BX_ALIGN_MASK(m_uniformBufferFragmentOffset, pso->m_fshConstantBufferAlignmentMask);
+ rce.setFragmentBuffer(m_uniformBuffer, m_uniformBufferFragmentOffset, 0);
+ }
- PredefinedUniform& predefined = program.m_predefined[0];
- uint8_t flags = predefined.m_type;
- setShaderUniform(flags, predefined.m_loc, proj, 4);
+ float proj[16];
+ bx::mtxOrtho(proj, 0.0f, (float)width, (float)height, 0.0f, 0.0f, 1000.0f, 0.0f, false);
- m_textures[_blitter.m_texture.idx].commit(0, false, true);
- }
+ PredefinedUniform& predefined = pso->m_predefined[0];
+ uint8_t flags = predefined.m_type;
+ setShaderUniform(flags, predefined.m_loc, proj, 4);
- void blitRender(TextVideoMemBlitter& _blitter, uint32_t _numIndices) override
- {
- const uint32_t numVertices = _numIndices*4/6;
- if (0 < numVertices)
- {
- m_indexBuffers [_blitter.m_ib->handle.idx].update(0, _numIndices*2, _blitter.m_ib->data, true);
- m_vertexBuffers[_blitter.m_vb->handle.idx].update(0, numVertices*_blitter.m_decl.m_stride, _blitter.m_vb->data, true);
+ m_textures[_blitter.m_texture.idx].commit(0, false, true);
VertexBufferMtl& vb = m_vertexBuffers[_blitter.m_vb->handle.idx];
- m_renderCommandEncoder.setVertexBuffer(vb.getBuffer(), 0, 1);
+ m_renderCommandEncoder.setVertexBuffer(vb.m_ptr, 0, 1);
- m_renderCommandEncoder.drawIndexedPrimitives(MTLPrimitiveTypeTriangle, _numIndices, MTLIndexTypeUInt16, m_indexBuffers[_blitter.m_ib->handle.idx].getBuffer(), 0, 1);
+ m_renderCommandEncoder.drawIndexedPrimitives(
+ MTLPrimitiveTypeTriangle
+ , _numIndices
+ , MTLIndexTypeUInt16
+ , m_indexBuffers[_blitter.m_ib->handle.idx].m_ptr
+ , 0
+ , 1
+ );
}
}
@@ -1107,11 +1204,16 @@ namespace bgfx { namespace mtl
for (uint32_t ii = 0, num = m_numWindows; ii < num; ++ii)
{
FrameBufferMtl& frameBuffer = ii == 0 ? m_mainFrameBuffer : m_frameBuffers[m_windows[ii].idx];
- if (NULL != frameBuffer.m_swapChain &&
- frameBuffer.m_swapChain->m_drawable)
+ if (NULL != frameBuffer.m_swapChain
+ && frameBuffer.m_swapChain->m_drawableTexture)
{
- m_commandBuffer.presentDrawable(frameBuffer.m_swapChain->m_drawable);
- MTL_RELEASE(frameBuffer.m_swapChain->m_drawable);
+ MTL_RELEASE(frameBuffer.m_swapChain->m_drawableTexture);
+
+ if ( NULL != frameBuffer.m_swapChain->m_drawable)
+ {
+ m_commandBuffer.presentDrawable(frameBuffer.m_swapChain->m_drawable);
+ MTL_RELEASE(frameBuffer.m_swapChain->m_drawable);
+ }
}
}
@@ -1157,6 +1259,7 @@ namespace bgfx { namespace mtl
{
MTL_RELEASE(m_screenshotBlitRenderPipelineState)
reset(m_renderPipelineDescriptor);
+
m_renderPipelineDescriptor.colorAttachments[0].pixelFormat = m_mainFrameBuffer.m_swapChain->m_metalLayer.pixelFormat;
m_renderPipelineDescriptor.vertexFunction = m_screenshotBlitProgram.m_vsh->m_function;
m_renderPipelineDescriptor.fragmentFunction = m_screenshotBlitProgram.m_fsh->m_function;
@@ -1165,6 +1268,14 @@ namespace bgfx { namespace mtl
}
}
+ void invalidateCompute()
+ {
+ if (m_computeCommandEncoder)
+ {
+ m_computeCommandEncoder.endEncoding();
+ m_computeCommandEncoder = NULL;
+ }
+ }
void updateCapture()
{
@@ -1251,7 +1362,7 @@ namespace bgfx { namespace mtl
{
g_callback->captureEnd();
BX_FREE(g_allocator, m_capture);
- m_capture = NULL;
+ m_capture = NULL;
m_captureSize = 0;
}
}
@@ -1342,9 +1453,9 @@ namespace bgfx { namespace mtl
}
break;
- CASE_IMPLEMENT_UNIFORM(Int1, I, int);
- CASE_IMPLEMENT_UNIFORM(Vec4, F, float);
- CASE_IMPLEMENT_UNIFORM(Mat4, F, float);
+ CASE_IMPLEMENT_UNIFORM(Sampler, I, int);
+ CASE_IMPLEMENT_UNIFORM(Vec4, F, float);
+ CASE_IMPLEMENT_UNIFORM(Mat4, F, float);
case UniformType::End:
break;
@@ -1395,45 +1506,50 @@ namespace bgfx { namespace mtl
uint32_t numMrt = 1;
FrameBufferHandle fbh = m_fbh;
- if (isValid(fbh) )
+ if (isValid(fbh) && m_frameBuffers[fbh.idx].m_swapChain == NULL)
{
const FrameBufferMtl& fb = m_frameBuffers[fbh.idx];
numMrt = bx::uint32_max(1, fb.m_num);
}
- const ProgramMtl& program = m_program[_clearQuad.m_program[numMrt-1].idx];
- RenderPipelineState pso = getPipelineState(
+ const VertexLayout* layout = &_clearQuad.m_layout;
+ const PipelineStateMtl* pso = getPipelineState(
state
, 0
, fbh
- , _clearQuad.m_vb->decl
- , _clearQuad.m_program[numMrt-1].idx
+ , 1
+ , &layout
+ , _clearQuad.m_program[numMrt-1]
, 0
);
- m_renderCommandEncoder.setRenderPipelineState(pso);
+ m_renderCommandEncoder.setRenderPipelineState(pso->m_rps);
- uint32_t fragmentUniformBufferSize = program.m_fshConstantBufferSize;
+ const uint32_t vertexUniformBufferSize = pso->m_vshConstantBufferSize;
+ const uint32_t fragmentUniformBufferSize = pso->m_fshConstantBufferSize;
- m_uniformBufferFragmentOffset = m_uniformBufferVertexOffset;
+ if (0 != vertexUniformBufferSize)
+ {
+ m_uniformBufferVertexOffset = BX_ALIGN_MASK(m_uniformBufferVertexOffset, pso->m_vshConstantBufferAlignmentMask);
+ m_renderCommandEncoder.setVertexBuffer(m_uniformBuffer, m_uniformBufferVertexOffset, 0);
+ }
+
+ m_uniformBufferFragmentOffset = m_uniformBufferVertexOffset + vertexUniformBufferSize;
if (fragmentUniformBufferSize)
{
- m_uniformBufferFragmentOffset = BX_ALIGN_MASK(m_uniformBufferFragmentOffset, program.m_fshConstantBufferAlignmentMask);
+ m_uniformBufferFragmentOffset = BX_ALIGN_MASK(m_uniformBufferFragmentOffset, pso->m_fshConstantBufferAlignmentMask);
m_renderCommandEncoder.setFragmentBuffer(m_uniformBuffer, m_uniformBufferFragmentOffset, 0);
}
+ float mrtClearColor[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS][4];
+ float mrtClearDepth[4] = { _clear.m_depth };
+
if (BGFX_CLEAR_COLOR_USE_PALETTE & _clear.m_flags)
{
- float mrtClear[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS][4];
for (uint32_t ii = 0; ii < numMrt; ++ii)
{
uint8_t index = (uint8_t)bx::uint32_min(BGFX_CONFIG_MAX_COLOR_PALETTE-1, _clear.m_index[ii]);
- bx::memCopy(mrtClear[ii], _palette[index], 16);
+ bx::memCopy(mrtClearColor[ii], _palette[index], 16);
}
-
- bx::memCopy( (uint8_t*)m_uniformBuffer.contents() + m_uniformBufferFragmentOffset
- , mrtClear
- , bx::uint32_min(fragmentUniformBufferSize, sizeof(mrtClear) )
- );
}
else
{
@@ -1445,87 +1561,82 @@ namespace bgfx { namespace mtl
_clear.m_index[3]*1.0f/255.0f,
};
- bx::memCopy( (uint8_t*)m_uniformBuffer.contents() + m_uniformBufferFragmentOffset
- , rgba
- , bx::uint32_min(fragmentUniformBufferSize, sizeof(rgba) )
- );
+ for (uint32_t ii = 0; ii < numMrt; ++ii)
+ {
+ bx::memCopy( mrtClearColor[ii]
+ , rgba
+ , 16
+ );
+ }
}
- m_uniformBufferFragmentOffset += fragmentUniformBufferSize;
- m_uniformBufferVertexOffset = m_uniformBufferFragmentOffset;
+ bx::memCopy( (uint8_t*)m_uniformBuffer.contents() + m_uniformBufferVertexOffset
+ , mrtClearDepth
+ , bx::uint32_min(vertexUniformBufferSize, sizeof(mrtClearDepth) )
+ );
- const VertexBufferMtl& vb = m_vertexBuffers[_clearQuad.m_vb->handle.idx];
- const VertexDecl& vertexDecl = m_vertexDecls[_clearQuad.m_vb->decl.idx];
- const uint32_t stride = vertexDecl.m_stride;
- const uint32_t offset = 0;
+ bx::memCopy( (uint8_t*)m_uniformBuffer.contents() + m_uniformBufferFragmentOffset
+ , mrtClearColor
+ , bx::uint32_min(fragmentUniformBufferSize, sizeof(mrtClearColor) )
+ );
- {
- struct Vertex
- {
- float m_x;
- float m_y;
- float m_z;
- };
- Vertex* vertex = (Vertex*)_clearQuad.m_vb->data;
- BX_CHECK(stride == sizeof(Vertex)
- , "Stride/Vertex mismatch (stride %d, sizeof(Vertex) %d)"
- , stride
- , sizeof(Vertex)
- );
- BX_UNUSED(stride);
-
- const float depth = _clear.m_depth;
-
- vertex->m_x = -1.0f;
- vertex->m_y = -1.0f;
- vertex->m_z = depth;
- vertex++;
- vertex->m_x = 1.0f;
- vertex->m_y = -1.0f;
- vertex->m_z = depth;
- vertex++;
- vertex->m_x = -1.0f;
- vertex->m_y = 1.0f;
- vertex->m_z = depth;
- vertex++;
- vertex->m_x = 1.0f;
- vertex->m_y = 1.0f;
- vertex->m_z = depth;
- }
+ m_uniformBufferFragmentOffset += fragmentUniformBufferSize;
+ m_uniformBufferVertexOffset = m_uniformBufferFragmentOffset;
+
+ const VertexBufferMtl& vb = m_vertexBuffers[_clearQuad.m_vb.idx];
- m_vertexBuffers[_clearQuad.m_vb->handle.idx].update(0, 4*_clearQuad.m_decl.m_stride, _clearQuad.m_vb->data);
m_renderCommandEncoder.setCullMode(MTLCullModeNone);
- m_renderCommandEncoder.setVertexBuffer(vb.getBuffer(), offset, 1);
+ m_renderCommandEncoder.setVertexBuffer(vb.m_ptr, 0, 1);
m_renderCommandEncoder.drawPrimitives(MTLPrimitiveTypeTriangleStrip, 0, 4, 1);
}
- void setFrameBuffer(RenderPassDescriptor renderPassDescriptor, FrameBufferHandle _fbh, bool _msaa = true)
+ void setAttachment(MTLRenderPassAttachmentDescriptor* _attachmentDescriptor, const Attachment& _at, uint8_t _textureType, bool _resolve)
{
- if (!isValid(_fbh) || m_frameBuffers[_fbh.idx].m_swapChain)
+ _attachmentDescriptor.level = _at.mip;
+ if ( _textureType == TextureMtl::Texture3D )
+ _attachmentDescriptor.depthPlane = _at.layer;
+ else
+ _attachmentDescriptor.slice = _at.layer;
+
+ if ( _resolve )
{
- SwapChainMtl* swapChain =
- !isValid(_fbh) ?
- m_mainFrameBuffer.m_swapChain :
- m_frameBuffers[_fbh.idx].m_swapChain;
- if (NULL != m_backBufferColorMsaa)
+ _attachmentDescriptor.resolveLevel = _at.mip;
+ if ( _textureType == TextureMtl::Texture3D )
+ _attachmentDescriptor.resolveDepthPlane = _at.layer;
+ else
+ _attachmentDescriptor.resolveSlice = _at.layer;
+ }
+ }
+
+ void setFrameBuffer(RenderPassDescriptor _renderPassDescriptor, FrameBufferHandle _fbh, bool _msaa = true)
+ {
+ if (!isValid(_fbh)
+ || m_frameBuffers[_fbh.idx].m_swapChain)
+ {
+ SwapChainMtl* swapChain = !isValid(_fbh)
+ ? m_mainFrameBuffer.m_swapChain
+ : m_frameBuffers[_fbh.idx].m_swapChain
+ ;
+
+ if (NULL != swapChain->m_backBufferColorMsaa)
{
- renderPassDescriptor.colorAttachments[0].texture = swapChain->m_backBufferColorMsaa;
- renderPassDescriptor.colorAttachments[0].resolveTexture = NULL != m_screenshotTarget
+ _renderPassDescriptor.colorAttachments[0].texture = swapChain->m_backBufferColorMsaa;
+ _renderPassDescriptor.colorAttachments[0].resolveTexture = NULL != m_screenshotTarget
? m_screenshotTarget.m_obj
- : swapChain->currentDrawable().texture
+ : swapChain->currentDrawableTexture()
;
}
else
{
- renderPassDescriptor.colorAttachments[0].texture = NULL != m_screenshotTarget
+ _renderPassDescriptor.colorAttachments[0].texture = NULL != m_screenshotTarget
? m_screenshotTarget.m_obj
- : swapChain->currentDrawable().texture
+ : swapChain->currentDrawableTexture()
;
}
- renderPassDescriptor.depthAttachment.texture = swapChain->m_backBufferDepth;
- renderPassDescriptor.stencilAttachment.texture = swapChain->m_backBufferStencil;
+ _renderPassDescriptor.depthAttachment.texture = swapChain->m_backBufferDepth;
+ _renderPassDescriptor.stencilAttachment.texture = swapChain->m_backBufferStencil;
}
else
{
@@ -1534,35 +1645,40 @@ namespace bgfx { namespace mtl
for (uint32_t ii = 0; ii < frameBuffer.m_num; ++ii)
{
const TextureMtl& texture = m_textures[frameBuffer.m_colorHandle[ii].idx];
- renderPassDescriptor.colorAttachments[ii].texture = texture.m_ptrMsaa
+ _renderPassDescriptor.colorAttachments[ii].texture = texture.m_ptrMsaa
? texture.m_ptrMsaa
: texture.m_ptr
;
- renderPassDescriptor.colorAttachments[ii].resolveTexture = texture.m_ptrMsaa
+ _renderPassDescriptor.colorAttachments[ii].resolveTexture = texture.m_ptrMsaa
? texture.m_ptr.m_obj
: NULL
;
+
+ setAttachment(_renderPassDescriptor.colorAttachments[ii], frameBuffer.m_colorAttachment[ii], texture.m_type, texture.m_ptrMsaa != NULL);
}
if (isValid(frameBuffer.m_depthHandle) )
{
const TextureMtl& texture = m_textures[frameBuffer.m_depthHandle.idx];
- renderPassDescriptor.depthAttachment.texture = texture.m_ptrMsaa
+ _renderPassDescriptor.depthAttachment.texture = texture.m_ptrMsaa
? texture.m_ptrMsaa
: texture.m_ptr
;
- renderPassDescriptor.stencilAttachment.texture = texture.m_ptrStencil;
+ _renderPassDescriptor.stencilAttachment.texture = texture.m_ptrStencil;
+
+ setAttachment(_renderPassDescriptor.depthAttachment, frameBuffer.m_depthAttachment, texture.m_type, NULL != texture.m_ptrMsaa);
+ setAttachment(_renderPassDescriptor.stencilAttachment, frameBuffer.m_depthAttachment, texture.m_type, NULL != texture.m_ptrMsaa);
if (texture.m_textureFormat == TextureFormat::D24S8)
{
if (texture.m_ptr.pixelFormat() == 255 /* Depth24Unorm_Stencil8 */
|| texture.m_ptr.pixelFormat() == 260 /* Depth32Float_Stencil8 */)
{
- renderPassDescriptor.stencilAttachment.texture = renderPassDescriptor.depthAttachment.texture;
+ _renderPassDescriptor.stencilAttachment.texture = _renderPassDescriptor.depthAttachment.texture;
}
else
{
- renderPassDescriptor.stencilAttachment.texture = texture.m_ptrMsaa
+ _renderPassDescriptor.stencilAttachment.texture = texture.m_ptrMsaa
? texture.m_ptrMsaa
: texture.m_ptrStencil
;
@@ -1617,10 +1733,10 @@ namespace bgfx { namespace mtl
frontFaceDesc.readMask = readMask;
frontFaceDesc.writeMask = writeMask;
- backfaceDesc.stencilFailureOperation = s_stencilOp[(bstencil&BGFX_STENCIL_OP_FAIL_S_MASK)>>BGFX_STENCIL_OP_FAIL_S_SHIFT];
- backfaceDesc.depthFailureOperation = s_stencilOp[(bstencil&BGFX_STENCIL_OP_FAIL_Z_MASK)>>BGFX_STENCIL_OP_FAIL_Z_SHIFT];
- backfaceDesc.depthStencilPassOperation = s_stencilOp[(bstencil&BGFX_STENCIL_OP_PASS_Z_MASK)>>BGFX_STENCIL_OP_PASS_Z_SHIFT];
- backfaceDesc.stencilCompareFunction = s_cmpFunc[(bstencil&BGFX_STENCIL_TEST_MASK)>>BGFX_STENCIL_TEST_SHIFT];
+ backfaceDesc.stencilFailureOperation = s_stencilOp[(bstencil&BGFX_STENCIL_OP_FAIL_S_MASK)>>BGFX_STENCIL_OP_FAIL_S_SHIFT];
+ backfaceDesc.depthFailureOperation = s_stencilOp[(bstencil&BGFX_STENCIL_OP_FAIL_Z_MASK)>>BGFX_STENCIL_OP_FAIL_Z_SHIFT];
+ backfaceDesc.depthStencilPassOperation = s_stencilOp[(bstencil&BGFX_STENCIL_OP_PASS_Z_MASK)>>BGFX_STENCIL_OP_PASS_Z_SHIFT];
+ backfaceDesc.stencilCompareFunction = s_cmpFunc[(bstencil&BGFX_STENCIL_TEST_MASK)>>BGFX_STENCIL_TEST_SHIFT];
backfaceDesc.readMask = readMask;
backfaceDesc.writeMask = writeMask;
@@ -1642,13 +1758,155 @@ namespace bgfx { namespace mtl
m_renderCommandEncoder.setStencilReferenceValue(ref);
}
- RenderPipelineState getPipelineState(
+ void processArguments(
+ PipelineStateMtl* ps
+ , NSArray <MTLArgument *>* _vertexArgs
+ , NSArray <MTLArgument *>* _fragmentArgs
+ )
+ {
+ ps->m_numPredefined = 0;
+
+ for (uint32_t shaderType = 0; shaderType < 2; ++shaderType)
+ {
+ UniformBuffer*& constantBuffer = shaderType == 0
+ ? ps->m_vshConstantBuffer
+ : ps->m_fshConstantBuffer
+ ;
+ const int8_t fragmentBit = (1 == shaderType ? BGFX_UNIFORM_FRAGMENTBIT : 0);
+
+ for (MTLArgument* arg in (shaderType == 0 ? _vertexArgs : _fragmentArgs) )
+ {
+ BX_TRACE("arg: %s type:%d", utf8String(arg.name), arg.type);
+
+ if (arg.active)
+ {
+ if (arg.type == MTLArgumentTypeBuffer
+ && 0 == bx::strCmp(utf8String(arg.name), SHADER_UNIFORM_NAME) )
+ {
+ BX_CHECK( arg.index == 0, "Uniform buffer must be in the buffer slot 0.");
+ BX_CHECK( MTLDataTypeStruct == arg.bufferDataType, "%s's type must be a struct",SHADER_UNIFORM_NAME );
+
+ if (MTLDataTypeStruct == arg.bufferDataType)
+ {
+ if (shaderType == 0)
+ {
+ ps->m_vshConstantBufferSize = (uint32_t)arg.bufferDataSize;
+ ps->m_vshConstantBufferAlignmentMask = (uint32_t)arg.bufferAlignment - 1;
+ }
+ else
+ {
+ ps->m_fshConstantBufferSize = (uint32_t)arg.bufferDataSize;
+ ps->m_fshConstantBufferAlignmentMask = (uint32_t)arg.bufferAlignment - 1;
+ }
+
+ for (MTLStructMember* uniform in arg.bufferStructType.members )
+ {
+ const char* name = utf8String(uniform.name);
+ BX_TRACE("uniform: %s type:%d", name, uniform.dataType);
+
+ MTLDataType dataType = uniform.dataType;
+ uint32_t num = 1;
+
+ if (dataType == MTLDataTypeArray)
+ {
+ dataType = uniform.arrayType.elementType;
+ num = (uint32_t)uniform.arrayType.arrayLength;
+ }
+
+ switch (dataType)
+ {
+ case MTLDataTypeFloat4: num *= 1; break;
+ case MTLDataTypeFloat4x4: num *= 4; break;
+ case MTLDataTypeFloat3x3: num *= 3; break;
+
+ default:
+ BX_WARN(0, "Unsupported uniform MTLDataType: %d", uniform.dataType);
+ break;
+ }
+
+ const PredefinedUniform::Enum predefined = nameToPredefinedUniformEnum(name);
+
+ if (PredefinedUniform::Count != predefined)
+ {
+ ps->m_predefined[ps->m_numPredefined].m_loc = uint32_t(uniform.offset);
+ ps->m_predefined[ps->m_numPredefined].m_count = uint16_t(num);
+ ps->m_predefined[ps->m_numPredefined].m_type = uint8_t(predefined|fragmentBit);
+ ++ps->m_numPredefined;
+ }
+ else
+ {
+ const UniformRegInfo* 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)
+ {
+ constantBuffer = UniformBuffer::create(1024);
+ }
+
+ UniformType::Enum type = convertMtlType(dataType);
+ constantBuffer->writeUniformHandle( (UniformType::Enum)(type|fragmentBit), uint32_t(uniform.offset), info->m_handle, uint16_t(num) );
+ BX_TRACE("store %s %d offset:%d", name, info->m_handle, uint32_t(uniform.offset) );
+ }
+ }
+ }
+ }
+ }
+ else if ( arg.type == MTLArgumentTypeBuffer && arg.index > 0 && NULL != arg.bufferStructType)
+ {
+ const char* name = utf8String(arg.name);
+
+ if (arg.index >= BGFX_CONFIG_MAX_TEXTURE_SAMPLERS)
+ {
+ BX_WARN(false, "Binding index is too large %d max is %d. User defined uniform '%s' won't be set.", int(arg.index - 1), BGFX_CONFIG_MAX_TEXTURE_SAMPLERS - 1, name);
+ }
+ else
+ {
+ ps->m_bindingTypes[arg.index-1] = fragmentBit ? PipelineStateMtl::BindToFragmentShader : PipelineStateMtl::BindToVertexShader;
+ BX_TRACE("buffer %s index:%d", name, uint32_t(arg.index-1) );
+ }
+ }
+ else if (arg.type == MTLArgumentTypeTexture)
+ {
+ const char* name = utf8String(arg.name);
+ const UniformRegInfo* 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 (arg.index >= BGFX_CONFIG_MAX_TEXTURE_SAMPLERS)
+ {
+ BX_WARN(false, "Binding index is too large %d max is %d. User defined uniform '%s' won't be set.", int(arg.index), BGFX_CONFIG_MAX_TEXTURE_SAMPLERS - 1, name);
+ }
+ else
+ {
+ ps->m_bindingTypes[arg.index] = fragmentBit ? PipelineStateMtl::BindToFragmentShader : PipelineStateMtl::BindToVertexShader;
+ BX_TRACE("texture %s %d index:%d", name, info->m_handle, uint32_t(arg.index) );
+ }
+ }
+ }
+ else if (arg.type == MTLArgumentTypeSampler)
+ {
+ BX_TRACE("sampler: %s index:%d", utf8String(arg.name), arg.index);
+ }
+ }
+ }
+
+ if (NULL != constantBuffer)
+ {
+ constantBuffer->finish();
+ }
+ }
+ }
+
+ PipelineStateMtl* getPipelineState(
uint64_t _state
, uint32_t _rgba
, FrameBufferHandle _fbh
, uint8_t _numStreams
- , const VertexDecl** _vertexDecls
- , uint16_t _programIdx
+ , const VertexLayout** _layouts
+ , ProgramHandle _program
, uint8_t _numInstanceData
)
{
@@ -1663,7 +1921,7 @@ namespace bgfx { namespace mtl
);
const bool independentBlendEnable = !!(BGFX_STATE_BLEND_INDEPENDENT & _state);
- ProgramMtl& program = m_program[_programIdx];
+ const ProgramMtl& program = m_program[_program.idx];
bx::HashMurmur2A murmur;
murmur.begin();
@@ -1673,7 +1931,7 @@ namespace bgfx { namespace mtl
if (!isValid(_fbh) )
{
- murmur.add(m_backBufferPixelFormatHash);
+ murmur.add(m_mainFrameBuffer.m_pixelFormatHash);
}
else
{
@@ -1689,14 +1947,17 @@ namespace bgfx { namespace mtl
for (uint8_t ii = 0; ii < _numStreams; ++ii)
{
- murmur.add(_vertexDecls[ii]->m_hash);
+ murmur.add(_layouts[ii]->m_hash);
}
uint32_t hash = murmur.end();
- RenderPipelineState pso = m_pipelineStateCache.find(hash);
+ PipelineStateMtl* pso = m_pipelineStateCache.find(hash);
+
if (NULL == pso)
{
+ pso = BX_NEW(g_allocator, PipelineStateMtl);
+
RenderPipelineDescriptor pd = m_renderPipelineDescriptor;
reset(pd);
@@ -1704,14 +1965,18 @@ namespace bgfx { namespace mtl
uint32_t frameBufferAttachment = 1;
- if (!isValid(_fbh) || s_renderMtl->m_frameBuffers[_fbh.idx].m_swapChain)
+ if (!isValid(_fbh)
+ || s_renderMtl->m_frameBuffers[_fbh.idx].m_swapChain)
{
- SwapChainMtl* swapChain =
- !isValid(_fbh) ?
- s_renderMtl->m_mainFrameBuffer.m_swapChain :
- s_renderMtl->m_frameBuffers[_fbh.idx].m_swapChain;
- pd.sampleCount = NULL != swapChain->m_backBufferColorMsaa ? swapChain->m_backBufferColorMsaa.sampleCount() : 1;
- pd.colorAttachments[0].pixelFormat = swapChain->currentDrawable().texture.pixelFormat;
+ SwapChainMtl* swapChain = !isValid(_fbh)
+ ? s_renderMtl->m_mainFrameBuffer.m_swapChain
+ : s_renderMtl->m_frameBuffers[_fbh.idx].m_swapChain
+ ;
+ pd.sampleCount = NULL != swapChain->m_backBufferColorMsaa
+ ? swapChain->m_backBufferColorMsaa.sampleCount()
+ : 1
+ ;
+ pd.colorAttachments[0].pixelFormat = swapChain->currentDrawableTexture().pixelFormat;
pd.depthAttachmentPixelFormat = swapChain->m_backBufferDepth.m_obj.pixelFormat;
pd.stencilAttachmentPixelFormat = swapChain->m_backBufferStencil.m_obj.pixelFormat;
}
@@ -1817,33 +2082,38 @@ namespace bgfx { namespace mtl
uint8_t stream = 0;
for (; stream < _numStreams; ++stream)
{
- const VertexDecl& vertexDecl = *_vertexDecls[stream];
+ const VertexLayout& layout = *_layouts[stream];
+ bool streamUsed = false;
for (uint32_t ii = 0; Attrib::Count != program.m_used[ii]; ++ii)
{
Attrib::Enum attr = Attrib::Enum(program.m_used[ii]);
+ if (attrSet[attr])
+ continue;
const uint32_t loc = program.m_attributes[attr];
uint8_t num;
AttribType::Enum type;
bool normalized;
bool asInt;
- vertexDecl.decode(attr, num, type, normalized, asInt);
+ layout.decode(attr, num, type, normalized, asInt);
BX_CHECK(num <= 4, "num must be <= 4");
- if (UINT16_MAX != vertexDecl.m_attributes[attr])
+ if (UINT16_MAX != layout.m_attributes[attr])
{
vertexDesc.attributes[loc].format = s_attribType[type][num-1][normalized?1:0];
vertexDesc.attributes[loc].bufferIndex = stream+1;
- vertexDesc.attributes[loc].offset = vertexDecl.m_offset[attr];
+ vertexDesc.attributes[loc].offset = layout.m_offset[attr];
BX_TRACE("attrib: %s format: %d offset: %d", s_attribName[attr], (int)vertexDesc.attributes[loc].format, (int)vertexDesc.attributes[loc].offset);
attrSet[attr] = true;
+ streamUsed = true;
}
}
-
- vertexDesc.layouts[stream+1].stride = vertexDecl.getStride();
- vertexDesc.layouts[stream+1].stepFunction = MTLVertexStepFunctionPerVertex;
+ if (streamUsed) {
+ vertexDesc.layouts[stream+1].stride = layout.getStride();
+ vertexDesc.layouts[stream+1].stepFunction = MTLVertexStepFunctionPerVertex;
+ }
}
for (uint32_t ii = 0; Attrib::Count != program.m_used[ii]; ++ii)
@@ -1875,169 +2145,67 @@ namespace bgfx { namespace mtl
pd.vertexDescriptor = vertexDesc;
- if (program.m_processedUniforms)
{
- pso = m_device.newRenderPipelineStateWithDescriptor(pd);
- }
- else
- {
- program.m_numPredefined = 0;
RenderPipelineReflection reflection = NULL;
- pso = m_device.newRenderPipelineStateWithDescriptor(pd, MTLPipelineOptionBufferTypeInfo, &reflection);
+ pso->m_rps = m_device.newRenderPipelineStateWithDescriptor(pd, MTLPipelineOptionBufferTypeInfo, &reflection);
if (NULL != reflection)
{
- for (uint32_t shaderType = 0; shaderType < 2; ++shaderType)
- {
- UniformBuffer*& constantBuffer = shaderType == 0
- ? program.m_vshConstantBuffer
- : program.m_fshConstantBuffer
- ;
- uint8_t fragmentBit = (1 == shaderType ? BGFX_UNIFORM_FRAGMENTBIT : 0);
-
- for (MTLArgument* arg in (shaderType == 0 ? reflection.vertexArguments : reflection.fragmentArguments) )
- {
- BX_TRACE("arg: %s type:%d", utf8String(arg.name), arg.type);
- if (arg.active)
- {
- if (arg.type == MTLArgumentTypeBuffer
- && 0 == bx::strCmp(utf8String(arg.name), SHADER_UNIFORM_NAME) )
- {
- BX_CHECK( arg.index == 0, "Uniform buffer must be in the buffer slot 0.");
- BX_CHECK( MTLDataTypeStruct == arg.bufferDataType, "%s's type must be a struct",SHADER_UNIFORM_NAME );
-
- if (MTLDataTypeStruct == arg.bufferDataType)
- {
- if (shaderType == 0)
- {
- program.m_vshConstantBufferSize = (uint32_t)arg.bufferDataSize;
- program.m_vshConstantBufferAlignmentMask = (uint32_t)arg.bufferAlignment - 1;
- }
- else
- {
- program.m_fshConstantBufferSize = (uint32_t)arg.bufferDataSize;
- program.m_fshConstantBufferAlignmentMask = (uint32_t)arg.bufferAlignment - 1;
- }
-
- for (MTLStructMember* uniform in arg.bufferStructType.members )
- {
- const char* name = utf8String(uniform.name);
- BX_TRACE("uniform: %s type:%d", name, uniform.dataType);
-
- MTLDataType dataType = uniform.dataType;
- uint32_t num = 1;
-
- if (dataType == MTLDataTypeArray)
- {
- dataType = uniform.arrayType.elementType;
- num = (uint32_t)uniform.arrayType.arrayLength;
- }
-
- switch (dataType)
- {
- case MTLDataTypeFloat4: num *= 1; break;
- case MTLDataTypeFloat4x4: num *= 4; break;
- case MTLDataTypeFloat3x3: num *= 3; break;
-
- default:
- BX_WARN(0, "Unsupported uniform MTLDataType: %d", uniform.dataType);
- break;
- }
-
- PredefinedUniform::Enum predefined = nameToPredefinedUniformEnum(name);
- if (PredefinedUniform::Count != predefined)
- {
- program.m_predefined[program.m_numPredefined].m_loc = uint32_t(uniform.offset);
- program.m_predefined[program.m_numPredefined].m_count = uint16_t(num);
- program.m_predefined[program.m_numPredefined].m_type = uint8_t(predefined|fragmentBit);
- ++program.m_numPredefined;
- }
- else
- {
- const UniformRegInfo* info = 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)
- {
- constantBuffer = UniformBuffer::create(1024);
- }
-
- UniformType::Enum type = convertMtlType(dataType);
- constantBuffer->writeUniformHandle( (UniformType::Enum)(type|fragmentBit), uint32_t(uniform.offset), info->m_handle, uint16_t(num) );
- BX_TRACE("store %s %d offset:%d", name, info->m_handle, uint32_t(uniform.offset) );
- }
- }
- }
- }
- }
- else if (arg.type == MTLArgumentTypeTexture)
- {
- const char* name = utf8String(arg.name);
- const UniformRegInfo* info = 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 (program.m_samplerCount >= BGFX_CONFIG_MAX_TEXTURE_SAMPLERS)
- {
- BX_WARN(NULL != info, "Too many samplers in shader(only %d is supported). User defined uniform '%s' won't be set.", BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, name);
- }
- else
- {
- program.m_samplers[program.m_samplerCount].m_index = uint32_t(arg.index);
- program.m_samplers[program.m_samplerCount].m_uniform = info->m_handle;
- program.m_samplers[program.m_samplerCount].m_fragment = fragmentBit ? 1 : 0;
- ++program.m_samplerCount;
- BX_TRACE("texture %s %d index:%d", name, info->m_handle, uint32_t(arg.index) );
- }
- }
- }
- else if (arg.type == MTLArgumentTypeSampler)
- {
- BX_TRACE("sampler: %s index:%d", utf8String(arg.name), arg.index);
- }
- }
- }
-
- if (NULL != constantBuffer)
- {
- constantBuffer->finish();
- }
- }
+ processArguments(pso, reflection.vertexArguments, reflection.fragmentArguments);
}
-
- program.m_processedUniforms = true;
}
m_pipelineStateCache.add(hash, pso);
+ m_pipelineProgram.push_back({hash, _program});
}
return pso;
}
- RenderPipelineState getPipelineState(
+ PipelineStateMtl* getPipelineState(
uint64_t _state
, uint32_t _rgba
, FrameBufferHandle _fbh
- , VertexDeclHandle _declHandle
- , uint16_t _programIdx
+ , VertexLayoutHandle _layoutHandle
+ , ProgramHandle _program
, uint16_t _numInstanceData
)
{
- const VertexDecl* decl = &m_vertexDecls[_declHandle.idx];
+ const VertexLayout* layout = &m_vertexLayouts[_layoutHandle.idx];
return getPipelineState(
_state
, _rgba
, _fbh
, 1
- , &decl
- , _programIdx
+ , &layout
+ , _program
, _numInstanceData
);
}
+ PipelineStateMtl* getComputePipelineState(ProgramHandle _program)
+ {
+ ProgramMtl& program = m_program[_program.idx];
+
+ if (NULL == program.m_computePS)
+ {
+ PipelineStateMtl* pso = BX_NEW(g_allocator, PipelineStateMtl);
+ program.m_computePS = pso;
+
+ ComputePipelineReflection reflection = NULL;
+ pso->m_cps = m_device.newComputePipelineStateWithFunction(program.m_vsh->m_function, MTLPipelineOptionBufferTypeInfo, &reflection);
+ processArguments(pso, reflection.arguments, NULL);
+
+ for (uint32_t ii = 0; ii < 3; ++ii)
+ {
+ pso->m_numThreads[ii] = program.m_vsh->m_numThreads[ii];
+ }
+ }
+
+ return program.m_computePS;
+ }
+
+
SamplerState getSamplerState(uint32_t _flags)
{
_flags &= BGFX_SAMPLER_BITS_MASK;
@@ -2045,20 +2213,19 @@ namespace bgfx { namespace mtl
if (NULL == sampler)
{
-
m_samplerDescriptor.sAddressMode = s_textureAddress[(_flags&BGFX_SAMPLER_U_MASK)>>BGFX_SAMPLER_U_SHIFT];
m_samplerDescriptor.tAddressMode = s_textureAddress[(_flags&BGFX_SAMPLER_V_MASK)>>BGFX_SAMPLER_V_SHIFT];
m_samplerDescriptor.rAddressMode = s_textureAddress[(_flags&BGFX_SAMPLER_W_MASK)>>BGFX_SAMPLER_W_SHIFT];
- m_samplerDescriptor.minFilter = s_textureFilterMinMag[(_flags&BGFX_SAMPLER_MIN_MASK)>>BGFX_SAMPLER_MIN_SHIFT];
- m_samplerDescriptor.magFilter = s_textureFilterMinMag[(_flags&BGFX_SAMPLER_MAG_MASK)>>BGFX_SAMPLER_MAG_SHIFT];
- m_samplerDescriptor.mipFilter = s_textureFilterMip[(_flags&BGFX_SAMPLER_MIP_MASK)>>BGFX_SAMPLER_MIP_SHIFT];
- m_samplerDescriptor.lodMinClamp = 0;
- m_samplerDescriptor.lodMaxClamp = FLT_MAX;
+ m_samplerDescriptor.minFilter = s_textureFilterMinMag[(_flags&BGFX_SAMPLER_MIN_MASK)>>BGFX_SAMPLER_MIN_SHIFT];
+ m_samplerDescriptor.magFilter = s_textureFilterMinMag[(_flags&BGFX_SAMPLER_MAG_MASK)>>BGFX_SAMPLER_MAG_SHIFT];
+ m_samplerDescriptor.mipFilter = s_textureFilterMip[(_flags&BGFX_SAMPLER_MIP_MASK)>>BGFX_SAMPLER_MIP_SHIFT];
+ m_samplerDescriptor.lodMinClamp = 0;
+ m_samplerDescriptor.lodMaxClamp = FLT_MAX;
m_samplerDescriptor.normalizedCoordinates = TRUE;
m_samplerDescriptor.maxAnisotropy = (0 != (_flags & (BGFX_SAMPLER_MIN_ANISOTROPIC|BGFX_SAMPLER_MAG_ANISOTROPIC) ) ) ? m_mainFrameBuffer.m_swapChain->m_maxAnisotropy : 1;
if (m_macOS11Runtime
- || [m_device supportsFeatureSet:(MTLFeatureSet)4 /*MTLFeatureSet_iOS_GPUFamily3_v1*/])
+ || [m_device supportsFeatureSet:(MTLFeatureSet)4 /*MTLFeatureSet_iOS_GPUFamily3_v1*/])
{
const uint32_t cmpFunc = (_flags&BGFX_SAMPLER_COMPARE_MASK)>>BGFX_SAMPLER_COMPARE_SHIFT;
m_samplerDescriptor.compareFunction = 0 == cmpFunc
@@ -2082,9 +2249,11 @@ namespace bgfx { namespace mtl
BlitCommandEncoder getBlitCommandEncoder()
{
- if (m_blitCommandEncoder == NULL)
+ if (NULL == m_blitCommandEncoder)
{
- if (m_commandBuffer == NULL)
+ endEncoding();
+
+ if (NULL == m_commandBuffer)
{
m_commandBuffer = m_cmd.alloc();
}
@@ -2095,15 +2264,25 @@ namespace bgfx { namespace mtl
return m_blitCommandEncoder;
}
- id<CAMetalDrawable> currentDrawable()
+ void endEncoding()
{
- if (m_drawable == nil)
+ if (0 != m_renderCommandEncoder)
{
- m_drawable = m_metalLayer.nextDrawable;
- retain(m_drawable); // keep alive to be useable at 'flip'
+ m_renderCommandEncoder.endEncoding();
+ m_renderCommandEncoder = 0;
+ }
+
+ if (0 != m_computeCommandEncoder)
+ {
+ m_computeCommandEncoder.endEncoding();
+ m_computeCommandEncoder = 0;
}
- return m_drawable;
+ if (0 != m_blitCommandEncoder)
+ {
+ m_blitCommandEncoder.endEncoding();
+ m_blitCommandEncoder = 0;
+ }
}
Device m_device;
@@ -2111,13 +2290,6 @@ namespace bgfx { namespace mtl
TimerQueryMtl m_gpuTimer;
CommandQueueMtl m_cmd;
- CAMetalLayer* m_metalLayer;
- Texture m_backBufferColorMsaa;
- Texture m_backBufferDepth;
- Texture m_backBufferStencil;
- uint32_t m_backBufferPixelFormatHash;
- uint32_t m_maxAnisotropy;
-
bool m_iOS9Runtime;
bool m_macOS11Runtime;
bool m_hasPixelFormatDepth32Float_Stencil8;
@@ -2139,13 +2311,23 @@ namespace bgfx { namespace mtl
TextureMtl m_textures[BGFX_CONFIG_MAX_TEXTURES];
FrameBufferMtl m_mainFrameBuffer;
FrameBufferMtl m_frameBuffers[BGFX_CONFIG_MAX_FRAME_BUFFERS];
- VertexDecl m_vertexDecls[BGFX_CONFIG_MAX_VERTEX_DECLS];
+ VertexLayout m_vertexLayouts[BGFX_CONFIG_MAX_VERTEX_LAYOUTS];
UniformRegistry m_uniformReg;
void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS];
- StateCacheT<RenderPipelineState> m_pipelineStateCache;
- StateCacheT<DepthStencilState> m_depthStencilStateCache;
- StateCacheT<SamplerState> m_samplerStateCache;
+ struct PipelineProgram
+ {
+ uint64_t key;
+ ProgramHandle program;
+ };
+
+ typedef stl::vector<PipelineProgram> PipelineProgramArray;
+
+ PipelineProgramArray m_pipelineProgram;
+
+ StateCacheT<PipelineStateMtl*> m_pipelineStateCache;
+ StateCacheT<DepthStencilState> m_depthStencilStateCache;
+ StateCacheT<SamplerState> m_samplerStateCache;
TextVideoMem m_textVideoMem;
@@ -2166,7 +2348,6 @@ namespace bgfx { namespace mtl
SamplerDescriptor m_samplerDescriptor;
// currently active objects data
- id <CAMetalDrawable> m_drawable;
bool m_saveScreenshot;
Texture m_screenshotTarget;
ShaderMtl m_screenshotBlitProgramVsh;
@@ -2174,11 +2355,11 @@ namespace bgfx { namespace mtl
ProgramMtl m_screenshotBlitProgram;
RenderPipelineState m_screenshotBlitRenderPipelineState;
- CommandBuffer m_commandBuffer;
- CommandBuffer m_prevCommandBuffer;
- BlitCommandEncoder m_blitCommandEncoder;
- RenderCommandEncoder m_renderCommandEncoder;
- FrameBufferHandle m_renderCommandEncoderFrameBufferHandle;
+ CommandBuffer m_commandBuffer;
+ BlitCommandEncoder m_blitCommandEncoder;
+ RenderCommandEncoder m_renderCommandEncoder;
+ ComputeCommandEncoder m_computeCommandEncoder;
+ FrameBufferHandle m_renderCommandEncoderFrameBufferHandle;
};
RendererContextI* rendererCreate(const Init& _init)
@@ -2255,6 +2436,14 @@ namespace bgfx { namespace mtl
bx::read(&reader, regCount);
}
+ if (isShaderType(magic, 'C'))
+ {
+ for (uint32_t ii = 0; ii < 3; ++ii)
+ {
+ bx::read(&reader, m_numThreads[ii]);
+ }
+ }
+
uint32_t shaderSize;
bx::read(&reader, shaderSize);
@@ -2335,91 +2524,63 @@ namespace bgfx { namespace mtl
{
m_vsh = NULL;
m_fsh = NULL;
-
- if (NULL != m_vshConstantBuffer)
- {
- UniformBuffer::destroy(m_vshConstantBuffer);
- m_vshConstantBuffer = NULL;
- }
-
- if (NULL != m_fshConstantBuffer)
+ if ( NULL != m_computePS )
{
- UniformBuffer::destroy(m_fshConstantBuffer);
- m_fshConstantBuffer = NULL;
+ BX_DELETE(g_allocator, m_computePS);
+ m_computePS = NULL;
}
-
- m_vshConstantBufferSize = 0;
- m_vshConstantBufferAlignmentMask = 0;
- m_fshConstantBufferSize = 0;
- m_fshConstantBufferAlignmentMask = 0;
-
- m_samplerCount = 0;
- m_processedUniforms = false;
- m_numPredefined = 0;
}
void BufferMtl::create(uint32_t _size, void* _data, uint16_t _flags, uint16_t _stride, bool _vertex)
{
- BX_UNUSED(_stride, _vertex);
+ BX_UNUSED(_stride);
m_size = _size;
m_flags = _flags;
- m_dynamic = (NULL == _data);
+ m_vertex = _vertex;
if (NULL == _data)
{
- for (uint32_t ii = 0; ii < MTL_MAX_FRAMES_IN_FLIGHT; ++ii)
- {
- m_buffers[ii] = s_renderMtl->m_device.newBufferWithLength(_size, 0);
- }
+ m_ptr = s_renderMtl->m_device.newBufferWithLength(_size, 0);
}
else
{
- m_buffers[0] = s_renderMtl->m_device.newBufferWithBytes(_data, _size, 0);
+ m_ptr = s_renderMtl->m_device.newBufferWithBytes(_data, _size, 0);
}
}
void BufferMtl::update(uint32_t _offset, uint32_t _size, void* _data, bool _discard)
{
- BX_UNUSED(_discard);
+ BlitCommandEncoder bce = s_renderMtl->getBlitCommandEncoder();
- if (m_dynamic
- && _discard)
+ if (!m_vertex && !_discard)
{
- m_bufferIndex = (m_bufferIndex + 1) % MTL_MAX_FRAMES_IN_FLIGHT;
- bx::memCopy( (uint8_t*)getBuffer().contents() + _offset, _data, _size);
- }
- else if (NULL != s_renderMtl->m_renderCommandEncoder)
- {
- s_renderMtl->m_cmd.release(m_buffers[m_bufferIndex]);
-
- if (_offset == 0
- && _size == m_size)
+ if ( m_dynamic == NULL )
{
- m_buffers[m_bufferIndex] = s_renderMtl->m_device.newBufferWithBytes(_data, _size, 0);
- }
- else
- {
- const void* oldContent = m_buffers[m_bufferIndex].contents();
- m_buffers[m_bufferIndex] = s_renderMtl->m_device.newBufferWithBytes(oldContent, m_size, 0);
- bx::memCopy( (uint8_t*)m_buffers[m_bufferIndex].contents() + _offset, _data, _size);
+ m_dynamic = (uint8_t*)BX_ALLOC(g_allocator, m_size);
}
+
+ bx::memCopy(m_dynamic + _offset, _data, _size);
+ uint32_t start = _offset & 4;
+ uint32_t end = bx::strideAlign(_offset + _size, 4);
+
+ Buffer temp = s_renderMtl->m_device.newBufferWithBytes(m_dynamic, end - start, 0);
+ bce.copyFromBuffer(temp, 0, m_ptr, start, end - start);
+ s_renderMtl->m_cmd.release(temp);
}
else
{
- BlitCommandEncoder bce = s_renderMtl->getBlitCommandEncoder();
-
Buffer temp = s_renderMtl->m_device.newBufferWithBytes(_data, _size, 0);
- bce.copyFromBuffer(temp, 0, getBuffer(), _offset, _size);
- release(temp);
+ bce.copyFromBuffer(temp, 0, m_ptr, _offset, _size);
+ s_renderMtl->m_cmd.release(temp);
}
}
- void VertexBufferMtl::create(uint32_t _size, void* _data, VertexDeclHandle _declHandle, uint16_t _flags)
+ void VertexBufferMtl::create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle, uint16_t _flags)
{
- m_decl = _declHandle;
- uint16_t stride = isValid(_declHandle)
- ? s_renderMtl->m_vertexDecls[_declHandle.idx].m_stride
+ m_layoutHandle = _layoutHandle;
+ uint16_t stride = isValid(_layoutHandle)
+ ? s_renderMtl->m_vertexLayouts[_layoutHandle.idx].m_stride
: 0
;
@@ -2434,18 +2595,26 @@ namespace bgfx { namespace mtl
if (bimg::imageParse(imageContainer, _mem->data, _mem->size) )
{
- uint8_t numMips = imageContainer.m_numMips;
- const uint8_t startLod = uint8_t(bx::uint32_min(_skip, numMips-1) );
- numMips -= startLod;
const bimg::ImageBlockInfo& blockInfo = getBlockInfo(bimg::TextureFormat::Enum(imageContainer.m_format) );
- const uint32_t textureWidth = bx::uint32_max(blockInfo.blockWidth, imageContainer.m_width >>startLod);
- const uint32_t textureHeight = bx::uint32_max(blockInfo.blockHeight, imageContainer.m_height>>startLod);
- const uint16_t numLayers = imageContainer.m_numLayers;
+ const uint8_t startLod = bx::min<uint8_t>(_skip, imageContainer.m_numMips-1);
+
+ bimg::TextureInfo ti;
+ bimg::imageGetSize(
+ &ti
+ , uint16_t(imageContainer.m_width >>startLod)
+ , uint16_t(imageContainer.m_height>>startLod)
+ , uint16_t(imageContainer.m_depth >>startLod)
+ , imageContainer.m_cubeMap
+ , 1 < imageContainer.m_numMips
+ , imageContainer.m_numLayers
+ , imageContainer.m_format
+ );
+ ti.numMips = bx::min<uint8_t>(imageContainer.m_numMips-startLod, ti.numMips);
m_flags = _flags;
- m_width = textureWidth;
- m_height = textureHeight;
- m_depth = imageContainer.m_depth;
+ m_width = ti.width;
+ m_height = ti.height;
+ m_depth = ti.depth;
m_requestedFormat = uint8_t(imageContainer.m_format);
m_textureFormat = uint8_t(getViableTextureFormat(imageContainer) );
const bool convert = m_textureFormat != m_requestedFormat;
@@ -2453,7 +2622,7 @@ namespace bgfx { namespace mtl
TextureDescriptor desc = s_renderMtl->m_textureDescriptor;
- if (1 < numLayers)
+ if (1 < ti.numLayers)
{
if (imageContainer.m_cubeMap)
{
@@ -2471,7 +2640,7 @@ namespace bgfx { namespace mtl
desc.textureType = MTLTextureTypeCube;
m_type = TextureCube;
}
- else if (imageContainer.m_depth > 1)
+ else if (1 < imageContainer.m_depth)
{
desc.textureType = MTLTextureType3D;
m_type = Texture3D;
@@ -2482,8 +2651,8 @@ namespace bgfx { namespace mtl
m_type = Texture2D;
}
- m_numMips = numMips;
- const uint16_t numSides = numLayers * (imageContainer.m_cubeMap ? 6 : 1);
+ m_numMips = ti.numMips;
+ const uint16_t numSides = ti.numLayers * (imageContainer.m_cubeMap ? 6 : 1);
const bool compressed = bimg::isCompressed(bimg::TextureFormat::Enum(m_textureFormat) );
const bool writeOnly = 0 != (_flags&BGFX_TEXTURE_RT_WRITE_ONLY);
const bool computeWrite = 0 != (_flags&BGFX_TEXTURE_COMPUTE_WRITE);
@@ -2494,18 +2663,18 @@ namespace bgfx { namespace mtl
, this - s_renderMtl->m_textures
, getName( (TextureFormat::Enum)m_textureFormat)
, getName( (TextureFormat::Enum)m_requestedFormat)
- , numLayers
- , textureWidth
- , textureHeight
+ , ti.numLayers
+ , ti.width
+ , ti.height
, imageContainer.m_cubeMap ? "x6" : ""
- , renderTarget ? 'x' : '.'
- , writeOnly ? 'x' : '.'
- , computeWrite ? 'x' : '.'
- , srgb ? 'x' : '.'
+ , renderTarget ? 'x' : ' '
+ , writeOnly ? 'x' : ' '
+ , computeWrite ? 'x' : ' '
+ , srgb ? 'x' : ' '
);
const uint32_t msaaQuality = bx::uint32_satsub( (_flags&BGFX_TEXTURE_RT_MSAA_MASK)>>BGFX_TEXTURE_RT_MSAA_SHIFT, 1);
- int sampleCount = s_msaa[msaaQuality];
+ const int32_t sampleCount = s_msaa[msaaQuality];
MTLPixelFormat format = MTLPixelFormatInvalid;
if (srgb)
@@ -2524,14 +2693,15 @@ namespace bgfx { namespace mtl
}
desc.pixelFormat = format;
- desc.width = textureWidth;
- desc.height = textureHeight;
+ desc.width = ti.width;
+ desc.height = ti.height;
desc.depth = bx::uint32_max(1,imageContainer.m_depth);
- desc.mipmapLevelCount = numMips;
+ desc.mipmapLevelCount = ti.numMips;
desc.sampleCount = 1;
- desc.arrayLength = numLayers;
+ desc.arrayLength = ti.numLayers;
- if (s_renderMtl->m_iOS9Runtime || s_renderMtl->m_macOS11Runtime)
+ if (s_renderMtl->m_iOS9Runtime
+ || s_renderMtl->m_macOS11Runtime)
{
desc.cpuCacheMode = MTLCPUCacheModeDefaultCache;
@@ -2582,20 +2752,20 @@ namespace bgfx { namespace mtl
uint8_t* temp = NULL;
if (convert)
{
- temp = (uint8_t*)BX_ALLOC(g_allocator, textureWidth*textureHeight*4);
+ temp = (uint8_t*)BX_ALLOC(g_allocator, ti.width*ti.height*4);
}
for (uint8_t side = 0; side < numSides; ++side)
{
- uint32_t width = textureWidth;
- uint32_t height = textureHeight;
- uint32_t depth = imageContainer.m_depth;
+ uint32_t width = ti.width;
+ uint32_t height = ti.height;
+ uint32_t depth = ti.depth;
- for (uint8_t lod = 0, num = numMips; lod < num; ++lod)
+ for (uint8_t lod = 0, num = ti.numMips; lod < num; ++lod)
{
- width = bx::uint32_max(1, width);
- height = bx::uint32_max(1, height);
- depth = bx::uint32_max(1, depth);
+ width = bx::max(1u, width);
+ height = bx::max(1u, height);
+ depth = bx::max(1u, depth);
bimg::ImageMip mip;
if (bimg::imageGetRawData(imageContainer, side, lod+startLod, _mem->data, _mem->size, mip) )
@@ -2668,8 +2838,8 @@ namespace bgfx { namespace mtl
const uint32_t bpp = bimg::getBitsPerPixel(bimg::TextureFormat::Enum(m_textureFormat) );
const uint32_t rectpitch = _rect.m_width*bpp/8;
const uint32_t srcpitch = UINT16_MAX == _pitch ? rectpitch : _pitch;
- const uint32_t slice = ( (m_type == Texture3D) ? 0 : _side + _z * (m_type == TextureCube ? 6 : 1) );
- const uint16_t z = (m_type == Texture3D) ? _z : 0 ;
+ const uint32_t slice = ( (m_type == Texture3D) ? 0 : _side + _z * (m_type == TextureCube ? 6 : 1) );
+ const uint16_t zz = (m_type == Texture3D) ? _z : 0 ;
const bool convert = m_textureFormat != m_requestedFormat;
@@ -2697,7 +2867,7 @@ namespace bgfx { namespace mtl
MTLRegion region =
{
- { _rect.m_x, _rect.m_y, z },
+ { _rect.m_x, _rect.m_y, zz },
{ _rect.m_width, _rect.m_height, _depth },
};
@@ -2728,7 +2898,7 @@ namespace bgfx { namespace mtl
, m_ptr
, slice
, _mip
- , MTLOriginMake(_rect.m_x, _rect.m_y, z)
+ , MTLOriginMake(_rect.m_x, _rect.m_y, zz)
);
release(tempBuffer);
}
@@ -2764,13 +2934,54 @@ namespace bgfx { namespace mtl
}
}
+ Texture TextureMtl::getTextureMipLevel(int _mip)
+ {
+ if (_mip >= 0
+ && _mip < m_numMips
+ && NULL != m_ptr)
+ {
+ if (NULL == m_ptrMips[_mip])
+ {
+ if (TextureCube == m_type)
+ {
+ m_ptrMips[_mip] = m_ptr.newTextureViewWithPixelFormat(
+ m_ptr.pixelFormat()
+ , MTLTextureType2DArray
+ , NSMakeRange(_mip,1)
+ , NSMakeRange(0,m_ptr.arrayLength() * 6)
+ );
+ }
+ else
+ {
+ m_ptrMips[_mip] = m_ptr.newTextureViewWithPixelFormat(
+ m_ptr.pixelFormat()
+ , m_ptr.textureType()
+ , NSMakeRange(_mip,1)
+ , NSMakeRange(0,m_ptr.arrayLength())
+ );
+ }
+ }
+
+ return m_ptrMips[_mip];
+ }
+
+ return 0;
+ }
+
SwapChainMtl::~SwapChainMtl()
{
+ MTL_RELEASE(m_metalLayer);
+ MTL_RELEASE(m_drawable);
+ MTL_RELEASE(m_drawableTexture);
+
MTL_RELEASE(m_backBufferDepth);
- if (BX_ENABLED(BX_PLATFORM_IOS) )
+ MTL_RELEASE(m_backBufferStencil);
+
+ if (NULL != m_backBufferColorMsaa)
{
- MTL_RELEASE(m_backBufferStencil);
+ MTL_RELEASE(m_backBufferColorMsaa);
}
+
}
void SwapChainMtl::init(void* _nwh)
@@ -2793,7 +3004,7 @@ namespace bgfx { namespace mtl
if (NULL == metalLayer
|| ![metalLayer isKindOfClass:NSClassFromString(@"CAMetalLayer")])
{
- BX_WARN(NULL != metalLayer, "Unable to create Metal device. Please set platform data window to a CAMetalLayer");
+ BX_WARN(false, "Unable to create Metal device. Please set platform data window to a CAMetalLayer");
return;
}
@@ -2809,10 +3020,34 @@ namespace bgfx { namespace mtl
}
else
{
- NSWindow* nsWindow = (NSWindow*)_nwh;
- [nsWindow.contentView setWantsLayer:YES];
- m_metalLayer = [CAMetalLayer layer];
- [nsWindow.contentView setLayer:m_metalLayer];
+ NSView *contentView;
+
+ if ([nvh isKindOfClass:[NSView class]])
+ {
+ contentView = (NSView*)nvh;
+ }
+ else if ([nvh isKindOfClass:[NSWindow class]])
+ {
+ NSWindow* nsWindow = (NSWindow*)nvh;
+ contentView = [nsWindow contentView];
+ }
+ else
+ {
+ BX_WARN(0, "Unable to create Metal device. Please set platform data window to an NSWindow, NSView, or CAMetalLayer");
+ return;
+ }
+
+ CALayer* layer = contentView.layer;
+ if(NULL != layer && [layer isKindOfClass:NSClassFromString(@"CAMetalLayer")])
+ {
+ m_metalLayer = (CAMetalLayer*)layer;
+ }
+ else
+ {
+ [contentView setWantsLayer:YES];
+ m_metalLayer = [CAMetalLayer layer];
+ [contentView setLayer:m_metalLayer];
+ }
}
}
#endif // BX_PLATFORM_*
@@ -2827,15 +3062,22 @@ namespace bgfx { namespace mtl
m_metalLayer.device = s_renderMtl->m_device;
m_metalLayer.pixelFormat = MTLPixelFormatBGRA8Unorm;
m_metalLayer.magnificationFilter = kCAFilterNearest;
+
+ retain(m_metalLayer);
}
void SwapChainMtl::resize(FrameBufferMtl &_frameBuffer, uint32_t _width, uint32_t _height, uint32_t _flags)
{
- int sampleCount = s_msaa[(_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT];
-
-#if BX_PLATFORM_OSX > 101300
- m_metalLayer.displaySyncEnabled = 0 != (_flags&BGFX_RESET_VSYNC);
-#endif // BX_PLATFORM_OSX > 101300
+ const int32_t sampleCount = s_msaa[(_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT];
+
+#if BX_PLATFORM_OSX
+#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
+ if (@available(macOS 10.13, *))
+ {
+ m_metalLayer.displaySyncEnabled = 0 != (_flags&BGFX_RESET_VSYNC);
+ }
+#endif // __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
+#endif // BX_PLATFORM_OSX
m_metalLayer.drawableSize = CGSizeMake(_width, _height);
m_metalLayer.pixelFormat = (_flags & BGFX_RESET_SRGB_BACKBUFFER)
@@ -2894,7 +3136,7 @@ namespace bgfx { namespace mtl
m_backBufferStencil = s_renderMtl->m_device.newTextureWithDescriptor(desc);
}
- if ( sampleCount > 1 )
+ if (sampleCount > 1)
{
if (NULL != m_backBufferColorMsaa)
{
@@ -2908,35 +3150,67 @@ namespace bgfx { namespace mtl
bx::HashMurmur2A murmur;
murmur.begin();
murmur.add(1);
- murmur.add((uint32_t)m_metalLayer.pixelFormat);
- murmur.add((uint32_t)m_backBufferDepth.pixelFormat());
- murmur.add((uint32_t)m_backBufferStencil.pixelFormat());
- murmur.add((uint32_t)sampleCount);
+ murmur.add( (uint32_t)m_metalLayer.pixelFormat);
+ murmur.add( (uint32_t)m_backBufferDepth.pixelFormat());
+ murmur.add( (uint32_t)m_backBufferStencil.pixelFormat());
+ murmur.add( (uint32_t)sampleCount);
_frameBuffer.m_pixelFormatHash = murmur.end();
}
- id<CAMetalDrawable> SwapChainMtl::currentDrawable()
+ id <MTLTexture> SwapChainMtl::currentDrawableTexture()
{
- if (m_drawable == nil)
+ if (NULL == m_drawableTexture)
{
m_drawable = m_metalLayer.nextDrawable;
- retain(m_drawable); // keep alive to be useable at 'flip'
+ if (m_drawable != NULL)
+ {
+ m_drawableTexture = m_drawable.texture;
+ retain(m_drawableTexture);
+ retain(m_drawable); // keep alive to be useable at 'flip'
+ }
+ else
+ {
+ TextureDescriptor desc = s_renderMtl->m_textureDescriptor;
+ desc.textureType = MTLTextureType2D;
+ desc.pixelFormat = m_metalLayer.pixelFormat;
+ desc.width = m_metalLayer.drawableSize.width;
+ desc.height = m_metalLayer.drawableSize.height;
+ desc.depth = 1;
+ desc.mipmapLevelCount = 1;
+ desc.sampleCount = 1;
+ desc.arrayLength = 1;
+
+ if (s_renderMtl->m_iOS9Runtime
+ || s_renderMtl->m_macOS11Runtime)
+ {
+ desc.cpuCacheMode = MTLCPUCacheModeDefaultCache;
+ desc.storageMode = BX_ENABLED(BX_PLATFORM_IOS)
+ ? (MTLStorageMode)0 // MTLStorageModeShared
+ : (MTLStorageMode)1 // MTLStorageModeManaged
+ ;
+
+ desc.usage = MTLTextureUsageRenderTarget;
+ }
+
+ m_drawableTexture = s_renderMtl->m_device.newTextureWithDescriptor(desc);
+ }
}
- return m_drawable;
+ return m_drawableTexture;
}
void FrameBufferMtl::create(uint8_t _num, const Attachment* _attachment)
{
m_swapChain = NULL;
- m_denseIdx = UINT16_MAX;
- m_num = 0;
- m_width = 0;
- m_height = 0;
+ m_denseIdx = UINT16_MAX;
+ m_num = 0;
+ m_width = 0;
+ m_height = 0;
for (uint32_t ii = 0; ii < _num; ++ii)
{
- TextureHandle handle = _attachment[ii].handle;
+ const Attachment& at = _attachment[ii];
+ TextureHandle handle = at.handle;
if (isValid(handle) )
{
@@ -2951,10 +3225,12 @@ namespace bgfx { namespace mtl
if (bimg::isDepth(bimg::TextureFormat::Enum(texture.m_textureFormat) ) )
{
m_depthHandle = handle;
+ m_depthAttachment = at;
}
else
{
m_colorHandle[m_num] = handle;
+ m_colorAttachment[m_num] = at;
m_num++;
}
}
@@ -2994,8 +3270,10 @@ namespace bgfx { namespace mtl
{
BX_UNUSED(_format, _depthFormat);
m_swapChain = BX_NEW(g_allocator, SwapChainMtl);
+ m_num = 0;
m_width = _width;
m_height = _height;
+ m_nwh = _nwh;
m_denseIdx = _denseIdx;
m_swapChain->init(_nwh);
@@ -3014,6 +3292,7 @@ namespace bgfx { namespace mtl
}
m_num = 0;
+ m_nwh = NULL;
m_depthHandle.idx = kInvalidHandle;
uint16_t denseIdx = m_denseIdx;
@@ -3041,7 +3320,7 @@ namespace bgfx { namespace mtl
return m_activeCommandBuffer;
}
- static void commandBufferFinishedCallback(void* _data)
+ inline void commandBufferFinishedCallback(void* _data)
{
CommandQueueMtl* queue = (CommandQueueMtl*)_data;
@@ -3123,6 +3402,17 @@ namespace bgfx { namespace mtl
{
}
+ uint32_t TimerQueryMtl::begin(uint32_t _resultIdx)
+ {
+ BX_UNUSED(_resultIdx);
+ return 0;
+ }
+
+ void TimerQueryMtl::end(uint32_t _idx)
+ {
+ BX_UNUSED(_idx);
+ }
+
static void setTimestamp(void* _data)
{
*( (int64_t*)_data) = bx::getHPCounter();
@@ -3135,10 +3425,10 @@ namespace bgfx { namespace mtl
m_control.consume(1);
}
- uint32_t offset = m_control.m_current * 2 + 0;
+ uint32_t offset = m_control.m_current;
- _commandBuffer.addScheduledHandler(setTimestamp, &m_result[offset]);
- _commandBuffer.addCompletedHandler(setTimestamp, &m_result[offset+1]);
+ _commandBuffer.addScheduledHandler(setTimestamp, &m_result[offset].m_begin);
+ _commandBuffer.addCompletedHandler(setTimestamp, &m_result[offset].m_end);
m_control.commit(1);
}
@@ -3146,9 +3436,9 @@ namespace bgfx { namespace mtl
{
if (0 != m_control.available() )
{
- uint32_t offset = m_control.m_read * 2;
- m_begin = m_result[offset+0];
- m_end = m_result[offset+1];
+ uint32_t offset = m_control.m_read;
+ m_begin = m_result[offset].m_begin;
+ m_end = m_result[offset].m_end;
m_elapsed = m_end - m_begin;
m_control.consume(1);
@@ -3224,15 +3514,13 @@ namespace bgfx { namespace mtl
void RendererContextMtl::submitBlit(BlitState& _bs, uint16_t _view)
{
- if (!_bs.hasItem(_view))
- return;
-
- if (0 != m_renderCommandEncoder)
+ if (!_bs.hasItem(_view) )
{
- m_renderCommandEncoder.endEncoding();
- m_renderCommandEncoder = 0;
+ return;
}
+ endEncoding();
+
m_blitCommandEncoder = getBlitCommandEncoder();
while (_bs.hasItem(_view) )
@@ -3310,11 +3598,13 @@ namespace bgfx { namespace mtl
{
m_cmd.finish(false);
- if (m_commandBuffer == NULL)
+ if (NULL == m_commandBuffer)
{
m_commandBuffer = m_cmd.alloc();
}
+ BGFX_MTL_PROFILER_BEGIN_LITERAL("rendererSubmit", kColorFrame);
+
int64_t timeBegin = bx::getHPCounter();
int64_t captureElapsed = 0;
@@ -3383,14 +3673,16 @@ namespace bgfx { namespace mtl
if (0 < _render->m_iboffset)
{
+ BGFX_PROFILER_SCOPE("bgfx/Update transient index buffer", kColorResource);
TransientIndexBuffer* ib = _render->m_transientIb;
- m_indexBuffers[ib->handle.idx].update(0, _render->m_iboffset, ib->data, true);
+ m_indexBuffers[ib->handle.idx].update(0, bx::strideAlign(_render->m_iboffset,4), ib->data, true);
}
if (0 < _render->m_vboffset)
{
+ BGFX_PROFILER_SCOPE("bgfx/Update transient vertex buffer", kColorResource);
TransientVertexBuffer* vb = _render->m_transientVb;
- m_vertexBuffers[vb->handle.idx].update(0, _render->m_vboffset, vb->data, true);
+ m_vertexBuffers[vb->handle.idx].update(0, bx::strideAlign(_render->m_vboffset,4), vb->data, true);
}
_render->sort();
@@ -3403,14 +3695,13 @@ namespace bgfx { namespace mtl
RenderBind currentBind;
currentBind.clear();
- const bool hmdEnabled = false;
static ViewState viewState;
- viewState.reset(_render, hmdEnabled);
+ viewState.reset(_render);
uint32_t blendFactor = 0;
bool wireframe = !!(_render->m_debug&BGFX_DEBUG_WIREFRAME);
- uint16_t programIdx = kInvalidHandle;
+ ProgramHandle currentProgram = BGFX_INVALID_HANDLE;
SortKey key;
uint16_t view = UINT16_MAX;
FrameBufferHandle fbh = { BGFX_CONFIG_MAX_FRAME_BUFFERS };
@@ -3420,33 +3711,38 @@ namespace bgfx { namespace mtl
const uint64_t primType = 0;
uint8_t primIndex = uint8_t(primType>>BGFX_STATE_PT_SHIFT);
PrimInfo prim = s_primInfo[primIndex];
+ const uint32_t maxComputeBindings = g_caps.limits.maxComputeBindings;
+ const uint32_t maxTextureSamplers = g_caps.limits.maxTextureSamplers;
- ProgramMtl* currentProgram = NULL;
RenderCommandEncoder rce;
+ PipelineStateMtl* currentPso = NULL;
- bool wasCompute = false;
+ bool wasCompute = false;
bool viewHasScissor = false;
Rect viewScissorRect;
viewScissorRect.clear();
uint32_t statsNumPrimsSubmitted[BX_COUNTOF(s_primInfo)] = {};
- uint32_t statsNumPrimsRendered[BX_COUNTOF(s_primInfo)] = {};
- uint32_t statsNumInstances[BX_COUNTOF(s_primInfo)] = {};
- uint32_t statsNumDrawIndirect[BX_COUNTOF(s_primInfo)] = {};
+ uint32_t statsNumPrimsRendered[BX_COUNTOF(s_primInfo)] = {};
+ uint32_t statsNumInstances[BX_COUNTOF(s_primInfo)] = {};
+ uint32_t statsNumDrawIndirect[BX_COUNTOF(s_primInfo)] = {};
uint32_t statsNumIndices = 0;
uint32_t statsKeyType[2] = {};
+ Profiler<TimerQueryMtl> profiler(
+ _render
+ , m_gpuTimer
+ , s_viewName
+ );
+
m_occlusionQuery.resolve(_render);
if (0 == (_render->m_debug&BGFX_DEBUG_IFH) )
{
- bool viewRestart = false;
- uint8_t eye = 0;
- uint8_t restartState = 0;
viewState.m_rect = _render->m_view[0].m_rect;
-
int32_t numItems = _render->m_numRenderItems;
- for (int32_t item = 0, restartItem = numItems; item < numItems || restartItem < numItems;)
+
+ for (int32_t item = 0; item < numItems;)
{
const uint64_t encodedKey = _render->m_sortKeys[item];
const bool isCompute = key.decode(encodedKey, _render->m_viewRemap);
@@ -3462,226 +3758,360 @@ namespace bgfx { namespace mtl
const RenderBind& renderBind = _render->m_renderItemBind[itemIdx];
++item;
- if (viewChanged)
+ if (viewChanged
+ || (!isCompute && wasCompute) )
{
- if (1 == restartState)
- {
- restartState = 2;
- item = restartItem;
- restartItem = numItems;
- view = UINT16_MAX;
- continue;
- }
-
view = key.m_view;
- programIdx = kInvalidHandle;
+ currentProgram = BGFX_INVALID_HANDLE;
- viewRestart = BGFX_VIEW_STEREO == (_render->m_view[view].m_flags & BGFX_VIEW_STEREO);
- viewRestart &= hmdEnabled;
-
- if (viewRestart)
- {
- if (0 == restartState)
- {
- restartState = 1;
- restartItem = item - 1;
- }
-
- eye = (restartState - 1) & 1;
- restartState &= 1;
- }
- else
+ if (item > 1)
{
- eye = 0;
+ profiler.end();
}
- viewState.m_rect = _render->m_view[view].m_rect;
+ BGFX_MTL_PROFILER_END();
+ setViewType(view, " ");
+ BGFX_MTL_PROFILER_BEGIN(view, kColorView);
- if (viewRestart)
- {
- viewState.m_rect.m_x = eye * (viewState.m_rect.m_width+1)/2;
- viewState.m_rect.m_width /= 2;
- }
+ profiler.begin(view);
+
+ viewState.m_rect = _render->m_view[view].m_rect;
submitBlit(bs, view);
- const Rect& scissorRect = _render->m_view[view].m_scissor;
- viewHasScissor = !scissorRect.isZero();
- viewScissorRect = viewHasScissor ? scissorRect : viewState.m_rect;
- Clear& clr = _render->m_view[view].m_clear;
+ if (!isCompute)
+ {
+ const Rect& scissorRect = _render->m_view[view].m_scissor;
+ viewHasScissor = !scissorRect.isZero();
+ viewScissorRect = viewHasScissor ? scissorRect : viewState.m_rect;
+ Clear& clr = _render->m_view[view].m_clear;
- Rect viewRect = viewState.m_rect;
- bool clearWithRenderPass = false;
+ Rect viewRect = viewState.m_rect;
+ bool clearWithRenderPass = false;
- if (NULL == m_renderCommandEncoder
- || fbh.idx != _render->m_view[view].m_fbh.idx)
- {
- if (0 != m_renderCommandEncoder)
+ if ((NULL == m_renderCommandEncoder
+ || fbh.idx != _render->m_view[view].m_fbh.idx))
{
- m_renderCommandEncoder.endEncoding();
- }
+ endEncoding();
- RenderPassDescriptor renderPassDescriptor = newRenderPassDescriptor();
- renderPassDescriptor.visibilityResultBuffer = m_occlusionQuery.m_buffer;
+ RenderPassDescriptor renderPassDescriptor = newRenderPassDescriptor();
+ renderPassDescriptor.visibilityResultBuffer = m_occlusionQuery.m_buffer;
- fbh = _render->m_view[view].m_fbh;
+ fbh = _render->m_view[view].m_fbh;
- uint32_t width = m_resolution.width;
- uint32_t height = m_resolution.height;
+ uint32_t width = m_resolution.width;
+ uint32_t height = m_resolution.height;
- if (isValid(fbh) )
- {
- FrameBufferMtl& frameBuffer = m_frameBuffers[fbh.idx];
- width = frameBuffer.m_width;
- height = frameBuffer.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
- ;
+ clearWithRenderPass = true
+ && 0 == viewRect.m_x
+ && 0 == viewRect.m_y
+ && width == viewRect.m_width
+ && height == viewRect.m_height
+ ;
- setFrameBuffer(renderPassDescriptor, fbh);
+ setFrameBuffer(renderPassDescriptor, fbh);
- if (clearWithRenderPass)
- {
- for (uint32_t ii = 0; ii < g_caps.limits.maxFBAttachments; ++ii)
+ if (clearWithRenderPass)
{
- MTLRenderPassColorAttachmentDescriptor* desc = renderPassDescriptor.colorAttachments[ii];
-
- if (desc.texture != NULL)
+ for (uint32_t ii = 0; ii < g_caps.limits.maxFBAttachments; ++ii)
{
- if (0 != (BGFX_CLEAR_COLOR & clr.m_flags) )
+ MTLRenderPassColorAttachmentDescriptor* desc = renderPassDescriptor.colorAttachments[ii];
+
+ if (desc.texture != NULL)
{
- if (0 != (BGFX_CLEAR_COLOR_USE_PALETTE & clr.m_flags) )
+ if (0 != (BGFX_CLEAR_COLOR & clr.m_flags) )
{
- uint8_t index = (uint8_t)bx::uint32_min(BGFX_CONFIG_MAX_COLOR_PALETTE-1, clr.m_index[ii]);
- const float* rgba = _render->m_colorPalette[index];
- const float rr = rgba[0];
- const float gg = rgba[1];
- const float bb = rgba[2];
- const float aa = rgba[3];
- desc.clearColor = MTLClearColorMake(rr, gg, bb, aa);
+ if (0 != (BGFX_CLEAR_COLOR_USE_PALETTE & clr.m_flags) )
+ {
+ uint8_t index = (uint8_t)bx::uint32_min(BGFX_CONFIG_MAX_COLOR_PALETTE-1, clr.m_index[ii]);
+ const float* rgba = _render->m_colorPalette[index];
+ const float rr = rgba[0];
+ const float gg = rgba[1];
+ const float bb = rgba[2];
+ const float aa = rgba[3];
+ desc.clearColor = MTLClearColorMake(rr, gg, bb, aa);
+ }
+ else
+ {
+ float rr = clr.m_index[0]*1.0f/255.0f;
+ float gg = clr.m_index[1]*1.0f/255.0f;
+ float bb = clr.m_index[2]*1.0f/255.0f;
+ float aa = clr.m_index[3]*1.0f/255.0f;
+ desc.clearColor = MTLClearColorMake(rr, gg, bb, aa);
+ }
+
+ desc.loadAction = MTLLoadActionClear;
}
else
{
- float rr = clr.m_index[0]*1.0f/255.0f;
- float gg = clr.m_index[1]*1.0f/255.0f;
- float bb = clr.m_index[2]*1.0f/255.0f;
- float aa = clr.m_index[3]*1.0f/255.0f;
- desc.clearColor = MTLClearColorMake(rr, gg, bb, aa);
+ desc.loadAction = MTLLoadActionLoad;
}
- desc.loadAction = MTLLoadActionClear;
+ desc.storeAction = desc.texture.sampleCount > 1 ? MTLStoreActionMultisampleResolve : MTLStoreActionStore;
}
- else
+ }
+
+ RenderPassDepthAttachmentDescriptor depthAttachment = renderPassDescriptor.depthAttachment;
+
+ if (NULL != depthAttachment.texture)
+ {
+ depthAttachment.clearDepth = clr.m_depth;
+ depthAttachment.loadAction = 0 != (BGFX_CLEAR_DEPTH & clr.m_flags)
+ ? MTLLoadActionClear
+ : MTLLoadActionLoad
+ ;
+ depthAttachment.storeAction = NULL != m_mainFrameBuffer.m_swapChain->m_backBufferColorMsaa
+ ? MTLStoreActionDontCare
+ : MTLStoreActionStore
+ ;
+ }
+
+ RenderPassStencilAttachmentDescriptor stencilAttachment = renderPassDescriptor.stencilAttachment;
+
+ if (NULL != stencilAttachment.texture)
+ {
+ stencilAttachment.clearStencil = clr.m_stencil;
+ stencilAttachment.loadAction = 0 != (BGFX_CLEAR_STENCIL & clr.m_flags)
+ ? MTLLoadActionClear
+ : MTLLoadActionLoad
+ ;
+ stencilAttachment.storeAction = NULL != m_mainFrameBuffer.m_swapChain->m_backBufferColorMsaa
+ ? MTLStoreActionDontCare
+ : MTLStoreActionStore
+ ;
+ }
+ }
+ else
+ {
+ for (uint32_t ii = 0; ii < g_caps.limits.maxFBAttachments; ++ii)
+ {
+ MTLRenderPassColorAttachmentDescriptor* desc = renderPassDescriptor.colorAttachments[ii];
+ if (desc.texture != NULL)
{
desc.loadAction = MTLLoadActionLoad;
}
- desc.storeAction = desc.texture.sampleCount > 1 ? MTLStoreActionMultisampleResolve : MTLStoreActionStore;
}
- }
- RenderPassDepthAttachmentDescriptor depthAttachment = renderPassDescriptor.depthAttachment;
- if (NULL != depthAttachment.texture)
- {
- depthAttachment.clearDepth = clr.m_depth;
- depthAttachment.loadAction = 0 != (BGFX_CLEAR_DEPTH & clr.m_flags)
- ? MTLLoadActionClear
- : MTLLoadActionLoad
- ;
- depthAttachment.storeAction = NULL != m_mainFrameBuffer.m_swapChain->m_backBufferColorMsaa
- ? MTLStoreActionDontCare
- : MTLStoreActionStore
- ;
- }
+ RenderPassDepthAttachmentDescriptor depthAttachment = renderPassDescriptor.depthAttachment;
- RenderPassStencilAttachmentDescriptor stencilAttachment = renderPassDescriptor.stencilAttachment;
- if (NULL != stencilAttachment.texture)
- {
- stencilAttachment.clearStencil = clr.m_stencil;
- stencilAttachment.loadAction = 0 != (BGFX_CLEAR_STENCIL & clr.m_flags)
- ? MTLLoadActionClear
- : MTLLoadActionLoad
- ;
- stencilAttachment.storeAction = NULL != m_mainFrameBuffer.m_swapChain->m_backBufferColorMsaa
- ? MTLStoreActionDontCare
- : MTLStoreActionStore
- ;
+ if (NULL != depthAttachment.texture)
+ {
+ depthAttachment.loadAction = MTLLoadActionLoad;
+ depthAttachment.storeAction = MTLStoreActionStore;
+ }
+
+ RenderPassStencilAttachmentDescriptor stencilAttachment = renderPassDescriptor.stencilAttachment;
+
+ if (NULL != stencilAttachment.texture)
+ {
+ stencilAttachment.loadAction = MTLLoadActionLoad;
+ stencilAttachment.storeAction = MTLStoreActionStore;
+ }
}
+
+ rce = m_commandBuffer.renderCommandEncoderWithDescriptor(renderPassDescriptor);
+ m_renderCommandEncoder = rce;
+ m_renderCommandEncoderFrameBufferHandle = fbh;
+ MTL_RELEASE(renderPassDescriptor);
}
- else
+ else if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
+ {
+ rce.popDebugGroup();
+ }
+
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
+ {
+ rce.pushDebugGroup(s_viewName[view]);
+ }
+
+ rce.setTriangleFillMode(wireframe ? MTLTriangleFillModeLines : MTLTriangleFillModeFill);
+
+ MTLViewport vp;
+ vp.originX = viewState.m_rect.m_x;
+ vp.originY = viewState.m_rect.m_y;
+ vp.width = viewState.m_rect.m_width;
+ vp.height = viewState.m_rect.m_height;
+ vp.znear = 0.0f;
+ vp.zfar = 1.0f;
+ rce.setViewport(vp);
+
+ if (BGFX_CLEAR_NONE != (clr.m_flags & BGFX_CLEAR_MASK)
+ && !clearWithRenderPass)
+ {
+ clearQuad(_clearQuad, viewState.m_rect, clr, _render->m_colorPalette);
+ }
+ }
+ }
+
+ if (isCompute)
+ {
+ if (!wasCompute)
+ {
+ wasCompute = true;
+
+ endEncoding();
+ rce = NULL;
+
+ setViewType(view, "C");
+ BGFX_MTL_PROFILER_END();
+ BGFX_MTL_PROFILER_BEGIN(view, kColorCompute);
+
+ m_computeCommandEncoder = m_commandBuffer.computeCommandEncoder();
+ }
+ else if (viewChanged && BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
+ {
+ m_computeCommandEncoder.popDebugGroup();
+ }
+
+ if (viewChanged
+ && BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
+ {
+ s_viewName[view][3] = L'C';
+ m_computeCommandEncoder.pushDebugGroup(s_viewName[view]);
+ s_viewName[view][3] = L' ';
+ }
+
+ const RenderCompute& compute = renderItem.compute;
+
+ bool programChanged = false;
+ rendererUpdateUniforms(this, _render->m_uniformBuffer[compute.m_uniformIdx], compute.m_uniformBegin, compute.m_uniformEnd);
+
+ if (key.m_program.idx != currentProgram.idx)
+ {
+ currentProgram = key.m_program;
+
+ currentPso = getComputePipelineState(currentProgram);
+
+ if (NULL == currentPso)
+ {
+ currentProgram = BGFX_INVALID_HANDLE;
+ continue;
+ }
+
+ m_computeCommandEncoder.setComputePipelineState(currentPso->m_cps);
+ programChanged = true;
+ }
+
+ if (isValid(currentProgram)
+ && NULL != currentPso)
+ {
+ uint32_t vertexUniformBufferSize = currentPso->m_vshConstantBufferSize;
+
+ if (0 != vertexUniformBufferSize)
+ {
+ m_uniformBufferVertexOffset = BX_ALIGN_MASK(m_uniformBufferVertexOffset, currentPso->m_vshConstantBufferAlignmentMask);
+ m_computeCommandEncoder.setBuffer(m_uniformBuffer, m_uniformBufferVertexOffset, 0);
+ }
+
+ UniformBuffer* vcb = currentPso->m_vshConstantBuffer;
+ if (NULL != vcb)
+ {
+ commit(*vcb);
+ }
+
+ viewState.setPredefined<4>(this, view, *currentPso, _render, compute);
+
+ m_uniformBufferVertexOffset += vertexUniformBufferSize;
+ }
+ BX_UNUSED(programChanged);
+
+ for (uint8_t stage = 0; stage < maxComputeBindings; ++stage)
+ {
+ const Binding& bind = renderBind.m_bind[stage];
+ if (kInvalidHandle != bind.m_idx)
{
- for (uint32_t ii = 0; ii < g_caps.limits.maxFBAttachments; ++ii)
+ switch (bind.m_type)
{
- MTLRenderPassColorAttachmentDescriptor* desc = renderPassDescriptor.colorAttachments[ii];
- if (desc.texture != NULL)
+ case Binding::Image:
{
- desc.loadAction = MTLLoadActionLoad;
+ TextureMtl& texture = m_textures[bind.m_idx];
+ m_computeCommandEncoder.setTexture(texture.getTextureMipLevel(bind.m_mip), stage);
}
- }
+ break;
- RenderPassDepthAttachmentDescriptor depthAttachment = renderPassDescriptor.depthAttachment;
- if (NULL != depthAttachment.texture)
- {
- depthAttachment.loadAction = MTLLoadActionLoad;
- depthAttachment.storeAction = MTLStoreActionStore;
- }
+ case Binding::Texture:
+ {
+ TextureMtl& texture = m_textures[bind.m_idx];
+ uint32_t flags = bind.m_samplerFlags;
+
+ m_computeCommandEncoder.setTexture(texture.m_ptr, stage);
+ m_computeCommandEncoder.setSamplerState(
+ 0 == (BGFX_SAMPLER_INTERNAL_DEFAULT & flags)
+ ? getSamplerState(flags)
+ : texture.m_sampler
+ , stage
+ );
+ }
+ break;
- RenderPassStencilAttachmentDescriptor stencilAttachment = renderPassDescriptor.stencilAttachment;
- if (NULL != stencilAttachment.texture)
- {
- stencilAttachment.loadAction = MTLLoadActionLoad;
- stencilAttachment.storeAction = MTLStoreActionStore;
+ case Binding::IndexBuffer:
+ case Binding::VertexBuffer:
+ {
+ const BufferMtl& buffer = Binding::IndexBuffer == bind.m_type
+ ? m_indexBuffers[bind.m_idx]
+ : m_vertexBuffers[bind.m_idx]
+ ;
+ m_computeCommandEncoder.setBuffer(buffer.m_ptr, 0, stage + 1);
+ }
+ break;
}
}
-
- rce = m_commandBuffer.renderCommandEncoderWithDescriptor(renderPassDescriptor);
- m_renderCommandEncoder = rce;
- m_renderCommandEncoderFrameBufferHandle = fbh;
- MTL_RELEASE(renderPassDescriptor);
}
- rce.setTriangleFillMode(wireframe ? MTLTriangleFillModeLines : MTLTriangleFillModeFill);
+ MTLSize threadsPerGroup = MTLSizeMake(
+ currentPso->m_numThreads[0]
+ , currentPso->m_numThreads[1]
+ , currentPso->m_numThreads[2]
+ );
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_MTL) )
+ if (isValid(compute.m_indirectBuffer) )
{
- if (item != 1)
+ const VertexBufferMtl& vb = m_vertexBuffers[compute.m_indirectBuffer.idx];
+
+ uint32_t numDrawIndirect = UINT16_MAX == compute.m_numIndirect
+ ? vb.m_size/BGFX_CONFIG_DRAW_INDIRECT_STRIDE
+ : compute.m_numIndirect
+ ;
+
+ uint32_t args = compute.m_startIndirect * BGFX_CONFIG_DRAW_INDIRECT_STRIDE;
+ for (uint32_t ii = 0; ii < numDrawIndirect; ++ii)
{
- rce.popDebugGroup();
+ m_computeCommandEncoder.dispatchThreadgroupsWithIndirectBuffer(
+ vb.m_ptr
+ , args
+ , threadsPerGroup
+ );
+ args += BGFX_CONFIG_DRAW_INDIRECT_STRIDE;
}
-
- rce.pushDebugGroup(s_viewName[view]);
}
-
- MTLViewport vp;
- vp.originX = viewState.m_rect.m_x;
- vp.originY = viewState.m_rect.m_y;
- vp.width = viewState.m_rect.m_width;
- vp.height = viewState.m_rect.m_height;
- vp.znear = 0.0f;
- vp.zfar = 1.0f;
- rce.setViewport(vp);
-
- if (BGFX_CLEAR_NONE != (clr.m_flags & BGFX_CLEAR_MASK)
- && !clearWithRenderPass)
+ else
{
- clearQuad(_clearQuad, viewState.m_rect, clr, _render->m_colorPalette);
+ m_computeCommandEncoder.dispatchThreadgroups(
+ MTLSizeMake(compute.m_numX, compute.m_numY, compute.m_numZ)
+ , threadsPerGroup
+ );
}
+ continue;
}
+
bool resetState = viewChanged || wasCompute;
if (wasCompute)
{
wasCompute = false;
+ currentProgram = BGFX_INVALID_HANDLE;
- programIdx = kInvalidHandle;
- currentProgram = NULL;
-
- //invalidateCompute();
+ setViewType(view, " ");
+ BGFX_MTL_PROFILER_END();
+ BGFX_MTL_PROFILER_BEGIN(view, kColorDraw);
}
const RenderDraw& draw = renderItem.draw;
@@ -3727,7 +4157,7 @@ namespace bgfx { namespace mtl
currentBind.clear();
- programIdx = kInvalidHandle;
+ currentProgram = BGFX_INVALID_HANDLE;
setDepthStencilState(newFlags, packStencil(BGFX_STENCIL_DEFAULT, BGFX_STENCIL_DEFAULT) );
const uint64_t pt = newFlags&BGFX_STATE_PT_MASK;
@@ -3826,12 +4256,11 @@ namespace bgfx { namespace mtl
}
bool programChanged = false;
- bool constantsChanged = draw.m_uniformBegin < draw.m_uniformEnd;
rendererUpdateUniforms(this, _render->m_uniformBuffer[draw.m_uniformIdx], draw.m_uniformBegin, draw.m_uniformEnd);
bool vertexStreamChanged = hasVertexStreamChanged(currentState, draw);
- if (key.m_program != programIdx
+ if (key.m_program.idx != currentProgram.idx
|| vertexStreamChanged
|| (0
| BGFX_STATE_BLEND_MASK
@@ -3844,36 +4273,39 @@ namespace bgfx { namespace mtl
) & changedFlags
|| ( (blendFactor != draw.m_rgba) && !!(newFlags & BGFX_STATE_BLEND_INDEPENDENT) ) )
{
- programIdx = key.m_program;
+ currentProgram = key.m_program;
currentState.m_streamMask = draw.m_streamMask;
currentState.m_instanceDataBuffer.idx = draw.m_instanceDataBuffer.idx;
currentState.m_instanceDataOffset = draw.m_instanceDataOffset;
currentState.m_instanceDataStride = draw.m_instanceDataStride;
- const VertexDecl* decls[BGFX_CONFIG_MAX_VERTEX_STREAMS];
+ const VertexLayout* layouts[BGFX_CONFIG_MAX_VERTEX_STREAMS];
uint32_t numVertices = draw.m_numVertices;
uint8_t numStreams = 0;
- for (uint32_t idx = 0, streamMask = draw.m_streamMask, ntz = bx::uint32_cnttz(streamMask)
+ for (uint32_t idx = 0, streamMask = draw.m_streamMask
; 0 != streamMask
- ; streamMask >>= 1, idx += 1, ntz = bx::uint32_cnttz(streamMask), ++numStreams
+ ; streamMask >>= 1, idx += 1, ++numStreams
)
{
+ const uint32_t ntz = bx::uint32_cnttz(streamMask);
streamMask >>= ntz;
idx += ntz;
- currentState.m_stream[idx].m_decl = draw.m_stream[idx].m_decl;
- currentState.m_stream[idx].m_handle = draw.m_stream[idx].m_handle;
- currentState.m_stream[idx].m_startVertex = draw.m_stream[idx].m_startVertex;
+ currentState.m_stream[idx].m_layoutHandle = draw.m_stream[idx].m_layoutHandle;
+ currentState.m_stream[idx].m_handle = draw.m_stream[idx].m_handle;
+ currentState.m_stream[idx].m_startVertex = draw.m_stream[idx].m_startVertex;
const uint16_t handle = draw.m_stream[idx].m_handle.idx;
const VertexBufferMtl& vb = m_vertexBuffers[handle];
- const uint16_t decl = !isValid(vb.m_decl) ? draw.m_stream[idx].m_decl.idx : vb.m_decl.idx;
- const VertexDecl& vertexDecl = m_vertexDecls[decl];
- const uint32_t stride = vertexDecl.m_stride;
+ const uint16_t decl = isValid(draw.m_stream[idx].m_layoutHandle)
+ ? draw.m_stream[idx].m_layoutHandle.idx
+ : vb.m_layoutHandle.idx;
+ const VertexLayout& layout = m_vertexLayouts[decl];
+ const uint32_t stride = layout.m_stride;
- decls[numStreams] = &vertexDecl;
+ layouts[numStreams] = &layout;
numVertices = bx::uint32_min(UINT32_MAX == draw.m_numVertices
? vb.m_size/stride
@@ -3882,123 +4314,128 @@ namespace bgfx { namespace mtl
);
const uint32_t offset = draw.m_stream[idx].m_startVertex * stride;
- rce.setVertexBuffer(vb.getBuffer(), offset, idx+1);
+ rce.setVertexBuffer(vb.m_ptr, offset, idx+1);
}
currentState.m_numVertices = numVertices;
- if (kInvalidHandle == programIdx)
+ if (!isValid(currentProgram) )
{
- currentProgram = NULL;
continue;
}
else
{
- ProgramMtl& program = m_program[programIdx];
- currentProgram = &program;
-
- RenderPipelineState pso = NULL;
+ currentPso = NULL;
if (0 < numStreams)
{
- pso = getPipelineState(
+ currentPso = getPipelineState(
newFlags
, draw.m_rgba
, fbh
, numStreams
- , decls
- , programIdx
+ , layouts
+ , currentProgram
, draw.m_instanceDataStride/16
);
}
- if (NULL == pso)
+ if (NULL == currentPso)
{
- currentProgram = NULL;
- programIdx = kInvalidHandle;
+ currentProgram = BGFX_INVALID_HANDLE;
continue;
}
- rce.setRenderPipelineState(pso);
+ rce.setRenderPipelineState(currentPso->m_rps);
}
if (isValid(draw.m_instanceDataBuffer) )
{
const VertexBufferMtl& inst = m_vertexBuffers[draw.m_instanceDataBuffer.idx];
- rce.setVertexBuffer(inst.getBuffer(), draw.m_instanceDataOffset, numStreams+1);
+ rce.setVertexBuffer(inst.m_ptr, draw.m_instanceDataOffset, numStreams+1);
}
- programChanged =
- constantsChanged = true;
+ programChanged = true;
}
- if (kInvalidHandle != programIdx)
+ if (isValid(currentProgram) )
{
- ProgramMtl& program = m_program[programIdx];
-
- uint32_t vertexUniformBufferSize = program.m_vshConstantBufferSize;
- uint32_t fragmentUniformBufferSize = program.m_fshConstantBufferSize;
+ const uint32_t vertexUniformBufferSize = currentPso->m_vshConstantBufferSize;
+ const uint32_t fragmentUniformBufferSize = currentPso->m_fshConstantBufferSize;
if (0 != vertexUniformBufferSize)
{
- m_uniformBufferVertexOffset = BX_ALIGN_MASK(m_uniformBufferVertexOffset, program.m_vshConstantBufferAlignmentMask);
+ m_uniformBufferVertexOffset = BX_ALIGN_MASK(m_uniformBufferVertexOffset, currentPso->m_vshConstantBufferAlignmentMask);
rce.setVertexBuffer(m_uniformBuffer, m_uniformBufferVertexOffset, 0);
}
m_uniformBufferFragmentOffset = m_uniformBufferVertexOffset + vertexUniformBufferSize;
if (0 != fragmentUniformBufferSize)
{
- m_uniformBufferFragmentOffset = BX_ALIGN_MASK(m_uniformBufferFragmentOffset, program.m_fshConstantBufferAlignmentMask);
+ m_uniformBufferFragmentOffset = BX_ALIGN_MASK(m_uniformBufferFragmentOffset, currentPso->m_fshConstantBufferAlignmentMask);
rce.setFragmentBuffer(m_uniformBuffer, m_uniformBufferFragmentOffset, 0);
}
- if (constantsChanged)
+ UniformBuffer* vcb = currentPso->m_vshConstantBuffer;
+ if (NULL != vcb)
{
- UniformBuffer* vcb = program.m_vshConstantBuffer;
- if (NULL != vcb)
- {
- commit(*vcb);
- }
-
- UniformBuffer* fcb = program.m_fshConstantBuffer;
- if (NULL != fcb)
- {
- commit(*fcb);
- }
+ commit(*vcb);
+ }
+
+ UniformBuffer* fcb = currentPso->m_fshConstantBuffer;
+ if (NULL != fcb)
+ {
+ commit(*fcb);
}
- viewState.setPredefined<4>(this, view, eye, program, _render, draw);
+ viewState.setPredefined<4>(this, view, *currentPso, _render, draw);
m_uniformBufferFragmentOffset += fragmentUniformBufferSize;
- m_uniformBufferVertexOffset = m_uniformBufferFragmentOffset;
+ m_uniformBufferVertexOffset = m_uniformBufferFragmentOffset;
}
- if (kInvalidHandle != programIdx)
+ if (isValid(currentProgram) )
{
- ProgramMtl& program = m_program[programIdx];
-
- for (uint32_t sampler = 0; sampler < program.m_samplerCount; ++sampler)
+ uint8_t* bindingTypes = currentPso->m_bindingTypes;
+ for (uint8_t stage = 0; stage < maxTextureSamplers; ++stage)
{
- ProgramMtl::SamplerInfo& samplerInfo = program.m_samplers[sampler];
-
- UniformHandle handle = samplerInfo.m_uniform;
- int stage = *((int*)m_uniforms[handle.idx]);
-
const Binding& bind = renderBind.m_bind[stage];
Binding& current = currentBind.m_bind[stage];
-
if (current.m_idx != bind.m_idx
- || current.m_samplerFlags != bind.m_samplerFlags
- || programChanged)
+ || current.m_type != bind.m_type
+ || current.m_samplerFlags != bind.m_samplerFlags
+ || programChanged)
{
if (kInvalidHandle != bind.m_idx)
{
- TextureMtl& texture = m_textures[bind.m_idx];
- texture.commit(samplerInfo.m_index
- , !samplerInfo.m_fragment
- , samplerInfo.m_fragment
- , bind.m_samplerFlags
- );
+ switch (bind.m_type)
+ {
+ case Binding::Texture:
+ {
+ TextureMtl& texture = m_textures[bind.m_idx];
+ texture.commit(stage
+ , 0 != (bindingTypes[stage] & PipelineStateMtl::BindToVertexShader)
+ , 0 != (bindingTypes[stage] & PipelineStateMtl::BindToFragmentShader)
+ , bind.m_samplerFlags
+ );
+ }
+ break;
+
+ case Binding::IndexBuffer:
+ case Binding::VertexBuffer:
+ {
+ const BufferMtl& buffer = Binding::IndexBuffer == bind.m_type
+ ? m_indexBuffers[bind.m_idx]
+ : m_vertexBuffers[bind.m_idx]
+ ;
+
+ if (0 != (bindingTypes[stage] & PipelineStateMtl::BindToVertexShader))
+ rce.setVertexBuffer(buffer.m_ptr, 0, stage + 1);
+ if (0 != (bindingTypes[stage] & PipelineStateMtl::BindToFragmentShader))
+ rce.setFragmentBuffer(buffer.m_ptr, 0, stage + 1);
+ }
+ break;
+ }
}
}
@@ -4012,9 +4449,9 @@ namespace bgfx { namespace mtl
if (UINT32_MAX == numVertices)
{
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;
+ uint16_t decl = !isValid(vb.m_layoutHandle) ? draw.m_stream[0].m_layoutHandle.idx : vb.m_layoutHandle.idx;
+ const VertexLayout& layout = m_vertexLayouts[decl];
+ numVertices = vb.m_size/layout.m_stride;
}
uint32_t numIndices = 0;
@@ -4030,6 +4467,34 @@ namespace bgfx { namespace mtl
if (isValid(draw.m_indirectBuffer) )
{
+ const VertexBufferMtl& vb = m_vertexBuffers[draw.m_indirectBuffer.idx];
+
+ if (isValid(draw.m_indexBuffer) )
+ {
+ const IndexBufferMtl& ib = m_indexBuffers[draw.m_indexBuffer.idx];
+ MTLIndexType indexType = 0 == (ib.m_flags & BGFX_BUFFER_INDEX32) ? MTLIndexTypeUInt16 : MTLIndexTypeUInt32;
+
+ numDrawIndirect = UINT16_MAX == draw.m_numIndirect
+ ? vb.m_size/BGFX_CONFIG_DRAW_INDIRECT_STRIDE
+ : draw.m_numIndirect
+ ;
+
+ for (uint32_t ii = 0; ii < numDrawIndirect; ++ii)
+ {
+ rce.drawIndexedPrimitives(prim.m_type,indexType, ib.m_ptr, 0, vb.m_ptr, (draw.m_startIndirect + ii )* BGFX_CONFIG_DRAW_INDIRECT_STRIDE);
+ }
+ }
+ else
+ {
+ numDrawIndirect = UINT16_MAX == draw.m_numIndirect
+ ? vb.m_size/BGFX_CONFIG_DRAW_INDIRECT_STRIDE
+ : draw.m_numIndirect
+ ;
+ for (uint32_t ii = 0; ii < numDrawIndirect; ++ii)
+ {
+ rce.drawPrimitives(prim.m_type,vb.m_ptr, (draw.m_startIndirect + ii) * BGFX_CONFIG_DRAW_INDIRECT_STRIDE);
+ }
+ }
}
else
{
@@ -4046,7 +4511,7 @@ namespace bgfx { namespace mtl
numInstances = draw.m_numInstances;
numPrimsRendered = numPrimsSubmitted*draw.m_numInstances;
- rce.drawIndexedPrimitives(prim.m_type, numIndices, indexType, ib.getBuffer(), 0, draw.m_numInstances);
+ rce.drawIndexedPrimitives(prim.m_type, numIndices, indexType, ib.m_ptr, 0, draw.m_numInstances);
}
else if (prim.m_min <= draw.m_numIndices)
{
@@ -4056,7 +4521,7 @@ namespace bgfx { namespace mtl
numInstances = draw.m_numInstances;
numPrimsRendered = numPrimsSubmitted*draw.m_numInstances;
- rce.drawIndexedPrimitives(prim.m_type, numIndices, indexType, ib.getBuffer(), draw.m_startIndex * indexSize,numInstances);
+ rce.drawIndexedPrimitives(prim.m_type, numIndices, indexType, ib.m_ptr, draw.m_startIndex * indexSize,numInstances);
}
}
else
@@ -4065,7 +4530,7 @@ namespace bgfx { namespace mtl
numInstances = draw.m_numInstances;
numPrimsRendered = numPrimsSubmitted*draw.m_numInstances;
- rce.drawPrimitives(prim.m_type, 0, draw.m_numVertices, draw.m_numInstances);
+ rce.drawPrimitives(prim.m_type, 0, numVertices, draw.m_numInstances);
}
}
@@ -4084,7 +4549,11 @@ namespace bgfx { namespace mtl
if (wasCompute)
{
- //invalidateCompute();
+ invalidateCompute();
+
+ setViewType(view, "C");
+ BGFX_MTL_PROFILER_END();
+ BGFX_MTL_PROFILER_BEGIN(view, kColorCompute);
}
submitBlit(bs, BGFX_CONFIG_MAX_VIEWS);
@@ -4095,10 +4564,12 @@ namespace bgfx { namespace mtl
capture();
rce = m_renderCommandEncoder;
captureElapsed += bx::getHPCounter();
+
+ profiler.end();
}
}
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_MTL) )
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
{
if (0 < _render->m_numRenderItems)
{
@@ -4106,6 +4577,8 @@ namespace bgfx { namespace mtl
}
}
+ BGFX_MTL_PROFILER_END();
+
int64_t timeEnd = bx::getHPCounter();
int64_t frameTime = timeEnd - timeBegin;
@@ -4241,18 +4714,19 @@ namespace bgfx { namespace mtl
rce.popDebugGroup();
}
- rce.endEncoding();
- m_renderCommandEncoder = 0;
+ endEncoding();
m_renderCommandEncoderFrameBufferHandle.idx = kInvalidHandle;
if (m_screenshotTarget)
{
RenderPassDescriptor renderPassDescriptor = newRenderPassDescriptor();
- renderPassDescriptor.colorAttachments[0].texture = m_mainFrameBuffer.m_swapChain->currentDrawable().texture;
+ renderPassDescriptor.colorAttachments[0].texture = m_mainFrameBuffer.m_swapChain->currentDrawableTexture();
renderPassDescriptor.colorAttachments[0].storeAction = MTLStoreActionStore;
rce = m_commandBuffer.renderCommandEncoderWithDescriptor(renderPassDescriptor);
+ MTL_RELEASE(renderPassDescriptor);
+
rce.setCullMode(MTLCullModeNone);
rce.setRenderPipelineState(m_screenshotBlitRenderPipelineState);
diff --git a/3rdparty/bgfx/src/renderer_noop.cpp b/3rdparty/bgfx/src/renderer_noop.cpp
index c4977464ff8..b71223c53ec 100644
--- a/3rdparty/bgfx/src/renderer_noop.cpp
+++ b/3rdparty/bgfx/src/renderer_noop.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -100,15 +100,15 @@ namespace bgfx { namespace noop
{
}
- void createVertexDecl(VertexDeclHandle /*_handle*/, const VertexDecl& /*_decl*/) override
+ void createVertexLayout(VertexLayoutHandle /*_handle*/, const VertexLayout& /*_layout*/) override
{
}
- void destroyVertexDecl(VertexDeclHandle /*_handle*/) override
+ void destroyVertexLayout(VertexLayoutHandle /*_handle*/) override
{
}
- void createVertexBuffer(VertexBufferHandle /*_handle*/, const Memory* /*_mem*/, VertexDeclHandle /*_declHandle*/, uint16_t /*_flags*/) override
+ void createVertexBuffer(VertexBufferHandle /*_handle*/, const Memory* /*_mem*/, VertexLayoutHandle /*_layoutHandle*/, uint16_t /*_flags*/) override
{
}
@@ -226,15 +226,15 @@ namespace bgfx { namespace noop
{
}
- void setMarker(const char* /*_marker*/, uint32_t /*_size*/) override
+ void invalidateOcclusionQuery(OcclusionQueryHandle /*_handle*/) override
{
}
- void invalidateOcclusionQuery(OcclusionQueryHandle /*_handle*/) override
+ void setMarker(const char* /*_marker*/, uint16_t /*_len*/) override
{
}
- virtual void setName(Handle /*_handle*/, const char* /*_name*/) override
+ virtual void setName(Handle /*_handle*/, const char* /*_name*/, uint16_t /*_len*/) override
{
}
diff --git a/3rdparty/bgfx/src/renderer_nvn.cpp b/3rdparty/bgfx/src/renderer_nvn.cpp
new file mode 100644
index 00000000000..11a96818354
--- /dev/null
+++ b/3rdparty/bgfx/src/renderer_nvn.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011-2019 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, _nvn); \
+ extern const uint32_t BX_CONCATENATE(_name, _nvn_size); \
+ static const uint8_t BX_CONCATENATE(_name, _int_nvn)[] = { 0 }; \
+ const uint8_t* BX_CONCATENATE(_name, _nvn) = &BX_CONCATENATE(_name, _int_nvn)[0]; \
+ const uint32_t BX_CONCATENATE(_name, _nvn_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 nvn
+{
+ RendererContextI* rendererCreate(const Init& _init)
+ {
+ BX_UNUSED(_init);
+ return NULL;
+ }
+
+ void rendererDestroy()
+ {
+ }
+} /* namespace nvn */ } // namespace bgfx
diff --git a/3rdparty/bgfx/src/renderer_vk.cpp b/3rdparty/bgfx/src/renderer_vk.cpp
index b3843e03047..ca8a2413e1a 100644
--- a/3rdparty/bgfx/src/renderer_vk.cpp
+++ b/3rdparty/bgfx/src/renderer_vk.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -8,6 +8,13 @@
#if BGFX_CONFIG_RENDERER_VULKAN
# include "renderer_vk.h"
+#if BX_PLATFORM_OSX
+# import <Cocoa/Cocoa.h>
+# import <Foundation/Foundation.h>
+# import <QuartzCore/QuartzCore.h>
+# import <Metal/Metal.h>
+#endif // BX_PLATFORM_OSX
+
namespace bgfx { namespace vk
{
static char s_viewName[BGFX_CONFIG_MAX_VIEWS][256];
@@ -224,6 +231,67 @@ VK_IMPORT_DEVICE
};
BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_textureFormat) );
+ struct Extension
+ {
+ enum Enum
+ {
+ EXT_debug_utils,
+ EXT_debug_report,
+ EXT_memory_budget,
+ KHR_get_physical_device_properties2,
+
+ Count
+ };
+
+ const char* m_name;
+ uint32_t m_minVersion;
+ bool m_instanceExt;
+ bool m_supported;
+ bool m_initialize;
+ };
+
+ // Extension registry
+ //
+ static Extension s_extension[] =
+ {
+ { "VK_EXT_debug_utils", 1, false, false, BGFX_CONFIG_DEBUG_OBJECT_NAME },
+ { "VK_EXT_debug_report", 1, false, false, BGFX_CONFIG_DEBUG },
+ { "VK_EXT_memory_budget", 1, false, false, true },
+ { "VK_KHR_get_physical_device_properties2", 1, false, false, true },
+ };
+ BX_STATIC_ASSERT(Extension::Count == BX_COUNTOF(s_extension) );
+
+ void updateExtension(const char* _name, uint32_t _version, bool _instanceExt)
+ {
+ bx::StringView ext(_name);
+
+ bool supported = false;
+ for (uint32_t ii = 0; ii < Extension::Count; ++ii)
+ {
+ Extension& extension = s_extension[ii];
+ if (!extension.m_supported
+ && extension.m_initialize)
+ {
+ if ( 0 == bx::strCmp(ext, extension.m_name)
+ && _version >= extension.m_minVersion)
+ {
+ extension.m_supported = true;
+ extension.m_instanceExt = _instanceExt;
+ supported = true;
+ break;
+ }
+ }
+ }
+
+ BX_TRACE("\tv%-3d %s%s"
+ , _version
+ , _name
+ , supported ? " (supported)" : "", _name
+ );
+
+ BX_UNUSED(supported);
+ }
+
static const VkFormat s_attribType[][4][2] =
{
{ // Uint8
@@ -259,48 +327,83 @@ VK_IMPORT_DEVICE
};
BX_STATIC_ASSERT(AttribType::Count == BX_COUNTOF(s_attribType) );
- uint32_t fillVertexDecl(const ShaderVK* _vsh, VkPipelineVertexInputStateCreateInfo& _vertexInputState, const VertexDecl& _decl)
+ void fillVertexLayout(const ShaderVK* _vsh, VkPipelineVertexInputStateCreateInfo& _vertexInputState, const VertexLayout& _layout)
{
- VkVertexInputBindingDescription* inputBinding = const_cast<VkVertexInputBindingDescription*>(_vertexInputState.pVertexBindingDescriptions);
- VkVertexInputAttributeDescription* inputAttrib = const_cast<VkVertexInputAttributeDescription*>(_vertexInputState.pVertexAttributeDescriptions);
+ uint32_t numBindings = _vertexInputState.vertexBindingDescriptionCount;
+ uint32_t numAttribs = _vertexInputState.vertexAttributeDescriptionCount;
+ VkVertexInputBindingDescription* inputBinding = const_cast<VkVertexInputBindingDescription*>(_vertexInputState.pVertexBindingDescriptions + numBindings);
+ VkVertexInputAttributeDescription* inputAttrib = const_cast<VkVertexInputAttributeDescription*>(_vertexInputState.pVertexAttributeDescriptions + numAttribs);
- inputBinding->binding = 0;
- inputBinding->stride = _decl.m_stride;
+ inputBinding->binding = numBindings;
+ inputBinding->stride = _layout.m_stride;
inputBinding->inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
- _vertexInputState.vertexBindingDescriptionCount = 1;
- uint32_t numAttribs = 0;
for (uint32_t attr = 0; attr < Attrib::Count; ++attr)
{
- if (UINT16_MAX != _decl.m_attributes[attr])
+ if (UINT16_MAX != _layout.m_attributes[attr])
{
inputAttrib->location = _vsh->m_attrRemap[attr];
- inputAttrib->binding = 0;
+ inputAttrib->binding = numBindings;
- if (0 == _decl.m_attributes[attr])
- {
- inputAttrib->format = VK_FORMAT_R32G32B32_SFLOAT;
- inputAttrib->offset = 0;
- }
- else
- {
- uint8_t num;
- AttribType::Enum type;
- bool normalized;
- bool asInt;
- _decl.decode(Attrib::Enum(attr), num, type, normalized, asInt);
- inputAttrib->format = s_attribType[type][num-1][normalized];
- inputAttrib->offset = _decl.m_offset[attr];
- }
+ uint8_t num;
+ AttribType::Enum type;
+ bool normalized;
+ bool asInt;
+ _layout.decode(Attrib::Enum(attr), num, type, normalized, asInt);
+ inputAttrib->format = s_attribType[type][num-1][normalized];
+ inputAttrib->offset = _layout.m_offset[attr];
++inputAttrib;
++numAttribs;
}
}
+ _vertexInputState.vertexBindingDescriptionCount = numBindings + 1;
_vertexInputState.vertexAttributeDescriptionCount = numAttribs;
+ }
+
+ void fillInstanceBinding(const ShaderVK* _vsh, VkPipelineVertexInputStateCreateInfo& _vertexInputState, uint32_t _numInstanceData)
+ {
+ BX_UNUSED(_vsh);
+
+ uint32_t numBindings = _vertexInputState.vertexBindingDescriptionCount;
+ uint32_t numAttribs = _vertexInputState.vertexAttributeDescriptionCount;
+ VkVertexInputBindingDescription* inputBinding = const_cast<VkVertexInputBindingDescription*>(_vertexInputState.pVertexBindingDescriptions + numBindings);
+ VkVertexInputAttributeDescription* inputAttrib = const_cast<VkVertexInputAttributeDescription*>(_vertexInputState.pVertexAttributeDescriptions + numAttribs);
+
+ inputBinding->binding = numBindings;
+ inputBinding->stride = _numInstanceData * 16;
+ inputBinding->inputRate = VK_VERTEX_INPUT_RATE_INSTANCE;
+
+ for (uint32_t inst = 0; inst < _numInstanceData; ++inst)
+ {
+ inputAttrib->location = numAttribs;
+ inputAttrib->binding = numBindings;
+ inputAttrib->format = VK_FORMAT_R32G32B32A32_SFLOAT;
+ inputAttrib->offset = inst * 16;
+
+ ++numAttribs;
+ ++inputAttrib;
+ }
- return numAttribs;
+ _vertexInputState.vertexBindingDescriptionCount = numBindings + 1;
+ _vertexInputState.vertexAttributeDescriptionCount = numAttribs;
+ }
+
+ static const char* s_deviceTypeName[] =
+ {
+ "Other",
+ "Integrated GPU",
+ "Discrete GPU",
+ "Virtual GPU",
+ "CPU",
+
+ "Unknown?!"
+ };
+
+ const char* getName(VkPhysicalDeviceType _type)
+ {
+ return s_deviceTypeName[bx::min<int32_t>(_type, BX_COUNTOF(s_deviceTypeName) )];
}
static const char* s_allocScopeName[] =
@@ -357,6 +460,27 @@ VK_IMPORT_DEVICE
internalFreeNotification,
};
+ VkResult VKAPI_PTR stubSetDebugUtilsObjectNameEXT(VkDevice _device, const VkDebugUtilsObjectNameInfoEXT* _nameInfo)
+ {
+ BX_UNUSED(_device, _nameInfo);
+ return VK_SUCCESS;
+ }
+
+ void VKAPI_PTR stubCmdInsertDebugUtilsLabelEXT(VkCommandBuffer _commandBuffer, const VkDebugUtilsLabelEXT* _labelInfo)
+ {
+ BX_UNUSED(_commandBuffer, _labelInfo);
+ }
+
+ void VKAPI_PTR stubCmdBeginDebugUtilsLabelEXT(VkCommandBuffer _commandBuffer, const VkDebugUtilsLabelEXT* _labelInfo)
+ {
+ BX_UNUSED(_commandBuffer, _labelInfo);
+ }
+
+ void VKAPI_PTR stubCmdEndDebugUtilsLabelEXT(VkCommandBuffer _commandBuffer)
+ {
+ BX_UNUSED(_commandBuffer);
+ }
+
static const char* s_debugReportObjectType[] =
{
"Unknown",
@@ -411,6 +535,12 @@ VK_IMPORT_DEVICE
, _userData
, s_debugReportObjectType
);
+ if (!bx::strFind(_message, "PointSizeMissing").isEmpty()
+ || !bx::strFind(_message, "SwapchainTooManyImages").isEmpty()
+ || !bx::strFind(_message, "SwapchainImageNotAcquired").isEmpty())
+ {
+ return VK_FALSE;
+ }
BX_TRACE("%c%c%c%c%c %19s, %s, %d: %s"
, 0 != (_flags & VK_DEBUG_REPORT_INFORMATION_BIT_EXT ) ? 'I' : '-'
, 0 != (_flags & VK_DEBUG_REPORT_WARNING_BIT_EXT ) ? 'W' : '-'
@@ -455,22 +585,23 @@ VK_IMPORT_DEVICE
&& 0 < numExtensionProperties)
{
VkExtensionProperties extensionProperties[64];
- numExtensionProperties = bx::uint32_min(numExtensionProperties, BX_COUNTOF(extensionProperties) );
+ numExtensionProperties = bx::min<uint32_t>(numExtensionProperties, BX_COUNTOF(extensionProperties) );
result = enumerateExtensionProperties(_physicalDevice
, NULL
, &numExtensionProperties
, extensionProperties
);
- BX_TRACE("\tGlobal extensions (%d):"
+ BX_TRACE("Global extensions (%d):"
, numExtensionProperties
);
for (uint32_t extension = 0; extension < numExtensionProperties; ++extension)
{
- BX_TRACE("\t\t%s (s: 0x%08x)"
- , extensionProperties[extension].extensionName
+ updateExtension(
+ extensionProperties[extension].extensionName
, extensionProperties[extension].specVersion
+ , VK_NULL_HANDLE == _physicalDevice
);
}
}
@@ -484,10 +615,10 @@ VK_IMPORT_DEVICE
&& 0 < numLayerProperties)
{
VkLayerProperties layerProperties[64];
- numLayerProperties = bx::uint32_min(numLayerProperties, BX_COUNTOF(layerProperties) );
+ numLayerProperties = bx::min<uint32_t>(numLayerProperties, BX_COUNTOF(layerProperties) );
result = enumerateLayerProperties(_physicalDevice, &numLayerProperties, layerProperties);
- char indent = VK_NULL_HANDLE == _physicalDevice ? ' ' : '\t';
+ char indent = VK_NULL_HANDLE == _physicalDevice ? '\0' : '\t';
BX_UNUSED(indent);
BX_TRACE("%cLayer extensions (%d):"
@@ -514,7 +645,7 @@ VK_IMPORT_DEVICE
&& 0 < numExtensionProperties)
{
VkExtensionProperties extensionProperties[64];
- numExtensionProperties = bx::uint32_min(numExtensionProperties, BX_COUNTOF(extensionProperties) );
+ numExtensionProperties = bx::min<uint32_t>(numExtensionProperties, BX_COUNTOF(extensionProperties) );
result = enumerateExtensionProperties(_physicalDevice
, layerProperties[layer].layerName
, &numExtensionProperties
@@ -570,7 +701,36 @@ VK_IMPORT_DEVICE
return "<VkResult?>";
}
- void setImageMemoryBarrier(VkCommandBuffer _commandBuffer, VkImage _image, VkImageLayout _oldLayout, VkImageLayout _newLayout)
+ template<typename Ty>
+ VkObjectType getType();
+
+ template<> VkObjectType getType<VkBuffer >() { return VK_OBJECT_TYPE_BUFFER; }
+ template<> VkObjectType getType<VkShaderModule>() { return VK_OBJECT_TYPE_SHADER_MODULE; }
+
+ template<typename Ty>
+ static BX_NO_INLINE void setDebugObjectName(VkDevice _device, Ty _object, const char* _format, ...)
+ {
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_OBJECT_NAME) && s_extension[Extension::EXT_debug_utils].m_supported)
+ {
+ char temp[2048];
+ va_list argList;
+ va_start(argList, _format);
+ int32_t size = bx::min<int32_t>(sizeof(temp)-1, bx::vsnprintf(temp, sizeof(temp), _format, argList) );
+ va_end(argList);
+ temp[size] = '\0';
+
+ VkDebugUtilsObjectNameInfoEXT ni;
+ ni.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
+ ni.pNext = NULL;
+ ni.objectType = getType<Ty>();
+ ni.objectHandle = uint64_t(_object.vk);
+ ni.pObjectName = temp;
+
+ VK_CHECK(vkSetDebugUtilsObjectNameEXT(_device, &ni) );
+ }
+ }
+
+ void setImageMemoryBarrier(VkCommandBuffer _commandBuffer, VkImage _image, VkImageAspectFlags _aspectMask, VkImageLayout _oldLayout, VkImageLayout _newLayout, uint32_t _levelCount, uint32_t _layerCount)
{
BX_CHECK(true
&& _newLayout != VK_IMAGE_LAYOUT_UNDEFINED
@@ -580,7 +740,6 @@ VK_IMPORT_DEVICE
VkAccessFlags srcAccessMask = 0;
VkAccessFlags dstAccessMask = 0;
- VkImageAspectFlags aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
switch (_oldLayout)
{
@@ -639,7 +798,7 @@ VK_IMPORT_DEVICE
case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
dstAccessMask |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
- aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
+ // aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
break;
case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL:
@@ -678,11 +837,11 @@ VK_IMPORT_DEVICE
imb.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
imb.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
imb.image = _image;
- imb.subresourceRange.aspectMask = aspectMask;
+ imb.subresourceRange.aspectMask = _aspectMask;
imb.subresourceRange.baseMipLevel = 0;
- imb.subresourceRange.levelCount = 1;
+ imb.subresourceRange.levelCount = _levelCount;
imb.subresourceRange.baseArrayLayer = 0;
- imb.subresourceRange.layerCount = 1;
+ imb.subresourceRange.layerCount = _layerCount;
vkCmdPipelineBarrier(_commandBuffer
, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT
, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT
@@ -712,6 +871,231 @@ VK_IMPORT_DEVICE
{
}
+ VkResult createSwapchain()
+ {
+ VkResult result = VK_SUCCESS;
+ result = vkCreateSwapchainKHR(m_device, &m_sci, m_allocatorCb, &m_swapchain);
+ if (VK_SUCCESS != result)
+ {
+ BX_TRACE("Create swapchain error: vkCreateSwapchainKHR failed %d: %s.", result, getName(result));
+ return result;
+ }
+
+ result = vkGetSwapchainImagesKHR(m_device, m_swapchain, &m_numSwapchainImages, NULL);
+ if (VK_SUCCESS != result)
+ {
+ BX_TRACE("Create swapchain error: vkGetSwapchainImagesKHR failed %d: %s.", result, getName(result));
+ return result;
+ }
+
+ if (m_numSwapchainImages < m_sci.minImageCount)
+ {
+ BX_TRACE("Create swapchain error: vkGetSwapchainImagesKHR: numSwapchainImages %d < minImageCount %d."
+ , m_numSwapchainImages
+ , m_sci.minImageCount
+ );
+ return VK_ERROR_INITIALIZATION_FAILED;
+ }
+
+ result = vkGetSwapchainImagesKHR(m_device, m_swapchain, &m_numSwapchainImages, &m_backBufferColorImage[0]);
+ if (VK_SUCCESS != result && VK_INCOMPLETE != result)
+ {
+ BX_TRACE("Create swapchain error: vkGetSwapchainImagesKHR failed %d: %s.", result, getName(result));
+ return result;
+ }
+
+ VkImageCreateInfo ici;
+ ici.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
+ ici.pNext = NULL;
+ ici.flags = 0;
+ ici.imageType = VK_IMAGE_TYPE_2D;
+ ici.format = m_backBufferDepthStencilFormat;
+ ici.extent.width = m_sci.imageExtent.width;
+ ici.extent.height = m_sci.imageExtent.height;
+ ici.extent.depth = 1;
+ ici.mipLevels = 1;
+ ici.arrayLayers = 1;
+ ici.samples = VK_SAMPLE_COUNT_1_BIT;
+ ici.tiling = VK_IMAGE_TILING_OPTIMAL;
+ ici.usage = 0
+ | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
+ | VK_IMAGE_USAGE_TRANSFER_SRC_BIT
+ ;
+ ici.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
+ ici.queueFamilyIndexCount = 0; //m_sci.queueFamilyIndexCount;
+ ici.pQueueFamilyIndices = NULL; //m_sci.pQueueFamilyIndices;
+ ici.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
+ result = vkCreateImage(m_device, &ici, m_allocatorCb, &m_backBufferDepthStencilImage);
+
+ if (VK_SUCCESS != result)
+ {
+ BX_TRACE("Create swapchain error: vkCreateImage failed %d: %s.", result, getName(result));
+ return result;
+ }
+
+ VkMemoryRequirements mr;
+ vkGetImageMemoryRequirements(m_device, m_backBufferDepthStencilImage, &mr);
+
+ VkMemoryAllocateInfo ma;
+ ma.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
+ ma.pNext = NULL;
+ ma.allocationSize = mr.size;
+ ma.memoryTypeIndex = selectMemoryType(mr.memoryTypeBits
+ , VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
+ );
+ result = vkAllocateMemory(m_device
+ , &ma
+ , m_allocatorCb
+ , &m_backBufferDepthStencilMemory
+ );
+
+ if (VK_SUCCESS != result)
+ {
+ BX_TRACE("Create swapchain error: vkAllocateMemory failed %d: %s.", result, getName(result));
+ return result;
+ }
+
+ result = vkBindImageMemory(m_device, m_backBufferDepthStencilImage, m_backBufferDepthStencilMemory, 0);
+
+ if (VK_SUCCESS != result)
+ {
+ BX_TRACE("Create swapchain error: vkBindImageMemory failed %d: %s.", result, getName(result));
+ return result;
+ }
+
+ VkImageViewCreateInfo ivci;
+ ivci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
+ ivci.pNext = NULL;
+ ivci.flags = 0;
+ ivci.image = m_backBufferDepthStencilImage;
+ ivci.viewType = VK_IMAGE_VIEW_TYPE_2D;
+ ivci.format = m_backBufferDepthStencilFormat;
+ ivci.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
+ ivci.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
+ ivci.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
+ ivci.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
+ ivci.subresourceRange.aspectMask = 0
+ | VK_IMAGE_ASPECT_DEPTH_BIT
+ | VK_IMAGE_ASPECT_STENCIL_BIT
+ ;
+ ivci.subresourceRange.baseMipLevel = 0;
+ ivci.subresourceRange.levelCount = 1;
+ ivci.subresourceRange.baseArrayLayer = 0;
+ ivci.subresourceRange.layerCount = 1;
+ result = vkCreateImageView(m_device, &ivci, m_allocatorCb, &m_backBufferDepthStencilImageView);
+
+ if (VK_SUCCESS != result)
+ {
+ BX_TRACE("Create swapchain error: vkCreateImageView failed %d: %s.", result, getName(result));
+ return result;
+ }
+
+ for (uint32_t ii = 0; ii < m_numSwapchainImages; ++ii)
+ {
+ ivci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
+ ivci.pNext = NULL;
+ ivci.flags = 0;
+ ivci.image = m_backBufferColorImage[ii];
+ ivci.viewType = VK_IMAGE_VIEW_TYPE_2D;
+ ivci.format = m_sci.imageFormat;
+ ivci.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
+ ivci.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
+ ivci.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
+ ivci.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
+ ivci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+ ivci.subresourceRange.baseMipLevel = 0;
+ ivci.subresourceRange.levelCount = 1;
+ ivci.subresourceRange.baseArrayLayer = 0;
+ ivci.subresourceRange.layerCount = 1;
+
+ result = vkCreateImageView(m_device, &ivci, m_allocatorCb, &m_backBufferColorImageView[ii]);
+
+ if (VK_SUCCESS != result)
+ {
+ BX_TRACE("Create swapchain error: vkCreateImageView failed %d: %s.", result, getName(result));
+ return result;
+ }
+
+ m_backBufferColorImageLayout[ii] = VK_IMAGE_LAYOUT_UNDEFINED;
+ }
+
+ m_needToRefreshSwapchain = false;
+
+ return result;
+ }
+
+ void releaseSwapchain()
+ {
+ VK_CHECK(vkDeviceWaitIdle(m_device) );
+ vkFreeMemory(m_device, m_backBufferDepthStencilMemory, m_allocatorCb);
+ vkDestroy(m_backBufferDepthStencilImageView);
+ vkDestroy(m_backBufferDepthStencilImage);
+ for (uint32_t ii = 0; ii < BX_COUNTOF(m_backBufferColorImageView); ++ii)
+ {
+ vkDestroy(m_backBufferColorImageView[ii]);
+ m_backBufferColorImageLayout[ii] = VK_IMAGE_LAYOUT_UNDEFINED;
+ }
+ vkDestroy(m_swapchain);
+ }
+
+ VkResult createSwapchainFramebuffer()
+ {
+ VkResult result = VK_SUCCESS;
+ for (uint32_t ii = 0; ii < m_numSwapchainImages; ++ii)
+ {
+ ::VkImageView attachments[] =
+ {
+ m_backBufferColorImageView[ii],
+ m_backBufferDepthStencilImageView,
+ };
+
+ VkFramebufferCreateInfo fci;
+ fci.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
+ fci.pNext = NULL;
+ fci.flags = 0;
+ fci.renderPass = m_renderPass;
+ fci.attachmentCount = BX_COUNTOF(attachments);
+ fci.pAttachments = attachments;
+ fci.width = m_sci.imageExtent.width;
+ fci.height = m_sci.imageExtent.height;
+ fci.layers = 1;
+
+ result = vkCreateFramebuffer(m_device, &fci, m_allocatorCb, &m_backBufferColor[ii]);
+
+ if (VK_SUCCESS != result)
+ {
+ return result;
+ }
+ }
+ return result;
+ }
+
+ void releaseSwapchainFramebuffer()
+ {
+ for (uint32_t ii = 0; ii < BX_COUNTOF(m_backBufferColorImageView); ++ii)
+ {
+ vkDestroy(m_backBufferColor[ii]);
+ }
+ }
+
+ void initSwapchainImageLayout()
+ {
+ VkCommandBuffer commandBuffer = beginNewCommand();
+
+ setImageMemoryBarrier(
+ commandBuffer
+ , m_backBufferDepthStencilImage
+ , VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT
+ , VK_IMAGE_LAYOUT_UNDEFINED
+ , VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
+ , 1
+ , 1
+ );
+
+ m_backBufferColorIdx = 0;
+ submitCommandAndWait(commandBuffer);
+ }
+
bool init(const Init& _init)
{
BX_UNUSED(s_checkMsaa, s_textureAddress);
@@ -724,9 +1108,10 @@ VK_IMPORT_DEVICE
LoadedVulkan1,
InstanceCreated,
DeviceCreated,
- RenderPassCreated,
SurfaceCreated,
SwapchainCreated,
+ RenderPassCreated,
+ FrameBufferCreated,
CommandBuffersCreated,
DescriptorCreated,
};
@@ -754,6 +1139,8 @@ VK_IMPORT_DEVICE
"vulkan-1.dll"
#elif BX_PLATFORM_ANDROID
"libvulkan.so"
+#elif BX_PLATFORM_OSX
+ "libvulkan.dylib"
#else
"libvulkan.so.1"
#endif // BX_PLATFORM_*
@@ -799,9 +1186,10 @@ VK_IMPORT
// "VK_LAYER_GOOGLE_threading",
// "VK_LAYER_GOOGLE_unique_objects",
// "VK_LAYER_LUNARG_device_limits",
-// "VK_LAYER_LUNARG_standard_validation",
+ "VK_LAYER_LUNARG_standard_validation",
// "VK_LAYER_LUNARG_image",
// "VK_LAYER_LUNARG_mem_tracker",
+// "VK_LAYER_LUNARG_core_validation",
// "VK_LAYER_LUNARG_object_tracker",
// "VK_LAYER_LUNARG_parameter_validation",
// "VK_LAYER_LUNARG_swapchain",
@@ -811,16 +1199,27 @@ VK_IMPORT
/*not used*/ ""
};
- const char* enabledExtension[] =
+ uint32_t numEnabledExtensions = 2;
+
+ const char* enabledExtension[Extension::Count + 2] =
{
VK_KHR_SURFACE_EXTENSION_NAME,
KHR_SURFACE_EXTENSION_NAME,
-#if BGFX_CONFIG_DEBUG
- VK_EXT_DEBUG_REPORT_EXTENSION_NAME,
-#endif // BGFX_CONFIG_DEBUG
- /*not used*/ ""
};
+ for (uint32_t ii = 0; ii < Extension::Count; ++ii)
+ {
+ const Extension& extension = s_extension[ii];
+
+ if (extension.m_supported
+ && extension.m_initialize
+ && extension.m_instanceExt)
+ {
+ enabledExtension[numEnabledExtensions++] = extension.m_name;
+ BX_TRACE("%d: %s", numEnabledExtensions, extension.m_name);
+ }
+ }
+
VkInstanceCreateInfo ici;
ici.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
ici.pNext = NULL;
@@ -828,7 +1227,7 @@ VK_IMPORT
ici.pApplicationInfo = &appInfo;
ici.enabledLayerCount = BX_COUNTOF(enabledLayerNames) - 1;
ici.ppEnabledLayerNames = enabledLayerNames;
- ici.enabledExtensionCount = BX_COUNTOF(enabledExtension) - 1;
+ ici.enabledExtensionCount = numEnabledExtensions;
ici.ppEnabledExtensionNames = enabledExtension;
if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
@@ -868,7 +1267,7 @@ VK_IMPORT_INSTANCE
m_debugReportCallback = VK_NULL_HANDLE;
- if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
+ if (s_extension[Extension::EXT_debug_report].m_supported)
{
VkDebugReportCallbackCreateInfoEXT drcb;
drcb.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
@@ -903,7 +1302,7 @@ VK_IMPORT_INSTANCE
}
VkPhysicalDevice physicalDevices[4];
- numPhysicalDevices = bx::uint32_min(numPhysicalDevices, BX_COUNTOF(physicalDevices) );
+ numPhysicalDevices = bx::min<uint32_t>(numPhysicalDevices, BX_COUNTOF(physicalDevices) );
result = vkEnumeratePhysicalDevices(m_instance
, &numPhysicalDevices
, physicalDevices
@@ -977,14 +1376,29 @@ VK_IMPORT_INSTANCE
g_caps.vendorId = uint16_t(m_deviceProperties.vendorID);
g_caps.deviceId = uint16_t(m_deviceProperties.deviceID);
+ g_caps.supported |= ( 0
+ | BGFX_CAPS_ALPHA_TO_COVERAGE
+ | BGFX_CAPS_BLEND_INDEPENDENT
+ | BGFX_CAPS_COMPUTE
+ | BGFX_CAPS_DRAW_INDIRECT
+ | BGFX_CAPS_FRAGMENT_DEPTH
+ | BGFX_CAPS_INSTANCING
+ | BGFX_CAPS_TEXTURE_3D
+ | BGFX_CAPS_TEXTURE_BLIT
+ | BGFX_CAPS_TEXTURE_COMPARE_ALL
+ | BGFX_CAPS_VERTEX_ATTRIB_HALF
+ | BGFX_CAPS_VERTEX_ATTRIB_UINT10
+ | BGFX_CAPS_VERTEX_ID
+ );
g_caps.limits.maxTextureSize = m_deviceProperties.limits.maxImageDimension2D;
- g_caps.limits.maxFBAttachments = uint8_t(bx::uint32_min(m_deviceProperties.limits.maxFragmentOutputAttachments, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS) );
+ g_caps.limits.maxFBAttachments = bx::min(uint8_t(m_deviceProperties.limits.maxFragmentOutputAttachments), uint8_t(BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS) );
g_caps.limits.maxComputeBindings = BGFX_MAX_COMPUTE_BINDINGS;
+ g_caps.limits.maxVertexStreams = BGFX_CONFIG_MAX_VERTEX_STREAMS;
- {
-// VkFormatProperties fp;
-// vkGetPhysicalDeviceFormatProperties(m_physicalDevice, fmt, &fp);
+ vkGetPhysicalDeviceFeatures(m_physicalDevice, &m_deviceFeatures);
+ m_deviceFeatures.robustBufferAccess = VK_FALSE;
+ {
struct ImageTest
{
VkImageType type;
@@ -999,11 +1413,12 @@ VK_IMPORT_INSTANCE
{ VK_IMAGE_TYPE_3D, VK_IMAGE_USAGE_SAMPLED_BIT, 0, { BGFX_CAPS_FORMAT_TEXTURE_3D, BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB } },
{ VK_IMAGE_TYPE_2D, VK_IMAGE_USAGE_SAMPLED_BIT, VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, { BGFX_CAPS_FORMAT_TEXTURE_CUBE, BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB } },
{ VK_IMAGE_TYPE_2D, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, 0, { BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER, BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER } },
+ { VK_IMAGE_TYPE_2D, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, 0, { BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER, BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER } },
};
for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii)
{
- uint8_t support = BGFX_CAPS_FORMAT_TEXTURE_NONE;
+ uint16_t support = BGFX_CAPS_FORMAT_TEXTURE_NONE;
const bool depth = bimg::isDepth(bimg::TextureFormat::Enum(ii) );
VkFormat fmt = depth
@@ -1059,8 +1474,8 @@ VK_IMPORT_INSTANCE
, NULL
);
- VkQueueFamilyProperties queueFamilyPropertices[10] = {};
- queueFamilyPropertyCount = bx::uint32_min(queueFamilyPropertyCount, BX_COUNTOF(queueFamilyPropertices) );
+ VkQueueFamilyProperties queueFamilyPropertices[10];
+ queueFamilyPropertyCount = bx::min<uint32_t>(queueFamilyPropertyCount, BX_COUNTOF(queueFamilyPropertices) );
vkGetPhysicalDeviceQueueFamilyProperties(m_physicalDevice
, &queueFamilyPropertyCount
, queueFamilyPropertices
@@ -1110,6 +1525,11 @@ VK_IMPORT_INSTANCE
}
}
+ if (m_qfiCompute != UINT32_MAX)
+ {
+ g_caps.supported |= BGFX_CAPS_COMPUTE;
+ }
+
{
const char* enabledLayerNames[] =
{
@@ -1128,13 +1548,26 @@ VK_IMPORT_INSTANCE
/*not used*/ ""
};
- const char* enabledExtension[] =
+ uint32_t numEnabledExtensions = 1;
+
+ const char* enabledExtension[Extension::Count + 1] =
{
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
-// "VK_LUNARG_DEBUG_MARKER",
- /*not used*/ ""
};
+ for (uint32_t ii = 0; ii < Extension::Count; ++ii)
+ {
+ const Extension& extension = s_extension[ii];
+
+ if (extension.m_supported
+ && extension.m_initialize
+ && !extension.m_instanceExt)
+ {
+ enabledExtension[numEnabledExtensions++] = extension.m_name;
+ BX_TRACE("%d: %s", numEnabledExtensions, extension.m_name);
+ }
+ }
+
float queuePriorities[1] = { 0.0f };
VkDeviceQueueCreateInfo dcqi;
dcqi.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
@@ -1152,15 +1585,16 @@ VK_IMPORT_INSTANCE
dci.pQueueCreateInfos = &dcqi;
dci.enabledLayerCount = BX_COUNTOF(enabledLayerNames) - 1;
dci.ppEnabledLayerNames = enabledLayerNames;
- dci.enabledExtensionCount = BX_COUNTOF(enabledExtension) - 1;
+ dci.enabledExtensionCount = numEnabledExtensions;
dci.ppEnabledExtensionNames = enabledExtension;
- dci.pEnabledFeatures = NULL;
+ dci.pEnabledFeatures = &m_deviceFeatures;
- result = vkCreateDevice(m_physicalDevice
- , &dci
- , m_allocatorCb
- , &m_device
- );
+ result = vkCreateDevice(
+ m_physicalDevice
+ , &dci
+ , m_allocatorCb
+ , &m_device
+ );
if (VK_SUCCESS != result)
{
@@ -1172,9 +1606,9 @@ VK_IMPORT_INSTANCE
errorState = ErrorState::DeviceCreated;
BX_TRACE("Device functions:");
-#define VK_IMPORT_DEVICE_FUNC(_optional, _func) \
+#define VK_IMPORT_DEVICE_FUNC(_optional, _func) \
_func = (PFN_##_func)vkGetDeviceProcAddr(m_device, #_func); \
- BX_TRACE("\t%p " #_func, _func); \
+ BX_TRACE("\t%p " #_func, _func); \
imported &= _optional || NULL != _func
VK_IMPORT_DEVICE
#undef VK_IMPORT_DEVICE_FUNC
@@ -1188,80 +1622,6 @@ VK_IMPORT_DEVICE
vkGetDeviceQueue(m_device, m_qfiGraphics, 0, &m_queueGraphics);
vkGetDeviceQueue(m_device, m_qfiCompute, 0, &m_queueCompute);
- m_backBufferDepthStencilFormat =
- VK_FORMAT_D32_SFLOAT_S8_UINT
-// VK_FORMAT_D24_UNORM_S8_UINT
- ;
-
- {
- m_sci.imageFormat = VK_FORMAT_B8G8R8A8_UNORM;
-
- VkAttachmentDescription ad[2];
- ad[0].flags = 0;
- ad[0].format = m_sci.imageFormat;
- ad[0].samples = VK_SAMPLE_COUNT_1_BIT;
- ad[0].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
- ad[0].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
- ad[0].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
- ad[0].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
- ad[0].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
- ad[0].finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
- ad[1].flags = 0;
- ad[1].format = m_backBufferDepthStencilFormat;
- ad[1].samples = VK_SAMPLE_COUNT_1_BIT;
- ad[1].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
- ad[1].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
- ad[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
- ad[1].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
- ad[1].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
- ad[1].finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
-
- VkAttachmentReference colorAr[1];
- colorAr[0].attachment = 0;
- colorAr[0].layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
-
- VkAttachmentReference resolveAr[1];
- resolveAr[0].attachment = VK_ATTACHMENT_UNUSED;
- resolveAr[0].layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
-
- VkAttachmentReference depthAr[1];
- depthAr[0].attachment = 1;
- depthAr[0].layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
-
- VkSubpassDescription sd[1];
- sd[0].flags = 0;
- sd[0].pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
- sd[0].inputAttachmentCount = 0;
- sd[0].pInputAttachments = NULL;
- sd[0].colorAttachmentCount = BX_COUNTOF(colorAr);
- sd[0].pColorAttachments = colorAr;
- sd[0].pResolveAttachments = resolveAr;
- sd[0].pDepthStencilAttachment = depthAr;
- sd[0].preserveAttachmentCount = 0;
- sd[0].pPreserveAttachments = NULL;
-
- VkRenderPassCreateInfo rpi;
- rpi.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
- rpi.pNext = NULL;
- rpi.flags = 0;
- rpi.attachmentCount = BX_COUNTOF(ad);
- rpi.pAttachments = ad;
- rpi.subpassCount = BX_COUNTOF(sd);
- rpi.pSubpasses = sd;
- rpi.dependencyCount = 0;
- rpi.pDependencies = NULL;
-
- result = vkCreateRenderPass(m_device, &rpi, m_allocatorCb, &m_renderPass);
-
- if (VK_SUCCESS != result)
- {
- BX_TRACE("Init error: vkCreateRenderPass failed %d: %s.", result, getName(result) );
- goto error;
- }
- }
-
- errorState = ErrorState::RenderPassCreated;
-
#if BX_PLATFORM_WINDOWS
{
VkWin32SurfaceCreateInfoKHR sci;
@@ -1278,6 +1638,7 @@ VK_IMPORT_DEVICE
sci.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
sci.pNext = NULL;
sci.flags = 0;
+ sci.window = (ANativeWindow*)g_platformData.nwh;
result = vkCreateAndroidSurfaceKHR(m_instance, &sci, m_allocatorCb, &m_surface);
}
#elif BX_PLATFORM_LINUX
@@ -1318,6 +1679,26 @@ VK_IMPORT_DEVICE
}
}
}
+#elif BX_PLATFORM_OSX
+ {
+ if (NULL != vkCreateMacOSSurfaceMVK)
+ {
+ NSWindow* window = (NSWindow*)(g_platformData.nwh);
+ NSView* contentView = (NSView*)window.contentView;
+ CAMetalLayer* layer = [CAMetalLayer layer];
+ if (_init.resolution.reset & BGFX_RESET_HIDPI)
+ layer.contentsScale = [window backingScaleFactor];
+ [contentView setWantsLayer : YES] ;
+ [contentView setLayer : layer] ;
+
+ VkMacOSSurfaceCreateInfoMVK sci;
+ sci.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
+ sci.pNext = NULL;
+ sci.flags = 0;
+ sci.pView = (__bridge void*)layer;
+ result = vkCreateMacOSSurfaceMVK(m_instance, &sci, m_allocatorCb, &m_surface);
+ }
+ }
#else
# error "Figure out KHR surface..."
#endif // BX_PLATFORM_
@@ -1349,6 +1730,17 @@ VK_IMPORT_DEVICE
goto error;
}
+ uint32_t width = bx::clamp<uint32_t>(
+ _init.resolution.width
+ , surfaceCapabilities.minImageExtent.width
+ , surfaceCapabilities.maxImageExtent.width
+ );
+ uint32_t height = bx::clamp<uint32_t>(
+ _init.resolution.height
+ , surfaceCapabilities.minImageExtent.height
+ , surfaceCapabilities.maxImageExtent.height
+ );
+
uint32_t numSurfaceFormats;
result = vkGetPhysicalDeviceSurfaceFormatsKHR(m_physicalDevice, m_surface, &numSurfaceFormats, NULL);
@@ -1359,11 +1751,40 @@ VK_IMPORT_DEVICE
}
VkSurfaceFormatKHR surfaceFormats[10];
- numSurfaceFormats = bx::uint32_min(numSurfaceFormats, BX_COUNTOF(surfaceFormats) );
+ numSurfaceFormats = bx::min<uint32_t>(numSurfaceFormats, BX_COUNTOF(surfaceFormats) );
vkGetPhysicalDeviceSurfaceFormatsKHR(m_physicalDevice, m_surface, &numSurfaceFormats, surfaceFormats);
// find the best match...
- uint32_t surfaceFormatIdx = 0;
+ VkFormat preferredSurfaceFormat[4] =
+ {
+ VK_FORMAT_R8G8B8A8_UNORM,
+ VK_FORMAT_B8G8R8A8_UNORM,
+ VK_FORMAT_R8G8B8A8_SRGB,
+ VK_FORMAT_B8G8R8A8_SRGB,
+ };
+
+ uint32_t surfaceFormatIdx = numSurfaceFormats;
+
+ for (uint32_t jj = 0; jj < BX_COUNTOF(preferredSurfaceFormat); jj++)
+ {
+ for (uint32_t ii = 0; ii < numSurfaceFormats; ii++)
+ {
+ BX_TRACE("Supported surface format: %d", surfaceFormats[ii].format);
+ if (preferredSurfaceFormat[jj] == surfaceFormats[ii].format)
+ {
+ surfaceFormatIdx = ii;
+ break;
+ }
+ }
+
+ if (surfaceFormatIdx < numSurfaceFormats)
+ { // found
+ BX_TRACE("Preferred surface format found: %d", surfaceFormats[surfaceFormatIdx].format);
+ break;
+ }
+ }
+
+ BX_CHECK(surfaceFormatIdx < numSurfaceFormats, "cannot found preferred surface format from supported surface format");
uint32_t numPresentModes;
result = vkGetPhysicalDeviceSurfacePresentModesKHR(m_physicalDevice, m_surface, &numPresentModes, NULL);
@@ -1374,228 +1795,190 @@ VK_IMPORT_DEVICE
}
VkPresentModeKHR presentModes[10];
- numPresentModes = bx::uint32_min(numPresentModes, BX_COUNTOF(presentModes) );
+ numPresentModes = bx::min<uint32_t>(numPresentModes, BX_COUNTOF(presentModes) );
vkGetPhysicalDeviceSurfacePresentModesKHR(m_physicalDevice, m_surface, &numPresentModes, presentModes);
// find the best match...
- uint32_t presentModeIdx = 0;
+ uint32_t presentModeIdx = numPresentModes;
+ VkPresentModeKHR preferredPresentMode[] = {
+ VK_PRESENT_MODE_FIFO_KHR,
+ VK_PRESENT_MODE_FIFO_RELAXED_KHR,
+ VK_PRESENT_MODE_MAILBOX_KHR,
+ VK_PRESENT_MODE_IMMEDIATE_KHR,
+ };
+ for (uint32_t ii = 0; ii < BX_COUNTOF(preferredPresentMode); ++ii)
+ {
+ for (uint32_t jj = 0; jj < numPresentModes; ++jj)
+ {
+ if (presentModes[jj] == preferredPresentMode[ii])
+ {
+ presentModeIdx = jj;
+ BX_TRACE("present mode: %d", (int)preferredPresentMode[ii]);
+ break;
+ }
+ }
+ if (presentModeIdx < numPresentModes)
+ {
+ break;
+ }
+ }
+ if (presentModeIdx == numPresentModes)
+ {
+ presentModeIdx = 0;
+ }
+
+ m_backBufferDepthStencilFormat = 0 != (g_caps.formats[TextureFormat::D24S8] & BGFX_CAPS_FORMAT_TEXTURE_2D)
+ ? VK_FORMAT_D24_UNORM_S8_UINT
+ : VK_FORMAT_D32_SFLOAT_S8_UINT
+ ;
+
+ VkCompositeAlphaFlagBitsKHR compositeAlpha = (VkCompositeAlphaFlagBitsKHR)0;
+ if (surfaceCapabilities.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR)
+ {
+ compositeAlpha = VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR;
+ }
+ else if (surfaceCapabilities.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR)
+ {
+ compositeAlpha = VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR;
+ }
+ else if (surfaceCapabilities.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR)
+ {
+ compositeAlpha = VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR;
+ }
+ else if (surfaceCapabilities.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR)
+ {
+ compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
+ }
m_sci.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
m_sci.pNext = NULL;
m_sci.flags = 0;
m_sci.surface = m_surface;
- m_sci.minImageCount = BX_COUNTOF(m_backBufferColorImage);
+ m_sci.minImageCount = 2;
m_sci.imageFormat = surfaceFormats[surfaceFormatIdx].format;
m_sci.imageColorSpace = surfaceFormats[surfaceFormatIdx].colorSpace;
- m_sci.imageExtent.width = _init.resolution.width;
- m_sci.imageExtent.height = _init.resolution.height;
+ m_sci.imageExtent.width = width;
+ m_sci.imageExtent.height = height;
m_sci.imageArrayLayers = 1;
m_sci.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
m_sci.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
m_sci.queueFamilyIndexCount = 0;
m_sci.pQueueFamilyIndices = NULL;
m_sci.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
- m_sci.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
+ m_sci.compositeAlpha = compositeAlpha;
m_sci.presentMode = presentModes[presentModeIdx];
m_sci.clipped = VK_TRUE;
m_sci.oldSwapchain = VK_NULL_HANDLE;
- result = vkCreateSwapchainKHR(m_device, &m_sci, m_allocatorCb, &m_swapchain);
-
- if (VK_SUCCESS != result)
- {
- BX_TRACE("Init error: vkCreateSwapchainKHR failed %d: %s.", result, getName(result) );
- goto error;
- }
-
- uint32_t numSwapchainImages;
- result = vkGetSwapchainImagesKHR(m_device, m_swapchain, &numSwapchainImages, NULL);
-
- if (VK_SUCCESS != result)
- {
- BX_TRACE("Init error: vkGetSwapchainImagesKHR failed %d: %s.", result, getName(result) );
- goto error;
- }
-
- if (numSwapchainImages < m_sci.minImageCount)
- {
- BX_TRACE("Init error: vkGetSwapchainImagesKHR: numSwapchainImages %d, minImageCount %d."
- , numSwapchainImages
- , m_sci.minImageCount
- );
- goto error;
- }
-
- numSwapchainImages = m_sci.minImageCount;
- result = vkGetSwapchainImagesKHR(m_device, m_swapchain, &numSwapchainImages, &m_backBufferColorImage[0]);
-
- if (VK_SUCCESS != result)
- {
- BX_TRACE("Init error: vkGetSwapchainImagesKHR failed %d: %s.", result, getName(result) );
- goto error;
- }
for (uint32_t ii = 0; ii < BX_COUNTOF(m_backBufferColorImageView); ++ii)
{
m_backBufferColorImageView[ii] = VK_NULL_HANDLE;
+ m_backBufferColorImage[ii] = VK_NULL_HANDLE;
m_backBufferColor[ii] = VK_NULL_HANDLE;
+ m_presentDone[ii] = VK_NULL_HANDLE;
}
- VkImageCreateInfo ici;
- ici.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
- ici.pNext = NULL;
- ici.flags = 0;
- ici.imageType = VK_IMAGE_TYPE_2D;
- ici.format = m_backBufferDepthStencilFormat;
- ici.extent.width = m_sci.imageExtent.width;
- ici.extent.height = m_sci.imageExtent.height;
- ici.extent.depth = 1;
- ici.mipLevels = 1;
- ici.arrayLayers = 1;
- ici.samples = VK_SAMPLE_COUNT_1_BIT;
- ici.tiling = VK_IMAGE_TILING_OPTIMAL;
- ici.usage = 0
- | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
- | VK_IMAGE_USAGE_TRANSFER_SRC_BIT
- ;
- ici.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
- ici.queueFamilyIndexCount = 0; //m_sci.queueFamilyIndexCount;
- ici.pQueueFamilyIndices = NULL; //m_sci.pQueueFamilyIndices;
- ici.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
- result = vkCreateImage(m_device, &ici, m_allocatorCb, &m_backBufferDepthStencilImage);
-
+ result = createSwapchain();
if (VK_SUCCESS != result)
{
- BX_TRACE("Init error: vkCreateImage failed %d: %s.", result, getName(result) );
+ BX_TRACE("Init error: creating swapchain and image view failed %d: %s", result, getName(result));
goto error;
}
- VkMemoryRequirements mr;
- vkGetImageMemoryRequirements(m_device, m_backBufferDepthStencilImage, &mr);
-
- VkMemoryAllocateInfo ma;
- ma.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
- ma.pNext = NULL;
- ma.allocationSize = mr.size;
- ma.memoryTypeIndex = selectMemoryType(mr.memoryTypeBits
- , VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
- );
- result = vkAllocateMemory(m_device
- , &ma
- , m_allocatorCb
- , &m_backBufferDepthStencilMemory
- );
-
- if (VK_SUCCESS != result)
- {
- BX_TRACE("Init error: vkAllocateMemory failed %d: %s.", result, getName(result) );
- goto error;
- }
-
- result = vkBindImageMemory(m_device, m_backBufferDepthStencilImage, m_backBufferDepthStencilMemory, 0);
-
- if (VK_SUCCESS != result)
- {
- BX_TRACE("Init error: vkBindImageMemory failed %d: %s.", result, getName(result) );
- goto error;
- }
-
- VkImageViewCreateInfo ivci;
- ivci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
- ivci.pNext = NULL;
- ivci.flags = 0;
- ivci.image = m_backBufferDepthStencilImage;
- ivci.viewType = VK_IMAGE_VIEW_TYPE_2D;
- ivci.format = m_backBufferDepthStencilFormat;
- ivci.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
- ivci.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
- ivci.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
- ivci.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
- ivci.subresourceRange.aspectMask = 0
- | VK_IMAGE_ASPECT_DEPTH_BIT
- | VK_IMAGE_ASPECT_STENCIL_BIT
- ;
- ivci.subresourceRange.baseMipLevel = 0;
- ivci.subresourceRange.levelCount = 1;
- ivci.subresourceRange.baseArrayLayer = 0;
- ivci.subresourceRange.layerCount = 1;
- result = vkCreateImageView(m_device, &ivci, m_allocatorCb, &m_backBufferDepthStencilImageView);
-
- if (VK_SUCCESS != result)
- {
- BX_TRACE("Init error: vkCreateImageView failed %d: %s.", result, getName(result) );
- goto error;
- }
-
- ::VkImageView attachments[] =
- {
- VK_NULL_HANDLE,
- m_backBufferDepthStencilImageView,
- };
-
- VkFramebufferCreateInfo fci;
- fci.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
- fci.pNext = NULL;
- fci.flags = 0;
- fci.renderPass = m_renderPass;
- fci.attachmentCount = BX_COUNTOF(attachments);
- fci.pAttachments = attachments;
- fci.width = m_sci.imageExtent.width;
- fci.height = m_sci.imageExtent.height;
- fci.layers = 1;
-
VkSemaphoreCreateInfo sci;
sci.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
sci.pNext = NULL;
sci.flags = 0;
- for (uint32_t ii = 0; ii < numSwapchainImages; ++ii)
+ for (uint32_t ii = 0; ii < m_numSwapchainImages; ++ii)
{
- ivci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
- ivci.pNext = NULL;
- ivci.flags = 0;
- ivci.image = m_backBufferColorImage[ii];
- ivci.viewType = VK_IMAGE_VIEW_TYPE_2D;
- ivci.format = m_sci.imageFormat;
- ivci.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
- ivci.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
- ivci.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
- ivci.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
- ivci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
- ivci.subresourceRange.baseMipLevel = 0;
- ivci.subresourceRange.levelCount = 1;
- ivci.subresourceRange.baseArrayLayer = 0;
- ivci.subresourceRange.layerCount = 1;
-
- result = vkCreateImageView(m_device, &ivci, m_allocatorCb, &m_backBufferColorImageView[ii]);
-
+ result = vkCreateSemaphore(m_device, &sci, m_allocatorCb, &m_presentDone[ii]);
if (VK_SUCCESS != result)
{
- BX_TRACE("Init error: vkCreateImageView failed %d: %s.", result, getName(result) );
+ BX_TRACE("Init error: vkCreateSemaphore failed %d: %s.", result, getName(result) );
goto error;
}
+ }
+ }
+
+ errorState = ErrorState::SwapchainCreated;
- attachments[0] = m_backBufferColorImageView[ii];
- result = vkCreateFramebuffer(m_device, &fci, m_allocatorCb, &m_backBufferColor[ii]);
+ {
+ VkAttachmentDescription ad[2];
+ ad[0].flags = 0;
+ ad[0].format = m_sci.imageFormat;
+ ad[0].samples = VK_SAMPLE_COUNT_1_BIT;
+ ad[0].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
+ ad[0].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
+ ad[0].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
+ ad[0].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
+ ad[0].initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
+ ad[0].finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
+ ad[1].flags = 0;
+ ad[1].format = m_backBufferDepthStencilFormat;
+ ad[1].samples = VK_SAMPLE_COUNT_1_BIT;
+ ad[1].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
+ ad[1].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
+ ad[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
+ ad[1].stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
+ ad[1].initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
+ ad[1].finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
- if (VK_SUCCESS != result)
- {
- BX_TRACE("Init error: vkCreateFramebuffer failed %d: %s.", result, getName(result) );
- goto error;
- }
+ VkAttachmentReference colorAr[1];
+ colorAr[0].attachment = 0;
+ colorAr[0].layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
- result = vkCreateSemaphore(m_device, &sci, m_allocatorCb, &m_presentDone[ii]);
+ VkAttachmentReference resolveAr[1];
+ resolveAr[0].attachment = VK_ATTACHMENT_UNUSED;
+ resolveAr[0].layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
- if (VK_SUCCESS != result)
- {
- BX_TRACE("Init error: vkCreateSemaphore failed %d: %s.", result, getName(result) );
- goto error;
- }
+ VkAttachmentReference depthAr[1];
+ depthAr[0].attachment = 1;
+ depthAr[0].layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
- sci.flags = 0;
+ VkSubpassDescription sd[1];
+ sd[0].flags = 0;
+ sd[0].pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
+ sd[0].inputAttachmentCount = 0;
+ sd[0].pInputAttachments = NULL;
+ sd[0].colorAttachmentCount = BX_COUNTOF(colorAr);
+ sd[0].pColorAttachments = colorAr;
+ sd[0].pResolveAttachments = resolveAr;
+ sd[0].pDepthStencilAttachment = depthAr;
+ sd[0].preserveAttachmentCount = 0;
+ sd[0].pPreserveAttachments = NULL;
+
+ VkRenderPassCreateInfo rpi;
+ rpi.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
+ rpi.pNext = NULL;
+ rpi.flags = 0;
+ rpi.attachmentCount = BX_COUNTOF(ad);
+ rpi.pAttachments = ad;
+ rpi.subpassCount = BX_COUNTOF(sd);
+ rpi.pSubpasses = sd;
+ rpi.dependencyCount = 0;
+ rpi.pDependencies = NULL;
+
+ result = vkCreateRenderPass(m_device, &rpi, m_allocatorCb, &m_renderPass);
+
+ if (VK_SUCCESS != result)
+ {
+ BX_TRACE("Init error: vkCreateRenderPass failed %d: %s.", result, getName(result));
+ goto error;
}
}
- errorState = ErrorState::SwapchainCreated;
+ errorState = ErrorState::RenderPassCreated;
+
+ // framebuffer creation
+ result = createSwapchainFramebuffer();
+ if (VK_SUCCESS != result)
+ {
+ BX_TRACE("Init error: vkCreateFramebuffer failed %d: %s.", result, getName(result));
+ goto error;
+ }
+
+ errorState = ErrorState::FrameBufferCreated;
{
VkFenceCreateInfo fci;
@@ -1641,55 +2024,10 @@ VK_IMPORT_DEVICE
goto error;
}
- VkCommandBufferBeginInfo cbbi;
- cbbi.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
- cbbi.pNext = NULL;
- cbbi.flags = 0;
- cbbi.pInheritanceInfo = NULL;
-
- VkCommandBuffer commandBuffer = m_commandBuffers[0];
- VK_CHECK(vkBeginCommandBuffer(commandBuffer, &cbbi) );
-
- VkRenderPassBeginInfo rpbi;
- rpbi.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- rpbi.pNext = NULL;
- rpbi.renderPass = m_renderPass;
- rpbi.renderArea.offset.x = 0;
- rpbi.renderArea.offset.y = 0;
- rpbi.renderArea.extent = m_sci.imageExtent;
- rpbi.clearValueCount = 0;
- rpbi.pClearValues = NULL;
-
- setImageMemoryBarrier(commandBuffer
- , m_backBufferDepthStencilImage
- , VK_IMAGE_LAYOUT_UNDEFINED
- , VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
- );
-
- for (uint32_t ii = 0; ii < BX_COUNTOF(m_backBufferColorImage); ++ii)
- {
- setImageMemoryBarrier(commandBuffer
- , m_backBufferColorImage[ii]
- , VK_IMAGE_LAYOUT_UNDEFINED
- , VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
- );
-
- rpbi.framebuffer = m_backBufferColor[ii];
- vkCmdBeginRenderPass(commandBuffer, &rpbi, VK_SUBPASS_CONTENTS_INLINE);
- vkCmdEndRenderPass(commandBuffer);
-
- setImageMemoryBarrier(commandBuffer
- , m_backBufferColorImage[ii]
- , VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
- , VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
- );
- }
-
- VK_CHECK(vkEndCommandBuffer(commandBuffer) );
- m_backBufferColorIdx = 0;
+ initSwapchainImageLayout();
- kick();
- finishAll();
+// kick();
+// finishAll();
VK_CHECK(vkResetCommandPool(m_device, m_commandPool, 0) );
}
@@ -1699,17 +2037,21 @@ VK_IMPORT_DEVICE
{
VkDescriptorPoolSize dps[] =
{
-// { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS },
- { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 10<<10 },
-// { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS },
+// { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, (10 * BGFX_CONFIG_MAX_TEXTURE_SAMPLERS) << 10 },
+ { VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, (10 * BGFX_CONFIG_MAX_TEXTURE_SAMPLERS) << 10 },
+ { VK_DESCRIPTOR_TYPE_SAMPLER, (10 * BGFX_CONFIG_MAX_TEXTURE_SAMPLERS) << 10 },
+ { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 10<<10 },
+ { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS << 10 },
+ { VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS << 10 },
};
- VkDescriptorSetLayoutBinding dslb[] =
- {
-// { DslBinding::CombinedImageSampler, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, VK_SHADER_STAGE_ALL, NULL },
- { DslBinding::UniformBuffer, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_ALL, NULL },
-// { DslBinding::StorageBuffer, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, VK_SHADER_STAGE_ALL, NULL },
- };
+// VkDescriptorSetLayoutBinding dslb[] =
+// {
+// // { DslBinding::CombinedImageSampler, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, VK_SHADER_STAGE_ALL, NULL },
+// { DslBinding::VertexUniformBuffer, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_ALL, NULL },
+// { DslBinding::FragmentUniformBuffer, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, NULL },
+// // { DslBinding::StorageBuffer, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, VK_SHADER_STAGE_ALL, NULL },
+// };
VkDescriptorPoolCreateInfo dpci;
dpci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
@@ -1727,35 +2069,35 @@ VK_IMPORT_DEVICE
goto error;
}
- VkDescriptorSetLayoutCreateInfo dsl;
- dsl.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
- dsl.pNext = NULL;
- dsl.flags = 0;
- dsl.bindingCount = BX_COUNTOF(dslb);
- dsl.pBindings = dslb;
- result = vkCreateDescriptorSetLayout(m_device, &dsl, m_allocatorCb, &m_descriptorSetLayout);
-
- if (VK_SUCCESS != result)
- {
- BX_TRACE("Init error: vkCreateDescriptorSetLayout failed %d: %s.", result, getName(result) );
- goto error;
- }
-
- VkPipelineLayoutCreateInfo pl;
- pl.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
- pl.pNext = NULL;
- pl.flags = 0;
- pl.setLayoutCount = 1;
- pl.pSetLayouts = &m_descriptorSetLayout;
- pl.pushConstantRangeCount = 0;
- pl.pPushConstantRanges = NULL;
- result = vkCreatePipelineLayout(m_device, &pl, m_allocatorCb, &m_pipelineLayout);
-
- if (VK_SUCCESS != result)
- {
- BX_TRACE("Init error: vkCreatePipelineLayout failed %d: %s.", result, getName(result) );
- goto error;
- }
+// VkDescriptorSetLayoutCreateInfo dsl;
+// dsl.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
+// dsl.pNext = NULL;
+// dsl.flags = 0;
+// dsl.bindingCount = BX_COUNTOF(dslb);
+// dsl.pBindings = dslb;
+// result = vkCreateDescriptorSetLayout(m_device, &dsl, m_allocatorCb, &m_descriptorSetLayout);
+//
+// if (VK_SUCCESS != result)
+// {
+// BX_TRACE("Init error: vkCreateDescriptorSetLayout failed %d: %s.", result, getName(result) );
+// goto error;
+// }
+//
+// VkPipelineLayoutCreateInfo pl;
+// pl.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
+// pl.pNext = NULL;
+// pl.flags = 0;
+// pl.setLayoutCount = 1;
+// pl.pSetLayouts = &m_descriptorSetLayout;
+// pl.pushConstantRangeCount = 0;
+// pl.pPushConstantRanges = NULL;
+// result = vkCreatePipelineLayout(m_device, &pl, m_allocatorCb, &m_pipelineLayout);
+//
+// if (VK_SUCCESS != result)
+// {
+// BX_TRACE("Init error: vkCreatePipelineLayout failed %d: %s.", result, getName(result) );
+// goto error;
+// }
VkPipelineCacheCreateInfo pcci;
pcci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO;
@@ -1774,13 +2116,36 @@ VK_IMPORT_DEVICE
for (uint32_t ii = 0; ii < BX_COUNTOF(m_scratchBuffer); ++ii)
{
- m_scratchBuffer[ii].create(BGFX_CONFIG_MAX_DRAW_CALLS*1024
- , 1024 //BGFX_CONFIG_MAX_TEXTURES + BGFX_CONFIG_MAX_SHADERS + BGFX_CONFIG_MAX_DRAW_CALLS
- );
+ BX_TRACE("Create scratch buffer %d", ii);
+ m_scratchBuffer[ii].create(BGFX_CONFIG_MAX_DRAW_CALLS * 128, 1024);
}
errorState = ErrorState::DescriptorCreated;
+ if (NULL == vkSetDebugUtilsObjectNameEXT)
+ {
+ vkSetDebugUtilsObjectNameEXT = stubSetDebugUtilsObjectNameEXT;
+ }
+
+ if (NULL == vkCmdBeginDebugUtilsLabelEXT
+ || NULL == vkCmdEndDebugUtilsLabelEXT)
+ {
+ vkCmdBeginDebugUtilsLabelEXT = stubCmdBeginDebugUtilsLabelEXT;
+ vkCmdEndDebugUtilsLabelEXT = stubCmdEndDebugUtilsLabelEXT;
+ }
+
+ if (NULL == vkCmdInsertDebugUtilsLabelEXT)
+ {
+ vkCmdInsertDebugUtilsLabelEXT = stubCmdInsertDebugUtilsLabelEXT;
+ }
+
+ // Init reserved part of view name.
+ for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_VIEWS; ++ii)
+ {
+ bx::snprintf(s_viewName[ii], BGFX_CONFIG_MAX_VIEW_NAME_RESERVED+1, "%3d ", ii);
+ }
+
+ g_internalData.context = m_device;
return true;
error:
@@ -1789,8 +2154,8 @@ VK_IMPORT_DEVICE
{
case ErrorState::DescriptorCreated:
vkDestroy(m_pipelineCache);
- vkDestroy(m_pipelineLayout);
- vkDestroy(m_descriptorSetLayout);
+// vkDestroy(m_pipelineLayout);
+// vkDestroy(m_descriptorSetLayout);
vkDestroy(m_descriptorPool);
BX_FALLTHROUGH;
@@ -1800,35 +2165,26 @@ VK_IMPORT_DEVICE
vkDestroy(m_fence);
BX_FALLTHROUGH;
+ case ErrorState::FrameBufferCreated:
+ releaseSwapchainFramebuffer();
+ BX_FALLTHROUGH;
+
+ case ErrorState::RenderPassCreated:
+ vkDestroy(m_renderPass);
+ BX_FALLTHROUGH;
+
case ErrorState::SwapchainCreated:
for (uint32_t ii = 0; ii < BX_COUNTOF(m_backBufferColorImageView); ++ii)
{
- if (VK_NULL_HANDLE != m_backBufferColorImageView[ii])
- {
- vkDestroy(m_backBufferColorImageView[ii]);
- }
-
- if (VK_NULL_HANDLE != m_backBufferColor[ii])
- {
- vkDestroy(m_backBufferColor[ii]);
- }
-
- if (VK_NULL_HANDLE != m_presentDone[ii])
- {
- vkDestroy(m_presentDone[ii]);
- }
+ vkDestroy(m_presentDone[ii]);
}
- vkDestroy(m_swapchain);
+ releaseSwapchain();
BX_FALLTHROUGH;
case ErrorState::SurfaceCreated:
vkDestroySurfaceKHR(m_instance, m_surface, m_allocatorCb);
BX_FALLTHROUGH;
- case ErrorState::RenderPassCreated:
- vkDestroy(m_renderPass);
- BX_FALLTHROUGH;
-
case ErrorState::DeviceCreated:
vkDestroyDevice(m_device, m_allocatorCb);
BX_FALLTHROUGH;
@@ -1863,6 +2219,9 @@ VK_IMPORT_DEVICE
VK_CHECK(vkDeviceWaitIdle(m_device) );
m_pipelineStateCache.invalidate();
+ m_descriptorSetLayoutCache.invalidate();
+ m_renderPassCache.invalidate();
+ m_samplerCache.invalidate();
for (uint32_t ii = 0; ii < BX_COUNTOF(m_scratchBuffer); ++ii)
{
@@ -1895,8 +2254,8 @@ VK_IMPORT_DEVICE
}
vkDestroy(m_pipelineCache);
- vkDestroy(m_pipelineLayout);
- vkDestroy(m_descriptorSetLayout);
+// vkDestroy(m_pipelineLayout);
+// vkDestroy(m_descriptorSetLayout);
vkDestroy(m_descriptorPool);
vkFreeCommandBuffers(m_device, m_commandPool, BX_COUNTOF(m_commandBuffers), m_commandBuffers);
@@ -1905,26 +2264,10 @@ VK_IMPORT_DEVICE
for (uint32_t ii = 0; ii < BX_COUNTOF(m_backBufferColorImageView); ++ii)
{
- if (VK_NULL_HANDLE != m_backBufferColorImageView[ii])
- {
- vkDestroy(m_backBufferColorImageView[ii]);
- }
-
- if (VK_NULL_HANDLE != m_backBufferColor[ii])
- {
- vkDestroy(m_backBufferColor[ii]);
- }
-
- if (VK_NULL_HANDLE != m_presentDone[ii])
- {
- vkDestroy(m_presentDone[ii]);
- }
+ vkDestroy(m_presentDone[ii]);
}
- vkDestroy(m_swapchain);
-
- vkDestroy(m_backBufferDepthStencilImageView);
- vkFreeMemory(m_device, m_backBufferDepthStencilMemory, m_allocatorCb);
- vkDestroy(m_backBufferDepthStencilImage);
+ releaseSwapchainFramebuffer();
+ releaseSwapchain();
vkDestroySurfaceKHR(m_instance, m_surface, m_allocatorCb);
@@ -1968,12 +2311,17 @@ VK_IMPORT_DEVICE
pi.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
pi.pNext = NULL;
pi.waitSemaphoreCount = 0;
- pi.pWaitSemaphores = NULL; //&m_presentDone[0];
+ pi.pWaitSemaphores = NULL;
pi.swapchainCount = 1;
pi.pSwapchains = &m_swapchain;
pi.pImageIndices = &m_backBufferColorIdx;
pi.pResults = NULL;
- VK_CHECK(vkQueuePresentKHR(m_queueGraphics, &pi) );
+ VkResult result = vkQueuePresentKHR(m_queueGraphics, &pi);
+ if (VK_ERROR_OUT_OF_DATE_KHR == result
+ || VK_SUBOPTIMAL_KHR == result)
+ {
+ m_needToRefreshSwapchain = true;
+ }
}
}
@@ -1987,20 +2335,20 @@ VK_IMPORT_DEVICE
m_indexBuffers[_handle.idx].destroy();
}
- void createVertexDecl(VertexDeclHandle _handle, const VertexDecl& _decl) override
+ void createVertexLayout(VertexLayoutHandle _handle, const VertexLayout& _layout) override
{
- VertexDecl& decl = m_vertexDecls[_handle.idx];
- bx::memCopy(&decl, &_decl, sizeof(VertexDecl) );
- dump(decl);
+ VertexLayout& layout = m_vertexLayouts[_handle.idx];
+ bx::memCopy(&layout, &_layout, sizeof(VertexLayout) );
+ dump(layout);
}
- void destroyVertexDecl(VertexDeclHandle /*_handle*/) override
+ void destroyVertexLayout(VertexLayoutHandle /*_handle*/) override
{
}
- void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexDeclHandle _declHandle, uint16_t _flags) override
+ void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexLayoutHandle _layoutHandle, uint16_t _flags) override
{
- m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _declHandle, _flags);
+ m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _layoutHandle, _flags);
}
void destroyVertexBuffer(VertexBufferHandle _handle) override
@@ -2015,8 +2363,8 @@ VK_IMPORT_DEVICE
void updateDynamicIndexBuffer(IndexBufferHandle _handle, uint32_t _offset, uint32_t _size, const Memory* _mem) override
{
- BX_UNUSED(_handle, _offset, _size, _mem);
-// m_indexBuffers[_handle.idx].update(m_commandBuffer, _offset, bx::uint32_min(_size, _mem->size), _mem->data);
+// BX_UNUSED(_handle, _offset, _size, _mem);
+ m_indexBuffers[_handle.idx].update(/*m_commandBuffer*/NULL, _offset, bx::min<uint32_t>(_size, _mem->size), _mem->data);
}
void destroyDynamicIndexBuffer(IndexBufferHandle _handle) override
@@ -2026,14 +2374,14 @@ VK_IMPORT_DEVICE
void createDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size, uint16_t _flags) override
{
- VertexDeclHandle decl = BGFX_INVALID_HANDLE;
- m_vertexBuffers[_handle.idx].create(_size, NULL, decl, _flags);
+ VertexLayoutHandle layoutHandle = BGFX_INVALID_HANDLE;
+ m_vertexBuffers[_handle.idx].create(_size, NULL, layoutHandle, _flags);
}
void updateDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _offset, uint32_t _size, const Memory* _mem) override
{
- BX_UNUSED(_handle, _offset, _size, _mem);
-// m_vertexBuffers[_handle.idx].update(m_commandBuffer, _offset, bx::uint32_min(_size, _mem->size), _mem->data);
+// BX_UNUSED(_handle, _offset, _size, _mem);
+ m_vertexBuffers[_handle.idx].update(/*m_commandBuffer*/NULL, _offset, bx::min<uint32_t>(_size, _mem->size), _mem->data);
}
void destroyDynamicVertexBuffer(VertexBufferHandle _handle) override
@@ -2061,17 +2409,18 @@ VK_IMPORT_DEVICE
m_program[_handle.idx].destroy();
}
- void* createTexture(TextureHandle /*_handle*/, const Memory* /*_mem*/, uint64_t /*_flags*/, uint8_t /*_skip*/) override
+ void* createTexture(TextureHandle _handle, const Memory* _mem, uint64_t _flags, uint8_t _skip) override
{
- return NULL;
+ return m_textures[_handle.idx].create(_mem, _flags, _skip);
}
void updateTextureBegin(TextureHandle /*_handle*/, uint8_t /*_side*/, uint8_t /*_mip*/) override
{
}
- 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*/) override
+ 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) override
{
+ m_textures[_handle.idx].update(m_commandPool, _side, _mip, _rect, _z, _depth, _pitch, _mem);
}
void updateTextureEnd() override
@@ -2095,20 +2444,23 @@ VK_IMPORT_DEVICE
return 0;
}
- void destroyTexture(TextureHandle /*_handle*/) override
+ void destroyTexture(TextureHandle _handle) override
{
+ m_textures[_handle.idx].destroy();
}
- void createFrameBuffer(FrameBufferHandle /*_handle*/, uint8_t /*_num*/, const Attachment* /*_attachment*/) override
+ void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const Attachment* _attachment) override
{
+ m_frameBuffers[_handle.idx].create(_num, _attachment);
}
void createFrameBuffer(FrameBufferHandle /*_handle*/, void* /*_nwh*/, uint32_t /*_width*/, uint32_t /*_height*/, TextureFormat::Enum /*_format*/, TextureFormat::Enum /*_depthFormat*/) override
{
}
- void destroyFrameBuffer(FrameBufferHandle /*_handle*/) override
+ void destroyFrameBuffer(FrameBufferHandle _handle) override
{
+ m_frameBuffers[_handle.idx].destroy();
}
void createUniform(UniformHandle _handle, UniformType::Enum _type, uint16_t _num, const char* _name) override
@@ -2148,30 +2500,224 @@ VK_IMPORT_DEVICE
bx::memCopy(m_uniforms[_loc], _data, _size);
}
- void setMarker(const char* /*_marker*/, uint32_t /*_size*/) override
+ void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override
{
+ BX_UNUSED(_handle);
}
- void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override
+ void setMarker(const char* _marker, uint16_t _len) override
{
- BX_UNUSED(_handle);
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
+ {
+ BX_UNUSED(_len);
+
+ VkDebugUtilsLabelEXT dul;
+ dul.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
+ dul.pNext = NULL;
+ dul.pLabelName = _marker;
+ dul.color[0] = 1.0f;
+ dul.color[1] = 0.0f;
+ dul.color[2] = 0.0f;
+ dul.color[3] = 1.0f;
+ vkCmdInsertDebugUtilsLabelEXT(m_commandBuffer, &dul);
+ }
}
- virtual void setName(Handle _handle, const char* _name) override
+ virtual void setName(Handle _handle, const char* _name, uint16_t _len) override
{
- BX_UNUSED(_handle, _name)
+ switch (_handle.type)
+ {
+ case Handle::IndexBuffer:
+ setDebugObjectName(m_device, m_indexBuffers[_handle.idx].m_buffer, "%.*s", _len, _name);
+ break;
+
+ case Handle::Shader:
+ setDebugObjectName(m_device, m_shaders[_handle.idx].m_module, "%.*s", _len, _name);
+ break;
+
+ case Handle::Texture:
+// setDebugObjectName(m_device, m_textures[_handle.idx].m_ptr, "%.*s", _len, _name);
+ break;
+
+ case Handle::VertexBuffer:
+ setDebugObjectName(m_device, m_vertexBuffers[_handle.idx].m_buffer, "%.*s", _len, _name);
+ break;
+
+ default:
+ BX_CHECK(false, "Invalid handle type?! %d", _handle.type);
+ break;
+ }
}
void submitBlit(BlitState& _bs, uint16_t _view);
void submit(Frame* _render, ClearQuad& _clearQuad, TextVideoMemBlitter& _textVideoMemBlitter) override;
- void blitSetup(TextVideoMemBlitter& /*_blitter*/) override
+ void blitSetup(TextVideoMemBlitter& _blitter) override
{
+ const uint32_t width = m_sci.imageExtent.width;
+ const uint32_t height = m_sci.imageExtent.height;
+
+ setFrameBuffer(BGFX_INVALID_HANDLE, false);
+
+ VkViewport vp;
+ vp.x = 0;
+ vp.y = 0;
+ vp.width = (float)width;
+ vp.height = (float)height;
+ vp.minDepth = 0.0f;
+ vp.maxDepth = 1.0f;
+ vkCmdSetViewport(m_commandBuffer, 0, 1, &vp);
+
+ VkRect2D rc;
+ rc.offset.x = 0;
+ rc.offset.y = 0;
+ rc.extent.width = width;
+ rc.extent.height = height;
+ vkCmdSetScissor(m_commandBuffer, 0, 1, &rc);
+
+ const uint64_t state = 0
+ | BGFX_STATE_WRITE_RGB
+ | BGFX_STATE_WRITE_A
+ | BGFX_STATE_DEPTH_TEST_ALWAYS
+ ;
+
+ const VertexLayout* layout = &m_vertexLayouts[_blitter.m_vb->layoutHandle.idx];
+ VkPipeline pso = getPipeline(state
+ , packStencil(BGFX_STENCIL_DEFAULT, BGFX_STENCIL_DEFAULT)
+ , 1
+ , &layout
+ , _blitter.m_program
+ , 0
+ );
+ vkCmdBindPipeline(m_commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pso);
+
+ ProgramVK& program = m_program[_blitter.m_program.idx];
+ float proj[16];
+ bx::mtxOrtho(proj, 0.0f, (float)width, (float)height, 0.0f, 0.0f, 1000.0f, 0.0f, false);
+
+ PredefinedUniform& predefined = m_program[_blitter.m_program.idx].m_predefined[0];
+ uint8_t flags = predefined.m_type;
+ setShaderUniform(flags, predefined.m_loc, proj, 4);
+
+ UniformBuffer* vcb = program.m_vsh->m_constantBuffer;
+ if (NULL != vcb)
+ {
+ commit(*vcb);
+ }
+ ScratchBufferVK& scratchBuffer = m_scratchBuffer[m_backBufferColorIdx];
+ VkDescriptorSetLayout dsl = m_descriptorSetLayoutCache.find(program.m_descriptorSetLayoutHash);
+ VkDescriptorSetAllocateInfo dsai;
+ dsai.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
+ dsai.pNext = NULL;
+ dsai.descriptorPool = m_descriptorPool;
+ dsai.descriptorSetCount = 1;
+ dsai.pSetLayouts = &dsl;
+ vkAllocateDescriptorSets(m_device, &dsai, &scratchBuffer.m_descriptorSet[scratchBuffer.m_currentDs]);
+
+ const uint32_t align = uint32_t(m_deviceProperties.limits.minUniformBufferOffsetAlignment);
+ TextureVK& texture = m_textures[_blitter.m_texture.idx];
+ uint32_t samplerFlags = (uint32_t)(texture.m_flags & BGFX_SAMPLER_BITS_MASK);
+ VkSampler sampler = getSampler(samplerFlags, 1);
+
+ const uint32_t size = bx::strideAlign(program.m_vsh->m_size, align);
+ uint32_t bufferOffset = scratchBuffer.m_pos;
+ VkDescriptorBufferInfo bufferInfo;
+ bufferInfo.buffer = scratchBuffer.m_buffer;
+ bufferInfo.offset = 0;
+ bufferInfo.range = size;
+ bx::memCopy(&scratchBuffer.m_data[scratchBuffer.m_pos], m_vsScratch, program.m_vsh->m_size);
+ scratchBuffer.m_pos += size;
+
+ VkWriteDescriptorSet wds[3];
+ wds[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
+ wds[0].pNext = NULL;
+ wds[0].dstSet = scratchBuffer.m_descriptorSet[scratchBuffer.m_currentDs];
+ wds[0].dstBinding = program.m_vsh->m_uniformBinding;
+ wds[0].dstArrayElement = 0;
+ wds[0].descriptorCount = 1;
+ wds[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;
+ wds[0].pImageInfo = NULL;
+ wds[0].pBufferInfo = &bufferInfo;
+ wds[0].pTexelBufferView = NULL;
+
+ VkDescriptorImageInfo imageInfo;
+ imageInfo.imageLayout = texture.m_currentImageLayout;
+ imageInfo.imageView = texture.m_textureImageView;
+ imageInfo.sampler = sampler;
+
+ wds[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
+ wds[1].pNext = NULL;
+ wds[1].dstSet = scratchBuffer.m_descriptorSet[scratchBuffer.m_currentDs];
+ wds[1].dstBinding = program.m_fsh->m_bindInfo[0].binding;
+ wds[1].dstArrayElement = 0;
+ wds[1].descriptorCount = 1;
+ wds[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
+ wds[1].pImageInfo = &imageInfo;
+ wds[1].pBufferInfo = NULL;
+ wds[1].pTexelBufferView = NULL;
+
+ wds[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
+ wds[2].pNext = NULL;
+ wds[2].dstSet = scratchBuffer.m_descriptorSet[scratchBuffer.m_currentDs];
+ wds[2].dstBinding = program.m_fsh->m_bindInfo[0].samplerBinding;
+ wds[2].dstArrayElement = 0;
+ wds[2].descriptorCount = 1;
+ wds[2].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER;
+ wds[2].pImageInfo = &imageInfo;
+ wds[2].pBufferInfo = NULL;
+ wds[2].pTexelBufferView = NULL;
+
+ m_vsChanges = 0;
+ m_fsChanges = 0;
+
+ vkUpdateDescriptorSets(m_device, 3, wds, 0, NULL);
+ vkCmdBindDescriptorSets(
+ m_commandBuffer
+ , VK_PIPELINE_BIND_POINT_GRAPHICS
+ , program.m_pipelineLayout
+ , 0
+ , 1
+ , &scratchBuffer.m_descriptorSet[scratchBuffer.m_currentDs]
+ , 1
+ , &bufferOffset
+ );
+
+ scratchBuffer.m_currentDs++;
+
+ VertexBufferVK& vb = m_vertexBuffers[_blitter.m_vb->handle.idx];
+ VkDeviceSize offset = 0;
+ vkCmdBindVertexBuffers(m_commandBuffer
+ , 0
+ , 1
+ , &vb.m_buffer
+ , &offset
+ );
+
+ BufferVK& ib = m_indexBuffers[_blitter.m_ib->handle.idx];
+ vkCmdBindIndexBuffer(m_commandBuffer
+ , ib.m_buffer
+ , 0
+ , VK_INDEX_TYPE_UINT16
+ );
}
- void blitRender(TextVideoMemBlitter& /*_blitter*/, uint32_t /*_numIndices*/) override
+ void blitRender(TextVideoMemBlitter& _blitter, uint32_t _numIndices) override
{
+ const uint32_t numVertices = _numIndices*4/6;
+ if (0 < numVertices)
+ {
+ m_indexBuffers[_blitter.m_ib->handle.idx].update(m_commandBuffer, 0, _numIndices*2, _blitter.m_ib->data);
+ m_vertexBuffers[_blitter.m_vb->handle.idx].update(m_commandBuffer, 0, numVertices*_blitter.m_layout.m_stride, _blitter.m_vb->data, true);
+
+ vkCmdDrawIndexed(m_commandBuffer
+ , _numIndices
+ , 1
+ , 0
+ , 0
+ , 0
+ );
+ }
}
void updateResolution(const Resolution& _resolution)
@@ -2209,6 +2755,29 @@ VK_IMPORT_DEVICE
m_textVideoMem.resize(false, _resolution.width, _resolution.height);
m_textVideoMem.clear();
+ if (resize || m_needToRefreshSwapchain)
+ {
+ VK_CHECK(vkDeviceWaitIdle(m_device) );
+ releaseSwapchainFramebuffer();
+ releaseSwapchain();
+
+ VkSurfaceCapabilitiesKHR surfaceCapabilities;
+ VK_CHECK(vkGetPhysicalDeviceSurfaceCapabilitiesKHR(m_physicalDevice, m_surface, &surfaceCapabilities) );
+
+ m_sci.imageExtent.width = bx::clamp<uint32_t>(m_resolution.width
+ , surfaceCapabilities.minImageExtent.width
+ , surfaceCapabilities.maxImageExtent.width
+ );
+ m_sci.imageExtent.height = bx::clamp<uint32_t>(m_resolution.height
+ , surfaceCapabilities.minImageExtent.height
+ , surfaceCapabilities.maxImageExtent.height
+ );
+
+ VK_CHECK(createSwapchain() );
+ VK_CHECK(createSwapchainFramebuffer() );
+ initSwapchainImageLayout();
+ BX_TRACE("refreshed swapchain: %d x %d", m_sci.imageExtent.width, m_sci.imageExtent.height);
+ }
#if 1
BX_UNUSED(resize);
#else
@@ -2278,42 +2847,44 @@ VK_IMPORT_DEVICE
setShaderUniform(_flags, _regIndex, _val, _numRegs);
}
- void commitShaderUniforms(VkCommandBuffer _commandBuffer, uint16_t _programIdx)
- {
- const ProgramVK& program = m_program[_programIdx];
- VkDescriptorBufferInfo descriptorBufferInfo;
- uint32_t total = 0
- + program.m_vsh->m_size
- + (NULL != program.m_fsh ? program.m_fsh->m_size : 0)
- ;
- if (0 < total)
- {
- uint8_t* data = (uint8_t*)m_scratchBuffer[m_backBufferColorIdx].allocUbv(descriptorBufferInfo, total);
-
- uint32_t size = program.m_vsh->m_size;
- bx::memCopy(data, m_vsScratch, size);
- data += size;
-
- if (NULL != program.m_fsh)
- {
- bx::memCopy(data, m_fsScratch, program.m_fsh->m_size);
- }
-
- vkCmdBindDescriptorSets(_commandBuffer
- , VK_PIPELINE_BIND_POINT_GRAPHICS
- , m_pipelineLayout
- , 0
- , 1
- , &m_scratchBuffer[m_backBufferColorIdx].m_descriptorSet
- [m_scratchBuffer[m_backBufferColorIdx].m_currentDs - 1]
- , 0
- , NULL
- );
- }
-
- m_vsChanges = 0;
- m_fsChanges = 0;
- }
+// void commitShaderUniforms(VkCommandBuffer _commandBuffer, ProgramHandle _program)
+// {
+// ProgramVK& program = m_program[_program.idx];
+//
+// const uint32_t align = uint32_t(m_deviceProperties.limits.minUniformBufferOffsetAlignment);
+// const uint32_t vsize = bx::strideAlign(program.m_vsh->m_size, align);
+// const uint32_t fsize = bx::strideAlign( (NULL != program.m_fsh ? program.m_fsh->m_size : 0), align);
+// const uint32_t total = vsize + fsize;
+//
+// if (0 < total)
+// {
+// ScratchBufferVK& sb = m_scratchBuffer[m_backBufferColorIdx];
+//
+// uint8_t* data = (uint8_t*)sb.allocUbv(vsize, fsize);
+//
+// bx::memCopy(data, m_vsScratch, program.m_vsh->m_size);
+// data += vsize;
+//
+// if (0 != fsize)
+// {
+// bx::memCopy(data, m_fsScratch, program.m_fsh->m_size);
+// }
+//
+// vkCmdBindDescriptorSets(_commandBuffer
+// , VK_PIPELINE_BIND_POINT_GRAPHICS
+// , m_pipelineLayout
+// , program.m_pipelineLayout
+// , 0
+// , 1
+// , &sb.m_descriptorSet[sb.m_currentDs - 1]
+// , 0
+// , NULL
+// );
+// }
+//
+// m_vsChanges = 0;
+// m_fsChanges = 0;
+// }
void setFrameBuffer(FrameBufferHandle _fbh, bool _msaa = true)
{
@@ -2325,21 +2896,21 @@ VK_IMPORT_DEVICE
const FrameBufferVK& frameBuffer = m_frameBuffers[m_fbh.idx];
BX_UNUSED(frameBuffer);
-// for (uint8_t ii = 0, num = frameBuffer.m_num; ii < num; ++ii)
-// {
-// TextureVK& texture = m_textures[frameBuffer.m_texture[ii].idx];
-// texture.setState(m_commandList, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
-// }
-//
-// if (isValid(frameBuffer.m_depth) )
-// {
-// TextureVK& texture = m_textures[frameBuffer.m_depth.idx];
-// const bool writeOnly = 0 != (texture.m_flags&BGFX_TEXTURE_RT_WRITE_ONLY);
-// if (!writeOnly)
-// {
-// texture.setState(m_commandList, D3D12_RESOURCE_STATE_DEPTH_READ);
-// }
-// }
+ for (uint8_t ii = 0, num = frameBuffer.m_num; ii < num; ++ii)
+ {
+ TextureVK& texture = m_textures[frameBuffer.m_texture[ii].idx];
+ texture.setImageMemoryBarrier(m_commandBuffer, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
+ }
+
+ if (isValid(frameBuffer.m_depth) )
+ {
+ TextureVK& texture = m_textures[frameBuffer.m_depth.idx];
+ const bool writeOnly = 0 != (texture.m_flags&BGFX_TEXTURE_RT_WRITE_ONLY);
+ if (!writeOnly)
+ {
+ texture.setImageMemoryBarrier(m_commandBuffer, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
+ }
+ }
}
if (!isValid(_fbh) )
@@ -2385,15 +2956,13 @@ VK_IMPORT_DEVICE
for (uint8_t ii = 0, num = frameBuffer.m_num; ii < num; ++ii)
{
TextureVK& texture = m_textures[frameBuffer.m_texture[ii].idx];
- BX_UNUSED(texture);
-// texture.setState(m_commandList, D3D12_RESOURCE_STATE_RENDER_TARGET);
+ texture.setImageMemoryBarrier(m_commandBuffer, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
}
if (isValid(frameBuffer.m_depth) )
{
TextureVK& texture = m_textures[frameBuffer.m_depth.idx];
- BX_UNUSED(texture);
-// texture.setState(m_commandList, D3D12_RESOURCE_STATE_DEPTH_WRITE);
+ texture.setImageMemoryBarrier(m_commandBuffer, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
}
// m_commandList->OMSetRenderTargets(frameBuffer.m_num
@@ -2449,7 +3018,7 @@ VK_IMPORT_DEVICE
numAttachments = frameBuffer.m_num;
}
- if (!!(BGFX_STATE_BLEND_INDEPENDENT & _state) )
+ if (!!(BGFX_STATE_BLEND_INDEPENDENT & _state) && m_deviceFeatures.independentBlend )
{
for (uint32_t ii = 1, rgba = _rgba; ii < numAttachments; ++ii, rgba >>= 11)
{
@@ -2552,54 +3121,261 @@ VK_IMPORT_DEVICE
_desc.maxDepthBounds = 1.0f;
}
- uint32_t setInputLayout(VkPipelineVertexInputStateCreateInfo& _vertexInputState, const VertexDecl& _vertexDecl, const ProgramVK& _program, uint8_t _numInstanceData)
+ void setInputLayout(VkPipelineVertexInputStateCreateInfo& _vertexInputState, uint8_t _numStream, const VertexLayout** _layout, const ProgramVK& _program, uint8_t _numInstanceData)
{
_vertexInputState.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
_vertexInputState.pNext = NULL;
_vertexInputState.flags = 0;
- VertexDecl decl;
- bx::memCopy(&decl, &_vertexDecl, sizeof(VertexDecl) );
- const uint16_t* attrMask = _program.m_vsh->m_attrMask;
+ _vertexInputState.vertexBindingDescriptionCount = 0;
+ _vertexInputState.vertexAttributeDescriptionCount = 0;
+
+ uint16_t unsettedAttr[Attrib::Count];
+ bx::memCopy(unsettedAttr, _program.m_vsh->m_attrMask, sizeof(uint16_t) * Attrib::Count);
+ for (uint8_t stream = 0; stream < _numStream; ++stream)
+ {
+ VertexLayout layout;
+ bx::memCopy(&layout, _layout[stream], sizeof(VertexLayout) );
+ const uint16_t* attrMask = _program.m_vsh->m_attrMask;
+
+ for (uint32_t ii = 0; ii < Attrib::Count; ++ii)
+ {
+ uint16_t mask = attrMask[ii];
+ uint16_t attr = (layout.m_attributes[ii] & mask);
+ layout.m_attributes[ii] = attr == 0 || attr == UINT16_MAX ? UINT16_MAX : attr;
+ if (unsettedAttr[ii] && attr != UINT16_MAX)
+ {
+ unsettedAttr[ii] = 0;
+ }
+ }
+
+ fillVertexLayout(_program.m_vsh, _vertexInputState, layout);
+ }
for (uint32_t ii = 0; ii < Attrib::Count; ++ii)
{
- uint16_t mask = attrMask[ii];
- uint16_t attr = (decl.m_attributes[ii] & mask);
- decl.m_attributes[ii] = attr == 0 ? UINT16_MAX : attr == UINT16_MAX ? 0 : attr;
+ if (0 < unsettedAttr[ii])
+ {
+ uint32_t numAttribs = _vertexInputState.vertexAttributeDescriptionCount;
+ VkVertexInputAttributeDescription* inputAttrib = const_cast<VkVertexInputAttributeDescription*>(_vertexInputState.pVertexAttributeDescriptions + numAttribs);
+ inputAttrib->location = _program.m_vsh->m_attrRemap[ii];
+ inputAttrib->binding = 0;
+ inputAttrib->format = VK_FORMAT_R32G32B32_SFLOAT;
+ inputAttrib->offset = 0;
+ _vertexInputState.vertexAttributeDescriptionCount++;
+ }
}
- uint32_t num = fillVertexDecl(_program.m_vsh, _vertexInputState, decl);
+ if (0 < _numInstanceData)
+ {
+ fillInstanceBinding(_program.m_vsh, _vertexInputState, _numInstanceData);
+ }
+ }
-// const D3D12_INPUT_ELEMENT_DESC inst = { "TEXCOORD", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA, 1 };
+ uint32_t getRenderPassHashkey(uint8_t _num, const Attachment* attachments)
+ {
+ if (_num == 0)
+ return 0;
+ bx::HashMurmur2A hash;
+ hash.begin(0);
+ for (uint8_t ii = 0; ii < _num; ++ii)
+ {
+ hash.add(attachments[ii].access);
+ hash.add(attachments[ii].layer);
+ hash.add(attachments[ii].mip);
+ hash.add(attachments[ii].resolve);
- // VK_VERTEX_INPUT_RATE_INSTANCE
+ TextureVK& texture = m_textures[attachments[ii].handle.idx];
+ hash.add(texture.m_textureFormat);
+ }
+ return hash.end();
+ }
- for (uint32_t ii = 0; ii < _numInstanceData; ++ii)
+ VkRenderPass getRenderPass(uint8_t _num, const Attachment* _attachments)
+ {
+ VkRenderPass renderPass = VK_NULL_HANDLE;
+ uint32_t hashKey = getRenderPassHashkey(_num, _attachments);
+ renderPass = (VkRenderPass)m_renderPassCache.find(hashKey);
+ if (renderPass != VK_NULL_HANDLE)
+ return renderPass;
+
+ // cache missed
+ VkAttachmentDescription ad[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
+ VkAttachmentReference colorAr[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
+ VkAttachmentReference resolveAr[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
+ VkAttachmentReference depthAr;
+ uint32_t numColorAr = 0;
+
+ depthAr.attachment = VK_ATTACHMENT_UNUSED;
+ depthAr.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
+
+ for (uint8_t ii = 0; ii < _num; ++ii)
{
- uint32_t index = 7 - ii; // TEXCOORD7 = i_data0, TEXCOORD6 = i_data1, etc.
+ TextureVK& texture = m_textures[_attachments[ii].handle.idx];
+ ad[ii].flags = 0;
+ ad[ii].format = texture.m_vkTextureFormat;
+ ad[ii].samples = VK_SAMPLE_COUNT_1_BIT;
- BX_UNUSED(index);
-// bx::memCopy(curr, &inst, sizeof(D3D12_INPUT_ELEMENT_DESC) );
-// curr->InputSlot = 1;
-// curr->SemanticIndex = index;
-// curr->AlignedByteOffset = ii*16;
+ if (texture.m_vkTextureAspect & VK_IMAGE_ASPECT_COLOR_BIT)
+ {
+ ad[ii].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
+ ad[ii].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
+ ad[ii].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
+ ad[ii].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
+ ad[ii].initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
+ ad[ii].finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
+ colorAr[numColorAr].layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
+ colorAr[numColorAr].attachment = ii;
+ numColorAr++;
+ }
+ else if (texture.m_vkTextureAspect & VK_IMAGE_ASPECT_DEPTH_BIT)
+ {
+ ad[ii].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
+ ad[ii].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
+ ad[ii].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
+ ad[ii].stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
+ ad[ii].initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
+ ad[ii].finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
+ depthAr.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
+ depthAr.attachment = ii;
+ }
+
+ resolveAr[ii].attachment = VK_ATTACHMENT_UNUSED;
+ resolveAr[ii].layout = ad[ii].initialLayout;
}
- _vertexInputState.vertexAttributeDescriptionCount = num;
- return num;
+ VkSubpassDescription sd[1];
+ sd[0].flags = 0;
+ sd[0].pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
+ sd[0].inputAttachmentCount = 0;
+ sd[0].pInputAttachments = NULL;
+ sd[0].colorAttachmentCount = numColorAr;
+ sd[0].pColorAttachments = colorAr;
+ sd[0].pResolveAttachments = resolveAr;
+ sd[0].pDepthStencilAttachment = &depthAr;
+ sd[0].preserveAttachmentCount = 0;
+ sd[0].pPreserveAttachments = NULL;
+
+ VkRenderPassCreateInfo rpi;
+ rpi.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
+ rpi.pNext = NULL;
+ rpi.flags = 0;
+ rpi.attachmentCount = _num;
+ rpi.pAttachments = ad;
+ rpi.subpassCount = BX_COUNTOF(sd);
+ rpi.pSubpasses = sd;
+ rpi.dependencyCount = 0;
+ rpi.pDependencies = NULL;
+
+ VK_CHECK( vkCreateRenderPass(m_device, &rpi, m_allocatorCb, &renderPass) );
+
+ m_renderPassCache.add(hashKey, renderPass);
+ return renderPass;
}
- VkPipeline getPipeline(uint16_t _programIdx)
+ VkSampler getSampler(uint32_t _samplerFlags, uint32_t _mipLevels)
{
- BX_UNUSED(_programIdx);
- // vkCreateComputePipelines
- return VK_NULL_HANDLE;
+ bx::HashMurmur2A hash;
+ hash.begin();
+ hash.add(_samplerFlags);
+ hash.add(_mipLevels);
+ uint32_t hashKey = hash.end();
+
+ VkSampler sampler = m_samplerCache.find(hashKey);
+ if (sampler != VK_NULL_HANDLE)
+ {
+ return sampler;
+ }
+
+ const uint32_t cmpFunc = (_samplerFlags&BGFX_SAMPLER_COMPARE_MASK)>>BGFX_SAMPLER_COMPARE_SHIFT;
+
+ VkSamplerCreateInfo sci;
+ sci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
+ sci.pNext = NULL;
+ sci.flags = 0;
+ sci.magFilter = VK_FILTER_LINEAR;
+ sci.minFilter = VK_FILTER_LINEAR;
+ sci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
+ sci.addressModeU = s_textureAddress[(_samplerFlags&BGFX_SAMPLER_U_MASK)>>BGFX_SAMPLER_U_SHIFT];
+ sci.addressModeV = s_textureAddress[(_samplerFlags&BGFX_SAMPLER_V_MASK)>>BGFX_SAMPLER_V_SHIFT];
+ sci.addressModeW = s_textureAddress[(_samplerFlags&BGFX_SAMPLER_W_MASK)>>BGFX_SAMPLER_W_SHIFT];
+ sci.mipLodBias = 0.0f;
+ sci.anisotropyEnable = VK_FALSE;
+ sci.maxAnisotropy = 4.0f;
+ sci.compareEnable = 0 != cmpFunc;
+ sci.compareOp = s_cmpFunc[cmpFunc];
+ sci.minLod = 0.0f;
+ sci.maxLod = (float)_mipLevels;
+ sci.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
+ sci.unnormalizedCoordinates = VK_FALSE;
+
+ switch (_samplerFlags & BGFX_SAMPLER_MAG_MASK)
+ {
+ case BGFX_SAMPLER_MAG_POINT: sci.magFilter = VK_FILTER_NEAREST; break;
+ case BGFX_SAMPLER_MAG_ANISOTROPIC: sci.anisotropyEnable = VK_TRUE; break;
+ }
+
+ switch (_samplerFlags & BGFX_SAMPLER_MIN_MASK)
+ {
+ case BGFX_SAMPLER_MIN_POINT: sci.minFilter = VK_FILTER_NEAREST; break;
+ case BGFX_SAMPLER_MIN_ANISOTROPIC: sci.anisotropyEnable = VK_TRUE; break;
+ }
+
+ uint32_t borderColor = ((_samplerFlags & BGFX_SAMPLER_BORDER_COLOR_MASK) >> BGFX_SAMPLER_BORDER_COLOR_SHIFT);
+ if (borderColor > 0)
+ {
+ sci.borderColor = VK_BORDER_COLOR_INT_OPAQUE_WHITE;
+ }
+
+ VK_CHECK(vkCreateSampler(m_device, &sci, m_allocatorCb, &sampler));
+
+ m_samplerCache.add(hashKey, sampler);
+ return sampler;
+ }
+
+ VkPipeline getPipeline(ProgramHandle _program)
+ {
+ ProgramVK& program = m_program[_program.idx];
+
+ bx::HashMurmur2A murmur;
+ murmur.begin();
+ murmur.add(program.m_vsh->m_hash);
+ const uint32_t hash = murmur.end();
+
+ VkPipeline pipeline = m_pipelineStateCache.find(hash);
+
+ if (VK_NULL_HANDLE != pipeline)
+ {
+ return pipeline;
+ }
+
+ VkComputePipelineCreateInfo cpci;
+ cpci.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO;
+ cpci.pNext = NULL;
+ cpci.flags = 0;
+
+ cpci.stage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
+ cpci.stage.pNext = NULL;
+ cpci.stage.flags = 0;
+ cpci.stage.stage = VK_SHADER_STAGE_COMPUTE_BIT;
+ cpci.stage.module = program.m_vsh->m_module;
+ cpci.stage.pName = "main";
+ cpci.stage.pSpecializationInfo = NULL;
+
+ cpci.layout = program.m_pipelineLayout;
+ cpci.basePipelineHandle = VK_NULL_HANDLE;
+ cpci.basePipelineIndex = 0;
+
+ VK_CHECK( vkCreateComputePipelines(m_device, m_pipelineCache, 1, &cpci, m_allocatorCb, &pipeline) );
+
+ m_pipelineStateCache.add(hash, pipeline);
+
+ return pipeline;
}
- VkPipeline getPipeline(uint64_t _state, uint64_t _stencil, uint16_t _declIdx, uint16_t _programIdx, uint8_t _numInstanceData)
+ VkPipeline getPipeline(uint64_t _state, uint64_t _stencil, uint8_t _numStreams, const VertexLayout** _layouts, ProgramHandle _program, uint8_t _numInstanceData)
{
- ProgramVK& program = m_program[_programIdx];
+ ProgramVK& program = m_program[_program.idx];
_state &= 0
| BGFX_STATE_WRITE_RGB
@@ -2619,15 +3395,18 @@ VK_IMPORT_DEVICE
_stencil &= packStencil(~BGFX_STENCIL_FUNC_REF_MASK, ~BGFX_STENCIL_FUNC_REF_MASK);
- VertexDecl decl;
- bx::memCopy(&decl, &m_vertexDecls[_declIdx], sizeof(VertexDecl) );
- const uint16_t* attrMask = program.m_vsh->m_attrMask;
-
- for (uint32_t ii = 0; ii < Attrib::Count; ++ii)
+ VertexLayout layout;
+ if (0 < _numStreams)
{
- uint16_t mask = attrMask[ii];
- uint16_t attr = (decl.m_attributes[ii] & mask);
- decl.m_attributes[ii] = attr == 0 ? UINT16_MAX : attr == UINT16_MAX ? 0 : attr;
+ bx::memCopy(&layout, _layouts[0], sizeof(VertexLayout) );
+ const uint16_t* attrMask = program.m_vsh->m_attrMask;
+
+ for (uint32_t ii = 0; ii < Attrib::Count; ++ii)
+ {
+ uint16_t mask = attrMask[ii];
+ uint16_t attr = (layout.m_attributes[ii] & mask);
+ layout.m_attributes[ii] = attr == 0 ? UINT16_MAX : attr == UINT16_MAX ? 0 : attr;
+ }
}
bx::HashMurmur2A murmur;
@@ -2637,8 +3416,11 @@ VK_IMPORT_DEVICE
murmur.add(program.m_vsh->m_hash);
murmur.add(program.m_vsh->m_attrMask, sizeof(program.m_vsh->m_attrMask) );
murmur.add(program.m_fsh->m_hash);
- murmur.add(m_vertexDecls[_declIdx].m_hash);
- murmur.add(decl.m_attributes, sizeof(decl.m_attributes) );
+ for (uint8_t ii = 0; ii < _numStreams; ++ii)
+ {
+ murmur.add(_layouts[ii]->m_hash);
+ }
+ murmur.add(layout.m_attributes, sizeof(layout.m_attributes) );
murmur.add(m_fbh.idx);
murmur.add(_numInstanceData);
const uint32_t hash = murmur.end();
@@ -2674,7 +3456,7 @@ VK_IMPORT_DEVICE
VkPipelineVertexInputStateCreateInfo vertexInputState;
vertexInputState.pVertexBindingDescriptions = inputBinding;
vertexInputState.pVertexAttributeDescriptions = inputAttrib;
- setInputLayout(vertexInputState, m_vertexDecls[_declIdx], program, _numInstanceData);
+ setInputLayout(vertexInputState, _numStreams, _layouts, program, _numInstanceData);
const VkDynamicState dynamicStates[] =
{
@@ -2683,6 +3465,7 @@ VK_IMPORT_DEVICE
VK_DYNAMIC_STATE_BLEND_CONSTANTS,
VK_DYNAMIC_STATE_STENCIL_REFERENCE,
};
+
VkPipelineDynamicStateCreateInfo dynamicState;
dynamicState.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
dynamicState.pNext = NULL;
@@ -2741,8 +3524,9 @@ VK_IMPORT_DEVICE
graphicsPipeline.pDepthStencilState = &depthStencilState;
graphicsPipeline.pColorBlendState = &colorBlendState;
graphicsPipeline.pDynamicState = &dynamicState;
- graphicsPipeline.layout = m_pipelineLayout;
- graphicsPipeline.renderPass = m_renderPass;
+// graphicsPipeline.layout = m_pipelineLayout;
+ graphicsPipeline.layout = program.m_pipelineLayout;
+ graphicsPipeline.renderPass = isValid(m_fbh) ? m_frameBuffers[m_fbh.idx].m_renderPass : m_renderPass;
graphicsPipeline.subpass = 0;
graphicsPipeline.basePipelineHandle = VK_NULL_HANDLE;
graphicsPipeline.basePipelineIndex = 0;
@@ -2808,6 +3592,205 @@ VK_IMPORT_DEVICE
return pipeline;
}
+ void allocDescriptorSet(ProgramVK& program, const RenderBind& renderBind, ScratchBufferVK& scratchBuffer)
+ {
+ VkDescriptorSetLayout dsl = m_descriptorSetLayoutCache.find(program.m_descriptorSetLayoutHash);
+ VkDescriptorSetAllocateInfo dsai;
+ dsai.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
+ dsai.pNext = NULL;
+ dsai.descriptorPool = m_descriptorPool;
+ dsai.descriptorSetCount = 1;
+ dsai.pSetLayouts = &dsl;
+
+ VkDescriptorSet& descriptorSet = scratchBuffer.m_descriptorSet[scratchBuffer.m_currentDs];
+ vkAllocateDescriptorSets(m_device, &dsai, &descriptorSet);
+ scratchBuffer.m_currentDs++;
+
+ VkDescriptorImageInfo imageInfo[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
+ VkDescriptorBufferInfo bufferInfo[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
+ VkWriteDescriptorSet wds[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
+ bx::memSet(wds, 0, sizeof(VkWriteDescriptorSet) * BGFX_CONFIG_MAX_TEXTURE_SAMPLERS);
+ uint32_t wdsCount = 0;
+ uint32_t bufferCount = 0;
+ uint32_t imageCount = 0;
+
+ for (uint32_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage)
+ {
+ const Binding& bind = renderBind.m_bind[stage];
+ if (kInvalidHandle != bind.m_idx)
+ {
+ const ShaderVK::BindInfo* bindInfo = NULL;
+ if (isValid(program.m_vsh->m_bindInfo[stage].uniformHandle))
+ {
+ bindInfo = &(program.m_vsh->m_bindInfo[stage]);
+ }
+ else if (NULL != program.m_fsh && isValid(program.m_fsh->m_bindInfo[stage].uniformHandle))
+ {
+ bindInfo = &(program.m_fsh->m_bindInfo[stage]);
+ }
+
+ if (NULL == bindInfo)
+ {
+ continue;
+ }
+
+ if (ShaderVK::BindType::Storage == bindInfo->type)
+ {
+ VkDescriptorType descriptorType = (VkDescriptorType)bindInfo->samplerBinding;
+ wds[wdsCount].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
+ wds[wdsCount].pNext = NULL;
+ wds[wdsCount].dstSet = descriptorSet;
+ wds[wdsCount].dstBinding = bindInfo->binding;
+ wds[wdsCount].dstArrayElement = 0;
+ wds[wdsCount].descriptorCount = 1;
+ wds[wdsCount].descriptorType = descriptorType;
+ wds[wdsCount].pImageInfo = NULL;
+ wds[wdsCount].pBufferInfo = NULL;
+ wds[wdsCount].pTexelBufferView = NULL;
+
+ if (VK_DESCRIPTOR_TYPE_STORAGE_BUFFER == descriptorType)
+ {
+ VertexBufferVK& vb = m_vertexBuffers[bind.m_idx];
+ bufferInfo[bufferCount].buffer = vb.m_buffer;
+ bufferInfo[bufferCount].offset = 0;
+ bufferInfo[bufferCount].range = vb.m_size;
+ wds[wdsCount].pBufferInfo = &bufferInfo[bufferCount];
+ ++bufferCount;
+ }
+ else if (VK_DESCRIPTOR_TYPE_STORAGE_IMAGE == descriptorType)
+ {
+ TextureVK& texture = m_textures[bind.m_idx];
+ VkSampler sampler = getSampler(
+ (0 == (BGFX_SAMPLER_INTERNAL_DEFAULT & bind.m_samplerFlags)
+ ? bind.m_samplerFlags
+ : (uint32_t)texture.m_flags
+ ) & (BGFX_SAMPLER_BITS_MASK | BGFX_SAMPLER_BORDER_COLOR_MASK)
+ , (uint32_t)texture.m_numMips);
+
+ if (VK_IMAGE_LAYOUT_GENERAL != texture.m_currentImageLayout
+ && VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL != texture.m_currentImageLayout)
+ {
+ texture.setImageMemoryBarrier(m_commandBuffer, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
+ }
+
+ imageInfo[imageCount].imageLayout = texture.m_currentImageLayout;
+ imageInfo[imageCount].imageView = VK_NULL_HANDLE != texture.m_textureImageStorageView
+ ? texture.m_textureImageStorageView
+ : texture.m_textureImageView
+ ;
+ imageInfo[imageCount].sampler = sampler;
+ wds[wdsCount].pImageInfo = &imageInfo[imageCount];
+ ++imageCount;
+ }
+
+ ++wdsCount;
+ }
+ else if (ShaderVK::BindType::Sampler == bindInfo->type)
+ {
+ TextureVK& texture = m_textures[bind.m_idx];
+ VkSampler sampler = getSampler(
+ (0 == (BGFX_SAMPLER_INTERNAL_DEFAULT & bind.m_samplerFlags)
+ ? bind.m_samplerFlags
+ : (uint32_t)texture.m_flags
+ ) & (BGFX_SAMPLER_BITS_MASK | BGFX_SAMPLER_BORDER_COLOR_MASK)
+ , (uint32_t)texture.m_numMips);
+
+ if (VK_IMAGE_LAYOUT_GENERAL != texture.m_currentImageLayout
+ && VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL != texture.m_currentImageLayout)
+ {
+ texture.setImageMemoryBarrier(m_commandBuffer, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
+ }
+
+ imageInfo[imageCount].imageLayout = texture.m_currentImageLayout;
+ imageInfo[imageCount].imageView = VK_NULL_HANDLE != texture.m_textureImageDepthView
+ ? texture.m_textureImageDepthView
+ : texture.m_textureImageView
+ ;
+ imageInfo[imageCount].sampler = sampler;
+
+ wds[wdsCount].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
+ wds[wdsCount].pNext = NULL;
+ wds[wdsCount].dstSet = descriptorSet;
+ wds[wdsCount].dstBinding = bindInfo->binding;
+ wds[wdsCount].dstArrayElement = 0;
+ wds[wdsCount].descriptorCount = 1;
+ wds[wdsCount].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
+ wds[wdsCount].pImageInfo = &imageInfo[imageCount];
+ wds[wdsCount].pBufferInfo = NULL;
+ wds[wdsCount].pTexelBufferView = NULL;
+ ++wdsCount;
+
+ wds[wdsCount].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
+ wds[wdsCount].pNext = NULL;
+ wds[wdsCount].dstSet = descriptorSet;
+ wds[wdsCount].dstBinding = bindInfo->samplerBinding;
+ wds[wdsCount].dstArrayElement = 0;
+ wds[wdsCount].descriptorCount = 1;
+ wds[wdsCount].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER;
+ wds[wdsCount].pImageInfo = &imageInfo[imageCount];
+ wds[wdsCount].pBufferInfo = NULL;
+ wds[wdsCount].pTexelBufferView = NULL;
+ ++wdsCount;
+
+ ++imageCount;
+ }
+ }
+ }
+
+ const uint32_t align = uint32_t(m_deviceProperties.limits.minUniformBufferOffsetAlignment);
+ const uint32_t vsize = bx::strideAlign(program.m_vsh->m_size, align);
+ const uint32_t fsize = bx::strideAlign((NULL != program.m_fsh ? program.m_fsh->m_size : 0), align);
+ const uint32_t total = vsize + fsize;
+
+ if (0 < total)
+ {
+ uint32_t vsUniformBinding = program.m_vsh->m_uniformBinding;
+ uint32_t fsUniformBinding = program.m_fsh ? program.m_fsh->m_uniformBinding : 0;
+
+ if (vsize > 0)
+ {
+ bufferInfo[bufferCount].buffer = scratchBuffer.m_buffer;
+ bufferInfo[bufferCount].offset = 0;
+ bufferInfo[bufferCount].range = vsize;
+
+ wds[wdsCount].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
+ wds[wdsCount].pNext = NULL;
+ wds[wdsCount].dstSet = descriptorSet;
+ wds[wdsCount].dstBinding = vsUniformBinding;
+ wds[wdsCount].dstArrayElement = 0;
+ wds[wdsCount].descriptorCount = 1;
+ wds[wdsCount].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;
+ wds[wdsCount].pImageInfo = NULL;
+ wds[wdsCount].pBufferInfo = &bufferInfo[bufferCount];
+ wds[wdsCount].pTexelBufferView = NULL;
+ ++wdsCount;
+ ++bufferCount;
+ }
+
+ if (fsize > 0)
+ {
+ bufferInfo[bufferCount].buffer = scratchBuffer.m_buffer;
+ bufferInfo[bufferCount].offset = 0;
+ bufferInfo[bufferCount].range = fsize;
+
+ wds[wdsCount].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
+ wds[wdsCount].pNext = NULL;
+ wds[wdsCount].dstSet = descriptorSet;
+ wds[wdsCount].dstBinding = fsUniformBinding;
+ wds[wdsCount].dstArrayElement = 0;
+ wds[wdsCount].descriptorCount = 1;
+ wds[wdsCount].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;
+ wds[wdsCount].pImageInfo = NULL;
+ wds[wdsCount].pBufferInfo = &bufferInfo[bufferCount];
+ wds[wdsCount].pTexelBufferView = NULL;
+ ++wdsCount;
+ ++bufferCount;
+ }
+ }
+
+ vkUpdateDescriptorSets(m_device, wdsCount, wds, 0, NULL);
+ }
+
void commit(UniformBuffer& _uniformBuffer)
{
_uniformBuffer.reset();
@@ -2839,12 +3822,12 @@ VK_IMPORT_DEVICE
data = (const char*)m_uniforms[handle.idx];
}
-#define CASE_IMPLEMENT_UNIFORM(_uniform, _dxsuffix, _type) \
- case UniformType::_uniform: \
- case UniformType::_uniform|BGFX_UNIFORM_FRAGMENTBIT: \
- { \
+#define CASE_IMPLEMENT_UNIFORM(_uniform, _dxsuffix, _type) \
+ case UniformType::_uniform: \
+ case UniformType::_uniform|BGFX_UNIFORM_FRAGMENTBIT: \
+ { \
setShaderUniform(uint8_t(type), loc, data, num); \
- } \
+ } \
break;
switch ( (uint32_t)type)
@@ -2873,9 +3856,13 @@ VK_IMPORT_DEVICE
}
break;
- CASE_IMPLEMENT_UNIFORM(Int1, I, int);
- CASE_IMPLEMENT_UNIFORM(Vec4, F, float);
- CASE_IMPLEMENT_UNIFORM(Mat4, F, float);
+ case UniformType::Sampler:
+ case UniformType::Sampler|BGFX_UNIFORM_FRAGMENTBIT:
+ // do nothing, but VkDescriptorSetImageInfo would be set before drawing
+ break;
+// CASE_IMPLEMENT_UNIFORM(Sampler, I, int);
+ CASE_IMPLEMENT_UNIFORM(Vec4, F, float);
+ CASE_IMPLEMENT_UNIFORM(Mat4, F, float);
case UniformType::End:
break;
@@ -2899,12 +3886,12 @@ VK_IMPORT_DEVICE
rect[0].layerCount = 1;
uint32_t numMrt = 1;
-// FrameBufferHandle fbh = m_fbh;
-// if (isValid(fbh) )
-// {
-// const FrameBufferVK& fb = m_frameBuffers[fbh.idx];
-// numMrt = bx::uint32_max(1, fb.m_num);
-// }
+ FrameBufferHandle fbh = m_fbh;
+ if (isValid(fbh) )
+ {
+ const FrameBufferVK& fb = m_frameBuffers[fbh.idx];
+ numMrt = bx::max((uint8_t)1, fb.m_num);
+ }
VkClearAttachment attachments[BGFX_CONFIG_MAX_FRAME_BUFFERS];
uint32_t mrt = 0;
@@ -2918,7 +3905,7 @@ VK_IMPORT_DEVICE
{
attachments[mrt].colorAttachment = mrt;
attachments[mrt].aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
- uint8_t index = (uint8_t)bx::uint32_min(BGFX_CONFIG_MAX_COLOR_PALETTE-1, _clear.m_index[ii]);
+ uint8_t index = bx::min<uint8_t>(BGFX_CONFIG_MAX_COLOR_PALETTE-1, _clear.m_index[ii]);
bx::memCopy(&attachments[mrt].clearValue.color.float32, _palette[index], 16);
++mrt;
}
@@ -2956,12 +3943,15 @@ VK_IMPORT_DEVICE
++mrt;
}
- vkCmdClearAttachments(m_commandBuffer
- , mrt
- , attachments
- , BX_COUNTOF(rect)
- , rect
- );
+ if (mrt > 0)
+ {
+ vkCmdClearAttachments(m_commandBuffer
+ , mrt
+ , attachments
+ , BX_COUNTOF(rect)
+ , rect
+ );
+ }
}
uint64_t kick(VkSemaphore _wait = VK_NULL_HANDLE, VkSemaphore _signal = VK_NULL_HANDLE)
@@ -3013,6 +4003,50 @@ VK_IMPORT_DEVICE
return 0;
}
+ VkCommandBuffer beginNewCommand(VkCommandBufferUsageFlagBits commandBufferUsageFlag = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)
+ {
+ VkCommandBufferAllocateInfo cbai;
+ cbai.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
+ cbai.pNext = NULL;
+ cbai.commandPool = m_commandPool;
+ cbai.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
+ cbai.commandBufferCount = 1;
+
+ VkCommandBuffer commandBuffer;
+ VK_CHECK(vkAllocateCommandBuffers(m_device, &cbai, &commandBuffer));
+
+ VkCommandBufferBeginInfo cbbi;
+ cbbi.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ cbbi.pNext = NULL;
+ cbbi.flags = commandBufferUsageFlag;
+ cbbi.pInheritanceInfo = NULL;
+ VK_CHECK(vkBeginCommandBuffer(commandBuffer, &cbbi));
+
+ return commandBuffer;
+ }
+
+ void submitCommandAndWait(VkCommandBuffer commandBuffer)
+ {
+ vkEndCommandBuffer(commandBuffer);
+
+ VkSubmitInfo submitInfo;
+ submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ submitInfo.pNext = NULL;
+ submitInfo.commandBufferCount = 1;
+ submitInfo.pCommandBuffers = &commandBuffer;
+ submitInfo.waitSemaphoreCount = 0;
+ submitInfo.pWaitSemaphores = NULL;
+ submitInfo.signalSemaphoreCount = 0;
+ submitInfo.pSignalSemaphores = NULL;
+ submitInfo.pWaitDstStageMask = NULL;
+
+ VK_CHECK(vkQueueSubmit(m_queueGraphics, 1, &submitInfo, VK_NULL_HANDLE));
+ VK_CHECK(vkQueueWaitIdle(m_queueGraphics));
+
+ vkFreeCommandBuffers(m_device, m_commandPool, 1, &commandBuffer);
+ }
+
+#define NUM_SWAPCHAIN_IMAGE 4
VkAllocationCallbacks* m_allocatorCb;
VkDebugReportCallbackEXT m_debugReportCallback;
VkInstance m_instance;
@@ -3020,23 +4054,27 @@ VK_IMPORT_DEVICE
VkPhysicalDeviceProperties m_deviceProperties;
VkPhysicalDeviceMemoryProperties m_memoryProperties;
+ VkPhysicalDeviceFeatures m_deviceFeatures;
VkSwapchainCreateInfoKHR m_sci;
VkSurfaceKHR m_surface;
VkSwapchainKHR m_swapchain;
- VkImage m_backBufferColorImage[4];
- VkImageView m_backBufferColorImageView[4];
- VkFramebuffer m_backBufferColor[4];
- VkCommandBuffer m_commandBuffers[4];
+ uint32_t m_numSwapchainImages;
+ VkImageLayout m_backBufferColorImageLayout[NUM_SWAPCHAIN_IMAGE];
+ VkImage m_backBufferColorImage[NUM_SWAPCHAIN_IMAGE];
+ VkImageView m_backBufferColorImageView[NUM_SWAPCHAIN_IMAGE];
+ VkFramebuffer m_backBufferColor[NUM_SWAPCHAIN_IMAGE];
+ VkCommandBuffer m_commandBuffers[NUM_SWAPCHAIN_IMAGE];
VkCommandBuffer m_commandBuffer;
+ bool m_needToRefreshSwapchain;
VkFormat m_backBufferDepthStencilFormat;
VkDeviceMemory m_backBufferDepthStencilMemory;
VkImage m_backBufferDepthStencilImage;
VkImageView m_backBufferDepthStencilImageView;
- ScratchBufferVK m_scratchBuffer[4];
- VkSemaphore m_presentDone[4];
+ ScratchBufferVK m_scratchBuffer[NUM_SWAPCHAIN_IMAGE];
+ VkSemaphore m_presentDone[NUM_SWAPCHAIN_IMAGE];
uint32_t m_qfiGraphics;
uint32_t m_qfiCompute;
@@ -3047,8 +4085,8 @@ VK_IMPORT_DEVICE
VkFence m_fence;
VkRenderPass m_renderPass;
VkDescriptorPool m_descriptorPool;
- VkDescriptorSetLayout m_descriptorSetLayout;
- VkPipelineLayout m_pipelineLayout;
+// VkDescriptorSetLayout m_descriptorSetLayout;
+// VkPipelineLayout m_pipelineLayout;
VkPipelineCache m_pipelineCache;
VkCommandPool m_commandPool;
@@ -3060,13 +4098,16 @@ VK_IMPORT_DEVICE
ShaderVK m_shaders[BGFX_CONFIG_MAX_SHADERS];
ProgramVK m_program[BGFX_CONFIG_MAX_PROGRAMS];
TextureVK m_textures[BGFX_CONFIG_MAX_TEXTURES];
- VertexDecl m_vertexDecls[BGFX_CONFIG_MAX_VERTEX_DECLS];
+ VertexLayout m_vertexLayouts[BGFX_CONFIG_MAX_VERTEX_LAYOUTS];
FrameBufferVK m_frameBuffers[BGFX_CONFIG_MAX_FRAME_BUFFERS];
void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS];
Matrix4 m_predefinedUniforms[PredefinedUniform::Count];
UniformRegistry m_uniformReg;
StateCacheT<VkPipeline> m_pipelineStateCache;
+ StateCacheT<VkDescriptorSetLayout> m_descriptorSetLayoutCache;
+ StateCacheT<VkRenderPass> m_renderPassCache;
+ StateCacheT<VkSampler> m_samplerCache;
Resolution m_resolution;
uint32_t m_maxAnisotropy;
@@ -3104,14 +4145,14 @@ VK_IMPORT_DEVICE
s_renderVK = NULL;
}
-#define VK_DESTROY_FUNC(_name) \
- void vkDestroy(Vk##_name& _obj) \
- { \
- if (VK_NULL_HANDLE != _obj) \
- { \
+#define VK_DESTROY_FUNC(_name) \
+ void vkDestroy(Vk##_name& _obj) \
+ { \
+ if (VK_NULL_HANDLE != _obj) \
+ { \
vkDestroy##_name(s_renderVK->m_device, _obj, s_renderVK->m_allocatorCb); \
- _obj = VK_NULL_HANDLE; \
- } \
+ _obj = VK_NULL_HANDLE; \
+ } \
}
VK_DESTROY
#undef VK_DESTROY_FUNC
@@ -3119,43 +4160,33 @@ VK_DESTROY
void ScratchBufferVK::create(uint32_t _size, uint32_t _maxDescriptors)
{
m_maxDescriptors = _maxDescriptors;
- m_descriptorSet = (VkDescriptorSet*)BX_ALLOC(g_allocator, _maxDescriptors * sizeof(VkDescriptorSet) );
+ m_currentDs = 0;
+ m_descriptorSet = (VkDescriptorSet*)BX_ALLOC(g_allocator, m_maxDescriptors * sizeof(VkDescriptorSet) );
+ bx::memSet(m_descriptorSet, 0, sizeof(VkDescriptorSet) * m_maxDescriptors);
VkAllocationCallbacks* allocatorCb = s_renderVK->m_allocatorCb;
VkDevice device = s_renderVK->m_device;
- VkDescriptorSetAllocateInfo dsai;
- dsai.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
- dsai.pNext = NULL;
- dsai.descriptorPool = s_renderVK->m_descriptorPool;
- dsai.descriptorSetCount = 1;
- dsai.pSetLayouts = &s_renderVK->m_descriptorSetLayout;
- for (uint32_t ii = 0, num = m_maxDescriptors; ii < num; ++ii)
- {
- VK_CHECK(vkAllocateDescriptorSets(device, &dsai, &m_descriptorSet[ii]) );
- }
-
VkBufferCreateInfo bci;
bci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
bci.pNext = NULL;
bci.flags = 0;
bci.size = _size;
- bci.usage = 0
- | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT
-// | VK_BUFFER_USAGE_TRANSFER_DST_BIT
- ;
+ bci.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
bci.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
bci.queueFamilyIndexCount = 0;
bci.pQueueFamilyIndices = NULL;
- VK_CHECK(vkCreateBuffer(device
+ VK_CHECK(vkCreateBuffer(
+ device
, &bci
, allocatorCb
, &m_buffer
) );
VkMemoryRequirements mr;
- vkGetBufferMemoryRequirements(device
+ vkGetBufferMemoryRequirements(
+ device
, m_buffer
, &mr
);
@@ -3186,54 +4217,34 @@ VK_DESTROY
VkAllocationCallbacks* allocatorCb = s_renderVK->m_allocatorCb;
VkDevice device = s_renderVK->m_device;
- vkFreeDescriptorSets(device, s_renderVK->m_descriptorPool, m_maxDescriptors, m_descriptorSet);
+ reset();
BX_FREE(g_allocator, m_descriptorSet);
vkUnmapMemory(device, m_deviceMem);
-
vkDestroy(m_buffer);
-
vkFreeMemory(device
, m_deviceMem
, allocatorCb
);
}
- void ScratchBufferVK::reset(VkDescriptorBufferInfo& /*_descriptorBufferInfo*/)
+ void ScratchBufferVK::reset()
{
+ if (m_currentDs > 0)
+ {
+ vkFreeDescriptorSets(
+ s_renderVK->m_device
+ , s_renderVK->m_descriptorPool
+ , m_currentDs
+ , m_descriptorSet
+ );
+ }
+
+ bx::memSet(m_descriptorSet, 0, sizeof(VkDescriptorSet) * m_maxDescriptors);
m_pos = 0;
m_currentDs = 0;
}
- void* ScratchBufferVK::allocUbv(VkDescriptorBufferInfo& _descriptorBufferInfo, uint32_t _size)
- {
- uint32_t total = bx::strideAlign(_size
- , uint32_t(s_renderVK->m_deviceProperties.limits.minUniformBufferOffsetAlignment)
- );
- _descriptorBufferInfo.buffer = m_buffer;
- _descriptorBufferInfo.offset = m_pos;
- _descriptorBufferInfo.range = total;
-
- VkWriteDescriptorSet wds[1];
- wds[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
- wds[0].pNext = NULL;
- wds[0].dstSet = m_descriptorSet[m_currentDs];
- wds[0].dstBinding = DslBinding::UniformBuffer;
- wds[0].dstArrayElement = 0;
- wds[0].descriptorCount = 1;
- wds[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
- wds[0].pImageInfo = NULL;
- wds[0].pBufferInfo = &_descriptorBufferInfo;
- wds[0].pTexelBufferView = NULL;
- vkUpdateDescriptorSets(s_renderVK->m_device, BX_COUNTOF(wds), wds, 0, NULL);
-
- void* data = &m_data[m_pos];
- m_pos += total;
- ++m_currentDs;
-
- return data;
- }
-
VkResult ImageVK::create(VkFormat _format, const VkExtent3D& _extent)
{
VkResult result;
@@ -3275,14 +4286,11 @@ VK_DESTROY
ma.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
ma.pNext = NULL;
ma.allocationSize = mr.size;
- ma.memoryTypeIndex = s_renderVK->selectMemoryType(mr.memoryTypeBits
+ ma.memoryTypeIndex = s_renderVK->selectMemoryType(
+ mr.memoryTypeBits
, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
);
- result = vkAllocateMemory(device
- , &ma
- , allocatorCb
- , &m_memory
- );
+ result = vkAllocateMemory(device, &ma, allocatorCb, &m_memory);
if (VK_SUCCESS != result)
{
@@ -3350,14 +4358,19 @@ VK_DESTROY
m_flags = _flags;
m_dynamic = NULL == _data;
+ bool storage = m_flags & BGFX_BUFFER_COMPUTE_READ_WRITE;
+ bool indirect = m_flags & BGFX_BUFFER_DRAW_INDIRECT;
VkBufferCreateInfo bci;
bci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
bci.pNext = NULL;
bci.flags = 0;
bci.size = _size;
bci.usage = 0
- | (m_dynamic ? VK_BUFFER_USAGE_TRANSFER_DST_BIT : 0)
- | (_vertex ? VK_BUFFER_USAGE_VERTEX_BUFFER_BIT : VK_BUFFER_USAGE_INDEX_BUFFER_BIT)
+// | (m_dynamic ? VK_BUFFER_USAGE_TRANSFER_DST_BIT : 0)
+ | (_vertex ? VK_BUFFER_USAGE_VERTEX_BUFFER_BIT : VK_BUFFER_USAGE_INDEX_BUFFER_BIT)
+ | (storage || indirect ? VK_BUFFER_USAGE_STORAGE_BUFFER_BIT : 0)
+ | (indirect ? VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT : 0)
+ | VK_BUFFER_USAGE_TRANSFER_DST_BIT
;
bci.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
bci.queueFamilyIndexCount = 0;
@@ -3372,38 +4385,155 @@ VK_DESTROY
) );
VkMemoryRequirements mr;
- vkGetBufferMemoryRequirements(device
- , m_buffer
- , &mr
- );
+ vkGetBufferMemoryRequirements(device, m_buffer, &mr);
VkMemoryAllocateInfo ma;
ma.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
ma.pNext = NULL;
ma.allocationSize = mr.size;
- ma.memoryTypeIndex = s_renderVK->selectMemoryType(mr.memoryTypeBits
- , VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
+ ma.memoryTypeIndex = s_renderVK->selectMemoryType(
+ mr.memoryTypeBits
+ , VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
);
- VK_CHECK(vkAllocateMemory(device
- , &ma
- , allocatorCb
- , &m_deviceMem
- ) );
+ VK_CHECK(vkAllocateMemory(device, &ma, allocatorCb, &m_deviceMem) );
+
+ VK_CHECK(vkBindBufferMemory(device, m_buffer, m_deviceMem, 0));
if (!m_dynamic)
{
+// void* dst;
+// VK_CHECK(vkMapMemory(device, m_deviceMem, 0, ma.allocationSize, 0, &dst) );
+// bx::memCopy(dst, _data, _size);
+// vkUnmapMemory(device, m_deviceMem);
+
+ // staging buffer
+ VkBuffer stagingBuffer;
+ VkDeviceMemory stagingMem;
+ bci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
+ bci.pNext = NULL;
+ bci.flags = 0;
+ bci.size = _size;
+ bci.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
+ bci.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
+ bci.queueFamilyIndexCount = 0;
+ bci.pQueueFamilyIndices = NULL;
+
+ VK_CHECK(vkCreateBuffer(device
+ , &bci
+ , allocatorCb
+ , &stagingBuffer
+ ));
+
+ vkGetBufferMemoryRequirements(device, stagingBuffer, &mr);
+
+ ma.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
+ ma.pNext = NULL;
+ ma.allocationSize = mr.size;
+ ma.memoryTypeIndex = s_renderVK->selectMemoryType(mr.memoryTypeBits
+ , VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
+ );
+ VK_CHECK(vkAllocateMemory(device
+ , &ma
+ , allocatorCb
+ , &stagingMem
+ ));
+
+ VK_CHECK(vkBindBufferMemory(device, stagingBuffer, stagingMem, 0));
+
void* dst;
- VK_CHECK(vkMapMemory(device, m_deviceMem, 0, ma.allocationSize, 0, &dst) );
+ VK_CHECK(vkMapMemory(device, stagingMem, 0, ma.allocationSize, 0, &dst));
bx::memCopy(dst, _data, _size);
- vkUnmapMemory(device, m_deviceMem);
- }
+ vkUnmapMemory(device, stagingMem);
- VK_CHECK(vkBindBufferMemory(device, m_buffer, m_deviceMem, 0) );
+ VkCommandBuffer commandBuffer = s_renderVK->beginNewCommand();
+ // copy buffer to buffer
+ {
+ VkBufferCopy region;
+ region.srcOffset = 0;
+ region.dstOffset = 0;
+ region.size = _size;
+
+ vkCmdCopyBuffer(commandBuffer, stagingBuffer, m_buffer, 1, &region);
+ }
+ s_renderVK->submitCommandAndWait(commandBuffer);
+
+ vkFreeMemory(device, stagingMem, allocatorCb);
+ vkDestroy(stagingBuffer);
+ }
}
void BufferVK::update(VkCommandBuffer _commandBuffer, uint32_t _offset, uint32_t _size, void* _data, bool _discard)
{
- BX_UNUSED(_commandBuffer, _offset, _size, _data, _discard);
+ BX_UNUSED(_commandBuffer, _discard);
+// void* dst;
+// VkDevice device = s_renderVK->m_device;
+// VK_CHECK(vkMapMemory(device, m_deviceMem, _offset, _size, 0, &dst) );
+// bx::memCopy(dst, _data, _size);
+// vkUnmapMemory(device, m_deviceMem);
+
+ // staging buffer
+ VkAllocationCallbacks* allocatorCb = s_renderVK->m_allocatorCb;
+ VkDevice device = s_renderVK->m_device;
+ VkBuffer stagingBuffer;
+ VkDeviceMemory stagingMem;
+ VkBufferCreateInfo bci;
+ bci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
+ bci.pNext = NULL;
+ bci.flags = 0;
+ bci.size = _size;
+ bci.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
+ bci.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
+ bci.queueFamilyIndexCount = 0;
+ bci.pQueueFamilyIndices = NULL;
+
+ VK_CHECK(vkCreateBuffer(device
+ , &bci
+ , allocatorCb
+ , &stagingBuffer
+ ));
+
+ VkMemoryRequirements mr;
+ vkGetBufferMemoryRequirements(device
+ , stagingBuffer
+ , &mr
+ );
+
+ VkMemoryAllocateInfo ma;
+ ma.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
+ ma.pNext = NULL;
+ ma.allocationSize = mr.size;
+ ma.memoryTypeIndex = s_renderVK->selectMemoryType(mr.memoryTypeBits
+ , VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
+ );
+ VK_CHECK(vkAllocateMemory(device
+ , &ma
+ , allocatorCb
+ , &stagingMem
+ ));
+
+ VK_CHECK(vkBindBufferMemory(device, stagingBuffer, stagingMem, 0));
+
+ void* dst;
+ VK_CHECK(vkMapMemory(device, stagingMem, 0, ma.allocationSize, 0, &dst));
+ bx::memCopy(dst, _data, _size);
+ vkUnmapMemory(device, stagingMem);
+
+ VkCommandBuffer commandBuffer = s_renderVK->beginNewCommand();
+
+ // copy buffer to buffer
+ {
+ VkBufferCopy region;
+ region.srcOffset = 0;
+ region.dstOffset = _offset;
+ region.size = _size;
+
+ vkCmdCopyBuffer(commandBuffer, stagingBuffer, m_buffer, 1, &region);
+ }
+
+ s_renderVK->submitCommandAndWait(commandBuffer);
+
+ vkFreeMemory(device, stagingMem, allocatorCb);
+ vkDestroy(stagingBuffer);
}
void BufferVK::destroy()
@@ -3422,10 +4552,10 @@ VK_DESTROY
}
}
- void VertexBufferVK::create(uint32_t _size, void* _data, VertexDeclHandle _declHandle, uint16_t _flags)
+ void VertexBufferVK::create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle, uint16_t _flags)
{
BufferVK::create(_size, _data, _flags, true);
- m_decl = _declHandle;
+ m_layoutHandle = _layoutHandle;
}
void ShaderVK::create(const Memory* _mem)
@@ -3480,6 +4610,14 @@ VK_DESTROY
uint8_t fragmentBit = fragment ? BGFX_UNIFORM_FRAGMENTBIT : 0;
+ for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++ii)
+ {
+ m_bindInfo[ii].uniformHandle = BGFX_INVALID_HANDLE;
+ m_bindInfo[ii].type = BindType::Count;
+ m_bindInfo[ii].binding = 0;
+ m_bindInfo[ii].samplerBinding = 0;
+ }
+
if (0 < count)
{
for (uint32_t ii = 0; ii < count; ++ii)
@@ -3514,7 +4652,28 @@ VK_DESTROY
m_predefined[m_numPredefined].m_type = uint8_t(predefined|fragmentBit);
m_numPredefined++;
}
- else if (0 == (BGFX_UNIFORM_SAMPLERBIT & type) )
+ else if (UniformType::End == (~BGFX_UNIFORM_MASK & type))
+ {
+ m_bindInfo[num].uniformHandle = { 0 };
+ m_bindInfo[num].type = BindType::Storage;
+ m_bindInfo[num].binding = regCount; // regCount is used for buffer binding index
+ m_bindInfo[num].samplerBinding = regIndex; // regIndex is used for descriptor type
+
+ kind = "storage";
+ }
+ else if (UniformType::Sampler == (~BGFX_UNIFORM_MASK & type) )
+ {
+ const UniformRegInfo* info = s_renderVK->m_uniformReg.find(name);
+ BX_CHECK(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
+
+ m_bindInfo[num].uniformHandle = info->m_handle;
+ m_bindInfo[num].type = BindType::Sampler;
+ m_bindInfo[num].binding = regIndex; // regIndex is used for image binding index
+ m_bindInfo[num].samplerBinding = regCount; // regCount is used for sampler binding index
+
+ kind = "sampler";
+ }
+ else
{
const UniformRegInfo* info = s_renderVK->m_uniformReg.find(name);
BX_CHECK(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
@@ -3530,10 +4689,7 @@ VK_DESTROY
m_constantBuffer->writeUniformHandle( (UniformType::Enum)(type|fragmentBit), regIndex, info->m_handle, regCount);
}
}
- else
- {
- kind = "sampler";
- }
+
BX_TRACE("\t%s: %s (%s), num %2d, r.index %3d, r.count %2d"
, kind
@@ -3559,10 +4715,7 @@ VK_DESTROY
bx::skip(&reader, shaderSize+1);
m_code = alloc(shaderSize);
- bx::memCopy(m_code->data
- , code
- , shaderSize
- );
+ bx::memCopy(m_code->data, code, shaderSize);
VkShaderModuleCreateInfo smci;
smci.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
@@ -3570,6 +4723,9 @@ VK_DESTROY
smci.flags = 0;
smci.codeSize = m_code->size;
smci.pCode = (const uint32_t*)m_code->data;
+
+// disassemble(bx::getDebugOut(), m_code->data, m_code->size);
+
VK_CHECK(vkCreateShaderModule(
s_renderVK->m_device
, &smci
@@ -3607,6 +4763,57 @@ VK_DESTROY
m_hash = murmur.end();
bx::read(&reader, m_size);
+
+ // fill binding description with uniform informations
+ {
+ uint16_t bidx = 0;
+ if (m_size > 0)
+ {
+ m_uniformBinding = fragment ? 48 : 0;
+ m_bindings[bidx].stageFlags = VK_SHADER_STAGE_ALL;
+ m_bindings[bidx].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;
+ m_bindings[bidx].binding = m_uniformBinding;
+ m_bindings[bidx].pImmutableSamplers = NULL;
+ m_bindings[bidx].descriptorCount = 1;
+ bidx++;
+ }
+
+ for (uint32_t ii = 0; ii < BX_COUNTOF(m_bindInfo); ++ii)
+ {
+ switch (m_bindInfo[ii].type)
+ {
+ case BindType::Storage:
+ m_bindings[bidx].stageFlags = VK_SHADER_STAGE_ALL;
+ m_bindings[bidx].descriptorType = (VkDescriptorType)m_bindInfo[ii].samplerBinding;
+ m_bindings[bidx].binding = m_bindInfo[ii].binding;
+ m_bindings[bidx].pImmutableSamplers = NULL;
+ m_bindings[bidx].descriptorCount = 1;
+ bidx++;
+ break;
+
+ case BindType::Sampler:
+ m_bindings[bidx].stageFlags = VK_SHADER_STAGE_ALL;
+ m_bindings[bidx].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
+ m_bindings[bidx].binding = m_bindInfo[ii].binding;
+ m_bindings[bidx].pImmutableSamplers = NULL;
+ m_bindings[bidx].descriptorCount = 1;
+ bidx++;
+
+ m_bindings[bidx].stageFlags = VK_SHADER_STAGE_ALL;
+ m_bindings[bidx].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER;
+ m_bindings[bidx].binding = m_bindInfo[ii].samplerBinding;
+ m_bindings[bidx].pImmutableSamplers = NULL;
+ m_bindings[bidx].descriptorCount = 1;
+ bidx++;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ m_numBindings = bidx;
+ }
}
void ShaderVK::destroy()
@@ -3632,21 +4839,827 @@ VK_DESTROY
}
}
+ void ProgramVK::create(const ShaderVK* _vsh, const ShaderVK* _fsh)
+ {
+ BX_CHECK(NULL != _vsh->m_code, "Vertex shader doesn't exist.");
+ m_vsh = _vsh;
+ bx::memCopy(
+ &m_predefined[0]
+ , _vsh->m_predefined
+ , _vsh->m_numPredefined * sizeof(PredefinedUniform)
+ );
+ m_numPredefined = _vsh->m_numPredefined;
+
+ if (NULL != _fsh)
+ {
+ BX_CHECK(NULL != _fsh->m_code, "Fragment shader doesn't exist.");
+ m_fsh = _fsh;
+ bx::memCopy(
+ &m_predefined[m_numPredefined]
+ , _fsh->m_predefined
+ , _fsh->m_numPredefined * sizeof(PredefinedUniform)
+ );
+ m_numPredefined += _fsh->m_numPredefined;
+ }
+
+ // create exact pipeline layout
+ VkDescriptorSetLayout dsl = VK_NULL_HANDLE;
+
+ uint32_t numBindings = m_vsh->m_numBindings + (m_fsh ? m_fsh->m_numBindings : 0);
+ if (0 < numBindings)
+ {
+ // generate descriptor set layout hash
+ bx::HashMurmur2A murmur;
+ murmur.begin();
+ murmur.add(m_vsh->m_bindings, sizeof(VkDescriptorSetLayoutBinding) * m_vsh->m_numBindings);
+ if (NULL != m_fsh)
+ {
+ murmur.add(m_fsh->m_bindings, sizeof(VkDescriptorSetLayoutBinding) * m_fsh->m_numBindings);
+ }
+ m_descriptorSetLayoutHash = murmur.end();
+
+ dsl = s_renderVK->m_descriptorSetLayoutCache.find(m_descriptorSetLayoutHash);
+
+ if (NULL == dsl)
+ {
+ VkDescriptorSetLayoutBinding bindings[64];
+ bx::memCopy(
+ bindings
+ , m_vsh->m_bindings
+ , sizeof(VkDescriptorSetLayoutBinding) * m_vsh->m_numBindings
+ );
+ if (NULL != m_fsh)
+ {
+ bx::memCopy(
+ bindings + m_vsh->m_numBindings
+ , m_fsh->m_bindings
+ , sizeof(VkDescriptorSetLayoutBinding) * m_fsh->m_numBindings
+ );
+ }
+
+ VkDescriptorSetLayoutCreateInfo dslci;
+ dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
+ dslci.pNext = NULL;
+ dslci.flags = 0;
+ dslci.bindingCount = numBindings;
+ dslci.pBindings = bindings;
+
+ VK_CHECK(vkCreateDescriptorSetLayout(
+ s_renderVK->m_device
+ , &dslci
+ , s_renderVK->m_allocatorCb
+ , &dsl
+ ));
+
+ s_renderVK->m_descriptorSetLayoutCache.add(m_descriptorSetLayoutHash, dsl);
+ }
+ }
+
+ VkPipelineLayoutCreateInfo plci;
+ plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
+ plci.pNext = NULL;
+ plci.flags = 0;
+ plci.pushConstantRangeCount = 0;
+ plci.pPushConstantRanges = NULL;
+ plci.setLayoutCount = (dsl == VK_NULL_HANDLE ? 0 : 1);
+ plci.pSetLayouts = &dsl;
+
+ VK_CHECK(vkCreatePipelineLayout(
+ s_renderVK->m_device
+ , &plci
+ , s_renderVK->m_allocatorCb
+ , &m_pipelineLayout
+ ));
+ }
+
+ void ProgramVK::destroy()
+ {
+ vkDestroy(m_pipelineLayout);
+ m_numPredefined = 0;
+ m_vsh = NULL;
+ m_fsh = NULL;
+ }
+
+ void* TextureVK::create(const Memory* _mem, uint64_t _flags, uint8_t _skip)
+ {
+ bimg::ImageContainer imageContainer;
+
+ if (bimg::imageParse(imageContainer, _mem->data, _mem->size))
+ {
+ VkAllocationCallbacks* allocatorCb = s_renderVK->m_allocatorCb;
+ VkDevice device = s_renderVK->m_device;
+
+ const bimg::ImageBlockInfo& blockInfo = bimg::getBlockInfo(imageContainer.m_format);
+ const uint8_t startLod = bx::min<uint8_t>(_skip, imageContainer.m_numMips - 1);
+
+ bimg::TextureInfo ti;
+ bimg::imageGetSize(
+ &ti
+ , uint16_t(imageContainer.m_width >> startLod)
+ , uint16_t(imageContainer.m_height >> startLod)
+ , uint16_t(imageContainer.m_depth >> startLod)
+ , imageContainer.m_cubeMap
+ , 1 < imageContainer.m_numMips
+ , imageContainer.m_numLayers
+ , imageContainer.m_format
+ );
+
+ ti.numMips = bx::min<uint8_t>(imageContainer.m_numMips - startLod, ti.numMips);
+
+ m_flags = _flags;
+ m_width = ti.width;
+ m_height = ti.height;
+ m_depth = ti.depth;
+ m_numLayers = ti.numLayers;
+ m_requestedFormat = uint8_t(imageContainer.m_format);
+ m_textureFormat = uint8_t(getViableTextureFormat(imageContainer));
+ m_vkTextureFormat = bimg::isDepth(bimg::TextureFormat::Enum(m_textureFormat) )
+ ? s_textureFormat[m_textureFormat].m_fmtDsv
+ : s_textureFormat[m_textureFormat].m_fmt
+ ;
+
+ const bool convert = m_textureFormat != m_requestedFormat;
+ const uint8_t bpp = bimg::getBitsPerPixel(bimg::TextureFormat::Enum(m_textureFormat));
+ m_vkTextureAspect = bimg::isDepth((bimg::TextureFormat::Enum)m_textureFormat)
+ ? VK_IMAGE_ASPECT_DEPTH_BIT
+ : VK_IMAGE_ASPECT_COLOR_BIT
+ ;
+
+ if (m_vkTextureFormat == VK_FORMAT_S8_UINT
+ || m_vkTextureFormat == VK_FORMAT_D16_UNORM_S8_UINT
+ || m_vkTextureFormat == VK_FORMAT_D24_UNORM_S8_UINT
+ || m_vkTextureFormat == VK_FORMAT_D32_SFLOAT_S8_UINT)
+ {
+ m_vkTextureAspect |= VK_IMAGE_ASPECT_STENCIL_BIT;
+ }
+
+ if (imageContainer.m_cubeMap)
+ {
+ m_type = VK_IMAGE_VIEW_TYPE_CUBE;
+ }
+ else if (imageContainer.m_depth > 1)
+ {
+ m_type = VK_IMAGE_VIEW_TYPE_3D;
+ }
+ else
+ {
+ m_type = VK_IMAGE_VIEW_TYPE_2D;
+ }
+
+ m_numMips = ti.numMips;
+ m_numSides = ti.numLayers * (imageContainer.m_cubeMap ? 6 : 1);
+ const uint16_t numSides = ti.numLayers * (imageContainer.m_cubeMap ? 6 : 1);
+ const uint32_t numSrd = numSides * ti.numMips;
+
+ uint32_t kk = 0;
+
+ const bool compressed = bimg::isCompressed(bimg::TextureFormat::Enum(m_textureFormat));
+ const bool swizzle = TextureFormat::BGRA8 == m_textureFormat && 0 != (m_flags & BGFX_TEXTURE_COMPUTE_WRITE);
+
+ const bool writeOnly = 0 != (m_flags & BGFX_TEXTURE_RT_WRITE_ONLY);
+ const bool computeWrite = 0 != (m_flags & BGFX_TEXTURE_COMPUTE_WRITE);
+ const bool renderTarget = 0 != (m_flags & BGFX_TEXTURE_RT_MASK);
+ const bool blit = 0 != (m_flags & BGFX_TEXTURE_BLIT_DST);
+
+ BX_UNUSED(swizzle, writeOnly, computeWrite, renderTarget, blit);
+
+ BX_TRACE(
+ "Texture %3d: %s (requested: %s), %dx%d%s RT[%c], BO[%c], CW[%c]%s."
+ , (int)(this - s_renderVK->m_textures)
+ , getName((TextureFormat::Enum)m_textureFormat)
+ , getName((TextureFormat::Enum)m_requestedFormat)
+ , ti.width
+ , ti.height
+ , imageContainer.m_cubeMap ? "x6" : ""
+ , renderTarget ? 'x' : ' '
+ , writeOnly ? 'x' : ' '
+ , computeWrite ? 'x' : ' '
+ , swizzle ? " (swizzle BGRA8 -> RGBA8)" : ""
+ );
+
+ // decode images
+ struct ImageInfo
+ {
+ uint8_t* data;
+ uint32_t width;
+ uint32_t height;
+ uint32_t depth;
+ uint32_t pitch;
+ uint32_t slice;
+ uint32_t size;
+ uint8_t mipLevel;
+ uint8_t layer;
+ };
+
+ ImageInfo* imageInfos = (ImageInfo*)BX_ALLOC(g_allocator, sizeof(ImageInfo) * numSrd);
+ bx::memSet(imageInfos, 0, sizeof(ImageInfo) * numSrd);
+ uint32_t alignment = 1; // tightly aligned buffer
+ for (uint8_t side = 0; side < numSides; ++side)
+ {
+ for (uint8_t lod = 0; lod < ti.numMips; ++lod)
+ {
+ bimg::ImageMip mip;
+ if (bimg::imageGetRawData(imageContainer, side, lod + startLod, _mem->data, _mem->size, mip))
+ {
+ if (convert)
+ {
+ const uint32_t pitch = bx::strideAlign(bx::max<uint32_t>(mip.m_width, 4) * bpp / 8, alignment);
+ const uint32_t slice = bx::strideAlign(bx::max<uint32_t>(mip.m_height, 4) * pitch, alignment);
+ const uint32_t size = slice * mip.m_depth;
+
+ uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, size);
+ bimg::imageDecodeToBgra8(
+ g_allocator
+ , temp
+ , mip.m_data
+ , mip.m_width
+ , mip.m_height
+ , pitch
+ , mip.m_format
+ );
+
+ imageInfos[kk].data = temp;
+ imageInfos[kk].width = mip.m_width;
+ imageInfos[kk].height = mip.m_height;
+ imageInfos[kk].depth = mip.m_depth;
+ imageInfos[kk].pitch = pitch;
+ imageInfos[kk].slice = slice;
+ imageInfos[kk].size = size;
+ imageInfos[kk].mipLevel = lod;
+ imageInfos[kk].layer = side;
+ }
+ else if (compressed)
+ {
+ const uint32_t pitch = bx::strideAlign((mip.m_width / blockInfo.blockWidth) * mip.m_blockSize, alignment);
+ const uint32_t slice = bx::strideAlign((mip.m_height / blockInfo.blockHeight) * pitch, alignment);
+ const uint32_t size = slice * mip.m_depth;
+
+ uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, size);
+ bimg::imageCopy(
+ temp
+ , mip.m_height / blockInfo.blockHeight
+ , (mip.m_width / blockInfo.blockWidth) * mip.m_blockSize
+ , mip.m_depth
+ , mip.m_data
+ , pitch
+ );
+
+ imageInfos[kk].data = temp;
+ imageInfos[kk].width = mip.m_width;
+ imageInfos[kk].height = mip.m_height;
+ imageInfos[kk].depth = mip.m_depth;
+ imageInfos[kk].pitch = pitch;
+ imageInfos[kk].slice = slice;
+ imageInfos[kk].size = size;
+ imageInfos[kk].mipLevel = lod;
+ imageInfos[kk].layer = side;
+ }
+ else
+ {
+ const uint32_t pitch = bx::strideAlign(mip.m_width * mip.m_bpp / 8, alignment);
+ const uint32_t slice = bx::strideAlign(mip.m_height * pitch, alignment);
+
+ uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, slice);
+ bimg::imageCopy(temp
+ , mip.m_height
+ , mip.m_width * mip.m_bpp / 8
+ , mip.m_depth
+ , mip.m_data
+ , pitch
+ );
+
+ imageInfos[kk].data = temp;
+ imageInfos[kk].width = mip.m_width;
+ imageInfos[kk].height = mip.m_height;
+ imageInfos[kk].depth = mip.m_depth;
+ imageInfos[kk].pitch = pitch;
+ imageInfos[kk].slice = slice;
+ imageInfos[kk].size = slice;
+ imageInfos[kk].mipLevel = lod;
+ imageInfos[kk].layer = side;
+ }
+ }
+ ++kk;
+ }
+ }
+
+ uint32_t totalMemSize = 0;
+ VkBufferImageCopy* bufferCopyInfo = (VkBufferImageCopy*)BX_ALLOC(g_allocator, sizeof(VkBufferImageCopy) * numSrd);
+ for (uint32_t ii = 0; ii < numSrd; ++ii)
+ {
+ uint32_t idealWidth = bx::max<uint32_t>(1, m_width >> imageInfos[ii].mipLevel);
+ uint32_t idealHeight = bx::max<uint32_t>(1, m_height >> imageInfos[ii].mipLevel);
+ bufferCopyInfo[ii].bufferOffset = totalMemSize;
+ bufferCopyInfo[ii].bufferRowLength = 0; // assume that image data are tightly aligned
+ bufferCopyInfo[ii].bufferImageHeight = 0; // assume that image data are tightly aligned
+ bufferCopyInfo[ii].imageSubresource.aspectMask = m_vkTextureAspect;
+ bufferCopyInfo[ii].imageSubresource.mipLevel = imageInfos[ii].mipLevel;
+ bufferCopyInfo[ii].imageSubresource.baseArrayLayer = imageInfos[ii].layer;
+ bufferCopyInfo[ii].imageSubresource.layerCount = 1;
+ bufferCopyInfo[ii].imageOffset = { 0, 0, 0 };
+ bufferCopyInfo[ii].imageExtent = { idealWidth, idealHeight, imageInfos[ii].depth };
+ totalMemSize += imageInfos[ii].size;
+ }
+
+ VkBuffer stagingBuffer = VK_NULL_HANDLE;
+ VkDeviceMemory stagingDeviceMem = VK_NULL_HANDLE;
+ if (totalMemSize > 0)
+ {
+ // staging buffer creation
+ VkBufferCreateInfo bci;
+ bci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
+ bci.pNext = NULL;
+ bci.flags = 0;
+ bci.size = totalMemSize;
+ bci.queueFamilyIndexCount = 0;
+ bci.pQueueFamilyIndices = NULL;
+ bci.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
+ bci.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
+ VK_CHECK(vkCreateBuffer(
+ device
+ , &bci
+ , allocatorCb
+ , &stagingBuffer
+ ));
+
+ VkMemoryRequirements mr;
+ vkGetBufferMemoryRequirements(
+ device
+ , stagingBuffer
+ , &mr
+ );
+
+ VkMemoryAllocateInfo ma;
+ ma.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
+ ma.pNext = NULL;
+ ma.allocationSize = mr.size;
+ ma.memoryTypeIndex = s_renderVK->selectMemoryType(
+ mr.memoryTypeBits
+ , VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
+ );
+ VK_CHECK(vkAllocateMemory(
+ device
+ , &ma
+ , allocatorCb
+ , &stagingDeviceMem
+ ));
+
+ VK_CHECK(vkBindBufferMemory(
+ device
+ , stagingBuffer
+ , stagingDeviceMem
+ , 0
+ ));
+ VK_CHECK(vkMapMemory(
+ device
+ , stagingDeviceMem
+ , 0
+ , ma.allocationSize
+ , 0
+ , (void**)& m_directAccessPtr
+ ));
+
+ uint8_t* mappedMemory = (uint8_t*)m_directAccessPtr;
+
+ // copy image to staging buffer
+ for (uint32_t ii = 0; ii < numSrd; ++ii)
+ {
+ bx::memCopy(mappedMemory, imageInfos[ii].data, imageInfos[ii].size);
+ mappedMemory += imageInfos[ii].size;
+ }
+
+ vkUnmapMemory(device, stagingDeviceMem);
+ }
+
+ // create texture and allocate its device memory
+ VkImageCreateInfo ici;
+ ici.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
+ ici.pNext = NULL;
+ ici.flags = VK_IMAGE_VIEW_TYPE_CUBE == m_type
+ ? VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT
+ : 0
+ ;
+ ici.pQueueFamilyIndices = NULL;
+ ici.queueFamilyIndexCount = 0;
+ ici.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
+ ici.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
+ ici.usage = 0
+ | VK_IMAGE_USAGE_TRANSFER_SRC_BIT
+ | VK_IMAGE_USAGE_TRANSFER_DST_BIT
+ | VK_IMAGE_USAGE_SAMPLED_BIT
+ | (_flags & BGFX_TEXTURE_RT_MASK
+ ? (bimg::isDepth((bimg::TextureFormat::Enum)m_textureFormat)
+ ? VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
+ : VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT)
+ : 0
+ )
+ | (_flags & BGFX_TEXTURE_COMPUTE_WRITE ? VK_IMAGE_USAGE_STORAGE_BIT : 0)
+ ;
+ ici.format = bimg::isDepth(bimg::TextureFormat::Enum(m_textureFormat) )
+ ? s_textureFormat[m_textureFormat].m_fmtDsv
+ : s_textureFormat[m_textureFormat].m_fmt
+ ;
+ ici.samples = VK_SAMPLE_COUNT_1_BIT;
+ ici.mipLevels = m_numMips;
+ ici.arrayLayers = m_numSides;
+ ici.extent.width = m_width;
+ ici.extent.height = m_height;
+ ici.extent.depth = m_depth;
+ ici.imageType = VK_IMAGE_VIEW_TYPE_3D == m_type
+ ? VK_IMAGE_TYPE_3D
+ : VK_IMAGE_TYPE_2D
+ ;
+ ici.tiling = VK_IMAGE_TILING_OPTIMAL;
+
+ VK_CHECK(vkCreateImage(device, &ici, allocatorCb, &m_textureImage));
+
+ VkMemoryRequirements imageMemReq;
+ vkGetImageMemoryRequirements(device, m_textureImage, &imageMemReq);
+
+ VkMemoryAllocateInfo imai;
+ imai.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
+ imai.pNext = NULL;
+ imai.allocationSize = imageMemReq.size;
+ imai.memoryTypeIndex = s_renderVK->selectMemoryType(
+ imageMemReq.memoryTypeBits
+ , VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
+ );
+
+ VK_CHECK(vkAllocateMemory(device, &imai, allocatorCb, &m_textureDeviceMem));
+
+ vkBindImageMemory(device, m_textureImage, m_textureDeviceMem, 0);
+
+ if (stagingBuffer)
+ {
+ copyBufferToTexture(stagingBuffer, numSrd, bufferCopyInfo);
+ }
+ else
+ {
+ VkCommandBuffer commandBuffer = s_renderVK->beginNewCommand();
+ setImageMemoryBarrier(
+ commandBuffer
+ , (m_flags & BGFX_TEXTURE_COMPUTE_WRITE
+ ? VK_IMAGE_LAYOUT_GENERAL
+ : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
+ )
+ );
+ s_renderVK->submitCommandAndWait(commandBuffer);
+ }
+
+ vkFreeMemory(device, stagingDeviceMem, allocatorCb);
+ vkDestroy(stagingBuffer);
+
+ BX_FREE(g_allocator, bufferCopyInfo);
+ for (uint32_t ii = 0; ii < numSrd; ++ii)
+ {
+ BX_FREE(g_allocator, imageInfos[ii].data);
+ }
+ BX_FREE(g_allocator, imageInfos);
+
+ // image view creation
+ {
+ VkImageViewCreateInfo viewInfo;
+ viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
+ viewInfo.pNext = NULL;
+ viewInfo.flags = 0;
+ viewInfo.image = m_textureImage;
+ viewInfo.viewType = m_type;
+ viewInfo.format = m_vkTextureFormat;
+ viewInfo.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
+ viewInfo.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
+ viewInfo.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
+ viewInfo.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
+ viewInfo.subresourceRange.aspectMask = m_vkTextureAspect;
+ viewInfo.subresourceRange.baseMipLevel = 0;
+ viewInfo.subresourceRange.levelCount = m_numMips; //m_numMips;
+ viewInfo.subresourceRange.baseArrayLayer = 0;
+ viewInfo.subresourceRange.layerCount = m_numSides; //(m_type == VK_IMAGE_VIEW_TYPE_CUBE ? 6 : m_numLayers);
+ VK_CHECK(vkCreateImageView(
+ device
+ , &viewInfo
+ , allocatorCb
+ , &m_textureImageView
+ ));
+ }
+
+ if ((m_vkTextureAspect & VK_IMAGE_ASPECT_DEPTH_BIT)
+ && (m_vkTextureAspect & VK_IMAGE_ASPECT_STENCIL_BIT))
+ {
+ VkImageViewCreateInfo viewInfo;
+ viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
+ viewInfo.pNext = NULL;
+ viewInfo.flags = 0;
+ viewInfo.image = m_textureImage;
+ viewInfo.viewType = m_type;
+ viewInfo.format = m_vkTextureFormat;
+ viewInfo.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
+ viewInfo.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
+ viewInfo.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
+ viewInfo.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
+ viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
+ viewInfo.subresourceRange.baseMipLevel = 0;
+ viewInfo.subresourceRange.levelCount = m_numMips; //m_numMips;
+ viewInfo.subresourceRange.baseArrayLayer = 0;
+ viewInfo.subresourceRange.layerCount = m_numSides; //(m_type == VK_IMAGE_VIEW_TYPE_CUBE ? 6 : m_numLayers);
+ VK_CHECK(vkCreateImageView(
+ device
+ , &viewInfo
+ , allocatorCb
+ , &m_textureImageDepthView
+ ));
+ }
+
+ // image view creation for storage if needed
+ if (m_flags & BGFX_TEXTURE_COMPUTE_WRITE)
+ {
+ VkImageViewCreateInfo viewInfo;
+ viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
+ viewInfo.pNext = NULL;
+ viewInfo.flags = 0;
+ viewInfo.image = m_textureImage;
+ viewInfo.viewType = (m_type == VK_IMAGE_VIEW_TYPE_CUBE ? VK_IMAGE_VIEW_TYPE_2D_ARRAY : m_type);
+ viewInfo.format = m_vkTextureFormat;
+ viewInfo.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
+ viewInfo.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
+ viewInfo.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
+ viewInfo.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
+ viewInfo.subresourceRange.aspectMask = m_vkTextureAspect;
+ viewInfo.subresourceRange.baseMipLevel = 0;
+ viewInfo.subresourceRange.levelCount = m_numMips; //m_numMips;
+ viewInfo.subresourceRange.baseArrayLayer = 0;
+ viewInfo.subresourceRange.layerCount = m_numSides; //(m_type == VK_IMAGE_VIEW_TYPE_CUBE ? 6 : m_numLayers);
+ VK_CHECK(vkCreateImageView(
+ device
+ , &viewInfo
+ , allocatorCb
+ , &m_textureImageStorageView
+ ));
+ }
+ }
+
+ return m_directAccessPtr;
+ }
+
void TextureVK::destroy()
{
+ if (m_textureImage)
+ {
+ VkAllocationCallbacks* allocatorCb = s_renderVK->m_allocatorCb;
+ VkDevice device = s_renderVK->m_device;
+
+ vkFreeMemory(device, m_textureDeviceMem, allocatorCb);
+
+ vkDestroy(m_textureImageStorageView);
+ vkDestroy(m_textureImageDepthView);
+ vkDestroy(m_textureImageView);
+ vkDestroy(m_textureImage);
+
+ m_currentImageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
+ }
+ }
+
+ void TextureVK::update(VkCommandPool _commandPool, uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem)
+ {
+ BX_UNUSED(_commandPool);
+
+ VkAllocationCallbacks* allocatorCb = s_renderVK->m_allocatorCb;
+ VkDevice device = s_renderVK->m_device;
+
+ VkBuffer stagingBuffer = VK_NULL_HANDLE;
+ VkDeviceMemory stagingDeviceMem = VK_NULL_HANDLE;
+
+ // staging buffer creation
+ VkBufferCreateInfo bci;
+ bci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
+ bci.pNext = NULL;
+ bci.flags = 0;
+ bci.size = (_pitch == UINT16_MAX ? _mem->size :_rect.m_height * _pitch * _depth);
+ bci.queueFamilyIndexCount = 0;
+ bci.pQueueFamilyIndices = NULL;
+ bci.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
+ bci.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
+ VK_CHECK(vkCreateBuffer(
+ device
+ , &bci
+ , allocatorCb
+ , &stagingBuffer
+ ));
+
+ VkMemoryRequirements mr;
+ vkGetBufferMemoryRequirements(
+ device
+ , stagingBuffer
+ , &mr
+ );
+
+ VkMemoryAllocateInfo ma;
+ ma.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
+ ma.pNext = NULL;
+ ma.allocationSize = mr.size;
+ ma.memoryTypeIndex = s_renderVK->selectMemoryType(
+ mr.memoryTypeBits
+ , VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
+ );
+ VK_CHECK(vkAllocateMemory(
+ device
+ , &ma
+ , allocatorCb
+ , &stagingDeviceMem
+ ));
+
+ void* directAccessPtr = NULL;
+ VK_CHECK(vkBindBufferMemory(device, stagingBuffer, stagingDeviceMem, 0));
+ VK_CHECK(vkMapMemory(device, stagingDeviceMem, 0, ma.allocationSize, 0, (void**)&directAccessPtr));
+ bx::memCopy(directAccessPtr, _mem->data, size_t(bci.size));
+ vkUnmapMemory(device, stagingDeviceMem);
+
+ const uint32_t bpp = bimg::getBitsPerPixel(bimg::TextureFormat::Enum(m_textureFormat) );
+ VkBufferImageCopy region;
+ region.bufferOffset = 0;
+ region.bufferRowLength = (_pitch == UINT16_MAX ? 0 : _pitch * 8 / bpp);
+ region.bufferImageHeight = 0;
+ region.imageSubresource.aspectMask = m_vkTextureAspect;
+ region.imageSubresource.mipLevel = _mip;
+ region.imageSubresource.baseArrayLayer = _side;
+ region.imageSubresource.layerCount = 1;
+ region.imageOffset = { _rect.m_x, _rect.m_y, _z };
+ region.imageExtent = { _rect.m_width, _rect.m_height, _depth };
+
+ copyBufferToTexture(stagingBuffer, 1, &region);
+
+ vkFreeMemory(device, stagingDeviceMem, allocatorCb);
+ vkDestroy(stagingBuffer);
+ }
+
+ void TextureVK::copyBufferToTexture(VkBuffer stagingBuffer, uint32_t bufferImageCopyCount, VkBufferImageCopy* bufferImageCopy)
+ {
+ VkCommandBuffer commandBuffer = s_renderVK->beginNewCommand();
+
+ // image Layout transition into destination optimal
+ setImageMemoryBarrier(commandBuffer, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
+
+ // copy buffer to image
+ vkCmdCopyBufferToImage(
+ commandBuffer
+ , stagingBuffer
+ , m_textureImage
+ , VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
+ , bufferImageCopyCount
+ , bufferImageCopy
+ );
+
+ setImageMemoryBarrier(commandBuffer, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
+ s_renderVK->submitCommandAndWait(commandBuffer);
+ }
+
+ void TextureVK::setImageMemoryBarrier(VkCommandBuffer commandBuffer, VkImageLayout newImageLayout)
+ {
+ if (m_currentImageLayout == newImageLayout)
+ return;
+ bgfx::vk::setImageMemoryBarrier(commandBuffer
+ , m_textureImage
+ , m_vkTextureAspect
+ , m_currentImageLayout
+ , newImageLayout
+ , m_numMips
+ , m_numSides
+ );
+ m_currentImageLayout = newImageLayout;
+ }
+
+ void FrameBufferVK::create(uint8_t _num, const Attachment* _attachment)
+ {
+ // create frame buffer object
+ m_numAttachment = _num;
+ bx::memCopy(m_attachment, _attachment, sizeof(Attachment) * _num);
+
+ VkDevice device = s_renderVK->m_device;
+ VkAllocationCallbacks* allocatorCb = s_renderVK->m_allocatorCb;
+ VkRenderPass renderPass = s_renderVK->getRenderPass(_num, _attachment);
+
+ TextureVK& firstTexture = s_renderVK->m_textures[m_attachment[0].handle.idx];
+ ::VkImageView textureImageViews[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
+
+ m_num = 0;
+ for (uint8_t ii = 0; ii < m_numAttachment; ++ii)
+ {
+ TextureVK& texture = s_renderVK->m_textures[m_attachment[ii].handle.idx];
+ textureImageViews[ii] = texture.m_textureImageView;
+ if (texture.m_vkTextureAspect & VK_IMAGE_ASPECT_COLOR_BIT)
+ {
+ m_texture[m_num] = m_attachment[ii].handle;
+ m_num++;
+ }
+ else if (texture.m_vkTextureAspect & VK_IMAGE_ASPECT_DEPTH_BIT)
+ {
+ m_depth = m_attachment[ii].handle;
+ }
+ }
+
+ VkFramebufferCreateInfo fci;
+ fci.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
+ fci.pNext = NULL;
+ fci.flags = 0;
+ fci.renderPass = renderPass;
+ fci.attachmentCount = m_numAttachment;
+ fci.pAttachments = textureImageViews;
+ fci.width = firstTexture.m_width >> m_attachment[0].mip;
+ fci.height = firstTexture.m_height >> m_attachment[0].mip;
+ fci.layers = firstTexture.m_numSides;
+ VK_CHECK( vkCreateFramebuffer(device, &fci, allocatorCb, &m_framebuffer) );
+ m_renderPass = renderPass;
}
void FrameBufferVK::destroy()
{
+ vkDestroy(m_framebuffer);
}
void RendererContextVK::submitBlit(BlitState& _bs, uint16_t _view)
{
+ TextureHandle currentSrc = { kInvalidHandle };
+ TextureHandle currentDst = { kInvalidHandle };
+ VkImageLayout oldSrcLayout = VK_IMAGE_LAYOUT_UNDEFINED;
+ VkImageLayout oldDstLayout = VK_IMAGE_LAYOUT_UNDEFINED;
+
+ VkCommandBuffer commandBuffer = beginNewCommand();
while (_bs.hasItem(_view) )
{
const BlitItem& blit = _bs.advance();
- BX_UNUSED(blit);
+
+ TextureVK& src = m_textures[blit.m_src.idx];
+ TextureVK& dst = m_textures[blit.m_dst.idx];
+
+ if (currentSrc.idx != blit.m_src.idx)
+ {
+ if (oldSrcLayout != VK_IMAGE_LAYOUT_UNDEFINED)
+ {
+ m_textures[currentSrc.idx].setImageMemoryBarrier(commandBuffer, oldSrcLayout);
+ }
+ oldSrcLayout = src.m_currentImageLayout;
+ src.setImageMemoryBarrier(commandBuffer, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
+ currentSrc = blit.m_src;
+ }
+
+ if (currentDst.idx != blit.m_dst.idx)
+ {
+ if (oldDstLayout != VK_IMAGE_LAYOUT_UNDEFINED)
+ {
+ m_textures[currentDst.idx].setImageMemoryBarrier(commandBuffer, oldDstLayout);
+ }
+ oldDstLayout = dst.m_currentImageLayout;
+ dst.setImageMemoryBarrier(commandBuffer, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
+ currentDst = blit.m_dst;
+ }
+
+ uint32_t srcZ = (VK_IMAGE_VIEW_TYPE_CUBE == src.m_type ? 0 : blit.m_srcZ);
+ uint32_t dstZ = (VK_IMAGE_VIEW_TYPE_CUBE == dst.m_type ? 0 : blit.m_dstZ);
+ uint32_t srcLayer = (VK_IMAGE_VIEW_TYPE_CUBE == src.m_type ? blit.m_srcZ : 0);
+ uint32_t dstLayer = (VK_IMAGE_VIEW_TYPE_CUBE == dst.m_type ? blit.m_dstZ : 0);
+ uint32_t depth = (blit.m_depth == UINT16_MAX ? 1 : blit.m_depth);
+
+ VkImageBlit blitInfo;
+ blitInfo.srcSubresource.aspectMask = src.m_vkTextureAspect;
+ blitInfo.srcSubresource.mipLevel = blit.m_srcMip;
+ blitInfo.srcSubresource.baseArrayLayer = srcLayer;
+ blitInfo.srcSubresource.layerCount = 1;
+ blitInfo.srcOffsets[0].x = blit.m_srcX;
+ blitInfo.srcOffsets[0].y = blit.m_srcY;
+ blitInfo.srcOffsets[0].z = srcZ;
+ blitInfo.srcOffsets[1].x = blit.m_srcX + blit.m_width;
+ blitInfo.srcOffsets[1].y = blit.m_srcY + blit.m_height;
+ blitInfo.srcOffsets[1].z = srcZ + depth;
+ blitInfo.dstSubresource.aspectMask = dst.m_vkTextureAspect;
+ blitInfo.dstSubresource.mipLevel = blit.m_dstMip;
+ blitInfo.dstSubresource.baseArrayLayer = dstLayer;
+ blitInfo.dstSubresource.layerCount = 1;
+ blitInfo.dstOffsets[0].x = blit.m_dstX;
+ blitInfo.dstOffsets[0].y = blit.m_dstY;
+ blitInfo.dstOffsets[0].z = dstZ;
+ blitInfo.dstOffsets[1].x = blit.m_dstX + blit.m_width;
+ blitInfo.dstOffsets[1].y = blit.m_dstY + blit.m_height;
+ blitInfo.dstOffsets[1].z = dstZ + depth;
+ vkCmdBlitImage(
+ commandBuffer
+ , src.m_textureImage
+ , src.m_currentImageLayout
+ , dst.m_textureImage
+ , dst.m_currentImageLayout
+ , 1
+ , &blitInfo
+ , VK_FILTER_LINEAR
+ );
+ }
+
+ if (oldSrcLayout != VK_IMAGE_LAYOUT_UNDEFINED)
+ {
+ m_textures[currentSrc.idx].setImageMemoryBarrier(commandBuffer, oldSrcLayout);
+ }
+ if (oldDstLayout != VK_IMAGE_LAYOUT_UNDEFINED)
+ {
+ m_textures[currentDst.idx].setImageMemoryBarrier(commandBuffer, oldDstLayout);
}
+ submitCommandAndWait(commandBuffer);
}
void RendererContextVK::submit(Frame* _render, ClearQuad& _clearQuad, TextVideoMemBlitter& _textVideoMemBlitter)
@@ -3662,14 +5675,16 @@ VK_DESTROY
if (0 < _render->m_iboffset)
{
-// TransientIndexBuffer* ib = _render->m_transientIb;
-// m_indexBuffers[ib->handle.idx].update(m_commandList, 0, _render->m_iboffset, ib->data);
+ BGFX_PROFILER_SCOPE("bgfx/Update transient index buffer", kColorResource);
+ TransientIndexBuffer* ib = _render->m_transientIb;
+ m_indexBuffers[ib->handle.idx].update(/*m_commandList*/NULL, 0, _render->m_iboffset, ib->data);
}
if (0 < _render->m_vboffset)
{
-// TransientVertexBuffer* vb = _render->m_transientVb;
-// m_vertexBuffers[vb->handle.idx].update(m_commandList, 0, _render->m_vboffset, vb->data);
+ BGFX_PROFILER_SCOPE("bgfx/Update transient vertex buffer", kColorResource);
+ TransientVertexBuffer* vb = _render->m_transientVb;
+ m_vertexBuffers[vb->handle.idx].update(/*m_commandList*/NULL, 0, _render->m_vboffset, vb->data);
}
_render->sort();
@@ -3679,16 +5694,16 @@ VK_DESTROY
currentState.m_stateFlags = BGFX_STATE_NONE;
currentState.m_stencil = packStencil(BGFX_STENCIL_NONE, BGFX_STENCIL_NONE);
- const bool hmdEnabled = false;
- ViewState viewState(_render, hmdEnabled);
- viewState.reset(_render, hmdEnabled);
+ static ViewState viewState;
+ viewState.reset(_render);
// bool wireframe = !!(_render->m_debug&BGFX_DEBUG_WIREFRAME);
// setDebugWireframe(wireframe);
uint16_t currentSamplerStateIdx = kInvalidHandle;
- uint16_t currentProgramIdx = kInvalidHandle;
+ ProgramHandle currentProgram = BGFX_INVALID_HANDLE;
uint32_t currentBindHash = 0;
+ uint32_t currentDslHash = 0;
bool hasPredefined = false;
bool commandListChanged = false;
VkPipeline currentPipeline = VK_NULL_HANDLE;
@@ -3704,7 +5719,7 @@ VK_DESTROY
uint8_t primIndex = uint8_t(primType >> BGFX_STATE_PT_SHIFT);
PrimInfo prim = s_primInfo[primIndex];
- bool wasCompute = false;
+ bool wasCompute = false;
bool viewHasScissor = false;
bool restoreScissor = false;
Rect viewScissorRect;
@@ -3720,21 +5735,31 @@ VK_DESTROY
uint32_t statsKeyType[2] = {};
VkSemaphore renderWait = m_presentDone[m_backBufferColorIdx];
- VK_CHECK(vkAcquireNextImageKHR(m_device
- , m_swapchain
- , UINT64_MAX
- , renderWait
- , VK_NULL_HANDLE
- , &m_backBufferColorIdx
- ) );
+ VkResult result = vkAcquireNextImageKHR(
+ m_device
+ , m_swapchain
+ , UINT64_MAX
+ , renderWait
+ , VK_NULL_HANDLE
+ , &m_backBufferColorIdx
+ );
- const uint64_t f0 = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_FACTOR, BGFX_STATE_BLEND_FACTOR);
- const uint64_t f1 = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_INV_FACTOR, BGFX_STATE_BLEND_INV_FACTOR);
+ if (VK_ERROR_OUT_OF_DATE_KHR == result
+ || VK_SUBOPTIMAL_KHR == result)
+ {
+ m_needToRefreshSwapchain = true;
+ return;
+ }
+// const uint64_t f0 = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_FACTOR, BGFX_STATE_BLEND_FACTOR);
+// const uint64_t f1 = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_INV_FACTOR, BGFX_STATE_BLEND_INV_FACTOR);
+ const uint64_t f0 = BGFX_STATE_BLEND_FACTOR;
+ const uint64_t f1 = BGFX_STATE_BLEND_INV_FACTOR;
+ const uint64_t f2 = BGFX_STATE_BLEND_FACTOR<<4;
+ const uint64_t f3 = BGFX_STATE_BLEND_INV_FACTOR<<4;
ScratchBufferVK& scratchBuffer = m_scratchBuffer[m_backBufferColorIdx];
- VkDescriptorBufferInfo descriptorBufferInfo;
- scratchBuffer.reset(descriptorBufferInfo);
+ scratchBuffer.reset();
VkCommandBufferBeginInfo cbbi;
cbbi.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
@@ -3750,9 +5775,11 @@ VK_DESTROY
setImageMemoryBarrier(m_commandBuffer
, m_backBufferColorImage[m_backBufferColorIdx]
- , VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
+ , VK_IMAGE_ASPECT_COLOR_BIT
+ , m_backBufferColorImageLayout[m_backBufferColorIdx]
, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
- );
+ , 1, 1);
+ m_backBufferColorImageLayout[m_backBufferColorIdx] = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
VkRenderPassBeginInfo rpbi;
rpbi.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
@@ -3771,12 +5798,10 @@ VK_DESTROY
{
// m_batch.begin();
-// uint8_t eye = 0;
-// uint8_t restartState = 0;
viewState.m_rect = _render->m_view[0].m_rect;
int32_t numItems = _render->m_numRenderItems;
- for (int32_t item = 0, restartItem = numItems; item < numItems || restartItem < numItems;)
+ for (int32_t item = 0; item < numItems;)
{
const uint64_t encodedKey = _render->m_sortKeys[item];
const bool isCompute = key.decode(encodedKey, _render->m_viewRemap);
@@ -3792,12 +5817,17 @@ VK_DESTROY
const RenderBind& renderBind = _render->m_renderItemBind[itemIdx];
++item;
- if (viewChanged)
+ if (viewChanged || isCompute || wasCompute)
{
if (beginRenderPass)
{
vkCmdEndRenderPass(m_commandBuffer);
beginRenderPass = false;
+
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) && s_extension[Extension::EXT_debug_utils].m_supported )
+ {
+ vkCmdEndDebugUtilsLabelEXT(m_commandBuffer);
+ }
}
VK_CHECK(vkEndCommandBuffer(m_commandBuffer) );
@@ -3805,15 +5835,16 @@ VK_DESTROY
// m_batch.flush(m_commandList, true);
kick(renderWait);
renderWait = VK_NULL_HANDLE;
-finishAll();
+ finishAll();
view = key.m_view;
currentPipeline = VK_NULL_HANDLE;
currentSamplerStateIdx = kInvalidHandle;
-BX_UNUSED(currentSamplerStateIdx);
- currentProgramIdx = kInvalidHandle;
+ BX_UNUSED(currentSamplerStateIdx);
+ currentProgram = BGFX_INVALID_HANDLE;
hasPredefined = false;
+ VK_CHECK(vkBeginCommandBuffer(m_commandBuffer, &cbbi) );
fbh = _render->m_view[view].m_fbh;
setFrameBuffer(fbh);
@@ -3823,43 +5854,61 @@ BX_UNUSED(currentSamplerStateIdx);
viewHasScissor = !scissorRect.isZero();
viewScissorRect = viewHasScissor ? scissorRect : rect;
+ rpbi.framebuffer = isValid(m_fbh) ? m_frameBuffers[m_fbh.idx].m_framebuffer : m_backBufferColor[m_backBufferColorIdx];
+ rpbi.renderPass = isValid(m_fbh) ? m_frameBuffers[m_fbh.idx].m_renderPass : m_renderPass;
rpbi.renderArea.offset.x = rect.m_x;
rpbi.renderArea.offset.y = rect.m_y;
rpbi.renderArea.extent.width = rect.m_width;
rpbi.renderArea.extent.height = rect.m_height;
- VK_CHECK(vkBeginCommandBuffer(m_commandBuffer, &cbbi) );
- vkCmdBeginRenderPass(m_commandBuffer, &rpbi, VK_SUBPASS_CONTENTS_INLINE);
- beginRenderPass = true;
-
- VkViewport vp;
- vp.x = rect.m_x;
- vp.y = rect.m_y;
- vp.width = rect.m_width;
- vp.height = rect.m_height;
- vp.minDepth = 0.0f;
- vp.maxDepth = 1.0f;
- vkCmdSetViewport(m_commandBuffer, 0, 1, &vp);
-
- VkRect2D rc;
- rc.offset.x = viewScissorRect.m_x;
- rc.offset.y = viewScissorRect.m_y;
- rc.extent.width = viewScissorRect.m_x + viewScissorRect.m_width;
- rc.extent.height = viewScissorRect.m_y + viewScissorRect.m_height;
- vkCmdSetScissor(m_commandBuffer, 0, 1, &rc);
-
- restoreScissor = false;
-
- Clear& clr = _render->m_view[view].m_clear;
- if (BGFX_CLEAR_NONE != clr.m_flags)
+
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) && s_extension[Extension::EXT_debug_utils].m_supported )
{
- Rect clearRect = rect;
- clearRect.setIntersect(rect, viewScissorRect);
- clearQuad(clearRect, clr, _render->m_colorPalette);
+ VkDebugUtilsLabelEXT dul;
+ dul.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
+ dul.pNext = NULL;
+ dul.pLabelName = s_viewName[view];
+ dul.color[0] = 1.0f;
+ dul.color[1] = 1.0f;
+ dul.color[2] = 1.0f;
+ dul.color[3] = 1.0f;
+ vkCmdBeginDebugUtilsLabelEXT(m_commandBuffer, &dul);
}
- prim = s_primInfo[Topology::Count]; // Force primitive type update.
+ if (!isCompute && !beginRenderPass)
+ {
+ vkCmdBeginRenderPass(m_commandBuffer, &rpbi, VK_SUBPASS_CONTENTS_INLINE);
+ beginRenderPass = true;
+
+ VkViewport vp;
+ vp.x = rect.m_x;
+ vp.y = rect.m_y;
+ vp.width = rect.m_width;
+ vp.height = rect.m_height;
+ vp.minDepth = 0.0f;
+ vp.maxDepth = 1.0f;
+ vkCmdSetViewport(m_commandBuffer, 0, 1, &vp);
+
+ VkRect2D rc;
+ rc.offset.x = viewScissorRect.m_x;
+ rc.offset.y = viewScissorRect.m_y;
+ rc.extent.width = viewScissorRect.m_width;
+ rc.extent.height = viewScissorRect.m_height;
+ vkCmdSetScissor(m_commandBuffer, 0, 1, &rc);
+
+ restoreScissor = false;
+
+ Clear& clr = _render->m_view[view].m_clear;
+ if (BGFX_CLEAR_NONE != clr.m_flags)
+ {
+ Rect clearRect = rect;
+ clearRect.setIntersect(rect, viewScissorRect);
+ clearQuad(clearRect, clr, _render->m_colorPalette);
+ }
+
+ prim = s_primInfo[Topology::Count]; // Force primitive type update.
- submitBlit(bs, view);
+ submitBlit(bs, view);
+ }
}
if (isCompute)
@@ -3884,104 +5933,17 @@ BX_UNUSED(currentSamplerStateIdx);
currentPipeline = pipeline;
vkCmdBindPipeline(m_commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
currentBindHash = 0;
+ currentDslHash = 0;
}
-// uint32_t bindHash = bx::hash<bx::HashMurmur2A>(renderBind.m_bind, sizeof(renderBind.m_bind) );
-// if (currentBindHash != bindHash)
-// {
-// currentBindHash = bindHash;
-//
-// Bind* bindCached = bindLru.find(bindHash);
-// if (NULL == bindCached)
-// {
-// D3D12_GPU_DESCRIPTOR_HANDLE srvHandle[BGFX_MAX_COMPUTE_BINDINGS] = {};
-// uint32_t samplerFlags[BGFX_MAX_COMPUTE_BINDINGS] = {};
-//
-// for (uint32_t ii = 0; ii < maxComputeBindings; ++ii)
-// {
-// const Binding& bind = renderBind.m_bind[ii];
-// if (kInvalidHandle != bind.m_idx)
-// {
-// switch (bind.m_type)
-// {
-// case Binding::Image:
-// {
-// TextureD3D12& texture = m_textures[bind.m_idx];
-//
-// if (Access::Read != bind.m_access)
-// {
-// texture.setState(m_commandList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
-// scratchBuffer.allocUav(srvHandle[ii], texture, bind.m_mip);
-// }
-// else
-// {
-// texture.setState(m_commandList, D3D12_RESOURCE_STATE_GENERIC_READ);
-// scratchBuffer.allocSrv(srvHandle[ii], texture, bind.m_mip);
-// samplerFlags[ii] = texture.m_flags;
-// }
-// }
-// break;
-//
-// case Binding::IndexBuffer:
-// case Binding::VertexBuffer:
-// {
-// BufferD3D12& buffer = Binding::IndexBuffer == bind.m_type
-// ? m_indexBuffers[bind.m_idx]
-// : m_vertexBuffers[bind.m_idx]
-// ;
-//
-// if (Access::Read != bind.m_access)
-// {
-// buffer.setState(m_commandList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
-// scratchBuffer.allocUav(srvHandle[ii], buffer);
-// }
-// else
-// {
-// buffer.setState(m_commandList, D3D12_RESOURCE_STATE_GENERIC_READ);
-// scratchBuffer.allocSrv(srvHandle[ii], buffer);
-// }
-// }
-// break;
-// }
-// }
-// }
-//
-// uint16_t samplerStateIdx = getSamplerState(samplerFlags, maxComputeBindings, _render->m_colorPalette);
-// if (samplerStateIdx != currentSamplerStateIdx)
-// {
-// currentSamplerStateIdx = samplerStateIdx;
-// m_commandList->SetComputeRootDescriptorTable(Rdt::Sampler, m_samplerAllocator.get(samplerStateIdx) );
-// }
-//
-// m_commandList->SetComputeRootDescriptorTable(Rdt::SRV, srvHandle[0]);
-// m_commandList->SetComputeRootDescriptorTable(Rdt::UAV, srvHandle[0]);
-//
-// Bind bind;
-// bind.m_srvHandle = srvHandle[0];
-// bind.m_samplerStateIdx = samplerStateIdx;
-// bindLru.add(bindHash, bind, 0);
-// }
-// else
-// {
-// uint16_t samplerStateIdx = bindCached->m_samplerStateIdx;
-// if (samplerStateIdx != currentSamplerStateIdx)
-// {
-// currentSamplerStateIdx = samplerStateIdx;
-// m_commandList->SetComputeRootDescriptorTable(Rdt::Sampler, m_samplerAllocator.get(samplerStateIdx) );
-// }
-// m_commandList->SetComputeRootDescriptorTable(Rdt::SRV, bindCached->m_srvHandle);
-// m_commandList->SetComputeRootDescriptorTable(Rdt::UAV, bindCached->m_srvHandle);
-// }
-// }
-
bool constantsChanged = false;
if (compute.m_uniformBegin < compute.m_uniformEnd
- || currentProgramIdx != key.m_program)
+ || currentProgram.idx != key.m_program.idx)
{
rendererUpdateUniforms(this, _render->m_uniformBuffer[compute.m_uniformIdx], compute.m_uniformBegin, compute.m_uniformEnd);
- currentProgramIdx = key.m_program;
- ProgramVK& program = m_program[currentProgramIdx];
+ currentProgram = key.m_program;
+ ProgramVK& program = m_program[currentProgram.idx];
UniformBuffer* vcb = program.m_vsh->m_constantBuffer;
if (NULL != vcb)
@@ -3993,15 +5955,54 @@ BX_UNUSED(currentSamplerStateIdx);
constantsChanged = true;
}
+ ProgramVK& program = m_program[currentProgram.idx];
if (constantsChanged
|| hasPredefined)
{
- ProgramVK& program = m_program[currentProgramIdx];
- viewState.setPredefined<4>(this, view, 0, program, _render, compute);
+ viewState.setPredefined<4>(this, view, program, _render, compute);
// commitShaderConstants(key.m_program, gpuAddress);
// m_commandList->SetComputeRootConstantBufferView(Rdt::CBV, gpuAddress);
}
+ uint32_t bindHash = bx::hash<bx::HashMurmur2A>(renderBind.m_bind, sizeof(renderBind.m_bind) );
+ if (currentBindHash != bindHash
+ || currentDslHash != program.m_descriptorSetLayoutHash)
+ {
+ currentBindHash = bindHash;
+ currentDslHash = program.m_descriptorSetLayoutHash;
+
+ allocDescriptorSet(program, renderBind, scratchBuffer);
+ }
+
+ uint32_t offset = 0;
+
+ if (constantsChanged
+ || hasPredefined)
+ {
+ const uint32_t align = uint32_t(m_deviceProperties.limits.minUniformBufferOffsetAlignment);
+ const uint32_t vsize = bx::strideAlign(program.m_vsh->m_size, align);
+
+ offset = scratchBuffer.m_pos;
+
+ m_vsChanges = 0;
+ m_fsChanges = 0;
+
+ bx::memCopy(&scratchBuffer.m_data[scratchBuffer.m_pos], m_vsScratch, program.m_vsh->m_size);
+
+ scratchBuffer.m_pos += vsize;
+ }
+
+ vkCmdBindDescriptorSets(
+ m_commandBuffer
+ , VK_PIPELINE_BIND_POINT_COMPUTE
+ , program.m_pipelineLayout
+ , 0
+ , 1
+ , &scratchBuffer.getCurrentDS()
+ , constantsChanged || hasPredefined ? 1 : 0
+ , &offset
+ );
+
if (isValid(compute.m_indirectBuffer) )
{
const VertexBufferVK& vb = m_vertexBuffers[compute.m_indirectBuffer.idx];
@@ -4014,13 +6015,13 @@ BX_UNUSED(currentSamplerStateIdx);
uint32_t args = compute.m_startIndirect * BGFX_CONFIG_DRAW_INDIRECT_STRIDE;
for (uint32_t ii = 0; ii < numDrawIndirect; ++ii)
{
-// m_commandList->ExecuteIndirect(ptr, args);
+ vkCmdDispatchIndirect(m_commandBuffer, vb.m_buffer, args);
args += BGFX_CONFIG_DRAW_INDIRECT_STRIDE;
}
}
else
{
-// m_commandList->Dispatch(compute.m_numX, compute.m_numY, compute.m_numZ);
+ vkCmdDispatch(m_commandBuffer, compute.m_numX, compute.m_numY, compute.m_numZ);
}
continue;
@@ -4066,7 +6067,7 @@ BX_UNUSED(currentSamplerStateIdx);
wasCompute = false;
}
- if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
{
BX_UNUSED(s_viewName);
// wchar_t* viewNameW = s_viewNameW[view];
@@ -4091,8 +6092,9 @@ BX_UNUSED(currentSamplerStateIdx);
currentPipeline = VK_NULL_HANDLE;
currentBindHash = 0;
+ currentDslHash = 0;
currentSamplerStateIdx = kInvalidHandle;
- currentProgramIdx = kInvalidHandle;
+ currentProgram = BGFX_INVALID_HANDLE;
currentState.clear();
currentState.m_scissor = !draw.m_scissor;
changedFlags = BGFX_STATE_MASK;
@@ -4106,100 +6108,57 @@ BX_UNUSED(currentSamplerStateIdx);
rendererUpdateUniforms(this, _render->m_uniformBuffer[draw.m_uniformIdx], draw.m_uniformBegin, draw.m_uniformEnd);
- if (isValid(draw.m_stream[0].m_handle) )
+ if (0 != draw.m_streamMask)
{
+ currentState.m_streamMask = draw.m_streamMask;
+
const uint64_t state = draw.m_stateFlags;
bool hasFactor = 0
|| f0 == (state & f0)
|| f1 == (state & f1)
+ || f2 == (state & f2)
+ || f3 == (state & f3)
;
- const VertexBufferVK& 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;
+ const VertexLayout* layouts[BGFX_CONFIG_MAX_VERTEX_STREAMS];
+ uint8_t numStreams = 0;
+ if (UINT8_MAX != draw.m_streamMask)
+ {
+ for (uint32_t idx = 0, streamMask = draw.m_streamMask
+ ; 0 != streamMask
+ ; streamMask >>= 1, idx += 1, ++numStreams
+ )
+ {
+ const uint32_t ntz = bx::uint32_cnttz(streamMask);
+ streamMask >>= ntz;
+ idx += ntz;
+
+ currentState.m_stream[idx].m_layoutHandle = draw.m_stream[idx].m_layoutHandle;
+ currentState.m_stream[idx].m_handle = draw.m_stream[idx].m_handle;
+ currentState.m_stream[idx].m_startVertex = draw.m_stream[idx].m_startVertex;
+
+ uint16_t handle = draw.m_stream[idx].m_handle.idx;
+ const VertexBufferVK& vb = m_vertexBuffers[handle];
+ const uint16_t decl = isValid(draw.m_stream[idx].m_layoutHandle)
+ ? draw.m_stream[idx].m_layoutHandle.idx
+ : vb.m_layoutHandle.idx;
+ const VertexLayout& layout = m_vertexLayouts[decl];
+
+ layouts[numStreams] = &layout;
+ }
+ }
VkPipeline pipeline =
getPipeline(state
, draw.m_stencil
- , declIdx
+ , numStreams
+ , layouts
, key.m_program
, uint8_t(draw.m_instanceDataStride/16)
);
uint16_t scissor = draw.m_scissor;
uint32_t bindHash = bx::hash<bx::HashMurmur2A>(renderBind.m_bind, sizeof(renderBind.m_bind) );
- if (currentBindHash != bindHash
- || 0 != changedStencil
- || (hasFactor && blendFactor != draw.m_rgba)
- || (0 != (BGFX_STATE_PT_MASK & changedFlags)
- || prim.m_topology != s_primInfo[primIndex].m_topology)
- || currentState.m_scissor != scissor
- || pipeline != currentPipeline
- || hasOcclusionQuery)
- {
-// m_batch.flush(m_commandList);
- }
-
-// if (currentBindHash != bindHash)
-// {
-// currentBindHash = bindHash;
-//
-// Bind* bindCached = bindLru.find(bindHash);
-// if (NULL == bindCached)
-// {
-// D3D12_GPU_DESCRIPTOR_HANDLE srvHandle[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
-// uint32_t samplerFlags[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
-// {
-// srvHandle[0].ptr = 0;
-// for (uint32_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage)
-// {
-// const Binding& bind = renderBind.m_bind[stage];
-// if (kInvalidHandle != bind.m_idx)
-// {
-// TextureD3D12& texture = m_textures[bind.m_idx];
-// texture.setState(m_commandList, D3D12_RESOURCE_STATE_GENERIC_READ);
-// scratchBuffer.allocSrv(srvHandle[stage], texture);
-// samplerFlags[stage] = (0 == (BGFX_TEXTURE_INTERNAL_DEFAULT_SAMPLER & bind.m_textureFlags)
-// ? bind.m_textureFlags
-// : texture.m_flags
-// ) & (BGFX_TEXTURE_SAMPLER_BITS_MASK|BGFX_TEXTURE_BORDER_COLOR_MASK)
-// ;
-// }
-// else
-// {
-// bx::memCopy(&srvHandle[stage], &srvHandle[0], sizeof(D3D12_GPU_DESCRIPTOR_HANDLE) );
-// samplerFlags[stage] = 0;
-// }
-// }
-// }
-//
-// if (srvHandle[0].ptr != 0)
-// {
-// uint16_t samplerStateIdx = getSamplerState(samplerFlags, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, _render->m_colorPalette);
-// if (samplerStateIdx != currentSamplerStateIdx)
-// {
-// currentSamplerStateIdx = samplerStateIdx;
-// m_commandList->SetGraphicsRootDescriptorTable(Rdt::Sampler, m_samplerAllocator.get(samplerStateIdx) );
-// }
-//
-// m_commandList->SetGraphicsRootDescriptorTable(Rdt::SRV, srvHandle[0]);
-//
-// Bind bind;
-// bind.m_srvHandle = srvHandle[0];
-// bind.m_samplerStateIdx = samplerStateIdx;
-// bindLru.add(bindHash, bind, 0);
-// }
-// }
-// else
-// {
-// uint16_t samplerStateIdx = bindCached->m_samplerStateIdx;
-// if (samplerStateIdx != currentSamplerStateIdx)
-// {
-// currentSamplerStateIdx = samplerStateIdx;
-// m_commandList->SetGraphicsRootDescriptorTable(Rdt::Sampler, m_samplerAllocator.get(samplerStateIdx) );
-// }
-// m_commandList->SetGraphicsRootDescriptorTable(Rdt::SRV, bindCached->m_srvHandle);
-// }
-// }
if (pipeline != currentPipeline
|| 0 != changedStencil)
@@ -4244,8 +6203,8 @@ BX_UNUSED(currentSamplerStateIdx);
VkRect2D rc;
rc.offset.x = viewScissorRect.m_x;
rc.offset.y = viewScissorRect.m_y;
- rc.extent.width = viewScissorRect.m_x + viewScissorRect.m_width;
- rc.extent.height = viewScissorRect.m_y + viewScissorRect.m_height;
+ rc.extent.width = viewScissorRect.m_width;
+ rc.extent.height = viewScissorRect.m_height;
vkCmdSetScissor(m_commandBuffer, 0, 1, &rc);
}
}
@@ -4258,8 +6217,8 @@ BX_UNUSED(currentSamplerStateIdx);
VkRect2D rc;
rc.offset.x = scissorRect.m_x;
rc.offset.y = scissorRect.m_y;
- rc.extent.width = scissorRect.m_x + scissorRect.m_width;
- rc.extent.height = scissorRect.m_y + scissorRect.m_height;
+ rc.extent.width = scissorRect.m_width;
+ rc.extent.height = scissorRect.m_height;
vkCmdSetScissor(m_commandBuffer, 0, 1, &rc);
}
}
@@ -4272,11 +6231,11 @@ BX_UNUSED(currentSamplerStateIdx);
bool constantsChanged = false;
if (draw.m_uniformBegin < draw.m_uniformEnd
- || currentProgramIdx != key.m_program
+ || currentProgram.idx != key.m_program.idx
|| BGFX_STATE_ALPHA_REF_MASK & changedFlags)
{
- currentProgramIdx = key.m_program;
- ProgramVK& program = m_program[currentProgramIdx];
+ currentProgram = key.m_program;
+ ProgramVK& program = m_program[currentProgram.idx];
UniformBuffer* vcb = program.m_vsh->m_constantBuffer;
if (NULL != vcb)
@@ -4294,34 +6253,103 @@ BX_UNUSED(currentSamplerStateIdx);
constantsChanged = true;
}
+ ProgramVK& program = m_program[currentProgram.idx];
+ if (hasPredefined)
+ {
+ uint32_t ref = (newFlags & BGFX_STATE_ALPHA_REF_MASK) >> BGFX_STATE_ALPHA_REF_SHIFT;
+ viewState.m_alphaRef = ref / 255.0f;
+ viewState.setPredefined<4>(this, view, program, _render, draw);
+ }
+
+ if (currentBindHash != bindHash
+ || currentDslHash != program.m_descriptorSetLayoutHash)
+ {
+ currentBindHash = bindHash;
+ currentDslHash = program.m_descriptorSetLayoutHash;
+
+ allocDescriptorSet(program, renderBind, scratchBuffer);
+ }
+
+ uint32_t numOffset = 0;
+ uint32_t offsets[2] = {0, 0};
if (constantsChanged
|| hasPredefined)
{
- ProgramVK& program = m_program[currentProgramIdx];
- uint32_t ref = (newFlags&BGFX_STATE_ALPHA_REF_MASK)>>BGFX_STATE_ALPHA_REF_SHIFT;
- viewState.m_alphaRef = ref/255.0f;
- viewState.setPredefined<4>(this, view, 0, program, _render, draw);
- commitShaderUniforms(m_commandBuffer, key.m_program); //, gpuAddress);
+ const uint32_t align = uint32_t(m_deviceProperties.limits.minUniformBufferOffsetAlignment);
+ const uint32_t vsize = bx::strideAlign(program.m_vsh->m_size, align);
+ const uint32_t fsize = bx::strideAlign((NULL != program.m_fsh ? program.m_fsh->m_size : 0), align);
+ const uint32_t total = vsize + fsize;
+ if (vsize > 0)
+ {
+ offsets[numOffset++] = scratchBuffer.m_pos;
+ bx::memCopy(&scratchBuffer.m_data[scratchBuffer.m_pos], m_vsScratch, program.m_vsh->m_size);
+ }
+ if (fsize > 0)
+ {
+ offsets[numOffset++] = scratchBuffer.m_pos + vsize;
+ bx::memCopy(&scratchBuffer.m_data[scratchBuffer.m_pos + vsize], m_fsScratch, program.m_fsh->m_size);
+ }
+
+ m_vsChanges = 0;
+ m_fsChanges = 0;
+ scratchBuffer.m_pos += total;
}
+ vkCmdBindDescriptorSets(
+ m_commandBuffer
+ , VK_PIPELINE_BIND_POINT_GRAPHICS
+ , program.m_pipelineLayout
+ , 0
+ , 1
+ , &scratchBuffer.getCurrentDS()
+ , numOffset
+ , offsets
+ );
+
+
+// if (constantsChanged
+// || hasPredefined)
+// {
+// ProgramVK& program = m_program[currentProgram.idx];
+// uint32_t ref = (newFlags&BGFX_STATE_ALPHA_REF_MASK)>>BGFX_STATE_ALPHA_REF_SHIFT;
+// viewState.m_alphaRef = ref/255.0f;
+// viewState.setPredefined<4>(this, view, program, _render, draw);
+// commitShaderUniforms(m_commandBuffer, key.m_program); //, gpuAddress);
+// }
// vb.setState(_commandList, D3D12_RESOURCE_STATE_GENERIC_READ);
- const VertexDecl& vertexDecl = m_vertexDecls[declIdx];
uint32_t numIndices = 0;
+ for (uint32_t ii = 0; ii < numStreams; ++ii)
+ {
+ VkDeviceSize offset = 0;
+ vkCmdBindVertexBuffers(m_commandBuffer
+ , ii
+ , 1
+ , &m_vertexBuffers[draw.m_stream[ii].m_handle.idx].m_buffer
+ , &offset
+ );
+ }
- VkDeviceSize offset = 0;
- vkCmdBindVertexBuffers(m_commandBuffer
- , 0
- , 1
- , &vb.m_buffer
- , &offset
- );
+ if (isValid(draw.m_instanceDataBuffer))
+ {
+ VkDeviceSize instanceOffset = draw.m_instanceDataOffset;
+ VertexBufferVK& instanceBuffer = m_vertexBuffers[draw.m_instanceDataBuffer.idx];
+ vkCmdBindVertexBuffers(m_commandBuffer
+ , numStreams
+ , 1
+ , &instanceBuffer.m_buffer
+ , &instanceOffset
+ );
+ }
if (!isValid(draw.m_indexBuffer) )
{
+ const VertexBufferVK& vertexBuffer = m_vertexBuffers[draw.m_stream[0].m_handle.idx];
+ const VertexLayout& layout = m_vertexLayouts[draw.m_stream[0].m_layoutHandle.idx];
+
const uint32_t numVertices = UINT32_MAX == draw.m_numVertices
- ? vb.m_size / vertexDecl.m_stride
+ ? vertexBuffer.m_size / layout.m_stride
: draw.m_numVertices
;
vkCmdDraw(m_commandBuffer
@@ -4334,7 +6362,6 @@ BX_UNUSED(currentSamplerStateIdx);
else
{
BufferVK& ib = m_indexBuffers[draw.m_indexBuffer.idx];
-// ib.setState(_commandList, D3D12_RESOURCE_STATE_GENERIC_READ);
const bool hasIndex16 = 0 == (ib.m_flags & BGFX_BUFFER_INDEX32);
const uint32_t indexSize = hasIndex16 ? 2 : 4;
@@ -4451,51 +6478,44 @@ BX_UNUSED(presentMin, presentMax);
, getRendererName()
);
-// const DXGI_ADAPTER_DESC& desc = m_adapterDesc;
-// char description[BX_COUNTOF(desc.Description)];
-// wcstombs(description, desc.Description, BX_COUNTOF(desc.Description) );
-// tvm.printf(0, pos++, 0x8f, " Device: %s", description);
-//
-// char dedicatedVideo[16];
-// bx::prettify(dedicatedVideo, BX_COUNTOF(dedicatedVideo), desc.DedicatedVideoMemory);
-//
-// char dedicatedSystem[16];
-// bx::prettify(dedicatedSystem, BX_COUNTOF(dedicatedSystem), desc.DedicatedSystemMemory);
-//
-// char sharedSystem[16];
-// bx::prettify(sharedSystem, BX_COUNTOF(sharedSystem), desc.SharedSystemMemory);
-//
-// char processMemoryUsed[16];
-// bx::prettify(processMemoryUsed, BX_COUNTOF(processMemoryUsed), bx::getProcessMemoryUsed() );
-//
-// tvm.printf(0, pos++, 0x8f, " Memory: %s (video), %s (system), %s (shared), %s (process) "
-// , dedicatedVideo
-// , dedicatedSystem
-// , sharedSystem
-// , processMemoryUsed
-// );
+ const VkPhysicalDeviceProperties& pdp = m_deviceProperties;
+ tvm.printf(0, pos++, 0x8f, " Device: %s (%s)"
+ , pdp.deviceName
+ , getName(pdp.deviceType)
+ );
-// DXGI_QUERY_VIDEO_MEMORY_INFO memInfo;
-// DX_CHECK(m_adapter->QueryVideoMemoryInfo(0, DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &memInfo) );
-//
-// char budget[16];
-// bx::prettify(budget, BX_COUNTOF(budget), memInfo.Budget);
-//
-// char currentUsage[16];
-// bx::prettify(currentUsage, BX_COUNTOF(currentUsage), memInfo.CurrentUsage);
-//
-// char availableForReservation[16];
-// bx::prettify(availableForReservation, BX_COUNTOF(currentUsage), memInfo.AvailableForReservation);
-//
-// char currentReservation[16];
-// bx::prettify(currentReservation, BX_COUNTOF(currentReservation), memInfo.CurrentReservation);
-//
-// tvm.printf(0, pos++, 0x8f, " Budget: %s, Usage: %s, AvailRes: %s, CurrRes: %s "
-// , budget
-// , currentUsage
-// , availableForReservation
-// , currentReservation
-// );
+ if (s_extension[Extension::EXT_memory_budget].m_supported)
+ {
+ VkPhysicalDeviceMemoryBudgetPropertiesEXT dmbp;
+ dmbp.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT;
+ dmbp.pNext = NULL;
+
+ VkPhysicalDeviceMemoryProperties2 pdmp2;
+ pdmp2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2;
+ pdmp2.pNext = &dmbp;
+
+ vkGetPhysicalDeviceMemoryProperties2KHR(m_physicalDevice, &pdmp2);
+
+ for (uint32_t ii = 0; ii < VK_MAX_MEMORY_HEAPS; ++ii)
+ {
+ if (dmbp.heapBudget[ii] == 0)
+ {
+ continue;
+ }
+
+ char budget[16];
+ bx::prettify(budget, BX_COUNTOF(budget), dmbp.heapBudget[ii]);
+
+ char usage[16];
+ bx::prettify(usage, BX_COUNTOF(usage), dmbp.heapUsage[ii]);
+
+ tvm.printf(0, pos++, 0x8f, " Memory %d - Budget: %12s, Usage: %12s"
+ , ii
+ , budget
+ , usage
+ );
+ }
+ }
pos = 10;
tvm.printf(10, pos++, 0x8b, " Frame: % 7.3f, % 7.3f \x1f, % 7.3f \x1e [ms] / % 6.2f FPS "
@@ -4548,10 +6568,10 @@ BX_UNUSED(presentMin, presentMax);
// , m_batch.m_stats.m_numImmediate[BatchD3D12::DrawIndexed]
// );
- if (NULL != m_renderDocDll)
- {
- tvm.printf(tvm.m_width-27, 0, 0x4f, " [F11 - RenderDoc capture] ");
- }
+ if (NULL != m_renderDocDll)
+ {
+ tvm.printf(tvm.m_width-27, 0, 0x4f, " [F11 - RenderDoc capture] ");
+ }
tvm.printf(10, pos++, 0x8b, " Indices: %7d ", statsNumIndices);
// tvm.printf(10, pos++, 0x8b, " Uniform size: %7d, Max: %7d ", _render->m_uniformEnd, _render->m_uniformMax);
@@ -4560,11 +6580,11 @@ BX_UNUSED(presentMin, presentMax);
pos++;
tvm.printf(10, pos++, 0x8b, " State cache: ");
- tvm.printf(10, pos++, 0x8b, " PSO | Sampler | Bind | Queued ");
- tvm.printf(10, pos++, 0x8b, " %6d " //| %6d | %6d | %6d "
+ tvm.printf(10, pos++, 0x8b, " PSO | DSL | DS | Queued ");
+ tvm.printf(10, pos++, 0x8b, " %6d | %6d | %6d | %6d "
, m_pipelineStateCache.getCount()
-// , m_samplerStateCache.getCount()
-// , bindLru.getCount()
+ , m_descriptorSetLayoutCache.getCount()
+ , scratchBuffer.m_currentDs
// , m_cmd.m_control.available()
);
pos++;
@@ -4597,17 +6617,32 @@ BX_UNUSED(presentMin, presentMax);
// PIX_ENDEVENT();
}
+ VkMappedMemoryRange range;
+ range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
+ range.pNext = NULL;
+ range.memory = scratchBuffer.m_deviceMem;
+ range.offset = 0;
+ range.size = scratchBuffer.m_pos;
+ vkFlushMappedMemoryRanges(m_device, 1, &range);
+
if (beginRenderPass)
{
vkCmdEndRenderPass(m_commandBuffer);
beginRenderPass = false;
+
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) && s_extension[Extension::EXT_debug_utils].m_supported )
+ {
+ vkCmdEndDebugUtilsLabelEXT(m_commandBuffer);
+ }
}
setImageMemoryBarrier(m_commandBuffer
, m_backBufferColorImage[m_backBufferColorIdx]
- , VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
+ , VK_IMAGE_ASPECT_COLOR_BIT
+ , m_backBufferColorImageLayout[m_backBufferColorIdx]
, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
- );
+ , 1, 1);
+ m_backBufferColorImageLayout[m_backBufferColorIdx] = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
VK_CHECK(vkEndCommandBuffer(m_commandBuffer) );
diff --git a/3rdparty/bgfx/src/renderer_vk.h b/3rdparty/bgfx/src/renderer_vk.h
index bd7ea608916..97ee710697d 100644
--- a/3rdparty/bgfx/src/renderer_vk.h
+++ b/3rdparty/bgfx/src/renderer_vk.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -21,6 +21,10 @@
# define VK_USE_PLATFORM_WIN32_KHR
# define KHR_SURFACE_EXTENSION_NAME VK_KHR_WIN32_SURFACE_EXTENSION_NAME
# define VK_IMPORT_INSTANCE_PLATFORM VK_IMPORT_INSTANCE_WINDOWS
+#elif BX_PLATFORM_OSX
+# define VK_USE_PLATFORM_MACOS_MVK
+# define KHR_SURFACE_EXTENSION_NAME VK_MVK_MACOS_SURFACE_EXTENSION_NAME
+# define VK_IMPORT_INSTANCE_PLATFORM VK_IMPORT_INSTANCE_MACOS
#else
# define KHR_SURFACE_EXTENSION_NAME ""
# define VK_IMPORT_INSTANCE_PLATFORM
@@ -57,6 +61,9 @@
VK_IMPORT_INSTANCE_FUNC(true, vkCreateWin32SurfaceKHR); \
VK_IMPORT_INSTANCE_FUNC(true, vkGetPhysicalDeviceWin32PresentationSupportKHR);
+#define VK_IMPORT_INSTANCE_MACOS \
+ VK_IMPORT_INSTANCE_FUNC(true, vkCreateMacOSSurfaceMVK);
+
#define VK_IMPORT_INSTANCE \
VK_IMPORT_INSTANCE_FUNC(false, vkDestroyInstance); \
VK_IMPORT_INSTANCE_FUNC(false, vkEnumeratePhysicalDevices); \
@@ -64,8 +71,10 @@
VK_IMPORT_INSTANCE_FUNC(false, vkEnumerateDeviceLayerProperties); \
VK_IMPORT_INSTANCE_FUNC(false, vkGetPhysicalDeviceProperties); \
VK_IMPORT_INSTANCE_FUNC(false, vkGetPhysicalDeviceFormatProperties); \
+ VK_IMPORT_INSTANCE_FUNC(false, vkGetPhysicalDeviceFeatures); \
VK_IMPORT_INSTANCE_FUNC(false, vkGetPhysicalDeviceImageFormatProperties); \
VK_IMPORT_INSTANCE_FUNC(false, vkGetPhysicalDeviceMemoryProperties); \
+ VK_IMPORT_INSTANCE_FUNC(true, vkGetPhysicalDeviceMemoryProperties2KHR); \
VK_IMPORT_INSTANCE_FUNC(false, vkGetPhysicalDeviceQueueFamilyProperties); \
VK_IMPORT_INSTANCE_FUNC(false, vkGetPhysicalDeviceSurfaceCapabilitiesKHR); \
VK_IMPORT_INSTANCE_FUNC(false, vkGetPhysicalDeviceSurfaceFormatsKHR); \
@@ -80,99 +89,113 @@
VK_IMPORT_INSTANCE_FUNC(true, vkDebugReportMessageEXT); \
VK_IMPORT_INSTANCE_PLATFORM
-#define VK_IMPORT_DEVICE \
- VK_IMPORT_DEVICE_FUNC(false, vkGetDeviceQueue); \
- VK_IMPORT_DEVICE_FUNC(false, vkCreateSwapchainKHR); \
- VK_IMPORT_DEVICE_FUNC(false, vkDestroySwapchainKHR); \
- VK_IMPORT_DEVICE_FUNC(false, vkGetSwapchainImagesKHR); \
- VK_IMPORT_DEVICE_FUNC(false, vkAcquireNextImageKHR); \
- VK_IMPORT_DEVICE_FUNC(false, vkQueuePresentKHR); \
- VK_IMPORT_DEVICE_FUNC(false, vkCreateFence); \
- VK_IMPORT_DEVICE_FUNC(false, vkDestroyFence); \
- VK_IMPORT_DEVICE_FUNC(false, vkCreateSemaphore); \
- VK_IMPORT_DEVICE_FUNC(false, vkDestroySemaphore); \
- VK_IMPORT_DEVICE_FUNC(false, vkResetFences); \
- VK_IMPORT_DEVICE_FUNC(false, vkCreateCommandPool); \
- VK_IMPORT_DEVICE_FUNC(false, vkDestroyCommandPool); \
- VK_IMPORT_DEVICE_FUNC(false, vkResetCommandPool); \
- VK_IMPORT_DEVICE_FUNC(false, vkAllocateCommandBuffers); \
- VK_IMPORT_DEVICE_FUNC(false, vkFreeCommandBuffers); \
- VK_IMPORT_DEVICE_FUNC(false, vkGetBufferMemoryRequirements); \
- VK_IMPORT_DEVICE_FUNC(false, vkGetImageMemoryRequirements); \
- VK_IMPORT_DEVICE_FUNC(false, vkAllocateMemory); \
- VK_IMPORT_DEVICE_FUNC(false, vkFreeMemory); \
- VK_IMPORT_DEVICE_FUNC(false, vkCreateImage); \
- VK_IMPORT_DEVICE_FUNC(false, vkDestroyImage); \
- VK_IMPORT_DEVICE_FUNC(false, vkCreateImageView); \
- VK_IMPORT_DEVICE_FUNC(false, vkDestroyImageView); \
- VK_IMPORT_DEVICE_FUNC(false, vkCreateBuffer); \
- VK_IMPORT_DEVICE_FUNC(false, vkDestroyBuffer); \
- VK_IMPORT_DEVICE_FUNC(false, vkCreateFramebuffer); \
- VK_IMPORT_DEVICE_FUNC(false, vkDestroyFramebuffer); \
- VK_IMPORT_DEVICE_FUNC(false, vkCreateRenderPass); \
- VK_IMPORT_DEVICE_FUNC(false, vkDestroyRenderPass); \
- VK_IMPORT_DEVICE_FUNC(false, vkCreateShaderModule); \
- VK_IMPORT_DEVICE_FUNC(false, vkDestroyShaderModule); \
- VK_IMPORT_DEVICE_FUNC(false, vkCreatePipelineCache); \
- VK_IMPORT_DEVICE_FUNC(false, vkDestroyPipelineCache); \
- VK_IMPORT_DEVICE_FUNC(false, vkGetPipelineCacheData); \
- VK_IMPORT_DEVICE_FUNC(false, vkMergePipelineCaches); \
- VK_IMPORT_DEVICE_FUNC(false, vkCreateGraphicsPipelines); \
- VK_IMPORT_DEVICE_FUNC(false, vkCreateComputePipelines); \
- VK_IMPORT_DEVICE_FUNC(false, vkDestroyPipeline); \
- VK_IMPORT_DEVICE_FUNC(false, vkCreatePipelineLayout); \
- VK_IMPORT_DEVICE_FUNC(false, vkDestroyPipelineLayout); \
- VK_IMPORT_DEVICE_FUNC(false, vkCreateSampler); \
- VK_IMPORT_DEVICE_FUNC(false, vkDestroySampler); \
- VK_IMPORT_DEVICE_FUNC(false, vkCreateDescriptorSetLayout); \
- VK_IMPORT_DEVICE_FUNC(false, vkDestroyDescriptorSetLayout); \
- VK_IMPORT_DEVICE_FUNC(false, vkCreateDescriptorPool); \
- VK_IMPORT_DEVICE_FUNC(false, vkDestroyDescriptorPool); \
- VK_IMPORT_DEVICE_FUNC(false, vkResetDescriptorPool); \
- VK_IMPORT_DEVICE_FUNC(false, vkAllocateDescriptorSets); \
- VK_IMPORT_DEVICE_FUNC(false, vkFreeDescriptorSets); \
- VK_IMPORT_DEVICE_FUNC(false, vkUpdateDescriptorSets); \
- VK_IMPORT_DEVICE_FUNC(false, vkQueueSubmit); \
- VK_IMPORT_DEVICE_FUNC(false, vkQueueWaitIdle); \
- VK_IMPORT_DEVICE_FUNC(false, vkDeviceWaitIdle); \
- VK_IMPORT_DEVICE_FUNC(false, vkWaitForFences); \
- VK_IMPORT_DEVICE_FUNC(false, vkBeginCommandBuffer); \
- VK_IMPORT_DEVICE_FUNC(false, vkEndCommandBuffer); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdPipelineBarrier); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdBeginRenderPass); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdEndRenderPass); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdSetViewport); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdDraw); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdDrawIndexed); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdDrawIndirect); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdDrawIndexedIndirect); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdDispatch); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdDispatchIndirect); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdBindPipeline); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdSetStencilReference); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdSetBlendConstants); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdSetScissor); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdBindDescriptorSets); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdBindIndexBuffer); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdBindVertexBuffers); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdUpdateBuffer); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdClearColorImage); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdClearDepthStencilImage); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdClearAttachments); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdResolveImage); \
- VK_IMPORT_DEVICE_FUNC(false, vkCmdCopyBuffer); \
- VK_IMPORT_DEVICE_FUNC(false, vkMapMemory); \
- VK_IMPORT_DEVICE_FUNC(false, vkUnmapMemory); \
- VK_IMPORT_DEVICE_FUNC(false, vkFlushMappedMemoryRanges); \
- VK_IMPORT_DEVICE_FUNC(false, vkInvalidateMappedMemoryRanges); \
- VK_IMPORT_DEVICE_FUNC(false, vkBindBufferMemory); \
- VK_IMPORT_DEVICE_FUNC(false, vkBindImageMemory); \
- /* VK_EXT_debug_marker */ \
- VK_IMPORT_DEVICE_FUNC(true, vkDebugMarkerSetObjectTagEXT); \
- VK_IMPORT_DEVICE_FUNC(true, vkDebugMarkerSetObjectNameEXT); \
- VK_IMPORT_DEVICE_FUNC(true, vkCmdDebugMarkerBeginEXT); \
- VK_IMPORT_DEVICE_FUNC(true, vkCmdDebugMarkerEndEXT); \
- VK_IMPORT_DEVICE_FUNC(true, vkCmdDebugMarkerInsertEXT); \
+#define VK_IMPORT_DEVICE \
+ VK_IMPORT_DEVICE_FUNC(false, vkGetDeviceQueue); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCreateSwapchainKHR); \
+ VK_IMPORT_DEVICE_FUNC(false, vkDestroySwapchainKHR); \
+ VK_IMPORT_DEVICE_FUNC(false, vkGetSwapchainImagesKHR); \
+ VK_IMPORT_DEVICE_FUNC(false, vkAcquireNextImageKHR); \
+ VK_IMPORT_DEVICE_FUNC(false, vkQueuePresentKHR); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCreateFence); \
+ VK_IMPORT_DEVICE_FUNC(false, vkDestroyFence); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCreateSemaphore); \
+ VK_IMPORT_DEVICE_FUNC(false, vkDestroySemaphore); \
+ VK_IMPORT_DEVICE_FUNC(false, vkResetFences); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCreateCommandPool); \
+ VK_IMPORT_DEVICE_FUNC(false, vkDestroyCommandPool); \
+ VK_IMPORT_DEVICE_FUNC(false, vkResetCommandPool); \
+ VK_IMPORT_DEVICE_FUNC(false, vkAllocateCommandBuffers); \
+ VK_IMPORT_DEVICE_FUNC(false, vkFreeCommandBuffers); \
+ VK_IMPORT_DEVICE_FUNC(false, vkGetBufferMemoryRequirements); \
+ VK_IMPORT_DEVICE_FUNC(false, vkGetImageMemoryRequirements); \
+ VK_IMPORT_DEVICE_FUNC(false, vkAllocateMemory); \
+ VK_IMPORT_DEVICE_FUNC(false, vkFreeMemory); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCreateImage); \
+ VK_IMPORT_DEVICE_FUNC(false, vkDestroyImage); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCreateImageView); \
+ VK_IMPORT_DEVICE_FUNC(false, vkDestroyImageView); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCreateBuffer); \
+ VK_IMPORT_DEVICE_FUNC(false, vkDestroyBuffer); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCreateFramebuffer); \
+ VK_IMPORT_DEVICE_FUNC(false, vkDestroyFramebuffer); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCreateRenderPass); \
+ VK_IMPORT_DEVICE_FUNC(false, vkDestroyRenderPass); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCreateShaderModule); \
+ VK_IMPORT_DEVICE_FUNC(false, vkDestroyShaderModule); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCreatePipelineCache); \
+ VK_IMPORT_DEVICE_FUNC(false, vkDestroyPipelineCache); \
+ VK_IMPORT_DEVICE_FUNC(false, vkGetPipelineCacheData); \
+ VK_IMPORT_DEVICE_FUNC(false, vkMergePipelineCaches); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCreateGraphicsPipelines); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCreateComputePipelines); \
+ VK_IMPORT_DEVICE_FUNC(false, vkDestroyPipeline); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCreatePipelineLayout); \
+ VK_IMPORT_DEVICE_FUNC(false, vkDestroyPipelineLayout); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCreateSampler); \
+ VK_IMPORT_DEVICE_FUNC(false, vkDestroySampler); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCreateDescriptorSetLayout); \
+ VK_IMPORT_DEVICE_FUNC(false, vkDestroyDescriptorSetLayout); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCreateDescriptorPool); \
+ VK_IMPORT_DEVICE_FUNC(false, vkDestroyDescriptorPool); \
+ VK_IMPORT_DEVICE_FUNC(false, vkResetDescriptorPool); \
+ VK_IMPORT_DEVICE_FUNC(false, vkAllocateDescriptorSets); \
+ VK_IMPORT_DEVICE_FUNC(false, vkFreeDescriptorSets); \
+ VK_IMPORT_DEVICE_FUNC(false, vkUpdateDescriptorSets); \
+ VK_IMPORT_DEVICE_FUNC(false, vkQueueSubmit); \
+ VK_IMPORT_DEVICE_FUNC(false, vkQueueWaitIdle); \
+ VK_IMPORT_DEVICE_FUNC(false, vkDeviceWaitIdle); \
+ VK_IMPORT_DEVICE_FUNC(false, vkWaitForFences); \
+ VK_IMPORT_DEVICE_FUNC(false, vkBeginCommandBuffer); \
+ VK_IMPORT_DEVICE_FUNC(false, vkEndCommandBuffer); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdPipelineBarrier); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdBeginRenderPass); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdEndRenderPass); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdSetViewport); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdDraw); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdDrawIndexed); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdDrawIndirect); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdDrawIndexedIndirect); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdDispatch); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdDispatchIndirect); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdBindPipeline); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdSetStencilReference); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdSetBlendConstants); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdSetScissor); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdBindDescriptorSets); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdBindIndexBuffer); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdBindVertexBuffers); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdUpdateBuffer); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdClearColorImage); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdClearDepthStencilImage); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdClearAttachments); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdResolveImage); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdCopyBuffer); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdCopyBufferToImage); \
+ VK_IMPORT_DEVICE_FUNC(false, vkCmdBlitImage); \
+ VK_IMPORT_DEVICE_FUNC(false, vkMapMemory); \
+ VK_IMPORT_DEVICE_FUNC(false, vkUnmapMemory); \
+ VK_IMPORT_DEVICE_FUNC(false, vkFlushMappedMemoryRanges); \
+ VK_IMPORT_DEVICE_FUNC(false, vkInvalidateMappedMemoryRanges); \
+ VK_IMPORT_DEVICE_FUNC(false, vkBindBufferMemory); \
+ VK_IMPORT_DEVICE_FUNC(false, vkBindImageMemory); \
+ /* VK_EXT_debug_marker */ \
+ VK_IMPORT_DEVICE_FUNC(true, vkDebugMarkerSetObjectTagEXT); \
+ VK_IMPORT_DEVICE_FUNC(true, vkDebugMarkerSetObjectNameEXT); \
+ VK_IMPORT_DEVICE_FUNC(true, vkCmdDebugMarkerBeginEXT); \
+ VK_IMPORT_DEVICE_FUNC(true, vkCmdDebugMarkerEndEXT); \
+ VK_IMPORT_DEVICE_FUNC(true, vkCmdDebugMarkerInsertEXT); \
+ /* VK_EXT_debug_utils */ \
+ VK_IMPORT_DEVICE_FUNC(true, vkSetDebugUtilsObjectNameEXT); \
+ VK_IMPORT_DEVICE_FUNC(true, vkSetDebugUtilsObjectTagEXT); \
+ VK_IMPORT_DEVICE_FUNC(true, vkQueueBeginDebugUtilsLabelEXT); \
+ VK_IMPORT_DEVICE_FUNC(true, vkQueueEndDebugUtilsLabelEXT); \
+ VK_IMPORT_DEVICE_FUNC(true, vkQueueInsertDebugUtilsLabelEXT); \
+ VK_IMPORT_DEVICE_FUNC(true, vkCmdBeginDebugUtilsLabelEXT); \
+ VK_IMPORT_DEVICE_FUNC(true, vkCmdEndDebugUtilsLabelEXT); \
+ VK_IMPORT_DEVICE_FUNC(true, vkCmdInsertDebugUtilsLabelEXT); \
+ VK_IMPORT_DEVICE_FUNC(true, vkCreateDebugUtilsMessengerEXT); \
+ VK_IMPORT_DEVICE_FUNC(true, vkDestroyDebugUtilsMessengerEXT); \
+ VK_IMPORT_DEVICE_FUNC(true, vkSubmitDebugUtilsMessageEXT); \
#define VK_DESTROY \
VK_DESTROY_FUNC(Buffer); \
@@ -183,6 +206,7 @@
VK_DESTROY_FUNC(Framebuffer); \
VK_DESTROY_FUNC(Image); \
VK_DESTROY_FUNC(ImageView); \
+ VK_DESTROY_FUNC(Sampler); \
VK_DESTROY_FUNC(Pipeline); \
VK_DESTROY_FUNC(PipelineCache); \
VK_DESTROY_FUNC(PipelineLayout); \
@@ -228,7 +252,8 @@ VK_DESTROY
enum Enum
{
// CombinedImageSampler,
- UniformBuffer,
+ VertexUniformBuffer,
+ FragmentUniformBuffer,
// StorageBuffer,
Count
@@ -299,8 +324,12 @@ VK_DESTROY
void create(uint32_t _size, uint32_t _maxDescriptors);
void destroy();
- void reset(VkDescriptorBufferInfo& _gpuAddress);
- void* allocUbv(VkDescriptorBufferInfo& _gpuAddress, uint32_t _size);
+ void reset();
+
+ VkDescriptorSet& getCurrentDS()
+ {
+ return m_descriptorSet[m_currentDs - 1];
+ }
VkDescriptorSet* m_descriptorSet;
VkBuffer m_buffer;
@@ -355,9 +384,9 @@ VK_DESTROY
struct VertexBufferVK : public BufferVK
{
- void create(uint32_t _size, void* _data, VertexDeclHandle _declHandle, uint16_t _flags);
+ void create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle, uint16_t _flags);
- VertexDeclHandle m_decl;
+ VertexLayoutHandle m_layoutHandle;
};
struct ShaderVK
@@ -369,6 +398,8 @@ VK_DESTROY
, m_hash(0)
, m_numUniforms(0)
, m_numPredefined(0)
+ , m_uniformBinding(0)
+ , m_numBindings(0)
{
}
@@ -388,6 +419,30 @@ VK_DESTROY
uint16_t m_size;
uint8_t m_numPredefined;
uint8_t m_numAttrs;
+
+ struct BindType
+ {
+ enum Enum
+ {
+ Storage,
+ Sampler,
+
+ Count
+ };
+ };
+
+ struct BindInfo
+ {
+ UniformHandle uniformHandle;
+ BindType::Enum type;
+ uint32_t binding;
+ uint32_t samplerBinding;
+ };
+
+ BindInfo m_bindInfo[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
+ uint32_t m_uniformBinding;
+ uint16_t m_numBindings;
+ VkDescriptorSetLayoutBinding m_bindings[32];
};
struct ProgramVK
@@ -395,46 +450,79 @@ VK_DESTROY
ProgramVK()
: m_vsh(NULL)
, m_fsh(NULL)
+ , m_descriptorSetLayoutHash(0)
+ , m_pipelineLayout(VK_NULL_HANDLE)
{
}
- void create(const ShaderVK* _vsh, const ShaderVK* _fsh)
- {
- BX_CHECK(NULL != _vsh->m_code, "Vertex shader doesn't exist.");
- m_vsh = _vsh;
- bx::memCopy(&m_predefined[0], _vsh->m_predefined, _vsh->m_numPredefined*sizeof(PredefinedUniform));
- m_numPredefined = _vsh->m_numPredefined;
-
- if (NULL != _fsh)
- {
- BX_CHECK(NULL != _fsh->m_code, "Fragment shader doesn't exist.");
- m_fsh = _fsh;
- bx::memCopy(&m_predefined[m_numPredefined], _fsh->m_predefined, _fsh->m_numPredefined*sizeof(PredefinedUniform));
- m_numPredefined += _fsh->m_numPredefined;
- }
- }
-
- void destroy()
- {
- m_numPredefined = 0;
- m_vsh = NULL;
- m_fsh = NULL;
- }
+ void create(const ShaderVK* _vsh, const ShaderVK* _fsh);
+ void destroy();
const ShaderVK* m_vsh;
const ShaderVK* m_fsh;
PredefinedUniform m_predefined[PredefinedUniform::Count * 2];
uint8_t m_numPredefined;
+
+ uint32_t m_descriptorSetLayoutHash;
+ VkPipelineLayout m_pipelineLayout;
};
struct TextureVK
{
+ TextureVK()
+ : m_vkTextureFormat(VK_FORMAT_UNDEFINED)
+ , m_textureImage(VK_NULL_HANDLE)
+ , m_textureDeviceMem(VK_NULL_HANDLE)
+ , m_textureImageView(VK_NULL_HANDLE)
+ , m_textureImageDepthView(VK_NULL_HANDLE)
+ , m_textureImageStorageView(VK_NULL_HANDLE)
+ , m_currentImageLayout(VK_IMAGE_LAYOUT_UNDEFINED)
+ {
+ }
+
+ void* create(const Memory* _mem, uint64_t _flags, uint8_t _skip);
void destroy();
+ void update(VkCommandPool commandPool, uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem);
+
+ void copyBufferToTexture(VkBuffer stagingBuffer, uint32_t bufferImageCopyCount, VkBufferImageCopy* bufferImageCopy);
+ void setImageMemoryBarrier(VkCommandBuffer commandBuffer, VkImageLayout newImageLayout);
+
+ void* m_directAccessPtr;
+ uint64_t m_flags;
+ uint32_t m_width;
+ uint32_t m_height;
+ uint32_t m_depth;
+ uint32_t m_numLayers;
+ uint32_t m_numSides;
+ VkImageViewType m_type;
+ uint8_t m_requestedFormat;
+ uint8_t m_textureFormat;
+ uint8_t m_numMips;
+ VkFormat m_vkTextureFormat;
+ VkImageAspectFlags m_vkTextureAspect;
+
+ VkImage m_textureImage;
+ VkDeviceMemory m_textureDeviceMem;
+ VkImageView m_textureImageView;
+ VkImageView m_textureImageDepthView;
+ VkImageView m_textureImageStorageView;
+ VkImageLayout m_currentImageLayout;
};
struct FrameBufferVK
{
+ FrameBufferVK()
+ : m_depth{ kInvalidHandle }
+ , m_width(0)
+ , m_height(0)
+ , m_denseIdx(kInvalidHandle)
+ , m_num(0)
+ , m_numTh(0)
+ , m_framebuffer(VK_NULL_HANDLE)
+ {
+ }
+ void create(uint8_t _num, const Attachment* _attachment);
void destroy();
TextureHandle m_texture[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
@@ -445,7 +533,10 @@ VK_DESTROY
uint16_t m_denseIdx;
uint8_t m_num;
uint8_t m_numTh;
+ uint8_t m_numAttachment;
Attachment m_attachment[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
+ VkFramebuffer m_framebuffer;
+ VkRenderPass m_renderPass;
};
} /* namespace bgfx */ } // namespace vk
diff --git a/3rdparty/bgfx/src/shader.cpp b/3rdparty/bgfx/src/shader.cpp
index f6dfb3e350d..867d812f109 100644
--- a/3rdparty/bgfx/src/shader.cpp
+++ b/3rdparty/bgfx/src/shader.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/shader.h b/3rdparty/bgfx/src/shader.h
index bd55dc91f90..0905f0052fd 100644
--- a/3rdparty/bgfx/src/shader.h
+++ b/3rdparty/bgfx/src/shader.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/shader_dx9bc.cpp b/3rdparty/bgfx/src/shader_dx9bc.cpp
index 988bec096f0..6bfe57e585b 100644
--- a/3rdparty/bgfx/src/shader_dx9bc.cpp
+++ b/3rdparty/bgfx/src/shader_dx9bc.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/shader_dx9bc.h b/3rdparty/bgfx/src/shader_dx9bc.h
index 618955f9921..8c864916501 100644
--- a/3rdparty/bgfx/src/shader_dx9bc.h
+++ b/3rdparty/bgfx/src/shader_dx9bc.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/shader_dxbc.cpp b/3rdparty/bgfx/src/shader_dxbc.cpp
index 49da315b3e9..9dca204f1ab 100644
--- a/3rdparty/bgfx/src/shader_dxbc.cpp
+++ b/3rdparty/bgfx/src/shader_dxbc.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -717,8 +717,8 @@ namespace bgfx
}
// dxbc hash function is slightly modified version of MD5 hash.
- // https://tools.ietf.org/html/rfc1321
- // http://www.efgh.com/software/md5.txt
+ // https://web.archive.org/web/20190207230524/https://tools.ietf.org/html/rfc1321
+ // https://web.archive.org/web/20190207230538/http://www.efgh.com/software/md5.txt
//
// Assumption is that data pointer, size are both 4-byte aligned,
// and little endian.
diff --git a/3rdparty/bgfx/src/shader_dxbc.h b/3rdparty/bgfx/src/shader_dxbc.h
index df87d7443a7..356d988f188 100644
--- a/3rdparty/bgfx/src/shader_dxbc.h
+++ b/3rdparty/bgfx/src/shader_dxbc.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/shader_spirv.cpp b/3rdparty/bgfx/src/shader_spirv.cpp
index 83b13c53b93..b4ded142975 100644
--- a/3rdparty/bgfx/src/shader_spirv.cpp
+++ b/3rdparty/bgfx/src/shader_spirv.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/shader_spirv.h b/3rdparty/bgfx/src/shader_spirv.h
index 1fe1c934090..dabd42de2e7 100644
--- a/3rdparty/bgfx/src/shader_spirv.h
+++ b/3rdparty/bgfx/src/shader_spirv.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/topology.cpp b/3rdparty/bgfx/src/topology.cpp
index 1a3e8b6f6ab..cf2b417cfad 100644
--- a/3rdparty/bgfx/src/topology.cpp
+++ b/3rdparty/bgfx/src/topology.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -277,22 +277,21 @@ namespace bgfx
return (_a + _b + _c) * 1.0f/3.0f;
}
- const float* vertexPos(const void* _vertices, uint32_t _stride, uint32_t _index)
+ const bx::Vec3 vertexPos(const void* _vertices, uint32_t _stride, uint32_t _index)
{
const uint8_t* vertices = (const uint8_t*)_vertices;
- return (const float*)&vertices[_index*_stride];
+ return bx::load<bx::Vec3>(&vertices[_index*_stride]);
}
- inline float distanceDir(const float* __restrict _dir, const void* __restrict _vertices, uint32_t _stride, uint32_t _index)
+ inline float distanceDir(const float* _dir, const void* _vertices, uint32_t _stride, uint32_t _index)
{
- return bx::vec3Dot(vertexPos(_vertices, _stride, _index), _dir);
+ return bx::dot(vertexPos(_vertices, _stride, _index), bx::load<bx::Vec3>(_dir) );
}
- inline float distancePos(const float* __restrict _pos, const void* __restrict _vertices, uint32_t _stride, uint32_t _index)
+ inline float distancePos(const float* _pos, const void* _vertices, uint32_t _stride, uint32_t _index)
{
- float tmp[3];
- bx::vec3Sub(tmp, _pos, vertexPos(_vertices, _stride, _index) );
- return bx::sqrt(bx::vec3Dot(tmp, tmp) );
+ const bx::Vec3 tmp = bx::sub(bx::load<bx::Vec3>(_pos), vertexPos(_vertices, _stride, _index) );
+ return bx::sqrt(bx::dot(tmp, tmp) );
}
typedef float (*KeyFn)(float, float, float);
@@ -300,10 +299,10 @@ namespace bgfx
template<typename IndexT, DistanceFn dfn, KeyFn kfn, uint32_t xorBits>
inline void calcSortKeys(
- uint32_t* __restrict _keys
- , uint32_t* __restrict _values
+ uint32_t* _keys
+ , uint32_t* _values
, const float _dirOrPos[3]
- , const void* __restrict _vertices
+ , const void* _vertices
, uint32_t _stride
, const IndexT* _indices
, uint32_t _num
diff --git a/3rdparty/bgfx/src/topology.h b/3rdparty/bgfx/src/topology.h
index 896e6e572f8..bb164115309 100644
--- a/3rdparty/bgfx/src/topology.h
+++ b/3rdparty/bgfx/src/topology.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/src/vertexdecl.cpp b/3rdparty/bgfx/src/vertexdecl.cpp
index 6c6358626d1..099b4b03635 100644
--- a/3rdparty/bgfx/src/vertexdecl.cpp
+++ b/3rdparty/bgfx/src/vertexdecl.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -49,6 +49,7 @@ namespace bgfx
&s_attribTypeSizeD3D1x, // Direct3D12
&s_attribTypeSizeD3D1x, // Gnm
&s_attribTypeSizeGl, // Metal
+ &s_attribTypeSizeGl, // Nvn
&s_attribTypeSizeGl, // OpenGLES
&s_attribTypeSizeGl, // OpenGL
&s_attribTypeSizeD3D1x, // Vulkan
@@ -62,16 +63,16 @@ namespace bgfx
s_attribTypeSize[RendererType::Count] = s_attribTypeSize[_type];
}
- VertexDecl::VertexDecl()
+ VertexLayout::VertexLayout()
: m_stride(0)
{
// BK - struct need to have ctor to qualify as non-POD data.
// Need this to catch programming errors when serializing struct.
}
- VertexDecl& VertexDecl::begin(RendererType::Enum _renderer)
+ VertexLayout& VertexLayout::begin(RendererType::Enum _renderer)
{
- m_hash = _renderer; // use hash to store renderer type while building VertexDecl.
+ m_hash = _renderer; // use hash to store renderer type while building VertexLayout.
m_stride = 0;
bx::memSet(m_attributes, 0xff, sizeof(m_attributes) );
bx::memSet(m_offset, 0, sizeof(m_offset) );
@@ -79,7 +80,7 @@ namespace bgfx
return *this;
}
- void VertexDecl::end()
+ void VertexLayout::end()
{
bx::HashMurmur2A murmur;
murmur.begin();
@@ -89,7 +90,7 @@ namespace bgfx
m_hash = murmur.end();
}
- VertexDecl& VertexDecl::add(Attrib::Enum _attrib, uint8_t _num, AttribType::Enum _type, bool _normalized, bool _asInt)
+ VertexLayout& VertexLayout::add(Attrib::Enum _attrib, uint8_t _num, AttribType::Enum _type, bool _normalized, bool _asInt)
{
const uint16_t encodedNorm = (_normalized&1)<<7;
const uint16_t encodedType = (_type&7)<<3;
@@ -103,14 +104,14 @@ namespace bgfx
return *this;
}
- VertexDecl& VertexDecl::skip(uint8_t _num)
+ VertexLayout& VertexLayout::skip(uint8_t _num)
{
m_stride += _num;
return *this;
}
- void VertexDecl::decode(Attrib::Enum _attrib, uint8_t& _num, AttribType::Enum& _type, bool& _normalized, bool& _asInt) const
+ void VertexLayout::decode(Attrib::Enum _attrib, uint8_t& _num, AttribType::Enum& _type, bool& _normalized, bool& _asInt) const
{
uint16_t val = m_attributes[_attrib];
_num = (val&3)+1;
@@ -240,7 +241,7 @@ namespace bgfx
return s_attribTypeToId[_attr].id;
}
- int32_t write(bx::WriterI* _writer, const VertexDecl& _decl, bx::Error* _err)
+ int32_t write(bx::WriterI* _writer, const VertexLayout& _layout, bx::Error* _err)
{
BX_ERROR_SCOPE(_err);
@@ -249,22 +250,22 @@ namespace bgfx
for (uint32_t attr = 0; attr < Attrib::Count; ++attr)
{
- numAttrs += UINT16_MAX == _decl.m_attributes[attr] ? 0 : 1;
+ numAttrs += UINT16_MAX == _layout.m_attributes[attr] ? 0 : 1;
}
total += bx::write(_writer, numAttrs, _err);
- total += bx::write(_writer, _decl.m_stride, _err);
+ total += bx::write(_writer, _layout.m_stride, _err);
for (uint32_t attr = 0; attr < Attrib::Count; ++attr)
{
- if (UINT16_MAX != _decl.m_attributes[attr])
+ if (UINT16_MAX != _layout.m_attributes[attr])
{
uint8_t num;
AttribType::Enum type;
bool normalized;
bool asInt;
- _decl.decode(Attrib::Enum(attr), num, type, normalized, asInt);
- total += bx::write(_writer, _decl.m_offset[attr], _err);
+ _layout.decode(Attrib::Enum(attr), num, type, normalized, asInt);
+ total += bx::write(_writer, _layout.m_offset[attr], _err);
total += bx::write(_writer, s_attribToId[attr].id, _err);
total += bx::write(_writer, num, _err);
total += bx::write(_writer, s_attribTypeToId[type].id, _err);
@@ -276,7 +277,7 @@ namespace bgfx
return total;
}
- int32_t read(bx::ReaderI* _reader, VertexDecl& _decl, bx::Error* _err)
+ int32_t read(bx::ReaderI* _reader, VertexLayout& _layout, bx::Error* _err)
{
BX_ERROR_SCOPE(_err);
@@ -293,7 +294,7 @@ namespace bgfx
return total;
}
- _decl.begin();
+ _layout.begin();
for (uint32_t ii = 0; ii < numAttrs; ++ii)
{
@@ -325,32 +326,32 @@ namespace bgfx
if (Attrib::Count != attr
&& AttribType::Count != type)
{
- _decl.add(attr, num, type, normalized, asInt);
- _decl.m_offset[attr] = offset;
+ _layout.add(attr, num, type, normalized, asInt);
+ _layout.m_offset[attr] = offset;
}
}
- _decl.end();
- _decl.m_stride = stride;
+ _layout.end();
+ _layout.m_stride = stride;
return total;
}
- void vertexPack(const float _input[4], bool _inputNormalized, Attrib::Enum _attr, const VertexDecl& _decl, void* _data, uint32_t _index)
+ void vertexPack(const float _input[4], bool _inputNormalized, Attrib::Enum _attr, const VertexLayout& _layout, void* _data, uint32_t _index)
{
- if (!_decl.has(_attr) )
+ if (!_layout.has(_attr) )
{
return;
}
- uint32_t stride = _decl.getStride();
- uint8_t* data = (uint8_t*)_data + _index*stride + _decl.getOffset(_attr);
+ uint32_t stride = _layout.getStride();
+ uint8_t* data = (uint8_t*)_data + _index*stride + _layout.getOffset(_attr);
uint8_t num;
AttribType::Enum type;
bool normalized;
bool asInt;
- _decl.decode(_attr, num, type, normalized, asInt);
+ _layout.decode(_attr, num, type, normalized, asInt);
switch (type)
{
@@ -492,22 +493,22 @@ namespace bgfx
}
}
- void vertexUnpack(float _output[4], Attrib::Enum _attr, const VertexDecl& _decl, const void* _data, uint32_t _index)
+ void vertexUnpack(float _output[4], Attrib::Enum _attr, const VertexLayout& _layout, const void* _data, uint32_t _index)
{
- if (!_decl.has(_attr) )
+ if (!_layout.has(_attr) )
{
bx::memSet(_output, 0, 4*sizeof(float) );
return;
}
- uint32_t stride = _decl.getStride();
- uint8_t* data = (uint8_t*)_data + _index*stride + _decl.getOffset(_attr);
+ uint32_t stride = _layout.getStride();
+ uint8_t* data = (uint8_t*)_data + _index*stride + _layout.getOffset(_attr);
uint8_t num;
AttribType::Enum type;
bool normalized;
bool asInt;
- _decl.decode(_attr, num, type, normalized, asInt);
+ _layout.decode(_attr, num, type, normalized, asInt);
switch (type)
{
@@ -618,11 +619,11 @@ namespace bgfx
}
}
- void vertexConvert(const VertexDecl& _destDecl, void* _destData, const VertexDecl& _srcDecl, const void* _srcData, uint32_t _num)
+ void vertexConvert(const VertexLayout& _destLayout, void* _destData, const VertexLayout& _srcLayout, const void* _srcData, uint32_t _num)
{
- if (_destDecl.m_hash == _srcDecl.m_hash)
+ if (_destLayout.m_hash == _srcLayout.m_hash)
{
- bx::memCopy(_destData, _srcData, _srcDecl.getSize(_num) );
+ bx::memCopy(_destData, _srcData, _srcLayout.getSize(_num) );
return;
}
@@ -649,23 +650,23 @@ namespace bgfx
{
Attrib::Enum attr = (Attrib::Enum)ii;
- if (_destDecl.has(attr) )
+ if (_destLayout.has(attr) )
{
ConvertOp& cop = convertOp[numOps];
cop.attr = attr;
- cop.dest = _destDecl.getOffset(attr);
+ cop.dest = _destLayout.getOffset(attr);
uint8_t num;
AttribType::Enum type;
bool normalized;
bool asInt;
- _destDecl.decode(attr, num, type, normalized, asInt);
+ _destLayout.decode(attr, num, type, normalized, asInt);
cop.size = (*s_attribTypeSize[0])[type][num-1];
- if (_srcDecl.has(attr) )
+ if (_srcLayout.has(attr) )
{
- cop.src = _srcDecl.getOffset(attr);
- cop.op = _destDecl.m_attributes[attr] == _srcDecl.m_attributes[attr] ? ConvertOp::Copy : ConvertOp::Convert;
+ cop.src = _srcLayout.getOffset(attr);
+ cop.op = _destLayout.m_attributes[attr] == _srcLayout.m_attributes[attr] ? ConvertOp::Copy : ConvertOp::Convert;
}
else
{
@@ -679,10 +680,10 @@ namespace bgfx
if (0 < numOps)
{
const uint8_t* src = (const uint8_t*)_srcData;
- uint32_t srcStride = _srcDecl.getStride();
+ uint32_t srcStride = _srcLayout.getStride();
uint8_t* dest = (uint8_t*)_destData;
- uint32_t destStride = _destDecl.getStride();
+ uint32_t destStride = _destLayout.getStride();
float unpacked[4];
@@ -703,8 +704,8 @@ namespace bgfx
break;
case ConvertOp::Convert:
- vertexUnpack(unpacked, cop.attr, _srcDecl, src);
- vertexPack(unpacked, true, cop.attr, _destDecl, dest);
+ vertexUnpack(unpacked, cop.attr, _srcLayout, src);
+ vertexPack(unpacked, true, cop.attr, _destLayout, dest);
break;
}
}
@@ -723,7 +724,7 @@ namespace bgfx
return xx*xx + yy*yy + zz*zz;
}
- uint16_t weldVerticesRef(uint16_t* _output, const VertexDecl& _decl, const void* _data, uint16_t _num, float _epsilon)
+ uint16_t weldVerticesRef(uint16_t* _output, const VertexLayout& _layout, const void* _data, uint16_t _num, float _epsilon)
{
// Brute force slow vertex welding...
const float epsilonSq = _epsilon*_epsilon;
@@ -742,7 +743,7 @@ namespace bgfx
++numVertices;
float pos[4];
- vertexUnpack(pos, Attrib::Position, _decl, _data, ii);
+ vertexUnpack(pos, Attrib::Position, _layout, _data, ii);
for (uint32_t jj = 0; jj < _num; ++jj)
{
@@ -752,7 +753,7 @@ namespace bgfx
}
float test[4];
- vertexUnpack(test, Attrib::Position, _decl, _data, jj);
+ vertexUnpack(test, Attrib::Position, _layout, _data, jj);
if (sqLength(test, pos) < epsilonSq)
{
@@ -764,7 +765,7 @@ namespace bgfx
return (uint16_t)numVertices;
}
- uint16_t weldVertices(uint16_t* _output, const VertexDecl& _decl, const void* _data, uint16_t _num, float _epsilon)
+ uint16_t weldVertices(uint16_t* _output, const VertexLayout& _layout, const void* _data, uint16_t _num, float _epsilon)
{
const uint32_t hashSize = bx::uint32_nextpow2(_num);
const uint32_t hashMask = hashSize-1;
@@ -781,14 +782,14 @@ namespace bgfx
for (uint32_t ii = 0; ii < _num; ++ii)
{
float pos[4];
- vertexUnpack(pos, Attrib::Position, _decl, _data, ii);
+ vertexUnpack(pos, Attrib::Position, _layout, _data, ii);
uint32_t hashValue = bx::hash<bx::HashMurmur2A>(pos, 3*sizeof(float) ) & hashMask;
uint16_t offset = hashTable[hashValue];
for (; UINT16_MAX != offset; offset = next[offset])
{
float test[4];
- vertexUnpack(test, Attrib::Position, _decl, _data, _output[offset]);
+ vertexUnpack(test, Attrib::Position, _layout, _data, _output[offset]);
if (sqLength(test, pos) < epsilonSq)
{
diff --git a/3rdparty/bgfx/src/vertexdecl.h b/3rdparty/bgfx/src/vertexdecl.h
index 2b80b1f50c3..46c656cadf7 100644
--- a/3rdparty/bgfx/src/vertexdecl.h
+++ b/3rdparty/bgfx/src/vertexdecl.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -30,10 +30,10 @@ namespace bgfx
AttribType::Enum idToAttribType(uint16_t id);
///
- int32_t write(bx::WriterI* _writer, const bgfx::VertexDecl& _decl, bx::Error* _err = NULL);
+ int32_t write(bx::WriterI* _writer, const bgfx::VertexLayout& _layout, bx::Error* _err = NULL);
///
- int32_t read(bx::ReaderI* _reader, bgfx::VertexDecl& _decl, bx::Error* _err = NULL);
+ int32_t read(bx::ReaderI* _reader, bgfx::VertexLayout& _layout, bx::Error* _err = NULL);
} // namespace bgfx
diff --git a/3rdparty/bgfx/src/vs_clear.bin.h b/3rdparty/bgfx/src/vs_clear.bin.h
index f884364e3fb..fe4986010b2 100644
--- a/3rdparty/bgfx/src/vs_clear.bin.h
+++ b/3rdparty/bgfx/src/vs_clear.bin.h
@@ -1,132 +1,170 @@
-static const uint8_t vs_clear_glsl[164] =
+static const uint8_t vs_clear_glsl[265] =
{
- 0x56, 0x53, 0x48, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x95, 0x00, 0x00, 0x00, 0x61, 0x74, // VSH...........at
- 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, // tribute highp ve
- 0x63, 0x33, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x76, // c3 a_position;.v
+ 0x56, 0x53, 0x48, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, // VSH............b
+ 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x64, 0x65, 0x70, 0x74, 0x68, 0x02, // gfx_clear_depth.
+ 0x01, 0x00, 0x00, 0x01, 0x00, 0xdf, 0x00, 0x00, 0x00, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, // .........attribu
+ 0x74, 0x65, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x61, 0x5f, // te highp vec3 a_
+ 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, // position;.unifor
+ 0x6d, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x62, 0x67, 0x66, // m highp vec4 bgf
+ 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x64, 0x65, 0x70, 0x74, 0x68, 0x3b, 0x0a, 0x76, // x_clear_depth;.v
0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, // oid main ().{.
0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // highp vec4 tmpva
0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, // r_1;. tmpvar_1.
0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // w = 1.0;. tmpva
- 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, // r_1.xyz = a_posi
- 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, // tion;. gl_Posit
- 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, // ion = tmpvar_1;.
- 0x7d, 0x0a, 0x0a, 0x00, // }...
+ 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, // r_1.xy = a_posit
+ 0x69, 0x6f, 0x6e, 0x2e, 0x78, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // ion.xy;. tmpvar
+ 0x5f, 0x31, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, // _1.z = bgfx_clea
+ 0x72, 0x5f, 0x64, 0x65, 0x70, 0x74, 0x68, 0x2e, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, // r_depth.x;. gl_
+ 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // Position = tmpva
+ 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // r_1;.}...
};
-static const uint8_t vs_clear_spv[568] =
+static const uint8_t vs_clear_spv[863] =
{
- 0x56, 0x53, 0x48, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x02, 0x00, 0x00, 0x03, 0x02, // VSH.......$.....
- 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x08, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, // #.........O.....
- 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, // ................
- 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, // ..GLSL.std.450..
- 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, // ................
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, // ..........main..
- 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, // ..'...*.........
- 0x00, 0x00, 0xf4, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, // ..............ma
- 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x27, 0x00, 0x00, 0x00, 0x61, 0x5f, // in........'...a_
- 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x2a, 0x00, // position......*.
- 0x00, 0x00, 0x40, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x4f, 0x75, 0x74, // ..@entryPointOut
- 0x70, 0x75, 0x74, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, // put.gl_Position.
- 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, // ..G...'.........
- 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, // ..G...*.........
- 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, // ..........!.....
- 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, // .............. .
- 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, // ................
- 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, // ................
- 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, // ..+.............
- 0x80, 0x3f, 0x20, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, // .? ...&.........
- 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x01, 0x00, // ..;...&...'.....
- 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x09, 0x00, // .. ...).........
- 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x03, 0x00, // ..;...)...*.....
- 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, // ..6.............
- 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3d, 0x00, // ..............=.
- 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x51, 0x00, // ......(...'...Q.
- 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, // ......8...(.....
- 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x28, 0x00, // ..Q.......9...(.
- 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3a, 0x00, // ......Q.......:.
- 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, 0x09, 0x00, // ..(.......P.....
- 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x3a, 0x00, // ..;...8...9...:.
- 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3f, 0x00, // ..............?.
- 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x52, 0x00, 0x06, 0x00, 0x09, 0x00, 0x00, 0x00, 0x4e, 0x00, // ..9...R.......N.
- 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3e, 0x00, // ..?...;.......>.
- 0x03, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, // ..*...N.......8.
- 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, // ........
+ 0x56, 0x53, 0x48, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, // VSH............b
+ 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x64, 0x65, 0x70, 0x74, 0x68, 0x02, // gfx_clear_depth.
+ 0x01, 0x00, 0x00, 0x01, 0x00, 0x30, 0x03, 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, // .....0.....#....
+ 0x00, 0x07, 0x00, 0x08, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, // .....d..........
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, // .............GLS
+ 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, // L.std.450.......
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, // ................
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, // .....main..../..
+ 0x00, 0x32, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0xf4, 0x01, 0x00, // .2..............
+ 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, // .........main...
+ 0x00, 0x05, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, // .........$Global
+ 0x00, 0x06, 0x00, 0x08, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, // .............bgf
+ 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x64, 0x65, 0x70, 0x74, 0x68, 0x00, 0x00, 0x00, // x_clear_depth...
+ 0x00, 0x05, 0x00, 0x03, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, // ................
+ 0x00, 0x2f, 0x00, 0x00, 0x00, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, // ./...a_position.
+ 0x00, 0x05, 0x00, 0x0a, 0x00, 0x32, 0x00, 0x00, 0x00, 0x40, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x50, // .....2...@entryP
+ 0x6f, 0x69, 0x6e, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, // ointOutput.gl_Po
+ 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x16, 0x00, 0x00, // sition...H......
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, // .....#.......G..
+ 0x00, 0x16, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x18, 0x00, 0x00, // .........G......
+ 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x18, 0x00, 0x00, // .".......G......
+ 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x2f, 0x00, 0x00, // .!.......G.../..
+ 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x32, 0x00, 0x00, // .........G...2..
+ 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, // ................
+ 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, // .!..............
+ 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, // ..... ..........
+ 0x00, 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, // ................
+ 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, // ................
+ 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, // . .......+......
+ 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x16, 0x00, 0x00, // ................
+ 0x00, 0x09, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x17, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // ..... ..........
+ 0x00, 0x16, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x17, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, // .....;..........
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x19, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // ............. ..
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, // .....+..........
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // ..... ..........
+ 0x00, 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....+..........
+ 0x00, 0x00, 0x00, 0x80, 0x3f, 0x20, 0x00, 0x04, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // ....? ..........
+ 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, // .....;......./..
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x31, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // ..... ...1......
+ 0x00, 0x09, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x31, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, // .....;...1...2..
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // .....6..........
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, // ................
+ 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, // .=.......0.../..
+ 0x00, 0x41, 0x00, 0x06, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, // .A.......M......
+ 0x00, 0x12, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, // .........=......
+ 0x00, 0x4e, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, // .N...M...Q......
+ 0x00, 0x4f, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, // .O...0.......Q..
+ 0x00, 0x06, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .....P...0......
+ 0x00, 0x50, 0x00, 0x07, 0x00, 0x09, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, // .P.......Q...O..
+ 0x00, 0x50, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x04, // .P...N..........
+ 0x00, 0x06, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x52, 0x00, 0x06, // .....U...P...R..
+ 0x00, 0x09, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, // .....c...U...Q..
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x32, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, // .....>...2...c..
+ 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x10, 0x00, // .....8.........
};
-static const uint8_t vs_clear_dx9[175] =
+static const uint8_t vs_clear_dx9[282] =
{
- 0x56, 0x53, 0x48, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x03, // VSH.............
- 0xfe, 0xff, 0xfe, 0xff, 0x14, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, 0x00, 0x00, 0x23, 0x00, // ......CTAB....#.
- 0x00, 0x00, 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, // ......vs_3_0.Mic
- 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, // rosoft (R) HLSL
- 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, // Shader Compiler
- 0x31, 0x30, 0x2e, 0x31, 0x00, 0xab, 0x51, 0x00, 0x00, 0x05, 0x00, 0x00, 0x0f, 0xa0, 0x00, 0x00, // 10.1..Q.........
- 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, // $...@..........
+ 0x56, 0x53, 0x48, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, // VSH............b
+ 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x64, 0x65, 0x70, 0x74, 0x68, 0x02, // gfx_clear_depth.
+ 0x01, 0x00, 0x00, 0x01, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfe, 0xff, 0xfe, 0xff, 0x25, // ...............%
+ 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfe, // .CTAB....[......
+ 0xff, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x54, 0x00, 0x00, // .............T..
+ 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, // .0...........D..
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, // .....bgfx_clear_
+ 0x64, 0x65, 0x70, 0x74, 0x68, 0x00, 0xab, 0xab, 0xab, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, // depth...........
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x73, 0x5f, 0x33, 0x5f, 0x30, 0x00, // .........vs_3_0.
+ 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, // Microsoft (R) HL
+ 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, // SL Shader Compil
+ 0x65, 0x72, 0x20, 0x36, 0x2e, 0x33, 0x2e, 0x39, 0x36, 0x30, 0x30, 0x2e, 0x31, 0x38, 0x36, 0x31, // er 6.3.9600.1861
+ 0x31, 0x00, 0xab, 0xab, 0xab, 0x51, 0x00, 0x00, 0x05, 0x01, 0x00, 0x0f, 0xa0, 0x00, 0x00, 0x80, // 1....Q..........
+ 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, 0x0b, 0xe0, 0x00, 0x00, 0x24, // ...............$
+ 0x90, 0x01, 0x00, 0x60, 0xa0, 0x01, 0x00, 0x25, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x04, // ...`...%........
+ 0xe0, 0x00, 0x00, 0x00, 0xa0, 0xff, 0xff, 0x00, 0x00, 0x00, // ..........
};
-static const uint8_t vs_clear_dx11[388] =
+static const uint8_t vs_clear_dx11[479] =
{
- 0x56, 0x53, 0x48, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x01, 0x00, 0x00, 0x44, 0x58, // VSH.......p...DX
- 0x42, 0x43, 0x35, 0x37, 0xf0, 0x90, 0x23, 0xc6, 0x3b, 0x7a, 0xd4, 0x66, 0x38, 0xf5, 0x51, 0x69, // BC57..#.;z.f8.Qi
- 0x19, 0xa8, 0x01, 0x00, 0x00, 0x00, 0x70, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x30, 0x00, // ......p.......0.
- 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x08, 0x01, 0x00, 0x00, 0x3c, 0x01, 0x00, 0x00, 0x41, 0x6f, // ..........<...Ao
- 0x6e, 0x39, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x02, 0xfe, 0xff, 0x50, 0x00, // n9x...x.......P.
- 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, // ..(.....$...$...
- 0x24, 0x00, 0x00, 0x00, 0x24, 0x00, 0x01, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, // $...$...$.......
- 0xfe, 0xff, 0x51, 0x00, 0x00, 0x05, 0x01, 0x00, 0x0f, 0xa0, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, // ..Q..........?..
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, // ................
- 0x00, 0x80, 0x00, 0x00, 0x0f, 0x90, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, // ................
- 0xe4, 0x90, 0x00, 0x00, 0xe4, 0xa0, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0c, 0xc0, 0x00, 0x00, // ................
- 0xaa, 0x90, 0x01, 0x00, 0x44, 0xa0, 0x01, 0x00, 0x14, 0xa0, 0xff, 0xff, 0x00, 0x00, 0x53, 0x48, // ....D.........SH
- 0x44, 0x52, 0x50, 0x00, 0x00, 0x00, 0x40, 0x00, 0x01, 0x00, 0x14, 0x00, 0x00, 0x00, 0x5f, 0x00, // DRP...@......._.
- 0x00, 0x03, 0x72, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x04, 0xf2, 0x20, // ..r.......g....
- 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x72, 0x20, // ..........6...r
- 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x12, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, // ......F.......6.
- 0x00, 0x05, 0x82, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, // ... .......@....
- 0x80, 0x3f, 0x3e, 0x00, 0x00, 0x01, 0x49, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, // .?>...ISGN,.....
- 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ...... .........
- 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x50, 0x4f, // ..............PO
- 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0xab, 0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x00, // SITION....OSGN,.
- 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, // .......... .....
- 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, // ................
- 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x00, 0x01, // ..SV_POSITION...
- 0x01, 0x00, 0x00, 0x00, // ....
+ 0x56, 0x53, 0x48, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, // VSH............b
+ 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x64, 0x65, 0x70, 0x74, 0x68, 0x02, // gfx_clear_depth.
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0xb0, 0x01, 0x00, 0x00, 0x44, 0x58, 0x42, 0x43, 0x2e, 0xa9, 0xc9, // .........DXBC...
+ 0x97, 0xf8, 0x17, 0xd7, 0x4e, 0xd1, 0x22, 0x2f, 0x75, 0x57, 0x9d, 0x14, 0x2f, 0x01, 0x00, 0x00, // ....N."/uW../...
+ 0x00, 0xb0, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, // .........0......
+ 0x00, 0x48, 0x01, 0x00, 0x00, 0x7c, 0x01, 0x00, 0x00, 0x41, 0x6f, 0x6e, 0x39, 0x90, 0x00, 0x00, // .H...|...Aon9...
+ 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x02, 0xfe, 0xff, 0x5c, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, // .............4..
+ 0x00, 0x01, 0x00, 0x24, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x24, // ...$...0...0...$
+ 0x00, 0x01, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, // ...0............
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xfe, 0xff, 0x51, 0x00, 0x00, 0x05, 0x02, 0x00, 0x0f, // .........Q......
+ 0xa0, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ....?...........
+ 0x00, 0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0x90, 0x02, 0x00, 0x00, // ................
+ 0x03, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0xe4, 0x90, 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, // ................
+ 0x02, 0x00, 0x00, 0x03, 0x80, 0x02, 0x00, 0xe4, 0xa0, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0c, // ................
+ 0xc0, 0x01, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x44, 0x80, 0x00, 0x00, 0x14, 0x80, 0xff, 0xff, 0x00, // .......D........
+ 0x00, 0x53, 0x48, 0x44, 0x52, 0x78, 0x00, 0x00, 0x00, 0x40, 0x00, 0x01, 0x00, 0x1e, 0x00, 0x00, // .SHDRx...@......
+ 0x00, 0x59, 0x00, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .Y...F. ........
+ 0x00, 0x5f, 0x00, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, // ._...2.......g..
+ 0x04, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, // .. ..........6..
+ 0x05, 0x32, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, // .2 ......F......
+ 0x00, 0x36, 0x00, 0x00, 0x06, 0x42, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x80, 0x20, // .6...B ........
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x20, 0x10, // .........6.... .
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x3e, 0x00, 0x00, // ......@.....?>..
+ 0x01, 0x49, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // .ISGN,..........
+ 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // . ..............
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x03, 0x00, 0x00, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, // .........POSITIO
+ 0x4e, 0x00, 0xab, 0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // N....OSGN,......
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // ..... ..........
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, // .............SV_
+ 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x00, 0x01, 0x01, 0x00, 0x10, 0x00, // POSITION.......
};
-static const uint8_t vs_clear_mtl[504] =
+static const uint8_t vs_clear_mtl[541] =
{
- 0x56, 0x53, 0x48, 0x05, 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 {
- 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, // . float3 a_posi
- 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, // tion [[attribute
- 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, // (0)]];.};.struct
- 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, // xlatMtlShaderOu
- 0x74, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, // tput {. float4
- 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x70, 0x6f, // gl_Position [[po
- 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x73, 0x74, 0x72, // sition]];.};.str
- 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, // uct xlatMtlShade
- 0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x7b, 0x0a, 0x7d, 0x3b, 0x0a, 0x76, 0x65, // rUniform {.};.ve
- 0x72, 0x74, 0x65, 0x78, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, // rtex xlatMtlShad
- 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, // erOutput xlatMtl
- 0x4d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, // Main (xlatMtlSha
- 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x20, // derInput _mtl_i
- 0x5b, 0x5b, 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x2c, 0x20, 0x63, 0x6f, // [[stage_in]], co
- 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, // nstant xlatMtlSh
- 0x61, 0x64, 0x65, 0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x26, 0x20, 0x5f, 0x6d, 0x74, // aderUniform& _mt
- 0x6c, 0x5f, 0x75, 0x20, 0x5b, 0x5b, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, // l_u [[buffer(0)]
- 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, 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;.}...
+ 0x56, 0x53, 0x48, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, // VSH............b
+ 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x64, 0x65, 0x70, 0x74, 0x68, 0x02, // gfx_clear_depth.
+ 0x01, 0x00, 0x00, 0x01, 0x00, 0xee, 0x01, 0x00, 0x00, 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, // .........#includ
+ 0x65, 0x20, 0x3c, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x3e, // e <metal_stdlib>
+ 0x0a, 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x73, 0x69, 0x6d, 0x64, 0x2f, // .#include <simd/
+ 0x73, 0x69, 0x6d, 0x64, 0x2e, 0x68, 0x3e, 0x0a, 0x0a, 0x75, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6e, // simd.h>..using n
+ 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x3b, 0x0a, // amespace metal;.
+ 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x5f, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x0a, // .struct _Global.
+ 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x62, 0x67, 0x66, // {. float4 bgf
+ 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x64, 0x65, 0x70, 0x74, 0x68, 0x3b, 0x0a, 0x7d, // x_clear_depth;.}
+ 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, // ;..struct xlatMt
+ 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x5f, 0x6f, 0x75, 0x74, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, // lMain_out.{.
+ 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, // float4 gl_Positi
+ 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5d, 0x5d, 0x3b, // on [[position]];
+ 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, // .};..struct xlat
+ 0x4d, 0x74, 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, // MtlMain_in.{.
+ 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, // float3 a_positi
+ 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x30, // on [[attribute(0
+ 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x20, // )]];.};..vertex
+ 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x5f, 0x6f, 0x75, 0x74, 0x20, // xlatMtlMain_out
+ 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x28, 0x78, 0x6c, 0x61, 0x74, // xlatMtlMain(xlat
+ 0x4d, 0x74, 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x20, 0x69, 0x6e, 0x20, 0x5b, 0x5b, // MtlMain_in in [[
+ 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x73, // stage_in]], cons
+ 0x74, 0x61, 0x6e, 0x74, 0x20, 0x5f, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x26, 0x20, 0x5f, 0x6d, // tant _Global& _m
+ 0x74, 0x6c, 0x5f, 0x75, 0x20, 0x5b, 0x5b, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x28, 0x30, 0x29, // tl_u [[buffer(0)
+ 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, // ]]).{. xlatMt
+ 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, // lMain_out out =
+ 0x7b, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x67, 0x6c, 0x5f, 0x50, // {};. out.gl_P
+ 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, // osition = float4
+ 0x28, 0x69, 0x6e, 0x2e, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x78, // (in.a_position.x
+ 0x79, 0x2c, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x2e, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, // y, _mtl_u.bgfx_c
+ 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x64, 0x65, 0x70, 0x74, 0x68, 0x2e, 0x78, 0x2c, 0x20, 0x31, 0x2e, // lear_depth.x, 1.
+ 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, // 0);. return o
+ 0x75, 0x74, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, 0x01, 0x01, 0x00, 0x10, 0x00, // ut;.}........
};
extern const uint8_t* vs_clear_pssl;
extern const uint32_t vs_clear_pssl_size;
diff --git a/3rdparty/bgfx/src/vs_clear.sc b/3rdparty/bgfx/src/vs_clear.sc
index 39abd06d212..a7ebdc992b7 100644
--- a/3rdparty/bgfx/src/vs_clear.sc
+++ b/3rdparty/bgfx/src/vs_clear.sc
@@ -1,13 +1,15 @@
$input a_position
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include "bgfx_shader.sh"
+uniform vec4 bgfx_clear_depth;
+
void main()
{
- gl_Position = vec4(a_position, 1.0);
+ gl_Position = vec4(a_position.xy, bgfx_clear_depth.x, 1.0);
}
diff --git a/3rdparty/bgfx/src/vs_debugfont.bin.h b/3rdparty/bgfx/src/vs_debugfont.bin.h
index a1bac2f0fe8..52d350dbea9 100644
--- a/3rdparty/bgfx/src/vs_debugfont.bin.h
+++ b/3rdparty/bgfx/src/vs_debugfont.bin.h
@@ -33,99 +33,101 @@ 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_spv[1456] =
+static const uint8_t vs_debugfont_spv[1476] =
{
- 0x56, 0x53, 0x48, 0x05, 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......
- 0x80, 0x05, 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x08, 0x00, // ......#.........
- 0xb6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, // ................
- 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, // ........GLSL.std
- 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // .450............
- 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, // ................
- 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, // main....D...G...
- 0x4b, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, // K...O......._...
- 0x62, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, // b...f...........
- 0xf4, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, // ............main
- 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6c, 0x6f, // ........*...$Glo
- 0x62, 0x61, 0x6c, 0x00, 0x06, 0x00, 0x07, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // bal.....*.......
- 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x00, // u_modelViewProj.
- 0x05, 0x00, 0x03, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, // ....,...........
- 0x44, 0x00, 0x00, 0x00, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x00, 0x00, 0x00, 0x00, // D...a_color0....
- 0x05, 0x00, 0x05, 0x00, 0x47, 0x00, 0x00, 0x00, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x31, // ....G...a_color1
- 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x61, 0x5f, 0x70, 0x6f, // ........K...a_po
- 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x4f, 0x00, 0x00, 0x00, // sition......O...
- 0x61, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x00, 0x05, 0x00, 0x0a, 0x00, // a_texcoord0.....
- 0x5c, 0x00, 0x00, 0x00, 0x40, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x4f, // ....@entryPointO
- 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, // utput.gl_Positio
- 0x6e, 0x00, 0x00, 0x00, 0x05, 0x00, 0x09, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x40, 0x65, 0x6e, 0x74, // n......._...@ent
- 0x72, 0x79, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x76, 0x5f, // ryPointOutput.v_
- 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x00, 0x00, 0x05, 0x00, 0x09, 0x00, 0x62, 0x00, 0x00, 0x00, // color0......b...
+ 0x56, 0x53, 0x48, 0x06, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xbe, 0x22, 0x66, 0x01, 0x00, 0x0f, 0x75, // VSH......."f...u
+ 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x01, // _modelViewProj..
+ 0x00, 0x00, 0x04, 0x00, 0x90, 0x05, 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, // ..........#.....
+ 0x07, 0x00, 0x08, 0x00, 0xb5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, // ................
+ 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, // ............GLSL
+ 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, // .std.450........
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+ 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, // ....main....D...
+ 0x47, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, // G...K...O.......
+ 0x5f, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, // _...b...f.......
+ 0x05, 0x00, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, // ................
+ 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, // main........*...
+ 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x00, 0x06, 0x00, 0x07, 0x00, 0x2a, 0x00, 0x00, 0x00, // $Global.....*...
+ 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, // ....u_modelViewP
+ 0x72, 0x6f, 0x6a, 0x00, 0x05, 0x00, 0x03, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // roj.....,.......
+ 0x05, 0x00, 0x05, 0x00, 0x44, 0x00, 0x00, 0x00, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, // ....D...a_color0
+ 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x47, 0x00, 0x00, 0x00, 0x61, 0x5f, 0x63, 0x6f, // ........G...a_co
+ 0x6c, 0x6f, 0x72, 0x31, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x4b, 0x00, 0x00, 0x00, // lor1........K...
+ 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, // a_position......
+ 0x4f, 0x00, 0x00, 0x00, 0x61, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x00, // O...a_texcoord0.
+ 0x05, 0x00, 0x0a, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x40, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x50, 0x6f, // ........@entryPo
+ 0x69, 0x6e, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, // intOutput.gl_Pos
+ 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x05, 0x00, 0x09, 0x00, 0x5f, 0x00, 0x00, 0x00, // ition......._...
0x40, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, // @entryPointOutpu
- 0x74, 0x2e, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x31, 0x00, 0x00, 0x05, 0x00, 0x0a, 0x00, // t.v_color1......
- 0x66, 0x00, 0x00, 0x00, 0x40, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x4f, // f...@entryPointO
- 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, // utput.v_texcoord
- 0x30, 0x00, 0x00, 0x00, 0x48, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0...H...*.......
- 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ....H...*.......
- 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x2a, 0x00, 0x00, 0x00, // #.......H...*...
- 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, // ............G...
- 0x2a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x2c, 0x00, 0x00, 0x00, // *.......G...,...
- 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x44, 0x00, 0x00, 0x00, // ".......G...D...
- 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x47, 0x00, 0x00, 0x00, // ........G...G...
- 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4b, 0x00, 0x00, 0x00, // ........G...K...
- 0x1e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4f, 0x00, 0x00, 0x00, // ........G...O...
- 0x1e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x5c, 0x00, 0x00, 0x00, // ........G.......
- 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x5f, 0x00, 0x00, 0x00, // ........G..._...
- 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x62, 0x00, 0x00, 0x00, // ........G...b...
- 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x66, 0x00, 0x00, 0x00, // ........G...f...
- 0x1e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, // ................
- 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, // !...............
- 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, // .... ...........
- 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, // ................
- 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, // ................
- 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x17, 0x00, 0x00, 0x00, // ................
- 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, // .......+.......
- 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x2b, 0x00, 0x04, 0x00, 0x17, 0x00, 0x00, 0x00, // .......?+.......
- 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, // #...........)...
- 0x07, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x2a, 0x00, 0x00, 0x00, // ............*...
- 0x29, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // )... ...+.......
- 0x2a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, // *...;...+...,...
- 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // .... ...-.......
- 0x29, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x43, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // )... ...C.......
- 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x43, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, // ....;...C...D...
- 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x43, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, // ....;...C...G...
- 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // .... ...J.......
- 0x09, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, // ....;...J...K...
- 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // .... ...N.......
- 0x0b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, // ....;...N...O...
- 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, // .... ...[.......
- 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, // ....;...[.......
- 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, // ....;...[..._...
- 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, // ....;...[...b...
- 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x65, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, // .... ...e.......
- 0x0b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x65, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, // ....;...e...f...
- 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, // ....6...........
- 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, // ................
- 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, // =.......E...D...
- 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, // =.......H...G...
- 0x3d, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, // =.......L...K...
- 0x3d, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, // =.......P...O...
- 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, // Q...........L...
- 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, // ....Q...........
- 0x4c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, // L.......Q.......
- 0x81, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, // ....L.......P...
- 0x07, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, // ................
- 0x81, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x2d, 0x00, 0x00, 0x00, // ........A...-...
- 0x83, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, // ....,...#...=...
- 0x29, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x90, 0x00, 0x05, 0x00, // )...............
- 0x07, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, // ................
- 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xb3, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, // Q...............
- 0x01, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, // ................
- 0xb3, 0x00, 0x00, 0x00, 0x52, 0x00, 0x06, 0x00, 0x07, 0x00, 0x00, 0x00, 0xb5, 0x00, 0x00, 0x00, // ....R...........
- 0x8f, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, // ............>...
- 0x5c, 0x00, 0x00, 0x00, 0xb5, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x5f, 0x00, 0x00, 0x00, // ........>..._...
- 0x45, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x62, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, // E...>...b...H...
- 0x3e, 0x00, 0x03, 0x00, 0x66, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, // >...f...P.......
- 0x38, 0x00, 0x01, 0x00, 0x00, 0x04, 0x05, 0x00, 0x06, 0x00, 0x01, 0x00, 0x10, 0x00, 0x40, 0x00, // 8.............@.
+ 0x74, 0x2e, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x00, 0x00, 0x05, 0x00, 0x09, 0x00, // t.v_color0......
+ 0x62, 0x00, 0x00, 0x00, 0x40, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x4f, // b...@entryPointO
+ 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x31, 0x00, 0x00, // utput.v_color1..
+ 0x05, 0x00, 0x0a, 0x00, 0x66, 0x00, 0x00, 0x00, 0x40, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x50, 0x6f, // ....f...@entryPo
+ 0x69, 0x6e, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, // intOutput.v_texc
+ 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x00, 0x00, 0x00, 0x48, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, // oord0...H...*...
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x2a, 0x00, 0x00, 0x00, // ........H...*...
+ 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, // ....#.......H...
+ 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, // *...............
+ 0x47, 0x00, 0x03, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, // G...*.......G...
+ 0x2c, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, // ,...".......G...
+ 0x2c, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, // ,...!.......G...
+ 0x44, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, // D...........G...
+ 0x47, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, // G...........G...
+ 0x4b, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, // K...........G...
+ 0x4f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, // O...........G...
+ 0x5c, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, // ............G...
+ 0x5f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, // _...........G...
+ 0x62, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, // b...........G...
+ 0x66, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, // f...............
+ 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // ....!...........
+ 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, // ........ .......
+ 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, // ................
+ 0x09, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, // ................
+ 0x0b, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, // ................
+ 0x17, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, // .... .......+...
+ 0x06, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x2b, 0x00, 0x04, 0x00, // ...........?+...
+ 0x17, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x04, 0x00, // ....#...........
+ 0x29, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, // )...............
+ 0x2a, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x2b, 0x00, 0x00, 0x00, // *...)... ...+...
+ 0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x2b, 0x00, 0x00, 0x00, // ....*...;...+...
+ 0x2c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x2d, 0x00, 0x00, 0x00, // ,....... ...-...
+ 0x02, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x43, 0x00, 0x00, 0x00, // ....)... ...C...
+ 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x43, 0x00, 0x00, 0x00, // ........;...C...
+ 0x44, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x43, 0x00, 0x00, 0x00, // D.......;...C...
+ 0x47, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x4a, 0x00, 0x00, 0x00, // G....... ...J...
+ 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4a, 0x00, 0x00, 0x00, // ........;...J...
+ 0x4b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x4e, 0x00, 0x00, 0x00, // K....... ...N...
+ 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4e, 0x00, 0x00, 0x00, // ........;...N...
+ 0x4f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x5b, 0x00, 0x00, 0x00, // O....... ...[...
+ 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x5b, 0x00, 0x00, 0x00, // ........;...[...
+ 0x5c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x5b, 0x00, 0x00, 0x00, // ........;...[...
+ 0x5f, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x5b, 0x00, 0x00, 0x00, // _.......;...[...
+ 0x62, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x65, 0x00, 0x00, 0x00, // b....... ...e...
+ 0x03, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x65, 0x00, 0x00, 0x00, // ........;...e...
+ 0x66, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, // f.......6.......
+ 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, // ................
+ 0x05, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, // ....=.......E...
+ 0x44, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, // D...=.......H...
+ 0x47, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, // G...=.......L...
+ 0x4b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, // K...=.......P...
+ 0x4f, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, // O...Q...........
+ 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, // L.......Q.......
+ 0x80, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, // ....L.......Q...
+ 0x06, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // ........L.......
+ 0x50, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, // P...............
+ 0x80, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, // ............A...
+ 0x2d, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, // -.......,...#...
+ 0x3d, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, // =...)...........
+ 0x90, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, // ................
+ 0x84, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, // ....Q...........
+ 0x85, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, // ................
+ 0x8f, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x52, 0x00, 0x06, 0x00, 0x07, 0x00, 0x00, 0x00, // ........R.......
+ 0xb4, 0x00, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // ................
+ 0x3e, 0x00, 0x03, 0x00, 0x5c, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, // >...........>...
+ 0x5f, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x62, 0x00, 0x00, 0x00, // _...E...>...b...
+ 0x48, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x66, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, // H...>...f...P...
+ 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x00, 0x04, 0x05, 0x00, 0x06, 0x00, 0x01, 0x00, // ....8...........
+ 0x10, 0x00, 0x40, 0x00, // ..@.
};
static const uint8_t vs_debugfont_dx9[385] =
{
diff --git a/3rdparty/bgfx/src/vs_debugfont.sc b/3rdparty/bgfx/src/vs_debugfont.sc
index 8c09d62a6a7..50db62d1fc8 100644
--- a/3rdparty/bgfx/src/vs_debugfont.sc
+++ b/3rdparty/bgfx/src/vs_debugfont.sc
@@ -2,7 +2,7 @@ $input a_position, a_color0, a_color1, a_texcoord0
$output v_color0, v_color1, v_texcoord0
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/