Skip to content

Commit a3264cf

Browse files
Update to latest bgfx/bx/bimg (#1618)
Updated to latest version of bgfx/bx/bimg.
1 parent 5406db7 commit a3264cf

14 files changed

Lines changed: 70 additions & 20 deletions

File tree

.github/jobs/win32.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,19 @@ jobs:
8383
)
8484
displayName: "Disable JIT Debugger for Script"
8585
86+
# Temporary disabling D3D12 validation tests. Changes in bgfx require changes in our D3D12 shader pipeline. This is been tracked by issue #1621
8687
- script: |
8788
cd build\${{variables.solutionName}}\Apps\Playground\RelWithDebInfo
8889
Playground app:///Scripts/validation_native.js
8990
displayName: "Validation Tests"
91+
condition: ne('${{parameters.graphics_api}}', 'D3D12')
9092
9193
- task: PublishBuildArtifacts@1
9294
inputs:
9395
artifactName: "${{variables.solutionName}} - ${{parameters.graphics_api}} Rendered Pictures"
9496
pathtoPublish: "build/${{variables.solutionName}}/Apps/Playground/Results"
9597
displayName: "Publish Tests ${{variables.solutionName}} Results"
96-
condition: always()
98+
condition: ne('${{parameters.graphics_api}}', 'D3D12')
9799

