mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-06 03:22:39 +08:00
commit gfx api commits (#4583)
This commit is contained in:
@@ -4,16 +4,28 @@ import { GFXDevice } from './device';
|
||||
import { GFXSampler } from './sampler';
|
||||
import { GFXTextureView } from './texture-view';
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX绑定
|
||||
*/
|
||||
export interface IGFXBinding {
|
||||
binding: number;
|
||||
type: GFXBindingType;
|
||||
name: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX绑定布局描述信息
|
||||
*/
|
||||
export interface IGFXBindingLayoutInfo {
|
||||
bindings: IGFXBinding[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX绑定单元
|
||||
*/
|
||||
export class GFXBindingUnit {
|
||||
public binding: number = 0;
|
||||
public type: GFXBindingType = GFXBindingType.UNKNOWN;
|
||||
@@ -23,21 +35,65 @@ export class GFXBindingUnit {
|
||||
public sampler: GFXSampler | null = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX绑定布局
|
||||
*/
|
||||
export abstract class GFXBindingLayout extends GFXObject {
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX设备
|
||||
*/
|
||||
protected _device: GFXDevice;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 绑定单元数组
|
||||
*/
|
||||
protected _bindingUnits: GFXBindingUnit[] = [];
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 脏数据标识
|
||||
*/
|
||||
protected _isDirty = false;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 构造函数
|
||||
* @param device GFX设备
|
||||
*/
|
||||
constructor (device: GFXDevice) {
|
||||
super(GFXObjectType.BINDING_LAYOUT);
|
||||
this._device = device;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 初始化函数
|
||||
* @param info GFX绑定布局描述信息
|
||||
*/
|
||||
public abstract initialize (info: IGFXBindingLayoutInfo): boolean;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 销毁函数
|
||||
*/
|
||||
public abstract destroy ();
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 更新
|
||||
*/
|
||||
public abstract update ();
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 在指定的binding位置上绑定缓冲
|
||||
* @param binding 绑定GFX组件的插槽
|
||||
* @param buffer GFX缓冲
|
||||
*/
|
||||
public bindBuffer (binding: number, buffer: GFXBuffer) {
|
||||
for (const bindingUnit of this._bindingUnits) {
|
||||
if (bindingUnit.binding === binding) {
|
||||
@@ -54,6 +110,12 @@ export abstract class GFXBindingLayout extends GFXObject {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 在指定的binding位置上绑定采样器
|
||||
* @param binding 绑定GFX组件的插槽
|
||||
* @param sampler GFX采样器
|
||||
*/
|
||||
public bindSampler (binding: number, sampler: GFXSampler) {
|
||||
for (const bindingUnit of this._bindingUnits) {
|
||||
if (bindingUnit.binding === binding) {
|
||||
@@ -70,6 +132,12 @@ export abstract class GFXBindingLayout extends GFXObject {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 在指定的binding位置上绑定纹理视图
|
||||
* @param binding 绑定GFX组件的插槽
|
||||
* @param texView GFX纹理视图
|
||||
*/
|
||||
public bindTextureView (binding: number, texView: GFXTextureView) {
|
||||
for (const bindingUnit of this._bindingUnits) {
|
||||
if (bindingUnit.binding === binding) {
|
||||
@@ -86,6 +154,11 @@ export abstract class GFXBindingLayout extends GFXObject {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 得到指定的binding位置上的GFX绑定单元
|
||||
* @param binding 绑定GFX组件的插槽
|
||||
*/
|
||||
public getBindingUnit (binding: number): GFXBindingUnit | null {
|
||||
for (const unit of this._bindingUnits) {
|
||||
if (unit.binding === binding) {
|
||||
|
||||
@@ -9,12 +9,20 @@ import {
|
||||
} from './define';
|
||||
import { GFXDevice } from './device';
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX Uniform信息
|
||||
*/
|
||||
export interface IGFXUniformInfo {
|
||||
name: string;
|
||||
type: GFXType;
|
||||
count: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX绘制信息
|
||||
*/
|
||||
export interface IGFXDrawInfo {
|
||||
vertexCount: number;
|
||||
firstVertex: number;
|
||||
@@ -27,12 +35,24 @@ export interface IGFXDrawInfo {
|
||||
|
||||
export const GFX_DRAW_INFO_SIZE: number = 56;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX间接缓冲
|
||||
*/
|
||||
export interface IGFXIndirectBuffer {
|
||||
drawInfos: IGFXDrawInfo[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX缓冲数据源
|
||||
*/
|
||||
export type GFXBufferSource = ArrayBuffer | IGFXIndirectBuffer;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX缓冲描述信息
|
||||
*/
|
||||
export interface IGFXBufferInfo {
|
||||
usage: GFXBufferUsage;
|
||||
memUsage: GFXMemoryUsage;
|
||||
@@ -40,24 +60,48 @@ export interface IGFXBufferInfo {
|
||||
stride?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX缓冲
|
||||
*/
|
||||
export abstract class GFXBuffer extends GFXObject {
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 缓冲使用方式
|
||||
*/
|
||||
public get usage (): GFXBufferUsage {
|
||||
return this._usage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 缓冲的内存使用方式
|
||||
*/
|
||||
public get memUsage (): GFXMemoryUsage {
|
||||
return this._memUsage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 缓冲大小
|
||||
*/
|
||||
public get size (): number {
|
||||
return this._size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 缓冲步长
|
||||
*/
|
||||
public get stride (): number {
|
||||
return this._stride;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 缓冲条目数量
|
||||
*/
|
||||
public get count (): number {
|
||||
return this._count;
|
||||
}
|
||||
@@ -68,21 +112,79 @@ export abstract class GFXBuffer extends GFXObject {
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX设备
|
||||
*/
|
||||
protected _device: GFXDevice;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 缓冲使用方式
|
||||
*/
|
||||
protected _usage: GFXBufferUsage = GFXBufferUsageBit.NONE;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 缓冲的内存使用方式
|
||||
*/
|
||||
protected _memUsage: GFXMemoryUsage = GFXMemoryUsageBit.NONE;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 缓冲大小
|
||||
*/
|
||||
protected _size: number = 0;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 缓冲步长
|
||||
*/
|
||||
protected _stride: number = 1;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 缓冲条目数量
|
||||
*/
|
||||
protected _count: number = 0;
|
||||
// protected _buffer: GFXBufferSource | null = null;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 构造函数
|
||||
* @param device GFX设备
|
||||
*/
|
||||
constructor (device: GFXDevice) {
|
||||
super(GFXObjectType.BUFFER);
|
||||
this._device = device;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 初始化函数
|
||||
* @param info GFX缓冲描述信息
|
||||
*/
|
||||
public abstract initialize (info: IGFXBufferInfo): boolean;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 销毁函数
|
||||
*/
|
||||
public abstract destroy (): void;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 重置缓冲大小
|
||||
* @param size 缓冲大小
|
||||
*/
|
||||
public abstract resize (size: number);
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 更新缓冲内容
|
||||
* @param buffer 缓冲数据源
|
||||
* @param offset 目的缓冲的偏移量
|
||||
* @param size 更新的缓冲大小
|
||||
*/
|
||||
public abstract update (buffer: GFXBufferSource, offset?: number, size?: number);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,46 @@
|
||||
import { GFXObject, GFXObjectType } from './define';
|
||||
import { GFXDevice } from './device';
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX命令分配器描述信息
|
||||
*/
|
||||
// tslint:disable-next-line:no-empty-interface
|
||||
export interface IGFXCommandAllocatorInfo {
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX命令分配器
|
||||
*/
|
||||
export abstract class GFXCommandAllocator extends GFXObject {
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX设备
|
||||
*/
|
||||
protected _device: GFXDevice;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 构造函数
|
||||
* @param device GFX设备
|
||||
*/
|
||||
constructor (device: GFXDevice) {
|
||||
super(GFXObjectType.COMMAND_ALLOCATOR);
|
||||
this._device = device;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 初始化函数
|
||||
* @param info GFX命令分配器描述信息
|
||||
*/
|
||||
public abstract initialize (info: IGFXCommandAllocatorInfo): boolean;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 销毁函数
|
||||
*/
|
||||
public abstract destroy ();
|
||||
}
|
||||
|
||||
+203
-1
@@ -3,6 +3,7 @@ import { GFXBuffer } from './buffer';
|
||||
import { GFXCommandAllocator } from './command-allocator';
|
||||
import {
|
||||
GFXBufferTextureCopy,
|
||||
GFXClearFlag,
|
||||
GFXCommandBufferType,
|
||||
GFXObject,
|
||||
GFXObjectType,
|
||||
@@ -11,7 +12,6 @@ import {
|
||||
IGFXColor,
|
||||
IGFXRect,
|
||||
IGFXViewport,
|
||||
GFXClearFlag,
|
||||
} from './define';
|
||||
import { GFXDevice } from './device';
|
||||
import { GFXFramebuffer } from './framebuffer';
|
||||
@@ -19,79 +19,281 @@ import { GFXInputAssembler } from './input-assembler';
|
||||
import { GFXPipelineState } from './pipeline-state';
|
||||
import { GFXTexture } from './texture';
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX命令缓冲描述信息
|
||||
*/
|
||||
export interface IGFXCommandBufferInfo {
|
||||
allocator: GFXCommandAllocator;
|
||||
type: GFXCommandBufferType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX深度便宜
|
||||
*/
|
||||
export interface IGFXDepthBias {
|
||||
constantFactor: number;
|
||||
clamp: number;
|
||||
slopeFactor: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX深度边界
|
||||
*/
|
||||
export interface IGFXDepthBounds {
|
||||
minBounds: number;
|
||||
maxBounds: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX模板写掩码
|
||||
*/
|
||||
export interface IGFXStencilWriteMask {
|
||||
face: GFXStencilFace;
|
||||
writeMask: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX模板比较掩码
|
||||
*/
|
||||
export interface IGFXStencilCompareMask {
|
||||
face: GFXStencilFace;
|
||||
reference: number;
|
||||
compareMask: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX命令缓冲
|
||||
*/
|
||||
// tslint:disable: max-line-length
|
||||
export abstract class GFXCommandBuffer extends GFXObject {
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 命令缓冲类型
|
||||
*/
|
||||
public get type (): GFXCommandBufferType {
|
||||
return this._type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 绘制调用次数
|
||||
*/
|
||||
public get numDrawCalls (): number {
|
||||
return this._numDrawCalls;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 绘制三角形数量
|
||||
*/
|
||||
public get numTris (): number {
|
||||
return this._numTris;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX设备
|
||||
*/
|
||||
protected _device: GFXDevice;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX命令缓冲分配器
|
||||
*/
|
||||
protected _allocator: GFXCommandAllocator | null = null;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 命令缓冲类型
|
||||
*/
|
||||
protected _type: GFXCommandBufferType = GFXCommandBufferType.PRIMARY;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 绘制调用次数
|
||||
*/
|
||||
protected _numDrawCalls: number = 0;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 绘制三角形数量
|
||||
*/
|
||||
protected _numTris: number = 0;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 构造函数
|
||||
* @param device GFX设备
|
||||
*/
|
||||
constructor (device: GFXDevice) {
|
||||
super(GFXObjectType.COMMAND_BUFFER);
|
||||
this._device = device;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 初始化函数
|
||||
* @param info GFX命令缓冲描述信息
|
||||
*/
|
||||
public abstract initialize (info: IGFXCommandBufferInfo): boolean;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 销毁函数
|
||||
*/
|
||||
public abstract destroy ();
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 开始记录命令
|
||||
*/
|
||||
public abstract begin ();
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 结束记录命令
|
||||
*/
|
||||
public abstract end ();
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 开始RenderPass
|
||||
* @param framebuffer GFX帧缓冲
|
||||
* @param renderArea 渲染区域
|
||||
* @param clearFlag 清除标识
|
||||
* @param clearColors 清除颜色数组
|
||||
* @param clearDepth 清除深度值
|
||||
* @param clearStencil 清除模板值
|
||||
*/
|
||||
public abstract beginRenderPass (framebuffer: GFXFramebuffer, renderArea: IGFXRect, clearFlag: GFXClearFlag, clearColors: IGFXColor[], clearDepth: number, clearStencil: number);
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 结束RenderPass
|
||||
*/
|
||||
public abstract endRenderPass ();
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 绑定GFX管线状态
|
||||
* @param pipelineState GFX管线状态
|
||||
*/
|
||||
public abstract bindPipelineState (pipelineState: GFXPipelineState);
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 绑定GFX绑定布局
|
||||
* @param bindingLayout GFX绑定布局
|
||||
*/
|
||||
public abstract bindBindingLayout (bindingLayout: GFXBindingLayout);
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 绑定GFX输入汇集器
|
||||
* @param inputAssembler GFX输入汇集器
|
||||
*/
|
||||
public abstract bindInputAssembler (inputAssembler: GFXInputAssembler);
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 设置视口
|
||||
* @param viewport 视口
|
||||
*/
|
||||
public abstract setViewport (viewport: IGFXViewport);
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 设置剪裁区域
|
||||
* @param scissor 剪裁区域
|
||||
*/
|
||||
public abstract setScissor (scissor: IGFXRect);
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 设置线宽
|
||||
* @param lineWidth 线的宽度
|
||||
*/
|
||||
public abstract setLineWidth (lineWidth: number);
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 设置深度偏移
|
||||
* @param depthBiasConstantFacotr
|
||||
* @param depthBiasClamp
|
||||
* @param depthBiasSlopeFactor
|
||||
*/
|
||||
public abstract setDepthBias (depthBiasConstantFacotr: number, depthBiasClamp: number, depthBiasSlopeFactor: number);
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 设置混合因子
|
||||
* @param blendConstants 混合因子
|
||||
*/
|
||||
public abstract setBlendConstants (blendConstants: number[]);
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 设置深度边界
|
||||
* @param minDepthBounds 最小深度边界
|
||||
* @param maxDepthBounds 最大深度边界
|
||||
*/
|
||||
public abstract setDepthBound (minDepthBounds: number, maxDepthBounds: number);
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 设置模板写掩码
|
||||
* @param face 三角面朝向
|
||||
* @param writeMask 写掩码
|
||||
*/
|
||||
public abstract setStencilWriteMask (face: GFXStencilFace, writeMask: number);
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 设置模板比较掩码
|
||||
* @param face 三角面朝向
|
||||
* @param reference 参考值
|
||||
* @param compareMask 比较掩码
|
||||
*/
|
||||
public abstract setStencilCompareMask (face: GFXStencilFace, reference: number, compareMask: number);
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 绘制
|
||||
* @param inputAssembler GFX输入汇集器
|
||||
*/
|
||||
public abstract draw (inputAssembler: GFXInputAssembler);
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 更新缓冲
|
||||
* @param buffer GFX缓冲
|
||||
* @param data 数据源
|
||||
* @param offset 目的缓冲的偏移量
|
||||
*/
|
||||
public abstract updateBuffer (buffer: GFXBuffer, data: ArrayBuffer, offset?: number);
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 拷贝缓冲到纹理
|
||||
* @param srcBuff 源GFX缓冲
|
||||
* @param dstTex 目的GFX纹理
|
||||
* @param dstLayout 目的纹理布局
|
||||
* @param regions 拷贝区域数组
|
||||
*/
|
||||
public abstract copyBufferToTexture (srcBuff: GFXBuffer, dstTex: GFXTexture, dstLayout: GFXTextureLayout, regions: GFXBufferTextureCopy[]);
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 执行一组命令缓冲
|
||||
* @param cmdBuffs 命令缓冲数组
|
||||
* @param count 执行命令缓冲的数组数量
|
||||
*/
|
||||
public abstract execute (cmdBuffs: GFXCommandBuffer[], count: number);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,10 @@ import { GFXDevice } from './device';
|
||||
import { GFXRenderPass } from './render-pass';
|
||||
import { GFXTextureView } from './texture-view';
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX帧缓冲描述信息
|
||||
*/
|
||||
export interface IGFXFramebufferInfo {
|
||||
renderPass: GFXRenderPass;
|
||||
colorViews: GFXTextureView[];
|
||||
@@ -10,35 +14,94 @@ export interface IGFXFramebufferInfo {
|
||||
isOffscreen?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX帧缓冲
|
||||
*/
|
||||
export abstract class GFXFramebuffer extends GFXObject {
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX渲染过程
|
||||
*/
|
||||
public get renderPass (): GFXRenderPass | null {
|
||||
return this._renderPass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 颜色纹理视图数组
|
||||
*/
|
||||
public get colorViews (): GFXTextureView[] {
|
||||
return this._colorViews;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 深度模板纹理视图
|
||||
*/
|
||||
public get depthStencilView (): GFXTextureView | null {
|
||||
return this._depthStencilView;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 是否是离屏的
|
||||
*/
|
||||
public get isOffscreen (): boolean {
|
||||
return this._isOffscreen;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX设备
|
||||
*/
|
||||
protected _device: GFXDevice;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX渲染过程
|
||||
*/
|
||||
protected _renderPass: GFXRenderPass | null = null;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 颜色纹理视图数组
|
||||
*/
|
||||
protected _colorViews: GFXTextureView[] = [];
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 深度模板纹理视图
|
||||
*/
|
||||
protected _depthStencilView: GFXTextureView | null = null;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 是否是离屏的
|
||||
*/
|
||||
protected _isOffscreen: boolean = true;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 构造函数
|
||||
* @param device GFX设备
|
||||
*/
|
||||
constructor (device: GFXDevice) {
|
||||
super(GFXObjectType.FRAMEBUFFER);
|
||||
this._device = device;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 初始化函数
|
||||
* @param info GFX帧缓冲描述信息
|
||||
*/
|
||||
public abstract initialize (info: IGFXFramebufferInfo): boolean;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 销毁函数
|
||||
*/
|
||||
public abstract destroy (): void;
|
||||
}
|
||||
|
||||
@@ -15,19 +15,52 @@ export interface IGFXPipelineLayoutInfo {
|
||||
|
||||
export abstract class GFXPipelineLayout extends GFXObject {
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX绑定布局数组
|
||||
*/
|
||||
public get layouts (): GFXBindingLayout[] {
|
||||
return this._layouts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX设备
|
||||
*/
|
||||
protected _device: GFXDevice;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 推送常量范围数组
|
||||
*/
|
||||
protected _pushConstantsRanges: IGFXPushConstantRange[] = [];
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX绑定布局数组
|
||||
*/
|
||||
protected _layouts: GFXBindingLayout[] = [];
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 构造函数
|
||||
* @param device GFX设备
|
||||
*/
|
||||
constructor (device: GFXDevice) {
|
||||
super(GFXObjectType.PIPELINE_LAYOUT);
|
||||
this._device = device;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 初始化函数
|
||||
* @param info GFX管线布局描述信息
|
||||
*/
|
||||
public abstract initialize (info: IGFXPipelineLayoutInfo): boolean;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 销毁函数
|
||||
*/
|
||||
public abstract destroy ();
|
||||
}
|
||||
|
||||
+148
-9
@@ -18,6 +18,10 @@ import { GFXPipelineLayout } from './pipeline-layout';
|
||||
import { GFXRenderPass } from './render-pass';
|
||||
import { GFXShader } from './shader';
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX光栅化状态
|
||||
*/
|
||||
export class GFXRasterizerState {
|
||||
public isDiscard: boolean = false;
|
||||
public polygonMode: GFXPolygonMode = GFXPolygonMode.FILL;
|
||||
@@ -31,6 +35,11 @@ export class GFXRasterizerState {
|
||||
public isMultisample: boolean = false;
|
||||
public lineWidth: number = 1.0;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 比较函数
|
||||
* @param state GFX光栅化状态
|
||||
*/
|
||||
public compare (state: GFXRasterizerState): boolean {
|
||||
return (this.isDiscard === state.isDiscard) &&
|
||||
(this.polygonMode === state.polygonMode) &&
|
||||
@@ -46,6 +55,10 @@ export class GFXRasterizerState {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX深度模板状态
|
||||
*/
|
||||
export class GFXDepthStencilState {
|
||||
public depthTest: boolean = true;
|
||||
public depthWrite: boolean = true;
|
||||
@@ -67,6 +80,11 @@ export class GFXDepthStencilState {
|
||||
public stencilPassOpBack: GFXStencilOp = GFXStencilOp.KEEP;
|
||||
public stencilRefBack: number = 1;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 比较函数
|
||||
* @param state GFX深度模板状态
|
||||
*/
|
||||
public compare (state: GFXDepthStencilState): boolean {
|
||||
return (this.depthTest === state.depthTest) &&
|
||||
(this.depthWrite === state.depthWrite) &&
|
||||
@@ -90,6 +108,10 @@ export class GFXDepthStencilState {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX混合目标
|
||||
*/
|
||||
export class GFXBlendTarget {
|
||||
public blend: boolean = false;
|
||||
public blendSrc: GFXBlendFactor = GFXBlendFactor.ONE;
|
||||
@@ -100,18 +122,27 @@ export class GFXBlendTarget {
|
||||
public blendAlphaEq: GFXBlendOp = GFXBlendOp.ADD;
|
||||
public blendColorMask: GFXColorMask = GFXColorMask.ALL;
|
||||
|
||||
public compare (state: GFXBlendTarget): boolean {
|
||||
return (this.blend === state.blend) &&
|
||||
(this.blendSrc === state.blendSrc) &&
|
||||
(this.blendDst === state.blendDst) &&
|
||||
(this.blendEq === state.blendEq) &&
|
||||
(this.blendSrcAlpha === state.blendSrcAlpha) &&
|
||||
(this.blendDstAlpha === state.blendDstAlpha) &&
|
||||
(this.blendAlphaEq === state.blendAlphaEq) &&
|
||||
(this.blendColorMask === state.blendColorMask);
|
||||
/**
|
||||
* @zh
|
||||
* 比较函数
|
||||
* @param target GFX混合目标
|
||||
*/
|
||||
public compare (target: GFXBlendTarget): boolean {
|
||||
return (this.blend === target.blend) &&
|
||||
(this.blendSrc === target.blendSrc) &&
|
||||
(this.blendDst === target.blendDst) &&
|
||||
(this.blendEq === target.blendEq) &&
|
||||
(this.blendSrcAlpha === target.blendSrcAlpha) &&
|
||||
(this.blendDstAlpha === target.blendDstAlpha) &&
|
||||
(this.blendAlphaEq === target.blendAlphaEq) &&
|
||||
(this.blendColorMask === target.blendColorMask);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX混合状态
|
||||
*/
|
||||
export class GFXBlendState {
|
||||
public isA2C: boolean = false;
|
||||
public isIndepend: boolean = false;
|
||||
@@ -119,10 +150,18 @@ export class GFXBlendState {
|
||||
public targets: GFXBlendTarget[] = [new GFXBlendTarget()];
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX输入状态
|
||||
*/
|
||||
export class GFXInputState {
|
||||
public attributes: IGFXAttribute[] = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX管线状态描述信息
|
||||
*/
|
||||
export interface IGFXPipelineStateInfo {
|
||||
primitive: GFXPrimitiveMode;
|
||||
shader: GFXShader;
|
||||
@@ -135,56 +174,156 @@ export interface IGFXPipelineStateInfo {
|
||||
renderPass: GFXRenderPass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX管线状态
|
||||
*/
|
||||
export abstract class GFXPipelineState extends GFXObject {
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX着色器
|
||||
*/
|
||||
public get shader (): GFXShader {
|
||||
return this._shader as GFXShader;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX图元模式
|
||||
*/
|
||||
public get primitive (): GFXPrimitiveMode {
|
||||
return this._primitive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX光栅化状态
|
||||
*/
|
||||
public get rasterizerState (): GFXRasterizerState {
|
||||
return this._rs as GFXRasterizerState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX深度模板状态
|
||||
*/
|
||||
public get depthStencilState (): GFXDepthStencilState {
|
||||
return this._dss as GFXDepthStencilState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX混合状态
|
||||
*/
|
||||
public get blendState (): GFXBlendState {
|
||||
return this._bs as GFXBlendState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX动态状态数组
|
||||
*/
|
||||
public get dynamicStates (): GFXDynamicState[] {
|
||||
return this._dynamicStates;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX管线布局
|
||||
*/
|
||||
public get pipelineLayout (): GFXPipelineLayout {
|
||||
return this._layout as GFXPipelineLayout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX渲染过程
|
||||
*/
|
||||
public get renderPass (): GFXRenderPass {
|
||||
return this._renderPass as GFXRenderPass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX设备
|
||||
*/
|
||||
protected _device: GFXDevice;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX着色器
|
||||
*/
|
||||
protected _shader: GFXShader | null = null;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX图元模式
|
||||
*/
|
||||
protected _primitive: GFXPrimitiveMode = GFXPrimitiveMode.TRIANGLE_LIST;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX输入状态
|
||||
*/
|
||||
protected _is: GFXInputState | null = null;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX光栅化状态
|
||||
*/
|
||||
protected _rs: GFXRasterizerState | null = null;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX深度模板状态
|
||||
*/
|
||||
protected _dss: GFXDepthStencilState | null = null;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX混合状态
|
||||
*/
|
||||
protected _bs: GFXBlendState | null = null;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX动态状态数组
|
||||
*/
|
||||
protected _dynamicStates: GFXDynamicState[] = [];
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX管线布局
|
||||
*/
|
||||
protected _layout: GFXPipelineLayout | null = null;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX渲染过程
|
||||
*/
|
||||
protected _renderPass: GFXRenderPass | null = null;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 构造函数
|
||||
* @param device GFX设备
|
||||
*/
|
||||
constructor (device: GFXDevice) {
|
||||
super(GFXObjectType.PIPELINE_STATE);
|
||||
this._device = device;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 初始化函数
|
||||
* @param info GFX管线状态描述信息
|
||||
*/
|
||||
public abstract initialize (info: IGFXPipelineStateInfo): boolean;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 销毁函数
|
||||
*/
|
||||
public abstract destroy (): void;
|
||||
}
|
||||
|
||||
@@ -2,25 +2,68 @@ import { GFXCommandBuffer } from './command-buffer';
|
||||
import { GFXObject, GFXObjectType, GFXQueueType } from './define';
|
||||
import { GFXDevice } from './device';
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX队列描述信息
|
||||
*/
|
||||
export interface IGFXQueueInfo {
|
||||
type: GFXQueueType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX队列
|
||||
*/
|
||||
export abstract class GFXQueue extends GFXObject {
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 队列类型
|
||||
*/
|
||||
public get type (): number {
|
||||
return this._type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX设备
|
||||
*/
|
||||
protected _device: GFXDevice;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 队列类型
|
||||
*/
|
||||
protected _type: GFXQueueType = GFXQueueType.GRAPHICS;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 构造函数
|
||||
* @param device GFX设备
|
||||
*/
|
||||
constructor (device: GFXDevice) {
|
||||
super(GFXObjectType.QUEUE);
|
||||
this._device = device;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 初始化函数
|
||||
* @param info GFX队列描述信息
|
||||
*/
|
||||
public abstract initialize (info: IGFXQueueInfo): boolean;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 销毁函数
|
||||
*/
|
||||
public abstract destroy ();
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 提交命令缓冲数组
|
||||
* @param cmdBuffs GFX命令缓冲数组
|
||||
* @param fence GFX栅栏
|
||||
*/
|
||||
public abstract submit (cmdBuffs: GFXCommandBuffer[], fence?);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,10 @@ import {
|
||||
} from './define';
|
||||
import { GFXDevice } from './device';
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX颜色附件
|
||||
*/
|
||||
export class GFXColorAttachment {
|
||||
public format: GFXFormat = GFXFormat.UNKNOWN;
|
||||
public loadOp: GFXLoadOp = GFXLoadOp.CLEAR;
|
||||
@@ -18,6 +22,10 @@ export class GFXColorAttachment {
|
||||
public endLayout: GFXTextureLayout = GFXTextureLayout.COLOR_ATTACHMENT_OPTIMAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX深度模板附件
|
||||
*/
|
||||
export class GFXDepthStencilAttachment {
|
||||
public format: GFXFormat = GFXFormat.UNKNOWN;
|
||||
public depthLoadOp: GFXLoadOp = GFXLoadOp.CLEAR;
|
||||
@@ -29,6 +37,10 @@ export class GFXDepthStencilAttachment {
|
||||
public endLayout: GFXTextureLayout = GFXTextureLayout.DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX子过程描述信息
|
||||
*/
|
||||
export interface IGFXSubPassInfo {
|
||||
bindPoint: GFXPipelineBindPoint;
|
||||
inputs: number[];
|
||||
@@ -38,24 +50,61 @@ export interface IGFXSubPassInfo {
|
||||
preserves: number[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX渲染过程描述信息
|
||||
*/
|
||||
export interface IGFXRenderPassInfo {
|
||||
colorAttachments?: GFXColorAttachment[];
|
||||
depthStencilAttachment?: GFXDepthStencilAttachment;
|
||||
// subPasses? : GFXSubPassInfo[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX渲染过程
|
||||
*/
|
||||
export abstract class GFXRenderPass extends GFXObject {
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX设备
|
||||
*/
|
||||
protected _device: GFXDevice;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX颜色附件数组
|
||||
*/
|
||||
protected _colorInfos: GFXColorAttachment[] = [];
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX深度模板附件
|
||||
*/
|
||||
protected _depthStencilInfo: GFXDepthStencilAttachment | null = null;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 构造函数
|
||||
* @param device GFX设备
|
||||
*/
|
||||
constructor (device: GFXDevice) {
|
||||
super(GFXObjectType.RENDER_PASS);
|
||||
this._device = device;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 提交命令缓冲数组
|
||||
* @param info GFX渲染过程描述信息
|
||||
*/
|
||||
public abstract initialize (info: IGFXRenderPassInfo): boolean;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 销毁函数
|
||||
*/
|
||||
public abstract destroy (): void;
|
||||
// protected _subPasses : GFXSubPassInfo[] = [];
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import { GFXAddress, GFXComparisonFunc, GFXFilter, GFXObject, GFXObjectType, IGFXColor } from './define';
|
||||
import { GFXDevice } from './device';
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX采样器描述信息
|
||||
*/
|
||||
export interface IGFXSamplerInfo {
|
||||
name?: string;
|
||||
minFilter?: GFXFilter;
|
||||
@@ -17,6 +21,10 @@ export interface IGFXSamplerInfo {
|
||||
mipLODBias?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX采样器状态
|
||||
*/
|
||||
export class GFXSamplerState {
|
||||
public name: string = '';
|
||||
public minFilter: GFXFilter = GFXFilter.LINEAR;
|
||||
@@ -32,6 +40,11 @@ export class GFXSamplerState {
|
||||
public maxLOD: number = 0;
|
||||
public mipLODBias: number = 0.0;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 比较函数
|
||||
* @param state GFX采样器状态
|
||||
*/
|
||||
public compare (state: GFXSamplerState): boolean {
|
||||
return (this.minFilter === state.minFilter) &&
|
||||
(this.magFilter === state.magFilter) &&
|
||||
@@ -51,20 +64,51 @@ export class GFXSamplerState {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX采样器
|
||||
*/
|
||||
export abstract class GFXSampler extends GFXObject {
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX采样器状态
|
||||
*/
|
||||
public get state (): GFXSamplerState {
|
||||
return this._state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX设备
|
||||
*/
|
||||
protected _device: GFXDevice;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX采样器状态
|
||||
*/
|
||||
protected _state: GFXSamplerState = new GFXSamplerState();
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 构造函数
|
||||
*/
|
||||
constructor (device: GFXDevice) {
|
||||
super(GFXObjectType.SAMPLER);
|
||||
this._device = device;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 初始化函数
|
||||
* @param info GFX采样器描述信息
|
||||
*/
|
||||
public abstract initialize (info: IGFXSamplerInfo): boolean;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 销毁函数
|
||||
*/
|
||||
public abstract destroy (): void;
|
||||
}
|
||||
|
||||
+84
-1
@@ -1,23 +1,39 @@
|
||||
import { GFXObject, GFXObjectType, GFXShaderType, GFXType } from './define';
|
||||
import { GFXDevice } from './device';
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX着色器宏
|
||||
*/
|
||||
export interface IGFXShaderMacro {
|
||||
macro: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX着色器阶段
|
||||
*/
|
||||
export interface IGFXShaderStage {
|
||||
type: GFXShaderType;
|
||||
source: string;
|
||||
macros?: IGFXShaderMacro[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX Uniform
|
||||
*/
|
||||
export class GFXUniform {
|
||||
public name: string = '';
|
||||
public type: GFXType = GFXType.UNKNOWN;
|
||||
public count: number = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX Uniform块
|
||||
*/
|
||||
export class GFXUniformBlock {
|
||||
public binding: number = -1;
|
||||
public name: string = '';
|
||||
@@ -25,6 +41,10 @@ export class GFXUniformBlock {
|
||||
public members: GFXUniform[] = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX Uniform采样器
|
||||
*/
|
||||
export class GFXUniformSampler {
|
||||
public binding: number = -1;
|
||||
public name: string = '';
|
||||
@@ -32,6 +52,10 @@ export class GFXUniformSampler {
|
||||
public count: number = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX着色器描述信息
|
||||
*/
|
||||
export interface IGFXShaderInfo {
|
||||
name: string;
|
||||
stages: IGFXShaderStage[];
|
||||
@@ -41,27 +65,86 @@ export interface IGFXShaderInfo {
|
||||
samplers?: GFXUniformSampler[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX着色器
|
||||
*/
|
||||
export abstract class GFXShader extends GFXObject {
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 着色器id
|
||||
*/
|
||||
public get id (): number {
|
||||
return this._id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 着色器名称
|
||||
*/
|
||||
public get name (): string {
|
||||
return this._name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX设备
|
||||
*/
|
||||
protected _device: GFXDevice;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 着色器id
|
||||
*/
|
||||
protected _id: number;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 着色器名称
|
||||
*/
|
||||
protected _name: string = '';
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 着色器阶段数组
|
||||
*/
|
||||
protected _stages: IGFXShaderStage[] = [];
|
||||
// protected _bindings: GFXBinding[] = [];
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 着色器Uniform块数组
|
||||
*/
|
||||
protected _blocks: GFXUniformBlock[] = []; // blocks are used for being compatible with single uniforms
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 着色器Uniform采样器数组
|
||||
*/
|
||||
protected _samplers: GFXUniformSampler[] = [];
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 构造函数
|
||||
* @param device GFX设备
|
||||
*/
|
||||
constructor (device: GFXDevice) {
|
||||
super(GFXObjectType.SHADER);
|
||||
this._device = device;
|
||||
this._id = device.genShaderId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 初始化函数
|
||||
* @param info GFX着色器描述信息
|
||||
*/
|
||||
public abstract initialize (info: IGFXShaderInfo): boolean;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 销毁函数
|
||||
*/
|
||||
public abstract destroy ();
|
||||
public get name () { return this._name; }
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@ import { GFXFormat, GFXObject, GFXObjectType, GFXTextureViewType } from './defin
|
||||
import { GFXDevice } from './device';
|
||||
import { GFXTexture } from './texture';
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX纹理视图描述信息
|
||||
*/
|
||||
export interface IGFXTextureViewInfo {
|
||||
texture: GFXTexture;
|
||||
type: GFXTextureViewType;
|
||||
@@ -12,50 +16,136 @@ export interface IGFXTextureViewInfo {
|
||||
layerCount?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX纹理视图
|
||||
*/
|
||||
export abstract class GFXTextureView extends GFXObject {
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX纹理
|
||||
*/
|
||||
public get texture (): GFXTexture {
|
||||
return this._texture as GFXTexture;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理视图类型
|
||||
*/
|
||||
public get type (): GFXTextureViewType {
|
||||
return this._type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理视图格式
|
||||
*/
|
||||
public get format (): GFXFormat {
|
||||
return this._format;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理视图基础层级
|
||||
*/
|
||||
public get baseLevel (): number {
|
||||
return this._baseLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理视图层级数量
|
||||
*/
|
||||
public get levelCount (): number {
|
||||
return this._levelCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理视图基础图层
|
||||
*/
|
||||
public get baseLayer (): number {
|
||||
return this._baseLayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理视图图层数量
|
||||
*/
|
||||
public get layerCount (): number {
|
||||
return this._layerCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX设备
|
||||
*/
|
||||
protected _device: GFXDevice;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX纹理
|
||||
*/
|
||||
protected _texture: GFXTexture | null = null;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理视图类型
|
||||
*/
|
||||
protected _type: GFXTextureViewType = GFXTextureViewType.TV2D;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理视图格式
|
||||
*/
|
||||
protected _format: GFXFormat = GFXFormat.UNKNOWN;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理视图基础层级
|
||||
*/
|
||||
protected _baseLevel: number = 0;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理视图层级数量
|
||||
*/
|
||||
protected _levelCount: number = 1;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理视图基础图层
|
||||
*/
|
||||
protected _baseLayer: number = 0;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理视图图层数量
|
||||
*/
|
||||
protected _layerCount: number = 1;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 构造函数
|
||||
* @param device GFX设备
|
||||
*/
|
||||
constructor (device: GFXDevice) {
|
||||
super(GFXObjectType.TEXTURE_VIEW);
|
||||
this._device = device;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 初始化函数
|
||||
* @param info GFX纹理视图描述信息
|
||||
*/
|
||||
public abstract initialize (info: IGFXTextureViewInfo): boolean;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 销毁函数
|
||||
*/
|
||||
public abstract destroy (): void;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,10 @@ import {
|
||||
} from './define';
|
||||
import { GFXDevice } from './device';
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX纹理描述信息
|
||||
*/
|
||||
export interface IGFXTextureInfo {
|
||||
type: GFXTextureType;
|
||||
usage: GFXTextureUsage;
|
||||
@@ -24,77 +28,220 @@ export interface IGFXTextureInfo {
|
||||
flags?: GFXTextureFlags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX纹理
|
||||
*/
|
||||
export abstract class GFXTexture extends GFXObject {
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理类型
|
||||
*/
|
||||
public get type (): GFXTextureType {
|
||||
return this._type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理使用方式
|
||||
*/
|
||||
public get usage (): GFXTextureUsage {
|
||||
return this._usage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理格式
|
||||
*/
|
||||
public get format (): GFXFormat {
|
||||
return this._format;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理宽度
|
||||
*/
|
||||
public get width (): number {
|
||||
return this._width;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理高度
|
||||
*/
|
||||
public get height (): number {
|
||||
return this._height;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理深度
|
||||
*/
|
||||
public get depth (): number {
|
||||
return this._depth;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理数组层数
|
||||
*/
|
||||
public get arrayLayer (): number {
|
||||
return this._arrayLayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理mip层级数
|
||||
*/
|
||||
public get mipLevel (): number {
|
||||
return this._mipLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理采样数
|
||||
*/
|
||||
public get samples (): GFXSampleCount {
|
||||
return this._samples;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理标识位
|
||||
*/
|
||||
public get flags (): GFXTextureFlags {
|
||||
return this._flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理大小
|
||||
*/
|
||||
public get size (): number {
|
||||
return this._size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理缓冲
|
||||
*/
|
||||
public get buffer (): ArrayBuffer | null {
|
||||
return this._buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX设备
|
||||
*/
|
||||
protected _device: GFXDevice;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理类型
|
||||
*/
|
||||
protected _type: GFXTextureType = GFXTextureType.TEX2D;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理使用方式
|
||||
*/
|
||||
protected _usage: GFXTextureUsage = GFXTextureUsageBit.NONE;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理格式
|
||||
*/
|
||||
protected _format: GFXFormat = GFXFormat.UNKNOWN;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理宽度
|
||||
*/
|
||||
protected _width: number = 0;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理高度
|
||||
*/
|
||||
protected _height: number = 0;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理深度
|
||||
*/
|
||||
protected _depth: number = 1;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理数组层数
|
||||
*/
|
||||
protected _arrayLayer: number = 1;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理mip层级数
|
||||
*/
|
||||
protected _mipLevel: number = 1;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理采样数
|
||||
*/
|
||||
protected _samples: GFXSampleCount = GFXSampleCount.X1;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理标识位
|
||||
*/
|
||||
protected _flags: GFXTextureFlags = GFXTextureFlagBit.NONE;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 是否是2次幂大小
|
||||
*/
|
||||
protected _isPowerOf2: boolean = false;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理大小
|
||||
*/
|
||||
protected _size: number = 0;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 纹理缓冲
|
||||
*/
|
||||
protected _buffer: ArrayBuffer | null = null;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 构造函数
|
||||
* @param device GFX设备
|
||||
*/
|
||||
constructor (device: GFXDevice) {
|
||||
super(GFXObjectType.TEXTURE);
|
||||
this._device = device;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 初始化函数
|
||||
* @param info GFX纹理描述信息
|
||||
*/
|
||||
public abstract initialize (info: IGFXTextureInfo): boolean;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 销毁函数
|
||||
*/
|
||||
public abstract destroy ();
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 重置纹理大小
|
||||
* @param width 纹理宽度
|
||||
* @param height 纹理高度
|
||||
*/
|
||||
public abstract resize (width: number, height: number);
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import { GFXAttributeName, GFXFormat } from './define';
|
||||
|
||||
const vfmt = [
|
||||
{
|
||||
name: GFXAttributeName.ATTR_POSITION,
|
||||
format: GFXFormat.RGB32F,
|
||||
},
|
||||
{
|
||||
name: GFXAttributeName.ATTR_TEX_COORD,
|
||||
format: GFXFormat.RG32F,
|
||||
},
|
||||
{
|
||||
name: GFXAttributeName.ATTR_COLOR,
|
||||
format: GFXFormat.RGBA32F,
|
||||
},
|
||||
];
|
||||
|
||||
export {
|
||||
vfmt,
|
||||
};
|
||||
@@ -5,6 +5,10 @@ import { GFXRenderPass } from './render-pass';
|
||||
import { GFXTexture } from './texture';
|
||||
import { GFXTextureView } from './texture-view';
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX窗口描述信息
|
||||
*/
|
||||
export interface IGFXWindowInfo {
|
||||
title?: string;
|
||||
left?: number;
|
||||
@@ -16,64 +20,206 @@ export interface IGFXWindowInfo {
|
||||
isOffscreen?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX窗口
|
||||
*/
|
||||
export abstract class GFXWindow extends GFXObject {
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 窗口宽度
|
||||
*/
|
||||
public get width (): number {
|
||||
return this._width;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 窗口高度
|
||||
*/
|
||||
public get height (): number {
|
||||
return this._height;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 窗口颜色格式
|
||||
*/
|
||||
public get colorFormat (): GFXFormat {
|
||||
return this._colorFmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 窗口深度模板格式
|
||||
*/
|
||||
public get detphStencilFormat (): GFXFormat {
|
||||
return this._depthStencilFmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX渲染过程
|
||||
*/
|
||||
public get renderPass (): GFXRenderPass {
|
||||
return this._renderPass!;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 颜色纹理视图
|
||||
*/
|
||||
public get colorTexView (): GFXTextureView | null {
|
||||
return this._colorTexView;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 深度模板纹理视图
|
||||
*/
|
||||
public get depthStencilTexView (): GFXTextureView | null {
|
||||
return this._depthStencilTexView;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX帧缓冲
|
||||
*/
|
||||
public get framebuffer (): GFXFramebuffer {
|
||||
return this._framebuffer!;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX设备
|
||||
*/
|
||||
protected _device: GFXDevice;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 标题
|
||||
*/
|
||||
protected _title: string = '';
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 左侧距离
|
||||
*/
|
||||
protected _left: number = 0;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 顶部距离
|
||||
*/
|
||||
protected _top: number = 0;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 窗口宽度
|
||||
*/
|
||||
protected _width: number = 0;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 窗口高度
|
||||
*/
|
||||
protected _height: number = 0;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 原生宽度
|
||||
*/
|
||||
protected _nativeWidth: number = 0;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 原生高度
|
||||
*/
|
||||
protected _nativeHeight: number = 0;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 颜色格式
|
||||
*/
|
||||
protected _colorFmt: GFXFormat = GFXFormat.UNKNOWN;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 深度模板格式
|
||||
*/
|
||||
protected _depthStencilFmt: GFXFormat = GFXFormat.UNKNOWN;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 是否是离屏的
|
||||
*/
|
||||
protected _isOffscreen: boolean = false;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX渲染过程
|
||||
*/
|
||||
protected _renderPass: GFXRenderPass | null = null;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 颜色纹理
|
||||
*/
|
||||
protected _colorTex: GFXTexture | null = null;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 颜色纹理视图
|
||||
*/
|
||||
protected _colorTexView: GFXTextureView | null = null;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 深度模板纹理
|
||||
*/
|
||||
protected _depthStencilTex: GFXTexture | null = null;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 深度模板纹理视图
|
||||
*/
|
||||
protected _depthStencilTexView: GFXTextureView | null = null;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* GFX帧缓冲
|
||||
*/
|
||||
protected _framebuffer: GFXFramebuffer | null = null;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 构造函数
|
||||
* @param device GFX设备
|
||||
*/
|
||||
constructor (device: GFXDevice) {
|
||||
super(GFXObjectType.WINDOW);
|
||||
this._device = device;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 初始化函数
|
||||
* @param info GFX窗口描述信息
|
||||
*/
|
||||
public abstract initialize (info: IGFXWindowInfo): boolean;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 销毁函数
|
||||
*/
|
||||
public abstract destroy ();
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 重置窗口大小
|
||||
* @param width 窗口宽度
|
||||
* @param height 窗口高度
|
||||
*/
|
||||
public abstract resize (width: number, height: number);
|
||||
}
|
||||
|
||||
+16
-1
@@ -8,11 +8,11 @@ import { Root } from '../../core/root';
|
||||
import { GFXBindingLayout } from '../../gfx/binding-layout';
|
||||
import { GFXCommandBuffer } from '../../gfx/command-buffer';
|
||||
import { GFXCommandBufferType } from '../../gfx/define';
|
||||
import { GFXAttributeName, GFXFormat } from '../../gfx/define';
|
||||
import { GFXDevice } from '../../gfx/device';
|
||||
import { IGFXAttribute } from '../../gfx/input-assembler';
|
||||
import { GFXPipelineState } from '../../gfx/pipeline-state';
|
||||
import { GFXTextureView } from '../../gfx/texture-view';
|
||||
import { vfmt } from '../../gfx/vertex-format-sample';
|
||||
import { Node } from '../../scene-graph/node';
|
||||
import { Camera } from '../scene/camera';
|
||||
import { Model } from '../scene/model';
|
||||
@@ -20,6 +20,21 @@ import { RenderScene } from '../scene/render-scene';
|
||||
import { UIBatchModel } from './ui-batch-model';
|
||||
import { UIMaterial } from './ui-material';
|
||||
|
||||
const vfmt = [
|
||||
{
|
||||
name: GFXAttributeName.ATTR_POSITION,
|
||||
format: GFXFormat.RGB32F,
|
||||
},
|
||||
{
|
||||
name: GFXAttributeName.ATTR_TEX_COORD,
|
||||
format: GFXFormat.RG32F,
|
||||
},
|
||||
{
|
||||
name: GFXAttributeName.ATTR_COLOR,
|
||||
format: GFXFormat.RGBA32F,
|
||||
},
|
||||
];
|
||||
|
||||
export class UIDrawBatch {
|
||||
public camera: Camera | null = null;
|
||||
public bufferBatch: MeshBuffer | null = null;
|
||||
|
||||
Reference in New Issue
Block a user