Skip to content
Open
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
0418e9f
Canvas Context angle/fontsize fixes
CedricGuillemet Feb 6, 2025
bbdcce3
Text/shape/state test script
CedricGuillemet Feb 6, 2025
e0f88f3
readme update
CedricGuillemet Feb 6, 2025
57ec8d7
Merge branch 'master' into CanvasTest
ryantrem Feb 7, 2025
a9737fc
Canvas transform implementation (#1460)
mattbirman Feb 17, 2025
dadeca3
plumb lineCap, lineJoin, miterLimit to nanovg
Pheo Feb 18, 2025
975e0dd
Add textMetrics implementation (#1461)
mattbirman Feb 18, 2025
7bbca53
Add letterSpacing polyfill and implementation (#1462)
mattbirman Feb 18, 2025
ef0b545
Merge branch 'master' of https://github.com/BabylonJS/BabylonNative i…
CedricGuillemet Feb 19, 2025
b733ab3
Canvas test update (#1463)
CedricGuillemet Feb 19, 2025
bbe83fa
map strings to lineCaps
Pheo Feb 19, 2025
c9be817
Merge branch 'CanvasLineImplementation' of https://github.com/Pheo/Ba…
CedricGuillemet Feb 20, 2025
1538543
Add lineCap, lineJoin, miterLimit (#1464)
Pheo Feb 20, 2025
aab744e
Gradient color stop (#1467)
CedricGuillemet Feb 25, 2025
d599479
Merge branch 'CanvasTest' of https://github.com/BabylonJS/BabylonNati…
CedricGuillemet Feb 25, 2025
4d03c02
fix merge conflicts
CedricGuillemet Feb 25, 2025
e404270
JSI build
CedricGuillemet Feb 25, 2025
73693f9
Path2D Implementation (#1469)
Pheo Feb 28, 2025
146210b
Merge branch 'master' of https://github.com/BabylonJS/BabylonNative i…
CedricGuillemet Mar 4, 2025
3235ff7
Canvas Transforms: getTransform setTransform, addPath (Path2D) (#1473)
Pheo Mar 4, 2025
4c60d74
Merge branch 'master' of https://github.com/BabylonJS/BabylonNative i…
CedricGuillemet Mar 5, 2025
a4a0082
Merge branch 'CanvasTest' of https://github.com/BabylonJS/BabylonNati…
CedricGuillemet Mar 5, 2025
de71606
Implement round rect (#1471)
hwarmington Mar 11, 2025
7cb49ba
Copy nanovg into Canvas sources (#1480)
matanui159 Mar 13, 2025
e154eb9
fixed MSVC build
CedricGuillemet Mar 13, 2025
c914be2
Use bgfx more recent glslang/spirv for NativeEngine (#1478)
CedricGuillemet Mar 13, 2025
2c1dcfe
fix mac build
CedricGuillemet Mar 13, 2025
f7a563d
Canvas gradient text (#1475)
CedricGuillemet Mar 14, 2025
58d3b2f
Add strokeText support to canvas via SDFs (#1482)
matanui159 Mar 18, 2025
6bf07b3
canvas fill Path2D (#1483)
Pheo Mar 24, 2025
5ef4c23
Canvas and Context (#1491)
CedricGuillemet Apr 4, 2025
cfe7305
Merge branch 'master' of https://github.com/BabylonJS/BabylonNative i…
CedricGuillemet Apr 7, 2025
c2d4a22
fixes: canvas.SetHeight/Width, Path2D, context.fill (#1493)
Pheo Apr 7, 2025
dfb0a8b
Improve parsing of the "font" field (#1486)
matanui159 Apr 7, 2025
f222e21
nanovg Compositor + context.filter blur (#1489)
Pheo Apr 7, 2025
7de5058
missing vector include
CedricGuillemet Apr 7, 2025
ff7c6e6
Use property for getting canvas from context (#1495)
CedricGuillemet Apr 7, 2025
207aa2e
work around for jsi
CedricGuillemet Apr 8, 2025
12ee2b3
fix: pool framebuffer stencil, release issues (#1496)
Pheo Apr 8, 2025
5abadc2
Canvas Path2D roundRect (#1501)
Pheo Apr 17, 2025
c6f22a8
Canvas direction + getTransform() fix (#1502)
Pheo Apr 17, 2025
425bc34
Merge copy texture fix (#1505)
ryantrem Apr 22, 2025
dfb5a89
Merge branch 'master' of https://github.com/BabylonJS/BabylonNative i…
CedricGuillemet Apr 23, 2025
d0eb88c
missed bool NativeCanvas::UpdateRenderTarget()
CedricGuillemet Apr 23, 2025
8acfcb2
Canvas filter blur: Gaussian + Box (#1506)
Pheo Apr 28, 2025
192c4af
Canvas roundRect DOMPoint argument (#1507)
Pheo Apr 28, 2025
e31aaeb
fix: don't allow loading same font more than once (#1516)
Pheo Apr 30, 2025
068409d
Canvas synchronous LoadTTF (#1517)
Pheo May 1, 2025
981edd2
Merge branch 'master' of https://github.com/BabylonJS/BabylonNative i…
CedricGuillemet Oct 15, 2025
b20ce99
conflict
CedricGuillemet Oct 15, 2025
1e55020
missing endif
CedricGuillemet Oct 15, 2025
7f39041
no member named 'floor' in namespace 'std'
CedricGuillemet Oct 15, 2025
9e6c04a
Canvas test
CedricGuillemet Oct 15, 2025
8f0707e
empty line
CedricGuillemet Oct 15, 2025
45d6024
disable canvas test on d3d12
CedricGuillemet Oct 15, 2025
2b19c16
PR feedback
CedricGuillemet Oct 16, 2025
f7a5100
Canvas Readme update, PR feedback
CedricGuillemet Oct 20, 2025
f6355ee
removing BGFX_BUILD_TOOLS
CedricGuillemet Oct 22, 2025
f245983
shaderc instructions and cmake
CedricGuillemet Oct 22, 2025
54f3096
installation condition
CedricGuillemet Oct 22, 2025
6de8594
spaces
CedricGuillemet Oct 22, 2025
deccfbe
simpler cmake
CedricGuillemet Oct 22, 2025
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: 0 additions & 1 deletion .github/jobs/test_install_win32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ jobs:

# BGFX_CONFIG_MAX_FRAME_BUFFERS is set so enough Framebuffers are available before V8 starts disposing unused ones
- script: |
# BGFX_CONFIG_MAX_FRAME_BUFFERS is set so enough Framebuffers are available before V8 starts disposing unused ones
cmake -G "Visual Studio 17 2022" -B build${{ variables.solutionName }} -A ${{ parameters.platform }} ${{ variables.jsEngineDefine }} -D BX_CONFIG_DEBUG=ON -D GRAPHICS_API=${{ parameters.graphics_api }} -D CMAKE_UNITY_BUILD=$(UNITY_BUILD) -D BGFX_CONFIG_MAX_FRAME_BUFFERS=256 -D BABYLON_DEBUG_TRACE=ON
displayName: 'Generate ${{ variables.solutionName }} solution'

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion Apps/Playground/Scripts/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"root": "https://cdn.babylonjs.com",
"tests": [
{
"title": "Native Canvas",
"playgroundId": "#TKVFSA#2",
"referenceImage": "native-canvas.png",
"excludedGraphicsApis": [ "D3D12" ],
"comment": "2D Path not rendered with D3D12"
},
{
"title": "EXR Loader",
"playgroundId": "#4RN0VF#151",
Expand Down Expand Up @@ -129,7 +136,7 @@
"title": "Dynamic Texture context clip",
"playgroundId": "#FU0ES5#47",
"referenceImage": "dynamicTextureClip.png",
"excludedGraphicsApis": ["D3D12" ],
"excludedGraphicsApis": [ "D3D12" ],
"comment": "D3D12/CI: Incorrect rendering of clipped texture"
},
{
Expand Down
50 changes: 35 additions & 15 deletions Plugins/NativeEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,41 @@ target_include_directories(NativeEngine
PUBLIC "Include"
PRIVATE "${BIMG_DIR}/3rdparty")

target_link_libraries(NativeEngine
PUBLIC napi
PRIVATE arcana
PRIVATE bgfx
PRIVATE bimg
PRIVATE bimg_encode
PRIVATE bimg_decode
PRIVATE bx
PRIVATE minz
PRIVATE glslang
PRIVATE glslang-default-resource-limits
PRIVATE GraphicsDevice
PRIVATE GraphicsDeviceContext
PRIVATE JsRuntime
PRIVATE SPIRV)
if(BGFX_BUILD_TOOLS)
target_link_libraries(NativeEngine
PUBLIC napi
PRIVATE JsRuntime
PRIVATE GraphicsDevice
PRIVATE arcana
PRIVATE bgfx
PRIVATE bimg
PRIVATE bimg_encode
PRIVATE bimg_decode
PRIVATE bx
PRIVATE minz
PRIVATE glslang
PRIVATE spirv-opt
PRIVATE GraphicsDeviceContext)
target_compile_definitions(NativeEngine PRIVATE BGFX_BUILD_TOOLS)
else()
target_link_libraries(NativeEngine
PUBLIC napi
PRIVATE arcana
PRIVATE bgfx
PRIVATE bimg
PRIVATE bimg_encode
PRIVATE bimg_decode
PRIVATE bx
PRIVATE minz
PRIVATE glslang
PRIVATE glslang-default-resource-limits
PRIVATE GraphicsDevice
PRIVATE GraphicsDeviceContext
PRIVATE JsRuntime
PRIVATE SPIRV)

warnings_as_errors(NativeEngine)
endif()

if(BABYLON_NATIVE_PLUGIN_NATIVEENGINE_WEBP)
target_compile_definitions(NativeEngine
Expand Down
1 change: 1 addition & 0 deletions Plugins/NativeEngine/Source/ShaderCompilerMetal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <bgfx/bgfx.h>
#include <glslang/Public/ShaderLang.h>
#include <glslang/Public/ResourceLimits.h>
#include <glslang/MachineIndependent/localintermediate.h>
#include <SPIRV/GlslangToSpv.h>
#include <spirv_parser.hpp>
#include <spirv_msl.hpp>
Expand Down
25 changes: 20 additions & 5 deletions Plugins/NativeEngine/Source/ShaderCompilerTraversers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,11 @@ namespace Babylon::ShaderCompilerTraversers
// Create the symbol for the actual struct. The name of this symbol, "anon@0",
// mirrors the kinds of strings glslang generates automatically for these sorts
// of objects.
TIntermSymbol* structSymbol = intermediate->addSymbol(TIntermSymbol{ids.Next(), "anon@0", structType});

#ifdef BGFX_BUILD_TOOLS
TIntermSymbol* structSymbol = intermediate->addSymbol(TIntermSymbol{ids.Next(), "anon@0", intermediate->getStage(), structType});
#else
TIntermSymbol* structSymbol = intermediate->addSymbol(TIntermSymbol{ ids.Next(), "anon@0", structType });
#endif
// Every affected symbol in the AST (except linker objects) must be replaced
// with a new operation to retrieve its value from the struct. This operation
// consists of a binary operation indexing into the struct at a specified
Expand Down Expand Up @@ -521,7 +524,11 @@ namespace Babylon::ShaderCompilerTraversers

TType newType{publicType};
newType.setBasicType(symbol->getType().getBasicType());
auto* newSymbol = intermediate->addSymbol(TIntermSymbol{ids.Next(), newName, newType});
#ifdef BGFX_BUILD_TOOLS
auto* newSymbol = intermediate->addSymbol(TIntermSymbol{ids.Next(), newName, intermediate->getStage(), newType});
#else
auto* newSymbol = intermediate->addSymbol(TIntermSymbol{ ids.Next(), newName, newType });
#endif
originalNameToReplacement[name] = newSymbol;
replacementToOriginalName[newName] = name;
}
Expand Down Expand Up @@ -794,7 +801,11 @@ namespace Babylon::ShaderCompilerTraversers

TType newType{publicType};
std::string newName = name + "Texture";
newTexture = intermediate->addSymbol(TIntermSymbol{ids.Next(), newName.c_str(), newType});
#ifdef BGFX_BUILD_TOOLS
newTexture = intermediate->addSymbol(TIntermSymbol{ids.Next(), newName.c_str(), intermediate->getStage(), newType});
#else
newTexture = intermediate->addSymbol(TIntermSymbol{ ids.Next(), newName.c_str(), newType });
#endif
}

// Create the new sampler symbol.
Expand All @@ -809,7 +820,11 @@ namespace Babylon::ShaderCompilerTraversers
publicType.sampler.sampler = true;

TType newType{publicType};
newSampler = intermediate->addSymbol(TIntermSymbol{ids.Next(), name.c_str(), newType});
#ifdef BGFX_BUILD_TOOLS
newSampler = intermediate->addSymbol(TIntermSymbol{ids.Next(), name.c_str(), intermediate->getStage(), newType});
#else
newSampler = intermediate->addSymbol(TIntermSymbol{ ids.Next(), name.c_str(), newType });
#endif
}

nameToNewTextureAndSampler[name] = std::pair<TIntermSymbol*, TIntermSymbol*>{newTexture, newSampler};
Expand Down
74 changes: 42 additions & 32 deletions Polyfills/Canvas/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,29 @@ function(add_bgfx_shader FILE FOLDER)
set(OUTPUTS_PRETTY "")

# dx11
set(DX11_OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Source/Shaders/dx11/${FILENAME}.h)
if(NOT "${TYPE}" STREQUAL "COMPUTE")
_bgfx_shaderc_parse(
DX11 ${COMMON} WINDOWS
PROFILE s_5_0
O 3
OUTPUT ${DX11_OUTPUT}
BIN2C "${FILENAME}_dx11"
)
else()
_bgfx_shaderc_parse(
DX11 ${COMMON} WINDOWS
PROFILE s_5_0
O 1
OUTPUT ${DX11_OUTPUT}
BIN2C "${FILENAME}_dx11"
)
if(WIN32)
set(DX11_OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Source/Shaders/dx11/${FILENAME}.h)
if(NOT "${TYPE}" STREQUAL "COMPUTE")
_bgfx_shaderc_parse(
DX11 ${COMMON} WINDOWS
PROFILE s_5_0
O 3
OUTPUT ${DX11_OUTPUT}
BIN2C "${FILENAME}_dx11"
)
else()
_bgfx_shaderc_parse(
DX11 ${COMMON} WINDOWS
PROFILE s_5_0
O 1
OUTPUT ${DX11_OUTPUT}
BIN2C "${FILENAME}_dx11"
)
endif()
list(APPEND OUTPUTS "DX11")
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}DX11, ")
endif()
list(APPEND OUTPUTS "DX11")
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}DX11, ")


# metal
set(METAL_OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Source/Shaders/metal/${FILENAME}.h)
_bgfx_shaderc_parse(METAL ${COMMON} OSX PROFILE metal OUTPUT ${METAL_OUTPUT} BIN2C "${FILENAME}_mtl")
Expand Down Expand Up @@ -93,32 +95,40 @@ set(SOURCES
"Source/Canvas.cpp"
"Source/Canvas.h"
"Source/Colors.h"
"Source/FrameBufferPool.cpp"
"Source/FrameBufferPool.h"
"Source/Image.cpp"
"Source/Image.h"
"Source/ImageData.cpp"
"Source/ImageData.h"
"Source/Path2D.cpp"
"Source/Path2D.h"
"Source/LineCaps.h"
"Source/Context.cpp"
"Source/Context.h"
"Source/MeasureText.cpp"
"Source/MeasureText.h"
"Source/nanovg_babylon.cpp"
"Source/nanovg_babylon.h"
"Source/Gradient.cpp"
"Source/Gradient.h"
"Source/Font.cpp"
"Source/Font.h"
"Source/nanosvg.h"
"Source/nanovg/nanovg.cpp"
"Source/nanovg/nanovg.h"
"Source/nanovg/nanovg_babylon.cpp"
"Source/nanovg/nanovg_babylon.h"
"Source/nanovg/nanovg_filterstack.cpp"
"Source/nanovg/nanovg_filterstack.h"
)

file(GLOB SHADERS "Source/Shaders/*.sc" "Source/Shaders/*.sh")

file(GLOB FONT_SOURCES ${BGFX_DIR}/examples/common/font/*.cpp)
file(GLOB NANOVG_SOURCES ${BGFX_DIR}/examples/common/nanovg/nanovg.cpp)
set(ATLAS_SOURCES ${BGFX_DIR}/examples/common/cube_atlas.cpp)

add_library(Canvas ${SOURCES} ${FONT_SOURCES} ${ATLAS_SOURCES} ${NANOVG_SOURCES} ${SHADERS})
add_library(Canvas ${SOURCES} ${SHADERS})

target_include_directories(Canvas
PUBLIC "Include"
PRIVATE "Source"
PRIVATE "${BGFX_DIR}/3rdparty"
PRIVATE "${BGFX_DIR}/examples/common"
PRIVATE "${BGFX_DIR}/examples/common/nanovg")
PRIVATE "${BGFX_DIR}/3rdparty")

target_link_libraries(Canvas
PUBLIC napi
Expand All @@ -141,6 +151,6 @@ endif()

set_property(TARGET Canvas PROPERTY FOLDER Polyfills)
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCES})
source_group("3rd party Sources" ${CMAKE_CURRENT_SOURCE_DIR} FILES ${FONT_SOURCES} ${NANOVG_SOURCES} ${ATLAS_SOURCES})
source_group("3rd party Sources" ${CMAKE_CURRENT_SOURCE_DIR} FILES ${FONT_SOURCES} ${ATLAS_SOURCES})
source_group("Shaders" ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SHADERS})
target_compile_definitions(Canvas PRIVATE _CRT_SECURE_NO_WARNINGS)
target_compile_definitions(Canvas PRIVATE _CRT_SECURE_NO_WARNINGS)
Loading
Loading