98100
- task: PublishBuildArtifacts@1
99101
inputs:
@@ -110,12 +112,14 @@ jobs:
110112
cleanTargetFolder: false
111113
displayName: "Stage test app exe/pdb for publishing"
112114
condition: failed()
113-
115+
116+
# Temporary disabling D3D12 unit tests. Changes in bgfx require changes in our D3D12 shader pipeline. This is been tracked by issue #1621
114117
- script: |
115118
cd build\${{variables.solutionName}}\Apps\UnitTests
116119
cd RelWithDebInfo
117120
UnitTests
118121
displayName: "Unit Tests"
122+
condition: ne('${{parameters.graphics_api}}', 'D3D12')
119123
120124
- task: CopyFiles@2
121125
inputs:

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ FetchContent_Declare(base-n
3535
EXCLUDE_FROM_ALL)
3636
FetchContent_Declare(bgfx.cmake
3737
GIT_REPOSITORY https://github.com/BabylonJS/bgfx.cmake.git
38-
GIT_TAG 0af3c9865a66aff1748a51bb466b24f05a123043
38+
GIT_TAG 1b10ed55fadc0171c736f9638514ae715a1d97de
3939
EXCLUDE_FROM_ALL)
4040
FetchContent_Declare(CMakeExtensions
4141
GIT_REPOSITORY https://github.com/BabylonJS/CMakeExtensions.git

Core/Graphics/InternalInclude/Babylon/Graphics/BgfxCallback.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace Babylon::Graphics
3838
uint32_t cacheReadSize(uint64_t id) override;
3939
bool cacheRead(uint64_t id, void* data, uint32_t size) override;
4040
void cacheWrite(uint64_t id, const void* data, uint32_t size) override;
41-
void screenShot(const char* filePath, uint32_t width, uint32_t height, uint32_t pitch, const void* data, uint32_t size, bool yflip) override;
41+
void screenShot(const char* filePath, uint32_t width, uint32_t height, uint32_t pitch, bgfx::TextureFormat::Enum format, const void* data, uint32_t size, bool yflip) override;
4242
void captureBegin(uint32_t width, uint32_t height, uint32_t pitch, bgfx::TextureFormat::Enum format, bool yflip) override;
4343
void captureEnd() override;
4444
void captureFrame(const void* _data, uint32_t _size) override;

Core/Graphics/Source/BgfxCallback.cpp

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <bx/string.h>
55
#include <cassert>
66
#include <stdarg.h>
7+
#include <stdexcept>
78

89
namespace Babylon::Graphics
910
{
@@ -85,25 +86,47 @@ namespace Babylon::Graphics
8586
{
8687
}
8788

88-
void BgfxCallback::screenShot(const char* /*filePath*/, uint32_t width, uint32_t height, uint32_t pitch, const void* data, uint32_t /*size*/, bool yflip)
89+
void BgfxCallback::screenShot(const char* /*filePath*/, uint32_t width, uint32_t height, uint32_t pitch, bgfx::TextureFormat::Enum format, const void* data, uint32_t /*size*/, bool yflip)
8990
{
9091
assert(!m_screenShotCallbacks.empty()); // addScreenShotCallback not called before doing the screenshot call on bgfx
9192

9293
std::vector<uint8_t> array(width * height * 4); // do not use pitch to define output size because it's padded
9394
uint8_t* bitmap{array.data()};
9495

95-
for (uint32_t py = 0; py < height; py++)
96+
if (format == bgfx::TextureFormat::BGRA8)
9697
{
97-
const uint8_t* ptr = static_cast<const uint8_t*>(data) + (yflip ? (height - py - 1) : py) * pitch;
98-
for (uint32_t px = 0; px < width; px++)
98+
for (uint32_t py = 0; py < height; py++)
9999
{
100-
// bgfx screenshot is BGRA
101-
*bitmap++ = ptr[px * 4 + 2];
102-
*bitmap++ = ptr[px * 4 + 1];
103-
*bitmap++ = ptr[px * 4 + 0];
104-
*bitmap++ = ptr[px * 4 + 3];
100+
const uint8_t* ptr = static_cast<const uint8_t*>(data) + (yflip ? (height - py - 1) : py) * pitch;
101+
for (uint32_t px = 0; px < width; px++)
102+
{
103+
// bgfx screenshot is BGRA
104+
*bitmap++ = ptr[px * 4 + 2];
105+
*bitmap++ = ptr[px * 4 + 1];
106+
*bitmap++ = ptr[px * 4 + 0];
107+
*bitmap++ = ptr[px * 4 + 3];
108+
}
105109
}
106110
}
111+
else if (format == bgfx::TextureFormat::RGBA8)
112+
{
113+
for (uint32_t py = 0; py < height; py++)
114+
{
115+
const uint8_t* ptr = static_cast<const uint8_t*>(data) + (yflip ? (height - py - 1) : py) * pitch;
116+
for (uint32_t px = 0; px < width; px++)
117+
{
118+
// bgfx screenshot is RGBA
119+
*bitmap++ = ptr[px * 4 + 0];
120+
*bitmap++ = ptr[px * 4 + 1];
121+
*bitmap++ = ptr[px * 4 + 2];
122+
*bitmap++ = ptr[px * 4 + 3];
123+
}
124+
}
125+
}
126+
else
127+
{
128+
throw std::runtime_error{"Unsupported format for screenshot"};
129+
}
107130

108131
m_screenShotCallbacks.front()(std::move(array));
109132
m_screenShotCallbacks.pop();

Dependencies/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ set(BGFX_CUSTOM_TARGETS OFF)
3737
set(BGFX_INSTALL OFF)
3838
set(BGFX_OPENGL_USE_EGL ON)
3939
set(BGFX_USE_DEBUG_SUFFIX OFF)
40+
4041
FetchContent_MakeAvailable_With_Message(bgfx.cmake)
4142

4243
# Turn off debug annotations as it causes an access violation in D3D12.
@@ -50,6 +51,12 @@ target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_MIN_RESOURCE_COMMAND_BUFFER_
5051
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_MIN_UNIFORM_BUFFER_SIZE=4096)
5152
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_UNIFORM_BUFFER_RESIZE_THRESHOLD_SIZE=256)
5253
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_UNIFORM_BUFFER_RESIZE_INCREMENT_SIZE=1024)
54+
target_compile_definitions(bgfx PUBLIC BGFX_PLATFORM_SUPPORTS_WGSL=0)
55+
target_compile_definitions(bgfx PUBLIC BGFX_PLATFORM_SUPPORTS_DXIL=0)
56+
57+
# Temporary disable uniform debug.
58+
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_DEBUG_UNIFORM=0)
59+
5360
if(GRAPHICS_API STREQUAL "D3D11")
5461
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_RENDERER_DIRECT3D11=1)
5562
elseif(GRAPHICS_API STREQUAL "D3D12")

Plugins/ExternalTexture/Source/ExternalTexture_D3D11.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ namespace
6161
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // ETC2
6262
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // ETC2A
6363
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // ETC2A1
64+
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // EACR11 UNORM
65+
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // EACR11 SNORM
66+
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // EACRG11 UNORM
67+
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // EACRG11 SNORM
6468
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // PTC12
6569
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // PTC14
6670
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // PTC12A

