This commit is contained in:
Akko
2025-08-04 18:57:35 +02:00
parent 8cf6e78a79
commit 9495868c2e
5030 changed files with 518594 additions and 17609 deletions

View File

@@ -0,0 +1,8 @@
import type { Shader } from '../../shared/shader/Shader';
import type { GlShaderSystem, ShaderSyncFunction } from './GlShaderSystem';
/**
* Generates the a function that will efficiently sync shader resources with the GPU.
* @param shader - The shader to generate the code for
* @param shaderSystem - An instance of the shader system
*/
export declare function generateShaderSyncCode(shader: Shader, shaderSystem: GlShaderSystem): ShaderSyncFunction;

View File

@@ -0,0 +1,74 @@
'use strict';
var BufferResource = require('../../shared/buffer/BufferResource.js');
var UniformGroup = require('../../shared/shader/UniformGroup.js');
var TextureSource = require('../../shared/texture/sources/TextureSource.js');
"use strict";
function generateShaderSyncCode(shader, shaderSystem) {
const funcFragments = [];
const headerFragments = [`
var g = s.groups;
var sS = r.shader;
var p = s.glProgram;
var ugS = r.uniformGroup;
var resources;
`];
let addedTextreSystem = false;
let blockIndex = 0;
let textureCount = 0;
const programData = shaderSystem._getProgramData(shader.glProgram);
for (const i in shader.groups) {
const group = shader.groups[i];
funcFragments.push(`
resources = g[${i}].resources;
`);
for (const j in group.resources) {
const resource = group.resources[j];
if (resource instanceof UniformGroup.UniformGroup) {
if (resource.ubo) {
funcFragments.push(`
sS.bindUniformBlock(
resources[${j}],
sS._uniformBindMap[${i}[${j}],
${blockIndex++}
);
`);
} else {
funcFragments.push(`
ugS.updateUniformGroup(resources[${j}], p, sD);
`);
}
} else if (resource instanceof BufferResource.BufferResource) {
funcFragments.push(`
sS.bindUniformBlock(
resources[${j}],
sS._uniformBindMap[${i}[${j}],
${blockIndex++}
);
`);
} else if (resource instanceof TextureSource.TextureSource) {
const uniformName = shader._uniformBindMap[i][j];
const uniformData = programData.uniformData[uniformName];
if (uniformData) {
if (!addedTextreSystem) {
addedTextreSystem = true;
headerFragments.push(`
var tS = r.texture;
`);
}
shaderSystem._gl.uniform1i(uniformData.location, textureCount);
funcFragments.push(`
tS.bind(resources[${j}], ${textureCount});
`);
textureCount++;
}
}
}
}
const functionSource = [...headerFragments, ...funcFragments].join("\n");
return new Function("r", "s", "sD", functionSource);
}
exports.generateShaderSyncCode = generateShaderSyncCode;
//# sourceMappingURL=GenerateShaderSyncCode.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,72 @@
import { BufferResource } from '../../shared/buffer/BufferResource.mjs';
import { UniformGroup } from '../../shared/shader/UniformGroup.mjs';
import { TextureSource } from '../../shared/texture/sources/TextureSource.mjs';
"use strict";
function generateShaderSyncCode(shader, shaderSystem) {
const funcFragments = [];
const headerFragments = [`
var g = s.groups;
var sS = r.shader;
var p = s.glProgram;
var ugS = r.uniformGroup;
var resources;
`];
let addedTextreSystem = false;
let blockIndex = 0;
let textureCount = 0;
const programData = shaderSystem._getProgramData(shader.glProgram);
for (const i in shader.groups) {
const group = shader.groups[i];
funcFragments.push(`
resources = g[${i}].resources;
`);
for (const j in group.resources) {
const resource = group.resources[j];
if (resource instanceof UniformGroup) {
if (resource.ubo) {
funcFragments.push(`
sS.bindUniformBlock(
resources[${j}],
sS._uniformBindMap[${i}[${j}],
${blockIndex++}
);
`);
} else {
funcFragments.push(`
ugS.updateUniformGroup(resources[${j}], p, sD);
`);
}
} else if (resource instanceof BufferResource) {
funcFragments.push(`
sS.bindUniformBlock(
resources[${j}],
sS._uniformBindMap[${i}[${j}],
${blockIndex++}
);
`);
} else if (resource instanceof TextureSource) {
const uniformName = shader._uniformBindMap[i][j];
const uniformData = programData.uniformData[uniformName];
if (uniformData) {
if (!addedTextreSystem) {
addedTextreSystem = true;
headerFragments.push(`
var tS = r.texture;
`);
}
shaderSystem._gl.uniform1i(uniformData.location, textureCount);
funcFragments.push(`
tS.bind(resources[${j}], ${textureCount});
`);
textureCount++;
}
}
}
}
const functionSource = [...headerFragments, ...funcFragments].join("\n");
return new Function("r", "s", "sD", functionSource);
}
export { generateShaderSyncCode };
//# sourceMappingURL=GenerateShaderSyncCode.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,120 @@
import type { TypedArray } from '../../shared/buffer/Buffer';
import type { ExtractedAttributeData } from './program/extractAttributesFromGlProgram';
export interface GlAttributeData {
type: string;
size: number;
location: number;
name: string;
}
export interface GlUniformData {
name: string;
index: number;
type: string;
size: number;
isArray: boolean;
value: any;
}
export interface GlUniformBlockData {
index: number;
name: string;
size: number;
value?: TypedArray;
}
/**
* The options for the gl program
* @memberof rendering
*/
export interface GlProgramOptions {
/** The fragment glsl shader source. */
fragment: string;
/** The vertex glsl shader source. */
vertex: string;
/** the name of the program, defaults to 'pixi-program' */
name?: string;
/** the preferred vertex precision for the shader, this may not be used if the device does not support it */
preferredVertexPrecision?: string;
/** the preferred fragment precision for the shader, this may not be used if the device does not support it */
preferredFragmentPrecision?: string;
}
/**
* A wrapper for a WebGL Program. You can create one and then pass it to a shader.
* This will manage the WebGL program that is compiled and uploaded to the GPU.
*
* To get the most out of this class, you should be familiar with glsl shaders and how they work.
* @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLProgram
* @example
*
* // Create a new program
* const program = new GlProgram({
* vertex: '...',
* fragment: '...',
* });
*
*
* There are a few key things that pixi shader will do for you automatically:
* <br>
* - If no precision is provided in the shader, it will be injected into the program source for you.
* This precision will be taken form the options provided, if none is provided,
* then the program will default to the defaultOptions.
* <br>
* - It will inject the program name into the shader source if none is provided.
* <br>
* - It will set the program version to 300 es.
*
* For optimal usage and best performance, its best to reuse programs as much as possible.
* You should use the {@link GlProgram.from} helper function to create programs.
* @class
* @memberof rendering
*/
export declare class GlProgram {
/** The default options used by the program. */
static defaultOptions: Partial<GlProgramOptions>;
/** the fragment glsl shader source. */
readonly fragment?: string;
/** the vertex glsl shader source */
readonly vertex?: string;
/**
* attribute data extracted from the program once created this happens when the program is used for the first time
* @internal
* @ignore
*/
_attributeData: Record<string, ExtractedAttributeData>;
/**
* uniform data extracted from the program once created this happens when the program is used for the first time
* @internal
* @ignore
*/
_uniformData: Record<string, GlUniformData>;
/**
* uniform data extracted from the program once created this happens when the program is used for the first time
* @internal
* @ignore
*/
_uniformBlockData: Record<string, GlUniformBlockData>;
/** details on how to use this program with transform feedback */
transformFeedbackVaryings?: {
names: string[];
bufferMode: 'separate' | 'interleaved';
};
/**
* the key that identifies the program via its source vertex + fragment
* @internal
* @ignore
*/
readonly _key: number;
/**
* Creates a shiny new GlProgram. Used by WebGL renderer.
* @param options - The options for the program.
*/
constructor(options: GlProgramOptions);
/** destroys the program */
destroy(): void;
/**
* Helper function that creates a program for a given source.
* It will check the program cache if the program has already been created.
* If it has that one will be returned, if not a new one will be created and cached.
* @param options - The options for the program.
* @returns A program using the same source
*/
static from(options: GlProgramOptions): GlProgram;
}

View File

@@ -0,0 +1,90 @@
'use strict';
var createIdFromString = require('../../shared/utils/createIdFromString.js');
var getMaxFragmentPrecision = require('./program/getMaxFragmentPrecision.js');
var addProgramDefines = require('./program/preprocessors/addProgramDefines.js');
var ensurePrecision = require('./program/preprocessors/ensurePrecision.js');
var insertVersion = require('./program/preprocessors/insertVersion.js');
var setProgramName = require('./program/preprocessors/setProgramName.js');
var stripVersion = require('./program/preprocessors/stripVersion.js');
"use strict";
const processes = {
// strips any version headers..
stripVersion: stripVersion.stripVersion,
// adds precision string if not already present
ensurePrecision: ensurePrecision.ensurePrecision,
// add some defines if WebGL1 to make it more compatible with WebGL2 shaders
addProgramDefines: addProgramDefines.addProgramDefines,
// add the program name to the shader
setProgramName: setProgramName.setProgramName,
// add the version string to the shader header
insertVersion: insertVersion.insertVersion
};
const programCache = /* @__PURE__ */ Object.create(null);
const _GlProgram = class _GlProgram {
/**
* Creates a shiny new GlProgram. Used by WebGL renderer.
* @param options - The options for the program.
*/
constructor(options) {
options = { ..._GlProgram.defaultOptions, ...options };
const isES300 = options.fragment.indexOf("#version 300 es") !== -1;
const preprocessorOptions = {
stripVersion: isES300,
ensurePrecision: {
requestedFragmentPrecision: options.preferredFragmentPrecision,
requestedVertexPrecision: options.preferredVertexPrecision,
maxSupportedVertexPrecision: "highp",
maxSupportedFragmentPrecision: getMaxFragmentPrecision.getMaxFragmentPrecision()
},
setProgramName: {
name: options.name
},
addProgramDefines: isES300,
insertVersion: isES300
};
let fragment = options.fragment;
let vertex = options.vertex;
Object.keys(processes).forEach((processKey) => {
const processOptions = preprocessorOptions[processKey];
fragment = processes[processKey](fragment, processOptions, true);
vertex = processes[processKey](vertex, processOptions, false);
});
this.fragment = fragment;
this.vertex = vertex;
this._key = createIdFromString.createIdFromString(`${this.vertex}:${this.fragment}`, "gl-program");
}
/** destroys the program */
destroy() {
this.fragment = null;
this.vertex = null;
this._attributeData = null;
this._uniformData = null;
this._uniformBlockData = null;
this.transformFeedbackVaryings = null;
}
/**
* Helper function that creates a program for a given source.
* It will check the program cache if the program has already been created.
* If it has that one will be returned, if not a new one will be created and cached.
* @param options - The options for the program.
* @returns A program using the same source
*/
static from(options) {
const key = `${options.vertex}:${options.fragment}`;
if (!programCache[key]) {
programCache[key] = new _GlProgram(options);
}
return programCache[key];
}
};
/** The default options used by the program. */
_GlProgram.defaultOptions = {
preferredVertexPrecision: "highp",
preferredFragmentPrecision: "mediump"
};
let GlProgram = _GlProgram;
exports.GlProgram = GlProgram;
//# sourceMappingURL=GlProgram.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,88 @@
import { createIdFromString } from '../../shared/utils/createIdFromString.mjs';
import { getMaxFragmentPrecision } from './program/getMaxFragmentPrecision.mjs';
import { addProgramDefines } from './program/preprocessors/addProgramDefines.mjs';
import { ensurePrecision } from './program/preprocessors/ensurePrecision.mjs';
import { insertVersion } from './program/preprocessors/insertVersion.mjs';
import { setProgramName } from './program/preprocessors/setProgramName.mjs';
import { stripVersion } from './program/preprocessors/stripVersion.mjs';
"use strict";
const processes = {
// strips any version headers..
stripVersion,
// adds precision string if not already present
ensurePrecision,
// add some defines if WebGL1 to make it more compatible with WebGL2 shaders
addProgramDefines,
// add the program name to the shader
setProgramName,
// add the version string to the shader header
insertVersion
};
const programCache = /* @__PURE__ */ Object.create(null);
const _GlProgram = class _GlProgram {
/**
* Creates a shiny new GlProgram. Used by WebGL renderer.
* @param options - The options for the program.
*/
constructor(options) {
options = { ..._GlProgram.defaultOptions, ...options };
const isES300 = options.fragment.indexOf("#version 300 es") !== -1;
const preprocessorOptions = {
stripVersion: isES300,
ensurePrecision: {
requestedFragmentPrecision: options.preferredFragmentPrecision,
requestedVertexPrecision: options.preferredVertexPrecision,
maxSupportedVertexPrecision: "highp",
maxSupportedFragmentPrecision: getMaxFragmentPrecision()
},
setProgramName: {
name: options.name
},
addProgramDefines: isES300,
insertVersion: isES300
};
let fragment = options.fragment;
let vertex = options.vertex;
Object.keys(processes).forEach((processKey) => {
const processOptions = preprocessorOptions[processKey];
fragment = processes[processKey](fragment, processOptions, true);
vertex = processes[processKey](vertex, processOptions, false);
});
this.fragment = fragment;
this.vertex = vertex;
this._key = createIdFromString(`${this.vertex}:${this.fragment}`, "gl-program");
}
/** destroys the program */
destroy() {
this.fragment = null;
this.vertex = null;
this._attributeData = null;
this._uniformData = null;
this._uniformBlockData = null;
this.transformFeedbackVaryings = null;
}
/**
* Helper function that creates a program for a given source.
* It will check the program cache if the program has already been created.
* If it has that one will be returned, if not a new one will be created and cached.
* @param options - The options for the program.
* @returns A program using the same source
*/
static from(options) {
const key = `${options.vertex}:${options.fragment}`;
if (!programCache[key]) {
programCache[key] = new _GlProgram(options);
}
return programCache[key];
}
};
/** The default options used by the program. */
_GlProgram.defaultOptions = {
preferredVertexPrecision: "highp",
preferredFragmentPrecision: "mediump"
};
let GlProgram = _GlProgram;
export { GlProgram };
//# sourceMappingURL=GlProgram.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,45 @@
/**
* @private
*/
export declare class IGLUniformData {
location: WebGLUniformLocation;
value: number | boolean | Float32Array | Int32Array | Uint32Array | boolean[];
}
/**
* Helper class to create a WebGL Program
* @private
*/
export declare class GlProgramData {
/** The shader program. */
program: WebGLProgram;
/**
* Holds the uniform data which contains uniform locations
* and current uniform values used for caching and preventing unneeded GPU commands.
*/
uniformData: Record<string, any>;
/**
* UniformGroups holds the various upload functions for the shader. Each uniform group
* and program have a unique upload function generated.
*/
uniformGroups: Record<string, any>;
/** A hash that stores where UBOs are bound to on the program. */
uniformBlockBindings: Record<string, any>;
/** A hash for lazily-generated uniform uploading functions. */
uniformSync: Record<string, any>;
/**
* A place where dirty ticks are stored for groups
* If a tick here does not match with the Higher level Programs tick, it means
* we should re upload the data.
*/
uniformDirtyGroups: Record<string, any>;
/**
* Makes a new Pixi program.
* @param program - webgl program
* @param uniformData - uniforms
*/
constructor(program: WebGLProgram, uniformData: {
[key: string]: IGLUniformData;
});
/** Destroys this program. */
destroy(): void;
}

View File

@@ -0,0 +1,31 @@
'use strict';
"use strict";
class IGLUniformData {
}
class GlProgramData {
/**
* Makes a new Pixi program.
* @param program - webgl program
* @param uniformData - uniforms
*/
constructor(program, uniformData) {
this.program = program;
this.uniformData = uniformData;
this.uniformGroups = {};
this.uniformDirtyGroups = {};
this.uniformBlockBindings = {};
}
/** Destroys this program. */
destroy() {
this.uniformData = null;
this.uniformGroups = null;
this.uniformDirtyGroups = null;
this.uniformBlockBindings = null;
this.program = null;
}
}
exports.GlProgramData = GlProgramData;
exports.IGLUniformData = IGLUniformData;
//# sourceMappingURL=GlProgramData.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"GlProgramData.js","sources":["../../../../../src/rendering/renderers/gl/shader/GlProgramData.ts"],"sourcesContent":["/**\n * @private\n */\nexport class IGLUniformData\n{\n public location: WebGLUniformLocation;\n public value: number | boolean | Float32Array | Int32Array | Uint32Array | boolean[];\n}\n\n/**\n * Helper class to create a WebGL Program\n * @private\n */\nexport class GlProgramData\n{\n /** The shader program. */\n public program: WebGLProgram;\n\n /**\n * Holds the uniform data which contains uniform locations\n * and current uniform values used for caching and preventing unneeded GPU commands.\n */\n public uniformData: Record<string, any>;\n\n /**\n * UniformGroups holds the various upload functions for the shader. Each uniform group\n * and program have a unique upload function generated.\n */\n public uniformGroups: Record<string, any>;\n\n /** A hash that stores where UBOs are bound to on the program. */\n public uniformBlockBindings: Record<string, any>;\n\n /** A hash for lazily-generated uniform uploading functions. */\n public uniformSync: Record<string, any>;\n\n /**\n * A place where dirty ticks are stored for groups\n * If a tick here does not match with the Higher level Programs tick, it means\n * we should re upload the data.\n */\n public uniformDirtyGroups: Record<string, any>;\n\n /**\n * Makes a new Pixi program.\n * @param program - webgl program\n * @param uniformData - uniforms\n */\n constructor(program: WebGLProgram, uniformData: {[key: string]: IGLUniformData})\n {\n this.program = program;\n this.uniformData = uniformData;\n this.uniformGroups = {};\n this.uniformDirtyGroups = {};\n this.uniformBlockBindings = {};\n }\n\n /** Destroys this program. */\n public destroy(): void\n {\n this.uniformData = null;\n this.uniformGroups = null;\n this.uniformDirtyGroups = null;\n this.uniformBlockBindings = null;\n this.program = null;\n }\n}\n"],"names":[],"mappings":";;;AAGO,MAAM,cACb,CAAA;AAGA,CAAA;AAMO,MAAM,aACb,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkCI,WAAA,CAAY,SAAuB,WACnC,EAAA;AACI,IAAA,IAAA,CAAK,OAAU,GAAA,OAAA,CAAA;AACf,IAAA,IAAA,CAAK,WAAc,GAAA,WAAA,CAAA;AACnB,IAAA,IAAA,CAAK,gBAAgB,EAAC,CAAA;AACtB,IAAA,IAAA,CAAK,qBAAqB,EAAC,CAAA;AAC3B,IAAA,IAAA,CAAK,uBAAuB,EAAC,CAAA;AAAA,GACjC;AAAA;AAAA,EAGO,OACP,GAAA;AACI,IAAA,IAAA,CAAK,WAAc,GAAA,IAAA,CAAA;AACnB,IAAA,IAAA,CAAK,aAAgB,GAAA,IAAA,CAAA;AACrB,IAAA,IAAA,CAAK,kBAAqB,GAAA,IAAA,CAAA;AAC1B,IAAA,IAAA,CAAK,oBAAuB,GAAA,IAAA,CAAA;AAC5B,IAAA,IAAA,CAAK,OAAU,GAAA,IAAA,CAAA;AAAA,GACnB;AACJ;;;;;"}

View File

