Skip to content
Merged
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
8 changes: 6 additions & 2 deletions .github/jobs/win32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,19 @@ jobs:
)
displayName: "Disable JIT Debugger for Script"

# Temporary disabling D3D12 validation tests. Changes in bgfx require changes in our D3D12 shader pipeline. This is been tracked by issue #1621
- script: |
cd build\${{variables.solutionName}}\Apps\Playground\RelWithDebInfo
Playground app:///Scripts/validation_native.js
displayName: "Validation Tests"
condition: ne('${{parameters.graphics_api}}', 'D3D12')

- task: PublishBuildArtifacts@1
inputs:
artifactName: "${{variables.solutionName}} - ${{parameters.graphics_api}} Rendered Pictures"
pathtoPublish: "build/${{variables.solutionName}}/Apps/Playground/Results"
displayName: "Publish Tests ${{variables.solutionName}} Results"
condition: always()
condition: ne('${{parameters.graphics_api}}', 'D3D12')

- task: PublishBuildArtifacts@1
inputs:
Expand All @@ -110,12 +112,14 @@ jobs:
cleanTargetFolder: false
displayName: "Stage test app exe/pdb for publishing"
condition: failed()


# Temporary disabling D3D12 unit tests. Changes in bgfx require changes in our D3D12 shader pipeline. This is been tracked by issue #1621
- script: |
cd build\${{variables.solutionName}}\Apps\UnitTests
cd RelWithDebInfo
UnitTests
displayName: "Unit Tests"
Comment thread
SergioRZMasson marked this conversation as resolved.
condition: ne('${{parameters.graphics_api}}', 'D3D12')

- task: CopyFiles@2
inputs:
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ FetchContent_Declare(base-n
EXCLUDE_FROM_ALL)
FetchContent_Declare(bgfx.cmake
GIT_REPOSITORY https://github.com/BabylonJS/bgfx.cmake.git
GIT_TAG 0af3c9865a66aff1748a51bb466b24f05a123043
GIT_TAG 1b10ed55fadc0171c736f9638514ae715a1d97de
EXCLUDE_FROM_ALL)
FetchContent_Declare(CMakeExtensions
GIT_REPOSITORY https://github.com/BabylonJS/CMakeExtensions.git
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace Babylon::Graphics
uint32_t cacheReadSize(uint64_t id) override;
bool cacheRead(uint64_t id, void* data, uint32_t size) override;
void cacheWrite(uint64_t id, const void* data, uint32_t size) override;
void screenShot(const char* filePath, uint32_t width, uint32_t height, uint32_t pitch, const void* data, uint32_t size, bool yflip) override;
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;
void captureBegin(uint32_t width, uint32_t height, uint32_t pitch, bgfx::TextureFormat::Enum format, bool yflip) override;
void captureEnd() override;
void captureFrame(const void* _data, uint32_t _size) override;
Expand Down
41 changes: 32 additions & 9 deletions Core/Graphics/Source/BgfxCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <bx/string.h>
#include <cassert>
#include <stdarg.h>
#include <stdexcept>

namespace Babylon::Graphics
{
Expand Down Expand Up @@ -85,25 +86,47 @@ namespace Babylon::Graphics
{
}

void BgfxCallback::screenShot(const char* /*filePath*/, uint32_t width, uint32_t height, uint32_t pitch, const void* data, uint32_t /*size*/, bool yflip)
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)
{
assert(!m_screenShotCallbacks.empty()); // addScreenShotCallback not called before doing the screenshot call on bgfx

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

for (uint32_t py = 0; py < height; py++)
if (format == bgfx::TextureFormat::BGRA8)
{
const uint8_t* ptr = static_cast<const uint8_t*>(data) + (yflip ? (height - py - 1) : py) * pitch;
for (uint32_t px = 0; px < width; px++)
for (uint32_t py = 0; py < height; py++)
{
// bgfx screenshot is BGRA
*bitmap++ = ptr[px * 4 + 2];
*bitmap++ = ptr[px * 4 + 1];
*bitmap++ = ptr[px * 4 + 0];
*bitmap++ = ptr[px * 4 + 3];
const uint8_t* ptr = static_cast<const uint8_t*>(data) + (yflip ? (height - py - 1) : py) * pitch;
for (uint32_t px = 0; px < width; px++)
{
// bgfx screenshot is BGRA
*bitmap++ = ptr[px * 4 + 2];
*bitmap++ = ptr[px * 4 + 1];
*bitmap++ = ptr[px * 4 + 0];
*bitmap++ = ptr[px * 4 + 3];
}
}
}
else if (format == bgfx::TextureFormat::RGBA8)
{
for (uint32_t py = 0; py < height; py++)
{
const uint8_t* ptr = static_cast<const uint8_t*>(data) + (yflip ? (height - py - 1) : py) * pitch;
for (uint32_t px = 0; px < width; px++)
{
// bgfx screenshot is RGBA
*bitmap++ = ptr[px * 4 + 0];
*bitmap++ = ptr[px * 4 + 1];
*bitmap++ = ptr[px * 4 + 2];
*bitmap++ = ptr[px * 4 + 3];
}
}
}
else
{
throw std::runtime_error{"Unsupported format for screenshot"};
}

m_screenShotCallbacks.front()(std::move(array));
m_screenShotCallbacks.pop();
Comment thread
SergioRZMasson marked this conversation as resolved.
Expand Down
7 changes: 7 additions & 0 deletions Dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ set(BGFX_CUSTOM_TARGETS OFF)
set(BGFX_INSTALL OFF)
set(BGFX_OPENGL_USE_EGL ON)
set(BGFX_USE_DEBUG_SUFFIX OFF)

FetchContent_MakeAvailable_With_Message(bgfx.cmake)

# Turn off debug annotations as it causes an access violation in D3D12.
Expand All @@ -50,6 +51,12 @@ target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_MIN_RESOURCE_COMMAND_BUFFER_
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_MIN_UNIFORM_BUFFER_SIZE=4096)
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_UNIFORM_BUFFER_RESIZE_THRESHOLD_SIZE=256)
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_UNIFORM_BUFFER_RESIZE_INCREMENT_SIZE=1024)
target_compile_definitions(bgfx PUBLIC BGFX_PLATFORM_SUPPORTS_WGSL=0)
target_compile_definitions(bgfx PUBLIC BGFX_PLATFORM_SUPPORTS_DXIL=0)
Comment thread
SergioRZMasson marked this conversation as resolved.

