diff --git a/scripts/bgfx.lua b/scripts/bgfx.lua index c76dd45ab..b02ae85b9 100644 --- a/scripts/bgfx.lua +++ b/scripts/bgfx.lua @@ -35,181 +35,191 @@ function overridefiles(_srcPath, _dstPath, _files) } end -function bgfxProject(_name, _kind, _defines) - project ("bgfx" .. _name) - uuid (os.uuid("bgfx" .. _name)) - bgfxProjectBase(_kind, _defines) - copyLib() -end - function bgfxProjectBase(_kind, _defines) - kind (_kind) - if _kind == "SharedLib" then - defines { - "BGFX_SHARED_LIB_BUILD=1", - } - - links { - "bimg", - "bx", - } - - configuration { "vs20* or mingw*" } - links { - "gdi32", - "psapi", - } - - configuration { "mingw*" } - linkoptions { - "-shared", - } - - configuration { "linux-*" } - buildoptions { - "-fPIC", - } - - configuration {} - end - - includedirs { - path.join(BGFX_DIR, "3rdparty"), - path.join(BX_DIR, "include"), - path.join(BIMG_DIR, "include"), - } + kind (_kind) + if _kind == "SharedLib" then defines { - _defines, + "BGFX_SHARED_LIB_BUILD=1", } links { + "bimg", "bx", } - if _OPTIONS["with-glfw"] then - defines { - "BGFX_CONFIG_MULTITHREADED=0", - } - end - - configuration { "Debug" } - defines { - "BGFX_CONFIG_DEBUG=1", - } - - configuration { "vs* or mingw*", "not durango" } - includedirs { - path.join(BGFX_DIR, "3rdparty/dxsdk/include"), - } - - configuration { "android*" } + configuration { "vs20* or mingw*" } links { - "EGL", - "GLESv2", + "gdi32", + "psapi", } - configuration { "winstore*" } + configuration { "mingw*" } linkoptions { - "/ignore:4264" -- LNK4264: archiving object file compiled with /ZW into a static library; note that when authoring Windows Runtime types it is not recommended to link with a static library that contains Windows Runtime metadata + "-shared", } - configuration { "*clang*" } + configuration { "linux-*" } buildoptions { - "-Wno-microsoft-enum-value", -- enumerator value is not representable in the underlying type 'int' - "-Wno-microsoft-const-init", -- default initialization of an object of const type '' without a user-provided default constructor is a Microsoft extension - } - - configuration { "osx" } - linkoptions { - "-framework Cocoa", - "-framework QuartzCore", - "-framework OpenGL", - "-weak_framework Metal", - "-weak_framework MetalKit", - } - - configuration { "not linux-steamlink", "not NX32", "not NX64" } - includedirs { - -- steamlink has EGL headers modified... - -- NX has EGL headers modified... - path.join(BGFX_DIR, "3rdparty/khronos"), - } - - configuration { "linux-steamlink" } - defines { - "EGL_API_FB", + "-fPIC", } configuration {} + end + includedirs { + path.join(BGFX_DIR, "3rdparty"), + path.join(BX_DIR, "include"), + path.join(BIMG_DIR, "include"), + } + + defines { + _defines, + } + + links { + "bx", + } + + if _OPTIONS["with-glfw"] then + defines { + "BGFX_CONFIG_MULTITHREADED=0", + } + end + + configuration { "Debug" } + defines { + "BGFX_CONFIG_DEBUG=1", + } + + configuration { "vs* or mingw*", "not durango" } includedirs { - path.join(BGFX_DIR, "include"), + path.join(BGFX_DIR, "3rdparty/dxsdk/include"), } - files { - path.join(BGFX_DIR, "include/**.h"), - path.join(BGFX_DIR, "src/**.cpp"), - path.join(BGFX_DIR, "src/**.h"), - path.join(BGFX_DIR, "scripts/**.natvis"), + configuration { "android*" } + links { + "EGL", + "GLESv2", } - removefiles { - path.join(BGFX_DIR, "src/**.bin.h"), + configuration { "winstore*" } + linkoptions { + "/ignore:4264" -- LNK4264: archiving object file compiled with /ZW into a static library; note that when authoring Windows Runtime types it is not recommended to link with a static library that contains Windows Runtime metadata } - overridefiles(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), { - path.join(BGFX_DIR, "src/renderer_gnm.cpp"), - path.join(BGFX_DIR, "src/renderer_gnm.h"), - }) + configuration { "*clang*" } + buildoptions { + "-Wno-microsoft-enum-value", -- enumerator value is not representable in the underlying type 'int' + "-Wno-microsoft-const-init", -- default initialization of an object of const type '' without a user-provided default constructor is a Microsoft extension + } - if _OPTIONS["with-amalgamated"] then - excludes { - path.join(BGFX_DIR, "src/bgfx.cpp"), - path.join(BGFX_DIR, "src/debug_**.cpp"), - path.join(BGFX_DIR, "src/dxgi.cpp"), - path.join(BGFX_DIR, "src/glcontext_**.cpp"), - path.join(BGFX_DIR, "src/hmd**.cpp"), - path.join(BGFX_DIR, "src/image.cpp"), - path.join(BGFX_DIR, "src/nvapi.cpp"), - path.join(BGFX_DIR, "src/renderer_**.cpp"), - path.join(BGFX_DIR, "src/shader**.cpp"), - path.join(BGFX_DIR, "src/topology.cpp"), - path.join(BGFX_DIR, "src/vertexdecl.cpp"), + configuration { "osx" } + linkoptions { + "-framework Cocoa", + "-framework QuartzCore", + "-framework OpenGL", + "-weak_framework Metal", + "-weak_framework MetalKit", + } + + configuration { "not linux-steamlink", "not NX32", "not NX64" } + includedirs { + -- steamlink has EGL headers modified... + -- NX has EGL headers modified... + path.join(BGFX_DIR, "3rdparty/khronos"), + } + + configuration { "linux-steamlink" } + defines { + "EGL_API_FB", + } + + configuration {} + + includedirs { + path.join(BGFX_DIR, "include"), + } + + files { + path.join(BGFX_DIR, "include/**.h"), + path.join(BGFX_DIR, "src/**.cpp"), + path.join(BGFX_DIR, "src/**.h"), + path.join(BGFX_DIR, "scripts/**.natvis"), + } + + removefiles { + path.join(BGFX_DIR, "src/**.bin.h"), + } + + overridefiles(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), { + path.join(BGFX_DIR, "src/renderer_gnm.cpp"), + path.join(BGFX_DIR, "src/renderer_gnm.h"), + }) + + if _OPTIONS["with-amalgamated"] then + excludes { + path.join(BGFX_DIR, "src/bgfx.cpp"), + path.join(BGFX_DIR, "src/debug_**.cpp"), + path.join(BGFX_DIR, "src/dxgi.cpp"), + path.join(BGFX_DIR, "src/glcontext_**.cpp"), + path.join(BGFX_DIR, "src/hmd**.cpp"), + path.join(BGFX_DIR, "src/image.cpp"), + path.join(BGFX_DIR, "src/nvapi.cpp"), + path.join(BGFX_DIR, "src/renderer_**.cpp"), + path.join(BGFX_DIR, "src/shader**.cpp"), + path.join(BGFX_DIR, "src/topology.cpp"), + path.join(BGFX_DIR, "src/vertexdecl.cpp"), + } + + configuration { "xcode* or osx or ios*" } + files { + path.join(BGFX_DIR, "src/amalgamated.mm"), } - configuration { "xcode* or osx or ios*" } - files { - path.join(BGFX_DIR, "src/amalgamated.mm"), - } - - excludes { - path.join(BGFX_DIR, "src/glcontext_**.mm"), - path.join(BGFX_DIR, "src/renderer_**.mm"), - path.join(BGFX_DIR, "src/amalgamated.cpp"), - } - - configuration { "not (xcode* or osx or ios*)" } - excludes { - path.join(BGFX_DIR, "src/**.mm"), - } - - configuration {} - - else - configuration { "xcode* or osx or ios*" } - files { - path.join(BGFX_DIR, "src/glcontext_**.mm"), - path.join(BGFX_DIR, "src/renderer_**.mm"), - } - - configuration {} - excludes { - path.join(BGFX_DIR, "src/amalgamated.**"), + path.join(BGFX_DIR, "src/glcontext_**.mm"), + path.join(BGFX_DIR, "src/renderer_**.mm"), + path.join(BGFX_DIR, "src/amalgamated.cpp"), + } + + configuration { "not (xcode* or osx or ios*)" } + excludes { + path.join(BGFX_DIR, "src/**.mm"), } - end configuration {} + + else + configuration { "xcode* or osx or ios*" } + files { + path.join(BGFX_DIR, "src/glcontext_**.mm"), + path.join(BGFX_DIR, "src/renderer_**.mm"), + } + + configuration {} + + excludes { + path.join(BGFX_DIR, "src/amalgamated.**"), + } + end + + if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), { + path.join(BGFX_DIR, "scripts/bgfx.lua"), }) then + + dofile(path.join(BGFX_DIR, "../bgfx-ext/scripts/bgfx.lua") ) + end + + configuration {} +end + +function bgfxProject(_name, _kind, _defines) + + project ("bgfx" .. _name) + uuid (os.uuid("bgfx" .. _name)) + + bgfxProjectBase(_kind, _defines) + + copyLib() end diff --git a/scripts/shaderc.lua b/scripts/shaderc.lua index cf9acbfad..043bc5c81 100644 --- a/scripts/shaderc.lua +++ b/scripts/shaderc.lua @@ -644,6 +644,11 @@ project "shaderc" "psapi", } + configuration { "osx or linux*" } + links { + "pthread", + } + configuration {} if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), { @@ -660,13 +665,6 @@ project "shaderc" dofile(path.join(BGFX_DIR, "../bgfx-ext/scripts/shaderc.lua") ) end - configuration { "osx or linux*" } - links { - "pthread", - } - - configuration {} - strip() group "tools" diff --git a/src/bgfx.cpp b/src/bgfx.cpp index cd2022cf1..9e60be6b0 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -2329,7 +2329,7 @@ namespace bgfx } else { - _renderCtx->setMarker(data, size); + _renderCtx->setMarker(data, uint16_t(size)-1); } } } diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 7c0934d39..9ea599d7e 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -2769,8 +2769,8 @@ 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 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; diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 6d9d9f45d..0712848f5 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -1981,22 +1981,23 @@ namespace bgfx { namespace d3d11 bx::memCopy(m_uniforms[_loc], _data, _size); } - void setMarker(const char* _marker, uint32_t _size) 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); - } - } - void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override { m_occlusionQuery.invalidate(_handle); } + void setMarker(const char* _marker, uint16_t _len) override + { + if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) ) + { + 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(D3DCOLOR_MARKER, name); + } + } + virtual void setName(Handle _handle, const char* _name, uint16_t _len) override { switch (_handle.type) diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index 2e9adaf87..fe02f3589 100644 --- a/src/renderer_d3d12.cpp +++ b/src/renderer_d3d12.cpp @@ -1859,19 +1859,21 @@ 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 { + m_occlusionQuery.invalidate(_handle); + } + + void setMarker(const char* _marker, uint16_t _len) override + { + BX_UNUSED(_len); + if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) ) { PIX3_SETMARKER(m_commandList, D3DCOLOR_MARKER, _marker); } } - void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override - { - m_occlusionQuery.invalidate(_handle); - } - virtual void setName(Handle _handle, const char* _name, uint16_t _len) override { switch (_handle.type) diff --git a/src/renderer_d3d9.cpp b/src/renderer_d3d9.cpp index 5722187b3..82ae488f4 100644 --- a/src/renderer_d3d9.cpp +++ b/src/renderer_d3d9.cpp @@ -1280,22 +1280,23 @@ namespace bgfx { namespace d3d9 bx::memCopy(m_uniforms[_loc], _data, _size); } - void setMarker(const char* _marker, uint32_t _size) 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); - } - void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override { m_occlusionQuery.invalidate(_handle); } + void setMarker(const char* _marker, uint16_t _len) override + { +#if BGFX_CONFIG_DEBUG_PIX + 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(D3DCOLOR_MARKER, name); +#endif // BGFX_CONFIG_DEBUG_PIX + BX_UNUSED(_marker, _len); + } + virtual void setName(Handle _handle, const char* _name, uint16_t _len) override { BX_UNUSED(_handle, _name, _len) diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index 588b2e9a8..a5375e808 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -2980,16 +2980,16 @@ 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 - { - GL_CHECK(glInsertEventMarker(_size, _marker) ); - } - void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override { m_occlusionQuery.invalidate(_handle); } + void setMarker(const char* _marker, uint16_t _len) override + { + GL_CHECK(glInsertEventMarker(_len, _marker) ); + } + virtual void setName(Handle _handle, const char* _name, uint16_t _len) override { uint16_t len = bx::min(_len, m_maxLabelLen); diff --git a/src/renderer_mtl.mm b/src/renderer_mtl.mm index 53b998bd9..1b157f5f2 100644 --- a/src/renderer_mtl.mm +++ b/src/renderer_mtl.mm @@ -1002,19 +1002,21 @@ 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 + { + BX_UNUSED(_len); + if (BX_ENABLED(BGFX_CONFIG_DEBUG_MTL) ) { m_renderCommandEncoder.insertDebugSignpost(_marker); } } - void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override - { - m_occlusionQuery.invalidate(_handle); - } - virtual void setName(Handle _handle, const char* _name, uint16_t _len) override { BX_UNUSED(_len); @@ -1579,7 +1581,7 @@ namespace bgfx { namespace mtl m_renderCommandEncoder.setVertexBuffer(vb.getBuffer(), offset, 1); m_renderCommandEncoder.drawPrimitives(MTLPrimitiveTypeTriangleStrip, 0, 4, 1); } - + void setAttachment(MTLRenderPassAttachmentDescriptor* _attachmentDescriptor, const Attachment& _at, uint8_t _textureType, bool _resolve) { _attachmentDescriptor.level = _at.mip; @@ -1587,7 +1589,7 @@ namespace bgfx { namespace mtl _attachmentDescriptor.depthPlane = _at.layer; else _attachmentDescriptor.slice = _at.layer; - + if ( _resolve ) { _attachmentDescriptor.resolveLevel = _at.mip; @@ -1642,7 +1644,7 @@ namespace bgfx { namespace mtl ? texture.m_ptr.m_obj : NULL ; - + setAttachment(_renderPassDescriptor.colorAttachments[ii], frameBuffer.m_colorAttachment[ii], texture.m_type, texture.m_ptrMsaa != NULL); } @@ -1657,7 +1659,7 @@ namespace bgfx { namespace mtl 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 */ @@ -3116,7 +3118,7 @@ namespace bgfx { namespace mtl { const Attachment& at = _attachment[ii]; TextureHandle handle = at.handle; - + if (isValid(handle) ) { const TextureMtl& texture = s_renderMtl->m_textures[handle.idx]; diff --git a/src/renderer_noop.cpp b/src/renderer_noop.cpp index 23843e6c5..6ce95ffe1 100644 --- a/src/renderer_noop.cpp +++ b/src/renderer_noop.cpp @@ -226,11 +226,11 @@ 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 { } diff --git a/src/renderer_vk.cpp b/src/renderer_vk.cpp index 353d9917e..008d9dcd6 100644 --- a/src/renderer_vk.cpp +++ b/src/renderer_vk.cpp @@ -2148,15 +2148,15 @@ 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 setMarker(const char* /*_marker*/, uint16_t /*_len*/) override + { + } + virtual void setName(Handle _handle, const char* _name, uint16_t _len) override { BX_UNUSED(_handle, _name, _len)