@@ -0,0 +1,28 @@
"use strict";
class IGLUniformData {
}
class GlProgramData {
/**
* Makes a new Pixi program.
* @param program - webgl program
* @param uniformData - uniforms
*/
constructor(program, uniformData) {
this.program = program;
this.uniformData = uniformData;
this.uniformGroups = {};
this.uniformDirtyGroups = {};
this.uniformBlockBindings = {};
}
/** Destroys this program. */
destroy() {
this.uniformData = null;
this.uniformGroups = null;
this.uniformDirtyGroups = null;
this.uniformBlockBindings = null;
this.program = null;
}
}
export { GlProgramData, IGLUniformData };
//# sourceMappingURL=GlProgramData.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"GlProgramData.mjs","sources":["../../../../../src/rendering/renderers/gl/shader/GlProgramData.ts"],"sourcesContent":["/**\n * @private\n */\nexport class IGLUniformData\n{\n public location: WebGLUniformLocation;\n public value: number | boolean | Float32Array | Int32Array | Uint32Array | boolean[];\n}\n\n/**\n * Helper class to create a WebGL Program\n * @private\n */\nexport class GlProgramData\n{\n /** The shader program. */\n public program: WebGLProgram;\n\n /**\n * Holds the uniform data which contains uniform locations\n * and current uniform values used for caching and preventing unneeded GPU commands.\n */\n public uniformData: Record<string, any>;\n\n /**\n * UniformGroups holds the various upload functions for the shader. Each uniform group\n * and program have a unique upload function generated.\n */\n public uniformGroups: Record<string, any>;\n\n /** A hash that stores where UBOs are bound to on the program. */\n public uniformBlockBindings: Record<string, any>;\n\n /** A hash for lazily-generated uniform uploading functions. */\n public uniformSync: Record<string, any>;\n\n /**\n * A place where dirty ticks are stored for groups\n * If a tick here does not match with the Higher level Programs tick, it means\n * we should re upload the data.\n */\n public uniformDirtyGroups: Record<string, any>;\n\n /**\n * Makes a new Pixi program.\n * @param program - webgl program\n * @param uniformData - uniforms\n */\n constructor(program: WebGLProgram, uniformData: {[key: string]: IGLUniformData})\n {\n this.program = program;\n this.uniformData = uniformData;\n this.uniformGroups = {};\n this.uniformDirtyGroups = {};\n this.uniformBlockBindings = {};\n }\n\n /** Destroys this program. */\n public destroy(): void\n {\n this.uniformData = null;\n this.uniformGroups = null;\n this.uniformDirtyGroups = null;\n this.uniformBlockBindings = null;\n this.program = null;\n }\n}\n"],"names":[],"mappings":";AAGO,MAAM,cACb,CAAA;AAGA,CAAA;AAMO,MAAM,aACb,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkCI,WAAA,CAAY,SAAuB,WACnC,EAAA;AACI,IAAA,IAAA,CAAK,OAAU,GAAA,OAAA,CAAA;AACf,IAAA,IAAA,CAAK,WAAc,GAAA,WAAA,CAAA;AACnB,IAAA,IAAA,CAAK,gBAAgB,EAAC,CAAA;AACtB,IAAA,IAAA,CAAK,qBAAqB,EAAC,CAAA;AAC3B,IAAA,IAAA,CAAK,uBAAuB,EAAC,CAAA;AAAA,GACjC;AAAA;AAAA,EAGO,OACP,GAAA;AACI,IAAA,IAAA,CAAK,WAAc,GAAA,IAAA,CAAA;AACnB,IAAA,IAAA,CAAK,aAAgB,GAAA,IAAA,CAAA;AACrB,IAAA,IAAA,CAAK,kBAAqB,GAAA,IAAA,CAAA;AAC1B,IAAA,IAAA,CAAK,oBAAuB,GAAA,IAAA,CAAA;AAC5B,IAAA,IAAA,CAAK,OAAU,GAAA,IAAA,CAAA;AAAA,GACnB;AACJ;;;;"}

View File

@@ -0,0 +1,78 @@
import { ExtensionType } from '../../../../extensions/Extensions';
import type { BufferResource } from '../../shared/buffer/BufferResource';
import type { Shader } from '../../shared/shader/Shader';
import type { ShaderSystem } from '../../shared/shader/ShaderSystem';
import type { UniformGroup } from '../../shared/shader/UniformGroup';
import type { GlRenderingContext } from '../context/GlRenderingContext';
import type { WebGLRenderer } from '../WebGLRenderer';
import type { GlProgram } from './GlProgram';
import type { GlProgramData } from './GlProgramData';
export interface ShaderSyncData {
textureCount: number;
blockIndex: number;
}
export type ShaderSyncFunction = (renderer: WebGLRenderer, shader: Shader, syncData: ShaderSyncData) => void;
/**
* System plugin to the renderer to manage the shaders for WebGL.
* @memberof rendering
*/
export declare class GlShaderSystem implements ShaderSystem {
/** @ignore */
static extension: {
readonly type: readonly [ExtensionType.WebGLSystem];
readonly name: "shader";
};
maxTextures: number;
/**
* @internal
* @private
*/
_activeProgram: GlProgram;
private _programDataHash;
private readonly _renderer;
_gl: WebGL2RenderingContext;
private _maxBindings;
private _nextIndex;
private _boundUniformsIdsToIndexHash;
private _boundIndexToUniformsHash;
private _shaderSyncFunctions;
constructor(renderer: WebGLRenderer);
protected contextChange(gl: GlRenderingContext): void;
/**
* Changes the current shader to the one given in parameter.
* @param shader - the new shader
* @param skipSync - false if the shader should automatically sync its uniforms.
* @returns the glProgram that belongs to the shader.
*/
bind(shader: Shader, skipSync?: boolean): void;
/**
* Updates the uniform group.
* @param uniformGroup - the uniform group to update
*/
updateUniformGroup(uniformGroup: UniformGroup): void;
/**
* Binds a uniform block to the shader.
* @param uniformGroup - the uniform group to bind
* @param name - the name of the uniform block
* @param index - the index of the uniform block
*/
bindUniformBlock(uniformGroup: UniformGroup | BufferResource, name: string, index?: number): void;
private _setProgram;
/**
* @param program - the program to get the data for
* @internal
* @private
*/
_getProgramData(program: GlProgram): GlProgramData;
private _createProgramData;
destroy(): void;
/**
* Creates a function that can be executed that will sync the shader as efficiently as possible.
* Overridden by the unsafe eval package if you don't want eval used in your project.
* @param shader - the shader to generate the sync function for
* @param shaderSystem - the shader system to use
* @returns - the generated sync function
* @ignore
*/
_generateShaderSync(shader: Shader, shaderSystem: GlShaderSystem): ShaderSyncFunction;
}

View File

@@ -0,0 +1,148 @@
'use strict';
var Extensions = require('../../../../extensions/Extensions.js');
var maxRecommendedTextures = require('../../../batcher/gl/utils/maxRecommendedTextures.js');
var GenerateShaderSyncCode = require('./GenerateShaderSyncCode.js');
var generateProgram = require('./program/generateProgram.js');
"use strict";
const defaultSyncData = {
textureCount: 0,
blockIndex: 0
};
class GlShaderSystem {
constructor(renderer) {
/**
* @internal
* @private
*/
this._activeProgram = null;
this._programDataHash = /* @__PURE__ */ Object.create(null);
this._nextIndex = 0;
this._boundUniformsIdsToIndexHash = /* @__PURE__ */ Object.create(null);
this._boundIndexToUniformsHash = /* @__PURE__ */ Object.create(null);
this._shaderSyncFunctions = /* @__PURE__ */ Object.create(null);
this._renderer = renderer;
}
contextChange(gl) {
this._gl = gl;
this._maxBindings = gl.MAX_UNIFORM_BUFFER_BINDINGS ? gl.getParameter(gl.MAX_UNIFORM_BUFFER_BINDINGS) : 0;
this._programDataHash = /* @__PURE__ */ Object.create(null);
this._boundUniformsIdsToIndexHash = /* @__PURE__ */ Object.create(null);
this._boundIndexToUniformsHash = /* @__PURE__ */ Object.create(null);
this._shaderSyncFunctions = /* @__PURE__ */ Object.create(null);
this._activeProgram = null;
this.maxTextures = maxRecommendedTextures.getMaxTexturesPerBatch();
}
/**
* Changes the current shader to the one given in parameter.
* @param shader - the new shader
* @param skipSync - false if the shader should automatically sync its uniforms.
* @returns the glProgram that belongs to the shader.
*/
bind(shader, skipSync) {
this._setProgram(shader.glProgram);
if (skipSync)
return;
defaultSyncData.textureCount = 0;
defaultSyncData.blockIndex = 0;
let syncFunction = this._shaderSyncFunctions[shader.glProgram._key];
if (!syncFunction) {
syncFunction = this._shaderSyncFunctions[shader.glProgram._key] = this._generateShaderSync(shader, this);
}
syncFunction(this._renderer, shader, defaultSyncData);
}
/**
* Updates the uniform group.
* @param uniformGroup - the uniform group to update
*/
updateUniformGroup(uniformGroup) {
this._renderer.uniformGroup.updateUniformGroup(uniformGroup, this._activeProgram, defaultSyncData);
}
/**
* Binds a uniform block to the shader.
* @param uniformGroup - the uniform group to bind
* @param name - the name of the uniform block
* @param index - the index of the uniform block
*/
bindUniformBlock(uniformGroup, name, index = 0) {
const bufferSystem = this._renderer.buffer;
const programData = this._getProgramData(this._activeProgram);
const isBufferResource = uniformGroup._bufferResource;
if (isBufferResource) {
this._renderer.ubo.updateUniformGroup(uniformGroup);
}
bufferSystem.updateBuffer(uniformGroup.buffer);
let boundIndex = this._boundUniformsIdsToIndexHash[uniformGroup.uid];
if (boundIndex === void 0) {
const nextIndex = this._nextIndex++ % this._maxBindings;
const currentBoundUniformGroup = this._boundIndexToUniformsHash[nextIndex];
if (currentBoundUniformGroup) {
this._boundUniformsIdsToIndexHash[currentBoundUniformGroup.uid] = void 0;
}
boundIndex = this._boundUniformsIdsToIndexHash[uniformGroup.uid] = nextIndex;
this._boundIndexToUniformsHash[nextIndex] = uniformGroup;
if (isBufferResource) {
bufferSystem.bindBufferRange(uniformGroup.buffer, nextIndex, uniformGroup.offset);
} else {
bufferSystem.bindBufferBase(uniformGroup.buffer, nextIndex);
}
}
const gl = this._gl;
const uniformBlockIndex = this._activeProgram._uniformBlockData[name].index;
if (programData.uniformBlockBindings[index] === boundIndex)
return;
programData.uniformBlockBindings[index] = boundIndex;
gl.uniformBlockBinding(programData.program, uniformBlockIndex, boundIndex);
}
_setProgram(program) {
if (this._activeProgram === program)
return;
this._activeProgram = program;
const programData = this._getProgramData(program);
this._gl.useProgram(programData.program);
}
/**
* @param program - the program to get the data for
* @internal
* @private
*/
_getProgramData(program) {
return this._programDataHash[program._key] || this._createProgramData(program);
}
_createProgramData(program) {
const key = program._key;
this._programDataHash[key] = generateProgram.generateProgram(this._gl, program);
return this._programDataHash[key];
}
destroy() {
for (const key of Object.keys(this._programDataHash)) {
const programData = this._programDataHash[key];
programData.destroy();
this._programDataHash[key] = null;
}
this._programDataHash = null;
this._boundUniformsIdsToIndexHash = null;
}
/**
* Creates a function that can be executed that will sync the shader as efficiently as possible.
* Overridden by the unsafe eval package if you don't want eval used in your project.
* @param shader - the shader to generate the sync function for
* @param shaderSystem - the shader system to use
* @returns - the generated sync function
* @ignore
*/
_generateShaderSync(shader, shaderSystem) {
return GenerateShaderSyncCode.generateShaderSyncCode(shader, shaderSystem);
}
}
/** @ignore */
GlShaderSystem.extension = {
type: [
Extensions.ExtensionType.WebGLSystem
],
name: "shader"
};
exports.GlShaderSystem = GlShaderSystem;
//# sourceMappingURL=GlShaderSystem.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,146 @@
import { ExtensionType } from '../../../../extensions/Extensions.mjs';
import { getMaxTexturesPerBatch } from '../../../batcher/gl/utils/maxRecommendedTextures.mjs';
import { generateShaderSyncCode } from './GenerateShaderSyncCode.mjs';
import { generateProgram } from './program/generateProgram.mjs';
"use strict";
const defaultSyncData = {
textureCount: 0,
blockIndex: 0
};
class GlShaderSystem {
constructor(renderer) {
/**
* @internal
* @private
*/
this._activeProgram = null;
this._programDataHash = /* @__PURE__ */ Object.create(null);
this._nextIndex = 0;
this._boundUniformsIdsToIndexHash = /* @__PURE__ */ Object.create(null);
this._boundIndexToUniformsHash = /* @__PURE__ */ Object.create(null);
this._shaderSyncFunctions = /* @__PURE__ */ Object.create(null);
this._renderer = renderer;
}
contextChange(gl) {
this._gl = gl;
this._maxBindings = gl.MAX_UNIFORM_BUFFER_BINDINGS ? gl.getParameter(gl.MAX_UNIFORM_BUFFER_BINDINGS) : 0;
this._programDataHash = /* @__PURE__ */ Object.create(null);
this._boundUniformsIdsToIndexHash = /* @__PURE__ */ Object.create(null);
this._boundIndexToUniformsHash = /* @__PURE__ */ Object.create(null);
this._shaderSyncFunctions = /* @__PURE__ */ Object.create(null);
this._activeProgram = null;
this.maxTextures = getMaxTexturesPerBatch();
}
/**
* Changes the current shader to the one given in parameter.
* @param shader - the new shader
* @param skipSync - false if the shader should automatically sync its uniforms.
* @returns the glProgram that belongs to the shader.
*/
bind(shader, skipSync) {
this._setProgram(shader.glProgram);
if (skipSync)
return;
defaultSyncData.textureCount = 0;
defaultSyncData.blockIndex = 0;
let syncFunction = this._shaderSyncFunctions[shader.glProgram._key];
if (!syncFunction) {
syncFunction = this._shaderSyncFunctions[shader.glProgram._key] = this._generateShaderSync(shader, this);
}
syncFunction(this._renderer, shader, defaultSyncData);
}
/**
* Updates the uniform group.
* @param uniformGroup - the uniform group to update
*/
updateUniformGroup(uniformGroup) {
this._renderer.uniformGroup.updateUniformGroup(uniformGroup, this._activeProgram, defaultSyncData);
}
/**
* Binds a uniform block to the shader.
* @param uniformGroup - the uniform group to bind
* @param name - the name of the uniform block
* @param index - the index of the uniform block
*/
bindUniformBlock(uniformGroup, name, index = 0) {
const bufferSystem = this._renderer.buffer;
const programData = this._getProgramData(this._activeProgram);
const isBufferResource = uniformGroup._bufferResource;
if (isBufferResource) {
this._renderer.ubo.updateUniformGroup(uniformGroup);
}
bufferSystem.updateBuffer(uniformGroup.buffer);
let boundIndex = this._boundUniformsIdsToIndexHash[uniformGroup.uid];
if (boundIndex === void 0) {
const nextIndex = this._nextIndex++ % this._maxBindings;
const currentBoundUniformGroup = this._boundIndexToUniformsHash[nextIndex];
if (currentBoundUniformGroup) {
this._boundUniformsIdsToIndexHash[currentBoundUniformGroup.uid] = void 0;
}
boundIndex = this._boundUniformsIdsToIndexHash[uniformGroup.uid] = nextIndex;
this._boundIndexToUniformsHash[nextIndex] = uniformGroup;
if (isBufferResource) {
bufferSystem.bindBufferRange(uniformGroup.buffer, nextIndex, uniformGroup.offset);
} else {
bufferSystem.bindBufferBase(uniformGroup.buffer, nextIndex);
}
}
const gl = this._gl;
const uniformBlockIndex = this._activeProgram._uniformBlockData[name].index;
if (programData.uniformBlockBindings[index] === boundIndex)
return;
programData.uniformBlockBindings[index] = boundIndex;
gl.uniformBlockBinding(programData.program, uniformBlockIndex, boundIndex);
}
_setProgram(program) {
if (this._activeProgram === program)
return;
this._activeProgram = program;
const programData = this._getProgramData(program);
this._gl.useProgram(programData.program);
}
/**
* @param program - the program to get the data for
* @internal
* @private
*/
_getProgramData(program) {
return this._programDataHash[program._key] || this._createProgramData(program);
}
_createProgramData(program) {
const key = program._key;
this._programDataHash[key] = generateProgram(this._gl, program);
return this._programDataHash[key];
}
destroy() {
for (const key of Object.keys(this._programDataHash)) {
const programData = this._programDataHash[key];
programData.destroy();
this._programDataHash[key] = null;
}
this._programDataHash = null;
this._boundUniformsIdsToIndexHash = null;
}
/**
* Creates a function that can be executed that will sync the shader as efficiently as possible.
* Overridden by the unsafe eval package if you don't want eval used in your project.
* @param shader - the shader to generate the sync function for
* @param shaderSystem - the shader system to use
* @returns - the generated sync function
* @ignore
*/
_generateShaderSync(shader, shaderSystem) {
return generateShaderSyncCode(shader, shaderSystem);
}
}
/** @ignore */
GlShaderSystem.extension = {
type: [
ExtensionType.WebGLSystem
],
name: "shader"
};
export { GlShaderSystem };
//# sourceMappingURL=GlShaderSystem.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,58 @@
import { ExtensionType } from '../../../../extensions/Extensions';
import type { UniformGroup } from '../../shared/shader/UniformGroup';
import type { System } from '../../shared/system/System';
import type { GlRenderingContext } from '../context/GlRenderingContext';
import type { WebGLRenderer } from '../WebGLRenderer';
import type { GlProgram } from './GlProgram';
/**
* System plugin to the renderer to manage shaders.
* @memberof rendering
*/
export declare class GlUniformGroupSystem implements System {
/** @ignore */
static extension: {
readonly type: readonly [ExtensionType.WebGLSystem];
readonly name: "uniformGroup";
};
/**
* The current WebGL rendering context.
* @member {WebGLRenderingContext}
*/
protected gl: GlRenderingContext;
/** Cache to holds the generated functions. Stored against UniformObjects unique signature. */
private _cache;
private _renderer;
private _uniformGroupSyncHash;
/** @param renderer - The renderer this System works for. */
constructor(renderer: WebGLRenderer);
protected contextChange(gl: GlRenderingContext): void;
/**
* Uploads the uniforms values to the currently bound shader.
* @param group - the uniforms values that be applied to the current shader
* @param program
* @param syncData
* @param syncData.textureCount
*/
updateUniformGroup(group: UniformGroup, program: GlProgram, syncData: {
textureCount: number;
}): void;
/**
* Overridable by the pixi.js/unsafe-eval package to use static syncUniforms instead.
* @param group
* @param program
*/
private _getUniformSyncFunction;
private _createUniformSyncFunction;
private _generateUniformsSync;
/**
* Takes a uniform group and data and generates a unique signature for them.
* @param group - The uniform group to get signature of
* @param group.uniforms
* @param uniformData - Uniform information generated by the shader
* @param preFix
* @returns Unique signature of the uniform group
*/
private _getSignature;
/** Destroys this System and removes all its textures. */
destroy(): void;
}

View File