# Temporary disable uniform debug.
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_DEBUG_UNIFORM=0)

if(GRAPHICS_API STREQUAL "D3D11")
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_RENDERER_DIRECT3D11=1)
elseif(GRAPHICS_API STREQUAL "D3D12")
Expand Down
4 changes: 4 additions & 0 deletions Plugins/ExternalTexture/Source/ExternalTexture_D3D11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ namespace
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // ETC2
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // ETC2A
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // ETC2A1
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // EACR11 UNORM
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // EACR11 SNORM
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // EACRG11 UNORM
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // EACRG11 SNORM
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // PTC12
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // PTC14
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // PTC12A
Expand Down
4 changes: 4 additions & 0 deletions Plugins/ExternalTexture/Source/ExternalTexture_D3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ namespace
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // ETC2
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // ETC2A
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // ETC2A1
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // EACR11 UNORM
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // EACR11 SNORM
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // EACRG11 UNORM
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // EACRG11 SNORM
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // PTC12
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // PTC14
{ DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // PTC12A
Expand Down
8 changes: 8 additions & 0 deletions Plugins/ExternalTexture/Source/ExternalTexture_Metal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ namespace
constexpr MTL::PixelFormat kMtlPixelFormatPVRTC_RGBA_2BPP_sRGB = MTL::PixelFormat(165);
constexpr MTL::PixelFormat kMtlPixelFormatPVRTC_RGBA_4BPP = MTL::PixelFormat(166);
constexpr MTL::PixelFormat kMtlPixelFormatPVRTC_RGBA_4BPP_sRGB = MTL::PixelFormat(167);
constexpr MTL::PixelFormat kMtlPixelFormatEAC_R11Unorm = MTL::PixelFormat(170);
constexpr MTL::PixelFormat kMtlPixelFormatEAC_R11Snorm = MTL::PixelFormat(172);
constexpr MTL::PixelFormat kMtlPixelFormatEAC_RG11Unorm = MTL::PixelFormat(174);
constexpr MTL::PixelFormat kMtlPixelFormatEAC_RG11Snorm = MTL::PixelFormat(176);
constexpr MTL::PixelFormat kMtlPixelFormatEAC_RGBA8 = MTL::PixelFormat(178);
constexpr MTL::PixelFormat kMtlPixelFormatEAC_RGBA8_sRGB = MTL::PixelFormat(179);
constexpr MTL::PixelFormat kMtlPixelFormatETC2_RGB8 = MTL::PixelFormat(180);
Expand Down Expand Up @@ -145,6 +149,10 @@ namespace
{ kMtlPixelFormatETC2_RGB8, kMtlPixelFormatETC2_RGB8_sRGB, }, // ETC2
{ kMtlPixelFormatEAC_RGBA8, kMtlPixelFormatEAC_RGBA8_sRGB, }, // ETC2A
{ kMtlPixelFormatETC2_RGB8A1, kMtlPixelFormatETC2_RGB8A1_sRGB, }, // ETC2A1
{ kMtlPixelFormatEAC_R11Unorm, kMtlPixelFormatInvalid }, // EACR11 UNORM
{ kMtlPixelFormatEAC_R11Snorm, kMtlPixelFormatInvalid }, // EACR11 SNORM
{ kMtlPixelFormatEAC_RG11Unorm, kMtlPixelFormatInvalid }, // EACRG11 UNORM
{ kMtlPixelFormatEAC_RG11Snorm, kMtlPixelFormatInvalid }, // EACRG11 SNORM
{ kMtlPixelFormatPVRTC_RGB_2BPP, kMtlPixelFormatPVRTC_RGB_2BPP_sRGB, }, // PTC12
{ kMtlPixelFormatPVRTC_RGB_4BPP, kMtlPixelFormatPVRTC_RGB_4BPP_sRGB, }, // PTC14
{ kMtlPixelFormatPVRTC_RGBA_2BPP, kMtlPixelFormatPVRTC_RGBA_2BPP_sRGB, }, // PTC12A
Expand Down
2 changes: 1 addition & 1 deletion Polyfills/Canvas/Source/Shaders/dx11/fs_boxblur.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
static const uint8_t fs_boxblur_dx11[1117] =
static const uint8_t fs_boxblur_dxbc[1117] =
{
0x46, 0x53, 0x48, 0x0b, 0xcf, 0xda, 0x1b, 0x94, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x0a, 0x75, // FSH............u
0x5f, 0x76, 0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // _viewSize.......
Expand Down
2 changes: 1 addition & 1 deletion Polyfills/Canvas/Source/Shaders/dx11/fs_gaussblur.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
static const uint8_t fs_gaussblur_dx11[1649] =
static const uint8_t fs_gaussblur_dxbc[1649] =
{
0x46, 0x53, 0x48, 0x0b, 0xcf, 0xda, 0x1b, 0x94, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x0a, 0x75, // FSH............u
0x5f, 0x76, 0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // _viewSize.......
Expand Down
2 changes: 1 addition & 1 deletion Polyfills/Canvas/Source/Shaders/dx11/fs_nanovg_fill.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
static const uint8_t fs_nanovg_fill_dx11[3258] =
static const uint8_t fs_nanovg_fill_dxbc[3258] =
{
0x46, 0x53, 0x48, 0x0b, 0x1e, 0x98, 0xde, 0xee, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x0c, 0x75, // FSH............u
0x5f, 0x73, 0x63, 0x69, 0x73, 0x73, 0x6f, 0x72, 0x4d, 0x61, 0x74, 0x13, 0x00, 0x00, 0x00, 0x03, // _scissorMat.....
Expand Down
2 changes: 1 addition & 1 deletion Polyfills/Canvas/Source/Shaders/dx11/vs_fspass.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
static const uint8_t vs_fspass_dx11[494] =
static const uint8_t vs_fspass_dxbc[494] =
{
0x56, 0x53, 0x48, 0x0b, 0x00, 0x00, 0x00, 0x00, 0xcf, 0xda, 0x1b, 0x94, 0x00, 0x00, 0xd4, 0x01, // VSH.............
0x00, 0x00, 0x44, 0x58, 0x42, 0x43, 0x2d, 0x40, 0xc0, 0xce, 0x39, 0x67, 0x5a, 0x73, 0x8a, 0xa9, // ..DXBC-@..9gZs..
Expand Down
2 changes: 1 addition & 1 deletion Polyfills/Canvas/Source/Shaders/dx11/vs_nanovg_fill.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
static const uint8_t vs_nanovg_fill_dx11[800] =
static const uint8_t vs_nanovg_fill_dxbc[800] =
{
0x56, 0x53, 0x48, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x98, 0xde, 0xee, 0x02, 0x00, 0x0a, 0x75, // VSH............u
0x5f, 0x76, 0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // _viewSize.......
Expand Down
4 changes: 2 additions & 2 deletions Polyfills/Canvas/shaderc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,15 @@ function(add_bgfx_shader FILE FOLDER)
PROFILE s_5_0
O 3
OUTPUT ${DX11_OUTPUT}
BIN2C "${FILENAME}_dx11"
BIN2C "${FILENAME}_dxbc"
)
else()
_bn_shaderc_parse(
DX11 ${COMMON} WINDOWS
PROFILE s_5_0
O 1
OUTPUT ${DX11_OUTPUT}
BIN2C "${FILENAME}_dx11"
BIN2C "${FILENAME}_dxbc"
)
endif()
list(APPEND OUTPUTS "DX11")
Expand Down