-
Notifications
You must be signed in to change notification settings - Fork 153
Expand file tree
/
Copy pathtests.externalTexture.layerCount.js
More file actions
154 lines (134 loc) · 5.79 KB
/
Copy pathtests.externalTexture.layerCount.js
File metadata and controls
154 lines (134 loc) · 5.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "@babylonjs/core"
/*!**************************!*\
!*** external "BABYLON" ***!
\**************************/
(module) {
module.exports = BABYLON;
/***/ }
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Check if module exists (development only)
/******/ if (__webpack_modules__[moduleId] === undefined) {
/******/ var e = new Error("Cannot find module '" + moduleId + "'");
/******/ e.code = 'MODULE_NOT_FOUND';
/******/ throw e;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ (() => {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = (module) => {
/******/ var getter = module && module.__esModule ?
/******/ () => (module['default']) :
/******/ () => (module);
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
(() => {
/*!*************************************************!*\
!*** ./src/tests.externalTexture.layerCount.ts ***!
\*************************************************/
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _babylonjs_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babylonjs/core */ "@babylonjs/core");
/* harmony import */ var _babylonjs_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babylonjs_core__WEBPACK_IMPORTED_MODULE_0__);
// JS-side scaffolding for Tests.ExternalTexture.LayerCount.cpp.
//
// Verifies that wrapNativeTexture auto-populates is2DArray/depth/baseDepth on the wrapped
// InternalTexture from the native layer count:
// - BN exposes getTextureLayerCount(handle) (BabylonJS/BabylonNative#1733), reporting the *bound*
// layer count: 1 for a single-slice view (layerIndex set), else the underlying array size.
// - BJS wrapNativeTexture consumes it (BabylonJS/Babylon.js#18535): layers > 1 -> is2DArray=true,
// baseDepth=depth=layers; layers == 1 -> left as a plain 2D texture.
// C++ wraps whole-array, single-slice, and single-layer native textures and asserts the values
// reported back here.
var engine;
function getEngine() {
if (!engine) {
engine = new _babylonjs_core__WEBPACK_IMPORTED_MODULE_0__.NativeEngine();
// This test never renders; don't wait on async shader compilation.
delete engine.getCaps().parallelShaderCompile;
}
return engine;
}
// Wraps the given native texture and returns the layer-related InternalTexture fields, plus the raw
// native layer count so C++ can tell "binding missing" / "BJS too old" from a real failure.
function inspectWrappedTexture(nativeTexture) {
var e = getEngine();
// getTextureLayerCount is a binding on the raw native engine (_engine), which is private and not
// yet in the shipped @babylonjs/core types; wrapNativeTexture reads it internally via this._engine.
var nativeEngine = e._engine;
var hasBinding = !!nativeEngine && typeof nativeEngine.getTextureLayerCount === "function";
var rawLayerCount = hasBinding ? nativeEngine.getTextureLayerCount(nativeTexture) : -1;
var internalTexture = e.wrapNativeTexture(nativeTexture);
return {
hasBinding: hasBinding,
rawLayerCount: rawLayerCount,
is2DArray: !!internalTexture.is2DArray,
depth: internalTexture.depth,
baseDepth: internalTexture.baseDepth
};
}
globalThis.inspectWrappedTexture = inspectWrappedTexture;
})();
/******/ })()
;