mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-05 11:02:40 +08:00
dfc3d141f2
* gfx: descriptor sets * gfx: descriptor set, singular * better structure * adapt upper layers: first pass finally all compiler errors cleared. OKAY IT'S HAPPENING EVERYBODY STAY THE ****ING CALM * adapt upper layers: second pass THERE AND BACK AGAIN * unified light pass & shadow shader * gfx: descriptor set & pipeline layout * light pass: better structure * light pass: dynamic uniform * even more type checking for memory pools * Fix particleSystem and lineComponent. * delete comment * guard pool init param * Fix trail module error. * delete space * light pass: instancing & batching support * don't polyfill gfx stuff inside EffectAsset * better light pass structure * fix spot light culling Co-authored-by: caryliu <caryliu1999@gmail.com>
67 lines
2.5 KiB
TypeScript
67 lines
2.5 KiB
TypeScript
import { GFXFramebuffer, IGFXFramebufferInfo } from '../framebuffer';
|
|
import { WebGLCmdFuncCreateFramebuffer, WebGLCmdFuncDestroyFramebuffer } from './webgl-commands';
|
|
import { WebGLDevice } from './webgl-device';
|
|
import { IWebGLGPUFramebuffer } from './webgl-gpu-objects';
|
|
import { WebGLRenderPass } from './webgl-render-pass';
|
|
import { IWebGLGPUTexture } from './webgl-gpu-objects';
|
|
import { WebGLTexture } from './webgl-texture';
|
|
|
|
export class WebGLFramebuffer extends GFXFramebuffer {
|
|
|
|
get gpuFramebuffer (): IWebGLGPUFramebuffer {
|
|
return this._gpuFramebuffer!;
|
|
}
|
|
|
|
private _gpuFramebuffer: IWebGLGPUFramebuffer | null = null;
|
|
|
|
public initialize (info: IGFXFramebufferInfo): boolean {
|
|
|
|
this._renderPass = info.renderPass;
|
|
this._colorTextures = info.colorTextures || [];
|
|
this._depthStencilTexture = info.depthStencilTexture || null;
|
|
|
|
if (info.depStencilMipmapLevel && info.depStencilMipmapLevel !== 0) {
|
|
console.warn('The mipmap level of th texture image to be attached of depth stencil attachment should be 0. Convert to 0.');
|
|
}
|
|
if (info.colorMipmapLevels && info.colorMipmapLevels.length > 0) {
|
|
for (let i = 0; i < info.colorMipmapLevels.length; ++i) {
|
|
if (info.colorMipmapLevels[i] !== 0) {
|
|
console.warn(`The mipmap level of th texture image to be attached of color attachment ${i} should be 0. Convert to 0.`);
|
|
}
|
|
}
|
|
}
|
|
|
|
const gpuColorTextures: IWebGLGPUTexture[] = [];
|
|
if (info.colorTextures !== undefined) {
|
|
for (const colorTexture of info.colorTextures) {
|
|
if (colorTexture) {
|
|
gpuColorTextures.push((colorTexture as WebGLTexture).gpuTexture);
|
|
}
|
|
}
|
|
}
|
|
|
|
let gpuDepthStencilTexture: IWebGLGPUTexture | null = null;
|
|
if (info.depthStencilTexture) {
|
|
gpuDepthStencilTexture = (info.depthStencilTexture as WebGLTexture).gpuTexture;
|
|
}
|
|
|
|
this._gpuFramebuffer = {
|
|
gpuRenderPass: (info.renderPass as WebGLRenderPass).gpuRenderPass,
|
|
gpuColorTextures,
|
|
gpuDepthStencilTexture,
|
|
glFramebuffer: null,
|
|
};
|
|
|
|
WebGLCmdFuncCreateFramebuffer(this._device as WebGLDevice, this._gpuFramebuffer);
|
|
|
|
return true;
|
|
}
|
|
|
|
public destroy () {
|
|
if (this._gpuFramebuffer) {
|
|
WebGLCmdFuncDestroyFramebuffer(this._device as WebGLDevice, this._gpuFramebuffer);
|
|
this._gpuFramebuffer = null;
|
|
}
|
|
}
|
|
}
|