mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
keep pipeline layouts for effect overrides (#7152)
This commit is contained in:
@@ -166,7 +166,7 @@ export interface IWebGLGPUDescriptorSetLayout {
|
||||
}
|
||||
|
||||
export interface IWebGLGPUPipelineLayout {
|
||||
setLayouts: GFXDescriptorSetLayout[];
|
||||
gpuSetLayouts: IWebGLGPUDescriptorSetLayout[];
|
||||
dynamicOffsetIndices: number[][];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { GFXPipelineLayout, IGFXPipelineLayoutInfo } from '../pipeline-layout';
|
||||
import { IWebGLGPUPipelineLayout } from './webgl-gpu-objects';
|
||||
import { IWebGLGPUPipelineLayout, IWebGLGPUDescriptorSetLayout } from './webgl-gpu-objects';
|
||||
import { WebGLDescriptorSetLayout } from './webgl-descriptor-set-layout';
|
||||
|
||||
export class WebGLPipelineLayout extends GFXPipelineLayout {
|
||||
@@ -13,12 +13,13 @@ export class WebGLPipelineLayout extends GFXPipelineLayout {
|
||||
|
||||
const dynamicOffsetIndices: number[][] = [];
|
||||
|
||||
let idx = 0;
|
||||
const gpuSetLayouts: IWebGLGPUDescriptorSetLayout[] = []; let idx = 0;
|
||||
for (let i = 0; i < this._setLayouts.length; i++) {
|
||||
const setLayout = this._setLayouts[i] as WebGLDescriptorSetLayout;
|
||||
const dynamicBindings = setLayout.gpuDescriptorSetLayout.dynamicBindings;
|
||||
const bindings = setLayout.bindings;
|
||||
const indices: number[] = [];
|
||||
gpuSetLayouts.push(setLayout.gpuDescriptorSetLayout);
|
||||
for (let j = 0, k = 0; j < bindings.length; j++) {
|
||||
if (dynamicBindings[k] === j) {
|
||||
indices.push(idx);
|
||||
@@ -32,7 +33,7 @@ export class WebGLPipelineLayout extends GFXPipelineLayout {
|
||||
}
|
||||
|
||||
this._gpuPipelineLayout = {
|
||||
setLayouts: this._setLayouts,
|
||||
gpuSetLayouts,
|
||||
dynamicOffsetIndices,
|
||||
};
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ export interface IWebGL2GPUDescriptorSetLayout {
|
||||
}
|
||||
|
||||
export interface IWebGL2GPUPipelineLayout {
|
||||
setLayouts: GFXDescriptorSetLayout[];
|
||||
gpuSetLayouts: IWebGL2GPUDescriptorSetLayout[];
|
||||
dynamicOffsetIndices: number[][];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { GFXPipelineLayout, IGFXPipelineLayoutInfo } from '../pipeline-layout';
|
||||
import { IWebGL2GPUPipelineLayout } from './webgl2-gpu-objects';
|
||||
import { IWebGL2GPUPipelineLayout, IWebGL2GPUDescriptorSetLayout } from './webgl2-gpu-objects';
|
||||
import { WebGL2DescriptorSetLayout } from './webgl2-descriptor-set-layout';
|
||||
|
||||
export class WebGL2PipelineLayout extends GFXPipelineLayout {
|
||||
@@ -13,12 +13,13 @@ export class WebGL2PipelineLayout extends GFXPipelineLayout {
|
||||
|
||||
const dynamicOffsetIndices: number[][] = [];
|
||||
|
||||
let idx = 0;
|
||||
const gpuSetLayouts: IWebGL2GPUDescriptorSetLayout[] = []; let idx = 0;
|
||||
for (let i = 0; i < this._setLayouts.length; i++) {
|
||||
const setLayout = this._setLayouts[i] as WebGL2DescriptorSetLayout;
|
||||
const dynamicBindings = setLayout.gpuDescriptorSetLayout.dynamicBindings;
|
||||
const bindings = setLayout.bindings;
|
||||
const indices: number[] = [];
|
||||
gpuSetLayouts.push(setLayout.gpuDescriptorSetLayout);
|
||||
for (let j = 0, k = 0; j < bindings.length; j++) {
|
||||
if (dynamicBindings[k] === j) {
|
||||
indices.push(idx);
|
||||
@@ -32,7 +33,7 @@ export class WebGL2PipelineLayout extends GFXPipelineLayout {
|
||||
}
|
||||
|
||||
this._gpuPipelineLayout = {
|
||||
setLayouts: this._setLayouts,
|
||||
gpuSetLayouts,
|
||||
dynamicOffsetIndices,
|
||||
};
|
||||
|
||||
|
||||
@@ -473,7 +473,6 @@ export class Pass {
|
||||
const pipeline = this._root.pipeline;
|
||||
if (!pipeline) { return null; }
|
||||
this._syncBatchingScheme();
|
||||
Object.assign(this._defines, pipeline.macros);
|
||||
const key = programLib.getKey(this._programName, this._defines);
|
||||
this._hShaderDefault = programLib.getGFXShader(this._device, this._programName, this._defines, pipeline, key);
|
||||
if (!this._hShaderDefault) { console.warn(`create shader ${this._programName} failed`); return false; }
|
||||
|
||||
@@ -227,7 +227,10 @@ class ProgramLib {
|
||||
|
||||
// store it
|
||||
this._templates[prog.name] = tmpl;
|
||||
this._pipelineLayouts[prog.name] = { hPipelineLayout: NULL_HANDLE, setLayouts: [] };
|
||||
|
||||
if (!this._pipelineLayouts[prog.name]) {
|
||||
this._pipelineLayouts[prog.name] = { hPipelineLayout: NULL_HANDLE, setLayouts: [] };
|
||||
}
|
||||
}
|
||||
|
||||
public getTemplate (name: string) {
|
||||
@@ -318,6 +321,7 @@ class ProgramLib {
|
||||
* @param pipeline 实际渲染命令执行时所属的 [[RenderPipeline]]
|
||||
*/
|
||||
public getGFXShader (device: GFXDevice, name: string, defines: MacroRecord, pipeline: RenderPipeline, key?: string) {
|
||||
Object.assign(defines, pipeline.macros);
|
||||
if (!key) key = this.getKey(name, defines);
|
||||
const res = this._cache[key];
|
||||
if (res) { return res; }
|
||||
|
||||
Reference in New Issue
Block a user