pixi.js
Version:
<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">
52 lines (49 loc) • 1.93 kB
JavaScript
import { BufferResource } from '../../rendering/renderers/shared/buffer/BufferResource.mjs';
import { UniformGroup } from '../../rendering/renderers/shared/shader/UniformGroup.mjs';
import { TextureSource } from '../../rendering/renderers/shared/texture/sources/TextureSource.mjs';
import { TextureStyle } from '../../rendering/renderers/shared/texture/TextureStyle.mjs';
;
function generateShaderSyncPolyfill() {
return syncShader;
}
function syncShader(renderer, shader, syncData) {
const gl = renderer.gl;
const shaderSystem = renderer.shader;
const programData = shaderSystem._getProgramData(shader.glProgram);
for (const i in shader.groups) {
const bindGroup = shader.groups[i];
for (const j in bindGroup.resources) {
const resource = bindGroup.resources[j];
if (resource instanceof UniformGroup) {
if (resource.ubo) {
shaderSystem.bindUniformBlock(
resource,
shader._uniformBindMap[i][j],
syncData.blockIndex++
);
} else {
shaderSystem.updateUniformGroup(resource);
}
} else if (resource instanceof BufferResource) {
shaderSystem.bindUniformBlock(
resource,
shader._uniformBindMap[i][j],
syncData.blockIndex++
);
} else if (resource instanceof TextureSource) {
renderer.texture.bind(resource, syncData.textureCount);
const uniformName = shader._uniformBindMap[i][j];
const uniformData = programData.uniformData[uniformName];
if (uniformData) {
if (uniformData.value !== syncData.textureCount) {
gl.uniform1i(uniformData.location, syncData.textureCount);
}
syncData.textureCount++;
}
} else if (resource instanceof TextureStyle) {
}
}
}
}
export { generateShaderSyncPolyfill };
//# sourceMappingURL=generateShaderSyncPolyfill.mjs.map