Skip to content

Commit

Permalink
Merge pull request #6 from YunHsiao/gfx
Browse files Browse the repository at this point in the history
pass refactor
  • Loading branch information
jerrywwl authored Jan 2, 2019
2 parents 94b7a58 + af2789f commit f394575
Show file tree
Hide file tree
Showing 45 changed files with 756 additions and 684 deletions.
38 changes: 19 additions & 19 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.

Expand All @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion EngineErrorMap.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
46 changes: 0 additions & 46 deletions cocos/3d/assets/effect-asset.js

This file was deleted.

92 changes: 92 additions & 0 deletions cocos/3d/assets/effect-asset.ts
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 2 additions & 2 deletions cocos/3d/builtin/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand All @@ -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"]}
],
Expand Down
2 changes: 1 addition & 1 deletion cocos/camera/CCCamera.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
12 changes: 6 additions & 6 deletions cocos/core/CCDirector.js → cocos/core/director.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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。
Expand Down
3 changes: 1 addition & 2 deletions cocos/core/CCGame.js → cocos/core/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down Expand Up @@ -793,7 +792,7 @@ var game = {
// renderer.initWebGL(localCanvas, opts);
// this._renderContext = renderer.device._gl;
}

if (!this._gfxDevice) {
//if (!this._renderContext) {

Expand Down
6 changes: 3 additions & 3 deletions cocos/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Loading

0 comments on commit f394575

Please sign in to comment.