Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Apps/Playground/Android/BabylonNative/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ target_link_libraries(BabylonNativeJNI
NativeTracing
NativeXr
ScriptLoader
ShaderCache
TestUtils
Window
XMLHttpRequest)
1 change: 1 addition & 0 deletions Apps/Playground/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ target_link_libraries(Playground
PRIVATE NativeInput
PRIVATE NativeOptimizations
PRIVATE NativeTracing
PRIVATE ShaderCache
PRIVATE ScriptLoader
PRIVATE TestUtils
PRIVATE Window
Expand Down
6 changes: 4 additions & 2 deletions Apps/Playground/Shared/AppContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <Babylon/Graphics/Device.h>
#include <Babylon/PerfTrace.h>
#include <Babylon/ScriptLoader.h>
#include <Babylon/ShaderCache.h>

#include <Babylon/Plugins/NativeCamera.h>
#include <Babylon/Plugins/NativeCapture.h>
Expand All @@ -14,6 +13,7 @@
#include <Babylon/Plugins/NativeInput.h>
#include <Babylon/Plugins/NativeOptimizations.h>
#include <Babylon/Plugins/NativeTracing.h>
#include <Babylon/Plugins/ShaderCache.h>
#include <Babylon/Plugins/TestUtils.h>

#include <Babylon/Polyfills/Blob.h>
Expand Down Expand Up @@ -63,7 +63,7 @@ AppContext::AppContext(
m_device.emplace(graphicsConfig);
m_deviceUpdate.emplace(m_device->GetUpdate("update"));

Babylon::ShaderCache::Enabled(true);
Babylon::Plugins::ShaderCache::Enable();

m_device->StartRenderingCurrentFrame();
m_deviceUpdate->Start();
Expand Down Expand Up @@ -142,6 +142,8 @@ AppContext::~AppContext()
m_device->FinishRenderingCurrentFrame();
}

Babylon::Plugins::ShaderCache::Disable();

m_scriptLoader.reset();
m_canvas.reset();
m_input = {};
Expand Down
2 changes: 1 addition & 1 deletion Apps/Playground/Win32/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace
RECT rect;
if (!GetClientRect(hWnd, &rect))
{
return;
throw std::exception{"Unable to get client rect"};
}

auto width = static_cast<size_t>(rect.right - rect.left);
Expand Down
5 changes: 3 additions & 2 deletions Apps/UnitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ set(BABYLONJS_MATERIALS_ASSETS

set(TEST_ASSETS
"JavaScript/dist/tests.javaScript.all.js"
"JavaScript/dist/tests.nativeEngine.shaderCache.js")
"JavaScript/dist/tests.shaderCache.basicScene.js")

set(SOURCES
"Source/App.h"
"Source/App.cpp"
"Source/Tests.ExternalTexture.cpp"
"Source/Tests.JavaScript.cpp"
"Source/Tests.NativeEngine.cpp"
"Source/Tests.ShaderCache.cpp"
"Source/Utils.h"
"Source/Utils.${GRAPHICS_API}.${BABYLON_NATIVE_PLATFORM_IMPL_EXT}")

Expand Down Expand Up @@ -58,6 +58,7 @@ target_link_libraries(UnitTests
PRIVATE NativeEngine
PRIVATE NativeEncoding
PRIVATE ScriptLoader
PRIVATE ShaderCache
PRIVATE UrlLib
PRIVATE Window
PRIVATE XMLHttpRequest
Expand Down
43 changes: 20 additions & 23 deletions Apps/UnitTests/JavaScript/dist/tests.javaScript.all.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ module.exports = BABYLON;
var __webpack_exports__ = {};
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
(() => {
/*!***********************************************!*\
!*** ./src/tests.nativeEngine.shaderCache.ts ***!
\***********************************************/
/*!*********************************************!*\
!*** ./src/tests.shaderCache.basicScene.ts ***!
\*********************************************/
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _babylonjs_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babylonjs/core */ "@babylonjs/core");
/* harmony import */ var _babylonjs_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babylonjs_core__WEBPACK_IMPORTED_MODULE_0__);
Expand Down
2 changes: 1 addition & 1 deletion Apps/UnitTests/JavaScript/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
devtool: false,
entry: {
"tests.javaScript.all": './src/tests.javaScript.all.ts',
"tests.nativeEngine.shaderCache": './src/tests.nativeEngine.shaderCache.ts',
"tests.shaderCache.basicScene": './src/tests.shaderCache.basicScene.ts',
},
externals: {
"@babylonjs/core": "BABYLON",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include <Babylon/Polyfills/Console.h>
#include <Babylon/Polyfills/Window.h>
#include <Babylon/Plugins/NativeEngine.h>
#include <Babylon/Plugins/ShaderCache.h>
#include <Babylon/ScriptLoader.h>
#include <Babylon/ShaderCache.h>

#include <chrono>
#include <optional>
Expand All @@ -18,9 +18,9 @@ using namespace std::chrono_literals;

extern Babylon::Graphics::Configuration g_deviceConfig;

TEST(NativeEngine, ShaderCache)
TEST(ShaderCache, SaveAndLoad)
{
Babylon::ShaderCache::Enabled(true);
Babylon::Plugins::ShaderCache::Enable();

Babylon::Graphics::Device device{g_deviceConfig};
Babylon::Graphics::DeviceUpdate update{device.GetUpdate("update")};
Expand Down Expand Up @@ -61,7 +61,7 @@ TEST(NativeEngine, ShaderCache)

Babylon::ScriptLoader loader{runtime};
loader.LoadScript("app:///Assets/babylon.max.js");
loader.LoadScript("app:///Assets/tests.nativeEngine.shaderCache.js");
loader.LoadScript("app:///Assets/tests.shaderCache.basicScene.js");
loader.Dispatch([&scriptIsDone](Napi::Env) {
scriptIsDone.set_value();
});
Expand All @@ -80,16 +80,18 @@ TEST(NativeEngine, ShaderCache)
static const char* shaderCacheFileName = "shaderCache.bin";
uint32_t shaderCount{};
{
std::ofstream fileSerialize(shaderCacheFileName, std::ios::binary);
shaderCount = Babylon::ShaderCache::Serialize(fileSerialize);
std::ofstream stream(shaderCacheFileName, std::ios::binary);
shaderCount = Babylon::Plugins::ShaderCache::Save(stream);
EXPECT_EQ(shaderCount, 1);
}
{
std::ifstream file(shaderCacheFileName, std::ios::binary);
auto deserializedCount = Babylon::ShaderCache::Deserialize(file);
std::ifstream stream(shaderCacheFileName, std::ios::binary);
auto deserializedCount = Babylon::Plugins::ShaderCache::Load(stream);
EXPECT_EQ(deserializedCount, shaderCount);
}

update.Finish();
device.FinishRenderingCurrentFrame();

Babylon::Plugins::ShaderCache::Disable();
}
9 changes: 8 additions & 1 deletion Apps/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ option(BABYLON_NATIVE_PLUGIN_NATIVEINPUT "Include Babylon Native Plugin NativeIn
option(BABYLON_NATIVE_PLUGIN_NATIVEOPTIMIZATIONS "Include Babylon Native Plugin NativeOptimizations." ON)
option(BABYLON_NATIVE_PLUGIN_NATIVETRACING "Include Babylon Native Plugin NativeTracing." ON)
option(BABYLON_NATIVE_PLUGIN_NATIVEXR "Include Babylon Native Plugin XR." ON)
option(BABYLON_NATIVE_PLUGIN_SHADERCACHE "Include Babylon Native Plugin ShaderCache." ON)
option(BABYLON_NATIVE_PLUGIN_SHADERCOMPILER "Include Babylon Native Plugin ShaderCompiler." ON)
option(BABYLON_NATIVE_PLUGIN_SHADERTOOL "Include Babylon Native Plugin ShaderTool." ON)
option(BABYLON_NATIVE_PLUGIN_TESTUTILS "Include Babylon Native Plugin TestUtils." ON)

# Polyfills
Expand Down
2 changes: 1 addition & 1 deletion Core/Graphics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ target_include_directories(Graphics
PRIVATE "Include/Shared"
PRIVATE "Include/Platform/${BABYLON_NATIVE_PLATFORM}"
PRIVATE "Include/RendererType/${GRAPHICS_API}"
PRIVATE "InternalInclude/Babylon/Graphics")
PRIVATE "InternalInclude")

if(WINDOWS_STORE)
target_link_libraries(Graphics
Expand Down
17 changes: 17 additions & 0 deletions Core/Graphics/InternalInclude/Babylon/Graphics/BgfxShaderInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <cstdint>
#include <string>
#include <map>
#include <vector>

namespace Babylon::Graphics
{
struct BgfxShaderInfo
{
std::vector<uint8_t> VertexBytes{};
std::vector<uint8_t> FragmentBytes{};
std::map<std::string, uint32_t> VertexAttributeLocations{};
std::map<std::string, uint8_t> UniformStages{};
};
}
8 changes: 3 additions & 5 deletions Core/Graphics/Source/BgfxCallback.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#include "BgfxCallback.h"
#include <Babylon/Graphics/BgfxCallback.h>
#include <bgfx/bgfx.h>
#include <bx/bx.h>
#include <bx/string.h>
#include <bx/platform.h>
#include <bx/debug.h>
#include <stdarg.h>
#include <bgfx/bgfx.h>
#include <cassert>
#include <stdarg.h>

namespace Babylon::Graphics
{
Expand Down
2 changes: 1 addition & 1 deletion Core/Graphics/Source/DeviceContext.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "DeviceContext.h"
#include <Babylon/Graphics/DeviceContext.h>

#include "DeviceImpl.h"

Expand Down
7 changes: 3 additions & 4 deletions Core/Graphics/Source/DeviceImpl.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#pragma once

#include "BgfxCallback.h"
#include "SafeTimespanGuarantor.h"
#include "DeviceContext.h"

#include <Babylon/Graphics/BgfxCallback.h>
#include <Babylon/Graphics/Device.h>
#include <Babylon/Graphics/DeviceContext.h>
#include <Babylon/Graphics/SafeTimespanGuarantor.h>

#include <arcana/containers/ticketed_collection.h>
#include <arcana/threading/blocking_concurrent_queue.h>
Expand Down
2 changes: 1 addition & 1 deletion Core/Graphics/Source/FrameBuffer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "FrameBuffer.h"
#include <Babylon/Graphics/FrameBuffer.h>
#include "DeviceImpl.h"
#include <arcana/macros.h>
#include <cmath>
Expand Down
2 changes: 1 addition & 1 deletion Core/Graphics/Source/SafeTimespanGuarantor.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "SafeTimespanGuarantor.h"
#include <Babylon/Graphics/SafeTimespanGuarantor.h>

namespace Babylon::Graphics
{
Expand Down
4 changes: 2 additions & 2 deletions Core/Graphics/Source/Texture.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Texture.h"
#include "DeviceContext.h"
#include <Babylon/Graphics/Texture.h>
#include <Babylon/Graphics/DeviceContext.h>
#include <cassert>
#include <bimg/bimg.h>

Expand Down
9 changes: 9 additions & 0 deletions Install/Install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ if(TARGET NativeEncoding)
install_include_for_targets(NativeEncoding)
endif()

if(TARGET ShaderCache)
install_targets(ShaderCache)
install_include_for_targets(ShaderCache)
endif()

if(TARGET ShaderCompiler)
install_targets(ShaderCompiler)
endif()

# ----------------
# Polyfills
# ----------------
Expand Down
12 changes: 7 additions & 5 deletions Install/Test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,16 @@ set(NAPI_JAVASCRIPT_ENGINE "Chakra")
if(WIN32 AND NOT WINDOWS_STORE)
set(SOURCE_DIR "../../Apps/UnitTests/Source")
set(SOURCES
"${SOURCE_DIR}/App.h"
"${SOURCE_DIR}/App.cpp"
"${SOURCE_DIR}/App.h"
"${SOURCE_DIR}/App.Win32.cpp"
"${SOURCE_DIR}/Tests.JavaScript.cpp"
"${SOURCE_DIR}/Tests.NativeEngine.cpp"
"${SOURCE_DIR}/Tests.Device.D3D11.cpp"
"${SOURCE_DIR}/Tests.ExternalTexture.cpp"
"${SOURCE_DIR}/Tests.ExternalTexture.D3D11.cpp"
"${SOURCE_DIR}/Utils.h"
"${SOURCE_DIR}/Utils.D3D11.cpp")
"${SOURCE_DIR}/Tests.JavaScript.cpp"
"${SOURCE_DIR}/Tests.ShaderCache.cpp"
"${SOURCE_DIR}/Utils.D3D11.cpp"
"${SOURCE_DIR}/Utils.h")
else()
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
endif()
Expand Down Expand Up @@ -76,6 +77,7 @@ target_link_libraries(TestInstall
${INSTALL_LIB_NAMES}
gtest_main
chakrart
d3d11
d3dcompiler
onecore)

Expand Down
39 changes: 38 additions & 1 deletion NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2258,4 +2258,41 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
```

# xxHash

```
xxHash - Extremely Fast Hash algorithm
Header File
Copyright (C) 2012-2023 Yann Collet

BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php)

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

You can contact the author at:
- xxHash homepage: https://www.xxhash.com
- xxHash source repository: https://github.com/Cyan4973/xxHash
```
Loading