@@ -0,0 +1,89 @@
'use strict';
var Extensions = require('../../../../extensions/Extensions.js');
var generateUniformsSync = require('./utils/generateUniformsSync.js');
"use strict";
class GlUniformGroupSystem {
/** @param renderer - The renderer this System works for. */
constructor(renderer) {
/** Cache to holds the generated functions. Stored against UniformObjects unique signature. */
this._cache = {};
this._uniformGroupSyncHash = {};
this._renderer = renderer;
this.gl = null;
this._cache = {};
}
contextChange(gl) {
this.gl = gl;
}
/**
* Uploads the uniforms values to the currently bound shader.
* @param group - the uniforms values that be applied to the current shader
* @param program
* @param syncData
* @param syncData.textureCount
*/
updateUniformGroup(group, program, syncData) {
const programData = this._renderer.shader._getProgramData(program);
if (!group.isStatic || group._dirtyId !== programData.uniformDirtyGroups[group.uid]) {
programData.uniformDirtyGroups[group.uid] = group._dirtyId;
const syncFunc = this._getUniformSyncFunction(group, program);
syncFunc(programData.uniformData, group.uniforms, this._renderer, syncData);
}
}
/**
* Overridable by the pixi.js/unsafe-eval package to use static syncUniforms instead.
* @param group
* @param program
*/
_getUniformSyncFunction(group, program) {
return this._uniformGroupSyncHash[group._signature]?.[program._key] || this._createUniformSyncFunction(group, program);
}
_createUniformSyncFunction(group, program) {
const uniformGroupSyncHash = this._uniformGroupSyncHash[group._signature] || (this._uniformGroupSyncHash[group._signature] = {});
const id = this._getSignature(group, program._uniformData, "u");
if (!this._cache[id]) {
this._cache[id] = this._generateUniformsSync(group, program._uniformData);
}
uniformGroupSyncHash[program._key] = this._cache[id];
return uniformGroupSyncHash[program._key];
}
_generateUniformsSync(group, uniformData) {
return generateUniformsSync.generateUniformsSync(group, uniformData);
}
/**
* Takes a uniform group and data and generates a unique signature for them.
* @param group - The uniform group to get signature of
* @param group.uniforms
* @param uniformData - Uniform information generated by the shader
* @param preFix
* @returns Unique signature of the uniform group
*/
_getSignature(group, uniformData, preFix) {
const uniforms = group.uniforms;
const strings = [`${preFix}-`];
for (const i in uniforms) {
strings.push(i);
if (uniformData[i]) {
strings.push(uniformData[i].type);
}
}
return strings.join("-");
}
/** Destroys this System and removes all its textures. */
destroy() {
this._renderer = null;
this._cache = null;
}
}
/** @ignore */
GlUniformGroupSystem.extension = {
type: [
Extensions.ExtensionType.WebGLSystem
],
name: "uniformGroup"
};
exports.GlUniformGroupSystem = GlUniformGroupSystem;
//# sourceMappingURL=GlUniformGroupSystem.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,87 @@
import { ExtensionType } from '../../../../extensions/Extensions.mjs';
import { generateUniformsSync } from './utils/generateUniformsSync.mjs';
"use strict";
class GlUniformGroupSystem {
/** @param renderer - The renderer this System works for. */
constructor(renderer) {
/** Cache to holds the generated functions. Stored against UniformObjects unique signature. */
this._cache = {};
this._uniformGroupSyncHash = {};
this._renderer = renderer;
this.gl = null;
this._cache = {};
}
contextChange(gl) {
this.gl = gl;
}
/**
* Uploads the uniforms values to the currently bound shader.
* @param group - the uniforms values that be applied to the current shader
* @param program
* @param syncData
* @param syncData.textureCount
*/
updateUniformGroup(group, program, syncData) {
const programData = this._renderer.shader._getProgramData(program);
if (!group.isStatic || group._dirtyId !== programData.uniformDirtyGroups[group.uid]) {
programData.uniformDirtyGroups[group.uid] = group._dirtyId;
const syncFunc = this._getUniformSyncFunction(group, program);
syncFunc(programData.uniformData, group.uniforms, this._renderer, syncData);
}
}
/**
* Overridable by the pixi.js/unsafe-eval package to use static syncUniforms instead.
* @param group
* @param program
*/
_getUniformSyncFunction(group, program) {
return this._uniformGroupSyncHash[group._signature]?.[program._key] || this._createUniformSyncFunction(group, program);
}
_createUniformSyncFunction(group, program) {
const uniformGroupSyncHash = this._uniformGroupSyncHash[group._signature] || (this._uniformGroupSyncHash[group._signature] = {});
const id = this._getSignature(group, program._uniformData, "u");
if (!this._cache[id]) {
this._cache[id] = this._generateUniformsSync(group, program._uniformData);
}
uniformGroupSyncHash[program._key] = this._cache[id];
return uniformGroupSyncHash[program._key];
}
_generateUniformsSync(group, uniformData) {
return generateUniformsSync(group, uniformData);
}
/**
* Takes a uniform group and data and generates a unique signature for them.
* @param group - The uniform group to get signature of
* @param group.uniforms
* @param uniformData - Uniform information generated by the shader
* @param preFix
* @returns Unique signature of the uniform group
*/
_getSignature(group, uniformData, preFix) {
const uniforms = group.uniforms;
const strings = [`${preFix}-`];
for (const i in uniforms) {
strings.push(i);
if (uniformData[i]) {
strings.push(uniformData[i].type);
}
}
return strings.join("-");
}
/** Destroys this System and removes all its textures. */
destroy() {
this._renderer = null;
this._cache = null;
}
}
/** @ignore */
GlUniformGroupSystem.extension = {
type: [
ExtensionType.WebGLSystem
],
name: "uniformGroup"
};
export { GlUniformGroupSystem };
//# sourceMappingURL=GlUniformGroupSystem.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
export type PRECISION = `highp` | `mediump` | `lowp`;

View File

@@ -0,0 +1,4 @@
'use strict';
"use strict";
//# sourceMappingURL=const.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"const.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}

View File

@@ -0,0 +1,2 @@
"use strict";
//# sourceMappingURL=const.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"const.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}

View File

@@ -0,0 +1,8 @@
import { UniformGroup } from '../../shared/shader/UniformGroup';
/**
* Automatically generates a uniform group that holds the texture samplers for a shader.
* This is used mainly by the shaders that batch textures!
* @param maxTextures - the number of textures that this uniform group will contain.
* @returns a uniform group that holds the texture samplers.
*/
export declare function getBatchSamplersUniformGroup(maxTextures: number): UniformGroup<any>;

View File

@@ -0,0 +1,22 @@
'use strict';
var UniformGroup = require('../../shared/shader/UniformGroup.js');
"use strict";
const batchSamplersUniformGroupHash = {};
function getBatchSamplersUniformGroup(maxTextures) {
let batchSamplersUniformGroup = batchSamplersUniformGroupHash[maxTextures];
if (batchSamplersUniformGroup)
return batchSamplersUniformGroup;
const sampleValues = new Int32Array(maxTextures);
for (let i = 0; i < maxTextures; i++) {
sampleValues[i] = i;
}
batchSamplersUniformGroup = batchSamplersUniformGroupHash[maxTextures] = new UniformGroup.UniformGroup({
uTextures: { value: sampleValues, type: `i32`, size: maxTextures }
}, { isStatic: true });
return batchSamplersUniformGroup;
}
exports.getBatchSamplersUniformGroup = getBatchSamplersUniformGroup;
//# sourceMappingURL=getBatchSamplersUniformGroup.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getBatchSamplersUniformGroup.js","sources":["../../../../../src/rendering/renderers/gl/shader/getBatchSamplersUniformGroup.ts"],"sourcesContent":["import { UniformGroup } from '../../shared/shader/UniformGroup';\n\nconst batchSamplersUniformGroupHash: Record<number, UniformGroup> = {};\n\n/**\n * Automatically generates a uniform group that holds the texture samplers for a shader.\n * This is used mainly by the shaders that batch textures!\n * @param maxTextures - the number of textures that this uniform group will contain.\n * @returns a uniform group that holds the texture samplers.\n */\nexport function getBatchSamplersUniformGroup(maxTextures: number)\n{\n let batchSamplersUniformGroup = batchSamplersUniformGroupHash[maxTextures];\n\n if (batchSamplersUniformGroup) return batchSamplersUniformGroup;\n\n const sampleValues = new Int32Array(maxTextures);\n\n for (let i = 0; i < maxTextures; i++)\n {\n sampleValues[i] = i;\n }\n\n batchSamplersUniformGroup = batchSamplersUniformGroupHash[maxTextures] = new UniformGroup({\n uTextures: { value: sampleValues, type: `i32`, size: maxTextures }\n }, { isStatic: true });\n\n return batchSamplersUniformGroup;\n}\n"],"names":["UniformGroup"],"mappings":";;;;;AAEA,MAAM,gCAA8D,EAAC,CAAA;AAQ9D,SAAS,6BAA6B,WAC7C,EAAA;AACI,EAAI,IAAA,yBAAA,GAA4B,8BAA8B,WAAW,CAAA,CAAA;AAEzE,EAAI,IAAA,yBAAA;AAA2B,IAAO,OAAA,yBAAA,CAAA;AAEtC,EAAM,MAAA,YAAA,GAAe,IAAI,UAAA,CAAW,WAAW,CAAA,CAAA;AAE/C,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,WAAA,EAAa,CACjC,EAAA,EAAA;AACI,IAAA,YAAA,CAAa,CAAC,CAAI,GAAA,CAAA,CAAA;AAAA,GACtB;AAEA,EAAA,yBAAA,GAA4B,6BAA8B,CAAA,WAAW,CAAI,GAAA,IAAIA,yBAAa,CAAA;AAAA,IACtF,WAAW,EAAE,KAAA,EAAO,cAAc,IAAM,EAAA,CAAA,GAAA,CAAA,EAAO,MAAM,WAAY,EAAA;AAAA,GAClE,EAAA,EAAE,QAAU,EAAA,IAAA,EAAM,CAAA,CAAA;AAErB,EAAO,OAAA,yBAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,20 @@
import { UniformGroup } from '../../shared/shader/UniformGroup.mjs';
"use strict";
const batchSamplersUniformGroupHash = {};
function getBatchSamplersUniformGroup(maxTextures) {
let batchSamplersUniformGroup = batchSamplersUniformGroupHash[maxTextures];
if (batchSamplersUniformGroup)
return batchSamplersUniformGroup;
const sampleValues = new Int32Array(maxTextures);
for (let i = 0; i < maxTextures; i++) {
sampleValues[i] = i;
}
batchSamplersUniformGroup = batchSamplersUniformGroupHash[maxTextures] = new UniformGroup({
uTextures: { value: sampleValues, type: `i32`, size: maxTextures }
}, { isStatic: true });
return batchSamplersUniformGroup;
}
export { getBatchSamplersUniformGroup };
//# sourceMappingURL=getBatchSamplersUniformGroup.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getBatchSamplersUniformGroup.mjs","sources":["../../../../../src/rendering/renderers/gl/shader/getBatchSamplersUniformGroup.ts"],"sourcesContent":["import { UniformGroup } from '../../shared/shader/UniformGroup';\n\nconst batchSamplersUniformGroupHash: Record<number, UniformGroup> = {};\n\n/**\n * Automatically generates a uniform group that holds the texture samplers for a shader.\n * This is used mainly by the shaders that batch textures!\n * @param maxTextures - the number of textures that this uniform group will contain.\n * @returns a uniform group that holds the texture samplers.\n */\nexport function getBatchSamplersUniformGroup(maxTextures: number)\n{\n let batchSamplersUniformGroup = batchSamplersUniformGroupHash[maxTextures];\n\n if (batchSamplersUniformGroup) return batchSamplersUniformGroup;\n\n const sampleValues = new Int32Array(maxTextures);\n\n for (let i = 0; i < maxTextures; i++)\n {\n sampleValues[i] = i;\n }\n\n batchSamplersUniformGroup = batchSamplersUniformGroupHash[maxTextures] = new UniformGroup({\n uTextures: { value: sampleValues, type: `i32`, size: maxTextures }\n }, { isStatic: true });\n\n return batchSamplersUniformGroup;\n}\n"],"names":[],"mappings":";;;AAEA,MAAM,gCAA8D,EAAC,CAAA;AAQ9D,SAAS,6BAA6B,WAC7C,EAAA;AACI,EAAI,IAAA,yBAAA,GAA4B,8BAA8B,WAAW,CAAA,CAAA;AAEzE,EAAI,IAAA,yBAAA;AAA2B,IAAO,OAAA,yBAAA,CAAA;AAEtC,EAAM,MAAA,YAAA,GAAe,IAAI,UAAA,CAAW,WAAW,CAAA,CAAA;AAE/C,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,WAAA,EAAa,CACjC,EAAA,EAAA;AACI,IAAA,YAAA,CAAa,CAAC,CAAI,GAAA,CAAA,CAAA;AAAA,GACtB;AAEA,EAAA,yBAAA,GAA4B,6BAA8B,CAAA,WAAW,CAAI,GAAA,IAAI,YAAa,CAAA;AAAA,IACtF,WAAW,EAAE,KAAA,EAAO,cAAc,IAAM,EAAA,CAAA,GAAA,CAAA,EAAO,MAAM,WAAY,EAAA;AAAA,GAClE,EAAA,EAAE,QAAU,EAAA,IAAA,EAAM,CAAA,CAAA;AAErB,EAAO,OAAA,yBAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1 @@
export declare function migrateFragmentFromV7toV8(fragmentShader: string): string;

View File

@@ -0,0 +1,14 @@
'use strict';
"use strict";
function migrateFragmentFromV7toV8(fragmentShader) {
fragmentShader = fragmentShader.replaceAll("texture2D", "texture").replaceAll("gl_FragColor", "finalColor").replaceAll("varying", "in");
fragmentShader = `
out vec4 finalColor;
${fragmentShader}
`;
return fragmentShader;
}
exports.migrateFragmentFromV7toV8 = migrateFragmentFromV7toV8;
//# sourceMappingURL=migrateFragmentFromV7toV8.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"migrateFragmentFromV7toV8.js","sources":["../../../../../src/rendering/renderers/gl/shader/migrateFragmentFromV7toV8.ts"],"sourcesContent":["export function migrateFragmentFromV7toV8(fragmentShader: string): string\n{\n fragmentShader = fragmentShader\n .replaceAll('texture2D', 'texture')\n .replaceAll('gl_FragColor', 'finalColor')\n .replaceAll('varying', 'in');\n\n fragmentShader = `\n out vec4 finalColor;\n ${fragmentShader}\n `;\n\n return fragmentShader;\n}\n"],"names":[],"mappings":";;;AAAO,SAAS,0BAA0B,cAC1C,EAAA;AACI,EAAiB,cAAA,GAAA,cAAA,CACZ,UAAW,CAAA,WAAA,EAAa,SAAS,CAAA,CACjC,UAAW,CAAA,cAAA,EAAgB,YAAY,CAAA,CACvC,UAAW,CAAA,SAAA,EAAW,IAAI,CAAA,CAAA;AAE/B,EAAiB,cAAA,GAAA,CAAA;AAAA;AAAA,IAAA,EAEf,cAAc,CAAA;AAAA,IAAA,CAAA,CAAA;AAGhB,EAAO,OAAA,cAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,12 @@
"use strict";
function migrateFragmentFromV7toV8(fragmentShader) {
fragmentShader = fragmentShader.replaceAll("texture2D", "texture").replaceAll("gl_FragColor", "finalColor").replaceAll("varying", "in");
fragmentShader = `
out vec4 finalColor;
${fragmentShader}
`;
return fragmentShader;
}
export { migrateFragmentFromV7toV8 };
//# sourceMappingURL=migrateFragmentFromV7toV8.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"migrateFragmentFromV7toV8.mjs","sources":["../../../../../src/rendering/renderers/gl/shader/migrateFragmentFromV7toV8.ts"],"sourcesContent":["export function migrateFragmentFromV7toV8(fragmentShader: string): string\n{\n fragmentShader = fragmentShader\n .replaceAll('texture2D', 'texture')\n .replaceAll('gl_FragColor', 'finalColor')\n .replaceAll('varying', 'in');\n\n fragmentShader = `\n out vec4 finalColor;\n ${fragmentShader}\n `;\n\n return fragmentShader;\n}\n"],"names":[],"mappings":";AAAO,SAAS,0BAA0B,cAC1C,EAAA;AACI,EAAiB,cAAA,GAAA,cAAA,CACZ,UAAW,CAAA,WAAA,EAAa,SAAS,CAAA,CACjC,UAAW,CAAA,cAAA,EAAgB,YAAY,CAAA,CACvC,UAAW,CAAA,SAAA,EAAW,IAAI,CAAA,CAAA;AAE/B,EAAiB,cAAA,GAAA,CAAA;AAAA;AAAA,IAAA,EAEf,cAAc,CAAA;AAAA,IAAA,CAAA,CAAA;AAGhB,EAAO,OAAA,cAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,8 @@
/**
* @private
* @param {WebGLRenderingContext} gl - The current WebGL context {WebGLProgram}
* @param {number} type - the type, can be either VERTEX_SHADER or FRAGMENT_SHADER
* @param {string} src - The vertex shader source as an array of strings.
* @returns {WebGLShader} the shader
*/
export declare function compileShader(gl: WebGLRenderingContextBase, type: number, src: string): WebGLShader;

View File

@@ -0,0 +1,12 @@
'use strict';
"use strict";
function compileShader(gl, type, src) {
const shader = gl.createShader(type);
gl.shaderSource(shader, src);
gl.compileShader(shader);
return shader;
}
exports.compileShader = compileShader;
//# sourceMappingURL=compileShader.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"compileShader.js","sources":["../../../../../../src/rendering/renderers/gl/shader/program/compileShader.ts"],"sourcesContent":["/**\n * @private\n * @param {WebGLRenderingContext} gl - The current WebGL context {WebGLProgram}\n * @param {number} type - the type, can be either VERTEX_SHADER or FRAGMENT_SHADER\n * @param {string} src - The vertex shader source as an array of strings.\n * @returns {WebGLShader} the shader\n */\nexport function compileShader(gl: WebGLRenderingContextBase, type: number, src: string): WebGLShader\n{\n const shader = gl.createShader(type);\n\n gl.shaderSource(shader, src);\n gl.compileShader(shader);\n\n return shader;\n}\n"],"names":[],"mappings":";;;AAOgB,SAAA,aAAA,CAAc,EAA+B,EAAA,IAAA,EAAc,GAC3E,EAAA;AACI,EAAM,MAAA,MAAA,GAAS,EAAG,CAAA,YAAA,CAAa,IAAI,CAAA,CAAA;AAEnC,EAAG,EAAA,CAAA,YAAA,CAAa,QAAQ,GAAG,CAAA,CAAA;AAC3B,EAAA,EAAA,CAAG,cAAc,MAAM,CAAA,CAAA;AAEvB,EAAO,OAAA,MAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,10 @@
"use strict";
function compileShader(gl, type, src) {
const shader = gl.createShader(type);
gl.shaderSource(shader, src);
gl.compileShader(shader);
return shader;
}
export { compileShader };
//# sourceMappingURL=compileShader.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"compileShader.mjs","sources":["../../../../../../src/rendering/renderers/gl/shader/program/compileShader.ts"],"sourcesContent":["/**\n * @private\n * @param {WebGLRenderingContext} gl - The current WebGL context {WebGLProgram}\n * @param {number} type - the type, can be either VERTEX_SHADER or FRAGMENT_SHADER\n * @param {string} src - The vertex shader source as an array of strings.\n * @returns {WebGLShader} the shader\n */\nexport function compileShader(gl: WebGLRenderingContextBase, type: number, src: string): WebGLShader\n{\n const shader = gl.createShader(type);\n\n gl.shaderSource(shader, src);\n gl.compileShader(shader);\n\n return shader;\n}\n"],"names":[],"mappings":";AAOgB,SAAA,aAAA,CAAc,EAA+B,EAAA,IAAA,EAAc,GAC3E,EAAA;AACI,EAAM,MAAA,MAAA,GAAS,EAAG,CAAA,YAAA,CAAa,IAAI,CAAA,CAAA;AAEnC,EAAG,EAAA,CAAA,YAAA,CAAa,QAAQ,GAAG,CAAA,CAAA;AAC3B,EAAA,EAAA,CAAG,cAAc,MAAM,CAAA,CAAA;AAEvB,EAAO,OAAA,MAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,7 @@
/**
* @method defaultValue
* @param {string} type - Type of value
* @param {number} size
* @private
*/
export declare function defaultValue(type: string, size: number): number | Float32Array | Int32Array | Uint32Array | boolean | boolean[];

View File