Plugins/ExternalTexture/Source/ExternalTexture_D3D12.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ namespace
6161
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // ETC2
6262
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // ETC2A
6363
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // ETC2A1
64+
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // EACR11 UNORM
65+
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // EACR11 SNORM
66+
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // EACRG11 UNORM
67+
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // EACRG11 SNORM
6468
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // PTC12
6569
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // PTC14
6670
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // PTC12A

Plugins/ExternalTexture/Source/ExternalTexture_Metal.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ namespace
8383
constexpr MTL::PixelFormat kMtlPixelFormatPVRTC_RGBA_2BPP_sRGB = MTL::PixelFormat(165);
8484
constexpr MTL::PixelFormat kMtlPixelFormatPVRTC_RGBA_4BPP = MTL::PixelFormat(166);
8585
constexpr MTL::PixelFormat kMtlPixelFormatPVRTC_RGBA_4BPP_sRGB = MTL::PixelFormat(167);
86+
constexpr MTL::PixelFormat kMtlPixelFormatEAC_R11Unorm = MTL::PixelFormat(170);
87+
constexpr MTL::PixelFormat kMtlPixelFormatEAC_R11Snorm = MTL::PixelFormat(172);
88+
constexpr MTL::PixelFormat kMtlPixelFormatEAC_RG11Unorm = MTL::PixelFormat(174);
89+
constexpr MTL::PixelFormat kMtlPixelFormatEAC_RG11Snorm = MTL::PixelFormat(176);
8690
constexpr MTL::PixelFormat kMtlPixelFormatEAC_RGBA8 = MTL::PixelFormat(178);
8791
constexpr MTL::PixelFormat kMtlPixelFormatEAC_RGBA8_sRGB = MTL::PixelFormat(179);
8892
constexpr MTL::PixelFormat kMtlPixelFormatETC2_RGB8 = MTL::PixelFormat(180);
@@ -145,6 +149,10 @@ namespace
145149
{ kMtlPixelFormatETC2_RGB8, kMtlPixelFormatETC2_RGB8_sRGB, }, // ETC2
146150
{ kMtlPixelFormatEAC_RGBA8, kMtlPixelFormatEAC_RGBA8_sRGB, }, // ETC2A
147151
{ kMtlPixelFormatETC2_RGB8A1, kMtlPixelFormatETC2_RGB8A1_sRGB, }, // ETC2A1
152+
{ kMtlPixelFormatEAC_R11Unorm, kMtlPixelFormatInvalid }, // EACR11 UNORM
153+
{ kMtlPixelFormatEAC_R11Snorm, kMtlPixelFormatInvalid }, // EACR11 SNORM
154+
{ kMtlPixelFormatEAC_RG11Unorm, kMtlPixelFormatInvalid }, // EACRG11 UNORM
155+
{ kMtlPixelFormatEAC_RG11Snorm, kMtlPixelFormatInvalid }, // EACRG11 SNORM
148156
{ kMtlPixelFormatPVRTC_RGB_2BPP, kMtlPixelFormatPVRTC_RGB_2BPP_sRGB, }, // PTC12
149157
{ kMtlPixelFormatPVRTC_RGB_4BPP, kMtlPixelFormatPVRTC_RGB_4BPP_sRGB, }, // PTC14
150158
{ kMtlPixelFormatPVRTC_RGBA_2BPP, kMtlPixelFormatPVRTC_RGBA_2BPP_sRGB, }, // PTC12A

Polyfills/Canvas/Source/Shaders/dx11/fs_boxblur.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
static const uint8_t fs_boxblur_dx11[1117] =
1+
static const uint8_t fs_boxblur_dxbc[1117] =
22
{
33
0x46, 0x53, 0x48, 0x0b, 0xcf, 0xda, 0x1b, 0x94, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x0a, 0x75, // FSH............u
44
0x5f, 0x76, 0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // _viewSize.......

Polyfills/Canvas/Source/Shaders/dx11/fs_gaussblur.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
static const uint8_t fs_gaussblur_dx11[1649] =
1+
static const uint8_t fs_gaussblur_dxbc[1649] =
22
{
33
0x46, 0x53, 0x48, 0x0b, 0xcf, 0xda, 0x1b, 0x94, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x0a, 0x75, // FSH............u
44
0x5f, 0x76, 0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // _viewSize.......

0 commit comments

Comments
 (0)