Merge pull request #6 from YunHsiao/gfx

pass refactor
This commit is contained in:
Weiliang Wang
2019-01-02 18:40:32 +08:00
committed by GitHub
45 changed files with 747 additions and 675 deletions
+19 -19
View File
@@ -1,7 +1,7 @@
ChangeLog:
Cocos2d-x v3.8 @ September.6 2015
[NEW] spine: Supported Spine runtime 2.3 (Both native and web engine)
[NEW] Animate: Added Animate's getCurrentFrameIndex function
[NEW] network: Upgrade SocketIO support to v1.x
@@ -58,9 +58,9 @@ Cocos2d-x v3.7.1 @ August.12 2015
Cocos2d-x v3.7 Final @ July 20 2015
[REFINE] web: Add compatible Uint16Array defintion
[FIX] web: Fixed url check regular expression not supporting localhost issue
[FIX] web: Fixed issue that sprite doesn't update texture rect correctly
[FIX] web: Fixed issue that sprite doesn't update texture rect correctly
Cocos2d-x v3.7 RC1 @ July 14 2015
[REFINE] Improved localStorage warning when disabled
@@ -181,9 +181,9 @@ Cocos2d-JS v3.5 @ April 1 2015
* Replaced '==' with '===' for better performance.
* Added `path` parameter in `ccs.load` to support modifying cocostudio project resource path.
* Added animationList to Cocostudio ActionTimeline to support playing animation by name.
* Made ParticleSystem support creation from an map object.
* Made ParticleSystem support creation from an map object.
* Added missing functions to `cc.Grid3D` and `cc.PageTurn3D`.
* Added tip message functions to `cc.TextFieldTTF` for mobile browser.
* Added tip message functions to `cc.TextFieldTTF` for mobile browser.
* Added a function `cc.sys.openURL`.
* Disabled retina display by default for better performance.
* Added Bower support.
@@ -192,15 +192,15 @@ Cocos2d-JS v3.5 @ April 1 2015
* Bug fixes:
1. Fixed a bug of chipmunk.js that it doesn't work under closure compiler advanced mode.
2. Fixed a bug of Cocos Studio parser that widget didn't set its layout component.
3. Fixed grammatical mistakes in cocostudio parser logs.
3. Fixed grammatical mistakes in cocostudio parser logs.
4. Fixed memory leak issue in `cc.LabelBMFont`.
5. Fixed a bug of `cc.Scale9Sprite` that its `updateDisplayColor` doesn't take effect.
6. Fixed a bug of Cocos Studio parser that `cc.Scale9Sprite` doesn't display correctly if its texture isn't preloaded.
7. Fixed a bug of `cc.MenuItemSprite` that the construction will fail when parameter `selectedSprite` is a Scale9Sprite instance.
7. Fixed a bug of `cc.MenuItemSprite` that the construction will fail when parameter `selectedSprite` is a Scale9Sprite instance.
8. Fixed a bug of Cocos Studio parser that the background color of `ccui.Layout` can't be parsed correctly.
9. Fixed a bug of `cc.ClippingNode` that it doesn't work when set `inverted` to true in Canvas Mode.
10. Fixed a bug of `ccs.Armature` that its name was modified to animation name when loading from json files.
11. Fixed a bug of `ccui.PageView` that it cancel child touch during movment of page view.
11. Fixed a bug of `ccui.PageView` that it cancel child touch during movment of page view.
12. Fixed a bug of `cc.Scheduler` that its parameter `repeat` is invalid in schedule function.
13. Fixed a bug of `cc.Scheduler` that `unschedule` function may fail.
@@ -225,19 +225,19 @@ Cocos2d-JS v3.4 Beta0 @ March 19 2015
1. Added `getSpriteFrame` to `cc.Sprite` to fix API inconsistency.
2. Added `getObject` to `cc.TMXObjectGroup` to fix API inconsistency.
3. Added `addImageAsync` to `cc.textureCache` to fix API inconsistency.
4. Fixed a bug of `cc.text` that its default font name is incorrect.
4. Fixed a bug of `cc.text` that its default font name is incorrect.
5. Fixed a bug of `ccui.PageView` that its `getPage` doesn't work.
6. Fixed a bug of `ccui.ImageView` that its `loadTexture` doesn't work while it's invoked multiple times at the same frame.
7. Fixed a bug of `ccui` that its load event callbacks have some mistakes.
8. Fixed a bug of `cc.Layer` that its bake function doesn't work when the layer has a parent node.
9. Fixed typos in `cc.ClippingNode.WebGLRenderCmd` and `cc.ParticleSystem.WebGLRenderCmd` creation.
10. Fixed a bug of `cc.Sprite` in `setTextureRect`.
10. Fixed a bug of `cc.Sprite` in `setTextureRect`.
11. Fixed a bug of `cc.Screen`.
12. Fixed a bug of `cc.view` that it doesn't work on iOS 8.1.2.
13. Fixed a bug of cc.DrawNode that its lineWidth is always to default value when set linewidth to zero.
14. Fixed a bug in hack for particles performance on canvas.
13. Fixed a bug of cc.DrawNode that its lineWidth is always to default value when set linewidth to zero.
14. Fixed a bug in hack for particles performance on canvas.
15. Fixed a bug of `cc.audioEngine` that it doesn't work after minified/compiled.
16. Fixed a bug in `CCBoot.js` that WebGL is not activated in web view of iOS 8.
16. Fixed a bug in `CCBoot.js` that WebGL is not activated in web view of iOS 8.
17. Fixed a bug of `cc.CheckBox` that its position is incorrect when its texture isn't preloaded.
18. Fixed a bug of `cc.TMXLayer` that it stops to work after `setTileGID` called.
19. Fixed a bug of Cocos parser 2.x that it doesn't set widget's LayoutComponent.
@@ -247,16 +247,16 @@ Cocos2d-JS v3.3 @ Feb.9, 2015
* Upgraded spine runtime to support the latest version and updated its test case.
* Added an option "noCache" for debugging on browsers.
* Set the default value of `cc.ParticleSystem`'s draw mode to texture mode.
* Set the default value of `cc.ParticleSystem`'s draw mode to texture mode.
* Added message to `ccs.load` when loading armature json file.
* Improved particle system test case.
* Bug fixes:
1. Fixed a bug of `cc.Sprite` that its `setSpriteFrame` doesn't work when sprite frame's `rotated` property is true.
1. Fixed a bug of `cc.Sprite` that its `setSpriteFrame` doesn't work when sprite frame's `rotated` property is true.
2. Fixed a bug of `cc.ClippingNode` when its stencil is `cc.Node` object in canvas mode.
3. Fixed a ccui bug that the position of widgets is incorrect after loaded v2.x json file with `ccs.load`.
4. Fixed a bug of `cc.PhysicsSprite` that `setIgnoreBodyRotation` function doesn't work.
5. Fixed a bug of `ccui.Button` that setting pressed texture doesn't work when scale9 enabled.
4. Fixed a bug of `cc.PhysicsSprite` that `setIgnoreBodyRotation` function doesn't work.
5. Fixed a bug of `ccui.Button` that setting pressed texture doesn't work when scale9 enabled.
6. Fixed a bug of `ccui.ScrollView` that its `dir` property is null when passing `DIR_NONE` as `direction` in `_endRecordSlidAction` function.
Cocos2d-JS v3.3 RC0 @ Feb.1, 2015
@@ -309,7 +309,7 @@ Cocos2d-JS v3.3 Beta @ Jan.24, 2015
9. Fixed a bug of `cc.audioEngine` that its loading path is incorrect.
10. Fixed a bug of `ccui.Widget` that it can't touch when it's reused.
11. Fixed a bug of UI system that the `setNormalizedPosition` doesn't work.
12. Fixed a bug of `cc.ActionInterval` that its `_times` conflict with `cc.Blink`.
12. Fixed a bug of `cc.ActionInterval` that its `_times` conflict with `cc.Blink`.
13. Fixed release texture issue in canvas mode.
14. Fixed a bug of `ccs.actionManager` that its `getActionByName` doesn't work.
15. Fixed a bug of `cc.Sprite` that it can't draw without texture on WebGL mode.
@@ -656,7 +656,7 @@ Cocos2d-html5-v3.0 alpha @ March.15, 2014
* Replace `replaceWithScene` and `runWithScene` with `runScene`.
* move sys.xxx to cc.sys.xxx.
* Refactor CCEGLView.js for better maintainability.
* Refactor CCScheduler.js for better maintainability.
* Refactor scheduler.js for better maintainability.
* Remove arguments.callee which is forbidden in ECMAScript strict mode.
* Refactor Array clean function for better performance.
* Refactor some functions about array operation.
+1 -1
View File
@@ -276,7 +276,7 @@ warning: you CANNOT change update priority in scheduled function
### 1507
CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: %.4f to %.4f
scheduler#scheduleSelector. Selector already scheduled. Updating interval from: %.4f to %.4f
### 1508
-46
View File
@@ -1,46 +0,0 @@
import Asset from "../../assets/CCAsset";
import { property, ccclass } from "../../core/data/class-decorator";
@ccclass('cc.EffectAsset')
class EffectAsset extends Asset {
@property
techniques = [];
@property
properties = {};
@property
shaders = [];
onLoaded() {
let lib = cc.game._renderer._programLib;
this.shaders.forEach(s => lib.define(s));
EffectAsset.register(this);
}
}
let effects = EffectAsset._effects = {};
EffectAsset.register = function(asset) {
effects[asset.name] = asset;
};
EffectAsset.remove = function(name) {
if (effects[name]) { delete effects[name]; return; }
for (let n in effects) {
if (effects[n]._uuid === name) {
delete effects[n];
return;
}
}
};
EffectAsset.get = function(name) {
if (effects[name]) return effects[name];
for (let n in effects)
if (effects[n]._uuid === name)
return effects[n];
};
EffectAsset.getAll = function() {
return effects;
};
export default EffectAsset;
cc.EffectAsset = EffectAsset;
+92
View File
@@ -0,0 +1,92 @@
import Asset from '../../assets/CCAsset';
import { ccclass, property } from '../../core/data/class-decorator';
import { PassInfo } from '../../renderer/core/pass';
const effects: { [name: string]: EffectAsset } = {};
interface TechniqueInfo {
passes: PassInfo[];
queue?: number;
priority?: number;
lod?: number;
}
interface PropertyMap {
[name: string]: {
type: number,
value: number | number[] | null,
};
}
interface ShaderInfo {
name: string;
vert: string; frag: string;
vert1: string; frag1: string;
defines: Array<{
name: string;
type: string;
defines: string[];
}>;
uniforms: Array<{
name: string;
type: string;
binding: number;
defines: string[];
} | {
blockName: string;
binding: number;
defines: string[];
members: Array< { name: string, type: number } >
}>;
attributes: Array<{
name: string;
type: string;
defines: string[];
}>;
extensions: Array<{
name: string;
define: string;
}>;
}
@ccclass('cc.EffectAsset')
class EffectAsset extends Asset {
public static register(asset: EffectAsset) {effects[asset.name] = asset; }
public static remove(name: string) {
if (effects[name]) { delete effects[name]; return; }
for (const n in effects) {
if (effects[n]._uuid === name) {
delete effects[n];
return;
}
}
}
public static get(name: string) {
if (effects[name]) { return effects[name]; }
for (const n in effects) {
if (effects[n]._uuid === name) {
return effects[n];
}
}
}
public static getAll() { return effects; }
protected static _effects: { [name: string]: EffectAsset } = {};
@property
public techniques: TechniqueInfo[] = [];
@property
public properties: PropertyMap = {};
@property
public shaders: ShaderInfo[] = [];
public onLoaded() {
const lib = cc.game._renderer._programLib;
this.shaders.forEach((s) => lib.define(s));
EffectAsset.register(this);
}
}
export default EffectAsset;
cc.EffectAsset = EffectAsset;
+2 -2
View File
@@ -6,7 +6,7 @@ export default [
"shaders": [
{
"name": "aa204b4f36b7a4b0c9e10806d01c41a2dcdfba410236f788b8f97fc9",
"vert": "\nattribute vec3 a_position;\nuniform mat4 _model;\nuniform mat4 _viewProj;\n#if USE_TEXTURE\n attribute vec2 a_uv0;\n uniform vec2 mainTiling;\n uniform vec2 mainOffset;\n varying vec2 uv0;\n#endif\n#if USE_SKINNING\n \nattribute vec4 a_weights;\nattribute vec4 a_joints;\n#if USE_JOINTS_TEXTURE\nuniform sampler2D _u_jointsTexture;\nuniform float _u_jointsTextureSize;\nmat4 getBoneMatrix(const in float i) {\n float size = _u_jointsTextureSize;\n float j = i * 4.0;\n float x = mod(j, size);\n float y = floor(j / size);\n float dx = 1.0 / size;\n float dy = 1.0 / size;\n y = dy * (y + 0.5);\n vec4 v1 = texture2D(_u_jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture2D(_u_jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture2D(_u_jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture2D(_u_jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n}\n#else\nuniform mat4 _u_jointMatrices[128];\nmat4 getBoneMatrix(const in float i) {\n return _u_jointMatrices[int(i)];\n}\n#endif\nmat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n}\n#endif\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n #if USE_SKINNING\n pos = skinMatrix() * pos;\n #endif\n pos = _viewProj * _model * pos;\n #if USE_TEXTURE\n uv0 = a_uv0 * mainTiling + mainOffset;\n #endif\n return pos;\n}\nvoid main() { gl_Position = vert(); }\n",
"vert": "\nattribute vec3 a_position;\nuniform mat4 _model;\nuniform mat4 _viewProj;\n#if USE_TEXTURE\n attribute vec2 a_texCoord1;\n uniform vec2 mainTiling;\n uniform vec2 mainOffset;\n varying vec2 uv0;\n#endif\n#if USE_SKINNING\n \nattribute vec4 a_weights;\nattribute vec4 a_joints;\n#if USE_JOINTS_TEXTURE\nuniform sampler2D _u_jointsTexture;\nuniform float _u_jointsTextureSize;\nmat4 getBoneMatrix(const in float i) {\n float size = _u_jointsTextureSize;\n float j = i * 4.0;\n float x = mod(j, size);\n float y = floor(j / size);\n float dx = 1.0 / size;\n float dy = 1.0 / size;\n y = dy * (y + 0.5);\n vec4 v1 = texture2D(_u_jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture2D(_u_jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture2D(_u_jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture2D(_u_jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n}\n#else\nuniform mat4 _u_jointMatrices[128];\nmat4 getBoneMatrix(const in float i) {\n return _u_jointMatrices[int(i)];\n}\n#endif\nmat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n}\n#endif\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n #if USE_SKINNING\n pos = skinMatrix() * pos;\n #endif\n pos = _viewProj * _model * pos;\n #if USE_TEXTURE\n uv0 = a_texCoord1 * mainTiling + mainOffset;\n #endif\n return pos;\n}\nvoid main() { gl_Position = vert(); }\n",
"frag": "\n#if USE_TEXTURE\n uniform sampler2D mainTexture;\n varying vec2 uv0;\n#endif\n#if USE_COLOR\n uniform vec4 color;\n#endif\nvec4 frag () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n o *= texture2D(mainTexture, uv0);\n #endif\n #if USE_COLOR\n o *= color;\n #endif\n return o;\n}\nvoid main() { gl_FragColor = frag(); }\n",
"defines": [
{"name": "USE_TEXTURE", "type": "boolean"},
@@ -22,7 +22,7 @@ export default [
],
"attributes": [
{"name": "a_position", "type": 6, "defines": []},
{"name": "a_uv0", "type": 5, "defines": ["USE_TEXTURE"]},
{"name": "a_texCoord1", "type": 5, "defines": ["USE_TEXTURE"]},
{"name": "a_weights", "type": 7, "defines": ["USE_SKINNING"]},
{"name": "a_joints", "type": 7, "defines": ["USE_SKINNING"]}
],
+1 -1
View File
@@ -24,7 +24,7 @@
THE SOFTWARE.
****************************************************************************/
import game from '../core/CCGame';
import game from '../core/game';
import AffineTrans from '../core/value-types/affine-transform';
import mat4 from '../core/vmath/mat4';
import vec2 from '../core/vmath/vec2';
@@ -28,8 +28,8 @@
import EventTarget from './event/event-target';
import eventManager from './platform/event-manager/CCEventManager';
import ccobject from './data/object';
import game from './CCGame';
import Scheduler from './CCScheduler';
import game from './game';
import Scheduler from './scheduler';
import { autoRelease } from '../load-pipeline/auto-release-utils';
import ComponentScheduler from '../scene-graph/component-scheduler';
import NodeActivator from '../scene-graph/node-activator';
@@ -229,7 +229,7 @@ class Director extends EventTarget {
* !#en
* Converts a view coordinate to an WebGL coordinate<br/>
* Useful to convert (multi) touches coordinates to the current layout (portrait or landscape)<br/>
* Implementation can be found in CCDirectorWebGL.
* Implementation can be found in directorWebGL.
* !#zh 将触摸点的屏幕坐标转换为 WebGL View 下的坐标。
* @method convertToGL
* @param {Vec2} uiPoint
@@ -251,7 +251,7 @@ class Director extends EventTarget {
* !#en
* Converts an OpenGL coordinate to a view coordinate<br/>
* Useful to convert node points to window points for calls such as glScissor<br/>
* Implementation can be found in CCDirectorWebGL.
* Implementation can be found in directorWebGL.
* !#zh 将触摸点的 WebGL View 坐标转换为屏幕坐标。
* @method convertToUI
* @param {Vec2} glPoint
@@ -680,7 +680,7 @@ class Director extends EventTarget {
/**
* !#en
* Enables or disables WebGL depth test.<br/>
* Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js
* Implementation can be found in directorCanvas.js/directorWebGL.js
* !#zh 启用/禁用深度测试(在 Canvas 渲染模式下不会生效)。
* @method setDepthTest
* @param {Boolean} on
@@ -696,7 +696,7 @@ class Director extends EventTarget {
/**
* !#en
* Set color for clear screen.<br/>
* (Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js)
* (Implementation can be found in directorCanvas.js/directorWebGL.js)
* !#zh
* 设置场景的默认擦除颜色。<br/>
* 支持全透明,但不支持透明度为中间值。要支持全透明需手工开启 cc.macro.ENABLE_TRANSPARENT_CANVAS。
+1 -2
View File
@@ -30,7 +30,6 @@ import debug from './platform/CCDebug';
import { addon } from './utils/js';
import renderer from '../renderer';
import '../gfx';
import builtinResMgr from '../3d/builtin/init';
/**
@@ -793,7 +792,7 @@ var game = {
// renderer.initWebGL(localCanvas, opts);
// this._renderContext = renderer.device._gl;
}
if (!this._gfxDevice) {
//if (!this._renderContext) {
+3 -3
View File
@@ -33,6 +33,6 @@ import './data';
import './event';
import './platform';
import './value-types';
import './CCGame';
import './CCScheduler';
import './CCDirector';
import './game';
import './scheduler';
import './director';
+9 -9
View File
@@ -28,7 +28,7 @@
import EventTarget from '../event/event-target';
import '../data/class';
import macro from '../platform/CCMacro';
import game from '../CCGame';
import game from '../game';
import Size from '../value-types/size';
import Rect from '../value-types/rect';
@@ -166,7 +166,7 @@ class View extends EventTarget {
init () {
__BrowserGetter.init(this);
this._initFrameSize();
this.enableAntiAlias(true);
@@ -303,9 +303,9 @@ class View extends EventTarget {
/**
* !#en
* Sets the orientation of the game, it can be landscape, portrait or auto.
* When set it to landscape or portrait, and screen w/h ratio doesn't fit,
* When set it to landscape or portrait, and screen w/h ratio doesn't fit,
* cc.view will automatically rotate the game canvas using CSS.
* Note that this function doesn't have any effect in native,
* Note that this function doesn't have any effect in native,
* in native, you need to set the application orientation in native project settings
* !#zh 设置游戏屏幕朝向,它能够是横版,竖版或自动。
* 当设置为横版或竖版,并且屏幕的宽高比例不匹配时,
@@ -331,7 +331,7 @@ class View extends EventTarget {
var isLandscape = w >= h;
if (CC_EDITOR || !cc.sys.isMobile ||
(isLandscape && this._orientation & macro.ORIENTATION_LANDSCAPE) ||
(isLandscape && this._orientation & macro.ORIENTATION_LANDSCAPE) ||
(!isLandscape && this._orientation & macro.ORIENTATION_PORTRAIT)) {
locFrameSize.width = w;
locFrameSize.height = h;
@@ -514,9 +514,9 @@ class View extends EventTarget {
* @param {Boolean} enabled - Enable or disable auto full screen on mobile devices
*/
enableAutoFullScreen(enabled) {
if (enabled &&
enabled !== this._autoFullScreen &&
cc.sys.isMobile &&
if (enabled &&
enabled !== this._autoFullScreen &&
cc.sys.isMobile &&
cc.sys.browserType !== cc.sys.BROWSER_TYPE_WECHAT) {
// Automatically full screen when user touches on mobile version
this._autoFullScreen = true;
@@ -1486,4 +1486,4 @@ let view = cc.view = new View();
*/
cc.winSize = cc.v2();
export default view;
export default view;
@@ -299,7 +299,7 @@ class Scheduler {
this._arrayForTimers = []; // Speed up indexing
//this._arrayForUpdates = []; // Speed up indexing
}
//-----------------------private method----------------------
_removeHashElement (element) {
delete this._hashForTimers[element.target._id];
@@ -509,7 +509,7 @@ class Scheduler {
* @param {Number} [repeat=cc.macro.REPEAT_FOREVER]
* @param {Number} [delay=0]
* @param {Boolean} paused
* @example {@link cocos2d/core/CCScheduler/schedule.js}
* @example {@link cocos2d/core/scheduler/schedule.js}
* @typescript
* schedule(callback: Function, target: any, interval: number, repeat: number, delay: number, paused?: boolean): void
* schedule(callback: Function, target: any, interval: number, paused?: boolean): void
@@ -694,7 +694,7 @@ class Scheduler {
}
}
/**
/**
* !#en Unschedules the update callback for a given target.
* !#zh 取消指定对象的 update 定时器。
* @method unscheduleUpdate
@@ -724,7 +724,7 @@ class Scheduler {
}
}
/**
/**
* !#en
* Unschedules all scheduled callbacks for a given target.
* This also includes the "update" callback.
@@ -752,7 +752,7 @@ class Scheduler {
var element = this._hashForTimers[targetId];
if (element) {
var timers = element.timers;
if (timers.indexOf(element.currentTimer) > -1 &&
if (timers.indexOf(element.currentTimer) > -1 &&
(!element.currentTimerSalvaged)) {
element.currentTimerSalvaged = true;
}
@@ -839,7 +839,7 @@ class Scheduler {
}
}
/**
/**
* !#en Checks whether a callback for a given target is scheduled.
* !#zh 检查指定的回调函数和回调对象组合是否存在定时器。
* @method isScheduled
@@ -862,7 +862,7 @@ class Scheduler {
cc.errorID(1510);
}
}
var element = this._hashForTimers[targetId];
if (!element) {
@@ -1003,7 +1003,7 @@ class Scheduler {
}
//customer selectors
var self = this,
var self = this,
element = self._hashForTimers[targetId];
if (element) {
element.paused = true;
+1 -1
View File
@@ -2,7 +2,7 @@ import { GFXDevice } from './device';
import { GFXBuffer } from './buffer';
import { GFXTextureView } from './texture-view';
import { GFXSampler } from './sampler';
import { GFXBindingType } from './gfx-define';
import { GFXBindingType } from './define';
export interface GFXBinding {
binding : number;
+1 -1
View File
@@ -1,5 +1,5 @@
import { GFXDevice } from './device';
import { GFXBufferUsage, GFXMemoryUsage, GFXBufferUsageBit, GFXMemoryUsageBit } from './gfx-define';
import { GFXBufferUsage, GFXMemoryUsage, GFXBufferUsageBit, GFXMemoryUsageBit } from './define';
export interface GFXBufferInfo {
usage: GFXBufferUsage;
+1 -1
View File
@@ -6,7 +6,7 @@ import { GFXPipelineState } from './pipeline-state';
import { GFXBindingLayout } from './binding-layout';
import { GFXTexture } from './texture';
import { GFXFramebuffer } from './framebuffer';
import { GFXColor, GFXRect, GFXCommandBufferType, GFXBufferTextureCopy, GFXTextureLayout } from './gfx-define';
import { GFXColor, GFXRect, GFXCommandBufferType, GFXBufferTextureCopy, GFXTextureLayout } from './define';
export interface GFXCommandBufferInfo {
allocator : GFXCommandAllocator;
+152 -164
View File
@@ -16,22 +16,22 @@ export enum WebGLEXT {
COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03,
COMPRESSED_RGB_ETC1_WEBGL = 0x8D64,
};
}
export const GFX_MAX_VERTEX_ATTRIBUTES: number = 8;
export const GFX_MAX_TEXTURE_UNITS: number = 16;
export const GFX_MAX_ATTACHMENTS: number = 4;
export const GFX_ATTRIBUTE_POSITION = "a_position"; // 0
export const GFX_ATTRIBUTE_COLOR = "a_color"; // 1
export const GFX_ATTRIBUTE_COLOR1 = "a_color1"; // 2
export const GFX_ATTRIBUTE_NORMAL = "a_normal"; // 3
export const GFX_ATTRIBUTE_TANGENT = "a_tangent"; // 4
export const GFX_ATTRIBUTE_BINORMAL = "a_binormal"; // 5
export const GFX_ATTRIBUTE_TEXCOORD = "a_texCoord"; // 6
export const GFX_ATTRIBUTE_TEXCOORD1 = "a_texCoord1"; // 7
export const GFX_ATTRIBUTE_JOINTS = "a_joints"; // 8
export const GFX_ATTRIBUTE_WEIGHTS = "a_weights"; // 9
export const GFX_ATTRIBUTE_POSITION = 'a_position'; // 0
export const GFX_ATTRIBUTE_COLOR = 'a_color'; // 1
export const GFX_ATTRIBUTE_COLOR1 = 'a_color1'; // 2
export const GFX_ATTRIBUTE_NORMAL = 'a_normal'; // 3
export const GFX_ATTRIBUTE_TANGENT = 'a_tangent'; // 4
export const GFX_ATTRIBUTE_BINORMAL = 'a_binormal'; // 5
export const GFX_ATTRIBUTE_TEXCOORD = 'a_texCoord'; // 6
export const GFX_ATTRIBUTE_TEXCOORD1 = 'a_texCoord1'; // 7
export const GFX_ATTRIBUTE_JOINTS = 'a_joints'; // 8
export const GFX_ATTRIBUTE_WEIGHTS = 'a_weights'; // 9
export enum GFXType {
UNKNOWN,
@@ -67,7 +67,7 @@ export enum GFXType {
SAMPLER3D,
SAMPLER_CUBE,
COUNT,
};
}
export enum GFXFormat {
@@ -189,7 +189,7 @@ export enum GFXFormat {
PVRTC_RGBA4,
PVRTC2_2BPP,
PVRTC2_4BPP,
};
}
export enum GFXBufferUsageBit {
NONE = 0,
@@ -199,7 +199,7 @@ export enum GFXBufferUsageBit {
VERTEX = 0x8,
UNIFORM = 0x10,
STORAGE = 0x20,
};
}
export type GFXBufferUsage = GFXBufferUsageBit;
@@ -207,7 +207,7 @@ export enum GFXMemoryUsageBit {
NONE = 0,
DEVICE = 0x1,
HOST = 0x2,
};
}
export type GFXMemoryUsage = GFXMemoryUsageBit;
@@ -215,7 +215,7 @@ export enum GFXBufferAccessBit {
NONE = 0,
READ = 0x1,
WRITE = 0x2,
};
}
export type GFXBufferAccess = GFXBufferAccessBit;
@@ -234,24 +234,24 @@ export enum GFXPrimitiveMode {
TRIANGLE_PATCH_ADJACENCY,
QUAD_PATCH_LIST,
ISO_LINE_LIST,
};
}
export enum GFXPolygonMode {
FILL,
LINE,
POINT,
};
}
export enum GFXShadeModel {
GOURAND,
FLAT,
};
}
export enum GFXCullMode {
NONE,
FRONT,
BACK,
};
}
export enum GFXComparisonFunc {
NEVER,
@@ -262,18 +262,18 @@ export enum GFXComparisonFunc {
NOT_EQUAL,
GREATER_EQUAL,
ALWAYS,
};
}
export enum GFXStencilOp {
KEEP,
ZERO,
KEEP,
REPLACE,
INCR,
DECR,
INVERT,
INCR_WRAP,
DECR_WRAP,
};
}
export enum GFXBlendOp {
ADD,
@@ -281,7 +281,7 @@ export enum GFXBlendOp {
REV_SUB,
MIN,
MAX,
};
}
export enum GFXBlendFactor {
ZERO,
@@ -299,7 +299,7 @@ export enum GFXBlendFactor {
ONE_MINUS_CONSTANT_COLOR,
CONSTANT_ALPHA,
ONE_MINUS_CONSTANT_ALPHA,
};
}
export enum GFXColorMask {
NONE = 0x0,
@@ -308,27 +308,27 @@ export enum GFXColorMask {
B = 0x4,
A = 0x8,
ALL = R | G | B | A,
};
}
export enum GFXFilter {
NONE,
POINT,
LINEAR,
ANISOTROPIC,
};
}
export enum GFXAddress {
WRAP,
MIRROR,
CLAMP,
BORDER,
};
}
export enum GFXTextureType {
TEX1D,
TEX2D,
TEX3D,
};
}
export enum GFXTextureUsageBit {
NONE = 0,
@@ -340,7 +340,7 @@ export enum GFXTextureUsageBit {
DEPTH_STENCIL_ATTACHMENT = 0x20,
TRANSIENT_ATTACHMENT = 0x40,
INPUT_ATTACHMENT = 0x80,
};
}
export type GFXTextureUsage = GFXTextureUsageBit;
@@ -349,7 +349,7 @@ export enum GFXTextureFlagBit {
GEN_MIPMAP = 0x1,
CUBEMAP = 0x2,
BAKUP_BUFFER = 0x4,
};
}
export type GFXTextureFlags = GFXTextureFlagBit;
@@ -360,7 +360,7 @@ export enum GFXTextureViewType {
CUBE,
TV1D_ARRAY,
TV2D_ARRAY,
};
}
export enum GFXShaderType {
VERTEX,
@@ -370,32 +370,32 @@ export enum GFXShaderType {
FRAGMENT,
COMPUTE,
COUNT,
};
}
export enum GFXBindingType {
UNKNOWN,
UNIFORM_BUFFER,
SAMPLER,
STORAGE_BUFFER,
};
}
export enum GFXCommandBufferType {
PRIMARY,
SECONDARY,
};
}
// Enumeration all possible values of operations to be performed on initially Loading a Framebuffer Object.
export enum GFXLoadOp {
LOAD, // Load the contents from the fbo from previous
CLEAR, // Clear the fbo
DISCARD, // Ignore writing to the fbo and keep old data
};
}
// Enumerates all possible values of operations to be performed when Storing to a Framebuffer Object.
export enum GFXStoreOp {
STORE, // Write the source to the destination
DISCARD, // Don't write the source to the destination
};
}
export enum GFXTextureLayout {
UNDEFINED,
@@ -408,19 +408,19 @@ export enum GFXTextureLayout {
TRANSFER_DST_OPTIMAL,
PREINITIALIZED,
PRESENT_SRC,
};
}
export enum GFXPipelineBindPoint {
GRAPHICS,
COMPUTE,
RAY_TRACING,
};
}
export enum GFXQueueType {
GRAPHICS,
COMPUTE,
TRANSFER,
};
}
// Interfaces
@@ -429,7 +429,7 @@ export interface GFXRect {
top: number;
width: number;
height: number;
};
}
export interface GFXViewport {
left: number;
@@ -438,21 +438,21 @@ export interface GFXViewport {
height: number;
minDepth: number;
maxDepth: number;
};
}
export interface GFXColor {
r: number;
g: number;
b: number;
a: number;
};
}
export interface GFXTextureSubres {
baseMipLevel: number;
levelCount: number;
baseArrayLayer: number;
layerCount: number;
};
}
export interface GFXTextureCopy {
srcSubres: GFXTextureSubres;
@@ -460,7 +460,7 @@ export interface GFXTextureCopy {
dstSubres: GFXTextureSubres;
dstOffset: number[];
extent: number[];
};
}
export interface GFXBufferTextureCopy {
buffOffset: number;
@@ -469,7 +469,7 @@ export interface GFXBufferTextureCopy {
texOffset: number[];
texExtent: number[];
texSubres: GFXTextureSubres;
};
}
export interface GFXFormatInfo {
readonly name: string;
@@ -480,112 +480,112 @@ export interface GFXFormatInfo {
readonly hasDepth: boolean;
readonly hasStencil: boolean;
readonly isCompressed: boolean;
};
}
export const GFXFormatInfos: GFXFormatInfo[] = [
{ name: "UNKNOWN", size: 0, count: 0, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'UNKNOWN', size: 0, count: 0, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "A8", size: 1, count: 1, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "L8", size: 1, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "LA8", size: 1, count: 2, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'A8', size: 1, count: 1, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'L8', size: 1, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'LA8', size: 1, count: 2, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "R8", size: 1, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "R8SN", size: 1, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "R8UI", size: 1, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "R8I", size: 1, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "R16F", size: 2, count: 1, isFloating: true, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "R16UI", size: 2, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "R16I", size: 2, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "R32F", size: 4, count: 1, isFloating: true, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "R32UI", size: 4, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "R32I", size: 4, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'R8', size: 1, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'R8SN', size: 1, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'R8UI', size: 1, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'R8I', size: 1, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'R16F', size: 2, count: 1, isFloating: true, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'R16UI', size: 2, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'R16I', size: 2, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'R32F', size: 4, count: 1, isFloating: true, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'R32UI', size: 4, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'R32I', size: 4, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RG8", size: 2, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RG8SN", size: 2, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RG8UI", size: 2, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RG8I", size: 2, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RG16F", size: 4, count: 2, isFloating: true, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RG16UI", size: 4, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RG16I", size: 4, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RG32F", size: 8, count: 2, isFloating: true, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RG32UI", size: 8, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RG32I", size: 8, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RG8', size: 2, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RG8SN', size: 2, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RG8UI', size: 2, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RG8I', size: 2, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RG16F', size: 4, count: 2, isFloating: true, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RG16UI', size: 4, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RG16I', size: 4, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RG32F', size: 8, count: 2, isFloating: true, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RG32UI', size: 8, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RG32I', size: 8, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGB8", size: 3, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "SRGB8", size: 3, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGB8SN", size: 3, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGB8UI", size: 3, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGB8I", size: 3, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGB16F", size: 6, count: 3, isFloating: true, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGB16UI", size: 6, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGB16I", size: 6, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGB32F", size: 12, count: 3, isFloating: true, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGB32UI", size: 12, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGB32I", size: 12, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGB8', size: 3, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'SRGB8', size: 3, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGB8SN', size: 3, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGB8UI', size: 3, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGB8I', size: 3, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGB16F', size: 6, count: 3, isFloating: true, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGB16UI', size: 6, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGB16I', size: 6, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGB32F', size: 12, count: 3, isFloating: true, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGB32UI', size: 12, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGB32I', size: 12, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGBA8", size: 4, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "SRGB8_A8", size: 4, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGBA8SN", size: 4, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGBA8UI", size: 4, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGBA8I", size: 4, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGBA16F", size: 8, count: 4, isFloating: true, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGBA16UI", size: 8, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGBA16I", size: 8, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGBA32F", size: 16, count: 4, isFloating: true, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGBA32UI", size: 16, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGBA32I", size: 16, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGBA8', size: 4, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'SRGB8_A8', size: 4, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGBA8SN', size: 4, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGBA8UI', size: 4, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGBA8I', size: 4, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGBA16F', size: 8, count: 4, isFloating: true, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGBA16UI', size: 8, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGBA16I', size: 8, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGBA32F', size: 16, count: 4, isFloating: true, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGBA32UI', size: 16, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGBA32I', size: 16, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "R5G6B5", size: 2, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "R11G11B10F", size: 4, count: 3, isFloating: true, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGB5A1", size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGBA4", size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGB10A2", size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGB10A2UI", size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "RGB9E5", size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'R5G6B5', size: 2, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'R11G11B10F', size: 4, count: 3, isFloating: true, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGB5A1', size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGBA4', size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGB10A2', size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGB10A2UI', size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: 'RGB9E5', size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: false },
{ name: "D16", size: 2, count: 1, isFloating: false, hasAlpha: false, hasDepth: true, hasStencil: false, isCompressed: false },
{ name: "D16S8", size: 3, count: 2, isFloating: false, hasAlpha: false, hasDepth: true, hasStencil: true, isCompressed: false },
{ name: "D24", size: 3, count: 1, isFloating: false, hasAlpha: false, hasDepth: true, hasStencil: false, isCompressed: false },
{ name: "D24S8", size: 4, count: 2, isFloating: false, hasAlpha: false, hasDepth: true, hasStencil: true, isCompressed: false },
{ name: "D32F", size: 4, count: 1, isFloating: true, hasAlpha: false, hasDepth: true, hasStencil: false, isCompressed: false },
{ name: "D32FS8", size: 5, count: 2, isFloating: true, hasAlpha: false, hasDepth: true, hasStencil: true, isCompressed: false },
{ name: 'D16', size: 2, count: 1, isFloating: false, hasAlpha: false, hasDepth: true, hasStencil: false, isCompressed: false },
{ name: 'D16S8', size: 3, count: 2, isFloating: false, hasAlpha: false, hasDepth: true, hasStencil: true, isCompressed: false },
{ name: 'D24', size: 3, count: 1, isFloating: false, hasAlpha: false, hasDepth: true, hasStencil: false, isCompressed: false },
{ name: 'D24S8', size: 4, count: 2, isFloating: false, hasAlpha: false, hasDepth: true, hasStencil: true, isCompressed: false },
{ name: 'D32F', size: 4, count: 1, isFloating: true, hasAlpha: false, hasDepth: true, hasStencil: false, isCompressed: false },
{ name: 'D32FS8', size: 5, count: 2, isFloating: true, hasAlpha: false, hasDepth: true, hasStencil: true, isCompressed: false },
{ name: "BC1", size: 1, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "BC1_ALPHA", size: 1, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "BC1_SRGB", size: 1, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "BC1_SRGB_ALPHA", size: 1, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "BC2", size: 1, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "BC2_SRGB", size: 1, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "BC3", size: 1, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "BC3_SRGB", size: 1, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "BC4", size: 1, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "BC4_SNORM", size: 1, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "BC5", size: 1, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "BC5_SNORM", size: 1, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "BC6H_UF16", size: 1, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "BC6H_SF16", size: 1, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "BC7", size: 1, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "BC7_SRGB", size: 1, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'BC1', size: 1, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'BC1_ALPHA', size: 1, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'BC1_SRGB', size: 1, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'BC1_SRGB_ALPHA', size: 1, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'BC2', size: 1, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'BC2_SRGB', size: 1, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'BC3', size: 1, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'BC3_SRGB', size: 1, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'BC4', size: 1, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'BC4_SNORM', size: 1, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'BC5', size: 1, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'BC5_SNORM', size: 1, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'BC6H_UF16', size: 1, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'BC6H_SF16', size: 1, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'BC7', size: 1, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'BC7_SRGB', size: 1, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "ETC_RGB8", size: 1, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "ETC2_RGB8", size: 1, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "ETC2_SRGB8", size: 1, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "ETC2_RGB8_A1", size: 1, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "ETC2_SRGB8_A1", size: 1, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "ETC2_RGBA8", size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "ETC2_SRGB8_A8", size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "EAC_R11", size: 1, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "EAC_R11SN", size: 1, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "EAC_RG11", size: 2, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "EAC_RG11SN", size: 2, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'ETC_RGB8', size: 1, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'ETC2_RGB8', size: 1, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'ETC2_SRGB8', size: 1, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'ETC2_RGB8_A1', size: 1, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'ETC2_SRGB8_A1', size: 1, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'ETC2_RGBA8', size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'ETC2_SRGB8_A8', size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'EAC_R11', size: 1, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'EAC_R11SN', size: 1, count: 1, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'EAC_RG11', size: 2, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'EAC_RG11SN', size: 2, count: 2, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "PVRTC_RGB2", size: 2, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "PVRTC_RGBA2", size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "PVRTC_RGB4", size: 2, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "PVRTC_RGBA4", size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "PVRTC2_2BPP", size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: "PVRTC2_4BPP", size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'PVRTC_RGB2', size: 2, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'PVRTC_RGBA2', size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'PVRTC_RGB4', size: 2, count: 3, isFloating: false, hasAlpha: false, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'PVRTC_RGBA4', size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'PVRTC2_2BPP', size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
{ name: 'PVRTC2_4BPP', size: 2, count: 4, isFloating: false, hasAlpha: true, hasDepth: false, hasStencil: false, isCompressed: true },
];
export function GFXFormatSize(format: GFXFormat, width: number, height: number, depth: number): number {
@@ -695,28 +695,16 @@ export function GFXGetTypeSize(type: GFXType): number {
}
}
export function GFXGetAttributeBinding(name: string) : number {
if (name === GFX_ATTRIBUTE_POSITION) {
return 20;
} else if (name === GFX_ATTRIBUTE_COLOR) {
return 21;
} else if (name === GFX_ATTRIBUTE_COLOR1) {
return 22;
} else if (name === GFX_ATTRIBUTE_NORMAL) {
return 23;
} else if (name === GFX_ATTRIBUTE_TANGENT) {
return 24;
} else if (name === GFX_ATTRIBUTE_BINORMAL) {
return 25;
} else if (name === GFX_ATTRIBUTE_TEXCOORD) {
return 26;
} else if (name === GFX_ATTRIBUTE_TEXCOORD1) {
return 27;
} else if (name === GFX_ATTRIBUTE_JOINTS) {
return 28;
} else if (name === GFX_ATTRIBUTE_WEIGHTS) {
return 29;
} else {
return -1;
}
}
const GFXBuiltinAttributeBindings = {
[GFX_ATTRIBUTE_POSITION]: 20,
[GFX_ATTRIBUTE_COLOR]: 21,
[GFX_ATTRIBUTE_COLOR1]: 22,
[GFX_ATTRIBUTE_NORMAL]: 23,
[GFX_ATTRIBUTE_TANGENT]: 24,
[GFX_ATTRIBUTE_BINORMAL]: 25,
[GFX_ATTRIBUTE_TEXCOORD]: 26,
[GFX_ATTRIBUTE_TEXCOORD1]: 27,
[GFX_ATTRIBUTE_JOINTS]: 28,
[GFX_ATTRIBUTE_WEIGHTS]: 29,
};
export { GFXBuiltinAttributeBindings };
+1 -1
View File
@@ -1,5 +1,5 @@
import { GFXDevice } from './device';
import { GFXFormat } from './gfx-define';
import { GFXFormat } from './define';
import { GFXBuffer } from './buffer';
export interface GFXInputAttribute {
+1 -1
View File
@@ -1,6 +1,6 @@
import { GFXDevice } from './device';
import { GFXBindingLayout } from './binding-layout';
import { GFXShaderType } from './gfx-define';
import { GFXShaderType } from './define';
export interface GFXPushConstantRange {
shaderType : GFXShaderType;
+1 -1
View File
@@ -3,7 +3,7 @@ import { GFXShader } from './shader';
import { GFXRenderPass } from './render-pass';
import { GFXPipelineLayout } from './pipeline-layout';
import { GFXInputAttribute } from './input-assembler';
import { GFXPolygonMode, GFXShadeModel, GFXCullMode, GFXComparisonFunc, GFXStencilOp, GFXBlendFactor, GFXBlendOp, GFXColorMask, GFXPrimitiveMode } from './gfx-define';
import { GFXPolygonMode, GFXShadeModel, GFXCullMode, GFXComparisonFunc, GFXStencilOp, GFXBlendFactor, GFXBlendOp, GFXColorMask, GFXPrimitiveMode } from './define';
export class GFXRasterizerState {
isDiscard: boolean = false;
+1 -1
View File
@@ -1,6 +1,6 @@
import { GFXDevice } from './device';
import { GFXCommandBuffer } from './command-buffer';
import { GFXQueueType } from './gfx-define';
import { GFXQueueType } from './define';
export interface GFXQueueInfo {
type : GFXQueueType;
+2 -2
View File
@@ -1,4 +1,4 @@
import { GFXFormat, GFXLoadOp, GFXStoreOp, GFXTextureLayout, GFXPipelineBindPoint } from './gfx-define';
import { GFXFormat, GFXLoadOp, GFXStoreOp, GFXTextureLayout, GFXPipelineBindPoint } from './define';
import { GFXDevice } from './device';
export class GFXColorAttachment
@@ -35,7 +35,7 @@ export interface GFXSubPassInfo
export interface GFXRenderPassInfo
{
colorAttachment? : GFXColorAttachment[];
colorAttachments? : GFXColorAttachment[];
depthStencilAttachment? : GFXDepthStencilAttachment;
//subPasses? : GFXSubPassInfo[];
};
+1 -1
View File
@@ -1,5 +1,5 @@
import { GFXDevice } from './device';
import { GFXFilter, GFXAddress, GFXComparisonFunc } from './gfx-define';
import { GFXFilter, GFXAddress, GFXComparisonFunc } from './define';
export interface GFXSamplerInfo {
name? : string;
+1 -1
View File
@@ -1,5 +1,5 @@
import { GFXDevice } from './device';
import { GFXType, GFXShaderType } from './gfx-define';
import { GFXType, GFXShaderType } from './define';
export interface GFXShaderMacro {
macro: string;
+1 -1
View File
@@ -1,4 +1,4 @@
import { GFXFormat, GFXTextureViewType } from './gfx-define';
import { GFXFormat, GFXTextureViewType } from './define';
import { GFXDevice } from './device';
import { GFXTexture } from './texture';
+1 -1
View File
@@ -1,4 +1,4 @@
import { GFXFormat, GFXTextureType, GFXTextureUsage, GFXTextureFlags, GFXTextureUsageBit, GFXTextureFlagBit } from './gfx-define';
import { GFXFormat, GFXTextureType, GFXTextureUsage, GFXTextureFlags, GFXTextureUsageBit, GFXTextureFlagBit } from './define';
import { GFXDevice } from './device';
export interface GFXTextureInfo {
+1 -1
View File
@@ -2,7 +2,7 @@ import { GFXBufferInfo, GFXBuffer } from '../buffer';
import { GFXDevice } from '../device';
import { WebGLGPUBuffer } from './webgl-gpu-objects';
import { WebGLGFXDevice } from './webgl-device';
import { GFXMemoryUsageBit } from '../gfx-define';
import { GFXMemoryUsageBit } from '../define';
export class WebGLGFXBuffer extends GFXBuffer {
+1 -1
View File
@@ -15,7 +15,7 @@ import { GFXBindingLayout } from '../binding-layout';
import { WebGLGFXBindingLayout } from './webgl-binding-layout';
import { GFXTexture } from '../texture';
import { WebGLGFXTexture } from './webgl-texture';
import { GFXColor, GFXViewport, GFXRect, GFXBufferTextureCopy, GFXTextureLayout } from '../gfx-define';
import { GFXColor, GFXViewport, GFXRect, GFXBufferTextureCopy, GFXTextureLayout } from '../define';
export class WebGLGFXCommandBuffer extends GFXCommandBuffer {
+2 -2
View File
@@ -1,6 +1,6 @@
import { WebGLGPUBuffer, WebGLGPUTexture, WebGLGPUInputAssembler, WebGLGPUFramebuffer, WebGLGPUShader, WebGLGPUInput, WebGLAttrib, WebGLGPUPipelineState, WebGLGPUUniformBlock, WebGLGPUBindingLayout, WebGLGPUUniform, WebGLGPUUniformSampler } from "./webgl-gpu-objects";
import { WebGLGFXDevice } from "./webgl-device";
import { GFXFormatInfos, GFXFormat, WebGLEXT, GFXType, GFX_MAX_VERTEX_ATTRIBUTES, GFXFormatSize, GFXColor, GFXRect, GFXBindingType, GFXBufferTextureCopy, GFXColorMask, GFXCullMode, GFXShaderType, GFXTextureViewType, GFXTextureLayout, GFXLoadOp, GFXTextureFlagBit, GFXMemoryUsageBit, GFXBufferUsageBit, GFXGetAttributeBinding } from "../gfx-define";
import { GFXFormatInfos, GFXFormat, WebGLEXT, GFXType, GFX_MAX_VERTEX_ATTRIBUTES, GFXFormatSize, GFXColor, GFXRect, GFXBindingType, GFXBufferTextureCopy, GFXColorMask, GFXCullMode, GFXShaderType, GFXTextureViewType, GFXTextureLayout, GFXLoadOp, GFXTextureFlagBit, GFXMemoryUsageBit, GFXBufferUsageBit, GFXBuiltinAttributeBindings } from "../define";
import { WebGLGFXCommandAllocator } from "./webgl-command-allocator";
import { WebGLTexUnit } from "./webgl-state-cache";
@@ -818,7 +818,7 @@ export function WebGLCmdFuncCreateShader(device: WebGLGFXDevice, gpuShader: WebG
varName = info.name;
}
let glLoc = GFXGetAttributeBinding(varName);
let glLoc = GFXBuiltinAttributeBindings[varName];
if(glLoc >= 0) {
gl.bindAttribLocation(gpuShader.glProgram, glLoc, varName);
+2 -2
View File
@@ -31,7 +31,7 @@ import { WebGLGFXFramebuffer } from './webgl-framebuffer';
import { WebGLGFXInputAssembler } from './webgl-input-assembler';
import { GFXWindow, GFXWindowInfo } from '../window';
import { WebGLGFXWindow } from './webgl-window';
import { GFXBindingType, GFXFilter, GFXAddress, GFXTextureType, GFXTextureFlagBit, GFXTextureViewType, GFXBufferUsageBit } from '../gfx-define';
import { GFXBindingType, GFXFilter, GFXAddress, GFXTextureType, GFXTextureFlagBit, GFXTextureViewType, GFXBufferUsageBit } from '../define';
import { WebGLGFXBindingLayout } from './webgl-binding-layout';
const WebGLPrimitives: GLenum[] = [
@@ -476,7 +476,7 @@ export class WebGLGFXDevice extends GFXDevice {
public emitCmdCreateGPURenderPass(info: GFXRenderPassInfo): WebGLGPURenderPass {
let gpuRenderPass: WebGLGPURenderPass = {
objType: WebGLGPUObjectType.RENDER_PASS,
colorAttachments: info.colorAttachment? info.colorAttachment : [],
colorAttachments: info.colorAttachments? info.colorAttachments : [],
depthStencilAttachment: info.depthStencilAttachment? info.depthStencilAttachment : null,
}
+1 -1
View File
@@ -1,4 +1,4 @@
import { GFXFormat, GFXType, GFXTextureType, GFXTextureUsage, GFXTextureUsageBit, GFXTextureFlags, GFXTextureFlagBit, GFXShaderType, GFXBindingType, GFXTextureViewType, GFXBufferUsageBit, GFXMemoryUsageBit, GFXMemoryUsage, GFXBufferUsage } from "../gfx-define";
import { GFXFormat, GFXType, GFXTextureType, GFXTextureUsage, GFXTextureUsageBit, GFXTextureFlags, GFXTextureFlagBit, GFXShaderType, GFXBindingType, GFXTextureViewType, GFXBufferUsageBit, GFXMemoryUsageBit, GFXMemoryUsage, GFXBufferUsage } from "../define";
import { GFXColorAttachment, GFXDepthStencilAttachment } from "../render-pass";
import { GFXRasterizerState, GFXDepthStencilState, GFXBlendState } from "../pipeline-state";
import { GFXInputAttribute } from "../input-assembler";
+2 -2
View File
@@ -11,8 +11,8 @@ export class WebGLGFXRenderPass extends GFXRenderPass {
public initialize(info: GFXRenderPassInfo): boolean {
if (info.colorAttachment) {
this._colorInfos = info.colorAttachment;
if (info.colorAttachments) {
this._colorInfos = info.colorAttachments;
}
if (info.depthStencilAttachment) {
+1 -1
View File
@@ -1,4 +1,4 @@
import { GFX_MAX_TEXTURE_UNITS, GFX_MAX_VERTEX_ATTRIBUTES, GFXViewport, GFXRect } from "../gfx-define";
import { GFX_MAX_TEXTURE_UNITS, GFX_MAX_VERTEX_ATTRIBUTES, GFXViewport, GFXRect } from "../define";
import { GFXRasterizerState, GFXDepthStencilState, GFXBlendState } from "../pipeline-state";
export interface WebGLTexUnit
+1 -1
View File
@@ -2,7 +2,7 @@ import { GFXDevice } from '../device';
import { WebGLGPUTexture } from './webgl-gpu-objects';
import { WebGLGFXDevice } from './webgl-device';
import { GFXTexture, GFXTextureInfo } from '../texture';
import { GFXFormatSurfaceSize, GFXTextureFlagBit } from '../gfx-define';
import { GFXFormatSurfaceSize, GFXTextureFlagBit } from '../define';
export class WebGLGFXTexture extends GFXTexture {
+2 -2
View File
@@ -1,7 +1,7 @@
import { GFXDevice } from '../device';
import { WebGLGFXDevice } from './webgl-device';
import { GFXWindow, GFXWindowInfo } from '../window';
import { GFXFormat, GFXTextureType, GFXTextureUsageBit, GFXTextureFlagBit, GFXTextureViewType, GFXTextureLayout, GFXLoadOp, GFXStoreOp } from '../gfx-define';
import { GFXFormat, GFXTextureType, GFXTextureUsageBit, GFXTextureFlagBit, GFXTextureViewType, GFXTextureLayout, GFXLoadOp, GFXStoreOp } from '../define';
export class WebGLGFXWindow extends GFXWindow {
@@ -34,7 +34,7 @@ export class WebGLGFXWindow extends GFXWindow {
}
this._renderPass = this._device.createRenderPass({
colorAttachment: [{
colorAttachments: [{
format: this._colorFmt,
loadOp: GFXLoadOp.CLEAR,
storeOp: GFXStoreOp.STORE,
+1 -1
View File
@@ -2,7 +2,7 @@ import { GFXDevice } from './device';
import { GFXFramebuffer } from './framebuffer';
import { GFXTexture } from './texture';
import { GFXTextureView } from './texture-view';
import { GFXFormat } from './gfx-define';
import { GFXFormat } from './define';
import { GFXRenderPass } from './render-pass';
export interface GFXWindowInfo {
+1 -1
View File
@@ -3,7 +3,7 @@ import { RenderFlow } from "../render-flow";
import { GFXCommandBuffer } from "../../gfx/command-buffer";
import { RenderView } from "../render-view";
import { GFXFramebuffer } from "../../gfx/framebuffer";
import { GFXCommandBufferType } from "../../gfx/gfx-define";
import { GFXCommandBufferType } from "../../gfx/define";
import { GFXInputAssembler } from "../../gfx/input-assembler";
export class ForwardStage extends RenderStage {
+2 -2
View File
@@ -3,7 +3,7 @@ import { RenderFlow } from "../render-flow";
import { GFXCommandBuffer } from "../../gfx/command-buffer";
import { RenderView } from "../render-view";
import { GFXFramebuffer } from "../../gfx/framebuffer";
import { GFXCommandBufferType, GFXShaderType, GFXPrimitiveMode } from "../../gfx/gfx-define";
import { GFXCommandBufferType, GFXShaderType, GFXPrimitiveMode } from "../../gfx/define";
import { GFXInputAssembler } from "../../gfx/input-assembler";
import { GFXPipelineState, GFXInputState, GFXRasterizerState, GFXDepthStencilState, GFXBlendState } from "../../gfx/pipeline-state";
import { GFXShader } from "../../gfx/shader";
@@ -122,7 +122,7 @@ export class TestStage extends RenderStage {
this._pipelineState.destroy();
this._pipelineState = null;
}
if (this._cmdBuff) {
this._cmdBuff.destroy();
this._cmdBuff = null;
+2 -2
View File
@@ -5,7 +5,7 @@ import { GFXRenderPass } from "../gfx/render-pass";
import { GFXDevice } from "../gfx/device";
import { GFXBuffer } from "../gfx/buffer";
import { GFXInputAssembler, GFXInputAttribute } from "../gfx/input-assembler";
import { GFXBufferUsageBit, GFXMemoryUsageBit, GFXFormat } from "../gfx/gfx-define";
import { GFXBufferUsageBit, GFXMemoryUsageBit, GFXFormat } from "../gfx/define";
export enum RenderPassStage {
FORWARD = 0,
@@ -145,7 +145,7 @@ export abstract class RenderPipeline {
this._quadIB.update(indices);
// create input assembler
let attributes: GFXInputAttribute[] = [
{name: "a_position", format: GFXFormat.RG32F},
{name: "a_texCoord", format: GFXFormat.RG32F},
+1 -1
View File
@@ -5,7 +5,7 @@ import { GFXCommandBuffer } from "../gfx/command-buffer";
import { RenderFlow } from "./render-flow";
import { GFXDevice } from "../gfx/device";
import { RenderPipeline } from "./render-pipeline";
import { GFXColor, GFX_MAX_ATTACHMENTS, GFXRect } from "../gfx/gfx-define";
import { GFXColor, GFX_MAX_ATTACHMENTS, GFXRect } from "../gfx/define";
export interface RenderStageInfo {
name?: string;
-286
View File
@@ -1,286 +0,0 @@
// Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
import enums from '../enums';
import Pass from './pass';
import Technique from './technique';
import { Vec2, Vec3, Vec4, Color, Mat4 } from '../../core/value-types';
import { CCObject } from '../../core/data';
import Texture2D from '../gfx/texture-2d';
import TextureCube from '../gfx/texture-cube';
let _typeMap = {
[enums.PARAM_INT]: Number,
[enums.PARAM_INT2]: Vec2,
[enums.PARAM_INT3]: Vec3,
[enums.PARAM_INT4]: Vec4,
[enums.PARAM_FLOAT]: Number,
[enums.PARAM_FLOAT2]: Vec2,
[enums.PARAM_FLOAT3]: Vec3,
[enums.PARAM_FLOAT4]: Vec4,
[enums.PARAM_COLOR3]: Color,
[enums.PARAM_COLOR4]: Color,
[enums.PARAM_MAT4]: Mat4,
[enums.PARAM_TEXTURE_2D]: Texture2D,
[enums.PARAM_TEXTURE_CUBE]: TextureCube,
number: Number,
boolean: Boolean,
default: CCObject
};
let getInstanceType = function(t) { return _typeMap[t] || _typeMap.default; };
let typeCheck = function(value, type) {
let instanceType = getInstanceType(type);
switch (typeof value) {
case 'object': return (value === null) || (value instanceof instanceType);
case 'number': return instanceType === Number;
default: return false;
}
};
let _globalTechLod = 600;
class Effect {
/**
* @param {Array} techniques
*/
constructor(name, techniques, programs, properties = {}, lod = -1) {
this._name = name;
this._techniques = techniques;
this._properties = properties;
this._programs = programs;
this._defines = {};
this._dependencies = {};
this._maxLOD = lod;
this.selectTechnique();
}
set LOD(lod) {
if (lod === this._maxLOD) {
return;
}
this._maxLOD = lod;
this.selectTechnique();
}
clear() {
this._techniques.length = 0;
this._properties = {};
this._defines = {};
this._dependencies.length = 0;
}
getTechnique(index) {
if (index < 0 || index >= this._techniques.length)
return null;
return this._techniques[index];
}
getProperty(name) {
if (!this._properties[name]) {
console.warn(`Failed to get property ${name}, property not found.`);
return null;
}
return this._properties[name].value;
}
setProperty(name, value) {
let prop = this._properties[name];
if (!prop) {
console.warn(`Failed to set property ${name}, property not found.`);
return;
}
else if (!typeCheck(value, prop.type)) {
console.warn(`Failed to set property ${name}, property type mismatch.`);
return;
}
this._properties[name].value = value;
}
getDefine(name) {
let def = this._defines[name];
if (def !== undefined) return def;
console.warn(`Failed to get define ${name}, define not found.`);
return null;
}
define(name, value) {
if (this._defines[name] !== undefined) this._defines[name] = value;
else console.warn(`Failed to set define ${name}, define not found.`);
}
extractDefines(out = {}) {
return Object.assign(out, this._defines);
}
extractDependencies(out = {}) {
return Object.assign(out, this._dependencies);
}
getActiveTechnique() {
return this._techniques[this._activeTechIdx];
}
selectTechnique() {
let lod = this._maxLOD === -1 ? _globalTechLod : this._maxLOD;
this._activeTechIdx = 0;
for (let i = 0; i < this._techniques.length; i++) {
if (this._techniques[i]._lod <= lod) {
this._activeTechIdx = i;
break;
}
}
// defines
this._defines = {};
this._techniques[this._activeTechIdx].passes.forEach(pass => this._programs[pass._programName].defines.forEach(def =>
this._defines[def.name] = getInstanceCtor(def.type)()));
// extensions
this._dependencies = {};
this._techniques[this._activeTechIdx].passes.forEach(pass => this._programs[pass._programName].extensions
.filter(ext => ext.define).forEach(ext => this._dependencies[ext.define] = ext.name));
}
static setGlobalLod(lod) {
_globalTechLod = lod;
}
}
let _ctorMap = {
[Number]: v => v || 0,
[Boolean]: v => v || false,
[Vec2]: v => v ? cc.v2(v[0], v[1]) : cc.v2(),
[Vec3]: v => v ? cc.v3(v[0], v[1], v[2]) : cc.v3(),
[Vec4]: v => v ? cc.v4(v[0], v[1], v[2], v[3]) : cc.v4(),
[Color]: v => v ? cc.color(v[0] * 255, v[1] * 255, v[2] * 255,
(v[3] || 1) * 255) : cc.color(),
[Mat4]: v => v ? cc.mat4(
v[0], v[1], v[2], v[3],
v[4], v[5], v[6], v[7],
v[8], v[9], v[10], v[11],
v[12], v[13], v[14], v[15],
) : cc.mat4(),
[Texture2D]: () => null,
[TextureCube]: () => null,
[CCObject]: () => null
};
let getInstanceCtor = function(t) { return _ctorMap[getInstanceType(t)]; };
let getInvolvedPrograms = function(effect) {
let programs = {}, lib = cc.game._renderer._programLib;
effect.techniques.forEach(tech => {
tech.passes.forEach(pass => {
programs[pass.program] = lib.getTemplate(pass.program);
});
});
return programs;
};
let parseProperties = (function() {
function genPropInfo(displayName, type, value) {
return {
type: type,
displayName: displayName,
instanceType: getInstanceType(type),
value: getInstanceCtor(type)(value)
};
}
return function(effect, programs) {
let props = {};
// properties may be specified in the shader too
for (let p in programs) {
programs[p].uniforms.forEach(prop => {
if (!prop.property) return;
props[prop.name] = genPropInfo(prop.displayName, prop.type, prop.value);
});
}
for (let prop in effect.properties) {
let propInfo = effect.properties[prop], uniformInfo;
// always try getting the type from shaders first
if (propInfo.tech !== undefined && propInfo.pass !== undefined) {
let pname = effect.techniques[propInfo.tech].passes[propInfo.pass].program;
uniformInfo = programs[pname].uniforms.find(u => u.name === prop);
} else {
for (let p in programs) {
uniformInfo = programs[p].uniforms.find(u => u.name === prop);
if (uniformInfo) break;
}
}
// the property is not defined in all the shaders used in techs
if (!uniformInfo) {
console.warn(`illegal property: ${prop}`);
continue;
}
// TODO: different param with same name for different passes
props[prop] = genPropInfo(
propInfo.displayName || uniformInfo.displayName,
propInfo.type || uniformInfo.type,
propInfo.value || uniformInfo.value);
}
return props;
};
})();
Effect.parseEffect = function(effect) {
// techniques
let techNum = effect.techniques.length, tech;
let programs = getInvolvedPrograms(effect);
let techniques = new Array(techNum);
for (let j = 0; j < techNum; ++j) {
tech = effect.techniques[j];
let passNum = tech.passes.length;
let passes = new Array(passNum);
for (let k = 0; k < passNum; ++k) {
let pass = tech.passes[k];
passes[k] = new Pass(pass.program);
passes[k].setStage(pass.stage);
passes[k].setDepth(pass.depthTest, pass.depthWrite, pass.depthFunc);
passes[k].setCullMode(pass.cullMode);
passes[k].setBlend(pass.blend, pass.blendEq, pass.blendSrc,
pass.blendDst, pass.blendAlphaEq, pass.blendSrcAlpha, pass.blendDstAlpha, pass.blendColor);
passes[k].setStencilFront(pass.stencilTest, pass.stencilFuncFront, pass.stencilRefFront, pass.stencilMaskFront,
pass.stencilFailOpFront, pass.stencilZFailOpFront, pass.stencilZPassOpFront, pass.stencilWriteMaskFront);
passes[k].setStencilBack(pass.stencilTest, pass.stencilFuncBack, pass.stencilRefBack, pass.stencilMaskBack,
pass.stencilFailOpBack, pass.stencilZFailOpBack, pass.stencilZPassOpBack, pass.stencilWriteMaskBack);
}
techniques[j] = new Technique(tech.queue, tech.priority, tech.lod, passes);
}
// uniforms
let props = parseProperties(effect, programs), uniforms = {};
for (let pn in programs) {
programs[pn].uniforms.forEach(u => {
let prop = props[u.name];
uniforms[u.name] = {
type: prop ? prop.type : u.type,
value: prop ? prop.value : getInstanceCtor(u.type)(u.value)
};
});
}
let parsedEffect = new Effect(effect.name, techniques, programs, uniforms);
return parsedEffect;
};
if (CC_EDITOR) {
Effect.parseForInspector = function(effect) {
let programs = getInvolvedPrograms(effect);
let props = parseProperties(effect, programs), defines = {};
for (let pn in programs) {
programs[pn].uniforms.forEach(u => {
let prop = props[u.name];
if (!prop) return;
prop.defines = u.defines;
});
programs[pn].defines.forEach(define => {
defines[define.name] = {
instanceType: getInstanceType(define.type),
value: getInstanceCtor(define.type)(),
defines: define.defines
};
});
}
return { props, defines };
};
}
export default Effect;
cc.Effect = Effect;
+311
View File
@@ -0,0 +1,311 @@
// Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
import EffectAsset from '../../3d/assets/effect-asset';
import { CCObject } from '../../core/data';
import { Color, Mat4, Vec2, Vec3, Vec4 } from '../../core/value-types';
import enums from '../enums';
import Texture2D from '../gfx/texture-2d';
import TextureCube from '../gfx/texture-cube';
import { Pass } from './pass';
import Technique from './technique';
const _typeMap = {
[enums.PARAM_INT]: 'Number',
[enums.PARAM_INT2]: Vec2,
[enums.PARAM_INT3]: Vec3,
[enums.PARAM_INT4]: Vec4,
[enums.PARAM_FLOAT]: 'Number',
[enums.PARAM_FLOAT2]: Vec2,
[enums.PARAM_FLOAT3]: Vec3,
[enums.PARAM_FLOAT4]: Vec4,
[enums.PARAM_COLOR3]: Color,
[enums.PARAM_COLOR4]: Color,
[enums.PARAM_MAT4]: Mat4,
[enums.PARAM_TEXTURE_2D]: Texture2D,
[enums.PARAM_TEXTURE_CUBE]: TextureCube,
number: 'Number',
boolean: 'Boolean',
default: CCObject,
};
const getInstanceType = (t: number | string) => _typeMap[t] || _typeMap.default;
const typeCheck = (value: any, type: number) => {
const instanceType = getInstanceType(type);
switch (typeof value) {
case 'object': return (value === null) || (value instanceof instanceType);
case 'number': return instanceType === 'Number';
default: return false;
}
};
let _globalTechLod = 600;
const _ctorMap = {
['Number']: (v?: number) => v || 0,
['Boolean']: (v?: boolean) => v || false,
[Vec2]: (v?: number[]) => v ? new Vec2(v[0], v[1]) : new Vec2(),
[Vec3]: (v?: number[]) => v ? new Vec3(v[0], v[1], v[2]) : new Vec3(),
[Vec4]: (v?: number[]) => v ? new Vec4(v[0], v[1], v[2], v[3]) : new Vec4(),
[Color]: (v?: number[]) => v ? new Color(v[0] * 255, v[1] * 255, v[2] * 255,
(v[3] || 1) * 255) : new Color(),
[Mat4]: (v?: number[]) => v ? new Mat4(
v[0], v[1], v[2], v[3],
v[4], v[5], v[6], v[7],
v[8], v[9], v[10], v[11],
v[12], v[13], v[14], v[15]
) : new Mat4(),
[Texture2D]: () => null,
[TextureCube]: () => null,
[CCObject]: () => null,
};
const getInstanceCtor = (t: number | string) => _ctorMap[getInstanceType(t)];
const getInvolvedPrograms = (effect: EffectAsset) => {
const programs: Programs = {};
const lib = cc.game._renderer._programLib;
effect.techniques.forEach((tech) => {
tech.passes.forEach((pass) => {
programs[pass.program] = lib.getTemplate(pass.program);
});
});
return programs;
};
const parseProperties = (() => {
function genPropInfo(displayName: string, type: number, value: any) {
return {
type,
displayName,
instanceType: getInstanceType(type),
value: getInstanceCtor(type)(value),
};
}
return (effect: EffectAsset, programs: Programs) => {
const props = {};
// properties may be specified in the shader too
for (const p of Object.keys(programs)) {
programs[p].uniforms.forEach((prop) => {
if (!prop.property) { return; }
props[prop.name] = genPropInfo(prop.displayName, prop.type, prop.value);
});
}
for (const prop of Object.keys(effect.properties)) {
const propInfo = effect.properties[prop];
let uniformInfo;
// always try getting the type from shaders first
if (propInfo.tech !== undefined && propInfo.pass !== undefined) {
const pname = effect.techniques[propInfo.tech].passes[propInfo.pass].program;
uniformInfo = programs[pname].uniforms.find((u) => u.name === prop);
} else {
for (const p of Object.keys(programs)) {
uniformInfo = programs[p].uniforms.find((u) => u.name === prop);
if (uniformInfo) { break; }
}
}
// the property is not defined in all the shaders used in techs
if (!uniformInfo) {
console.warn(`illegal property: ${prop}`);
continue;
}
// TODO: different param with same name for different passes
props[prop] = genPropInfo(
propInfo.displayName || uniformInfo.displayName,
propInfo.type || uniformInfo.type,
propInfo.value || uniformInfo.value);
}
return props;
};
})();
const parseEffect = (effect: EffectAsset) => {
// techniques
const techNum = effect.techniques.length;
const programs = getInvolvedPrograms(effect);
const techniques = new Array(techNum);
let tech;
for (let j = 0; j < techNum; ++j) {
tech = effect.techniques[j];
const passNum = tech.passes.length;
const passes = new Array(passNum);
for (let k = 0; k < passNum; ++k) {
const passInfo = tech.passes[k];
passInfo.device = cc.game._renderContext;
passes[k] = Pass.create(passInfo);
}
techniques[j] = new Technique(tech.queue, tech.priority, tech.lod, passes);
}
// uniforms
const props = parseProperties(effect, programs);
const uniforms = {};
for (const pn of Object.keys(programs)) {
programs[pn].uniforms.forEach((u) => {
const prop = props[u.name];
uniforms[u.name] = {
type: prop ? prop.type : u.type,
value: prop ? prop.value : getInstanceCtor(u.type)(u.value),
};
});
}
return new Effect(effect.name, techniques, programs, uniforms);
};
let parseForInspector = (effect: EffectAsset) => {};
if (CC_EDITOR) {
parseForInspector = (effect: EffectAsset) => {
const programs = getInvolvedPrograms(effect);
const props = parseProperties(effect, programs);
const defines = {};
for (const pn of Object.keys(programs)) {
programs[pn].uniforms.forEach((u) => {
const prop = props[u.name];
if (!prop) { return; }
prop.defines = u.defines;
});
programs[pn].defines.forEach((define) => {
defines[define.name] = {
instanceType: getInstanceType(define.type),
value: getInstanceCtor(define.type)(),
defines: define.defines,
};
});
}
return { props, defines };
};
}
interface PropertyMap {
[name: string]: { type: number, value: any };
}
interface DefineMap {
[name: string]: number | boolean;
}
interface DependencyMap {
[define: string]: string;
}
interface ProgramInfo {
uniforms: Array< { name: string, type: string } >;
defines: Array< { name: string, type: string } >;
extensions: Array< { name: string, define: string } >;
}
interface Programs {
[name: string]: ProgramInfo;
}
class Effect {
public static parseEffect = parseEffect;
public static parseForInspector = parseForInspector;
public static setGlobalLod(lod: number) { _globalTechLod = lod; }
protected _name: string = '';
protected _techniques: Technique[] = [];
protected _properties: PropertyMap = {};
protected _programs: Programs = {};
protected _defines: DefineMap = {};
protected _dependencies: DependencyMap = {};
protected _maxLOD: number = 0;
protected _activeTechIdx: number = 0;
constructor(name: string, techniques: Technique[], programs: Programs, properties: PropertyMap = {}, lod = -1) {
this._name = name;
this._techniques = techniques;
this._properties = properties;
this._programs = programs;
this._defines = {};
this._dependencies = {};
this._maxLOD = lod;
this.selectTechnique();
}
set LOD(lod: number) {
if (lod === this._maxLOD) {
return;
}
this._maxLOD = lod;
this.selectTechnique();
}
public clear() {
this._techniques.length = 0;
this._properties = {};
this._defines = {};
this._dependencies = {};
}
public getTechnique(index: number) {
if (index < 0 || index >= this._techniques.length) { return null; }
return this._techniques[index];
}
public getProperty(name: string) {
if (!this._properties[name]) {
console.warn(`Failed to get property ${name}, property not found.`);
return null;
}
return this._properties[name].value;
}
public setProperty(name: string, value: any) {
const prop = this._properties[name];
if (!prop) {
console.warn(`Failed to set property ${name}, property not found.`);
return;
} else if (!typeCheck(value, prop.type)) {
console.warn(`Failed to set property ${name}, property type mismatch.`);
return;
}
this._properties[name].value = value;
}
public getDefine(name: string) {
const def = this._defines[name];
if (def !== undefined) { return def; }
console.warn(`Failed to get define ${name}, define not found.`);
return null;
}
public define(name: string, value: number | boolean) {
if (this._defines[name] !== undefined) {
this._defines[name] = value;
} else {
console.warn(`Failed to set define ${name}, define not found.`);
}
}
public extractDefines(out = {}) {
return Object.assign(out, this._defines);
}
public extractDependencies(out = {}) {
return Object.assign(out, this._dependencies);
}
public getActiveTechnique() {
return this._techniques[this._activeTechIdx];
}
public selectTechnique() {
const lod = this._maxLOD === -1 ? _globalTechLod : this._maxLOD;
this._activeTechIdx = 0;
for (let i = 0; i < this._techniques.length; i++) {
if (this._techniques[i]._lod <= lod) {
this._activeTechIdx = i;
break;
}
}
// defines
this._defines = {};
this._techniques[this._activeTechIdx].passes.forEach((pass) =>
this._programs[pass._programName].defines.forEach((def) =>
this._defines[def.name] = getInstanceCtor(def.type)()));
// extensions
this._dependencies = {};
this._techniques[this._activeTechIdx].passes.forEach((pass) => this._programs[pass._programName].extensions
.filter((ext) => ext.define).forEach((ext) => this._dependencies[ext.define] = ext.name));
}
}
export default Effect;
cc.Effect = Effect;
+38 -26
View File
@@ -1,46 +1,58 @@
// Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
import { PassStage } from './constants';
import { GFXBuffer } from '../../gfx/buffer';
import { GFXSampler } from '../../gfx/sampler';
import { GFXDevice } from '../../gfx/device';
import { GFXDepthStencilAttachment, GFXColorAttachment } from '../../gfx/render-pass';
import { GFXPipelineState, GFXRasterizerState, GFXDepthStencilState, GFXBlendState, GFXInputState } from '../../gfx/pipeline-state';
import { GFXBindingLayoutInfo } from '../../gfx/binding-layout';
import { GFXPrimitiveMode } from '../../gfx/gfx-define';
import { GFXBuffer } from '../../gfx/buffer';
import { GFXPrimitiveMode } from '../../gfx/define';
import { GFXDevice } from '../../gfx/device';
import { GFXBlendState, GFXBlendTarget, GFXDepthStencilState, GFXInputState,
GFXPipelineState, GFXRasterizerState } from '../../gfx/pipeline-state';
import { GFXColorAttachment, GFXDepthStencilAttachment } from '../../gfx/render-pass';
import { GFXSampler } from '../../gfx/sampler';
import { PassStage } from './constants';
interface PassInfo {
programName?: string;
export interface PassInfo {
device: GFXDevice;
program: string;
primitive?: GFXPrimitiveMode;
stage?: PassStage;
inputState?: GFXInputState;
rasterizerState?: GFXRasterizerState;
depthStencilState?: GFXDepthStencilState;
blendState?: GFXBlendState;
blendTarget?: GFXBlendTarget;
bindingLayoutInfo?: GFXBindingLayoutInfo;
colorAttachment?: GFXColorAttachment;
depthStencilAttachment?: GFXDepthStencilAttachment;
}
export default class Pass {
static create(info: PassInfo) {
let pass = new Pass();
let device = pass._device = cc.game._renderContext;
pass._programName = info.programName || '';
export class Pass {
public static create(info: PassInfo) {
const pass = new Pass();
const device = pass._device = info.device;
pass._programName = info.program;
pass._stage = info.stage || PassStage.DEFAULT;
// pipeline state
const shader = device.createShader({ name: info.program, stages: [] });
if (!shader) { console.error('create shader failed'); return; }
const bindingLayout = device.createBindingLayout(info.bindingLayoutInfo || { bindings: [] });
if (!bindingLayout) { console.error('create binding layout failed'); return; }
const layout = device.createPipelineLayout({ layouts: [bindingLayout] });
if (!layout) { console.error('create pipeline layout failed'); return; }
const renderPass = device.createRenderPass({
colorAttachments: [Object.assign(new GFXColorAttachment(), info.colorAttachment)],
depthStencilAttachment: Object.assign(new GFXDepthStencilAttachment(), info.depthStencilAttachment),
});
if (!renderPass) { console.error('create render pass failed'); return; }
const bs = Object.assign(new GFXBlendState(), info.blendState);
Object.assign(bs.targets[0], info.blendTarget);
pass._pipelineState = device.createPipelineState({
primitive: info.primitive || GFXPrimitiveMode.TRIANGLE_LIST,
shader: null,
is: Object.assign(new GFXInputState, info.inputState),
rs: Object.assign(new GFXRasterizerState, info.rasterizerState),
dss: Object.assign(new GFXDepthStencilState, info.depthStencilState),
bs: Object.assign(new GFXBlendState, info.blendState),
layout: device.createPipelineLayout({
layouts: [device.createBindingLayout(info.bindingLayoutInfo || { bindings: [] })]
}),
renderPass: device.createRenderPass({
colorAttachments: [new GFXColorAttachment],
depthStencilAttachment: new GFXDepthStencilAttachment
})
is: Object.assign(new GFXInputState(), info.inputState),
rs: Object.assign(new GFXRasterizerState(), info.rasterizerState),
dss: Object.assign(new GFXDepthStencilState(), info.depthStencilState),
bs, shader, layout, renderPass,
});
}
@@ -1,24 +1,25 @@
// Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
import { RenderQueue } from "./constants";
import { RenderQueue } from './constants';
import { Pass } from './pass';
let _genID = 0;
export default class Technique {
/**
* @param {Array} stages
* @param {Array} passes
* @param {Number} renderQueue
*/
protected _id: number = -1;
protected _renderQueue: number = RenderQueue.OPAQUE;
protected _priority: number = 0;
protected _lod: number = -1;
protected _passes: Pass[] = [];
constructor(renderQueue = RenderQueue.OPAQUE, priority = 0, lod = -1, passes = []) {
this._id = _genID++;
this._renderQueue = renderQueue;
this._priority = priority;
this._lod = lod;
this._passes = passes;
// TODO: this._version = 'webgl' or 'webgl2' // ????
}
setRenderQueue(renderQueue) {
public setRenderQueue(renderQueue: number) {
this._renderQueue = renderQueue;
}
+1 -1
View File
@@ -3,7 +3,7 @@ import { createIA } from './utils';
import config from './config';
import { RenderQueue, PassStage } from './core/constants';
import Pass from './core/pass';
import { Pass } from './core/pass';
import Technique from './core/technique';
import Effect from './core/effect';
import InputAssembler from './core/input-assembler';
+5 -5
View File
@@ -17,12 +17,12 @@
"./cocos2d/audio/**/*",
"./cocos2d/core/CCDebug.js",
"./cocos2d/core/CCDirector.js",
"./cocos2d/core/director.js",
"./cocos2d/core/CCNode.js",
"./cocos2d/core/CCPrivateNode.js",
"./cocos2d/core/CCScene.js",
"./cocos2d/core/CCGame.js",
"./cocos2d/core/CCScheduler.js",
"./cocos2d/core/game.js",
"./cocos2d/core/scheduler.js",
"./cocos2d/core/assets/**/*",
@@ -42,7 +42,7 @@
"!./cocos2d/core/load-pipeline/asset-table.js",
"./cocos2d/core/physics/**/*",
"./cocos2d/core/platform/**/*",
"!./cocos2d/core/platform/BKInputManager.js",
"!./cocos2d/core/platform/CCAssetLibrary.js",
@@ -79,4 +79,4 @@
"./extensions/ccpool/*.js",
"./extensions/spine/*.js",
"./extensions/dragonbones/*.js"
]
]
+56 -55
View File
@@ -1,62 +1,63 @@
{
"compilerOptions": {
/* Basic Options */
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
"allowJs": false, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./dist", /* Redirect output structure to the directory. */
"rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
"compilerOptions": {
/* Basic Options */
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"lib": ["es2015", "es2017", "dom"],
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
"allowJs": false, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./dist", /* Redirect output structure to the directory. */
"rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Experimental Options */
"experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
}
//"include" : ["./source"]
//"exclude" : ["js"]
}
//"include" : ["./source"]
//"exclude" : ["js"]
}