mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-06 19:42:39 +08:00
commit files
This commit is contained in:
@@ -6,12 +6,12 @@ const vfmt = [
|
||||
format: GFXFormat.RGB32F,
|
||||
},
|
||||
{
|
||||
name: GFXAttributeName.ATTR_COLOR,
|
||||
format: GFXFormat.RGB32F,
|
||||
name: GFXAttributeName.ATTR_TEX_COORD,
|
||||
format: GFXFormat.RG32F,
|
||||
},
|
||||
{
|
||||
name: GFXAttributeName.ATTR_TEX_COORD,
|
||||
format: GFXFormat.RGB32F,
|
||||
name: GFXAttributeName.ATTR_COLOR,
|
||||
format: GFXFormat.RGBA32F,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -292,6 +292,7 @@ export class Pass {
|
||||
}
|
||||
|
||||
get programName () { return this._programName; }
|
||||
get shader (): GFXShader { return this._shader!; }
|
||||
get pipelineState () { return this._pipelineState as GFXPipelineState; }
|
||||
get bindingLayout () { return this._bindingLayout as GFXBindingLayout; }
|
||||
get primitive (): GFXPrimitiveMode { return this._primitive; }
|
||||
|
||||
+62
-16
@@ -1,26 +1,31 @@
|
||||
|
||||
import RecyclePool from '../../3d/memop/recycle-pool';
|
||||
import { CachedArray } from '../../core/memop/cached-array';
|
||||
import { MeshBuffer, IMeshBufferInitData } from '../../3d/ui/mesh-buffer';
|
||||
import { Material } from '../../3d/assets/material';
|
||||
import RecyclePool from '../../3d/memop/recycle-pool';
|
||||
import { CanvasComponent } from '../../3d/ui/components/canvas-component';
|
||||
import { LabelComponent } from '../../3d/ui/components/label-component';
|
||||
import { SpriteComponent } from '../../3d/ui/components/sprite-component';
|
||||
import { IMeshBufferInitData, MeshBuffer } from '../../3d/ui/mesh-buffer';
|
||||
import { SpriteFrame } from '../../assets/CCSpriteFrame';
|
||||
import { CachedArray } from '../../core/memop/cached-array';
|
||||
import { Root } from '../../core/root';
|
||||
import { GFXBindingLayout } from '../../gfx/binding-layout';
|
||||
import { GFXBuffer } from '../../gfx/buffer';
|
||||
import { GFXCommandBuffer } from '../../gfx/command-buffer';
|
||||
import { GFXBufferUsageBit, GFXCommandBufferType, GFXFormat, GFXMemoryUsageBit, IGFXRect } from '../../gfx/define';
|
||||
import {
|
||||
GFXBufferUsageBit,
|
||||
GFXCommandBufferType,
|
||||
GFXFormat,
|
||||
GFXMemoryUsageBit,
|
||||
IGFXRect,
|
||||
} from '../../gfx/define';
|
||||
import { GFXDevice } from '../../gfx/device';
|
||||
import { GFXInputAssembler, IGFXInputAttribute } from '../../gfx/input-assembler';
|
||||
import { GFXPipelineLayout } from '../../gfx/pipeline-layout';
|
||||
import { GFXPipelineState } from '../../gfx/pipeline-state';
|
||||
import { vfmt } from '../../gfx/vertex-format-sample';
|
||||
import { Pass } from '../core/pass';
|
||||
import { Camera } from '../scene/camera';
|
||||
import { RenderScene } from '../scene/render-scene';
|
||||
import { CanvasComponent } from '../../3d/ui/components/canvas-component';
|
||||
import { LabelComponent } from '../../3d/ui/components/label-component';
|
||||
import { SpriteComponent } from '../../3d/ui/components/sprite-component';
|
||||
import { UIBatchModel } from './ui-batch-model';
|
||||
import { vfmt } from '../../gfx/vertex-format-sample';
|
||||
// import { GFXBuffer } from '../../gfx/buffer';
|
||||
// import { RenderComponent } from '../../3d/ui/components/ui-render-component';
|
||||
|
||||
@@ -31,6 +36,13 @@ export interface IUIBufferBatch {
|
||||
ib: GFXBuffer;
|
||||
}
|
||||
|
||||
export interface IUIMaterial {
|
||||
pass: Pass;
|
||||
bindingLayout: GFXBindingLayout;
|
||||
pipelineLayout: GFXPipelineLayout;
|
||||
pipelineState: GFXPipelineState;
|
||||
}
|
||||
|
||||
export interface IUIRenderItem {
|
||||
camera: Camera;
|
||||
pass: Pass;
|
||||
@@ -65,6 +77,7 @@ export class UI {
|
||||
private _scene: RenderScene;
|
||||
private _attributes: IGFXInputAttribute[] = [];
|
||||
private _bufferBatches: IUIBufferBatch[] = [];
|
||||
private _materials: IUIMaterial[] = [];
|
||||
private _items: CachedArray<IUIRenderItem>;
|
||||
private _commitBuffers: any[] = [];
|
||||
|
||||
@@ -109,6 +122,43 @@ export class UI {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public registerMaterial (material: Material): IUIMaterial {
|
||||
const pass = material.passes[0];
|
||||
for (const mtrl of this._materials) {
|
||||
if (mtrl.pass.shader.id === pass.shader.id) {
|
||||
return mtrl;
|
||||
}
|
||||
}
|
||||
|
||||
const bindLayout = this._device.createBindingLayout({
|
||||
bindings: [pass.binds],
|
||||
});
|
||||
|
||||
const pipelineLayout = this._device.createPipelineLayout({
|
||||
layouts: [bindLayout],
|
||||
});
|
||||
|
||||
const pipelineState = this._device.createPipelineState({
|
||||
primitive: GFXPrimitiveMode.TRIANGLE_LIST,
|
||||
shader: this._shader,
|
||||
is,
|
||||
rs: this._rs,
|
||||
dss: this._dss,
|
||||
bs: this._bs,
|
||||
layout: this._pipelineLayout,
|
||||
renderPass: this._framebuffer.renderPass as GFXRenderPass,
|
||||
});
|
||||
|
||||
this._materials.push({
|
||||
pass,
|
||||
bindLayout,
|
||||
pipelineLayout,
|
||||
pipelineState,
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
public addScreen (comp) {
|
||||
this._screens.push(comp);
|
||||
}
|
||||
@@ -171,16 +221,12 @@ export class UI {
|
||||
private _commitComp (comp) {
|
||||
const buffer = this._bufferPool.add();
|
||||
buffer.initialize({
|
||||
vertexCount: comp.renderData.vertexCount,
|
||||
indexCount: comp.renderData.indiceCount,
|
||||
vertexCount: comp.renderData!.vertexCount,
|
||||
indexCount: comp.renderData!.indiceCount,
|
||||
attributes: vfmt,
|
||||
} as IMeshBufferInitData);
|
||||
comp.updateRenderData(buffer);
|
||||
this._emit({ meshBuffer: buffer, material: comp.material} as IUIRenderData);
|
||||
}
|
||||
|
||||
private _emit (renderData: IUIRenderData) {
|
||||
this._commitBuffers.push(renderData);
|
||||
this._commitBuffers.push({ meshBuffer: buffer, material: comp.material});
|
||||
}
|
||||
|
||||
private render () {
|
||||
|
||||
Reference in New Issue
Block a user