@@ -0,0 +1,89 @@
'use strict';
"use strict";
function booleanArray(size) {
const array = new Array(size);
for (let i = 0; i < array.length; i++) {
array[i] = false;
}
return array;
}
function defaultValue(type, size) {
switch (type) {
case "float":
return 0;
case "vec2":
return new Float32Array(2 * size);
case "vec3":
return new Float32Array(3 * size);
case "vec4":
return new Float32Array(4 * size);
case "int":
case "uint":
case "sampler2D":
case "sampler2DArray":
return 0;
case "ivec2":
return new Int32Array(2 * size);
case "ivec3":
return new Int32Array(3 * size);
case "ivec4":
return new Int32Array(4 * size);
case "uvec2":
return new Uint32Array(2 * size);
case "uvec3":
return new Uint32Array(3 * size);
case "uvec4":
return new Uint32Array(4 * size);
case "bool":
return false;
case "bvec2":
return booleanArray(2 * size);
case "bvec3":
return booleanArray(3 * size);
case "bvec4":
return booleanArray(4 * size);
case "mat2":
return new Float32Array([
1,
0,
0,
1
]);
case "mat3":
return new Float32Array([
1,
0,
0,
0,
1,
0,
0,
0,
1
]);
case "mat4":
return new Float32Array([
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1
]);
}
return null;
}
exports.defaultValue = defaultValue;
//# sourceMappingURL=defaultValue.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"defaultValue.js","sources":["../../../../../../src/rendering/renderers/gl/shader/program/defaultValue.ts"],"sourcesContent":["function booleanArray(size: number): Array<boolean>\n{\n const array = new Array(size);\n\n for (let i = 0; i < array.length; i++)\n {\n array[i] = false;\n }\n\n return array;\n}\n\n/**\n * @method defaultValue\n * @param {string} type - Type of value\n * @param {number} size\n * @private\n */\nexport function defaultValue(\n type: string,\n size: number\n): number | Float32Array | Int32Array | Uint32Array | boolean | boolean[]\n{\n switch (type)\n {\n case 'float':\n return 0;\n\n case 'vec2':\n return new Float32Array(2 * size);\n\n case 'vec3':\n return new Float32Array(3 * size);\n\n case 'vec4':\n return new Float32Array(4 * size);\n\n case 'int':\n case 'uint':\n case 'sampler2D':\n case 'sampler2DArray':\n return 0;\n\n case 'ivec2':\n return new Int32Array(2 * size);\n\n case 'ivec3':\n return new Int32Array(3 * size);\n\n case 'ivec4':\n return new Int32Array(4 * size);\n\n case 'uvec2':\n return new Uint32Array(2 * size);\n\n case 'uvec3':\n return new Uint32Array(3 * size);\n\n case 'uvec4':\n return new Uint32Array(4 * size);\n\n case 'bool':\n return false;\n\n case 'bvec2':\n\n return booleanArray(2 * size);\n\n case 'bvec3':\n return booleanArray(3 * size);\n\n case 'bvec4':\n return booleanArray(4 * size);\n\n case 'mat2':\n return new Float32Array([1, 0,\n 0, 1]);\n\n case 'mat3':\n return new Float32Array([1, 0, 0,\n 0, 1, 0,\n 0, 0, 1]);\n\n case 'mat4':\n return new Float32Array([1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1]);\n }\n\n return null;\n}\n"],"names":[],"mappings":";;;AAAA,SAAS,aAAa,IACtB,EAAA;AACI,EAAM,MAAA,KAAA,GAAQ,IAAI,KAAA,CAAM,IAAI,CAAA,CAAA;AAE5B,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,KAAA,CAAM,QAAQ,CAClC,EAAA,EAAA;AACI,IAAA,KAAA,CAAM,CAAC,CAAI,GAAA,KAAA,CAAA;AAAA,GACf;AAEA,EAAO,OAAA,KAAA,CAAA;AACX,CAAA;AAQgB,SAAA,YAAA,CACZ,MACA,IAEJ,EAAA;AACI,EAAA,QAAQ,IACR;AAAA,IACI,KAAK,OAAA;AACD,MAAO,OAAA,CAAA,CAAA;AAAA,IAEX,KAAK,MAAA;AACD,MAAO,OAAA,IAAI,YAAa,CAAA,CAAA,GAAI,IAAI,CAAA,CAAA;AAAA,IAEpC,KAAK,MAAA;AACD,MAAO,OAAA,IAAI,YAAa,CAAA,CAAA,GAAI,IAAI,CAAA,CAAA;AAAA,IAEpC,KAAK,MAAA;AACD,MAAO,OAAA,IAAI,YAAa,CAAA,CAAA,GAAI,IAAI,CAAA,CAAA;AAAA,IAEpC,KAAK,KAAA,CAAA;AAAA,IACL,KAAK,MAAA,CAAA;AAAA,IACL,KAAK,WAAA,CAAA;AAAA,IACL,KAAK,gBAAA;AACD,MAAO,OAAA,CAAA,CAAA;AAAA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B,KAAK,MAAA;AACD,MAAA,OAAO,IAAI,YAAa,CAAA;AAAA,QAAC,CAAA;AAAA,QAAG,CAAA;AAAA,QAAG,CAAA;AAAA,QAAG,CAAA;AAAA,QAC9B,CAAA;AAAA,QAAG,CAAA;AAAA,QAAG,CAAA;AAAA,QAAG,CAAA;AAAA,QACT,CAAA;AAAA,QAAG,CAAA;AAAA,QAAG,CAAA;AAAA,QAAG,CAAA;AAAA,QACT,CAAA;AAAA,QAAG,CAAA;AAAA,QAAG,CAAA;AAAA,QAAG,CAAA;AAAA,OAAE,CAAA,CAAA;AAAA,GACvB;AAEA,EAAO,OAAA,IAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,87 @@
"use strict";
function booleanArray(size) {
const array = new Array(size);
for (let i = 0; i < array.length; i++) {
array[i] = false;
}
return array;
}
function defaultValue(type, size) {
switch (type) {
case "float":
return 0;
case "vec2":
return new Float32Array(2 * size);
case "vec3":
return new Float32Array(3 * size);
case "vec4":
return new Float32Array(4 * size);
case "int":
case "uint":
case "sampler2D":
case "sampler2DArray":
return 0;
case "ivec2":
return new Int32Array(2 * size);
case "ivec3":
return new Int32Array(3 * size);
case "ivec4":
return new Int32Array(4 * size);
case "uvec2":
return new Uint32Array(2 * size);
case "uvec3":
return new Uint32Array(3 * size);
case "uvec4":
return new Uint32Array(4 * size);
case "bool":
return false;
case "bvec2":
return booleanArray(2 * size);
case "bvec3":
return booleanArray(3 * size);
case "bvec4":
return booleanArray(4 * size);
case "mat2":
return new Float32Array([
1,
0,
0,
1
]);
case "mat3":
return new Float32Array([
1,
0,
0,
0,
1,
0,
0,
0,
1
]);
case "mat4":
return new Float32Array([
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1
]);
}
return null;
}
export { defaultValue };
//# sourceMappingURL=defaultValue.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"defaultValue.mjs","sources":["../../../../../../src/rendering/renderers/gl/shader/program/defaultValue.ts"],"sourcesContent":["function booleanArray(size: number): Array<boolean>\n{\n const array = new Array(size);\n\n for (let i = 0; i < array.length; i++)\n {\n array[i] = false;\n }\n\n return array;\n}\n\n/**\n * @method defaultValue\n * @param {string} type - Type of value\n * @param {number} size\n * @private\n */\nexport function defaultValue(\n type: string,\n size: number\n): number | Float32Array | Int32Array | Uint32Array | boolean | boolean[]\n{\n switch (type)\n {\n case 'float':\n return 0;\n\n case 'vec2':\n return new Float32Array(2 * size);\n\n case 'vec3':\n return new Float32Array(3 * size);\n\n case 'vec4':\n return new Float32Array(4 * size);\n\n case 'int':\n case 'uint':\n case 'sampler2D':\n case 'sampler2DArray':\n return 0;\n\n case 'ivec2':\n return new Int32Array(2 * size);\n\n case 'ivec3':\n return new Int32Array(3 * size);\n\n case 'ivec4':\n return new Int32Array(4 * size);\n\n case 'uvec2':\n return new Uint32Array(2 * size);\n\n case 'uvec3':\n return new Uint32Array(3 * size);\n\n case 'uvec4':\n return new Uint32Array(4 * size);\n\n case 'bool':\n return false;\n\n case 'bvec2':\n\n return booleanArray(2 * size);\n\n case 'bvec3':\n return booleanArray(3 * size);\n\n case 'bvec4':\n return booleanArray(4 * size);\n\n case 'mat2':\n return new Float32Array([1, 0,\n 0, 1]);\n\n case 'mat3':\n return new Float32Array([1, 0, 0,\n 0, 1, 0,\n 0, 0, 1]);\n\n case 'mat4':\n return new Float32Array([1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1]);\n }\n\n return null;\n}\n"],"names":[],"mappings":";AAAA,SAAS,aAAa,IACtB,EAAA;AACI,EAAM,MAAA,KAAA,GAAQ,IAAI,KAAA,CAAM,IAAI,CAAA,CAAA;AAE5B,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,KAAA,CAAM,QAAQ,CAClC,EAAA,EAAA;AACI,IAAA,KAAA,CAAM,CAAC,CAAI,GAAA,KAAA,CAAA;AAAA,GACf;AAEA,EAAO,OAAA,KAAA,CAAA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A;AACD,MAAO,OAAA,YAAA,CAAa,IAAI,IAAI,CAAA,CAAA;AAAA,IAEhC,KAAK,OAAA;AACD,MAAO,OAAA,YAAA,CAAa,IAAI,IAAI,CAAA,CAAA;AAAA,IAEhC,KAAK,MAAA;AACD,MAAA,OAAO,IAAI,YAAa,CAAA;AAAA,QAAC,CAAA;AAAA,QAAG,CAAA;AAAA,QACxB,CAAA;AAAA,QAAG,CAAA;AAAA,OAAE,CAAA,CAAA;AAAA,IAEb,KAAK,MAAA;AACD,MAAA,OAAO,IAAI,YAAa,CAAA;AAAA,QAAC,CAAA;AAAA,QAAG,CAAA;AAAA,QAAG,CAAA;AAAA,QAC3B,CAAA;AAAA,QAAG,CAAA;AAAA,QAAG,CAAA;AAAA,QACN,CAAA;AAAA,QAAG,CAAA;AAAA,QAAG,CAAA;AAAA,OAAE,CAAA,CAAA;AAAA,IAEhB,KAAK,MAAA;AACD,MAAA,OAAO,IAAI,YAAa,CAAA;AAAA,QAAC,CAAA;AAAA,QAAG,CAAA;AAAA,QAAG,CAAA;AAAA,QAAG,CAAA;AAAA,QAC9B,CAAA;AAAA,QAAG,CAAA;AAAA,QAAG,CAAA;AAAA,QAAG,CAAA;AAAA,QACT,CAAA;AAAA,QAAG,CAAA;AAAA,QAAG,CAAA;AAAA,QAAG,CAAA;AAAA,QACT,CAAA;AAAA,QAAG,CAAA;AAAA,QAAG,CAAA;AAAA,QAAG,CAAA;AAAA,OAAE,CAAA,CAAA;AAAA,GACvB;AAEA,EAAO,OAAA,IAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,14 @@
import type { Geometry } from '../../../shared/geometry/Geometry';
import type { ExtractedAttributeData } from './extractAttributesFromGlProgram';
/**
* This function looks at the attribute information provided to the geometry and attempts
* to fill in an gaps. WE do this by looking at the extracted data from the shader and
* making best guesses.
*
* Most of th etime users don't need to provide all the attribute info beyond the data itself, so we
* can fill in the gaps for them. If you are using attributes in a more advanced way, you can
* don't forget to add all the info at creation!
* @param geometry - the geometry to ensure attributes for
* @param extractedData - the extracted data from the shader
*/
export declare function ensureAttributes(geometry: Geometry, extractedData: Record<string, ExtractedAttributeData>): void;

View File

@@ -0,0 +1,43 @@
'use strict';
var warn = require('../../../../../utils/logging/warn.js');
var getAttributeInfoFromFormat = require('../../../shared/geometry/utils/getAttributeInfoFromFormat.js');
"use strict";
function ensureAttributes(geometry, extractedData) {
for (const i in geometry.attributes) {
const attribute = geometry.attributes[i];
const attributeData = extractedData[i];
if (attributeData) {
attribute.format ?? (attribute.format = attributeData.format);
attribute.offset ?? (attribute.offset = attributeData.offset);
attribute.instance ?? (attribute.instance = attributeData.instance);
} else {
warn.warn(`Attribute ${i} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`);
}
}
ensureStartAndStride(geometry);
}
function ensureStartAndStride(geometry) {
const { buffers, attributes } = geometry;
const tempStride = {};
const tempStart = {};
for (const j in buffers) {
const buffer = buffers[j];
tempStride[buffer.uid] = 0;
tempStart[buffer.uid] = 0;
}
for (const j in attributes) {
const attribute = attributes[j];
tempStride[attribute.buffer.uid] += getAttributeInfoFromFormat.getAttributeInfoFromFormat(attribute.format).stride;
}
for (const j in attributes) {
const attribute = attributes[j];
attribute.stride ?? (attribute.stride = tempStride[attribute.buffer.uid]);
attribute.start ?? (attribute.start = tempStart[attribute.buffer.uid]);
tempStart[attribute.buffer.uid] += getAttributeInfoFromFormat.getAttributeInfoFromFormat(attribute.format).stride;
}
}
exports.ensureAttributes = ensureAttributes;
//# sourceMappingURL=ensureAttributes.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ensureAttributes.js","sources":["../../../../../../src/rendering/renderers/gl/shader/program/ensureAttributes.ts"],"sourcesContent":["import { warn } from '../../../../../utils/logging/warn';\nimport { getAttributeInfoFromFormat } from '../../../shared/geometry/utils/getAttributeInfoFromFormat';\n\nimport type { Geometry } from '../../../shared/geometry/Geometry';\nimport type { ExtractedAttributeData } from './extractAttributesFromGlProgram';\n\n/**\n * This function looks at the attribute information provided to the geometry and attempts\n * to fill in an gaps. WE do this by looking at the extracted data from the shader and\n * making best guesses.\n *\n * Most of th etime users don't need to provide all the attribute info beyond the data itself, so we\n * can fill in the gaps for them. If you are using attributes in a more advanced way, you can\n * don't forget to add all the info at creation!\n * @param geometry - the geometry to ensure attributes for\n * @param extractedData - the extracted data from the shader\n */\nexport function ensureAttributes(\n geometry: Geometry,\n extractedData: Record<string, ExtractedAttributeData>\n): void\n{\n for (const i in geometry.attributes)\n {\n const attribute = geometry.attributes[i];\n const attributeData = extractedData[i];\n\n if (attributeData)\n {\n attribute.format ??= attributeData.format;\n attribute.offset ??= attributeData.offset;\n attribute.instance ??= attributeData.instance;\n }\n else\n {\n // eslint-disable-next-line max-len\n warn(`Attribute ${i} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`);\n }\n }\n\n ensureStartAndStride(geometry);\n}\n\nfunction ensureStartAndStride(geometry: Geometry): void\n{\n const { buffers, attributes } = geometry;\n\n const tempStride: Record<string, number> = {};\n const tempStart: Record<string, number> = {};\n\n for (const j in buffers)\n {\n const buffer = buffers[j];\n\n tempStride[buffer.uid] = 0;\n tempStart[buffer.uid] = 0;\n }\n\n for (const j in attributes)\n {\n const attribute = attributes[j];\n\n tempStride[attribute.buffer.uid] += getAttributeInfoFromFormat(attribute.format).stride;\n }\n\n for (const j in attributes)\n {\n const attribute = attributes[j];\n\n attribute.stride ??= tempStride[attribute.buffer.uid];\n\n attribute.start ??= tempStart[attribute.buffer.uid];\n\n tempStart[attribute.buffer.uid] += getAttributeInfoFromFormat(attribute.format).stride;\n }\n}\n"],"names":["warn","getAttributeInfoFromFormat"],"mappings":";;;;;;AAiBgB,SAAA,gBAAA,CACZ,UACA,aAEJ,EAAA;AACI,EAAW,KAAA,MAAA,CAAA,IAAK,SAAS,UACzB,EAAA;AACI,IAAM,MAAA,SAAA,GAAY,QAAS,CAAA,UAAA,CAAW,CAAC,CAAA,CAAA;AACvC,IAAM,MAAA,aAAA,GAAgB,cAAc,CAAC,CAA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,IAAA,SAAA,CAAU,WAAV,SAAU,CAAA,MAAA,GAAW,UAAW,CAAA,SAAA,CAAU,OAAO,GAAG,CAAA,CAAA,CAAA;AAEpD,IAAA,SAAA,CAAU,UAAV,SAAU,CAAA,KAAA,GAAU,SAAU,CAAA,SAAA,CAAU,OAAO,GAAG,CAAA,CAAA,CAAA;AAElD,IAAA,SAAA,CAAU,UAAU,MAAO,CAAA,GAAG,KAAKA,qDAA2B,CAAA,SAAA,CAAU,MAAM,CAAE,CAAA,MAAA,CAAA;AAAA,GACpF;AACJ;;;;"}

View File

@@ -0,0 +1,41 @@
import { warn } from '../../../../../utils/logging/warn.mjs';
import { getAttributeInfoFromFormat } from '../../../shared/geometry/utils/getAttributeInfoFromFormat.mjs';
"use strict";
function ensureAttributes(geometry, extractedData) {
for (const i in geometry.attributes) {
const attribute = geometry.attributes[i];
const attributeData = extractedData[i];
if (attributeData) {
attribute.format ?? (attribute.format = attributeData.format);
attribute.offset ?? (attribute.offset = attributeData.offset);
attribute.instance ?? (attribute.instance = attributeData.instance);
} else {
warn(`Attribute ${i} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`);
}
}
ensureStartAndStride(geometry);
}
function ensureStartAndStride(geometry) {
const { buffers, attributes } = geometry;
const tempStride = {};
const tempStart = {};
for (const j in buffers) {
const buffer = buffers[j];
tempStride[buffer.uid] = 0;
tempStart[buffer.uid] = 0;
}
for (const j in attributes) {
const attribute = attributes[j];
tempStride[attribute.buffer.uid] += getAttributeInfoFromFormat(attribute.format).stride;
}
for (const j in attributes) {
const attribute = attributes[j];
attribute.stride ?? (attribute.stride = tempStride[attribute.buffer.uid]);
attribute.start ?? (attribute.start = tempStart[attribute.buffer.uid]);
tempStart[attribute.buffer.uid] += getAttributeInfoFromFormat(attribute.format).stride;
}
}
export { ensureAttributes };
//# sourceMappingURL=ensureAttributes.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ensureAttributes.mjs","sources":["../../../../../../src/rendering/renderers/gl/shader/program/ensureAttributes.ts"],"sourcesContent":["import { warn } from '../../../../../utils/logging/warn';\nimport { getAttributeInfoFromFormat } from '../../../shared/geometry/utils/getAttributeInfoFromFormat';\n\nimport type { Geometry } from '../../../shared/geometry/Geometry';\nimport type { ExtractedAttributeData } from './extractAttributesFromGlProgram';\n\n/**\n * This function looks at the attribute information provided to the geometry and attempts\n * to fill in an gaps. WE do this by looking at the extracted data from the shader and\n * making best guesses.\n *\n * Most of th etime users don't need to provide all the attribute info beyond the data itself, so we\n * can fill in the gaps for them. If you are using attributes in a more advanced way, you can\n * don't forget to add all the info at creation!\n * @param geometry - the geometry to ensure attributes for\n * @param extractedData - the extracted data from the shader\n */\nexport function ensureAttributes(\n geometry: Geometry,\n extractedData: Record<string, ExtractedAttributeData>\n): void\n{\n for (const i in geometry.attributes)\n {\n const attribute = geometry.attributes[i];\n const attributeData = extractedData[i];\n\n if (attributeData)\n {\n attribute.format ??= attributeData.format;\n attribute.offset ??= attributeData.offset;\n attribute.instance ??= attributeData.instance;\n }\n else\n {\n // eslint-disable-next-line max-len\n warn(`Attribute ${i} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`);\n }\n }\n\n ensureStartAndStride(geometry);\n}\n\nfunction ensureStartAndStride(geometry: Geometry): void\n{\n const { buffers, attributes } = geometry;\n\n const tempStride: Record<string, number> = {};\n const tempStart: Record<string, number> = {};\n\n for (const j in buffers)\n {\n const buffer = buffers[j];\n\n tempStride[buffer.uid] = 0;\n tempStart[buffer.uid] = 0;\n }\n\n for (const j in attributes)\n {\n const attribute = attributes[j];\n\n tempStride[attribute.buffer.uid] += getAttributeInfoFromFormat(attribute.format).stride;\n }\n\n for (const j in attributes)\n {\n const attribute = attributes[j];\n\n attribute.stride ??= tempStride[attribute.buffer.uid];\n\n attribute.start ??= tempStart[attribute.buffer.uid];\n\n tempStart[attribute.buffer.uid] += getAttributeInfoFromFormat(attribute.format).stride;\n }\n}\n"],"names":[],"mappings":";;;;AAiBgB,SAAA,gBAAA,CACZ,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AAA,GAAG,KAAK,0BAA2B,CAAA,SAAA,CAAU,MAAM,CAAE,CAAA,MAAA,CAAA;AAAA,GACrF;AAEA,EAAA,KAAA,MAAW,KAAK,UAChB,EAAA;AACI,IAAM,MAAA,SAAA,GAAY,WAAW,CAAC,CAAA,CAAA;AAE9B,IAAA,SAAA,CAAU,WAAV,SAAU,CAAA,MAAA,GAAW,UAAW,CAAA,SAAA,CAAU,OAAO,GAAG,CAAA,CAAA,CAAA;AAEpD,IAAA,SAAA,CAAU,UAAV,SAAU,CAAA,KAAA,GAAU,SAAU,CAAA,SAAA,CAAU,OAAO,GAAG,CAAA,CAAA,CAAA;AAElD,IAAA,SAAA,CAAU,UAAU,MAAO,CAAA,GAAG,KAAK,0BAA2B,CAAA,SAAA,CAAU,MAAM,CAAE,CAAA,MAAA,CAAA;AAAA,GACpF;AACJ;;;;"}

