@babylonjs/lite-gl 1.22.0 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/README.md +98 -2
- package/context.d.ts +5 -0
- package/context.js +8 -0
- package/context.js.map +1 -1
- package/depth-stencil.d.ts +1 -14
- package/depth-stencil.js.map +1 -1
- package/effect-renderer.d.ts +1 -11
- package/effect-renderer.js.map +1 -1
- package/effect.d.ts +5 -27
- package/effect.js +22 -0
- package/effect.js.map +1 -1
- package/family.d.ts +470 -0
- package/family.js +14 -0
- package/family.js.map +1 -0
- package/index.d.ts +8 -6
- package/index.js +3 -3
- package/index.js.map +1 -1
- package/mesh.d.ts +4 -1
- package/mesh.js +10 -3
- package/mesh.js.map +1 -1
- package/native/command-stream.d.ts +1 -0
- package/native/command-stream.js +135 -0
- package/native/command-stream.js.map +1 -0
- package/native/context.d.ts +26 -0
- package/native/context.js +89 -0
- package/native/context.js.map +1 -0
- package/native/effect.d.ts +44 -0
- package/native/effect.js +276 -0
- package/native/effect.js.map +1 -0
- package/native/family.d.ts +75 -0
- package/native/family.js +2 -0
- package/native/family.js.map +1 -0
- package/native/identity.d.ts +11 -0
- package/native/identity.js +2 -0
- package/native/identity.js.map +1 -0
- package/native/index.d.ts +25 -0
- package/native/index.js +7 -0
- package/native/index.js.map +1 -0
- package/native/mesh.d.ts +53 -0
- package/native/mesh.js +137 -0
- package/native/mesh.js.map +1 -0
- package/native/render-target.d.ts +35 -0
- package/native/render-target.js +159 -0
- package/native/render-target.js.map +1 -0
- package/native/runtime.d.ts +1 -0
- package/native/runtime.js +12 -0
- package/native/runtime.js.map +1 -0
- package/native/state.d.ts +19 -0
- package/native/state.js +104 -0
- package/native/state.js.map +1 -0
- package/native/texture.d.ts +37 -0
- package/native/texture.js +86 -0
- package/native/texture.js.map +1 -0
- package/package.json +11 -3
- package/render-target.d.ts +7 -0
- package/render-target.js +38 -0
- package/render-target.js.map +1 -1
- package/scissor.d.ts +2 -2
- package/scissor.js +2 -2
- package/scissor.js.map +1 -1
- package/state.d.ts +1 -0
- package/state.js +2 -5
- package/state.js.map +1 -1
- package/text/text-renderer.js.map +1 -1
- package/web-family.d.ts +87 -0
- package/web-family.js +2 -0
- package/web-family.js.map +1 -0
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,gFAAgF;AAChF,EAAE;AACF,iFAAiF;AACjF,4EAA4E;AAC5E,2EAA2E;AAC3E,yEAAyE;AACzE,+DAA+D;AAC/D,EAAE;AACF,gFAAgF;AAChF,8EAA8E;AAC9E,wCAAwC;AAExC,wEAAwE;AACxE,OAAO,EACH,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,kBAAkB,GACrB,MAAM,cAAc,CAAC;AAGtB,uEAAuE;AACvE,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEvG,wEAAwE;AACxE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvF,uEAAuE;AACvE,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAGlF,wEAAwE;AACxE,OAAO,EACH,YAAY,EACZ,SAAS,EACT,aAAa,EACb,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,eAAe,EACf,eAAe,EACf,eAAe,EACf,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,mBAA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AAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGrG,wEAAwE;AACxE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,YAAY,EAAE,WAAW,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAGhK,wEAAwE;AACxE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE1D,wEAAwE;AACxE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAGpH,wEAAwE;AACxE,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAIvF,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAGnF,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEtG,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtF,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAEnH,OAAO,EACH,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC","sourcesContent":["// @babylonjs/lite-gl — Public API\n// Function-based, tree-shakeable WebGL2 micro-engine. Import only what you use.\n//\n// Convention (mirrors @babylonjs/lite): the public API is re-exported EXPLICITLY\n// by name — never `export *`. This keeps the public surface intentional and\n// reviewable, lets `export type` mark type-only re-exports (required under\n// `isolatedModules`), and keeps internal helpers (e.g. `bindTextureRaw`,\n// `bindTextureForUpload`) out of consumers' bundles + `.d.ts`.\n//\n// The package is `sideEffects: false` and no module has top-level side effects,\n// so a consumer that imports only the symbols it needs tree-shakes everything\n// else (sprites, html-texture, …) away.\n\n// ─── Engine / context ────────────────────────────────────────────────\nexport {\n createGLEngine,\n disposeGLEngine,\n resizeGLEngine,\n setGLEngineSize,\n wipeGLStateCache,\n getRenderWidth,\n getRenderHeight,\n getHardwareScalingLevel,\n setHardwareScalingLevel,\n getRenderingCanvas,\n onContextLost,\n offContextLost,\n onContextRestored,\n offContextRestored,\n} from \"./context.js\";\nexport type { GLEngineOptions, GLEngineCaps, GLEngineContext } from \"./context.js\";\n\n// ─── Alpha-to-coverage (optional) ───────────────────────────────────\nexport { getAlphaToCoverage, getCurrentSampleCount, setAlphaToCoverage } from \"./alpha-to-coverage.js\";\n\n// ─── Render loop ─────────────────────────────────────────────────────\nexport { runRenderLoop, stopRenderLoop, beginFrame, endFrame } from \"./render-loop.js\";\n\n// ─── GPU frame timing (optional) ────────────────────────────────────\nexport { captureGPUFrameTime, getGPUFrameTimeCounter } from \"./gpu-frame-time.js\";\nexport type { GLPerfCounter } from \"./gpu-frame-time.js\";\n\n// ─── Effects ─────────────────────────────────────────────────────────\nexport {\n createEffect,\n useEffect,\n isEffectReady,\n getEffectCompilationError,\n executeWhenCompiled,\n disposeEffect,\n setEffectFloat,\n setEffectFloat2,\n setEffectFloat3,\n setEffectFloat4,\n setEffectColor3,\n setEffectColor4,\n setEffectVector2,\n setEffectDirectColor4,\n setEffectInt,\n setEffectTexture,\n setEffectMatrix,\n setEffectMatrix3x3,\n setEffectFloatArray,\n setEffectFloatArray4,\n setEffectIntArray,\n} from \"./effect.js\";\nexport type { GLEffectOptions, GLEffect } from \"./effect.js\";\nexport { waitForEffect } from \"./effect-ready.js\";\nexport type { GLEffectWaitOptions } from \"./effect-ready.js\";\n\n// ─── Effect renderer (fullscreen quad) ───────────────────────────────\nexport { createEffectWrapper, applyEffectWrapper, drawEffect, setViewport, disposeEffectWrapper } from \"./effect-renderer.js\";\nexport type { GLEffectWrapperOptions, GLEffectWrapper, GLViewport } from \"./effect-renderer.js\";\n\n// ─── Textures ────────────────────────────────────────────────────────\nexport {\n createRawTexture,\n createFloatTexture,\n generateTextureMipMaps,\n loadTexture2D,\n bindTexture,\n unbindTexture,\n disposeTexture,\n updateRawTexture,\n updateTextureSamplingMode,\n updateTextureSamplingPreset,\n updateTextureWrapMode,\n createTextureFromHandle,\n getSamplingModeFilters,\n isTextureReady,\n // GLSamplingMode is a const + same-name type; one value re-export carries both.\n GLSamplingMode,\n} from \"./texture.js\";\nexport type { GLTextureOptions, GLTextureUpdateOptions, GLRawTextureOptions, GLFloatTextureOptions, GLTexture, GLSamplingFilters } from \"./texture.js\";\nexport { createTextureFromSource } from \"./texture-source.js\";\nexport type { GLTextureSourceOptions } from \"./texture-source.js\";\nexport {\n createTexture3DFromPixels,\n bindTexture3D,\n unbindTexture3D,\n setEffectTexture3D,\n generateTexture3DMipMaps,\n updateTexture3DSamplingMode,\n updateTexture3DWrapMode,\n disposeTexture3D,\n} from \"./texture-3d.js\";\nexport type { GLPixelsTexture3DOptions, GLTexture3D } from \"./texture-3d.js\";\n\n// ─── Dynamic textures ────────────────────────────────────────────────\nexport { createDynamicTexture, updateDynamicTexture, clearDynamicTextureSource } from \"./dynamic-texture.js\";\n\n// ─── Render targets ──────────────────────────────────────────────────\nexport {\n createRenderTarget,\n createFloatRenderTarget,\n bindRenderTarget,\n restoreDefaultFramebuffer,\n generateRenderTargetMipMaps,\n resizeRenderTarget,\n readRenderTargetPixels,\n readRenderTargetPixelsToBuffer,\n disposeRenderTarget,\n} from \"./render-target.js\";\nexport type {\n GLRenderTarget,\n GLRenderTargetOptions,\n GLFloatRenderTargetOptions,\n GLReadPixelsRegionOptions,\n GLReadPixelsOptions,\n GLReadPixelsToBufferOptions,\n} from \"./render-target.js\";\n\n// ─── Meshes / buffers / instancing ───────────────────────────────────\nexport {\n createVertexBuffer,\n updateVertexBuffer,\n createIndexBuffer,\n disposeBuffer,\n bindIndexBuffer,\n bindAttributes,\n unbindInstanceAttributes,\n drawIndexed,\n createMeshVao,\n bindMeshVao,\n drawMesh,\n disposeMeshVao,\n} from \"./mesh.js\";\nexport type { GLVertexBuffer, GLIndexBuffer, GLAttributeDescriptor, GLMeshVertexBuffer, GLMeshVao } from \"./mesh.js\";\n\n// ─── Blend modes ─────────────────────────────────────────────────────\n// GLBlendMode / GLBlendEquation are const + same-name type; one value\n// re-export carries both.\nexport { GLBlendMode, GLBlendEquation, setBlendMode, setBlendState, disableBlend } from \"./blend.js\";\nexport type { GLBlendState } from \"./blend.js\";\n\n// ─── Depth / stencil / color-mask / clear ────────────────────────────\nexport { setDepthState, setCullState, setStencilState, setStencilOpSeparate, setColorMask, clearEngine, generateRenderTargetStencil } from \"./depth-stencil.js\";\nexport type { GLDepthState, GLStencilState, GLStencilOpState, GLClearOptions } from \"./depth-stencil.js\";\n\n// ─── Scissor ─────────────────────────────────────────────────────────\nexport { setScissor, disableScissor } from \"./scissor.js\";\n\n// ─── Sprites ─────────────────────────────────────────────────────────\nexport { createSpriteRenderer, renderSprites, setSpriteRendererTexture, disposeSpriteRenderer } from \"./sprites.js\";\nexport type { GLSprite, GLSpriteColor, GLSpriteRendererOptions, GLSpriteRenderer } from \"./sprites.js\";\n\n// ─── HTML-element textures ───────────────────────────────────────────\nexport { createHtmlElementTexture, updateHtmlElementTexture } from \"./html-texture.js\";\n\n// ─── Text (analytic Slug coverage) ───────────────────────────────────\nexport type { GLFont } from \"./text/font.js\";\nexport { loadFont, createFontFromBuffer } from \"./text/font.js\";\nexport { extractGlyphCurves, cubicToQuadratics } from \"./text/glyph-extraction.js\";\nexport type { GLTextLayoutOptions } from \"./text/layout.js\";\nexport type { GLGlyphStorage, GLCurveSetId, GLQuadCurve, GLGlyphBounds, GLGlyphCurves } from \"./text/glyph-storage.js\";\nexport { createGlyphStorage, updateGlyphStorage, disposeGlyphStorage } from \"./text/glyph-storage.js\";\nexport type { GLTextData, GLPlacedGlyph, GLGlyphRun, GLTextDataUpdate } from \"./text/text-data.js\";\nexport { createTextData, updateTextData, disposeTextData } from \"./text/text-data.js\";\nexport type { GLDefaultTextData } from \"./text/default-text-data.js\";\nexport { createDefaultTextData, updateDefaultTextData, disposeDefaultTextData } from \"./text/default-text-data.js\";\nexport type { GLTextLayer, GLTextLayerOptions, GLTextRenderer, GLTextRendererOptions } from \"./text/text-renderer.js\";\nexport {\n createTextLayer,\n setTextLayerPosition,\n createTextRenderer,\n renderText,\n isTextRendererReady,\n addTextRendererLayer,\n removeTextRendererLayer,\n registerTextRenderer,\n unregisterTextRenderer,\n disposeTextRenderer,\n} from \"./text/text-renderer.js\";\nexport { setFontWeightOffset } from \"./text/set-font-weight-offset.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,gFAAgF;AAChF,EAAE;AACF,iFAAiF;AACjF,4EAA4E;AAC5E,2EAA2E;AAC3E,yEAAyE;AACzE,+DAA+D;AAC/D,EAAE;AACF,gFAAgF;AAChF,8EAA8E;AAC9E,wCAAwC;AASxC,wEAAwE;AACxE,OAAO,EACH,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,kBAAkB,GACrB,MAAM,cAAc,CAAC;AAGtB,uEAAuE;AACvE,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEvG,wEAAwE;AACxE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,Q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E,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAEnH,OAAO,EACH,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC","sourcesContent":["// @babylonjs/lite-gl — Public API\n// Function-based, tree-shakeable WebGL2 micro-engine. Import only what you use.\n//\n// Convention (mirrors @babylonjs/lite): the public API is re-exported EXPLICITLY\n// by name — never `export *`. This keeps the public surface intentional and\n// reviewable, lets `export type` mark type-only re-exports (required under\n// `isolatedModules`), and keeps internal helpers (e.g. `bindTextureRaw`,\n// `bindTextureForUpload`) out of consumers' bundles + `.d.ts`.\n//\n// The package is `sideEffects: false` and no module has top-level side effects,\n// so a consumer that imports only the symbols it needs tree-shakes everything\n// else (sprites, html-texture, …) away.\n\n// ─── Backend-neutral contract ────────────────────────────────────────\n// The generic contract (`GLFamily`, `GLOps`, `GLKit`) is published at\n// `@babylonjs/lite-gl/family`; this entry adds the WebGL2 mapping and keeps the\n// shared descriptors importable alongside the operations that take them.\nexport type { GLEffectOptions, GLViewport, GLClearOptions } from \"./family.js\";\nexport type { WebGLFamily, WebGLHostOps } from \"./web-family.js\";\n\n// ─── Engine / context ────────────────────────────────────────────────\nexport {\n createGLEngine,\n disposeGLEngine,\n resizeGLEngine,\n setGLEngineSize,\n wipeGLStateCache,\n getRenderWidth,\n getRenderHeight,\n getTextureCount,\n getCurrentRenderTarget,\n getHardwareScalingLevel,\n setHardwareScalingLevel,\n getRenderingCanvas,\n onContextLost,\n offContextLost,\n onContextRestored,\n offContextRestored,\n} from \"./context.js\";\nexport type { GLEngineOptions, GLEngineCaps, GLEngineContext } from \"./context.js\";\n\n// ─── Alpha-to-coverage (optional) ───────────────────────────────────\nexport { getAlphaToCoverage, getCurrentSampleCount, setAlphaToCoverage } from \"./alpha-to-coverage.js\";\n\n// ─── Render loop ─────────────────────────────────────────────────────\nexport { runRenderLoop, stopRenderLoop, beginFrame, endFrame } from \"./render-loop.js\";\n\n// ─── GPU frame timing (optional) ────────────────────────────────────\nexport { captureGPUFrameTime, getGPUFrameTimeCounter } from \"./gpu-frame-time.js\";\nexport type { GLPerfCounter } from \"./gpu-frame-time.js\";\n\n// ─── Effects ─────────────────────────────────────────────────────────\nexport {\n createEffect,\n useEffect,\n isEffectReady,\n getEffectCompilationError,\n executeWhenCompiled,\n disposeEffect,\n setEffectFloat,\n setEffectFloat2,\n setEffectFloat3,\n setEffectFloat4,\n setEffectColor3,\n setEffectColor4,\n setEffectVector2,\n setEffectDirectColor4,\n setEffectInt,\n setEffectTexture,\n setEffectMatrix,\n setEffectMatrix3x3,\n setEffectFloatArray,\n setEffectFloatArray2,\n setEffectFloatArray3,\n setEffectFloatArray4,\n setEffectIntArray,\n} from \"./effect.js\";\nexport type { GLEffect } from \"./effect.js\";\nexport { waitForEffect } from \"./effect-ready.js\";\nexport type { GLEffectWaitOptions } from \"./effect-ready.js\";\n\n// ─── Effect renderer (fullscreen quad) ───────────────────────────────\nexport { createEffectWrapper, applyEffectWrapper, drawEffect, setViewport, disposeEffectWrapper } from \"./effect-renderer.js\";\nexport type { GLEffectWrapperOptions, GLEffectWrapper } from \"./effect-renderer.js\";\n\n// ─── Textures ────────────────────────────────────────────────────────\nexport {\n createRawTexture,\n createFloatTexture,\n generateTextureMipMaps,\n loadTexture2D,\n bindTexture,\n unbindTexture,\n disposeTexture,\n updateRawTexture,\n updateTextureSamplingMode,\n updateTextureSamplingPreset,\n updateTextureWrapMode,\n createTextureFromHandle,\n getSamplingModeFilters,\n isTextureReady,\n // GLSamplingMode is a const + same-name type; one value re-export carries both.\n GLSamplingMode,\n} from \"./texture.js\";\nexport type { GLTextureOptions, GLTextureUpdateOptions, GLRawTextureOptions, GLFloatTextureOptions, GLTexture, GLSamplingFilters } from \"./texture.js\";\nexport { createTextureFromSource } from \"./texture-source.js\";\nexport type { GLTextureSourceOptions } from \"./texture-source.js\";\nexport {\n createTexture3DFromPixels,\n bindTexture3D,\n unbindTexture3D,\n setEffectTexture3D,\n generateTexture3DMipMaps,\n updateTexture3DSamplingMode,\n updateTexture3DWrapMode,\n disposeTexture3D,\n} from \"./texture-3d.js\";\nexport type { GLPixelsTexture3DOptions, GLTexture3D } from \"./texture-3d.js\";\n\n// ─── Dynamic textures ────────────────────────────────────────────────\nexport { createDynamicTexture, updateDynamicTexture, clearDynamicTextureSource } from \"./dynamic-texture.js\";\n\n// ─── Render targets ──────────────────────────────────────────────────\nexport {\n createRenderTarget,\n createFloatRenderTarget,\n bindRenderTarget,\n restoreDefaultFramebuffer,\n presentRenderTarget,\n generateRenderTargetMipMaps,\n resizeRenderTarget,\n readRenderTargetPixels,\n readRenderTargetPixelsToBuffer,\n disposeRenderTarget,\n} from \"./render-target.js\";\nexport type {\n GLRenderTarget,\n GLRenderTargetOptions,\n GLFloatRenderTargetOptions,\n GLReadPixelsRegionOptions,\n GLReadPixelsOptions,\n GLReadPixelsToBufferOptions,\n} from \"./render-target.js\";\n\n// ─── Meshes / buffers / instancing ───────────────────────────────────\nexport {\n createVertexBuffer,\n updateVertexBuffer,\n createIndexBuffer,\n disposeBuffer,\n bindIndexBuffer,\n bindAttributes,\n unbindInstanceAttributes,\n drawIndexed,\n createMeshVao,\n bindMeshVao,\n drawMesh,\n disposeMeshVao,\n} from \"./mesh.js\";\nexport type { GLVertexBuffer, GLIndexBuffer, GLAttributeDescriptor, GLMeshVertexBuffer, GLMeshVao } from \"./mesh.js\";\n\n// ─── Blend modes ─────────────────────────────────────────────────────\n// GLBlendMode / GLBlendEquation are const + same-name type; one value\n// re-export carries both.\nexport { GLBlendMode, GLBlendEquation, setBlendMode, setBlendState, disableBlend } from \"./blend.js\";\nexport type { GLBlendState } from \"./blend.js\";\n\n// ─── Depth / stencil / color-mask / clear ────────────────────────────\nexport { setDepthState, setCullState, setStencilState, setStencilOpSeparate, setColorMask, clearEngine, generateRenderTargetStencil } from \"./depth-stencil.js\";\nexport type { GLDepthState, GLStencilState, GLStencilOpState } from \"./depth-stencil.js\";\n\n// ─── Scissor ─────────────────────────────────────────────────────────\nexport { setScissor, disableScissor } from \"./scissor.js\";\n\n// ─── Sprites ─────────────────────────────────────────────────────────\nexport { createSpriteRenderer, renderSprites, setSpriteRendererTexture, disposeSpriteRenderer } from \"./sprites.js\";\nexport type { GLSprite, GLSpriteColor, GLSpriteRendererOptions, GLSpriteRenderer } from \"./sprites.js\";\n\n// ─── HTML-element textures ───────────────────────────────────────────\nexport { createHtmlElementTexture, updateHtmlElementTexture } from \"./html-texture.js\";\n\n// ─── Text (analytic Slug coverage) ───────────────────────────────────\nexport type { GLFont } from \"./text/font.js\";\nexport { loadFont, createFontFromBuffer } from \"./text/font.js\";\nexport { extractGlyphCurves, cubicToQuadratics } from \"./text/glyph-extraction.js\";\nexport type { GLTextLayoutOptions } from \"./text/layout.js\";\nexport type { GLGlyphStorage, GLCurveSetId, GLQuadCurve, GLGlyphBounds, GLGlyphCurves } from \"./text/glyph-storage.js\";\nexport { createGlyphStorage, updateGlyphStorage, disposeGlyphStorage } from \"./text/glyph-storage.js\";\nexport type { GLTextData, GLPlacedGlyph, GLGlyphRun, GLTextDataUpdate } from \"./text/text-data.js\";\nexport { createTextData, updateTextData, disposeTextData } from \"./text/text-data.js\";\nexport type { GLDefaultTextData } from \"./text/default-text-data.js\";\nexport { createDefaultTextData, updateDefaultTextData, disposeDefaultTextData } from \"./text/default-text-data.js\";\nexport type { GLTextLayer, GLTextLayerOptions, GLTextRenderer, GLTextRendererOptions } from \"./text/text-renderer.js\";\nexport {\n createTextLayer,\n setTextLayerPosition,\n createTextRenderer,\n renderText,\n isTextRendererReady,\n addTextRendererLayer,\n removeTextRendererLayer,\n registerTextRenderer,\n unregisterTextRenderer,\n disposeTextRenderer,\n} from \"./text/text-renderer.js\";\nexport { setFontWeightOffset } from \"./text/set-font-weight-offset.js\";\n"]}
|
package/mesh.d.ts
CHANGED
|
@@ -198,8 +198,11 @@ export declare function bindMeshVao(vao: GLMeshVao): void;
|
|
|
198
198
|
*
|
|
199
199
|
* @param vao - The mesh VAO to draw.
|
|
200
200
|
* @param instanceCount - Instance count for instanced draws. Default 0 (non-instanced).
|
|
201
|
+
* @param indexStart - First index in the retained mesh.
|
|
202
|
+
* @param indexCount - Number of indices; defaults to the indices from `indexStart` to the end of the mesh.
|
|
203
|
+
* @throws RangeError when the range is not whole indices within the mesh.
|
|
201
204
|
*/
|
|
202
|
-
export declare function drawMesh(vao: GLMeshVao, instanceCount?: number): void;
|
|
205
|
+
export declare function drawMesh(vao: GLMeshVao, instanceCount?: number, indexStart?: number, indexCount?: number): void;
|
|
203
206
|
/** Dispose a {@link GLMeshVao}: delete the VAO and unregister its restore hook.
|
|
204
207
|
* Does NOT dispose the vertex/index buffers (the caller owns those). Idempotent. */
|
|
205
208
|
export declare function disposeMeshVao(vao: GLMeshVao): void;
|
package/mesh.js
CHANGED
|
@@ -378,8 +378,15 @@ export function bindMeshVao(vao) {
|
|
|
378
378
|
*
|
|
379
379
|
* @param vao - The mesh VAO to draw.
|
|
380
380
|
* @param instanceCount - Instance count for instanced draws. Default 0 (non-instanced).
|
|
381
|
+
* @param indexStart - First index in the retained mesh.
|
|
382
|
+
* @param indexCount - Number of indices; defaults to the indices from `indexStart` to the end of the mesh.
|
|
383
|
+
* @throws RangeError when the range is not whole indices within the mesh.
|
|
381
384
|
*/
|
|
382
|
-
export function drawMesh(vao, instanceCount = 0) {
|
|
385
|
+
export function drawMesh(vao, instanceCount = 0, indexStart = 0, indexCount = vao._indexBuffer.count - indexStart) {
|
|
386
|
+
const total = vao._indexBuffer.count;
|
|
387
|
+
if (!Number.isInteger(indexStart) || !Number.isInteger(indexCount) || indexStart < 0 || indexCount < 0 || indexStart + indexCount > total) {
|
|
388
|
+
throw new RangeError(`lite-gl: drawMesh range (start ${indexStart}, count ${indexCount}) must be whole indices within the mesh's ${total}`);
|
|
389
|
+
}
|
|
383
390
|
const engine = vao._engine;
|
|
384
391
|
if (engine._isLost || engine._disposed || vao._disposed) {
|
|
385
392
|
return;
|
|
@@ -393,10 +400,10 @@ export function drawMesh(vao, instanceCount = 0) {
|
|
|
393
400
|
const gl = engine.gl;
|
|
394
401
|
const type = ib.is32Bits ? UNSIGNED_INT : UNSIGNED_SHORT;
|
|
395
402
|
if (instanceCount > 0) {
|
|
396
|
-
gl.drawElementsInstanced(TRIANGLES,
|
|
403
|
+
gl.drawElementsInstanced(TRIANGLES, indexCount, type, indexStart * (ib.is32Bits ? 4 : 2), instanceCount);
|
|
397
404
|
}
|
|
398
405
|
else {
|
|
399
|
-
gl.drawElements(TRIANGLES,
|
|
406
|
+
gl.drawElements(TRIANGLES, indexCount, type, indexStart * (ib.is32Bits ? 4 : 2));
|
|
400
407
|
}
|
|
401
408
|
}
|
|
402
409
|
/** Dispose a {@link GLMeshVao}: delete the VAO and unregister its restore hook.
|
package/mesh.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mesh.js","sourceRoot":"","sources":["../src/mesh.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAiB,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,4BAA4B;AAC5B,MAAM,YAAY,GAAG,MAAM,CAAC;AAC5B,oCAAoC;AACpC,MAAM,oBAAoB,GAAG,MAAM,CAAC;AACpC,2BAA2B;AAC3B,MAAM,WAAW,GAAG,MAAM,CAAC;AAC3B,4BAA4B;AAC5B,MAAM,YAAY,GAAG,MAAM,CAAC;AAC5B,qBAAqB;AACrB,MAAM,KAAK,GAAG,MAAM,CAAC;AACrB,yBAAyB;AACzB,MAAM,SAAS,GAAG,MAAM,CAAC;AACz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I,CAAC;QAClB,CAAC,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAChC,CAAC;AACL,CAAC;AAED;iEACiE;AACjE,SAAS,kBAAkB,CAAC,MAAuB,EAAE,MAAmB;IACpE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IACxB,IAAI,CAAC,CAAC,gBAAgB,KAAK,MAAM,EAAE,CAAC;QAChC,OAAO;IACX,CAAC;IACD,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC,CAAC,gBAAgB,GAAG,MAAM,CAAC;AAChC,CAAC","sourcesContent":["/**\n * Indexed meshes, dynamic vertex/index buffers, and hardware instancing.\n *\n * Part of the public API via the `@babylonjs/lite-gl` barrel. The package is\n * `sideEffects: false`, so consumers that only render the fullscreen quad /\n * sprites tree-shake the mesh code out.\n *\n * This is the lite-gl equivalent of Babylon's `ThinEngine.createVertexBuffer` /\n * `createIndexBuffer` / `_releaseBuffer` / `bindIndexBuffer` /\n * `bindInstancesBuffer` / `unbindInstanceAttributes` / `drawElementsType`. The\n * attribute binder reproduces Babylon's instancing semantics EXACTLY, including\n * the `computeStride = false → stride 0` \"sliding window\" used by ShapeBuilder's\n * tape buffers (consecutive instances read overlapping vec4 windows) and the\n * `divisor === undefined → 1` default.\n *\n * The mesh path runs on the DEFAULT (null) VAO — every buffer/attribute op binds\n * `gl.bindVertexArray(null)` first, so it never corrupts the quad / sprite VAOs.\n * Vertex and index buffers retain their CPU data and re-upload automatically on\n * `webglcontextrestored`.\n */\nimport type { GLEngineContext } from \"./context.js\";\nimport { onContextRestored, offContextRestored } from \"./context.js\";\nimport { getEffectAttributeLocation, type GLEffect } from \"./effect.js\";\nimport { applyGLStates } from \"./apply-states.js\";\n\n/** GL `gl.ARRAY_BUFFER`. */\nconst ARRAY_BUFFER = 0x8892;\n/** GL `gl.ELEMENT_ARRAY_BUFFER`. */\nconst ELEMENT_ARRAY_BUFFER = 0x8893;\n/** GL `gl.STATIC_DRAW`. */\nconst STATIC_DRAW = 0x88e4;\n/** GL `gl.DYNAMIC_DRAW`. */\nconst DYNAMIC_DRAW = 0x88e8;\n/** GL `gl.FLOAT`. */\nconst FLOAT = 0x1406;\n/** GL `gl.TRIANGLES`. */\nconst TRIANGLES = 0x0004;\n/** GL `gl.UNSIGNED_SHORT`. */\nconst UNSIGNED_SHORT = 0x1403;\n/** GL `gl.UNSIGNED_INT`. */\nconst UNSIGNED_INT = 0x1405;\n\n/** A GPU vertex buffer holding interleaved float vertex data. The lite-gl\n * counterpart of Babylon's `DataBuffer` for vertex data. */\nexport interface GLVertexBuffer {\n /** The live `WebGLBuffer`. Swapped on `webglcontextrestored`. */\n handle: WebGLBuffer;\n /** Size of the GL buffer in bytes. */\n byteLength: number;\n /** The engine that created (and owns) this buffer. Operations on it derive\n * their engine from here, so they take the buffer alone. @internal */\n _engine: GLEngineContext;\n /** @internal */\n _disposed: boolean;\n /** @internal Delete the underlying GL buffer. */\n _deleteGpu: (gl: WebGL2RenderingContext) => void;\n /** @internal Re-create + re-upload the retained CPU data into a fresh handle. */\n _restore: (engine: GLEngineContext) => void;\n /** @internal Retained CPU data for context-restore replay (the creation /\n * last full-buffer upload). */\n _data: Float32Array;\n /** @internal `true` for `DYNAMIC_DRAW` (updated via `updateVertexBuffer`). */\n _dynamic: boolean;\n}\n\n/** A GPU index buffer. The lite-gl counterpart of Babylon's `DataBuffer` for\n * index data. */\nexport interface GLIndexBuffer {\n /** The live `WebGLBuffer`. Swapped on `webglcontextrestored`. */\n handle: WebGLBuffer;\n /** Number of indices. */\n count: number;\n /** `true` for 32-bit (`Uint32Array`) indices, `false` for 16-bit. */\n is32Bits: boolean;\n /** The engine that created (and owns) this buffer. Operations on it derive\n * their engine from here, so they take the buffer alone. @internal */\n _engine: GLEngineContext;\n /** @internal */\n _disposed: boolean;\n /** @internal Delete the underlying GL buffer. */\n _deleteGpu: (gl: WebGL2RenderingContext) => void;\n /** @internal Re-create + re-upload the retained CPU data into a fresh handle. */\n _restore: (engine: GLEngineContext) => void;\n /** @internal Retained CPU data for context-restore replay. */\n _data: Uint16Array | Uint32Array;\n}\n\n/**\n * Describes one vertex attribute fed from a buffer — the lite-gl equivalent of\n * Babylon's `InstancingAttributeInfo`. Pass an array of these to\n * {@link bindAttributes}.\n */\nexport interface GLAttributeDescriptor {\n /** Attribute name; resolved to a location via the effect when `index` is\n * omitted (`Effect.getAttributeLocationByName`). */\n name?: string;\n /** Explicit attribute location. When set, overrides the `name` lookup. */\n index?: number;\n /** Number of components, 1–4. */\n size: number;\n /** Byte offset of this attribute's first element within the buffer. Default 0. */\n offset?: number;\n /**\n * Per-instance vertex divisor. **Omitted/`undefined` → `1` (instanced)**,\n * matching Babylon's `bindInstancesBuffer`. Pass `0` explicitly for a\n * per-vertex attribute (e.g. the base mesh position).\n */\n divisor?: number;\n /** GL component type. Default `gl.FLOAT`. */\n type?: GLenum;\n /** Normalize fixed-point integer data to `[0,1]`/`[-1,1]`. Default `false`. */\n normalized?: boolean;\n}\n\n/* ──────────────────────────────── buffers ──────────────────────────────── */\n\n/**\n * Create a GPU vertex buffer from interleaved float data.\n *\n * @param engine - The engine.\n * @param data - The vertex data. Retained by reference for context-restore — do\n * not mutate it in place; use {@link updateVertexBuffer} to change contents.\n * @param dynamic - Hint that the buffer will be updated frequently\n * (`DYNAMIC_DRAW`). Default `false` (`STATIC_DRAW`).\n * @returns The new {@link GLVertexBuffer}.\n */\nexport function createVertexBuffer(engine: GLEngineContext, data: Float32Array, dynamic = false): GLVertexBuffer {\n const gl = engine.gl;\n const handle = gl.createBuffer();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createBuffer returned null (vertex buffer)\");\n }\n const vb: GLVertexBuffer = {\n handle,\n byteLength: data.byteLength,\n _data: data,\n _dynamic: dynamic,\n _engine: engine,\n _disposed: false,\n _deleteGpu: () => {},\n _restore: () => {},\n };\n vb._deleteGpu = (g: WebGL2RenderingContext): void => {\n g.deleteBuffer(vb.handle);\n };\n vb._restore = (target: GLEngineContext): void => {\n const g = target.gl;\n const fresh = g.createBuffer();\n if (fresh === null) {\n return;\n }\n vb.handle = fresh;\n bindArrayBufferRaw(target, fresh);\n g.bufferData(ARRAY_BUFFER, vb._data, vb._dynamic ? DYNAMIC_DRAW : STATIC_DRAW);\n };\n bindArrayBufferRaw(engine, handle);\n gl.bufferData(ARRAY_BUFFER, data, dynamic ? DYNAMIC_DRAW : STATIC_DRAW);\n engine._buffers.push(vb);\n return vb;\n}\n\n/**\n * Upload new contents into (part of) a vertex buffer via `bufferSubData`. A\n * full-buffer update from offset 0 also refreshes the retained CPU data used\n * for context-restore.\n *\n * @param vb - The vertex buffer to update.\n * @param data - The new float data.\n * @param dstByteOffset - Destination byte offset within the buffer. Default 0.\n */\nexport function updateVertexBuffer(vb: GLVertexBuffer, data: Float32Array, dstByteOffset = 0): void {\n const engine = vb._engine;\n if (engine._isLost || engine._disposed || vb._disposed) {\n return;\n }\n bindArrayBufferRaw(engine, vb.handle);\n engine.gl.bufferSubData(ARRAY_BUFFER, dstByteOffset, data);\n if (dstByteOffset === 0 && data.byteLength >= vb.byteLength) {\n vb._data = data;\n vb.byteLength = data.byteLength;\n }\n}\n\n/**\n * Create a GPU index buffer. `Uint16Array` → 16-bit indices, `Uint32Array` →\n * 32-bit. Binds the default VAO first so it never corrupts the quad / sprite\n * VAO element bindings.\n *\n * @param engine - The engine.\n * @param data - The index data. Retained by reference for context-restore.\n * @returns The new {@link GLIndexBuffer}.\n */\nexport function createIndexBuffer(engine: GLEngineContext, data: Uint16Array | Uint32Array): GLIndexBuffer {\n const gl = engine.gl;\n const handle = gl.createBuffer();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createBuffer returned null (index buffer)\");\n }\n const is32 = data instanceof Uint32Array;\n const ib: GLIndexBuffer = {\n handle,\n count: data.length,\n is32Bits: is32,\n _data: data,\n _engine: engine,\n _disposed: false,\n _deleteGpu: () => {},\n _restore: () => {},\n };\n ib._deleteGpu = (g: WebGL2RenderingContext): void => {\n g.deleteBuffer(ib.handle);\n };\n ib._restore = (target: GLEngineContext): void => {\n const g = target.gl;\n const fresh = g.createBuffer();\n if (fresh === null) {\n return;\n }\n ib.handle = fresh;\n bindDefaultVao(target);\n g.bindBuffer(ELEMENT_ARRAY_BUFFER, fresh);\n target._state.boundElementBuffer = fresh;\n g.bufferData(ELEMENT_ARRAY_BUFFER, ib._data, STATIC_DRAW);\n };\n bindDefaultVao(engine);\n gl.bindBuffer(ELEMENT_ARRAY_BUFFER, handle);\n engine._state.boundElementBuffer = handle;\n gl.bufferData(ELEMENT_ARRAY_BUFFER, data, STATIC_DRAW);\n engine._buffers.push(ib);\n return ib;\n}\n\n/** Dispose a vertex or index buffer (delete the GL buffer + unregister). Clears\n * the array/element-buffer cache slot if it pointed at this buffer. Idempotent. */\nexport function disposeBuffer(buffer: GLVertexBuffer | GLIndexBuffer): void {\n const engine = buffer._engine;\n if (buffer._disposed) {\n return;\n }\n buffer._disposed = true;\n const i = engine._buffers.indexOf(buffer);\n if (i !== -1) {\n engine._buffers.splice(i, 1);\n }\n const s = engine._state;\n if (!engine._isLost && !engine._disposed) {\n engine.gl.deleteBuffer(buffer.handle);\n }\n if (s.boundArrayBuffer === buffer.handle) {\n s.boundArrayBuffer = null;\n }\n if (s.boundElementBuffer === buffer.handle) {\n s.boundElementBuffer = null;\n }\n}\n\n/* ────────────────────────────── binding + draw ──────────────────────────── */\n\n/**\n * Bind an index buffer as the current element-array buffer (on the default\n * VAO). Cached. The lite-gl equivalent of Babylon's `_bindIndexBufferWithCache`.\n *\n * @param ib - The index buffer to bind.\n */\nexport function bindIndexBuffer(ib: GLIndexBuffer): void {\n const engine = ib._engine;\n if (engine._isLost || engine._disposed || ib._disposed) {\n return;\n }\n bindDefaultVao(engine);\n const s = engine._state;\n if (s.boundElementBuffer === ib.handle) {\n return;\n }\n engine.gl.bindBuffer(ELEMENT_ARRAY_BUFFER, ib.handle);\n s.boundElementBuffer = ib.handle;\n}\n\n/**\n * Configure vertex attributes from `vb`, reproducing Babylon's\n * `bindInstancesBuffer` exactly. For each descriptor: resolves the location\n * (explicit `index` or via the effect), enables the attribute array, issues\n * `vertexAttribPointer`, and sets the vertex divisor (`undefined → 1`). Each\n * instanced location (divisor ≠ 0) is tracked once so {@link unbindInstanceAttributes}\n * can reset its divisor afterwards; per-vertex locations already have divisor 0 and are\n * not tracked, so callers that never instance can rebind every frame without growth.\n *\n * `computeStride` controls the GL stride passed to `vertexAttribPointer`:\n * - `false` (default) → stride `0`: each attribute is independently tightly\n * packed. Combined with overlapping `offset`s this yields the \"sliding window\"\n * ShapeBuilder uses for distance-field tape buffers.\n * - `true` → stride = Σ(`size`·4 bytes): interleaved per-vertex/per-instance.\n *\n * Runs on the default (null) VAO — never corrupts the quad / sprite VAOs.\n * No-op on a lost/disposed context or before the effect is ready.\n *\n * @param vb - The buffer supplying the attribute data.\n * @param descriptors - The attribute layout.\n * @param effect - The effect whose attribute locations resolve unnamed indices.\n * @param computeStride - See above. Default `false`.\n */\nexport function bindAttributes(vb: GLVertexBuffer, descriptors: readonly GLAttributeDescriptor[], effect: GLEffect, computeStride = false): void {\n const engine = vb._engine;\n if (engine._isLost || engine._disposed || vb._disposed || !effect.isReady) {\n return;\n }\n const gl = engine.gl;\n const s = engine._state;\n bindDefaultVao(engine);\n bindArrayBufferRaw(engine, vb.handle);\n\n let stride = 0;\n if (computeStride) {\n for (let i = 0; i < descriptors.length; i++) {\n stride += (descriptors[i] as GLAttributeDescriptor).size * 4;\n }\n }\n\n for (let i = 0; i < descriptors.length; i++) {\n const d = descriptors[i] as GLAttributeDescriptor;\n const loc = d.index !== undefined ? d.index : d.name !== undefined ? getEffectAttributeLocation(effect, d.name) : -1;\n if (loc < 0) {\n continue;\n }\n if (!s.enabledAttribs[loc]) {\n gl.enableVertexAttribArray(loc);\n s.enabledAttribs[loc] = true;\n }\n gl.vertexAttribPointer(loc, d.size, d.type ?? FLOAT, d.normalized ?? false, stride, d.offset ?? 0);\n const divisor = d.divisor ?? 1;\n gl.vertexAttribDivisor(loc, divisor);\n if (divisor !== 0 && !s.instanceLocations.includes(loc)) {\n s.instanceLocations.push(loc);\n }\n }\n}\n\n/**\n * Reset the vertex divisor of every attribute touched by {@link bindAttributes}\n * back to 0 — the lite-gl equivalent of Babylon's `unbindInstanceAttributes`.\n * Call after an instanced draw so a following non-instanced draw is not skewed.\n * No-op on a lost/disposed context.\n *\n * @param engine - The engine.\n */\nexport function unbindInstanceAttributes(engine: GLEngineContext): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n const gl = engine.gl;\n const locs = engine._state.instanceLocations;\n for (let i = 0; i < locs.length; i++) {\n gl.vertexAttribDivisor(locs[i] as number, 0);\n }\n locs.length = 0;\n}\n\n/**\n * Draw indexed triangles from `ib` — the lite-gl equivalent of Babylon's\n * `drawElementsType` (triangle fill mode). When `instanceCount > 0` issues\n * `drawElementsInstanced`, otherwise `drawElements`. No-op on a lost/disposed\n * context or when no program is current.\n *\n * @param ib - The index buffer (also bound as a side-effect, cached).\n * @param indexCount - Number of indices to draw.\n * @param indexStart - First index offset (in indices, not bytes). Default 0.\n * @param instanceCount - Instance count for instanced draws. Default 0\n * (non-instanced).\n */\nexport function drawIndexed(ib: GLIndexBuffer, indexCount: number, indexStart = 0, instanceCount = 0): void {\n const engine = ib._engine;\n if (engine._isLost || engine._disposed || ib._disposed) {\n return;\n }\n if (engine._state.currentProgram === null) {\n return;\n }\n bindIndexBuffer(ib);\n const gl = engine.gl;\n const type = ib.is32Bits ? UNSIGNED_INT : UNSIGNED_SHORT;\n const byteOffset = indexStart * (ib.is32Bits ? 4 : 2);\n applyGLStates(engine);\n if (instanceCount > 0) {\n gl.drawElementsInstanced(TRIANGLES, indexCount, type, byteOffset, instanceCount);\n } else {\n gl.drawElements(TRIANGLES, indexCount, type, byteOffset);\n }\n}\n\n/* ────────────────────────── static mesh VAO ─────────────────────────────\n * The VAO-cached counterpart of the manual `bindAttributes` path above — Babylon's\n * `recordVertexArrayObject` / `_cachedVertexArrayObject` for STATIC meshes. A\n * `GLMeshVao` records the whole attribute layout (enable + pointer + divisor for\n * every attribute, across one or more vertex buffers) AND the index binding into a\n * single VAO ONCE. The per-frame draw is then just `bindVertexArray` +\n * `drawElements[Instanced]` — zero per-draw `vertexAttribPointer`/`vertexAttribDivisor`,\n * and no `unbindInstanceAttributes` (the VAO isolates the divisors from the default\n * VAO). Use this for fixed-layout meshes; keep `bindAttributes` for dynamic layouts\n * (e.g. ShapeBuilder's per-draw sliding-window tape buffers). */\n\n/** One vertex buffer + its attribute layout, for {@link createMeshVao}. */\nexport interface GLMeshVertexBuffer {\n /** The buffer supplying this group's attributes. */\n buffer: GLVertexBuffer;\n /** The attributes read from `buffer` (same shape as {@link bindAttributes}). */\n attributes: readonly GLAttributeDescriptor[];\n /** Stride mode (see {@link bindAttributes}): `false` (default) → stride `0`\n * per attribute; `true` → interleaved stride = Σ(`size`·4). */\n computeStride?: boolean;\n}\n\n/** A recorded Vertex Array Object capturing a static mesh's attribute layout +\n * index binding. Bind + draw it with {@link drawMesh} each frame — the GPU\n * replays the entire attribute setup from one `bindVertexArray`. Re-recorded\n * automatically on `webglcontextrestored`. */\nexport interface GLMeshVao {\n /** The live `WebGLVertexArrayObject`. Swapped on `webglcontextrestored`. */\n handle: WebGLVertexArrayObject;\n /** The engine that created (and owns) this VAO. Operations on it derive\n * their engine from here, so they take the VAO alone. @internal */\n _engine: GLEngineContext;\n /** @internal */\n _disposed: boolean;\n /** @internal The index buffer recorded into the VAO. */\n _indexBuffer: GLIndexBuffer;\n /** @internal Resolved attribute bindings, reused to re-record on restore. */\n _bindings: _ResolvedBinding[];\n /** @internal `webglcontextrestored` re-record hook. */\n _restore: () => void;\n}\n\n/** @internal A single attribute with its location resolved once at record time\n * (locations are stable across re-link via `bindAttribLocation`, so the VAO can\n * re-record on context-restore without the effect). */\ninterface _ResolvedAttr {\n loc: number;\n size: number;\n type: number;\n normalized: boolean;\n stride: number;\n offset: number;\n divisor: number;\n}\n\n/** @internal A vertex buffer + its resolved attributes. */\ninterface _ResolvedBinding {\n buffer: GLVertexBuffer;\n attrs: _ResolvedAttr[];\n}\n\n/**\n * Record a static mesh's attribute layout + index binding into a new VAO. The\n * effect MUST be ready (its attribute locations are resolved here, once). Returns\n * a {@link GLMeshVao} to draw with {@link drawMesh}.\n *\n * @param engine - The engine.\n * @param vertexBuffers - One or more buffers + their attribute layouts.\n * @param indexBuffer - The index buffer recorded into the VAO.\n * @param effect - The effect whose attribute locations resolve unnamed indices.\n * @returns The recorded {@link GLMeshVao}.\n */\nexport function createMeshVao(engine: GLEngineContext, vertexBuffers: readonly GLMeshVertexBuffer[], indexBuffer: GLIndexBuffer, effect: GLEffect): GLMeshVao {\n const gl = engine.gl;\n // The effect's attribute locations are resolved (once) below; an unready effect\n // would resolve every name to -1 → a silently-empty VAO. Fail fast — callers\n // must gate on isEffectReady (see scene10's first-ready-frame creation).\n if (!effect.isReady) {\n throw new Error(\"lite-gl: createMeshVao requires a ready effect (poll isEffectReady first)\");\n }\n const handle = gl.createVertexArray();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createVertexArray returned null (mesh VAO)\");\n }\n // Resolve every attribute location ONCE (stable across re-link), so a restore\n // re-record needs only the buffer handles, not the effect.\n const bindings: _ResolvedBinding[] = [];\n for (const vbb of vertexBuffers) {\n let stride = 0;\n if (vbb.computeStride) {\n for (let i = 0; i < vbb.attributes.length; i++) {\n stride += (vbb.attributes[i] as GLAttributeDescriptor).size * 4;\n }\n }\n const attrs: _ResolvedAttr[] = [];\n for (let i = 0; i < vbb.attributes.length; i++) {\n const d = vbb.attributes[i] as GLAttributeDescriptor;\n const loc = d.index !== undefined ? d.index : d.name !== undefined ? getEffectAttributeLocation(effect, d.name) : -1;\n if (loc < 0) {\n continue;\n }\n attrs.push({\n loc,\n size: d.size,\n type: d.type ?? FLOAT,\n normalized: d.normalized ?? false,\n stride,\n offset: d.offset ?? 0,\n divisor: d.divisor === undefined ? 1 : d.divisor,\n });\n }\n bindings.push({ buffer: vbb.buffer, attrs });\n }\n const vao: GLMeshVao = { handle, _engine: engine, _disposed: false, _indexBuffer: indexBuffer, _bindings: bindings, _restore: () => {} };\n vao._restore = (): void => {\n if (engine._isLost || engine._disposed || vao._disposed) {\n return;\n }\n const fresh = engine.gl.createVertexArray();\n if (fresh === null) {\n return;\n }\n vao.handle = fresh;\n recordMeshVao(engine, vao);\n };\n recordMeshVao(engine, vao);\n onContextRestored(engine, vao._restore);\n return vao;\n}\n\n/**\n * Bind a {@link GLMeshVao} (cached `gl.bindVertexArray`). Rarely called directly —\n * {@link drawMesh} binds it for you. Binding restores the VAO's recorded element\n * binding, so the element-buffer cache is updated in lock-step.\n *\n * @param vao - The mesh VAO to bind.\n */\nexport function bindMeshVao(vao: GLMeshVao): void {\n const engine = vao._engine;\n if (engine._isLost || engine._disposed || vao._disposed) {\n return;\n }\n const s = engine._state;\n if (s.boundVao === vao.handle) {\n return;\n }\n engine.gl.bindVertexArray(vao.handle);\n s.boundVao = vao.handle;\n s.boundElementBuffer = vao._indexBuffer.handle;\n}\n\n/**\n * Draw a static mesh recorded with {@link createMeshVao}: binds its VAO (cached),\n * flushes deferred GL state, and issues ONE `drawElements` (or\n * `drawElementsInstanced` when `instanceCount > 0`) over the VAO's full index\n * buffer. No per-draw attribute (re)binding. No-op on a lost/disposed context, a\n * disposed VAO, or when no program is current.\n *\n * @param vao - The mesh VAO to draw.\n * @param instanceCount - Instance count for instanced draws. Default 0 (non-instanced).\n */\nexport function drawMesh(vao: GLMeshVao, instanceCount = 0): void {\n const engine = vao._engine;\n if (engine._isLost || engine._disposed || vao._disposed) {\n return;\n }\n if (engine._state.currentProgram === null) {\n return;\n }\n bindMeshVao(vao);\n applyGLStates(engine);\n const ib = vao._indexBuffer;\n const gl = engine.gl;\n const type = ib.is32Bits ? UNSIGNED_INT : UNSIGNED_SHORT;\n if (instanceCount > 0) {\n gl.drawElementsInstanced(TRIANGLES, ib.count, type, 0, instanceCount);\n } else {\n gl.drawElements(TRIANGLES, ib.count, type, 0);\n }\n}\n\n/** Dispose a {@link GLMeshVao}: delete the VAO and unregister its restore hook.\n * Does NOT dispose the vertex/index buffers (the caller owns those). Idempotent. */\nexport function disposeMeshVao(vao: GLMeshVao): void {\n const engine = vao._engine;\n if (vao._disposed) {\n return;\n }\n vao._disposed = true;\n offContextRestored(engine, vao._restore);\n if (!engine._isLost && !engine._disposed) {\n const s = engine._state;\n engine.gl.deleteVertexArray(vao.handle);\n if (s.boundVao === vao.handle) {\n // Return to the default VAO so the cache stays coherent.\n engine.gl.bindVertexArray(null);\n s.boundVao = null;\n s.boundElementBuffer = null;\n }\n }\n}\n\n/** @internal Record `vao._bindings` + the index binding into `vao.handle`. Leaves\n * the default (null) VAO bound afterwards (so the mesh VAO is not left current),\n * forgetting the element-buffer cache. Touches neither `s.enabledAttribs` (those\n * track the DEFAULT VAO) nor the divisor reset — all of that lives in the VAO. */\nfunction recordMeshVao(engine: GLEngineContext, vao: GLMeshVao): void {\n const gl = engine.gl;\n const s = engine._state;\n gl.bindVertexArray(vao.handle);\n s.boundVao = vao.handle;\n for (const b of vao._bindings) {\n bindArrayBufferRaw(engine, b.buffer.handle);\n for (const a of b.attrs) {\n gl.enableVertexAttribArray(a.loc);\n gl.vertexAttribPointer(a.loc, a.size, a.type, a.normalized, a.stride, a.offset);\n gl.vertexAttribDivisor(a.loc, a.divisor);\n }\n }\n gl.bindBuffer(ELEMENT_ARRAY_BUFFER, vao._indexBuffer.handle);\n gl.bindVertexArray(null);\n s.boundVao = null;\n s.boundElementBuffer = null;\n}\n\n/* ──────────────────────────── internal helpers ──────────────────────────── */\n\n/** Bind the default (null) VAO if not already bound. The mesh path lives here so\n * it never disturbs the quad / sprite VAO state. Binding a VAO restores ITS\n * element-array binding, so the element-buffer cache is forgotten on the\n * switch (the next `bindIndexBuffer` re-binds). */\nfunction bindDefaultVao(engine: GLEngineContext): void {\n const s = engine._state;\n if (s.boundVao !== null) {\n engine.gl.bindVertexArray(null);\n s.boundVao = null;\n s.boundElementBuffer = null;\n }\n}\n\n/** Cached `gl.bindBuffer(ARRAY_BUFFER, …)`. ARRAY_BUFFER binding is global (not\n * VAO state), so this cache is coherent across VAO switches. */\nfunction bindArrayBufferRaw(engine: GLEngineContext, handle: WebGLBuffer): void {\n const s = engine._state;\n if (s.boundArrayBuffer === handle) {\n return;\n }\n engine.gl.bindBuffer(ARRAY_BUFFER, handle);\n s.boundArrayBuffer = handle;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mesh.js","sourceRoot":"","sources":["../src/mesh.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAiB,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,4BAA4B;AAC5B,MAAM,YAAY,GAAG,MAAM,CAAC;AAC5B,oCAAoC;AACpC,MAAM,oBAAoB,GAAG,MAAM,CAAC;AACpC,2BAA2B;AAC3B,MAAM,WAAW,GAAG,MAAM,CAAC;AAC3B,4BAA4B;AAC5B,MAAM,YAAY,GAAG,MAAM,CAAC;AAC5B,qBAAqB;AACrB,MAAM,KAAK,GAAG,MAAM,CAAC;AACrB,yBAAyB;AACzB,MAAM,SAAS,GAAG,MAAM,CAAC;AACzB,8BAA8B;AAC9B,MAAM,cAAc,GAAG,MAAM,CAAC;AAC9B,4BAA4B;AAC5B,MAAM,YAAY,GAAG,MAAM,CAAC;AA0E5B,iFAAiF;AAEjF;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAuB,EAAE,IAAkB,EAAE,OAAO,GAAG,KAAK;IAC3F,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;IACrB,MAAM,MAAM,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC;IACjC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAClB,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pD,SAAS,cAAc,CAAC,MAAuB;IAC3C,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IACxB,IAAI,CAAC,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,MAAM,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC;QAClB,CAAC,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAChC,CAAC;AACL,CAAC;AAED;iEACiE;AACjE,SAAS,kBAAkB,CAAC,MAAuB,EAAE,MAAmB;IACpE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IACxB,IAAI,CAAC,CAAC,gBAAgB,KAAK,MAAM,EAAE,CAAC;QAChC,OAAO;IACX,CAAC;IACD,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC,CAAC,gBAAgB,GAAG,MAAM,CAAC;AAChC,CAAC","sourcesContent":["/**\n * Indexed meshes, dynamic vertex/index buffers, and hardware instancing.\n *\n * Part of the public API via the `@babylonjs/lite-gl` barrel. The package is\n * `sideEffects: false`, so consumers that only render the fullscreen quad /\n * sprites tree-shake the mesh code out.\n *\n * This is the lite-gl equivalent of Babylon's `ThinEngine.createVertexBuffer` /\n * `createIndexBuffer` / `_releaseBuffer` / `bindIndexBuffer` /\n * `bindInstancesBuffer` / `unbindInstanceAttributes` / `drawElementsType`. The\n * attribute binder reproduces Babylon's instancing semantics EXACTLY, including\n * the `computeStride = false → stride 0` \"sliding window\" used by ShapeBuilder's\n * tape buffers (consecutive instances read overlapping vec4 windows) and the\n * `divisor === undefined → 1` default.\n *\n * The mesh path runs on the DEFAULT (null) VAO — every buffer/attribute op binds\n * `gl.bindVertexArray(null)` first, so it never corrupts the quad / sprite VAOs.\n * Vertex and index buffers retain their CPU data and re-upload automatically on\n * `webglcontextrestored`.\n */\nimport type { GLEngineContext } from \"./context.js\";\nimport { onContextRestored, offContextRestored } from \"./context.js\";\nimport { getEffectAttributeLocation, type GLEffect } from \"./effect.js\";\nimport { applyGLStates } from \"./apply-states.js\";\n\n/** GL `gl.ARRAY_BUFFER`. */\nconst ARRAY_BUFFER = 0x8892;\n/** GL `gl.ELEMENT_ARRAY_BUFFER`. */\nconst ELEMENT_ARRAY_BUFFER = 0x8893;\n/** GL `gl.STATIC_DRAW`. */\nconst STATIC_DRAW = 0x88e4;\n/** GL `gl.DYNAMIC_DRAW`. */\nconst DYNAMIC_DRAW = 0x88e8;\n/** GL `gl.FLOAT`. */\nconst FLOAT = 0x1406;\n/** GL `gl.TRIANGLES`. */\nconst TRIANGLES = 0x0004;\n/** GL `gl.UNSIGNED_SHORT`. */\nconst UNSIGNED_SHORT = 0x1403;\n/** GL `gl.UNSIGNED_INT`. */\nconst UNSIGNED_INT = 0x1405;\n\n/** A GPU vertex buffer holding interleaved float vertex data. The lite-gl\n * counterpart of Babylon's `DataBuffer` for vertex data. */\nexport interface GLVertexBuffer {\n /** The live `WebGLBuffer`. Swapped on `webglcontextrestored`. */\n handle: WebGLBuffer;\n /** Size of the GL buffer in bytes. */\n byteLength: number;\n /** The engine that created (and owns) this buffer. Operations on it derive\n * their engine from here, so they take the buffer alone. @internal */\n _engine: GLEngineContext;\n /** @internal */\n _disposed: boolean;\n /** @internal Delete the underlying GL buffer. */\n _deleteGpu: (gl: WebGL2RenderingContext) => void;\n /** @internal Re-create + re-upload the retained CPU data into a fresh handle. */\n _restore: (engine: GLEngineContext) => void;\n /** @internal Retained CPU data for context-restore replay (the creation /\n * last full-buffer upload). */\n _data: Float32Array;\n /** @internal `true` for `DYNAMIC_DRAW` (updated via `updateVertexBuffer`). */\n _dynamic: boolean;\n}\n\n/** A GPU index buffer. The lite-gl counterpart of Babylon's `DataBuffer` for\n * index data. */\nexport interface GLIndexBuffer {\n /** The live `WebGLBuffer`. Swapped on `webglcontextrestored`. */\n handle: WebGLBuffer;\n /** Number of indices. */\n count: number;\n /** `true` for 32-bit (`Uint32Array`) indices, `false` for 16-bit. */\n is32Bits: boolean;\n /** The engine that created (and owns) this buffer. Operations on it derive\n * their engine from here, so they take the buffer alone. @internal */\n _engine: GLEngineContext;\n /** @internal */\n _disposed: boolean;\n /** @internal Delete the underlying GL buffer. */\n _deleteGpu: (gl: WebGL2RenderingContext) => void;\n /** @internal Re-create + re-upload the retained CPU data into a fresh handle. */\n _restore: (engine: GLEngineContext) => void;\n /** @internal Retained CPU data for context-restore replay. */\n _data: Uint16Array | Uint32Array;\n}\n\n/**\n * Describes one vertex attribute fed from a buffer — the lite-gl equivalent of\n * Babylon's `InstancingAttributeInfo`. Pass an array of these to\n * {@link bindAttributes}.\n */\nexport interface GLAttributeDescriptor {\n /** Attribute name; resolved to a location via the effect when `index` is\n * omitted (`Effect.getAttributeLocationByName`). */\n name?: string;\n /** Explicit attribute location. When set, overrides the `name` lookup. */\n index?: number;\n /** Number of components, 1–4. */\n size: number;\n /** Byte offset of this attribute's first element within the buffer. Default 0. */\n offset?: number;\n /**\n * Per-instance vertex divisor. **Omitted/`undefined` → `1` (instanced)**,\n * matching Babylon's `bindInstancesBuffer`. Pass `0` explicitly for a\n * per-vertex attribute (e.g. the base mesh position).\n */\n divisor?: number;\n /** GL component type. Default `gl.FLOAT`. */\n type?: GLenum;\n /** Normalize fixed-point integer data to `[0,1]`/`[-1,1]`. Default `false`. */\n normalized?: boolean;\n}\n\n/* ──────────────────────────────── buffers ──────────────────────────────── */\n\n/**\n * Create a GPU vertex buffer from interleaved float data.\n *\n * @param engine - The engine.\n * @param data - The vertex data. Retained by reference for context-restore — do\n * not mutate it in place; use {@link updateVertexBuffer} to change contents.\n * @param dynamic - Hint that the buffer will be updated frequently\n * (`DYNAMIC_DRAW`). Default `false` (`STATIC_DRAW`).\n * @returns The new {@link GLVertexBuffer}.\n */\nexport function createVertexBuffer(engine: GLEngineContext, data: Float32Array, dynamic = false): GLVertexBuffer {\n const gl = engine.gl;\n const handle = gl.createBuffer();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createBuffer returned null (vertex buffer)\");\n }\n const vb: GLVertexBuffer = {\n handle,\n byteLength: data.byteLength,\n _data: data,\n _dynamic: dynamic,\n _engine: engine,\n _disposed: false,\n _deleteGpu: () => {},\n _restore: () => {},\n };\n vb._deleteGpu = (g: WebGL2RenderingContext): void => {\n g.deleteBuffer(vb.handle);\n };\n vb._restore = (target: GLEngineContext): void => {\n const g = target.gl;\n const fresh = g.createBuffer();\n if (fresh === null) {\n return;\n }\n vb.handle = fresh;\n bindArrayBufferRaw(target, fresh);\n g.bufferData(ARRAY_BUFFER, vb._data, vb._dynamic ? DYNAMIC_DRAW : STATIC_DRAW);\n };\n bindArrayBufferRaw(engine, handle);\n gl.bufferData(ARRAY_BUFFER, data, dynamic ? DYNAMIC_DRAW : STATIC_DRAW);\n engine._buffers.push(vb);\n return vb;\n}\n\n/**\n * Upload new contents into (part of) a vertex buffer via `bufferSubData`. A\n * full-buffer update from offset 0 also refreshes the retained CPU data used\n * for context-restore.\n *\n * @param vb - The vertex buffer to update.\n * @param data - The new float data.\n * @param dstByteOffset - Destination byte offset within the buffer. Default 0.\n */\nexport function updateVertexBuffer(vb: GLVertexBuffer, data: Float32Array, dstByteOffset = 0): void {\n const engine = vb._engine;\n if (engine._isLost || engine._disposed || vb._disposed) {\n return;\n }\n bindArrayBufferRaw(engine, vb.handle);\n engine.gl.bufferSubData(ARRAY_BUFFER, dstByteOffset, data);\n if (dstByteOffset === 0 && data.byteLength >= vb.byteLength) {\n vb._data = data;\n vb.byteLength = data.byteLength;\n }\n}\n\n/**\n * Create a GPU index buffer. `Uint16Array` → 16-bit indices, `Uint32Array` →\n * 32-bit. Binds the default VAO first so it never corrupts the quad / sprite\n * VAO element bindings.\n *\n * @param engine - The engine.\n * @param data - The index data. Retained by reference for context-restore.\n * @returns The new {@link GLIndexBuffer}.\n */\nexport function createIndexBuffer(engine: GLEngineContext, data: Uint16Array | Uint32Array): GLIndexBuffer {\n const gl = engine.gl;\n const handle = gl.createBuffer();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createBuffer returned null (index buffer)\");\n }\n const is32 = data instanceof Uint32Array;\n const ib: GLIndexBuffer = {\n handle,\n count: data.length,\n is32Bits: is32,\n _data: data,\n _engine: engine,\n _disposed: false,\n _deleteGpu: () => {},\n _restore: () => {},\n };\n ib._deleteGpu = (g: WebGL2RenderingContext): void => {\n g.deleteBuffer(ib.handle);\n };\n ib._restore = (target: GLEngineContext): void => {\n const g = target.gl;\n const fresh = g.createBuffer();\n if (fresh === null) {\n return;\n }\n ib.handle = fresh;\n bindDefaultVao(target);\n g.bindBuffer(ELEMENT_ARRAY_BUFFER, fresh);\n target._state.boundElementBuffer = fresh;\n g.bufferData(ELEMENT_ARRAY_BUFFER, ib._data, STATIC_DRAW);\n };\n bindDefaultVao(engine);\n gl.bindBuffer(ELEMENT_ARRAY_BUFFER, handle);\n engine._state.boundElementBuffer = handle;\n gl.bufferData(ELEMENT_ARRAY_BUFFER, data, STATIC_DRAW);\n engine._buffers.push(ib);\n return ib;\n}\n\n/** Dispose a vertex or index buffer (delete the GL buffer + unregister). Clears\n * the array/element-buffer cache slot if it pointed at this buffer. Idempotent. */\nexport function disposeBuffer(buffer: GLVertexBuffer | GLIndexBuffer): void {\n const engine = buffer._engine;\n if (buffer._disposed) {\n return;\n }\n buffer._disposed = true;\n const i = engine._buffers.indexOf(buffer);\n if (i !== -1) {\n engine._buffers.splice(i, 1);\n }\n const s = engine._state;\n if (!engine._isLost && !engine._disposed) {\n engine.gl.deleteBuffer(buffer.handle);\n }\n if (s.boundArrayBuffer === buffer.handle) {\n s.boundArrayBuffer = null;\n }\n if (s.boundElementBuffer === buffer.handle) {\n s.boundElementBuffer = null;\n }\n}\n\n/* ────────────────────────────── binding + draw ──────────────────────────── */\n\n/**\n * Bind an index buffer as the current element-array buffer (on the default\n * VAO). Cached. The lite-gl equivalent of Babylon's `_bindIndexBufferWithCache`.\n *\n * @param ib - The index buffer to bind.\n */\nexport function bindIndexBuffer(ib: GLIndexBuffer): void {\n const engine = ib._engine;\n if (engine._isLost || engine._disposed || ib._disposed) {\n return;\n }\n bindDefaultVao(engine);\n const s = engine._state;\n if (s.boundElementBuffer === ib.handle) {\n return;\n }\n engine.gl.bindBuffer(ELEMENT_ARRAY_BUFFER, ib.handle);\n s.boundElementBuffer = ib.handle;\n}\n\n/**\n * Configure vertex attributes from `vb`, reproducing Babylon's\n * `bindInstancesBuffer` exactly. For each descriptor: resolves the location\n * (explicit `index` or via the effect), enables the attribute array, issues\n * `vertexAttribPointer`, and sets the vertex divisor (`undefined → 1`). Each\n * instanced location (divisor ≠ 0) is tracked once so {@link unbindInstanceAttributes}\n * can reset its divisor afterwards; per-vertex locations already have divisor 0 and are\n * not tracked, so callers that never instance can rebind every frame without growth.\n *\n * `computeStride` controls the GL stride passed to `vertexAttribPointer`:\n * - `false` (default) → stride `0`: each attribute is independently tightly\n * packed. Combined with overlapping `offset`s this yields the \"sliding window\"\n * ShapeBuilder uses for distance-field tape buffers.\n * - `true` → stride = Σ(`size`·4 bytes): interleaved per-vertex/per-instance.\n *\n * Runs on the default (null) VAO — never corrupts the quad / sprite VAOs.\n * No-op on a lost/disposed context or before the effect is ready.\n *\n * @param vb - The buffer supplying the attribute data.\n * @param descriptors - The attribute layout.\n * @param effect - The effect whose attribute locations resolve unnamed indices.\n * @param computeStride - See above. Default `false`.\n */\nexport function bindAttributes(vb: GLVertexBuffer, descriptors: readonly GLAttributeDescriptor[], effect: GLEffect, computeStride = false): void {\n const engine = vb._engine;\n if (engine._isLost || engine._disposed || vb._disposed || !effect.isReady) {\n return;\n }\n const gl = engine.gl;\n const s = engine._state;\n bindDefaultVao(engine);\n bindArrayBufferRaw(engine, vb.handle);\n\n let stride = 0;\n if (computeStride) {\n for (let i = 0; i < descriptors.length; i++) {\n stride += (descriptors[i] as GLAttributeDescriptor).size * 4;\n }\n }\n\n for (let i = 0; i < descriptors.length; i++) {\n const d = descriptors[i] as GLAttributeDescriptor;\n const loc = d.index !== undefined ? d.index : d.name !== undefined ? getEffectAttributeLocation(effect, d.name) : -1;\n if (loc < 0) {\n continue;\n }\n if (!s.enabledAttribs[loc]) {\n gl.enableVertexAttribArray(loc);\n s.enabledAttribs[loc] = true;\n }\n gl.vertexAttribPointer(loc, d.size, d.type ?? FLOAT, d.normalized ?? false, stride, d.offset ?? 0);\n const divisor = d.divisor ?? 1;\n gl.vertexAttribDivisor(loc, divisor);\n if (divisor !== 0 && !s.instanceLocations.includes(loc)) {\n s.instanceLocations.push(loc);\n }\n }\n}\n\n/**\n * Reset the vertex divisor of every attribute touched by {@link bindAttributes}\n * back to 0 — the lite-gl equivalent of Babylon's `unbindInstanceAttributes`.\n * Call after an instanced draw so a following non-instanced draw is not skewed.\n * No-op on a lost/disposed context.\n *\n * @param engine - The engine.\n */\nexport function unbindInstanceAttributes(engine: GLEngineContext): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n const gl = engine.gl;\n const locs = engine._state.instanceLocations;\n for (let i = 0; i < locs.length; i++) {\n gl.vertexAttribDivisor(locs[i] as number, 0);\n }\n locs.length = 0;\n}\n\n/**\n * Draw indexed triangles from `ib` — the lite-gl equivalent of Babylon's\n * `drawElementsType` (triangle fill mode). When `instanceCount > 0` issues\n * `drawElementsInstanced`, otherwise `drawElements`. No-op on a lost/disposed\n * context or when no program is current.\n *\n * @param ib - The index buffer (also bound as a side-effect, cached).\n * @param indexCount - Number of indices to draw.\n * @param indexStart - First index offset (in indices, not bytes). Default 0.\n * @param instanceCount - Instance count for instanced draws. Default 0\n * (non-instanced).\n */\nexport function drawIndexed(ib: GLIndexBuffer, indexCount: number, indexStart = 0, instanceCount = 0): void {\n const engine = ib._engine;\n if (engine._isLost || engine._disposed || ib._disposed) {\n return;\n }\n if (engine._state.currentProgram === null) {\n return;\n }\n bindIndexBuffer(ib);\n const gl = engine.gl;\n const type = ib.is32Bits ? UNSIGNED_INT : UNSIGNED_SHORT;\n const byteOffset = indexStart * (ib.is32Bits ? 4 : 2);\n applyGLStates(engine);\n if (instanceCount > 0) {\n gl.drawElementsInstanced(TRIANGLES, indexCount, type, byteOffset, instanceCount);\n } else {\n gl.drawElements(TRIANGLES, indexCount, type, byteOffset);\n }\n}\n\n/* ────────────────────────── static mesh VAO ─────────────────────────────\n * The VAO-cached counterpart of the manual `bindAttributes` path above — Babylon's\n * `recordVertexArrayObject` / `_cachedVertexArrayObject` for STATIC meshes. A\n * `GLMeshVao` records the whole attribute layout (enable + pointer + divisor for\n * every attribute, across one or more vertex buffers) AND the index binding into a\n * single VAO ONCE. The per-frame draw is then just `bindVertexArray` +\n * `drawElements[Instanced]` — zero per-draw `vertexAttribPointer`/`vertexAttribDivisor`,\n * and no `unbindInstanceAttributes` (the VAO isolates the divisors from the default\n * VAO). Use this for fixed-layout meshes; keep `bindAttributes` for dynamic layouts\n * (e.g. ShapeBuilder's per-draw sliding-window tape buffers). */\n\n/** One vertex buffer + its attribute layout, for {@link createMeshVao}. */\nexport interface GLMeshVertexBuffer {\n /** The buffer supplying this group's attributes. */\n buffer: GLVertexBuffer;\n /** The attributes read from `buffer` (same shape as {@link bindAttributes}). */\n attributes: readonly GLAttributeDescriptor[];\n /** Stride mode (see {@link bindAttributes}): `false` (default) → stride `0`\n * per attribute; `true` → interleaved stride = Σ(`size`·4). */\n computeStride?: boolean;\n}\n\n/** A recorded Vertex Array Object capturing a static mesh's attribute layout +\n * index binding. Bind + draw it with {@link drawMesh} each frame — the GPU\n * replays the entire attribute setup from one `bindVertexArray`. Re-recorded\n * automatically on `webglcontextrestored`. */\nexport interface GLMeshVao {\n /** The live `WebGLVertexArrayObject`. Swapped on `webglcontextrestored`. */\n handle: WebGLVertexArrayObject;\n /** The engine that created (and owns) this VAO. Operations on it derive\n * their engine from here, so they take the VAO alone. @internal */\n _engine: GLEngineContext;\n /** @internal */\n _disposed: boolean;\n /** @internal The index buffer recorded into the VAO. */\n _indexBuffer: GLIndexBuffer;\n /** @internal Resolved attribute bindings, reused to re-record on restore. */\n _bindings: _ResolvedBinding[];\n /** @internal `webglcontextrestored` re-record hook. */\n _restore: () => void;\n}\n\n/** @internal A single attribute with its location resolved once at record time\n * (locations are stable across re-link via `bindAttribLocation`, so the VAO can\n * re-record on context-restore without the effect). */\ninterface _ResolvedAttr {\n loc: number;\n size: number;\n type: number;\n normalized: boolean;\n stride: number;\n offset: number;\n divisor: number;\n}\n\n/** @internal A vertex buffer + its resolved attributes. */\ninterface _ResolvedBinding {\n buffer: GLVertexBuffer;\n attrs: _ResolvedAttr[];\n}\n\n/**\n * Record a static mesh's attribute layout + index binding into a new VAO. The\n * effect MUST be ready (its attribute locations are resolved here, once). Returns\n * a {@link GLMeshVao} to draw with {@link drawMesh}.\n *\n * @param engine - The engine.\n * @param vertexBuffers - One or more buffers + their attribute layouts.\n * @param indexBuffer - The index buffer recorded into the VAO.\n * @param effect - The effect whose attribute locations resolve unnamed indices.\n * @returns The recorded {@link GLMeshVao}.\n */\nexport function createMeshVao(engine: GLEngineContext, vertexBuffers: readonly GLMeshVertexBuffer[], indexBuffer: GLIndexBuffer, effect: GLEffect): GLMeshVao {\n const gl = engine.gl;\n // The effect's attribute locations are resolved (once) below; an unready effect\n // would resolve every name to -1 → a silently-empty VAO. Fail fast — callers\n // must gate on isEffectReady (see scene10's first-ready-frame creation).\n if (!effect.isReady) {\n throw new Error(\"lite-gl: createMeshVao requires a ready effect (poll isEffectReady first)\");\n }\n const handle = gl.createVertexArray();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createVertexArray returned null (mesh VAO)\");\n }\n // Resolve every attribute location ONCE (stable across re-link), so a restore\n // re-record needs only the buffer handles, not the effect.\n const bindings: _ResolvedBinding[] = [];\n for (const vbb of vertexBuffers) {\n let stride = 0;\n if (vbb.computeStride) {\n for (let i = 0; i < vbb.attributes.length; i++) {\n stride += (vbb.attributes[i] as GLAttributeDescriptor).size * 4;\n }\n }\n const attrs: _ResolvedAttr[] = [];\n for (let i = 0; i < vbb.attributes.length; i++) {\n const d = vbb.attributes[i] as GLAttributeDescriptor;\n const loc = d.index !== undefined ? d.index : d.name !== undefined ? getEffectAttributeLocation(effect, d.name) : -1;\n if (loc < 0) {\n continue;\n }\n attrs.push({\n loc,\n size: d.size,\n type: d.type ?? FLOAT,\n normalized: d.normalized ?? false,\n stride,\n offset: d.offset ?? 0,\n divisor: d.divisor === undefined ? 1 : d.divisor,\n });\n }\n bindings.push({ buffer: vbb.buffer, attrs });\n }\n const vao: GLMeshVao = { handle, _engine: engine, _disposed: false, _indexBuffer: indexBuffer, _bindings: bindings, _restore: () => {} };\n vao._restore = (): void => {\n if (engine._isLost || engine._disposed || vao._disposed) {\n return;\n }\n const fresh = engine.gl.createVertexArray();\n if (fresh === null) {\n return;\n }\n vao.handle = fresh;\n recordMeshVao(engine, vao);\n };\n recordMeshVao(engine, vao);\n onContextRestored(engine, vao._restore);\n return vao;\n}\n\n/**\n * Bind a {@link GLMeshVao} (cached `gl.bindVertexArray`). Rarely called directly —\n * {@link drawMesh} binds it for you. Binding restores the VAO's recorded element\n * binding, so the element-buffer cache is updated in lock-step.\n *\n * @param vao - The mesh VAO to bind.\n */\nexport function bindMeshVao(vao: GLMeshVao): void {\n const engine = vao._engine;\n if (engine._isLost || engine._disposed || vao._disposed) {\n return;\n }\n const s = engine._state;\n if (s.boundVao === vao.handle) {\n return;\n }\n engine.gl.bindVertexArray(vao.handle);\n s.boundVao = vao.handle;\n s.boundElementBuffer = vao._indexBuffer.handle;\n}\n\n/**\n * Draw a static mesh recorded with {@link createMeshVao}: binds its VAO (cached),\n * flushes deferred GL state, and issues ONE `drawElements` (or\n * `drawElementsInstanced` when `instanceCount > 0`) over the VAO's full index\n * buffer. No per-draw attribute (re)binding. No-op on a lost/disposed context, a\n * disposed VAO, or when no program is current.\n *\n * @param vao - The mesh VAO to draw.\n * @param instanceCount - Instance count for instanced draws. Default 0 (non-instanced).\n * @param indexStart - First index in the retained mesh.\n * @param indexCount - Number of indices; defaults to the indices from `indexStart` to the end of the mesh.\n * @throws RangeError when the range is not whole indices within the mesh.\n */\nexport function drawMesh(vao: GLMeshVao, instanceCount = 0, indexStart = 0, indexCount = vao._indexBuffer.count - indexStart): void {\n const total = vao._indexBuffer.count;\n if (!Number.isInteger(indexStart) || !Number.isInteger(indexCount) || indexStart < 0 || indexCount < 0 || indexStart + indexCount > total) {\n throw new RangeError(`lite-gl: drawMesh range (start ${indexStart}, count ${indexCount}) must be whole indices within the mesh's ${total}`);\n }\n const engine = vao._engine;\n if (engine._isLost || engine._disposed || vao._disposed) {\n return;\n }\n if (engine._state.currentProgram === null) {\n return;\n }\n bindMeshVao(vao);\n applyGLStates(engine);\n const ib = vao._indexBuffer;\n const gl = engine.gl;\n const type = ib.is32Bits ? UNSIGNED_INT : UNSIGNED_SHORT;\n if (instanceCount > 0) {\n gl.drawElementsInstanced(TRIANGLES, indexCount, type, indexStart * (ib.is32Bits ? 4 : 2), instanceCount);\n } else {\n gl.drawElements(TRIANGLES, indexCount, type, indexStart * (ib.is32Bits ? 4 : 2));\n }\n}\n\n/** Dispose a {@link GLMeshVao}: delete the VAO and unregister its restore hook.\n * Does NOT dispose the vertex/index buffers (the caller owns those). Idempotent. */\nexport function disposeMeshVao(vao: GLMeshVao): void {\n const engine = vao._engine;\n if (vao._disposed) {\n return;\n }\n vao._disposed = true;\n offContextRestored(engine, vao._restore);\n if (!engine._isLost && !engine._disposed) {\n const s = engine._state;\n engine.gl.deleteVertexArray(vao.handle);\n if (s.boundVao === vao.handle) {\n // Return to the default VAO so the cache stays coherent.\n engine.gl.bindVertexArray(null);\n s.boundVao = null;\n s.boundElementBuffer = null;\n }\n }\n}\n\n/** @internal Record `vao._bindings` + the index binding into `vao.handle`. Leaves\n * the default (null) VAO bound afterwards (so the mesh VAO is not left current),\n * forgetting the element-buffer cache. Touches neither `s.enabledAttribs` (those\n * track the DEFAULT VAO) nor the divisor reset — all of that lives in the VAO. */\nfunction recordMeshVao(engine: GLEngineContext, vao: GLMeshVao): void {\n const gl = engine.gl;\n const s = engine._state;\n gl.bindVertexArray(vao.handle);\n s.boundVao = vao.handle;\n for (const b of vao._bindings) {\n bindArrayBufferRaw(engine, b.buffer.handle);\n for (const a of b.attrs) {\n gl.enableVertexAttribArray(a.loc);\n gl.vertexAttribPointer(a.loc, a.size, a.type, a.normalized, a.stride, a.offset);\n gl.vertexAttribDivisor(a.loc, a.divisor);\n }\n }\n gl.bindBuffer(ELEMENT_ARRAY_BUFFER, vao._indexBuffer.handle);\n gl.bindVertexArray(null);\n s.boundVao = null;\n s.boundElementBuffer = null;\n}\n\n/* ──────────────────────────── internal helpers ──────────────────────────── */\n\n/** Bind the default (null) VAO if not already bound. The mesh path lives here so\n * it never disturbs the quad / sprite VAO state. Binding a VAO restores ITS\n * element-array binding, so the element-buffer cache is forgotten on the\n * switch (the next `bindIndexBuffer` re-binds). */\nfunction bindDefaultVao(engine: GLEngineContext): void {\n const s = engine._state;\n if (s.boundVao !== null) {\n engine.gl.bindVertexArray(null);\n s.boundVao = null;\n s.boundElementBuffer = null;\n }\n}\n\n/** Cached `gl.bindBuffer(ARRAY_BUFFER, …)`. ARRAY_BUFFER binding is global (not\n * VAO state), so this cache is coherent across VAO switches. */\nfunction bindArrayBufferRaw(engine: GLEngineContext, handle: WebGLBuffer): void {\n const s = engine._state;\n if (s.boundArrayBuffer === handle) {\n return;\n }\n engine.gl.bindBuffer(ARRAY_BUFFER, handle);\n s.boundArrayBuffer = handle;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/** @internal Capacity of the reusable command buffer, in 32-bit words. */
|
|
2
|
+
export const COMMAND_STREAM_WORDS = 16384;
|
|
3
|
+
function capacityError() {
|
|
4
|
+
return new Error(`Native Lite GL command exceeds its ${(COMMAND_STREAM_WORDS * 4) / 1024} KiB buffer.`);
|
|
5
|
+
}
|
|
6
|
+
/** @internal */
|
|
7
|
+
export class CommandStream {
|
|
8
|
+
runtime;
|
|
9
|
+
engine;
|
|
10
|
+
/** Reusable copy of an array upload, read completely before any of its command is recorded. */
|
|
11
|
+
staging = [];
|
|
12
|
+
/** Changes whenever an array upload claims `staging`, so an interrupted upload can detect the overwrite. */
|
|
13
|
+
stagingGeneration = 0;
|
|
14
|
+
words = new Uint32Array(COMMAND_STREAM_WORDS);
|
|
15
|
+
integers = new Int32Array(this.words.buffer);
|
|
16
|
+
floats = new Float32Array(this.words.buffer);
|
|
17
|
+
position = 0;
|
|
18
|
+
frameActive = false;
|
|
19
|
+
retained = [];
|
|
20
|
+
/** Host textures whose deletion waits until the commands recorded before it are submitted. */
|
|
21
|
+
deletedTextures = [];
|
|
22
|
+
/** @internal */
|
|
23
|
+
_nativeDataStream;
|
|
24
|
+
constructor(runtime, engine) {
|
|
25
|
+
this.runtime = runtime;
|
|
26
|
+
this.engine = engine;
|
|
27
|
+
this._nativeDataStream = new runtime.NativeDataStream(() => this.flush());
|
|
28
|
+
engine.setCommandDataStream(this);
|
|
29
|
+
}
|
|
30
|
+
begin() {
|
|
31
|
+
if (this.frameActive) {
|
|
32
|
+
throw new Error("Native Lite GL frame is already active.");
|
|
33
|
+
}
|
|
34
|
+
this.frameActive = true;
|
|
35
|
+
}
|
|
36
|
+
end() {
|
|
37
|
+
if (!this.frameActive) {
|
|
38
|
+
throw new Error("Native Lite GL frame is not active.");
|
|
39
|
+
}
|
|
40
|
+
this.frameActive = false;
|
|
41
|
+
this.submit();
|
|
42
|
+
}
|
|
43
|
+
start(command) {
|
|
44
|
+
this.handle(command);
|
|
45
|
+
}
|
|
46
|
+
uint(value) {
|
|
47
|
+
this.tag(this.runtime.NativeDataStream.VALIDATION_UINT_32);
|
|
48
|
+
this.reserve(1);
|
|
49
|
+
this.words[this.position++] = value;
|
|
50
|
+
}
|
|
51
|
+
int(value) {
|
|
52
|
+
this.tag(this.runtime.NativeDataStream.VALIDATION_INT_32);
|
|
53
|
+
this.reserve(1);
|
|
54
|
+
this.integers[this.position++] = value;
|
|
55
|
+
}
|
|
56
|
+
float(value) {
|
|
57
|
+
this.tag(this.runtime.NativeDataStream.VALIDATION_FLOAT_32);
|
|
58
|
+
this.reserve(1);
|
|
59
|
+
this.floats[this.position++] = value;
|
|
60
|
+
}
|
|
61
|
+
bool(value) {
|
|
62
|
+
this.tag(this.runtime.NativeDataStream.VALIDATION_BOOLEAN);
|
|
63
|
+
this.reserve(1);
|
|
64
|
+
this.words[this.position++] = value ? 1 : 0;
|
|
65
|
+
}
|
|
66
|
+
/** Encodes the first `length` values. */
|
|
67
|
+
array(values, length) {
|
|
68
|
+
this.tag(this.runtime.NativeDataStream.VALIDATION_FLOAT_32_ARRAY);
|
|
69
|
+
this.reserve(1 + length);
|
|
70
|
+
this.words[this.position++] = length;
|
|
71
|
+
for (let index = 0; index < length; index++) {
|
|
72
|
+
this.floats[this.position++] = values[index];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
handle(value) {
|
|
76
|
+
this.tag(this.runtime.NativeDataStream.VALIDATION_NATIVE_DATA);
|
|
77
|
+
this.reserve(value.length);
|
|
78
|
+
this.words.set(value, this.position);
|
|
79
|
+
this.position += value.length;
|
|
80
|
+
this.retained.push(value);
|
|
81
|
+
}
|
|
82
|
+
finish() {
|
|
83
|
+
if (!this.frameActive) {
|
|
84
|
+
this.submit();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** Claims `staging` for an encodable float array of `length` values. */
|
|
88
|
+
beginStaging(length) {
|
|
89
|
+
if (!Number.isInteger(length) || length < 0) {
|
|
90
|
+
throw new RangeError(`Native Lite GL array length must be a nonnegative integer, got ${length}.`);
|
|
91
|
+
}
|
|
92
|
+
if (length + 1 > this.words.length) {
|
|
93
|
+
throw capacityError();
|
|
94
|
+
}
|
|
95
|
+
return ++this.stagingGeneration;
|
|
96
|
+
}
|
|
97
|
+
/** Rejects an upload whose `staging` claim was taken by a nested upload. */
|
|
98
|
+
endStaging(generation) {
|
|
99
|
+
if (generation !== this.stagingGeneration) {
|
|
100
|
+
throw new Error("Native Lite GL array upload was interrupted by a nested array upload while reading its values.");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** Deletes host texture storage once every command recorded before this call has been submitted. */
|
|
104
|
+
deleteTexture(texture) {
|
|
105
|
+
this.deletedTextures.push(texture);
|
|
106
|
+
this.finish();
|
|
107
|
+
}
|
|
108
|
+
tag(value) {
|
|
109
|
+
if (this.runtime.NativeDataStream.VALIDATION_ENABLED) {
|
|
110
|
+
this.reserve(1);
|
|
111
|
+
this.words[this.position++] = value;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
reserve(length) {
|
|
115
|
+
if (length > this.words.length) {
|
|
116
|
+
throw capacityError();
|
|
117
|
+
}
|
|
118
|
+
if (this.position + length > this.words.length) {
|
|
119
|
+
this.flush();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
flush() {
|
|
123
|
+
this._nativeDataStream.writeBuffer(this.words.buffer, this.position);
|
|
124
|
+
this.position = 0;
|
|
125
|
+
}
|
|
126
|
+
submit() {
|
|
127
|
+
this.engine.submitCommands();
|
|
128
|
+
this.retained.length = 0;
|
|
129
|
+
for (let index = 0; index < this.deletedTextures.length; index++) {
|
|
130
|
+
this.engine.deleteTexture(this.deletedTextures[index]);
|
|
131
|
+
}
|
|
132
|
+
this.deletedTextures.length = 0;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=command-stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-stream.js","sourceRoot":"","sources":["../../src/native/command-stream.ts"],"names":[],"mappings":"AAEA,0EAA0E;AAC1E,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAE1C,SAAS,aAAa;IAClB,OAAO,IAAI,KAAK,CAAC,sCAAsC,CAAC,oBAAoB,GAAG,CAAC,CAAC,GAAG,IAAI,cAAc,CAAC,CAAC;AAC5G,CAAC;AAED,gBAAgB;AAChB,MAAM,OAAO,aAA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AAC;YAC/D,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAiB,CAAC,CAAC;QAC3E,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC;IACpC,CAAC;CACJ","sourcesContent":["import type { NativeEngine, NativeHandle, NativeRuntime } from \"./runtime.js\";\n\n/** @internal Capacity of the reusable command buffer, in 32-bit words. */\nexport const COMMAND_STREAM_WORDS = 16384;\n\nfunction capacityError(): Error {\n return new Error(`Native Lite GL command exceeds its ${(COMMAND_STREAM_WORDS * 4) / 1024} KiB buffer.`);\n}\n\n/** @internal */\nexport class CommandStream {\n /** Reusable copy of an array upload, read completely before any of its command is recorded. */\n readonly staging: number[] = [];\n /** Changes whenever an array upload claims `staging`, so an interrupted upload can detect the overwrite. */\n private stagingGeneration = 0;\n private readonly words = new Uint32Array(COMMAND_STREAM_WORDS);\n private readonly integers = new Int32Array(this.words.buffer);\n private readonly floats = new Float32Array(this.words.buffer);\n private position = 0;\n private frameActive = false;\n private readonly retained: NativeHandle[] = [];\n /** Host textures whose deletion waits until the commands recorded before it are submitted. */\n private readonly deletedTextures: NativeHandle[] = [];\n /** @internal */\n readonly _nativeDataStream;\n\n constructor(\n private readonly runtime: NativeRuntime,\n private readonly engine: NativeEngine\n ) {\n this._nativeDataStream = new runtime.NativeDataStream(() => this.flush());\n engine.setCommandDataStream(this);\n }\n\n begin(): void {\n if (this.frameActive) {\n throw new Error(\"Native Lite GL frame is already active.\");\n }\n this.frameActive = true;\n }\n\n end(): void {\n if (!this.frameActive) {\n throw new Error(\"Native Lite GL frame is not active.\");\n }\n this.frameActive = false;\n this.submit();\n }\n\n start(command: NativeHandle): void {\n this.handle(command);\n }\n\n uint(value: number): void {\n this.tag(this.runtime.NativeDataStream.VALIDATION_UINT_32);\n this.reserve(1);\n this.words[this.position++] = value;\n }\n\n int(value: number): void {\n this.tag(this.runtime.NativeDataStream.VALIDATION_INT_32);\n this.reserve(1);\n this.integers[this.position++] = value;\n }\n\n float(value: number): void {\n this.tag(this.runtime.NativeDataStream.VALIDATION_FLOAT_32);\n this.reserve(1);\n this.floats[this.position++] = value;\n }\n\n bool(value: boolean): void {\n this.tag(this.runtime.NativeDataStream.VALIDATION_BOOLEAN);\n this.reserve(1);\n this.words[this.position++] = value ? 1 : 0;\n }\n\n /** Encodes the first `length` values. */\n array(values: readonly number[], length: number): void {\n this.tag(this.runtime.NativeDataStream.VALIDATION_FLOAT_32_ARRAY);\n this.reserve(1 + length);\n this.words[this.position++] = length;\n for (let index = 0; index < length; index++) {\n this.floats[this.position++] = values[index] as number;\n }\n }\n\n handle(value: NativeHandle): void {\n this.tag(this.runtime.NativeDataStream.VALIDATION_NATIVE_DATA);\n this.reserve(value.length);\n this.words.set(value, this.position);\n this.position += value.length;\n this.retained.push(value);\n }\n\n finish(): void {\n if (!this.frameActive) {\n this.submit();\n }\n }\n\n /** Claims `staging` for an encodable float array of `length` values. */\n beginStaging(length: number): number {\n if (!Number.isInteger(length) || length < 0) {\n throw new RangeError(`Native Lite GL array length must be a nonnegative integer, got ${length}.`);\n }\n if (length + 1 > this.words.length) {\n throw capacityError();\n }\n return ++this.stagingGeneration;\n }\n\n /** Rejects an upload whose `staging` claim was taken by a nested upload. */\n endStaging(generation: number): void {\n if (generation !== this.stagingGeneration) {\n throw new Error(\"Native Lite GL array upload was interrupted by a nested array upload while reading its values.\");\n }\n }\n\n /** Deletes host texture storage once every command recorded before this call has been submitted. */\n deleteTexture(texture: NativeHandle): void {\n this.deletedTextures.push(texture);\n this.finish();\n }\n\n private tag(value: number): void {\n if (this.runtime.NativeDataStream.VALIDATION_ENABLED) {\n this.reserve(1);\n this.words[this.position++] = value;\n }\n }\n\n private reserve(length: number): void {\n if (length > this.words.length) {\n throw capacityError();\n }\n if (this.position + length > this.words.length) {\n this.flush();\n }\n }\n\n private flush(): void {\n this._nativeDataStream.writeBuffer(this.words.buffer, this.position);\n this.position = 0;\n }\n\n private submit(): void {\n this.engine.submitCommands();\n this.retained.length = 0;\n for (let index = 0; index < this.deletedTextures.length; index++) {\n this.engine.deleteTexture(this.deletedTextures[index] as NativeHandle);\n }\n this.deletedTextures.length = 0;\n }\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { NativeResource } from "./identity.js";
|
|
2
|
+
import type { GLRenderTarget } from "./render-target.js";
|
|
3
|
+
/** Device limits used by composition producers. */
|
|
4
|
+
export interface GLEngineCaps {
|
|
5
|
+
/** Largest supported texture dimension, or 0 when the host has not reported one. */
|
|
6
|
+
readonly maxTextureSize: number;
|
|
7
|
+
}
|
|
8
|
+
/** Composition state owned by one Babylon Native engine. */
|
|
9
|
+
export interface GLEngineContext extends NativeResource<"engine"> {
|
|
10
|
+
/** Device limits. */
|
|
11
|
+
readonly caps: GLEngineCaps;
|
|
12
|
+
}
|
|
13
|
+
/** Creates the native composition engine without a scene graph. */
|
|
14
|
+
export declare function createNativeEngine(): GLEngineContext;
|
|
15
|
+
/** Begins a native command submission scope. */
|
|
16
|
+
export declare function beginFrame(engine: GLEngineContext): void;
|
|
17
|
+
/** Submits a native frame, including commands recorded before a caller error. */
|
|
18
|
+
export declare function endFrame(engine: GLEngineContext): void;
|
|
19
|
+
/** Releases the engine after its renderer resources have been disposed. */
|
|
20
|
+
export declare function disposeNativeEngine(engine: GLEngineContext): void;
|
|
21
|
+
/** Default output width in physical pixels, the native counterpart of the canvas width. */
|
|
22
|
+
export declare function getRenderWidth(engine: GLEngineContext): number;
|
|
23
|
+
/** Default output height in physical pixels, the native counterpart of the canvas height. */
|
|
24
|
+
export declare function getRenderHeight(engine: GLEngineContext): number;
|
|
25
|
+
/** Current drawing target, or null for the default output. */
|
|
26
|
+
export declare function getCurrentRenderTarget(engine: GLEngineContext): GLRenderTarget | null;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { CommandStream } from "./command-stream.js";
|
|
2
|
+
import { getRuntime } from "./runtime.js";
|
|
3
|
+
/** Creates the native composition engine without a scene graph. */
|
|
4
|
+
export function createNativeEngine() {
|
|
5
|
+
const runtime = getRuntime();
|
|
6
|
+
const nativeEngine = new runtime.Engine({ version: "@babylonjs/lite-gl/native", nonFloatVertexBuffers: true });
|
|
7
|
+
const fields = {
|
|
8
|
+
caps: { maxTextureSize: runtime.Engine.CAPS_LIMITS_MAX_TEXTURE_SIZE },
|
|
9
|
+
_runtime: runtime,
|
|
10
|
+
_native: nativeEngine,
|
|
11
|
+
_commands: new CommandStream(runtime, nativeEngine),
|
|
12
|
+
_target: null,
|
|
13
|
+
_program: null,
|
|
14
|
+
_vertexArray: null,
|
|
15
|
+
_blend: -1,
|
|
16
|
+
_viewport: [NaN, NaN, NaN, NaN],
|
|
17
|
+
_textureGeneration: 0,
|
|
18
|
+
_scissorEmpty: false,
|
|
19
|
+
_disposed: false,
|
|
20
|
+
};
|
|
21
|
+
const engine = fields;
|
|
22
|
+
nativeEngine.setHardwareScalingLevel(1);
|
|
23
|
+
nativeEngine.setRenderResetCallback(() => {
|
|
24
|
+
engine._target = null;
|
|
25
|
+
engine._program = null;
|
|
26
|
+
engine._vertexArray = null;
|
|
27
|
+
engine._blend = -1;
|
|
28
|
+
engine._viewport.fill(NaN);
|
|
29
|
+
engine._textureGeneration++;
|
|
30
|
+
engine._scissorEmpty = false;
|
|
31
|
+
initializeCompositionState(engine);
|
|
32
|
+
});
|
|
33
|
+
initializeCompositionState(engine);
|
|
34
|
+
return engine;
|
|
35
|
+
}
|
|
36
|
+
/** Composition draws without depth testing, culling or a scissor rectangle. */
|
|
37
|
+
function initializeCompositionState(engine) {
|
|
38
|
+
const runtime = engine._runtime;
|
|
39
|
+
const commands = engine._commands;
|
|
40
|
+
commands.start(runtime.Engine.COMMAND_SETDEPTHTEST);
|
|
41
|
+
commands.uint(runtime.Engine.DEPTH_TEST_ALWAYS);
|
|
42
|
+
commands.finish();
|
|
43
|
+
commands.start(runtime.Engine.COMMAND_SETDEPTHWRITE);
|
|
44
|
+
commands.uint(0);
|
|
45
|
+
commands.finish();
|
|
46
|
+
commands.start(runtime.Engine.COMMAND_SETSTATE);
|
|
47
|
+
commands.uint(0);
|
|
48
|
+
commands.float(0);
|
|
49
|
+
commands.float(0);
|
|
50
|
+
commands.uint(1);
|
|
51
|
+
commands.uint(0);
|
|
52
|
+
commands.finish();
|
|
53
|
+
// The host keeps the default output's scissor across a device reset; an all-zero rectangle removes it.
|
|
54
|
+
commands.start(runtime.Engine.COMMAND_SETSCISSOR);
|
|
55
|
+
commands.float(0);
|
|
56
|
+
commands.float(0);
|
|
57
|
+
commands.float(0);
|
|
58
|
+
commands.float(0);
|
|
59
|
+
commands.finish();
|
|
60
|
+
}
|
|
61
|
+
/** Begins a native command submission scope. */
|
|
62
|
+
export function beginFrame(engine) {
|
|
63
|
+
engine._commands.begin();
|
|
64
|
+
engine._textureGeneration++;
|
|
65
|
+
}
|
|
66
|
+
/** Submits a native frame, including commands recorded before a caller error. */
|
|
67
|
+
export function endFrame(engine) {
|
|
68
|
+
engine._commands.end();
|
|
69
|
+
}
|
|
70
|
+
/** Releases the engine after its renderer resources have been disposed. */
|
|
71
|
+
export function disposeNativeEngine(engine) {
|
|
72
|
+
if (!engine._disposed) {
|
|
73
|
+
engine._disposed = true;
|
|
74
|
+
engine._native.dispose();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** Default output width in physical pixels, the native counterpart of the canvas width. */
|
|
78
|
+
export function getRenderWidth(engine) {
|
|
79
|
+
return engine._native.getRenderWidth();
|
|
80
|
+
}
|
|
81
|
+
/** Default output height in physical pixels, the native counterpart of the canvas height. */
|
|
82
|
+
export function getRenderHeight(engine) {
|
|
83
|
+
return engine._native.getRenderHeight();
|
|
84
|
+
}
|
|
85
|
+
/** Current drawing target, or null for the default output. */
|
|
86
|
+
export function getCurrentRenderTarget(engine) {
|
|
87
|
+
return engine._target;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|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AAC,CAAC,CAAC,CAAC;IAClB,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,QAAQ,CAAC,MAAM,EAAE,CAAC;AACtB,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,UAAU,CAAC,MAAuB;IAC9C,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACzB,MAAM,CAAC,kBAAkB,EAAE,CAAC;AAChC,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,QAAQ,CAAC,MAAuB;IAC5C,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;AAC3B,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,mBAAmB,CAAC,MAAuB;IACvD,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QACpB,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC;QACxB,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;AACL,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,cAAc,CAAC,MAAuB;IAClD,OAAO,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;AAC3C,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,eAAe,CAAC,MAAuB;IACnD,OAAO,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;AAC5C,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,sBAAsB,CAAC,MAAuB;IAC1D,OAAO,MAAM,CAAC,OAAO,CAAC;AAC1B,CAAC","sourcesContent":["import { CommandStream } from \"./command-stream.js\";\nimport type { NativeResource, NativeResourceFields } from \"./identity.js\";\nimport { getRuntime } from \"./runtime.js\";\nimport type { NativeEngine, NativeHandle, NativeRuntime } from \"./runtime.js\";\nimport type { GLRenderTarget } from \"./render-target.js\";\n\n/** Device limits used by composition producers. */\nexport interface GLEngineCaps {\n /** Largest supported texture dimension, or 0 when the host has not reported one. */\n readonly maxTextureSize: number;\n}\n\n/** Composition state owned by one Babylon Native engine. */\nexport interface GLEngineContext extends NativeResource<\"engine\"> {\n /** Device limits. */\n readonly caps: GLEngineCaps;\n /** @internal */\n readonly _runtime: NativeRuntime;\n /** @internal */\n readonly _native: NativeEngine;\n /** @internal */\n readonly _commands: CommandStream;\n /** @internal */\n _target: GLRenderTarget | null;\n /** @internal */\n _program: NativeHandle | null;\n /** @internal */\n _vertexArray: NativeHandle | null;\n /** @internal */\n _blend: number;\n /** @internal Normalized viewport last sent to the native engine. */\n readonly _viewport: number[];\n /** @internal */\n _textureGeneration: number;\n /** @internal Whether the scissor rectangle has no area, so drawing and clearing do nothing. */\n _scissorEmpty: boolean;\n /** @internal */\n _disposed: boolean;\n}\n\n/** Creates the native composition engine without a scene graph. */\nexport function createNativeEngine(): GLEngineContext {\n const runtime = getRuntime();\n const nativeEngine = new runtime.Engine({ version: \"@babylonjs/lite-gl/native\", nonFloatVertexBuffers: true });\n const fields: NativeResourceFields<GLEngineContext> = {\n caps: { maxTextureSize: runtime.Engine.CAPS_LIMITS_MAX_TEXTURE_SIZE },\n _runtime: runtime,\n _native: nativeEngine,\n _commands: new CommandStream(runtime, nativeEngine),\n _target: null,\n _program: null,\n _vertexArray: null,\n _blend: -1,\n _viewport: [NaN, NaN, NaN, NaN],\n _textureGeneration: 0,\n _scissorEmpty: false,\n _disposed: false,\n };\n const engine = fields as GLEngineContext;\n nativeEngine.setHardwareScalingLevel(1);\n nativeEngine.setRenderResetCallback(() => {\n engine._target = null;\n engine._program = null;\n engine._vertexArray = null;\n engine._blend = -1;\n engine._viewport.fill(NaN);\n engine._textureGeneration++;\n engine._scissorEmpty = false;\n initializeCompositionState(engine);\n });\n initializeCompositionState(engine);\n return engine;\n}\n\n/** Composition draws without depth testing, culling or a scissor rectangle. */\nfunction initializeCompositionState(engine: GLEngineContext): void {\n const runtime = engine._runtime;\n const commands = engine._commands;\n commands.start(runtime.Engine.COMMAND_SETDEPTHTEST);\n commands.uint(runtime.Engine.DEPTH_TEST_ALWAYS);\n commands.finish();\n commands.start(runtime.Engine.COMMAND_SETDEPTHWRITE);\n commands.uint(0);\n commands.finish();\n commands.start(runtime.Engine.COMMAND_SETSTATE);\n commands.uint(0);\n commands.float(0);\n commands.float(0);\n commands.uint(1);\n commands.uint(0);\n commands.finish();\n // The host keeps the default output's scissor across a device reset; an all-zero rectangle removes it.\n commands.start(runtime.Engine.COMMAND_SETSCISSOR);\n commands.float(0);\n commands.float(0);\n commands.float(0);\n commands.float(0);\n commands.finish();\n}\n\n/** Begins a native command submission scope. */\nexport function beginFrame(engine: GLEngineContext): void {\n engine._commands.begin();\n engine._textureGeneration++;\n}\n\n/** Submits a native frame, including commands recorded before a caller error. */\nexport function endFrame(engine: GLEngineContext): void {\n engine._commands.end();\n}\n\n/** Releases the engine after its renderer resources have been disposed. */\nexport function disposeNativeEngine(engine: GLEngineContext): void {\n if (!engine._disposed) {\n engine._disposed = true;\n engine._native.dispose();\n }\n}\n\n/** Default output width in physical pixels, the native counterpart of the canvas width. */\nexport function getRenderWidth(engine: GLEngineContext): number {\n return engine._native.getRenderWidth();\n}\n\n/** Default output height in physical pixels, the native counterpart of the canvas height. */\nexport function getRenderHeight(engine: GLEngineContext): number {\n return engine._native.getRenderHeight();\n}\n\n/** Current drawing target, or null for the default output. */\nexport function getCurrentRenderTarget(engine: GLEngineContext): GLRenderTarget | null {\n return engine._target;\n}\n"]}
|