diff --git a/Apps/Playground/Scripts/config.json b/Apps/Playground/Scripts/config.json index 3b7389558..75cc09441 100644 --- a/Apps/Playground/Scripts/config.json +++ b/Apps/Playground/Scripts/config.json @@ -1823,16 +1823,12 @@ "title": "Shadows with instances in left handed system", "playgroundId": "#MSAHKR#79", "renderCount": 10, - "excludeFromAutomaticTesting": true, - "reason": "Test crashes or hangs on Babylon Native", "referenceImage": "shadowsinstancesleft.png" }, { "title": "Shadows with instances in right handed system", "playgroundId": "#MSAHKR#13", "renderCount": 10, - "excludeFromAutomaticTesting": true, - "reason": "Test crashes or hangs on Babylon Native", "referenceImage": "shadowsinstancesright.png" }, { diff --git a/Plugins/NativeEngine/Source/NativeEngine.cpp b/Plugins/NativeEngine/Source/NativeEngine.cpp index 864031710..7d7bee390 100644 --- a/Plugins/NativeEngine/Source/NativeEngine.cpp +++ b/Plugins/NativeEngine/Source/NativeEngine.cpp @@ -1348,6 +1348,7 @@ namespace Babylon const bool renderTarget = info[5].As(); const bool srgb = info[6].As(); const uint32_t samples = info[7].IsUndefined() ? 1 : info[7].As().Uint32Value(); + const bool isCube = info.Length() > 8 && !info[8].IsUndefined() && info[8].As(); auto flags = BGFX_TEXTURE_NONE; if (renderTarget) @@ -1359,7 +1360,15 @@ namespace Babylon flags |= BGFX_TEXTURE_SRGB; } - texture->Create2D(width, height, hasMips, 1, format, flags); + if (isCube) + { + // Cube render target: width is the per-face size. + texture->CreateCube(width, hasMips, 1, format, flags); + } + else + { + texture->Create2D(width, height, hasMips, 1, format, flags); + } } void NativeEngine::LoadTexture(const Napi::CallbackInfo& info) @@ -1852,6 +1861,8 @@ namespace Babylon const bool generateStencilBuffer = info[3].As(); const bool generateDepth = info[4].As(); const uint32_t samples = info[5].IsUndefined() ? 1 : info[5].As().Uint32Value(); + // Optional cube-face / array layer for the color attachment (single-face cube render targets). + const uint16_t layer = (info.Length() > 6 && !info[6].IsUndefined()) ? static_cast(info[6].As().Uint32Value()) : 0; std::array attachments{}; uint8_t numAttachments = 0; @@ -1862,7 +1873,7 @@ namespace Babylon // 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, // 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 // mips were expected. Basically this change preserves previous behavior. - attachments[numAttachments++].init(texture->Handle(), bgfx::Access::Write, 0, 1, 0 + attachments[numAttachments++].init(texture->Handle(), bgfx::Access::Write, layer, 1, 0 , 0 != (caps->formats[texture->Format()] & BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN) ? BGFX_RESOLVE_AUTO_GEN_MIPS : BGFX_RESOLVE_NONE ); }