View File

@@ -0,0 +1,13 @@
import type { Attribute } from '../../../shared/geometry/Geometry';
export interface ExtractedAttributeData extends Omit<Attribute, 'buffer'> {
/** set where the shader location is for this attribute */
location?: number;
}
/**
* returns the attribute data from the program
* @private
* @param {WebGLProgram} [program] - the WebGL program
* @param {WebGLRenderingContext} [gl] - the WebGL context
* @returns {object} the attribute data for this program
*/
export declare function extractAttributesFromGlProgram(program: WebGLProgram, gl: WebGLRenderingContextBase, sortAttributes?: boolean): Record<string, ExtractedAttributeData>;

View File

@@ -0,0 +1,43 @@
'use strict';
var getAttributeInfoFromFormat = require('../../../shared/geometry/utils/getAttributeInfoFromFormat.js');
var mapType = require('./mapType.js');
"use strict";
function extractAttributesFromGlProgram(program, gl, sortAttributes = false) {
const attributes = {};
const totalAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
for (let i = 0; i < totalAttributes; i++) {
const attribData = gl.getActiveAttrib(program, i);
if (attribData.name.startsWith("gl_")) {
continue;
}
const format = mapType.mapGlToVertexFormat(gl, attribData.type);
attributes[attribData.name] = {
location: 0,
// set further down..
format,
stride: getAttributeInfoFromFormat.getAttributeInfoFromFormat(format).stride,
offset: 0,
instance: false,
start: 0
};
}
const keys = Object.keys(attributes);
if (sortAttributes) {
keys.sort((a, b) => a > b ? 1 : -1);
for (let i = 0; i < keys.length; i++) {
attributes[keys[i]].location = i;
gl.bindAttribLocation(program, i, keys[i]);
}
gl.linkProgram(program);
} else {
for (let i = 0; i < keys.length; i++) {
attributes[keys[i]].location = gl.getAttribLocation(program, keys[i]);
}
}
return attributes;
}
exports.extractAttributesFromGlProgram = extractAttributesFromGlProgram;
//# sourceMappingURL=extractAttributesFromGlProgram.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"extractAttributesFromGlProgram.js","sources":["../../../../../../src/rendering/renderers/gl/shader/program/extractAttributesFromGlProgram.ts"],"sourcesContent":["import { getAttributeInfoFromFormat } from '../../../shared/geometry/utils/getAttributeInfoFromFormat';\nimport { mapGlToVertexFormat } from './mapType';\n\nimport type { Attribute } from '../../../shared/geometry/Geometry';\n\nexport interface ExtractedAttributeData extends Omit<Attribute, 'buffer'>\n{\n /** set where the shader location is for this attribute */\n location?: number;\n}\n\n/**\n * returns the attribute data from the program\n * @private\n * @param {WebGLProgram} [program] - the WebGL program\n * @param {WebGLRenderingContext} [gl] - the WebGL context\n * @returns {object} the attribute data for this program\n */\n\nexport function extractAttributesFromGlProgram(\n program: WebGLProgram,\n gl: WebGLRenderingContextBase,\n sortAttributes = false\n): Record<string, ExtractedAttributeData>\n{\n const attributes: {[key: string]: ExtractedAttributeData} = {};\n\n const totalAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);\n\n for (let i = 0; i < totalAttributes; i++)\n {\n const attribData = gl.getActiveAttrib(program, i);\n\n // ignore the default ones!\n if (attribData.name.startsWith('gl_'))\n {\n continue;\n }\n\n const format = mapGlToVertexFormat(gl, attribData.type);\n\n attributes[attribData.name] = {\n location: 0, // set further down..\n format,\n stride: getAttributeInfoFromFormat(format).stride,\n offset: 0,\n instance: false,\n start: 0,\n };\n }\n\n const keys = Object.keys(attributes);\n\n if (sortAttributes)\n {\n keys.sort((a, b) => (a > b) ? 1 : -1); // eslint-disable-line no-confusing-arrow\n\n for (let i = 0; i < keys.length; i++)\n {\n attributes[keys[i]].location = i;\n\n gl.bindAttribLocation(program, i, keys[i]);\n }\n\n gl.linkProgram(program);\n }\n else\n {\n for (let i = 0; i < keys.length; i++)\n {\n attributes[keys[i]].location = gl.getAttribLocation(program, keys[i]);\n }\n }\n\n return attributes;\n}\n"],"names":["mapGlToVertexFormat","getAttributeInfoFromFormat"],"mappings":";;;;;;AAmBO,SAAS,8BACZ,CAAA,OAAA,EACA,EACA,EAAA,cAAA,GAAiB,KAErB,EAAA;AACI,EAAA,MAAM,aAAsD,EAAC,CAAA;AAE7D,EAAA,MAAM,eAAkB,GAAA,EAAA,CAAG,mBAAoB,CAAA,OAAA,EAAS,GAAG,iBAAiB,CAAA,CAAA;AAE5E,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,eAAA,EAAiB,CACrC,EAAA,EAAA;AACI,IAAA,MAAM,UAAa,GAAA,EAAA,CAAG,eAAgB,CAAA,OAAA,EAAS,CAAC,CAAA,CAAA;AAGhD,IAAA,IAAI,UAAW,CAAA,IAAA,CAAK,UAAW,CAAA,KAAK,CACpC,EAAA;AACI,MAAA,SAAA;AAAA,KACJ;AAEA,IAAA,MAAM,MAAS,GAAAA,2BAAA,CAAoB,EAAI,EAAA,UAAA,CAAW,IAAI,CAAA,CAAA;AAEtD,IAAW,UAAA,CAAA,UAAA,CAAW,IAAI,CAAI,GAAA;AAAA,MAC1B,QAAU,EAAA,CAAA;AAAA;AAAA,MACV,MAAA;AAAA,MACA,MAAA,EAAQC,qDAA2B,CAAA,MAAM,CAAE,CAAA,MAAA;AAAA,MAC3C,MAAQ,EAAA,CAAA;AAAA,MACR,QAAU,EAAA,KAAA;AAAA,MACV,KAAO,EAAA,CAAA;AAAA,KACX,CAAA;AAAA,GACJ;AAEA,EAAM,MAAA,IAAA,GAAO,MAAO,CAAA,IAAA,CAAK,UAAU,CAAA,CAAA;AAEnC,EAAA,IAAI,cACJ,EAAA;AACI,IAAA,IAAA,CAAK,KAAK,CAAC,CAAA,EAAG,MAAO,CAAI,GAAA,CAAA,GAAK,IAAI,CAAE,CAAA,CAAA,CAAA;AAEpC,IAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,IAAA,CAAK,QAAQ,CACjC,EAAA,EAAA;AACI,MAAA,UAAA,CAAW,IAAK,CAAA,CAAC,CAAC,CAAA,CAAE,QAAW,GAAA,CAAA,CAAA;AAE/B,MAAA,EAAA,CAAG,kBAAmB,CAAA,OAAA,EAAS,CAAG,EAAA,IAAA,CAAK,CAAC,CAAC,CAAA,CAAA;AAAA,KAC7C;AAEA,IAAA,EAAA,CAAG,YAAY,OAAO,CAAA,CAAA;AAAA,GAG1B,MAAA;AACI,IAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,IAAA,CAAK,QAAQ,CACjC,EAAA,EAAA;AACI,MAAW,UAAA,CAAA,IAAA,CAAK,CAAC,CAAC,CAAE,CAAA,QAAA,GAAW,GAAG,iBAAkB,CAAA,OAAA,EAAS,IAAK,CAAA,CAAC,CAAC,CAAA,CAAA;AAAA,KACxE;AAAA,GACJ;AAEA,EAAO,OAAA,UAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,41 @@
import { getAttributeInfoFromFormat } from '../../../shared/geometry/utils/getAttributeInfoFromFormat.mjs';
import { mapGlToVertexFormat } from './mapType.mjs';
"use strict";
function extractAttributesFromGlProgram(program, gl, sortAttributes = false) {
const attributes = {};
const totalAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
for (let i = 0; i < totalAttributes; i++) {
const attribData = gl.getActiveAttrib(program, i);
if (attribData.name.startsWith("gl_")) {
continue;
}
const format = mapGlToVertexFormat(gl, attribData.type);
attributes[attribData.name] = {
location: 0,
// set further down..
format,
stride: getAttributeInfoFromFormat(format).stride,
offset: 0,
instance: false,
start: 0
};
}
const keys = Object.keys(attributes);
if (sortAttributes) {
keys.sort((a, b) => a > b ? 1 : -1);
for (let i = 0; i < keys.length; i++) {
attributes[keys[i]].location = i;
gl.bindAttribLocation(program, i, keys[i]);
}
gl.linkProgram(program);
} else {
for (let i = 0; i < keys.length; i++) {
attributes[keys[i]].location = gl.getAttribLocation(program, keys[i]);
}
}
return attributes;
}
export { extractAttributesFromGlProgram };
//# sourceMappingURL=extractAttributesFromGlProgram.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"extractAttributesFromGlProgram.mjs","sources":["../../../../../../src/rendering/renderers/gl/shader/program/extractAttributesFromGlProgram.ts"],"sourcesContent":["import { getAttributeInfoFromFormat } from '../../../shared/geometry/utils/getAttributeInfoFromFormat';\nimport { mapGlToVertexFormat } from './mapType';\n\nimport type { Attribute } from '../../../shared/geometry/Geometry';\n\nexport interface ExtractedAttributeData extends Omit<Attribute, 'buffer'>\n{\n /** set where the shader location is for this attribute */\n location?: number;\n}\n\n/**\n * returns the attribute data from the program\n * @private\n * @param {WebGLProgram} [program] - the WebGL program\n * @param {WebGLRenderingContext} [gl] - the WebGL context\n * @returns {object} the attribute data for this program\n */\n\nexport function extractAttributesFromGlProgram(\n program: WebGLProgram,\n gl: WebGLRenderingContextBase,\n sortAttributes = false\n): Record<string, ExtractedAttributeData>\n{\n const attributes: {[key: string]: ExtractedAttributeData} = {};\n\n const totalAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);\n\n for (let i = 0; i < totalAttributes; i++)\n {\n const attribData = gl.getActiveAttrib(program, i);\n\n // ignore the default ones!\n if (attribData.name.startsWith('gl_'))\n {\n continue;\n }\n\n const format = mapGlToVertexFormat(gl, attribData.type);\n\n attributes[attribData.name] = {\n location: 0, // set further down..\n format,\n stride: getAttributeInfoFromFormat(format).stride,\n offset: 0,\n instance: false,\n start: 0,\n };\n }\n\n const keys = Object.keys(attributes);\n\n if (sortAttributes)\n {\n keys.sort((a, b) => (a > b) ? 1 : -1); // eslint-disable-line no-confusing-arrow\n\n for (let i = 0; i < keys.length; i++)\n {\n attributes[keys[i]].location = i;\n\n gl.bindAttribLocation(program, i, keys[i]);\n }\n\n gl.linkProgram(program);\n }\n else\n {\n for (let i = 0; i < keys.length; i++)\n {\n attributes[keys[i]].location = gl.getAttribLocation(program, keys[i]);\n }\n }\n\n return attributes;\n}\n"],"names":[],"mappings":";;;;AAmBO,SAAS,8BACZ,CAAA,OAAA,EACA,EACA,EAAA,cAAA,GAAiB,KAErB,EAAA;AACI,EAAA,MAAM,aAAsD,EAAC,CAAA;AAE7D,EAAA,MAAM,eAAkB,GAAA,EAAA,CAAG,mBAAoB,CAAA,OAAA,EAAS,GAAG,iBAAiB,CAAA,CAAA;AAE5E,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,eAAA,EAAiB,CACrC,EAAA,EAAA;AACI,IAAA,MAAM,UAAa,GAAA,EAAA,CAAG,eAAgB,CAAA,OAAA,EAAS,CAAC,CAAA,CAAA;AAGhD,IAAA,IAAI,UAAW,CAAA,IAAA,CAAK,UAAW,CAAA,KAAK,CACpC,EAAA;AACI,MAAA,SAAA;AAAA,KACJ;AAEA,IAAA,MAAM,MAAS,GAAA,mBAAA,CAAoB,EAAI,EAAA,UAAA,CAAW,IAAI,CAAA,CAAA;AAEtD,IAAW,UAAA,CAAA,UAAA,CAAW,IAAI,CAAI,GAAA;AAAA,MAC1B,QAAU,EAAA,CAAA;AAAA;AAAA,MACV,MAAA;AAAA,MACA,MAAA,EAAQ,0BAA2B,CAAA,MAAM,CAAE,CAAA,MAAA;AAAA,MAC3C,MAAQ,EAAA,CAAA;AAAA,MACR,QAAU,EAAA,KAAA;AAAA,MACV,KAAO,EAAA,CAAA;AAAA,KACX,CAAA;AAAA,GACJ;AAEA,EAAM,MAAA,IAAA,GAAO,MAAO,CAAA,IAAA,CAAK,UAAU,CAAA,CAAA;AAEnC,EAAA,IAAI,cACJ,EAAA;AACI,IAAA,IAAA,CAAK,KAAK,CAAC,CAAA,EAAG,MAAO,CAAI,GAAA,CAAA,GAAK,IAAI,CAAE,CAAA,CAAA,CAAA;AAEpC,IAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,IAAA,CAAK,QAAQ,CACjC,EAAA,EAAA;AACI,MAAA,UAAA,CAAW,IAAK,CAAA,CAAC,CAAC,CAAA,CAAE,QAAW,GAAA,CAAA,CAAA;AAE/B,MAAA,EAAA,CAAG,kBAAmB,CAAA,OAAA,EAAS,CAAG,EAAA,IAAA,CAAK,CAAC,CAAC,CAAA,CAAA;AAAA,KAC7C;AAEA,IAAA,EAAA,CAAG,YAAY,OAAO,CAAA,CAAA;AAAA,GAG1B,MAAA;AACI,IAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,IAAA,CAAK,QAAQ,CACjC,EAAA,EAAA;AACI,MAAW,UAAA,CAAA,IAAA,CAAK,CAAC,CAAC,CAAE,CAAA,QAAA,GAAW,GAAG,iBAAkB,CAAA,OAAA,EAAS,IAAK,CAAA,CAAC,CAAC,CAAA,CAAA;AAAA,KACxE;AAAA,GACJ;AAEA,EAAO,OAAA,UAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,10 @@
import { GlProgramData } from '../GlProgramData';
import type { GlRenderingContext } from '../../context/GlRenderingContext';
import type { GlProgram } from '../GlProgram';
/**
* generates a WebGL Program object from a high level Pixi Program.
* @param gl - a rendering context on which to generate the program
* @param program - the high level Pixi Program.
* @private
*/
export declare function generateProgram(gl: GlRenderingContext, program: GlProgram): GlProgramData;

View File

@@ -0,0 +1,57 @@
'use strict';
var warn = require('../../../../../utils/logging/warn.js');
var GlProgramData = require('../GlProgramData.js');
var compileShader = require('./compileShader.js');
var defaultValue = require('./defaultValue.js');
var extractAttributesFromGlProgram = require('./extractAttributesFromGlProgram.js');
var getUboData = require('./getUboData.js');
var getUniformData = require('./getUniformData.js');
var logProgramError = require('./logProgramError.js');
"use strict";
function generateProgram(gl, program) {
const glVertShader = compileShader.compileShader(gl, gl.VERTEX_SHADER, program.vertex);
const glFragShader = compileShader.compileShader(gl, gl.FRAGMENT_SHADER, program.fragment);
const webGLProgram = gl.createProgram();
gl.attachShader(webGLProgram, glVertShader);
gl.attachShader(webGLProgram, glFragShader);
const transformFeedbackVaryings = program.transformFeedbackVaryings;
if (transformFeedbackVaryings) {
if (typeof gl.transformFeedbackVaryings !== "function") {
warn.warn(`TransformFeedback is not supported but TransformFeedbackVaryings are given.`);
} else {
gl.transformFeedbackVaryings(
webGLProgram,
transformFeedbackVaryings.names,
transformFeedbackVaryings.bufferMode === "separate" ? gl.SEPARATE_ATTRIBS : gl.INTERLEAVED_ATTRIBS
);
}
}
gl.linkProgram(webGLProgram);
if (!gl.getProgramParameter(webGLProgram, gl.LINK_STATUS)) {
logProgramError.logProgramError(gl, webGLProgram, glVertShader, glFragShader);
}
program._attributeData = extractAttributesFromGlProgram.extractAttributesFromGlProgram(
webGLProgram,
gl,
!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(program.vertex)
);
program._uniformData = getUniformData.getUniformData(webGLProgram, gl);
program._uniformBlockData = getUboData.getUboData(webGLProgram, gl);
gl.deleteShader(glVertShader);
gl.deleteShader(glFragShader);
const uniformData = {};
for (const i in program._uniformData) {
const data = program._uniformData[i];
uniformData[i] = {
location: gl.getUniformLocation(webGLProgram, i),
value: defaultValue.defaultValue(data.type, data.size)
};
}
const glProgram = new GlProgramData.GlProgramData(webGLProgram, uniformData);
return glProgram;
}
exports.generateProgram = generateProgram;
//# sourceMappingURL=generateProgram.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,55 @@
import { warn } from '../../../../../utils/logging/warn.mjs';
import { GlProgramData } from '../GlProgramData.mjs';
import { compileShader } from './compileShader.mjs';
import { defaultValue } from './defaultValue.mjs';
import { extractAttributesFromGlProgram } from './extractAttributesFromGlProgram.mjs';
import { getUboData } from './getUboData.mjs';
import { getUniformData } from './getUniformData.mjs';
import { logProgramError } from './logProgramError.mjs';
"use strict";
function generateProgram(gl, program) {
const glVertShader = compileShader(gl, gl.VERTEX_SHADER, program.vertex);
const glFragShader = compileShader(gl, gl.FRAGMENT_SHADER, program.fragment);
const webGLProgram = gl.createProgram();
gl.attachShader(webGLProgram, glVertShader);
gl.attachShader(webGLProgram, glFragShader);
const transformFeedbackVaryings = program.transformFeedbackVaryings;
if (transformFeedbackVaryings) {
if (typeof gl.transformFeedbackVaryings !== "function") {
warn(`TransformFeedback is not supported but TransformFeedbackVaryings are given.`);
} else {
gl.transformFeedbackVaryings(
webGLProgram,
transformFeedbackVaryings.names,
transformFeedbackVaryings.bufferMode === "separate" ? gl.SEPARATE_ATTRIBS : gl.INTERLEAVED_ATTRIBS
);
}
}
gl.linkProgram(webGLProgram);
if (!gl.getProgramParameter(webGLProgram, gl.LINK_STATUS)) {
logProgramError(gl, webGLProgram, glVertShader, glFragShader);
}
program._attributeData = extractAttributesFromGlProgram(
webGLProgram,
gl,
!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(program.vertex)
);
program._uniformData = getUniformData(webGLProgram, gl);
program._uniformBlockData = getUboData(webGLProgram, gl);
gl.deleteShader(glVertShader);
gl.deleteShader(glFragShader);
const uniformData = {};
for (const i in program._uniformData) {
const data = program._uniformData[i];
uniformData[i] = {
location: gl.getUniformLocation(webGLProgram, i),
value: defaultValue(data.type, data.size)
};
}
const glProgram = new GlProgramData(webGLProgram, uniformData);
return glProgram;
}
export { generateProgram };
//# sourceMappingURL=generateProgram.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
import type { PRECISION } from '../const';
export declare function getMaxFragmentPrecision(): PRECISION;

