Skip to content

Commit c120e02

Browse files
committed
Merge branch 'native-cube-render-target' into native-combined-gl-fixes
2 parents f43d83b + 77c4f66 commit c120e02

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

Apps/Playground/Scripts/config.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,16 +1813,12 @@
18131813
"title": "Shadows with instances in left handed system",
18141814
"playgroundId": "#MSAHKR#79",
18151815
"renderCount": 10,
1816-
"excludeFromAutomaticTesting": true,
1817-
"reason": "Test crashes or hangs on Babylon Native",
18181816
"referenceImage": "shadowsinstancesleft.png"
18191817
},
18201818
{
18211819
"title": "Shadows with instances in right handed system",
18221820
"playgroundId": "#MSAHKR#13",
18231821
"renderCount": 10,
1824-
"excludeFromAutomaticTesting": true,
1825-
"reason": "Test crashes or hangs on Babylon Native",
18261822
"referenceImage": "shadowsinstancesright.png"
18271823
},
18281824
{

Plugins/NativeEngine/Source/NativeEngine.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,7 @@ namespace Babylon
15571557
const bool renderTarget = info[5].As<Napi::Boolean>();
15581558
const bool srgb = info[6].As<Napi::Boolean>();
15591559
const uint32_t samples = info[7].IsUndefined() ? 1 : info[7].As<Napi::Number>().Uint32Value();
1560+
const bool isCube = info.Length() > 8 && !info[8].IsUndefined() && info[8].As<Napi::Boolean>();
15601561

15611562
auto flags = BGFX_TEXTURE_NONE;
15621563
if (renderTarget)
@@ -1568,7 +1569,15 @@ namespace Babylon
15681569
flags |= BGFX_TEXTURE_SRGB;
15691570
}
15701571

1571-
texture->Create2D(width, height, hasMips, 1, format, flags);
1572+
if (isCube)
1573+
{
1574+
// Cube render target: width is the per-face size.
1575+
texture->CreateCube(width, hasMips, 1, format, flags);
1576+
}
1577+
else
1578+
{
1579+
texture->Create2D(width, height, hasMips, 1, format, flags);
1580+
}
15721581
}
15731582

15741583
void NativeEngine::LoadTexture(const Napi::CallbackInfo& info)
@@ -2094,6 +2103,8 @@ namespace Babylon
20942103
const bool generateStencilBuffer = info[3].As<Napi::Boolean>();
20952104
const bool generateDepth = info[4].As<Napi::Boolean>();
20962105
const uint32_t samples = info[5].IsUndefined() ? 1 : info[5].As<Napi::Number>().Uint32Value();
2106+
// Optional cube-face / array layer for the color attachment (single-face cube render targets).
2107+
const uint16_t layer = (info.Length() > 6 && !info[6].IsUndefined()) ? static_cast<uint16_t>(info[6].As<Napi::Number>().Uint32Value()) : 0;
20972108

20982109
std::array<bgfx::Attachment, 2> attachments{};
20992110
uint8_t numAttachments = 0;
@@ -2104,7 +2115,7 @@ namespace Babylon
21042115
// bgfx validation now asserts when trying to use BGFX_RESOLVE_AUTO_GEN_MIPS with a texture that doesn't have the BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN flag,
21052116
// but before it would just ignore the flag and not generate mips without any warning. This prevents validation assert, but rendering might be broken if autogen
21062117
// mips were expected. Basically this change preserves previous behavior.
2107-
attachments[numAttachments++].init(texture->Handle(), bgfx::Access::Write, 0, 1, 0
2118+
attachments[numAttachments++].init(texture->Handle(), bgfx::Access::Write, layer, 1, 0
21082119
, 0 != (caps->formats[texture->Format()] & BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN) ? BGFX_RESOLVE_AUTO_GEN_MIPS : BGFX_RESOLVE_NONE
21092120
);
21102121
}

0 commit comments

Comments
 (0)