Merge pull request #90 from YunHsiao/gfx

pass priority
This commit is contained in:
Weiliang Wang
2019-01-22 11:27:44 +08:00
committed by GitHub
6 changed files with 44 additions and 20 deletions
+1
View File
@@ -12,6 +12,7 @@ export interface IPropertyInfo {
export interface IPassInfo {
program: string;
// effect-writer part
priority?: number;
primitive?: GFXPrimitiveMode;
stage?: RenderPassStage;
rasterizerState?: GFXRasterizerState;
+4
View File
@@ -163,6 +163,10 @@ export class ModelComponent extends RenderableComponent {
this._model = null;
}
get model () {
return this._model;
}
onLoad() {
}
+6
View File
@@ -791,3 +791,9 @@ export function GFXGetTypeSize (type: GFXType): number {
}
}
}
export enum GFXPassPriority {
MIN = 0,
MAX = 0xff,
DEFAULT = 0x80,
}
+9 -9
View File
@@ -25,23 +25,28 @@ export class WebGLGFXCommandPool<T> {
}
}
/* */
public alloc (clazz: new() => T): T {
return new clazz();
}
/*
/* *
public alloc (clazz: new() => T): T {
if (this._count >= this._data.length) {
const size = this._data.length * 2;
for (let i = this._data.length; i < size; ++i) {
this._data[i] = new clazz();
this._objIdx.set(this._data[i], i);
}
}
return this._data[this._count++];
}
*/
/* */
/* */
public free (obj: T) {
}
/* *
public freeAt (idx: number) {
if (idx >= this._count) {
return;
@@ -55,18 +60,13 @@ export class WebGLGFXCommandPool<T> {
this._objIdx.set(this._data[last], last);
this._count -= 1;
}
public free (obj: T) {
}
/*
public free (obj: T) {
const idx = this._objIdx.get(obj);
if (idx !== undefined) {
this.freeAt(idx);
}
}
*/
/* */
}
export class WebGLGFXCommandAllocator extends GFXCommandAllocator {
+13 -10
View File
@@ -5,7 +5,7 @@ import { color4, mat2, mat3, mat4, vec2, vec3, vec4 } from '../../core/vmath';
import { GFXBindingLayout, IGFXBinding } from '../../gfx/binding-layout';
import { GFXBuffer } from '../../gfx/buffer';
import { GFXBindingType, GFXBufferUsageBit, GFXDynamicState,
GFXMemoryUsageBit, GFXPrimitiveMode, GFXType } from '../../gfx/define';
GFXMemoryUsageBit, GFXPassPriority, GFXPrimitiveMode, GFXType } from '../../gfx/define';
import { GFXDevice } from '../../gfx/device';
import { GFXPipelineLayout } from '../../gfx/pipeline-layout';
import { GFXBlendState, GFXBlendTarget, GFXDepthStencilState,
@@ -107,6 +107,7 @@ export class Pass {
protected _resources: IPassResources[] = [];
// internal data
protected _programName: string = '';
protected _priority: GFXPassPriority = GFXPassPriority.DEFAULT;
protected _primitive: GFXPrimitiveMode = GFXPrimitiveMode.TRIANGLE_LIST;
protected _stage: RenderPassStage = RenderPassStage.DEFAULT;
protected _bindings: IGFXBinding[] = [];
@@ -312,6 +313,7 @@ export class Pass {
}
protected _fillinPipelineInfo (info: PassOverrides) {
if (info.priority !== undefined) { this._priority = info.priority; }
if (info.primitive !== undefined) { this._primitive = info.primitive; }
if (info.stage !== undefined) { this._stage = info.stage; }
if (info.dynamics !== undefined) { this._dynamicStates = info.dynamics; }
@@ -331,15 +333,16 @@ export class Pass {
}
get programName () { return this._programName; }
get primitive (): GFXPrimitiveMode { return this._primitive; }
get stage (): RenderPassStage { return this._stage; }
get bindings (): IGFXBinding[] { return this._bindings; }
get blendState (): GFXBlendState { return this._bs; }
get depthStencilState (): GFXDepthStencilState { return this._dss; }
get rasterizerState (): GFXRasterizerState { return this._rs; }
get shader (): GFXShader | null { return this._shader; }
get renderPass (): GFXRenderPass | null { return this._renderPass; }
get dynamics (): IPassDynamics { return this._dynamics; }
get priority () { return this._priority; }
get primitive () { return this._primitive; }
get stage () { return this._stage; }
get bindings () { return this._bindings; }
get blendState () { return this._bs; }
get depthStencilState () { return this._dss; }
get rasterizerState () { return this._rs; }
get shader () { return this._shader; }
get renderPass () { return this._renderPass; }
get dynamics () { return this._dynamics; }
}
function serializeBlendState (bs: GFXBlendState) {
+11 -1
View File
@@ -1,7 +1,7 @@
import { Material } from '../../3d/assets/material';
import { IRenderingSubmesh } from '../../3d/assets/mesh';
import { GFXCommandBuffer } from '../../gfx/command-buffer';
import { GFXCommandBufferType } from '../../gfx/define';
import { GFXCommandBufferType, GFXPassPriority } from '../../gfx/define';
import { GFXDevice } from '../../gfx/device';
import { GFXInputAssembler, IGFXInputAssemblerInfo } from '../../gfx/input-assembler';
import { GFXPipelineState } from '../../gfx/pipeline-state';
@@ -14,6 +14,7 @@ export class SubModel {
private _cmdBuffers: GFXCommandBuffer[];
private _psos: GFXPipelineState[] | null;
private _castShadow: boolean;
private _priority: GFXPassPriority;
constructor () {
this._subMeshObject = null;
@@ -22,6 +23,7 @@ export class SubModel {
this._psos = null;
this._castShadow = false;
this._inputAssembler = null;
this._priority = GFXPassPriority.DEFAULT;
}
public initialize (subMesh: IRenderingSubmesh, mat: Material, psos: GFXPipelineState[]) {
@@ -43,6 +45,14 @@ export class SubModel {
}
}
set priority (val: GFXPassPriority) {
this._priority = val;
}
get priority () {
return this._priority;
}
set subMeshData (sm: IRenderingSubmesh) {
if (this._inputAssembler) {
this._inputAssembler.destroy();