View File

@@ -0,0 +1,22 @@
'use strict';
var getTestContext = require('./getTestContext.js');
"use strict";
let maxFragmentPrecision;
function getMaxFragmentPrecision() {
if (!maxFragmentPrecision) {
maxFragmentPrecision = "mediump";
const gl = getTestContext.getTestContext();
if (gl) {
if (gl.getShaderPrecisionFormat) {
const shaderFragment = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT);
maxFragmentPrecision = shaderFragment.precision ? "highp" : "mediump";
}
}
}
return maxFragmentPrecision;
}
exports.getMaxFragmentPrecision = getMaxFragmentPrecision;
//# sourceMappingURL=getMaxFragmentPrecision.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getMaxFragmentPrecision.js","sources":["../../../../../../src/rendering/renderers/gl/shader/program/getMaxFragmentPrecision.ts"],"sourcesContent":["import { getTestContext } from './getTestContext';\n\nimport type { PRECISION } from '../const';\n\nlet maxFragmentPrecision: PRECISION;\n\nexport function getMaxFragmentPrecision(): PRECISION\n{\n if (!maxFragmentPrecision)\n {\n maxFragmentPrecision = 'mediump';\n const gl = getTestContext();\n\n if (gl)\n {\n if (gl.getShaderPrecisionFormat)\n {\n const shaderFragment = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT);\n\n maxFragmentPrecision = shaderFragment.precision ? 'highp' : 'mediump';\n }\n }\n }\n\n return maxFragmentPrecision;\n}\n"],"names":["getTestContext"],"mappings":";;;;;AAIA,IAAI,oBAAA,CAAA;AAEG,SAAS,uBAChB,GAAA;AACI,EAAA,IAAI,CAAC,oBACL,EAAA;AACI,IAAuB,oBAAA,GAAA,SAAA,CAAA;AACvB,IAAA,MAAM,KAAKA,6BAAe,EAAA,CAAA;AAE1B,IAAA,IAAI,EACJ,EAAA;AACI,MAAA,IAAI,GAAG,wBACP,EAAA;AACI,QAAA,MAAM,iBAAiB,EAAG,CAAA,wBAAA,CAAyB,EAAG,CAAA,eAAA,EAAiB,GAAG,UAAU,CAAA,CAAA;AAEpF,QAAuB,oBAAA,GAAA,cAAA,CAAe,YAAY,OAAU,GAAA,SAAA,CAAA;AAAA,OAChE;AAAA,KACJ;AAAA,GACJ;AAEA,EAAO,OAAA,oBAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,20 @@
import { getTestContext } from './getTestContext.mjs';
"use strict";
let maxFragmentPrecision;
function getMaxFragmentPrecision() {
if (!maxFragmentPrecision) {
maxFragmentPrecision = "mediump";
const gl = getTestContext();
if (gl) {
if (gl.getShaderPrecisionFormat) {
const shaderFragment = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT);
maxFragmentPrecision = shaderFragment.precision ? "highp" : "mediump";
}
}
}
return maxFragmentPrecision;
}
export { getMaxFragmentPrecision };
//# sourceMappingURL=getMaxFragmentPrecision.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getMaxFragmentPrecision.mjs","sources":["../../../../../../src/rendering/renderers/gl/shader/program/getMaxFragmentPrecision.ts"],"sourcesContent":["import { getTestContext } from './getTestContext';\n\nimport type { PRECISION } from '../const';\n\nlet maxFragmentPrecision: PRECISION;\n\nexport function getMaxFragmentPrecision(): PRECISION\n{\n if (!maxFragmentPrecision)\n {\n maxFragmentPrecision = 'mediump';\n const gl = getTestContext();\n\n if (gl)\n {\n if (gl.getShaderPrecisionFormat)\n {\n const shaderFragment = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT);\n\n maxFragmentPrecision = shaderFragment.precision ? 'highp' : 'mediump';\n }\n }\n }\n\n return maxFragmentPrecision;\n}\n"],"names":[],"mappings":";;;AAIA,IAAI,oBAAA,CAAA;AAEG,SAAS,uBAChB,GAAA;AACI,EAAA,IAAI,CAAC,oBACL,EAAA;AACI,IAAuB,oBAAA,GAAA,SAAA,CAAA;AACvB,IAAA,MAAM,KAAK,cAAe,EAAA,CAAA;AAE1B,IAAA,IAAI,EACJ,EAAA;AACI,MAAA,IAAI,GAAG,wBACP,EAAA;AACI,QAAA,MAAM,iBAAiB,EAAG,CAAA,wBAAA,CAAyB,EAAG,CAAA,eAAA,EAAiB,GAAG,UAAU,CAAA,CAAA;AAEpF,QAAuB,oBAAA,GAAA,cAAA,CAAe,YAAY,OAAU,GAAA,SAAA,CAAA;AAAA,OAChE;AAAA,KACJ;AAAA,GACJ;AAEA,EAAO,OAAA,oBAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,8 @@
import type { GlRenderingContext } from '../../context/GlRenderingContext';
/**
* returns a little WebGL context to use for program inspection.
* @static
* @private
* @returns {WebGLRenderingContext} a gl context to test with
*/
export declare function getTestContext(): GlRenderingContext;

View File

@@ -0,0 +1,16 @@
'use strict';
var adapter = require('../../../../../environment/adapter.js');
"use strict";
let context;
function getTestContext() {
if (!context || context?.isContextLost()) {
const canvas = adapter.DOMAdapter.get().createCanvas();
context = canvas.getContext("webgl", {});
}
return context;
}
exports.getTestContext = getTestContext;
//# sourceMappingURL=getTestContext.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getTestContext.js","sources":["../../../../../../src/rendering/renderers/gl/shader/program/getTestContext.ts"],"sourcesContent":["import { DOMAdapter } from '../../../../../environment/adapter';\n\nimport type { GlRenderingContext } from '../../context/GlRenderingContext';\n\nlet context: GlRenderingContext;\n\n/**\n * returns a little WebGL context to use for program inspection.\n * @static\n * @private\n * @returns {WebGLRenderingContext} a gl context to test with\n */\nexport function getTestContext(): GlRenderingContext\n{\n if (!context || context?.isContextLost())\n {\n const canvas = DOMAdapter.get().createCanvas();\n\n context = canvas.getContext('webgl', {}) as GlRenderingContext;\n }\n\n return context;\n}\n"],"names":["DOMAdapter"],"mappings":";;;;;AAIA,IAAI,OAAA,CAAA;AAQG,SAAS,cAChB,GAAA;AACI,EAAA,IAAI,CAAC,OAAA,IAAW,OAAS,EAAA,aAAA,EACzB,EAAA;AACI,IAAA,MAAM,MAAS,GAAAA,kBAAA,CAAW,GAAI,EAAA,CAAE,YAAa,EAAA,CAAA;AAE7C,IAAA,OAAA,GAAU,MAAO,CAAA,UAAA,CAAW,OAAS,EAAA,EAAE,CAAA,CAAA;AAAA,GAC3C;AAEA,EAAO,OAAA,OAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,14 @@
import { DOMAdapter } from '../../../../../environment/adapter.mjs';
"use strict";
let context;
function getTestContext() {
if (!context || context?.isContextLost()) {
const canvas = DOMAdapter.get().createCanvas();
context = canvas.getContext("webgl", {});
}
return context;
}
export { getTestContext };
//# sourceMappingURL=getTestContext.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getTestContext.mjs","sources":["../../../../../../src/rendering/renderers/gl/shader/program/getTestContext.ts"],"sourcesContent":["import { DOMAdapter } from '../../../../../environment/adapter';\n\nimport type { GlRenderingContext } from '../../context/GlRenderingContext';\n\nlet context: GlRenderingContext;\n\n/**\n * returns a little WebGL context to use for program inspection.\n * @static\n * @private\n * @returns {WebGLRenderingContext} a gl context to test with\n */\nexport function getTestContext(): GlRenderingContext\n{\n if (!context || context?.isContextLost())\n {\n const canvas = DOMAdapter.get().createCanvas();\n\n context = canvas.getContext('webgl', {}) as GlRenderingContext;\n }\n\n return context;\n}\n"],"names":[],"mappings":";;;AAIA,IAAI,OAAA,CAAA;AAQG,SAAS,cAChB,GAAA;AACI,EAAA,IAAI,CAAC,OAAA,IAAW,OAAS,EAAA,aAAA,EACzB,EAAA;AACI,IAAA,MAAM,MAAS,GAAA,UAAA,CAAW,GAAI,EAAA,CAAE,YAAa,EAAA,CAAA;AAE7C,IAAA,OAAA,GAAU,MAAO,CAAA,UAAA,CAAW,OAAS,EAAA,EAAE,CAAA,CAAA;AAAA,GAC3C;AAEA,EAAO,OAAA,OAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,9 @@
import type { GlUniformBlockData } from '../GlProgram';
/**
* returns the uniform block data from the program
* @private
* @param program - the webgl program
* @param gl - the WebGL context
* @returns {object} the uniform data for this program
*/
export declare function getUboData(program: WebGLProgram, gl: WebGL2RenderingContext): Record<string, GlUniformBlockData>;

View File

@@ -0,0 +1,23 @@
'use strict';
"use strict";
function getUboData(program, gl) {
if (!gl.ACTIVE_UNIFORM_BLOCKS)
return {};
const uniformBlocks = {};
const totalUniformsBlocks = gl.getProgramParameter(program, gl.ACTIVE_UNIFORM_BLOCKS);
for (let i = 0; i < totalUniformsBlocks; i++) {
const name = gl.getActiveUniformBlockName(program, i);
const uniformBlockIndex = gl.getUniformBlockIndex(program, name);
const size = gl.getActiveUniformBlockParameter(program, i, gl.UNIFORM_BLOCK_DATA_SIZE);
uniformBlocks[name] = {
name,
index: uniformBlockIndex,
size
};
}
return uniformBlocks;
}
exports.getUboData = getUboData;
//# sourceMappingURL=getUboData.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getUboData.js","sources":["../../../../../../src/rendering/renderers/gl/shader/program/getUboData.ts"],"sourcesContent":["import type { GlUniformBlockData } from '../GlProgram';\n\n/**\n * returns the uniform block data from the program\n * @private\n * @param program - the webgl program\n * @param gl - the WebGL context\n * @returns {object} the uniform data for this program\n */\nexport function getUboData(program: WebGLProgram, gl: WebGL2RenderingContext): Record<string, GlUniformBlockData>\n{\n // if uniform buffer data is not supported, early out\n if (!gl.ACTIVE_UNIFORM_BLOCKS) return {};\n\n const uniformBlocks: Record<string, GlUniformBlockData> = {};\n\n // const totalUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);\n\n const totalUniformsBlocks = gl.getProgramParameter(program, gl.ACTIVE_UNIFORM_BLOCKS);\n\n for (let i = 0; i < totalUniformsBlocks; i++)\n {\n const name = gl.getActiveUniformBlockName(program, i);\n const uniformBlockIndex = gl.getUniformBlockIndex(program, name);\n\n const size = gl.getActiveUniformBlockParameter(program, i, gl.UNIFORM_BLOCK_DATA_SIZE);\n\n uniformBlocks[name] = {\n name,\n index: uniformBlockIndex,\n size,\n };\n }\n\n return uniformBlocks;\n}\n"],"names":[],"mappings":";;;AASgB,SAAA,UAAA,CAAW,SAAuB,EAClD,EAAA;AAEI,EAAA,IAAI,CAAC,EAAG,CAAA,qBAAA;AAAuB,IAAA,OAAO,EAAC,CAAA;AAEvC,EAAA,MAAM,gBAAoD,EAAC,CAAA;AAI3D,EAAA,MAAM,mBAAsB,GAAA,EAAA,CAAG,mBAAoB,CAAA,OAAA,EAAS,GAAG,qBAAqB,CAAA,CAAA;AAEpF,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,mBAAA,EAAqB,CACzC,EAAA,EAAA;AACI,IAAA,MAAM,IAAO,GAAA,EAAA,CAAG,yBAA0B,CAAA,OAAA,EAAS,CAAC,CAAA,CAAA;AACpD,IAAA,MAAM,iBAAoB,GAAA,EAAA,CAAG,oBAAqB,CAAA,OAAA,EAAS,IAAI,CAAA,CAAA;AAE/D,IAAA,MAAM,OAAO,EAAG,CAAA,8BAAA,CAA+B,OAAS,EAAA,CAAA,EAAG,GAAG,uBAAuB,CAAA,CAAA;AAErF,IAAA,aAAA,CAAc,IAAI,CAAI,GAAA;AAAA,MAClB,IAAA;AAAA,MACA,KAAO,EAAA,iBAAA;AAAA,MACP,IAAA;AAAA,KACJ,CAAA;AAAA,GACJ;AAEA,EAAO,OAAA,aAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,21 @@
"use strict";
function getUboData(program, gl) {
if (!gl.ACTIVE_UNIFORM_BLOCKS)
return {};
const uniformBlocks = {};
const totalUniformsBlocks = gl.getProgramParameter(program, gl.ACTIVE_UNIFORM_BLOCKS);
for (let i = 0; i < totalUniformsBlocks; i++) {
const name = gl.getActiveUniformBlockName(program, i);
const uniformBlockIndex = gl.getUniformBlockIndex(program, name);
const size = gl.getActiveUniformBlockParameter(program, i, gl.UNIFORM_BLOCK_DATA_SIZE);
uniformBlocks[name] = {
name,
index: uniformBlockIndex,
size
};
}
return uniformBlocks;
}
export { getUboData };
//# sourceMappingURL=getUboData.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getUboData.mjs","sources":["../../../../../../src/rendering/renderers/gl/shader/program/getUboData.ts"],"sourcesContent":["import type { GlUniformBlockData } from '../GlProgram';\n\n/**\n * returns the uniform block data from the program\n * @private\n * @param program - the webgl program\n * @param gl - the WebGL context\n * @returns {object} the uniform data for this program\n */\nexport function getUboData(program: WebGLProgram, gl: WebGL2RenderingContext): Record<string, GlUniformBlockData>\n{\n // if uniform buffer data is not supported, early out\n if (!gl.ACTIVE_UNIFORM_BLOCKS) return {};\n\n const uniformBlocks: Record<string, GlUniformBlockData> = {};\n\n // const totalUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);\n\n const totalUniformsBlocks = gl.getProgramParameter(program, gl.ACTIVE_UNIFORM_BLOCKS);\n\n for (let i = 0; i < totalUniformsBlocks; i++)\n {\n const name = gl.getActiveUniformBlockName(program, i);\n const uniformBlockIndex = gl.getUniformBlockIndex(program, name);\n\n const size = gl.getActiveUniformBlockParameter(program, i, gl.UNIFORM_BLOCK_DATA_SIZE);\n\n uniformBlocks[name] = {\n name,\n index: uniformBlockIndex,\n size,\n };\n }\n\n return uniformBlocks;\n}\n"],"names":[],"mappings":";AASgB,SAAA,UAAA,CAAW,SAAuB,EAClD,EAAA;AAEI,EAAA,IAAI,CAAC,EAAG,CAAA,qBAAA;AAAuB,IAAA,OAAO,EAAC,CAAA;AAEvC,EAAA,MAAM,gBAAoD,EAAC,CAAA;AAI3D,EAAA,MAAM,mBAAsB,GAAA,EAAA,CAAG,mBAAoB,CAAA,OAAA,EAAS,GAAG,qBAAqB,CAAA,CAAA;AAEpF,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,mBAAA,EAAqB,CACzC,EAAA,EAAA;AACI,IAAA,MAAM,IAAO,GAAA,EAAA,CAAG,yBAA0B,CAAA,OAAA,EAAS,CAAC,CAAA,CAAA;AACpD,IAAA,MAAM,iBAAoB,GAAA,EAAA,CAAG,oBAAqB,CAAA,OAAA,EAAS,IAAI,CAAA,CAAA;AAE/D,IAAA,MAAM,OAAO,EAAG,CAAA,8BAAA,CAA+B,OAAS,EAAA,CAAA,EAAG,GAAG,uBAAuB,CAAA,CAAA;AAErF,IAAA,aAAA,CAAc,IAAI,CAAI,GAAA;AAAA,MAClB,IAAA;AAAA,MACA,KAAO,EAAA,iBAAA;AAAA,MACP,IAAA;AAAA,KACJ,CAAA;AAAA,GACJ;AAEA,EAAO,OAAA,aAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,11 @@
import type { GlUniformData } from '../GlProgram';
/**
* returns the uniform data from the program
* @private
* @param program - the webgl program
* @param gl - the WebGL context
* @returns {object} the uniform data for this program
*/
export declare function getUniformData(program: WebGLProgram, gl: WebGLRenderingContextBase): {
[key: string]: GlUniformData;
};

View File

