shute-technologies.octopus-web-framework 1.5.0 → 1.7.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/lib/index.d.ts +3 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/src/shute-technologies/modules/framework/core/device/ofDeviceCapabilities.d.ts +10 -0
- package/lib/src/shute-technologies/modules/framework/core/device/ofDeviceCapabilities.js +46 -0
- package/lib/src/shute-technologies/modules/framework/core/device/ofDeviceCapabilities.js.map +1 -1
- package/lib/src/shute-technologies/modules/framework/core/device/ofGraphicDevice.d.ts +77 -1
- package/lib/src/shute-technologies/modules/framework/core/device/ofGraphicDevice.js +209 -14
- package/lib/src/shute-technologies/modules/framework/core/device/ofGraphicDevice.js.map +1 -1
- package/lib/src/shute-technologies/modules/framework/core/device/optimization/gpu/ofVBOObject.js +2 -1
- package/lib/src/shute-technologies/modules/framework/core/device/optimization/gpu/ofVBOObject.js.map +1 -1
- package/lib/src/shute-technologies/modules/framework/core/render/camera/ofRenderCamera.js +2 -2
- package/lib/src/shute-technologies/modules/framework/core/render/camera/ofRenderCamera.js.map +1 -1
- package/lib/src/shute-technologies/modules/framework/core/render/graphics/d2d/ofAnimation.js +2 -2
- package/lib/src/shute-technologies/modules/framework/core/render/graphics/d2d/ofAnimation.js.map +1 -1
- package/lib/src/shute-technologies/modules/framework/core/render/graphics/d2d/ofPrimitiveCircle.js +3 -3
- package/lib/src/shute-technologies/modules/framework/core/render/graphics/d2d/ofPrimitiveCircle.js.map +1 -1
- package/lib/src/shute-technologies/modules/framework/core/render/graphics/d2d/ofPrimitiveGrid.js +4 -4
- package/lib/src/shute-technologies/modules/framework/core/render/graphics/d2d/ofPrimitiveGrid.js.map +1 -1
- package/lib/src/shute-technologies/modules/framework/core/render/graphics/d2d/ofPrimitiveQuad.js +5 -5
- package/lib/src/shute-technologies/modules/framework/core/render/graphics/d2d/ofPrimitiveQuad.js.map +1 -1
- package/lib/src/shute-technologies/modules/framework/core/render/graphics/d2d/ofSprite.js +2 -2
- package/lib/src/shute-technologies/modules/framework/core/render/graphics/d2d/ofSprite.js.map +1 -1
- package/lib/src/shute-technologies/modules/framework/core/render/graphics/d2d/optimization/ofOptSpriteBatcher.d.ts +2 -0
- package/lib/src/shute-technologies/modules/framework/core/render/graphics/d2d/optimization/ofOptSpriteBatcher.js +6 -5
- package/lib/src/shute-technologies/modules/framework/core/render/graphics/d2d/optimization/ofOptSpriteBatcher.js.map +1 -1
- package/lib/src/shute-technologies/modules/framework/core/render/graphics/d2d/optimization/ofPolygonBatcher.d.ts +21 -0
- package/lib/src/shute-technologies/modules/framework/core/render/graphics/d2d/optimization/ofPolygonBatcher.js +149 -23
- package/lib/src/shute-technologies/modules/framework/core/render/graphics/d2d/optimization/ofPolygonBatcher.js.map +1 -1
- package/lib/src/shute-technologies/modules/framework/core/render/graphics/d2d/optimization/ofSpriteBatcher.js +2 -2
- package/lib/src/shute-technologies/modules/framework/core/render/graphics/d2d/optimization/ofSpriteBatcher.js.map +1 -1
- package/lib/src/shute-technologies/modules/framework/core/render/shader/ofBaseShader.d.ts +6 -0
- package/lib/src/shute-technologies/modules/framework/core/render/shader/ofBaseShader.js +16 -0
- package/lib/src/shute-technologies/modules/framework/core/render/shader/ofBaseShader.js.map +1 -1
- package/lib/src/shute-technologies/modules/framework/core/render/shader/ofEnumBlendMode.d.ts +5 -1
- package/lib/src/shute-technologies/modules/framework/core/render/shader/ofEnumBlendMode.js +4 -0
- package/lib/src/shute-technologies/modules/framework/core/render/shader/ofEnumBlendMode.js.map +1 -1
- package/lib/src/shute-technologies/modules/framework/core/render/shader/ofShaderAbstract.d.ts +13 -0
- package/lib/src/shute-technologies/modules/framework/core/render/shader/ofShaderAbstract.js +65 -6
- package/lib/src/shute-technologies/modules/framework/core/render/shader/ofShaderAbstract.js.map +1 -1
- package/lib/src/shute-technologies/modules/framework/core/render/shader/ofShaderPrimitive.d.ts +1 -0
- package/lib/src/shute-technologies/modules/framework/core/render/shader/ofShaderPrimitive.js +6 -3
- package/lib/src/shute-technologies/modules/framework/core/render/shader/ofShaderPrimitive.js.map +1 -1
- package/lib/src/shute-technologies/modules/framework/core/render/shader/ofShaderTexture.d.ts +1 -0
- package/lib/src/shute-technologies/modules/framework/core/render/shader/ofShaderTexture.js +9 -8
- package/lib/src/shute-technologies/modules/framework/core/render/shader/ofShaderTexture.js.map +1 -1
- package/lib/src/shute-technologies/modules/framework/core/render/target/ofFullscreenPass.d.ts +32 -0
- package/lib/src/shute-technologies/modules/framework/core/render/target/ofFullscreenPass.js +81 -0
- package/lib/src/shute-technologies/modules/framework/core/render/target/ofFullscreenPass.js.map +1 -0
- package/lib/src/shute-technologies/modules/framework/core/render/target/ofRenderTarget.d.ts +54 -0
- package/lib/src/shute-technologies/modules/framework/core/render/target/ofRenderTarget.js +131 -0
- package/lib/src/shute-technologies/modules/framework/core/render/target/ofRenderTarget.js.map +1 -0
- package/lib/src/shute-technologies/modules/framework/core/render/target/ofRenderTargetPool.d.ts +29 -0
- package/lib/src/shute-technologies/modules/framework/core/render/target/ofRenderTargetPool.js +69 -0
- package/lib/src/shute-technologies/modules/framework/core/render/target/ofRenderTargetPool.js.map +1 -0
- package/lib/src/shute-technologies/modules/framework/default-assets/ofDefaultShaderSources.d.ts +2 -0
- package/lib/src/shute-technologies/modules/framework/default-assets/ofDefaultShaderSources.js +24 -0
- package/lib/src/shute-technologies/modules/framework/default-assets/ofDefaultShaderSources.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -45,6 +45,9 @@ export * from './src/shute-technologies/modules/framework/core/render/shader/ofE
|
|
|
45
45
|
export * from './src/shute-technologies/modules/framework/core/render/shader/ofShaderAbstract';
|
|
46
46
|
export * from './src/shute-technologies/modules/framework/core/render/shader/ofShaderFactory';
|
|
47
47
|
export * from './src/shute-technologies/modules/framework/core/render/shader/ofShaderPrimitive';
|
|
48
|
+
export * from './src/shute-technologies/modules/framework/core/render/target/ofFullscreenPass';
|
|
49
|
+
export * from './src/shute-technologies/modules/framework/core/render/target/ofRenderTarget';
|
|
50
|
+
export * from './src/shute-technologies/modules/framework/core/render/target/ofRenderTargetPool';
|
|
48
51
|
export * from './src/shute-technologies/modules/framework/core/render/shader/ofShaderTexture';
|
|
49
52
|
export * from './src/shute-technologies/modules/framework/core/render/shader/interfaces/ofIIsShaderAbstract';
|
|
50
53
|
export * from './src/shute-technologies/modules/framework/core/render/viewport/ofViewport';
|
package/lib/index.js
CHANGED
|
@@ -61,6 +61,9 @@ __exportStar(require("./src/shute-technologies/modules/framework/core/render/sha
|
|
|
61
61
|
__exportStar(require("./src/shute-technologies/modules/framework/core/render/shader/ofShaderAbstract"), exports);
|
|
62
62
|
__exportStar(require("./src/shute-technologies/modules/framework/core/render/shader/ofShaderFactory"), exports);
|
|
63
63
|
__exportStar(require("./src/shute-technologies/modules/framework/core/render/shader/ofShaderPrimitive"), exports);
|
|
64
|
+
__exportStar(require("./src/shute-technologies/modules/framework/core/render/target/ofFullscreenPass"), exports);
|
|
65
|
+
__exportStar(require("./src/shute-technologies/modules/framework/core/render/target/ofRenderTarget"), exports);
|
|
66
|
+
__exportStar(require("./src/shute-technologies/modules/framework/core/render/target/ofRenderTargetPool"), exports);
|
|
64
67
|
__exportStar(require("./src/shute-technologies/modules/framework/core/render/shader/ofShaderTexture"), exports);
|
|
65
68
|
__exportStar(require("./src/shute-technologies/modules/framework/core/render/shader/interfaces/ofIIsShaderAbstract"), exports);
|
|
66
69
|
__exportStar(require("./src/shute-technologies/modules/framework/core/render/viewport/ofViewport"), exports);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iGAA8E;AAC9E,yGAAuF;AACvF,6GAA2F;AAC3F,yGAAuF;AACvF,wGAAsF;AACtF,2GAAyF;AACzF,yGAAuF;AACvF,4GAA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qE;AACrE,gHAA8F;AAC9F,sHAAoG;AACpG,6HAA2G;AAC3G,sHAAoG;AACpG,mHAAiG"}
|
|
@@ -7,5 +7,15 @@ export declare class OFDeviceCapabilities {
|
|
|
7
7
|
get renderEngineType(): OFEnumRenderEngineType;
|
|
8
8
|
get graphiContext(): WebGLRenderingContext | RenderingContext;
|
|
9
9
|
private constructor();
|
|
10
|
+
/** Whether this context can render to, and linearly sample, a half-float RGBA texture. See the static form. */
|
|
11
|
+
get supportsHalfFloatTarget(): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Whether `gl` can render to, and linearly sample, a half-float RGBA texture. Extension names alone are not
|
|
14
|
+
* enough on some drivers, so a 1x1 half-float framebuffer is made and its status checked; the answer is kept
|
|
15
|
+
* per context. Needs OES_texture_half_float (the type), OES_texture_half_float_linear (LINEAR filtering, without
|
|
16
|
+
* which the texture samples black) and a complete framebuffer; EXT_color_buffer_half_float is enabled when present.
|
|
17
|
+
* Leaves the framebuffer and the 2D texture (on the active unit) bound as they were.
|
|
18
|
+
*/
|
|
19
|
+
static supportsHalfFloatTarget(gl: WebGLRenderingContext): boolean;
|
|
10
20
|
static create(framework: OFFramework, forceCanvas: boolean): OFDeviceCapabilities;
|
|
11
21
|
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OFDeviceCapabilities = void 0;
|
|
4
4
|
const ofEnumRenderEngine_1 = require("../../enums/ofEnumRenderEngine");
|
|
5
|
+
// The answer per context: the probe allocates GL objects, so it runs once.
|
|
6
|
+
const halfFloatTargetByContext = new WeakMap();
|
|
5
7
|
class OFDeviceCapabilities {
|
|
6
8
|
get renderEngineType() { return this._renderEngineType; }
|
|
7
9
|
get graphiContext() { return this._graphiContext; }
|
|
@@ -19,6 +21,50 @@ class OFDeviceCapabilities {
|
|
|
19
21
|
this._renderEngineType = ofEnumRenderEngine_1.OFEnumRenderEngineType.WebGL;
|
|
20
22
|
}
|
|
21
23
|
}
|
|
24
|
+
/** Whether this context can render to, and linearly sample, a half-float RGBA texture. See the static form. */
|
|
25
|
+
get supportsHalfFloatTarget() {
|
|
26
|
+
return this._renderEngineType === ofEnumRenderEngine_1.OFEnumRenderEngineType.WebGL
|
|
27
|
+
&& OFDeviceCapabilities.supportsHalfFloatTarget(this._graphiContext);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Whether `gl` can render to, and linearly sample, a half-float RGBA texture. Extension names alone are not
|
|
31
|
+
* enough on some drivers, so a 1x1 half-float framebuffer is made and its status checked; the answer is kept
|
|
32
|
+
* per context. Needs OES_texture_half_float (the type), OES_texture_half_float_linear (LINEAR filtering, without
|
|
33
|
+
* which the texture samples black) and a complete framebuffer; EXT_color_buffer_half_float is enabled when present.
|
|
34
|
+
* Leaves the framebuffer and the 2D texture (on the active unit) bound as they were.
|
|
35
|
+
*/
|
|
36
|
+
static supportsHalfFloatTarget(gl) {
|
|
37
|
+
if (!gl) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
const known = halfFloatTargetByContext.get(gl);
|
|
41
|
+
if (known !== undefined) {
|
|
42
|
+
return known;
|
|
43
|
+
}
|
|
44
|
+
let result = false;
|
|
45
|
+
const halfFloat = gl.getExtension('OES_texture_half_float');
|
|
46
|
+
const halfFloatLinear = gl.getExtension('OES_texture_half_float_linear');
|
|
47
|
+
gl.getExtension('EXT_color_buffer_half_float');
|
|
48
|
+
if (halfFloat && halfFloatLinear) {
|
|
49
|
+
const previousFramebuffer = gl.getParameter(gl.FRAMEBUFFER_BINDING);
|
|
50
|
+
const previousTexture = gl.getParameter(gl.TEXTURE_BINDING_2D);
|
|
51
|
+
const texture = gl.createTexture();
|
|
52
|
+
const framebuffer = gl.createFramebuffer();
|
|
53
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
54
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, halfFloat.HALF_FLOAT_OES, null);
|
|
55
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
56
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
57
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
|
|
58
|
+
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
|
|
59
|
+
result = gl.checkFramebufferStatus(gl.FRAMEBUFFER) === gl.FRAMEBUFFER_COMPLETE;
|
|
60
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, previousFramebuffer);
|
|
61
|
+
gl.bindTexture(gl.TEXTURE_2D, previousTexture);
|
|
62
|
+
gl.deleteFramebuffer(framebuffer);
|
|
63
|
+
gl.deleteTexture(texture);
|
|
64
|
+
}
|
|
65
|
+
halfFloatTargetByContext.set(gl, result);
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
22
68
|
static create(framework, forceCanvas) {
|
|
23
69
|
return new OFDeviceCapabilities(framework, forceCanvas);
|
|
24
70
|
}
|
package/lib/src/shute-technologies/modules/framework/core/device/ofDeviceCapabilities.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ofDeviceCapabilities.js","sourceRoot":"","sources":["../../../../../../../src/shute-technologies/modules/framework/core/device/ofDeviceCapabilities.ts"],"names":[],"mappings":";;;AACA,uEAAwE;AAExE,MAAa,oBAAoB;IAK/B,IAAI,gBAAgB,KAA6B,OAAO,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACjF,IAAI,aAAa,KAA+C,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;IAE7F,YAAqC,UAAuB,EAAE,WAAoB;QAA7C,eAAU,GAAV,UAAU,CAAa;QAC1D,MAAM,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;QAEpD,IAAI,CAAC,WAAW,EAAE;YAChB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,oBAAoB,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;SAC/F;QAED,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;YACxB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,oBAAoB,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;YAC1F,IAAI,CAAC,iBAAiB,GAAG,2CAAsB,CAAC,eAAe,CAAC;SACjE;aAAM;YACL,IAAI,CAAC,iBAAiB,GAAG,2CAAsB,CAAC,KAAK,CAAC;SACvD;IACH,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,SAAsB,EAAE,WAAoB;QACxD,OAAO,IAAI,oBAAoB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IAC1D,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"ofDeviceCapabilities.js","sourceRoot":"","sources":["../../../../../../../src/shute-technologies/modules/framework/core/device/ofDeviceCapabilities.ts"],"names":[],"mappings":";;;AACA,uEAAwE;AAExE,2EAA2E;AAC3E,MAAM,wBAAwB,GAAG,IAAI,OAAO,EAAkC,CAAC;AAE/E,MAAa,oBAAoB;IAK/B,IAAI,gBAAgB,KAA6B,OAAO,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACjF,IAAI,aAAa,KAA+C,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;IAE7F,YAAqC,UAAuB,EAAE,WAAoB;QAA7C,eAAU,GAAV,UAAU,CAAa;QAC1D,MAAM,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;QAEpD,IAAI,CAAC,WAAW,EAAE;YAChB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,oBAAoB,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;SAC/F;QAED,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;YACxB,IAAI,CAAC,cAAc,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CACF;AAzED,oDAyEC"}
|
|
@@ -15,8 +15,17 @@ export declare class OFGraphicDevice {
|
|
|
15
15
|
private _deviceOptimizationManager;
|
|
16
16
|
private _hasCustomCamera;
|
|
17
17
|
private _currentShaderProgram;
|
|
18
|
+
private _isShaderProgramKnown;
|
|
18
19
|
private readonly _enabledVertexAttributes;
|
|
20
|
+
private _areVertexAttributesKnown;
|
|
21
|
+
private _boundArrayBuffer;
|
|
22
|
+
private _boundElementArrayBuffer;
|
|
23
|
+
private _stateEpoch;
|
|
24
|
+
private _quadIndexBuffer;
|
|
19
25
|
private _currentBlendMode;
|
|
26
|
+
private _currentBlendInTarget;
|
|
27
|
+
private _currentFramebuffer;
|
|
28
|
+
private readonly _renderTargetStack;
|
|
20
29
|
clearColor: OFColor;
|
|
21
30
|
/** Seconds since the framework started, summed from the frames' `dt`. Fills a `: Time` input. */
|
|
22
31
|
elapsedSeconds: number;
|
|
@@ -28,8 +37,27 @@ export declare class OFGraphicDevice {
|
|
|
28
37
|
height: number;
|
|
29
38
|
};
|
|
30
39
|
/** Values by uniform name that fill a `: Shared` input of any shader. A texture takes a unit. */
|
|
40
|
+
/**
|
|
41
|
+
* The shared uniform a shader declares (`uniform float uPremultiplyAlpha : Shared;`) to output
|
|
42
|
+
* premultiplied colour. Textures are straight alpha, and the Multiply and Screen blend functions
|
|
43
|
+
* are the premultiplied ones.
|
|
44
|
+
*/
|
|
45
|
+
static readonly premultiplyUniformName = "uPremultiplyAlpha";
|
|
46
|
+
/** The most quads one draw with quadIndexBuffer() reaches: 4 vertices each, within 16-bit indices. */
|
|
47
|
+
static readonly maxQuadsPerDraw = 16384;
|
|
48
|
+
/** True for the blend modes whose blend function expects premultiplied colour. */
|
|
49
|
+
static premultipliesFor(mode: OFEnumBlendMode): boolean;
|
|
31
50
|
readonly sharedUniforms: Map<string, number | ArrayLike<number> | WebGLTexture>;
|
|
32
51
|
get currentShaderProgram(): WebGLProgram;
|
|
52
|
+
/**
|
|
53
|
+
* Changes on every resetStateCache(). A shader that skips re-sending a uniform value it sent before trusts its
|
|
54
|
+
* copy only while this number is the one the value was sent under.
|
|
55
|
+
*/
|
|
56
|
+
get stateEpoch(): number;
|
|
57
|
+
/** The framebuffer draws go to: null for the canvas, else the bound render target's. */
|
|
58
|
+
get currentFramebuffer(): WebGLFramebuffer | null;
|
|
59
|
+
/** How many render targets are bound, nested; 0 when drawing to the canvas. */
|
|
60
|
+
get renderTargetDepth(): number;
|
|
33
61
|
get hasCustomCamera(): boolean;
|
|
34
62
|
get graphicContext(): WebGLRenderingContext;
|
|
35
63
|
get canvasElement(): HTMLCanvasElement;
|
|
@@ -41,7 +69,28 @@ export declare class OFGraphicDevice {
|
|
|
41
69
|
invalidateConfiguration(): void;
|
|
42
70
|
resize(width: number, height: number, oldWidth: number, oldHeight: number): void;
|
|
43
71
|
useCustomRenderCamera(hasCustomCamera: boolean): void;
|
|
72
|
+
/**
|
|
73
|
+
* Makes `shaderProgram` the context's program, skipping the GL call when it already is. Every program switch in
|
|
74
|
+
* octopus goes through here. A host that calls `useProgram` itself calls resetStateCache() afterwards.
|
|
75
|
+
*
|
|
76
|
+
* Deleting the current program cannot leave this stale: a deleted program is never used again, and any other
|
|
77
|
+
* program is a different object, which always switches.
|
|
78
|
+
*/
|
|
44
79
|
useShaderProgram(shaderProgram: WebGLProgram): void;
|
|
80
|
+
/**
|
|
81
|
+
* Binds `buffer` to `target`, skipping the GL call when ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER already holds it.
|
|
82
|
+
* Every buffer bind in octopus goes through here. A host that binds buffers itself calls resetStateCache()
|
|
83
|
+
* afterwards. Any other target is bound every time.
|
|
84
|
+
*/
|
|
85
|
+
bindBuffer(target: number, buffer: WebGLBuffer | null): void;
|
|
86
|
+
/** Deletes `buffer` and forgets it wherever bindBuffer() recorded it (GL unbinds a buffer it deletes). */
|
|
87
|
+
deleteBuffer(buffer: WebGLBuffer): void;
|
|
88
|
+
/**
|
|
89
|
+
* An index buffer for `OFGraphicDevice.maxQuadsPerDraw` quads, built on first use and shared by every batcher on
|
|
90
|
+
* this device. Quad q is the triangles 4q, 4q+1, 4q+2 and 4q+2, 4q+1, 4q+3: OFSprite's triangle-strip corners.
|
|
91
|
+
* Never deleted. It is left bound to ELEMENT_ARRAY_BUFFER after it is built.
|
|
92
|
+
*/
|
|
93
|
+
quadIndexBuffer(): WebGLBuffer;
|
|
45
94
|
/**
|
|
46
95
|
* Enables blending and sets the blend function for `mode`. Skips every GL call when the mode is
|
|
47
96
|
* the one set last. A host that changes GL blend state itself calls resetStateCache() afterwards.
|
|
@@ -49,7 +98,30 @@ export declare class OFGraphicDevice {
|
|
|
49
98
|
useBlendMode(mode: OFEnumBlendMode): void;
|
|
50
99
|
/** Records the viewport and sets it on the context. */
|
|
51
100
|
setViewport(x: number, y: number, width: number, height: number): void;
|
|
52
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* Makes `framebuffer` the draw target with a viewport of `width` x `height` at 0, 0, and disables the
|
|
103
|
+
* scissor test (a camera's scissor rectangle is in canvas pixels and would clip the target). Remembers the
|
|
104
|
+
* framebuffer, viewport and scissor state it replaces; unbindRenderTarget() restores them. Nests.
|
|
105
|
+
*/
|
|
106
|
+
bindRenderTarget(framebuffer: WebGLFramebuffer, width: number, height: number): void;
|
|
107
|
+
/**
|
|
108
|
+
* Restores what the matching bindRenderTarget() replaced. Does nothing when no target is bound. `framebuffer`
|
|
109
|
+
* is the one being unbound: it must be the most recent bind, or this throws and changes nothing.
|
|
110
|
+
*/
|
|
111
|
+
unbindRenderTarget(framebuffer: WebGLFramebuffer): void;
|
|
112
|
+
/**
|
|
113
|
+
* Binds `framebuffer` (null: the canvas) and records it. For a render target's own setup; drawing into one
|
|
114
|
+
* goes through bindRenderTarget(), which also sets the viewport.
|
|
115
|
+
*/
|
|
116
|
+
bindFramebuffer(framebuffer: WebGLFramebuffer | null): void;
|
|
117
|
+
/**
|
|
118
|
+
* Forgets every GL state the device skips setting when unchanged: the blend mode, the program, the buffers bound to
|
|
119
|
+
* ARRAY_BUFFER and ELEMENT_ARRAY_BUFFER, which vertex attribute arrays are enabled, and (through stateEpoch) the
|
|
120
|
+
* uniform values shaders skip re-sending. The next draw sets each of them again.
|
|
121
|
+
*
|
|
122
|
+
* A host that changes any of that state with its own GL calls (useProgram, bindBuffer, enable or disable of a
|
|
123
|
+
* vertex attribute array, a uniform of an octopus shader's program, the blend function) calls this afterwards.
|
|
124
|
+
*/
|
|
53
125
|
resetStateCache(): void;
|
|
54
126
|
/**
|
|
55
127
|
* Enables the vertex attribute arrays a draw reads, and disables every one an earlier draw
|
|
@@ -59,6 +131,10 @@ export declare class OFGraphicDevice {
|
|
|
59
131
|
* coordinates enabled, pointing at its own vertex buffer. Once the VBO pool deletes that buffer,
|
|
60
132
|
* every later draw that leaves the array enabled fails with INVALID_OPERATION ("no buffer is bound
|
|
61
133
|
* to enabled attribute") and draws nothing. Inactive locations (-1) are skipped.
|
|
134
|
+
*
|
|
135
|
+
* An array this already enabled is not enabled again. After resetStateCache() the next call enables
|
|
136
|
+
* every location it is given, as a host may have disabled one; it still disables everything an
|
|
137
|
+
* earlier call enabled that this one does not read.
|
|
62
138
|
*/
|
|
63
139
|
useVertexAttributes(locations: ReadonlyArray<number>): void;
|
|
64
140
|
clear(): void;
|
|
@@ -6,7 +6,20 @@ const ofShaderFactory_1 = require("../render/shader/ofShaderFactory");
|
|
|
6
6
|
const ofDeviceOptimizationManager_1 = require("./optimization/gpu/ofDeviceOptimizationManager");
|
|
7
7
|
const ofEnumBlendMode_1 = require("../render/shader/ofEnumBlendMode");
|
|
8
8
|
class OFGraphicDevice {
|
|
9
|
+
/** True for the blend modes whose blend function expects premultiplied colour. */
|
|
10
|
+
static premultipliesFor(mode) {
|
|
11
|
+
return mode === ofEnumBlendMode_1.OFEnumBlendMode.Multiply || mode === ofEnumBlendMode_1.OFEnumBlendMode.Screen;
|
|
12
|
+
}
|
|
9
13
|
get currentShaderProgram() { return this._currentShaderProgram; }
|
|
14
|
+
/**
|
|
15
|
+
* Changes on every resetStateCache(). A shader that skips re-sending a uniform value it sent before trusts its
|
|
16
|
+
* copy only while this number is the one the value was sent under.
|
|
17
|
+
*/
|
|
18
|
+
get stateEpoch() { return this._stateEpoch || 0; }
|
|
19
|
+
/** The framebuffer draws go to: null for the canvas, else the bound render target's. */
|
|
20
|
+
get currentFramebuffer() { return this._currentFramebuffer; }
|
|
21
|
+
/** How many render targets are bound, nested; 0 when drawing to the canvas. */
|
|
22
|
+
get renderTargetDepth() { return this._renderTargetStack.length; }
|
|
10
23
|
get hasCustomCamera() { return this._hasCustomCamera; }
|
|
11
24
|
get graphicContext() { return this._graphicContext; }
|
|
12
25
|
get canvasElement() { return this._canvasObject.canvasElement; }
|
|
@@ -15,13 +28,29 @@ class OFGraphicDevice {
|
|
|
15
28
|
get deviceOptimizationManager() { return this._deviceOptimizationManager; }
|
|
16
29
|
constructor(framework) {
|
|
17
30
|
this.framework = framework;
|
|
31
|
+
// Whether _currentShaderProgram is known to be the context's program. False after resetStateCache().
|
|
32
|
+
this._isShaderProgramKnown = false;
|
|
18
33
|
// Vertex attribute arrays are context state, not program state; see useVertexAttributes().
|
|
19
34
|
this._enabledVertexAttributes = new Set();
|
|
35
|
+
// Whether _enabledVertexAttributes is known to be enabled on the context. False after resetStateCache().
|
|
36
|
+
this._areVertexAttributesKnown = false;
|
|
37
|
+
// The buffers bound through bindBuffer(); undefined when unknown, which always binds.
|
|
38
|
+
this._boundArrayBuffer = undefined;
|
|
39
|
+
this._boundElementArrayBuffer = undefined;
|
|
40
|
+
// Counts resetStateCache() calls; a shader's copy of the uniforms it sent is valid while this is unchanged.
|
|
41
|
+
this._stateEpoch = 0;
|
|
42
|
+
// The index buffer pushQuads() batches draw with, built once; see quadIndexBuffer().
|
|
43
|
+
this._quadIndexBuffer = null;
|
|
44
|
+
// Whether that blend mode was set while a render target was bound: Alpha differs there.
|
|
45
|
+
this._currentBlendInTarget = false;
|
|
46
|
+
// The framebuffer bound through bindRenderTarget(); null is the canvas.
|
|
47
|
+
this._currentFramebuffer = null;
|
|
48
|
+
// What bindRenderTarget() replaced, restored by unbindRenderTarget(); nests.
|
|
49
|
+
this._renderTargetStack = [];
|
|
20
50
|
/** Seconds since the framework started, summed from the frames' `dt`. Fills a `: Time` input. */
|
|
21
51
|
this.elapsedSeconds = 0;
|
|
22
52
|
/** The viewport last set through setViewport(), in drawing-buffer pixels. Fills a `: Viewport` input. */
|
|
23
53
|
this.currentViewport = { x: 0, y: 0, width: 0, height: 0 };
|
|
24
|
-
/** Values by uniform name that fill a `: Shared` input of any shader. A texture takes a unit. */
|
|
25
54
|
this.sharedUniforms = new Map();
|
|
26
55
|
this._hasCustomCamera = false;
|
|
27
56
|
this.clearColor = this.framework.settings.renderClearColor;
|
|
@@ -34,6 +63,7 @@ class OFGraphicDevice {
|
|
|
34
63
|
this._renderCamera.initialize(this);
|
|
35
64
|
// configure
|
|
36
65
|
this._currentShaderProgram = 0;
|
|
66
|
+
this._isShaderProgramKnown = false;
|
|
37
67
|
// Create a Shader Factory and Load all the Shaders in the application
|
|
38
68
|
this._shaderFactory = new ofShaderFactory_1.OFShaderFactory(this);
|
|
39
69
|
// Create device optimization managment
|
|
@@ -59,24 +89,103 @@ class OFGraphicDevice {
|
|
|
59
89
|
useCustomRenderCamera(hasCustomCamera) {
|
|
60
90
|
this._hasCustomCamera = hasCustomCamera;
|
|
61
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Makes `shaderProgram` the context's program, skipping the GL call when it already is. Every program switch in
|
|
94
|
+
* octopus goes through here. A host that calls `useProgram` itself calls resetStateCache() afterwards.
|
|
95
|
+
*
|
|
96
|
+
* Deleting the current program cannot leave this stale: a deleted program is never used again, and any other
|
|
97
|
+
* program is a different object, which always switches.
|
|
98
|
+
*/
|
|
62
99
|
useShaderProgram(shaderProgram) {
|
|
63
|
-
|
|
64
|
-
|
|
100
|
+
if (this._isShaderProgramKnown && this._currentShaderProgram === shaderProgram) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
65
103
|
this._currentShaderProgram = shaderProgram;
|
|
66
|
-
|
|
67
|
-
|
|
104
|
+
this._isShaderProgramKnown = true;
|
|
105
|
+
this._graphicContext.useProgram(shaderProgram);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Binds `buffer` to `target`, skipping the GL call when ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER already holds it.
|
|
109
|
+
* Every buffer bind in octopus goes through here. A host that binds buffers itself calls resetStateCache()
|
|
110
|
+
* afterwards. Any other target is bound every time.
|
|
111
|
+
*/
|
|
112
|
+
bindBuffer(target, buffer) {
|
|
113
|
+
const _GL = this._graphicContext;
|
|
114
|
+
if (target === _GL.ARRAY_BUFFER) {
|
|
115
|
+
if (this._boundArrayBuffer === buffer) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
this._boundArrayBuffer = buffer;
|
|
119
|
+
}
|
|
120
|
+
else if (target === _GL.ELEMENT_ARRAY_BUFFER) {
|
|
121
|
+
if (this._boundElementArrayBuffer === buffer) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
this._boundElementArrayBuffer = buffer;
|
|
125
|
+
}
|
|
126
|
+
_GL.bindBuffer(target, buffer);
|
|
127
|
+
}
|
|
128
|
+
/** Deletes `buffer` and forgets it wherever bindBuffer() recorded it (GL unbinds a buffer it deletes). */
|
|
129
|
+
deleteBuffer(buffer) {
|
|
130
|
+
if (!buffer) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (this._boundArrayBuffer === buffer) {
|
|
134
|
+
this._boundArrayBuffer = undefined;
|
|
135
|
+
}
|
|
136
|
+
if (this._boundElementArrayBuffer === buffer) {
|
|
137
|
+
this._boundElementArrayBuffer = undefined;
|
|
138
|
+
}
|
|
139
|
+
this._graphicContext.deleteBuffer(buffer);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* An index buffer for `OFGraphicDevice.maxQuadsPerDraw` quads, built on first use and shared by every batcher on
|
|
143
|
+
* this device. Quad q is the triangles 4q, 4q+1, 4q+2 and 4q+2, 4q+1, 4q+3: OFSprite's triangle-strip corners.
|
|
144
|
+
* Never deleted. It is left bound to ELEMENT_ARRAY_BUFFER after it is built.
|
|
145
|
+
*/
|
|
146
|
+
quadIndexBuffer() {
|
|
147
|
+
if (!this._quadIndexBuffer) {
|
|
148
|
+
const _GL = this._graphicContext;
|
|
149
|
+
const quadCount = OFGraphicDevice.maxQuadsPerDraw;
|
|
150
|
+
const indices = new Uint16Array(quadCount * 6);
|
|
151
|
+
for (let quad = 0, at = 0; quad < quadCount; quad++, at += 6) {
|
|
152
|
+
const first = quad * 4;
|
|
153
|
+
indices[at] = first;
|
|
154
|
+
indices[at + 1] = first + 1;
|
|
155
|
+
indices[at + 2] = first + 2;
|
|
156
|
+
indices[at + 3] = first + 2;
|
|
157
|
+
indices[at + 4] = first + 1;
|
|
158
|
+
indices[at + 5] = first + 3;
|
|
159
|
+
}
|
|
160
|
+
this._quadIndexBuffer = _GL.createBuffer();
|
|
161
|
+
this.bindBuffer(_GL.ELEMENT_ARRAY_BUFFER, this._quadIndexBuffer);
|
|
162
|
+
_GL.bufferData(_GL.ELEMENT_ARRAY_BUFFER, indices, _GL.STATIC_DRAW);
|
|
163
|
+
}
|
|
164
|
+
return this._quadIndexBuffer;
|
|
68
165
|
}
|
|
69
166
|
/**
|
|
70
167
|
* Enables blending and sets the blend function for `mode`. Skips every GL call when the mode is
|
|
71
168
|
* the one set last. A host that changes GL blend state itself calls resetStateCache() afterwards.
|
|
72
169
|
*/
|
|
73
170
|
useBlendMode(mode) {
|
|
74
|
-
|
|
171
|
+
// Set on every call, before the early return: the next draw reads the shared value, not the context.
|
|
172
|
+
this.sharedUniforms.set(OFGraphicDevice.premultiplyUniformName, OFGraphicDevice.premultipliesFor(mode) ? 1 : 0);
|
|
173
|
+
const inTarget = this._renderTargetStack.length > 0;
|
|
174
|
+
if (this._currentBlendMode === mode && this._currentBlendInTarget === inTarget) {
|
|
75
175
|
return;
|
|
76
176
|
}
|
|
77
177
|
const _GL = this._graphicContext;
|
|
78
|
-
|
|
178
|
+
// Replace disables BLEND, and every other mode enables it again: it never relies on the cache.
|
|
179
|
+
if (mode !== ofEnumBlendMode_1.OFEnumBlendMode.Replace) {
|
|
180
|
+
_GL.enable(_GL.BLEND);
|
|
181
|
+
}
|
|
79
182
|
switch (mode) {
|
|
183
|
+
case ofEnumBlendMode_1.OFEnumBlendMode.Replace:
|
|
184
|
+
_GL.disable(_GL.BLEND);
|
|
185
|
+
break;
|
|
186
|
+
case ofEnumBlendMode_1.OFEnumBlendMode.Premultiplied:
|
|
187
|
+
_GL.blendFuncSeparate(_GL.ONE, _GL.ONE_MINUS_SRC_ALPHA, _GL.ONE, _GL.ONE_MINUS_SRC_ALPHA);
|
|
188
|
+
break;
|
|
80
189
|
case ofEnumBlendMode_1.OFEnumBlendMode.Additive:
|
|
81
190
|
_GL.blendFuncSeparate(_GL.SRC_ALPHA, _GL.ONE, _GL.ONE, _GL.ONE_MINUS_SRC_ALPHA);
|
|
82
191
|
break;
|
|
@@ -87,10 +196,18 @@ class OFGraphicDevice {
|
|
|
87
196
|
_GL.blendFuncSeparate(_GL.ONE, _GL.ONE_MINUS_SRC_COLOR, _GL.ONE, _GL.ONE_MINUS_SRC_ALPHA);
|
|
88
197
|
break;
|
|
89
198
|
default:
|
|
90
|
-
|
|
199
|
+
if (inTarget) {
|
|
200
|
+
// Alpha as one blendFunc would also blend the alpha channel (a² + dA(1-a)), wrong for a transparent
|
|
201
|
+
// target. The canvas has no alpha channel to keep right, and keeps the plain call.
|
|
202
|
+
_GL.blendFuncSeparate(_GL.SRC_ALPHA, _GL.ONE_MINUS_SRC_ALPHA, _GL.ONE, _GL.ONE_MINUS_SRC_ALPHA);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
_GL.blendFunc(_GL.SRC_ALPHA, _GL.ONE_MINUS_SRC_ALPHA);
|
|
206
|
+
}
|
|
91
207
|
break;
|
|
92
208
|
}
|
|
93
209
|
this._currentBlendMode = mode;
|
|
210
|
+
this._currentBlendInTarget = inTarget;
|
|
94
211
|
}
|
|
95
212
|
/** Records the viewport and sets it on the context. */
|
|
96
213
|
setViewport(x, y, width, height) {
|
|
@@ -101,9 +218,72 @@ class OFGraphicDevice {
|
|
|
101
218
|
viewport.height = height;
|
|
102
219
|
this._graphicContext.viewport(x, y, width, height);
|
|
103
220
|
}
|
|
104
|
-
/**
|
|
221
|
+
/**
|
|
222
|
+
* Makes `framebuffer` the draw target with a viewport of `width` x `height` at 0, 0, and disables the
|
|
223
|
+
* scissor test (a camera's scissor rectangle is in canvas pixels and would clip the target). Remembers the
|
|
224
|
+
* framebuffer, viewport and scissor state it replaces; unbindRenderTarget() restores them. Nests.
|
|
225
|
+
*/
|
|
226
|
+
bindRenderTarget(framebuffer, width, height) {
|
|
227
|
+
const _GL = this._graphicContext;
|
|
228
|
+
const viewport = this.currentViewport;
|
|
229
|
+
this._renderTargetStack.push({
|
|
230
|
+
bound: framebuffer,
|
|
231
|
+
framebuffer: this._currentFramebuffer,
|
|
232
|
+
viewport: { x: viewport.x, y: viewport.y, width: viewport.width, height: viewport.height },
|
|
233
|
+
scissor: !!_GL.isEnabled(_GL.SCISSOR_TEST)
|
|
234
|
+
});
|
|
235
|
+
this.bindFramebuffer(framebuffer);
|
|
236
|
+
_GL.disable(_GL.SCISSOR_TEST);
|
|
237
|
+
this.setViewport(0, 0, width, height);
|
|
238
|
+
// Alpha blends differently in a target; see useBlendMode().
|
|
239
|
+
this.resetStateCache();
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Restores what the matching bindRenderTarget() replaced. Does nothing when no target is bound. `framebuffer`
|
|
243
|
+
* is the one being unbound: it must be the most recent bind, or this throws and changes nothing.
|
|
244
|
+
*/
|
|
245
|
+
unbindRenderTarget(framebuffer) {
|
|
246
|
+
const stack = this._renderTargetStack;
|
|
247
|
+
if (stack.length === 0) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (stack[stack.length - 1].bound !== framebuffer) {
|
|
251
|
+
throw new Error('OFGraphicDevice.unbindRenderTarget: render targets must be unbound in reverse order.');
|
|
252
|
+
}
|
|
253
|
+
const previous = stack.pop();
|
|
254
|
+
const _GL = this._graphicContext;
|
|
255
|
+
const viewport = previous.viewport;
|
|
256
|
+
this.bindFramebuffer(previous.framebuffer);
|
|
257
|
+
this.setViewport(viewport.x, viewport.y, viewport.width, viewport.height);
|
|
258
|
+
if (previous.scissor) {
|
|
259
|
+
_GL.enable(_GL.SCISSOR_TEST);
|
|
260
|
+
}
|
|
261
|
+
this.resetStateCache();
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Binds `framebuffer` (null: the canvas) and records it. For a render target's own setup; drawing into one
|
|
265
|
+
* goes through bindRenderTarget(), which also sets the viewport.
|
|
266
|
+
*/
|
|
267
|
+
bindFramebuffer(framebuffer) {
|
|
268
|
+
const _GL = this._graphicContext;
|
|
269
|
+
this._currentFramebuffer = framebuffer;
|
|
270
|
+
_GL.bindFramebuffer(_GL.FRAMEBUFFER, framebuffer);
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Forgets every GL state the device skips setting when unchanged: the blend mode, the program, the buffers bound to
|
|
274
|
+
* ARRAY_BUFFER and ELEMENT_ARRAY_BUFFER, which vertex attribute arrays are enabled, and (through stateEpoch) the
|
|
275
|
+
* uniform values shaders skip re-sending. The next draw sets each of them again.
|
|
276
|
+
*
|
|
277
|
+
* A host that changes any of that state with its own GL calls (useProgram, bindBuffer, enable or disable of a
|
|
278
|
+
* vertex attribute array, a uniform of an octopus shader's program, the blend function) calls this afterwards.
|
|
279
|
+
*/
|
|
105
280
|
resetStateCache() {
|
|
106
281
|
this._currentBlendMode = undefined;
|
|
282
|
+
this._isShaderProgramKnown = false;
|
|
283
|
+
this._boundArrayBuffer = undefined;
|
|
284
|
+
this._boundElementArrayBuffer = undefined;
|
|
285
|
+
this._areVertexAttributesKnown = false;
|
|
286
|
+
this._stateEpoch = (this._stateEpoch || 0) + 1;
|
|
107
287
|
}
|
|
108
288
|
/**
|
|
109
289
|
* Enables the vertex attribute arrays a draw reads, and disables every one an earlier draw
|
|
@@ -113,22 +293,28 @@ class OFGraphicDevice {
|
|
|
113
293
|
* coordinates enabled, pointing at its own vertex buffer. Once the VBO pool deletes that buffer,
|
|
114
294
|
* every later draw that leaves the array enabled fails with INVALID_OPERATION ("no buffer is bound
|
|
115
295
|
* to enabled attribute") and draws nothing. Inactive locations (-1) are skipped.
|
|
296
|
+
*
|
|
297
|
+
* An array this already enabled is not enabled again. After resetStateCache() the next call enables
|
|
298
|
+
* every location it is given, as a host may have disabled one; it still disables everything an
|
|
299
|
+
* earlier call enabled that this one does not read.
|
|
116
300
|
*/
|
|
117
301
|
useVertexAttributes(locations) {
|
|
118
302
|
const _GL = this._graphicContext;
|
|
119
|
-
this._enabledVertexAttributes
|
|
303
|
+
const enabled = this._enabledVertexAttributes;
|
|
304
|
+
const known = this._areVertexAttributesKnown;
|
|
305
|
+
enabled.forEach((location) => {
|
|
120
306
|
if (locations.indexOf(location) < 0) {
|
|
121
307
|
_GL.disableVertexAttribArray(location);
|
|
122
|
-
|
|
308
|
+
enabled.delete(location);
|
|
123
309
|
}
|
|
124
310
|
});
|
|
125
|
-
// Enabled on every draw, not only when new: cheap, and right even if a host changed the state.
|
|
126
311
|
for (const location of locations) {
|
|
127
|
-
if (location >= 0) {
|
|
312
|
+
if (location >= 0 && (!known || !enabled.has(location))) {
|
|
128
313
|
_GL.enableVertexAttribArray(location);
|
|
129
|
-
|
|
314
|
+
enabled.add(location);
|
|
130
315
|
}
|
|
131
316
|
}
|
|
317
|
+
this._areVertexAttributesKnown = true;
|
|
132
318
|
}
|
|
133
319
|
clear() {
|
|
134
320
|
const _GL = this._graphicContext;
|
|
@@ -146,4 +332,13 @@ class OFGraphicDevice {
|
|
|
146
332
|
}
|
|
147
333
|
}
|
|
148
334
|
exports.OFGraphicDevice = OFGraphicDevice;
|
|
335
|
+
/** Values by uniform name that fill a `: Shared` input of any shader. A texture takes a unit. */
|
|
336
|
+
/**
|
|
337
|
+
* The shared uniform a shader declares (`uniform float uPremultiplyAlpha : Shared;`) to output
|
|
338
|
+
* premultiplied colour. Textures are straight alpha, and the Multiply and Screen blend functions
|
|
339
|
+
* are the premultiplied ones.
|
|
340
|
+
*/
|
|
341
|
+
OFGraphicDevice.premultiplyUniformName = 'uPremultiplyAlpha';
|
|
342
|
+
/** The most quads one draw with quadIndexBuffer() reaches: 4 vertices each, within 16-bit indices. */
|
|
343
|
+
OFGraphicDevice.maxQuadsPerDraw = 16384;
|
|
149
344
|
//# sourceMappingURL=ofGraphicDevice.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ofGraphicDevice.js","sourceRoot":"","sources":["../../../../../../../src/shute-technologies/modules/framework/core/device/ofGraphicDevice.ts"],"names":[],"mappings":";;;AACA,oEAAiE;AAEjE,sEAAmE;AACnE,gGAA6F;AAG7F,sEAAmE;
|
|
1
|
+
{"version":3,"file":"ofGraphicDevice.js","sourceRoot":"","sources":["../../../../../../../src/shute-technologies/modules/framework/core/device/ofGraphicDevice.ts"],"names":[],"mappings":";;;AACA,oEAAiE;AAEjE,sEAAmE;AACnE,gGAA6F;AAG7F,sEAAmE;AAUnE,MAAa,eAAe;IAgD1B,kFAAkF;IAClF,MAAM,CAAC,gBAAgB,CAAC,IAAqB;QAC3C,OAAO,IAAI,KAAK,iCAAe,CAAC,QAAQ,IAAI,IAAI,KAAK,iCAAe,CAAC,MAAM,CAAC;IAC9E,CAAC;IAID,IAAI,oBAAoB,KAAmB,OAAO,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAC/E;;;OAGG;IACH,IAAI,UAAU,KAAa,OAAO,IAAI,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC,CAAC;IAC1D,wFAAwF;IACxF,IAAI,kBAAkB,KAA8B,OAAO,IAAI,CAA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
|
package/lib/src/shute-technologies/modules/framework/core/device/optimization/gpu/ofVBOObject.js
CHANGED
|
@@ -36,7 +36,8 @@ class OFVBOObject {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
destroy() {
|
|
39
|
-
|
|
39
|
+
// Through the device, so a buffer it recorded as bound is not taken for bound after it is gone.
|
|
40
|
+
this._vboPooler.graphicDeviceOptManager.graphicDevice.deleteBuffer(this.vbo);
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
exports.OFVBOObject = OFVBOObject;
|
package/lib/src/shute-technologies/modules/framework/core/device/optimization/gpu/ofVBOObject.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ofVBOObject.js","sourceRoot":"","sources":["../../../../../../../../../src/shute-technologies/modules/framework/core/device/optimization/gpu/ofVBOObject.ts"],"names":[],"mappings":";;;AACA,+DAA4D;AAG5D,MAAa,WAAW;IAatB,IAAI,EAAE,KAAc,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAC5C,IAAI,WAAW,KAAe,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEzD,YAA6B,UAAuB;QAAvB,eAAU,GAAV,UAAU,CAAa;QAClD,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC,mBAAmB,CAAC;QACjD,IAAI,CAAC,UAAU,GAAG,yCAAmB,CAAC,QAAQ,CAAC;QAC/C,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,uBAAuB,CAAC,aAAa,CAAC,cAAc,CAAC;IAC7E,CAAC;IAED,UAAU,CAAC,EAAU;QACnB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;IACrC,CAAC;IAED,QAAQ,CAAE,UAA+B;QACvC,IAAI,IAAI,CAAC,UAAU,KAAK,yCAAmB,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACxE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;SAC9B;QAED,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC5B,CAAC;IAED,UAAU;QACR,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,iBAAiB;QACjB,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC,mBAAmB,CAAC;IACnD,CAAC;IAED,MAAM,CAAE,IAAmB;QACzB,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,EAAE,CAAC;YAE1B,IAAI,IAAI,CAAC,SAAS,IAAI,CAAC,EAAE;gBACvB,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;aAChC;SACF;IACH,CAAC;IAED,OAAO;QACL,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"ofVBOObject.js","sourceRoot":"","sources":["../../../../../../../../../src/shute-technologies/modules/framework/core/device/optimization/gpu/ofVBOObject.ts"],"names":[],"mappings":";;;AACA,+DAA4D;AAG5D,MAAa,WAAW;IAatB,IAAI,EAAE,KAAc,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAC5C,IAAI,WAAW,KAAe,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEzD,YAA6B,UAAuB;QAAvB,eAAU,GAAV,UAAU,CAAa;QAClD,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC,mBAAmB,CAAC;QACjD,IAAI,CAAC,UAAU,GAAG,yCAAmB,CAAC,QAAQ,CAAC;QAC/C,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,uBAAuB,CAAC,aAAa,CAAC,cAAc,CAAC;IAC7E,CAAC;IAED,UAAU,CAAC,EAAU;QACnB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;IACrC,CAAC;IAED,QAAQ,CAAE,UAA+B;QACvC,IAAI,IAAI,CAAC,UAAU,KAAK,yCAAmB,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACxE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;SAC9B;QAED,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC5B,CAAC;IAED,UAAU;QACR,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,iBAAiB;QACjB,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC,mBAAmB,CAAC;IACnD,CAAC;IAED,MAAM,CAAE,IAAmB;QACzB,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,EAAE,CAAC;YAE1B,IAAI,IAAI,CAAC,SAAS,IAAI,CAAC,EAAE;gBACvB,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;aAChC;SACF;IACH,CAAC;IAED,OAAO;QACL,gGAAgG;QAChG,IAAI,CAAC,UAAU,CAAC,uBAAuB,CAAC,aAAa,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/E,CAAC;;AAvDH,kCAwDC;AAtDiB,+BAAmB,GAAG,MAAM,GAAG,MAAM,CAAC"}
|
|
@@ -88,13 +88,13 @@ class OFRenderCamera {
|
|
|
88
88
|
// Change Viewport
|
|
89
89
|
this._viewport.width = width;
|
|
90
90
|
this._viewport.height = height;
|
|
91
|
-
this.
|
|
91
|
+
this._graphicDevice.setViewport(this._viewport.x, this._viewport.y, this._viewport.width, this._viewport.height);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
invalidateConfiguration() {
|
|
95
95
|
const _GL = this._graphicContext;
|
|
96
96
|
// Viewport
|
|
97
|
-
this.
|
|
97
|
+
this._graphicDevice.setViewport(this._viewport.x, this._viewport.y, this._viewport.width, this._viewport.height);
|
|
98
98
|
// Set the scissor rectangle.
|
|
99
99
|
_GL.scissor(this._viewport.x, this._viewport.y, this._viewport.width * this._width, this._viewport.height * this._height);
|
|
100
100
|
}
|