@@ -0,0 +1,28 @@
'use strict';
var defaultValue = require('./defaultValue.js');
var mapType = require('./mapType.js');
"use strict";
function getUniformData(program, gl) {
const uniforms = {};
const totalUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
for (let i = 0; i < totalUniforms; i++) {
const uniformData = gl.getActiveUniform(program, i);
const name = uniformData.name.replace(/\[.*?\]$/, "");
const isArray = !!uniformData.name.match(/\[.*?\]$/);
const type = mapType.mapType(gl, uniformData.type);
uniforms[name] = {
name,
index: i,
type,
size: uniformData.size,
isArray,
value: defaultValue.defaultValue(type, uniformData.size)
};
}
return uniforms;
}
exports.getUniformData = getUniformData;
//# sourceMappingURL=getUniformData.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getUniformData.js","sources":["../../../../../../src/rendering/renderers/gl/shader/program/getUniformData.ts"],"sourcesContent":["import { defaultValue } from './defaultValue';\nimport { mapType } from './mapType';\n\nimport type { GlUniformData } from '../GlProgram';\n\n/**\n * returns the uniform data from the program\n * @private\n * @param program - the webgl program\n * @param gl - the WebGL context\n * @returns {object} the uniform data for this program\n */\nexport function getUniformData(program: WebGLProgram, gl: WebGLRenderingContextBase): {[key: string]: GlUniformData}\n{\n const uniforms: {[key: string]: GlUniformData} = {};\n\n const totalUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);\n\n for (let i = 0; i < totalUniforms; i++)\n {\n const uniformData = gl.getActiveUniform(program, i);\n const name = uniformData.name.replace(/\\[.*?\\]$/, '');\n\n const isArray = !!(uniformData.name.match(/\\[.*?\\]$/));\n\n const type = mapType(gl, uniformData.type);\n\n uniforms[name] = {\n name,\n index: i,\n type,\n size: uniformData.size,\n isArray,\n value: defaultValue(type, uniformData.size),\n };\n }\n\n return uniforms;\n}\n"],"names":["mapType","defaultValue"],"mappings":";;;;;;AAYgB,SAAA,cAAA,CAAe,SAAuB,EACtD,EAAA;AACI,EAAA,MAAM,WAA2C,EAAC,CAAA;AAElD,EAAA,MAAM,aAAgB,GAAA,EAAA,CAAG,mBAAoB,CAAA,OAAA,EAAS,GAAG,eAAe,CAAA,CAAA;AAExE,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,aAAA,EAAe,CACnC,EAAA,EAAA;AACI,IAAA,MAAM,WAAc,GAAA,EAAA,CAAG,gBAAiB,CAAA,OAAA,EAAS,CAAC,CAAA,CAAA;AAClD,IAAA,MAAM,IAAO,GAAA,WAAA,CAAY,IAAK,CAAA,OAAA,CAAQ,YAAY,EAAE,CAAA,CAAA;AAEpD,IAAA,MAAM,UAAU,CAAC,CAAE,WAAY,CAAA,IAAA,CAAK,MAAM,UAAU,CAAA,CAAA;AAEpD,IAAA,MAAM,IAAO,GAAAA,eAAA,CAAQ,EAAI,EAAA,WAAA,CAAY,IAAI,CAAA,CAAA;AAEzC,IAAA,QAAA,CAAS,IAAI,CAAI,GAAA;AAAA,MACb,IAAA;AAAA,MACA,KAAO,EAAA,CAAA;AAAA,MACP,IAAA;AAAA,MACA,MAAM,WAAY,CAAA,IAAA;AAAA,MAClB,OAAA;AAAA,MACA,KAAO,EAAAC,yBAAA,CAAa,IAAM,EAAA,WAAA,CAAY,IAAI,CAAA;AAAA,KAC9C,CAAA;AAAA,GACJ;AAEA,EAAO,OAAA,QAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,26 @@
import { defaultValue } from './defaultValue.mjs';
import { mapType } from './mapType.mjs';
"use strict";
function getUniformData(program, gl) {
const uniforms = {};
const totalUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
for (let i = 0; i < totalUniforms; i++) {
const uniformData = gl.getActiveUniform(program, i);
const name = uniformData.name.replace(/\[.*?\]$/, "");
const isArray = !!uniformData.name.match(/\[.*?\]$/);
const type = mapType(gl, uniformData.type);
uniforms[name] = {
name,
index: i,
type,
size: uniformData.size,
isArray,
value: defaultValue(type, uniformData.size)
};
}
return uniforms;
}
export { getUniformData };
//# sourceMappingURL=getUniformData.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getUniformData.mjs","sources":["../../../../../../src/rendering/renderers/gl/shader/program/getUniformData.ts"],"sourcesContent":["import { defaultValue } from './defaultValue';\nimport { mapType } from './mapType';\n\nimport type { GlUniformData } from '../GlProgram';\n\n/**\n * returns the uniform data from the program\n * @private\n * @param program - the webgl program\n * @param gl - the WebGL context\n * @returns {object} the uniform data for this program\n */\nexport function getUniformData(program: WebGLProgram, gl: WebGLRenderingContextBase): {[key: string]: GlUniformData}\n{\n const uniforms: {[key: string]: GlUniformData} = {};\n\n const totalUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);\n\n for (let i = 0; i < totalUniforms; i++)\n {\n const uniformData = gl.getActiveUniform(program, i);\n const name = uniformData.name.replace(/\\[.*?\\]$/, '');\n\n const isArray = !!(uniformData.name.match(/\\[.*?\\]$/));\n\n const type = mapType(gl, uniformData.type);\n\n uniforms[name] = {\n name,\n index: i,\n type,\n size: uniformData.size,\n isArray,\n value: defaultValue(type, uniformData.size),\n };\n }\n\n return uniforms;\n}\n"],"names":[],"mappings":";;;;AAYgB,SAAA,cAAA,CAAe,SAAuB,EACtD,EAAA;AACI,EAAA,MAAM,WAA2C,EAAC,CAAA;AAElD,EAAA,MAAM,aAAgB,GAAA,EAAA,CAAG,mBAAoB,CAAA,OAAA,EAAS,GAAG,eAAe,CAAA,CAAA;AAExE,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,aAAA,EAAe,CACnC,EAAA,EAAA;AACI,IAAA,MAAM,WAAc,GAAA,EAAA,CAAG,gBAAiB,CAAA,OAAA,EAAS,CAAC,CAAA,CAAA;AAClD,IAAA,MAAM,IAAO,GAAA,WAAA,CAAY,IAAK,CAAA,OAAA,CAAQ,YAAY,EAAE,CAAA,CAAA;AAEpD,IAAA,MAAM,UAAU,CAAC,CAAE,WAAY,CAAA,IAAA,CAAK,MAAM,UAAU,CAAA,CAAA;AAEpD,IAAA,MAAM,IAAO,GAAA,OAAA,CAAQ,EAAI,EAAA,WAAA,CAAY,IAAI,CAAA,CAAA;AAEzC,IAAA,QAAA,CAAS,IAAI,CAAI,GAAA;AAAA,MACb,IAAA;AAAA,MACA,KAAO,EAAA,CAAA;AAAA,MACP,IAAA;AAAA,MACA,MAAM,WAAY,CAAA,IAAA;AAAA,MAClB,OAAA;AAAA,MACA,KAAO,EAAA,YAAA,CAAa,IAAM,EAAA,WAAA,CAAY,IAAI,CAAA;AAAA,KAC9C,CAAA;AAAA,GACJ;AAEA,EAAO,OAAA,QAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,10 @@
/**
*
* logs out any program errors
* @param gl - The current WebGL context
* @param program - the WebGL program to display errors for
* @param vertexShader - the fragment WebGL shader program
* @param fragmentShader - the vertex WebGL shader program
* @private
*/
export declare function logProgramError(gl: WebGLRenderingContext, program: WebGLProgram, vertexShader: WebGLShader, fragmentShader: WebGLShader): void;

View File

@@ -0,0 +1,44 @@
'use strict';
"use strict";
function logPrettyShaderError(gl, shader) {
const shaderSrc = gl.getShaderSource(shader).split("\n").map((line, index) => `${index}: ${line}`);
const shaderLog = gl.getShaderInfoLog(shader);
const splitShader = shaderLog.split("\n");
const dedupe = {};
const lineNumbers = splitShader.map((line) => parseFloat(line.replace(/^ERROR\: 0\:([\d]+)\:.*$/, "$1"))).filter((n) => {
if (n && !dedupe[n]) {
dedupe[n] = true;
return true;
}
return false;
});
const logArgs = [""];
lineNumbers.forEach((number) => {
shaderSrc[number - 1] = `%c${shaderSrc[number - 1]}%c`;
logArgs.push("background: #FF0000; color:#FFFFFF; font-size: 10px", "font-size: 10px");
});
const fragmentSourceToLog = shaderSrc.join("\n");
logArgs[0] = fragmentSourceToLog;
console.error(shaderLog);
console.groupCollapsed("click to view full shader code");
console.warn(...logArgs);
console.groupEnd();
}
function logProgramError(gl, program, vertexShader, fragmentShader) {
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
logPrettyShaderError(gl, vertexShader);
}
if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {
logPrettyShaderError(gl, fragmentShader);
}
console.error("PixiJS Error: Could not initialize shader.");
if (gl.getProgramInfoLog(program) !== "") {
console.warn("PixiJS Warning: gl.getProgramInfoLog()", gl.getProgramInfoLog(program));
}
}
}
exports.logProgramError = logProgramError;
//# sourceMappingURL=logProgramError.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"logProgramError.js","sources":["../../../../../../src/rendering/renderers/gl/shader/program/logProgramError.ts"],"sourcesContent":["/**\n * will log a shader error highlighting the lines with the error\n * also will add numbers along the side.\n * @param gl - the WebGLContext\n * @param shader - the shader to log errors for\n */\nfunction logPrettyShaderError(gl: WebGLRenderingContext, shader: WebGLShader): void\n{\n const shaderSrc = gl.getShaderSource(shader)\n .split('\\n')\n .map((line, index) => `${index}: ${line}`);\n\n const shaderLog = gl.getShaderInfoLog(shader);\n const splitShader = shaderLog.split('\\n');\n\n const dedupe: Record<number, boolean> = {};\n\n const lineNumbers = splitShader.map((line) => parseFloat(line.replace(/^ERROR\\: 0\\:([\\d]+)\\:.*$/, '$1')))\n .filter((n) =>\n {\n if (n && !dedupe[n])\n {\n dedupe[n] = true;\n\n return true;\n }\n\n return false;\n });\n\n const logArgs = [''];\n\n lineNumbers.forEach((number) =>\n {\n shaderSrc[number - 1] = `%c${shaderSrc[number - 1]}%c`;\n logArgs.push('background: #FF0000; color:#FFFFFF; font-size: 10px', 'font-size: 10px');\n });\n\n const fragmentSourceToLog = shaderSrc\n .join('\\n');\n\n logArgs[0] = fragmentSourceToLog;\n\n console.error(shaderLog);\n\n // eslint-disable-next-line no-console\n console.groupCollapsed('click to view full shader code');\n console.warn(...logArgs);\n // eslint-disable-next-line no-console\n console.groupEnd();\n}\n\n/**\n *\n * logs out any program errors\n * @param gl - The current WebGL context\n * @param program - the WebGL program to display errors for\n * @param vertexShader - the fragment WebGL shader program\n * @param fragmentShader - the vertex WebGL shader program\n * @private\n */\nexport function logProgramError(\n gl: WebGLRenderingContext,\n program: WebGLProgram,\n vertexShader: WebGLShader,\n fragmentShader: WebGLShader\n): void\n{\n // if linking fails, then log and cleanup\n if (!gl.getProgramParameter(program, gl.LINK_STATUS))\n {\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS))\n {\n logPrettyShaderError(gl, vertexShader);\n }\n\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS))\n {\n logPrettyShaderError(gl, fragmentShader);\n }\n\n console.error('PixiJS Error: Could not initialize shader.');\n\n // if there is a program info log, log it\n if (gl.getProgramInfoLog(program) !== '')\n {\n console.warn('PixiJS Warning: gl.getProgramInfoLog()', gl.getProgramInfoLog(program));\n }\n }\n}\n"],"names":[],"mappings":";;;AAMA,SAAS,oBAAA,CAAqB,IAA2B,MACzD,EAAA;AACI,EAAA,MAAM,YAAY,EAAG,CAAA,eAAA,CAAgB,MAAM,CAAA,CACtC,MAAM,IAAI,CAAA,CACV,GAAI,CAAA,CAAC,MAAM,KAAU,KAAA,CAAA,EAAG,KAAK,CAAA,EAAA,EAAK,IAAI,CAAE,CAAA,CAAA,CAAA;AAE7C,EAAM,MAAA,SAAA,GAAY,EAAG,CAAA,gBAAA,CAAiB,MAAM,CAAA,CAAA;AAC5C,EAAM,MAAA,WAAA,GAAc,SAAU,CAAA,KAAA,CAAM,IAAI,CAAA,CAAA;AAExC,EAAA,MAAM,SAAkC,EAAC,CAAA;AAEzC,EAAA,MAAM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A,kBAAA,CAAmB,YAAc,EAAA,EAAA,CAAG,cAAc,CAC1D,EAAA;AACI,MAAA,oBAAA,CAAqB,IAAI,YAAY,CAAA,CAAA;AAAA,KACzC;AAEA,IAAA,IAAI,CAAC,EAAG,CAAA,kBAAA,CAAmB,cAAgB,EAAA,EAAA,CAAG,cAAc,CAC5D,EAAA;AACI,MAAA,oBAAA,CAAqB,IAAI,cAAc,CAAA,CAAA;AAAA,KAC3C;AAEA,IAAA,OAAA,CAAQ,MAAM,4CAA4C,CAAA,CAAA;AAG1D,IAAA,IAAI,EAAG,CAAA,iBAAA,CAAkB,OAAO,CAAA,KAAM,EACtC,EAAA;AACI,MAAA,OAAA,CAAQ,IAAK,CAAA,wCAAA,EAA0C,EAAG,CAAA,iBAAA,CAAkB,OAAO,CAAC,CAAA,CAAA;AAAA,KACxF;AAAA,GACJ;AACJ;;;;"}

View File

@@ -0,0 +1,42 @@
"use strict";
function logPrettyShaderError(gl, shader) {
const shaderSrc = gl.getShaderSource(shader).split("\n").map((line, index) => `${index}: ${line}`);
const shaderLog = gl.getShaderInfoLog(shader);
const splitShader = shaderLog.split("\n");
const dedupe = {};
const lineNumbers = splitShader.map((line) => parseFloat(line.replace(/^ERROR\: 0\:([\d]+)\:.*$/, "$1"))).filter((n) => {
if (n && !dedupe[n]) {
dedupe[n] = true;
return true;
}
return false;
});
const logArgs = [""];
lineNumbers.forEach((number) => {
shaderSrc[number - 1] = `%c${shaderSrc[number - 1]}%c`;
logArgs.push("background: #FF0000; color:#FFFFFF; font-size: 10px", "font-size: 10px");
});
const fragmentSourceToLog = shaderSrc.join("\n");
logArgs[0] = fragmentSourceToLog;
console.error(shaderLog);
console.groupCollapsed("click to view full shader code");
console.warn(...logArgs);
console.groupEnd();
}
function logProgramError(gl, program, vertexShader, fragmentShader) {
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
logPrettyShaderError(gl, vertexShader);
}
if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {
logPrettyShaderError(gl, fragmentShader);
}
console.error("PixiJS Error: Could not initialize shader.");
if (gl.getProgramInfoLog(program) !== "") {
console.warn("PixiJS Warning: gl.getProgramInfoLog()", gl.getProgramInfoLog(program));
}
}
}
export { logProgramError };
//# sourceMappingURL=logProgramError.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"logProgramError.mjs","sources":["../../../../../../src/rendering/renderers/gl/shader/program/logProgramError.ts"],"sourcesContent":["/**\n * will log a shader error highlighting the lines with the error\n * also will add numbers along the side.\n * @param gl - the WebGLContext\n * @param shader - the shader to log errors for\n */\nfunction logPrettyShaderError(gl: WebGLRenderingContext, shader: WebGLShader): void\n{\n const shaderSrc = gl.getShaderSource(shader)\n .split('\\n')\n .map((line, index) => `${index}: ${line}`);\n\n const shaderLog = gl.getShaderInfoLog(shader);\n const splitShader = shaderLog.split('\\n');\n\n const dedupe: Record<number, boolean> = {};\n\n const lineNumbers = splitShader.map((line) => parseFloat(line.replace(/^ERROR\\: 0\\:([\\d]+)\\:.*$/, '$1')))\n .filter((n) =>\n {\n if (n && !dedupe[n])\n {\n dedupe[n] = true;\n\n return true;\n }\n\n return false;\n });\n\n const logArgs = [''];\n\n lineNumbers.forEach((number) =>\n {\n shaderSrc[number - 1] = `%c${shaderSrc[number - 1]}%c`;\n logArgs.push('background: #FF0000; color:#FFFFFF; font-size: 10px', 'font-size: 10px');\n });\n\n const fragmentSourceToLog = shaderSrc\n .join('\\n');\n\n logArgs[0] = fragmentSourceToLog;\n\n console.error(shaderLog);\n\n // eslint-disable-next-line no-console\n console.groupCollapsed('click to view full shader code');\n console.warn(...logArgs);\n // eslint-disable-next-line no-console\n console.groupEnd();\n}\n\n/**\n *\n * logs out any program errors\n * @param gl - The current WebGL context\n * @param program - the WebGL program to display errors for\n * @param vertexShader - the fragment WebGL shader program\n * @param fragmentShader - the vertex WebGL shader program\n * @private\n */\nexport function logProgramError(\n gl: WebGLRenderingContext,\n program: WebGLProgram,\n vertexShader: WebGLShader,\n fragmentShader: WebGLShader\n): void\n{\n // if linking fails, then log and cleanup\n if (!gl.getProgramParameter(program, gl.LINK_STATUS))\n {\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS))\n {\n logPrettyShaderError(gl, vertexShader);\n }\n\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS))\n {\n logPrettyShaderError(gl, fragmentShader);\n }\n\n console.error('PixiJS Error: Could not initialize shader.');\n\n // if there is a program info log, log it\n if (gl.getProgramInfoLog(program) !== '')\n {\n console.warn('PixiJS Warning: gl.getProgramInfoLog()', gl.getProgramInfoLog(program));\n }\n }\n}\n"],"names":[],"mappings":";AAMA,SAAS,oBAAA,CAAqB,IAA2B,MACzD,EAAA;AACI,EAAA,MAAM,YAAY,EAAG,CAAA,eAAA,CAAgB,MAAM,CAAA,CACtC,MAAM,IAAI,CAAA,CACV,GAAI,CAAA,CAAC,MAAM,KAAU,KAAA,CAAA,EAAG,KAAK,CAAA,EAAA,EAAK,IAAI,CAAE,CAAA,CAAA,CAAA;AAE7C,EAAM,MAAA,SAAA,GAAY,EAAG,CAAA,gBAAA,CAAiB,MAAM,CAAA,CAAA;AAC5C,EAAM,MAAA,WAAA,GAAc,SAAU,CAAA,KAAA,CAAM,IAAI,CAAA,CAAA;AAExC,EAAA,MAAM,SAAkC,EAAC,CAAA;AAEzC,EAAA,MAAM,WAAc,GAAA,WAAA,CAAY,GAAI,CAAA,CAAC,SAAS,UAAW,CAAA,IAAA,CAAK,OAAQ,CAAA,0BAAA,EAA4B,IAAI,CAAC,CAAC,CACnG,CAAA,MAAA,CAAO,CAAC,CACT,KAAA;AACI,IAAA,IAAI,CAAK,IAAA,CAAC,MAAO,CAAA,CAAC,CAClB,EAAA;AACI,MAAA,MAAA,CAAO,CAAC,CAAI,GAAA,IAAA,CAAA;AAEZ,MAAO,OAAA,IAAA,CAAA;AAAA,KACX;AAEA,IAAO,OAAA,KAAA,C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AAI,EAAG,CAAA,iBAAA,CAAkB,OAAO,CAAA,KAAM,EACtC,EAAA;AACI,MAAA,OAAA,CAAQ,IAAK,CAAA,wCAAA,EAA0C,EAAG,CAAA,iBAAA,CAAkB,OAAO,CAAC,CAAA,CAAA;AAAA,KACxF;AAAA,GACJ;AACJ;;;;"}

View File

@@ -0,0 +1,6 @@
/**
* @private
* @method mapSize
* @param {string} type
*/
export declare function mapSize(type: string): number;

View File

@@ -0,0 +1,31 @@
'use strict';
"use strict";
const GLSL_TO_SIZE = {
float: 1,
vec2: 2,
vec3: 3,
vec4: 4,
int: 1,
ivec2: 2,
ivec3: 3,
ivec4: 4,
uint: 1,
uvec2: 2,
uvec3: 3,
uvec4: 4,
bool: 1,
bvec2: 2,
bvec3: 3,
bvec4: 4,
mat2: 4,
mat3: 9,
mat4: 16,
sampler2D: 1
};
function mapSize(type) {
return GLSL_TO_SIZE[type];
}
exports.mapSize = mapSize;
//# sourceMappingURL=mapSize.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"mapSize.js","sources":["../../../../../../src/rendering/renderers/gl/shader/program/mapSize.ts"],"sourcesContent":["import type { Dict } from '../../../../../utils/types';\n\nconst GLSL_TO_SIZE: Dict<number> = {\n float: 1,\n vec2: 2,\n vec3: 3,\n vec4: 4,\n\n int: 1,\n ivec2: 2,\n ivec3: 3,\n ivec4: 4,\n\n uint: 1,\n uvec2: 2,\n uvec3: 3,\n uvec4: 4,\n\n bool: 1,\n bvec2: 2,\n bvec3: 3,\n bvec4: 4,\n\n mat2: 4,\n mat3: 9,\n mat4: 16,\n\n sampler2D: 1,\n};\n\n/**\n * @private\n * @method mapSize\n * @param {string} type\n */\nexport function mapSize(type: string): number\n{\n return GLSL_TO_SIZE[type];\n}\n"],"names":[],"mappings":";;;AAEA,MAAM,YAA6B,GAAA;AAAA,EAC/B,KAAU,EAAA,CAAA;AAAA,EACV,IAAU,EAAA,CAAA;AAAA,EACV,IAAU,EAAA,CAAA;AAAA,EACV,IAAU,EAAA,CAAA;AAAA,EAEV,GAAU,EAAA,CAAA;AAAA,EACV,KAAU,EAAA,CAAA;AAAA,EACV,KAAU,EAAA,CAAA;AAAA,EACV,KAAU,EAAA,CAAA;AAAA,EAEV,IAAU,EAAA,CAAA;AAAA,EACV,KAAU,EAAA,CAAA;AAAA,EACV,KAAU,EAAA,CAAA;AAAA,EACV,KAAU,EAAA,CAAA;AAAA,EAEV,IAAU,EAAA,CAAA;AAAA,EACV,KAAU,EAAA,CAAA;AAAA,EACV,KAAU,EAAA,CAAA;AAAA,EACV,KAAU,EAAA,CAAA;AAAA,EAEV,IAAU,EAAA,CAAA;AAAA,EACV,IAAU,EAAA,CAAA;AAAA,EACV,IAAU,EAAA,EAAA;AAAA,EAEV,SAAY,EAAA,CAAA;AAChB,CAAA,CAAA;AAOO,SAAS,QAAQ,IACxB,EAAA;AACI,EAAA,OAAO,aAAa,IAAI,CAAA,CAAA;AAC5B;;;;"}

View File

@@ -0,0 +1,29 @@
"use strict";
const GLSL_TO_SIZE = {
float: 1,
vec2: 2,
vec3: 3,
vec4: 4,
int: 1,
ivec2: 2,
ivec3: 3,
ivec4: 4,
uint: 1,
uvec2: 2,
uvec3: 3,
uvec4: 4,
bool: 1,
bvec2: 2,
bvec3: 3,
bvec4: 4,
mat2: 4,
mat3: 9,
mat4: 16,
sampler2D: 1
};
function mapSize(type) {
return GLSL_TO_SIZE[type];
}
export { mapSize };
//# sourceMappingURL=mapSize.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"mapSize.mjs","sources":["../../../../../../src/rendering/renderers/gl/shader/program/mapSize.ts"],"sourcesContent":["import type { Dict } from '../../../../../utils/types';\n\nconst GLSL_TO_SIZE: Dict<number> = {\n float: 1,\n vec2: 2,\n vec3: 3,\n vec4: 4,\n\n int: 1,\n ivec2: 2,\n ivec3: 3,\n ivec4: 4,\n\n uint: 1,\n uvec2: 2,\n uvec3: 3,\n uvec4: 4,\n\n bool: 1,\n bvec2: 2,\n bvec3: 3,\n bvec4: 4,\n\n mat2: 4,\n mat3: 9,\n mat4: 16,\n\n sampler2D: 1,\n};\n\n/**\n * @private\n * @method mapSize\n * @param {string} type\n */\nexport function mapSize(type: string): number\n{\n return GLSL_TO_SIZE[type];\n}\n"],"names":[],"mappings":";AAEA,MAAM,YAA6B,GAAA;AAAA,EAC/B,KAAU,EAAA,CAAA;AAAA,EACV,IAAU,EAAA,CAAA;AAAA,EACV,IAAU,EAAA,CAAA;AAAA,EACV,IAAU,EAAA,CAAA;AAAA,EAEV,GAAU,EAAA,CAAA;AAAA,EACV,KAAU,EAAA,CAAA;AAAA,EACV,KAAU,EAAA,CAAA;AAAA,EACV,KAAU,EAAA,CAAA;AAAA,EAEV,IAAU,EAAA,CAAA;AAAA,EACV,KAAU,EAAA,CAAA;AAAA,EACV,KAAU,EAAA,CAAA;AAAA,EACV,KAAU,EAAA,CAAA;AAAA,EAEV,IAAU,EAAA,CAAA;AAAA,EACV,KAAU,EAAA,CAAA;AAAA,EACV,KAAU,EAAA,CAAA;AAAA,EACV,KAAU,EAAA,CAAA;AAAA,EAEV,IAAU,EAAA,CAAA;AAAA,EACV,IAAU,EAAA,CAAA;AAAA,EACV,IAAU,EAAA,EAAA;AAAA,EAEV,SAAY,EAAA,CAAA;AAChB,CAAA,CAAA;AAOO,SAAS,QAAQ,IACxB,EAAA;AACI,EAAA,OAAO,aAAa,IAAI,CAAA,CAAA;AAC5B;;;;"}

View File

@@ -0,0 +1,3 @@
import type { VertexFormat } from '../../../shared/geometry/const';
export declare function mapType(gl: any, type: number): string;
export declare function mapGlToVertexFormat(gl: any, type: number): VertexFormat;

View File

@@ -0,0 +1,71 @@
'use strict';
"use strict";
let GL_TABLE = null;
const GL_TO_GLSL_TYPES = {
FLOAT: "float",
FLOAT_VEC2: "vec2",
FLOAT_VEC3: "vec3",
FLOAT_VEC4: "vec4",
INT: "int",
INT_VEC2: "ivec2",
INT_VEC3: "ivec3",
INT_VEC4: "ivec4",
UNSIGNED_INT: "uint",
UNSIGNED_INT_VEC2: "uvec2",
UNSIGNED_INT_VEC3: "uvec3",
UNSIGNED_INT_VEC4: "uvec4",
BOOL: "bool",
BOOL_VEC2: "bvec2",
BOOL_VEC3: "bvec3",
BOOL_VEC4: "bvec4",
FLOAT_MAT2: "mat2",
FLOAT_MAT3: "mat3",
FLOAT_MAT4: "mat4",
SAMPLER_2D: "sampler2D",
INT_SAMPLER_2D: "sampler2D",
UNSIGNED_INT_SAMPLER_2D: "sampler2D",
SAMPLER_CUBE: "samplerCube",
INT_SAMPLER_CUBE: "samplerCube",
UNSIGNED_INT_SAMPLER_CUBE: "samplerCube",
SAMPLER_2D_ARRAY: "sampler2DArray",
INT_SAMPLER_2D_ARRAY: "sampler2DArray",
UNSIGNED_INT_SAMPLER_2D_ARRAY: "sampler2DArray"
};
const GLSL_TO_VERTEX_TYPES = {
float: "float32",
vec2: "float32x2",
vec3: "float32x3",
vec4: "float32x4",
int: "sint32",
ivec2: "sint32x2",
ivec3: "sint32x3",
ivec4: "sint32x4",
uint: "uint32",
uvec2: "uint32x2",
uvec3: "uint32x3",
uvec4: "uint32x4",
bool: "uint32",
bvec2: "uint32x2",
bvec3: "uint32x3",
bvec4: "uint32x4"
};
function mapType(gl, type) {
if (!GL_TABLE) {
const typeNames = Object.keys(GL_TO_GLSL_TYPES);
GL_TABLE = {};
for (let i = 0; i < typeNames.length; ++i) {
const tn = typeNames[i];
GL_TABLE[gl[tn]] = GL_TO_GLSL_TYPES[tn];
}
}
return GL_TABLE[type];
}
function mapGlToVertexFormat(gl, type) {
const typeValue = mapType(gl, type);
return GLSL_TO_VERTEX_TYPES[typeValue] || "float32";
}
exports.mapGlToVertexFormat = mapGlToVertexFormat;
exports.mapType = mapType;
//# sourceMappingURL=mapType.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"mapType.js","sources":["../../../../../../src/rendering/renderers/gl/shader/program/mapType.ts"],"sourcesContent":["import type { Dict } from '../../../../../utils/types';\nimport type { VertexFormat } from '../../../shared/geometry/const';\n\nlet GL_TABLE: Dict<string> = null;\n\nconst GL_TO_GLSL_TYPES: Dict<string> = {\n FLOAT: 'float',\n FLOAT_VEC2: 'vec2',\n FLOAT_VEC3: 'vec3',\n FLOAT_VEC4: 'vec4',\n\n INT: 'int',\n INT_VEC2: 'ivec2',\n INT_VEC3: 'ivec3',\n INT_VEC4: 'ivec4',\n\n UNSIGNED_INT: 'uint',\n UNSIGNED_INT_VEC2: 'uvec2',\n UNSIGNED_INT_VEC3: 'uvec3',\n UNSIGNED_INT_VEC4: 'uvec4',\n\n BOOL: 'bool',\n BOOL_VEC2: 'bvec2',\n BOOL_VEC3: 'bvec3',\n BOOL_VEC4: 'bvec4',\n\n FLOAT_MAT2: 'mat2',\n FLOAT_MAT3: 'mat3',\n FLOAT_MAT4: 'mat4',\n\n SAMPLER_2D: 'sampler2D',\n INT_SAMPLER_2D: 'sampler2D',\n UNSIGNED_INT_SAMPLER_2D: 'sampler2D',\n SAMPLER_CUBE: 'samplerCube',\n INT_SAMPLER_CUBE: 'samplerCube',\n UNSIGNED_INT_SAMPLER_CUBE: 'samplerCube',\n SAMPLER_2D_ARRAY: 'sampler2DArray',\n INT_SAMPLER_2D_ARRAY: 'sampler2DArray',\n UNSIGNED_INT_SAMPLER_2D_ARRAY: 'sampler2DArray',\n};\n\nconst GLSL_TO_VERTEX_TYPES: Record<string, VertexFormat> = {\n\n float: 'float32',\n vec2: 'float32x2',\n vec3: 'float32x3',\n vec4: 'float32x4',\n\n int: 'sint32',\n ivec2: 'sint32x2',\n ivec3: 'sint32x3',\n ivec4: 'sint32x4',\n\n uint: 'uint32',\n uvec2: 'uint32x2',\n uvec3: 'uint32x3',\n uvec4: 'uint32x4',\n\n bool: 'uint32',\n bvec2: 'uint32x2',\n bvec3: 'uint32x3',\n bvec4: 'uint32x4',\n};\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\nexport function mapType(gl: any, type: number): string\n{\n if (!GL_TABLE)\n {\n const typeNames = Object.keys(GL_TO_GLSL_TYPES);\n\n GL_TABLE = {};\n\n for (let i = 0; i < typeNames.length; ++i)\n {\n const tn = typeNames[i];\n\n GL_TABLE[gl[tn]] = GL_TO_GLSL_TYPES[tn];\n }\n }\n\n return GL_TABLE[type];\n}\n\nexport function mapGlToVertexFormat(gl: any, type: number): VertexFormat\n{\n const typeValue = mapType(gl, type);\n\n return GLSL_TO_VERTEX_TYPES[typeValue] || 'float32';\n}\n"],"names":[],"mappings":";;;AAGA,IAAI,QAAyB,GAAA,IAAA,CAAA;AAE7B,MAAM,gBAAiC,GAAA;AAAA,EACnC,KAAa,EAAA,OAAA;AAAA,EACb,UAAa,EAAA,MAAA;AAAA,EACb,UAAa,EAAA,MAAA;AAAA,EACb,UAAa,EAAA,MAAA;AAAA,EAEb,GAAa,EAAA,KAAA;AAAA,EACb,QAAa,EAAA,OAAA;AAAA,EACb,QAAa,EAAA,OAAA;AAAA,EACb,QAAa,EAAA,OAAA;AAAA,EAEb,YAAsB,EAAA,MAAA;AAAA,EACtB,iBAAsB,EAAA,OAAA;AAAA,EACtB,iBAAsB,EAAA,OAAA;AAAA,EACtB,iBAAsB,EAAA,OAAA;AAAA,EAEtB,IAAa,EAAA,MAAA;AAAA,EACb,SAAa,EAAA,OAAA;AAAA,EACb,SAAa,EAAA,OAAA;AAAA,EACb,SAAa,EAAA,OAAA;AAAA,EAEb,UAAa,EAAA,MAAA;AAAA,EACb,UAAa,EAAA,MAAA;AAAA,EACb,UAAa,EAAA,MAAA;AAAA,EAEb,UAAyB,EAAA,WAAA;AAAA,EACzB,cAAyB,EAAA,WAAA;AAAA,EACzB,uBAAyB,EAAA,WAAA;AAAA,EACzB,YAA2B,EAAA,aAAA;AAAA,EAC3B,gBAA2B,EAAA,aAAA;AAAA,EAC3B,yBAA2B,EAAA,aAAA;AAAA,EAC3B,gBAA+B,EAAA,gBAAA;AAAA,EAC/B,oBAA+B,EAAA,gBAAA;AAAA,EAC/B,6BAA+B,EAAA,gBAAA;AACnC,CAA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-0,0 +1,68 @@
"use strict";
let GL_TABLE = null;
const GL_TO_GLSL_TYPES = {
FLOAT: "float",
FLOAT_VEC2: "vec2",
FLOAT_VEC3: "vec3",
FLOAT_VEC4: "vec4",
INT: "int",
INT_VEC2: "ivec2",
INT_VEC3: "ivec3",
INT_VEC4: "ivec4",
UNSIGNED_INT: "uint",
UNSIGNED_INT_VEC2: "uvec2",
UNSIGNED_INT_VEC3: "uvec3",
UNSIGNED_INT_VEC4: "uvec4",
BOOL: "bool",
BOOL_VEC2: "bvec2",
BOOL_VEC3: "bvec3",
BOOL_VEC4: "bvec4",
FLOAT_MAT2: "mat2",
FLOAT_MAT3: "mat3",
FLOAT_MAT4: "mat4",
SAMPLER_2D: "sampler2D",
INT_SAMPLER_2D: "sampler2D",
UNSIGNED_INT_SAMPLER_2D: "sampler2D",
SAMPLER_CUBE: "samplerCube",
INT_SAMPLER_CUBE: "samplerCube",
UNSIGNED_INT_SAMPLER_CUBE: "samplerCube",
SAMPLER_2D_ARRAY: "sampler2DArray",
INT_SAMPLER_2D_ARRAY: "sampler2DArray",
UNSIGNED_INT_SAMPLER_2D_ARRAY: "sampler2DArray"
};
const GLSL_TO_VERTEX_TYPES = {
float: "float32",
vec2: "float32x2",
vec3: "float32x3",
vec4: "float32x4",
int: "sint32",
ivec2: "sint32x2",
ivec3: "sint32x3",
ivec4: "sint32x4",
uint: "uint32",
uvec2: "uint32x2",
uvec3: "uint32x3",
uvec4: "uint32x4",
bool: "uint32",
bvec2: "uint32x2",
bvec3: "uint32x3",
bvec4: "uint32x4"
};
function mapType(gl, type) {
if (!GL_TABLE) {
const typeNames = Object.keys(GL_TO_GLSL_TYPES);
GL_TABLE = {};
for (let i = 0; i < typeNames.length; ++i) {
const tn = typeNames[i];
GL_TABLE[gl[tn]] = GL_TO_GLSL_TYPES[tn];
}
}
return GL_TABLE[type];
}
function mapGlToVertexFormat(gl, type) {
const typeValue = mapType(gl, type);
return GLSL_TO_VERTEX_TYPES[typeValue] || "float32";
}
export { mapGlToVertexFormat, mapType };
//# sourceMappingURL=mapType.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"mapType.mjs","sources":["../../../../../../src/rendering/renderers/gl/shader/program/mapType.ts"],"sourcesContent":["import type { Dict } from '../../../../../utils/types';\nimport type { VertexFormat } from '../../../shared/geometry/const';\n\nlet GL_TABLE: Dict<string> = null;\n\nconst GL_TO_GLSL_TYPES: Dict<string> = {\n FLOAT: 'float',\n FLOAT_VEC2: 'vec2',\n FLOAT_VEC3: 'vec3',\n FLOAT_VEC4: 'vec4',\n\n INT: 'int',\n INT_VEC2: 'ivec2',\n INT_VEC3: 'ivec3',\n INT_VEC4: 'ivec4',\n\n UNSIGNED_INT: 'uint',\n UNSIGNED_INT_VEC2: 'uvec2',\n UNSIGNED_INT_VEC3: 'uvec3',\n UNSIGNED_INT_VEC4: 'uvec4',\n\n BOOL: 'bool',\n BOOL_VEC2: 'bvec2',\n BOOL_VEC3: 'bvec3',\n BOOL_VEC4: 'bvec4',\n\n FLOAT_MAT2: 'mat2',\n FLOAT_MAT3: 'mat3',\n FLOAT_MAT4: 'mat4',\n\n SAMPLER_2D: 'sampler2D',\n INT_SAMPLER_2D: 'sampler2D',\n UNSIGNED_INT_SAMPLER_2D: 'sampler2D',\n SAMPLER_CUBE: 'samplerCube',\n INT_SAMPLER_CUBE: 'samplerCube',\n UNSIGNED_INT_SAMPLER_CUBE: 'samplerCube',\n SAMPLER_2D_ARRAY: 'sampler2DArray',\n INT_SAMPLER_2D_ARRAY: 'sampler2DArray',\n UNSIGNED_INT_SAMPLER_2D_ARRAY: 'sampler2DArray',\n};\n\nconst GLSL_TO_VERTEX_TYPES: Record<string, VertexFormat> = {\n\n float: 'float32',\n vec2: 'float32x2',\n vec3: 'float32x3',\n vec4: 'float32x4',\n\n int: 'sint32',\n ivec2: 'sint32x2',\n ivec3: 'sint32x3',\n ivec4: 'sint32x4',\n\n uint: 'uint32',\n uvec2: 'uint32x2',\n uvec3: 'uint32x3',\n uvec4: 'uint32x4',\n\n bool: 'uint32',\n bvec2: 'uint32x2',\n bvec3: 'uint32x3',\n bvec4: 'uint32x4',\n};\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\nexport function mapType(gl: any, type: number): string\n{\n if (!GL_TABLE)\n {\n const typeNames = Object.keys(GL_TO_GLSL_TYPES);\n\n GL_TABLE = {};\n\n for (let i = 0; i < typeNames.length; ++i)\n {\n const tn = typeNames[i];\n\n GL_TABLE[gl[tn]] = GL_TO_GLSL_TYPES[tn];\n }\n }\n\n return GL_TABLE[type];\n}\n\nexport function mapGlToVertexFormat(gl: any, type: number): VertexFormat\n{\n const typeValue = mapType(gl, type);\n\n return GLSL_TO_VERTEX_TYPES[typeValue] || 'float32';\n}\n"],"names":[],"mappings":";AAGA,IAAI,QAAyB,GAAA,IAAA,CAAA;AAE7B,MAAM,gBAAiC,GAAA;AAAA,EACnC,KAAa,EAAA,OAAA;AAAA,EACb,UAAa,EAAA,MAAA;AAAA,EACb,UAAa,EAAA,MAAA;AAAA,EACb,UAAa,EAAA,MAAA;AAAA,EAEb,GAAa,EAAA,KAAA;AAAA,EACb,QAAa,EAAA,OAAA;AAAA,EACb,QAAa,EAAA,OAAA;AAAA,EACb,QAAa,EAAA,OAAA;AAAA,EAEb,YAAsB,EAAA,MAAA;AAAA,EACtB,iBAAsB,EAAA,OAAA;AAAA,EACtB,iBAAsB,EAAA,OAAA;AAAA,EACtB,iBAAsB,EAAA,OAAA;AAAA,EAEtB,IAAa,EAAA,MAAA;AAAA,EACb,SAAa,EAAA,OAAA;AAAA,EACb,SAAa,EAAA,OAAA;AAAA,EACb,SAAa,EAAA,OAAA;AAAA,EAEb,UAAa,EAAA,MAAA;AAAA,EACb,UAAa,EAAA,MAAA;AAAA,EACb,UAAa,EAAA,MAAA;AAAA,EAEb,UAAyB,EAAA,WAAA;AAAA,EACzB,cAAyB,EAAA,WAAA;AAAA,EACzB,uBAAyB,EAAA,WAAA;AAAA,EACzB,YAA2B,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