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,25 @@
import { GL_FORMATS, GL_TARGETS } from './const';
/**
* Internal texture for WebGL context
* @memberof rendering
* @ignore
*/
export declare class GlTexture {
target: GL_TARGETS;
/** The WebGL texture. */
texture: WebGLTexture;
/** Width of texture that was used in texImage2D. */
width: number;
/** Height of texture that was used in texImage2D. */
height: number;
/** Whether mip levels has to be generated. */
mipmap: boolean;
/** Type copied from texture source. */
type: number;
/** Type copied from texture source. */
internalFormat: number;
/** Type of sampler corresponding to this texture. See {@link SAMPLER_TYPES} */
samplerType: number;
format: GL_FORMATS;
constructor(texture: WebGLTexture);
}

View File

@@ -0,0 +1,20 @@
'use strict';
var _const = require('./const.js');
"use strict";
class GlTexture {
constructor(texture) {
this.target = _const.GL_TARGETS.TEXTURE_2D;
this.texture = texture;
this.width = -1;
this.height = -1;
this.type = _const.GL_TYPES.UNSIGNED_BYTE;
this.internalFormat = _const.GL_FORMATS.RGBA;
this.format = _const.GL_FORMATS.RGBA;
this.samplerType = 0;
}
}
exports.GlTexture = GlTexture;
//# sourceMappingURL=GlTexture.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"GlTexture.js","sources":["../../../../../src/rendering/renderers/gl/texture/GlTexture.ts"],"sourcesContent":["import { GL_FORMATS, GL_TARGETS, GL_TYPES } from './const';\n\n/**\n * Internal texture for WebGL context\n * @memberof rendering\n * @ignore\n */\nexport class GlTexture\n{\n public target: GL_TARGETS = GL_TARGETS.TEXTURE_2D;\n\n /** The WebGL texture. */\n public texture: WebGLTexture;\n\n /** Width of texture that was used in texImage2D. */\n public width: number;\n\n /** Height of texture that was used in texImage2D. */\n public height: number;\n\n /** Whether mip levels has to be generated. */\n public mipmap: boolean;\n\n /** Type copied from texture source. */\n public type: number;\n\n /** Type copied from texture source. */\n public internalFormat: number;\n\n /** Type of sampler corresponding to this texture. See {@link SAMPLER_TYPES} */\n public samplerType: number;\n\n public format: GL_FORMATS;\n\n constructor(texture: WebGLTexture)\n {\n this.texture = texture;\n this.width = -1;\n this.height = -1;\n this.type = GL_TYPES.UNSIGNED_BYTE;\n this.internalFormat = GL_FORMATS.RGBA;\n this.format = GL_FORMATS.RGBA;\n this.samplerType = 0;\n }\n}\n"],"names":["GL_TARGETS","GL_TYPES","GL_FORMATS"],"mappings":";;;;;AAOO,MAAM,SACb,CAAA;AAAA,EA0BI,YAAY,OACZ,EAAA;AA1BA,IAAA,IAAA,CAAO,SAAqBA,iBAAW,CAAA,UAAA,CAAA;AA2BnC,IAAA,IAAA,CAAK,OAAU,GAAA,OAAA,CAAA;AACf,IAAA,IAAA,CAAK,KAAQ,GAAA,CAAA,CAAA,CAAA;AACb,IAAA,IAAA,CAAK,MAAS,GAAA,CAAA,CAAA,CAAA;AACd,IAAA,IAAA,CAAK,OAAOC,eAAS,CAAA,aAAA,CAAA;AACrB,IAAA,IAAA,CAAK,iBAAiBC,iBAAW,CAAA,IAAA,CAAA;AACjC,IAAA,IAAA,CAAK,SAASA,iBAAW,CAAA,IAAA,CAAA;AACzB,IAAA,IAAA,CAAK,WAAc,GAAA,CAAA,CAAA;AAAA,GACvB;AACJ;;;;"}

View File

@@ -0,0 +1,18 @@
import { GL_TARGETS, GL_TYPES, GL_FORMATS } from './const.mjs';
"use strict";
class GlTexture {
constructor(texture) {
this.target = GL_TARGETS.TEXTURE_2D;
this.texture = texture;
this.width = -1;
this.height = -1;
this.type = GL_TYPES.UNSIGNED_BYTE;
this.internalFormat = GL_FORMATS.RGBA;
this.format = GL_FORMATS.RGBA;
this.samplerType = 0;
}
}
export { GlTexture };
//# sourceMappingURL=GlTexture.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"GlTexture.mjs","sources":["../../../../../src/rendering/renderers/gl/texture/GlTexture.ts"],"sourcesContent":["import { GL_FORMATS, GL_TARGETS, GL_TYPES } from './const';\n\n/**\n * Internal texture for WebGL context\n * @memberof rendering\n * @ignore\n */\nexport class GlTexture\n{\n public target: GL_TARGETS = GL_TARGETS.TEXTURE_2D;\n\n /** The WebGL texture. */\n public texture: WebGLTexture;\n\n /** Width of texture that was used in texImage2D. */\n public width: number;\n\n /** Height of texture that was used in texImage2D. */\n public height: number;\n\n /** Whether mip levels has to be generated. */\n public mipmap: boolean;\n\n /** Type copied from texture source. */\n public type: number;\n\n /** Type copied from texture source. */\n public internalFormat: number;\n\n /** Type of sampler corresponding to this texture. See {@link SAMPLER_TYPES} */\n public samplerType: number;\n\n public format: GL_FORMATS;\n\n constructor(texture: WebGLTexture)\n {\n this.texture = texture;\n this.width = -1;\n this.height = -1;\n this.type = GL_TYPES.UNSIGNED_BYTE;\n this.internalFormat = GL_FORMATS.RGBA;\n this.format = GL_FORMATS.RGBA;\n this.samplerType = 0;\n }\n}\n"],"names":[],"mappings":";;;AAOO,MAAM,SACb,CAAA;AAAA,EA0BI,YAAY,OACZ,EAAA;AA1BA,IAAA,IAAA,CAAO,SAAqB,UAAW,CAAA,UAAA,CAAA;AA2BnC,IAAA,IAAA,CAAK,OAAU,GAAA,OAAA,CAAA;AACf,IAAA,IAAA,CAAK,KAAQ,GAAA,CAAA,CAAA,CAAA;AACb,IAAA,IAAA,CAAK,MAAS,GAAA,CAAA,CAAA,CAAA;AACd,IAAA,IAAA,CAAK,OAAO,QAAS,CAAA,aAAA,CAAA;AACrB,IAAA,IAAA,CAAK,iBAAiB,UAAW,CAAA,IAAA,CAAA;AACjC,IAAA,IAAA,CAAK,SAAS,UAAW,CAAA,IAAA,CAAA;AACzB,IAAA,IAAA,CAAK,WAAc,GAAA,CAAA,CAAA;AAAA,GACvB;AACJ;;;;"}

View File

@@ -0,0 +1,55 @@
import { ExtensionType } from '../../../../extensions/Extensions';
import { Texture } from '../../shared/texture/Texture';
import { GlTexture } from './GlTexture';
import type { ICanvas } from '../../../../environment/canvas/ICanvas';
import type { System } from '../../shared/system/System';
import type { CanvasGenerator, GetPixelsOutput } from '../../shared/texture/GenerateCanvas';
import type { TextureSource } from '../../shared/texture/sources/TextureSource';
import type { BindableTexture } from '../../shared/texture/Texture';
import type { GlRenderingContext } from '../context/GlRenderingContext';
import type { WebGLRenderer } from '../WebGLRenderer';
/**
* The system for managing textures in WebGL.
* @memberof rendering
*/
export declare class GlTextureSystem implements System, CanvasGenerator {
/** @ignore */
static extension: {
readonly type: readonly [ExtensionType.WebGLSystem];
readonly name: "texture";
};
readonly managedTextures: TextureSource[];
private readonly _renderer;
private _glTextures;
private _glSamplers;
private _boundTextures;
private _activeTextureLocation;
private _boundSamplers;
private readonly _uploads;
private _gl;
private _mapFormatToInternalFormat;
private _mapFormatToType;
private _mapFormatToFormat;
private readonly _useSeparateSamplers;
constructor(renderer: WebGLRenderer);
protected contextChange(gl: GlRenderingContext): void;
initSource(source: TextureSource): void;
bind(texture: BindableTexture, location?: number): void;
bindSource(source: TextureSource, location?: number): void;
private _bindSampler;
unbind(texture: BindableTexture): void;
private _activateLocation;
private _initSource;
protected onStyleChange(source: TextureSource): void;
protected updateStyle(source: TextureSource, firstCreation: boolean): void;
protected onSourceUnload(source: TextureSource): void;
protected onSourceUpdate(source: TextureSource): void;
protected onUpdateMipmaps(source: TextureSource, bind?: boolean): void;
protected onSourceDestroy(source: TextureSource): void;
private _initSampler;
private _getGlSampler;
getGlSource(source: TextureSource): GlTexture;
generateCanvas(texture: Texture): ICanvas;
getPixels(texture: Texture): GetPixelsOutput;
destroy(): void;
}

View File

@@ -0,0 +1,268 @@
'use strict';
var adapter = require('../../../../environment/adapter.js');
var Extensions = require('../../../../extensions/Extensions.js');
var Texture = require('../../shared/texture/Texture.js');
var GlTexture = require('./GlTexture.js');
var glUploadBufferImageResource = require('./uploaders/glUploadBufferImageResource.js');
var glUploadCompressedTextureResource = require('./uploaders/glUploadCompressedTextureResource.js');
var glUploadImageResource = require('./uploaders/glUploadImageResource.js');
var glUploadVideoResource = require('./uploaders/glUploadVideoResource.js');
var applyStyleParams = require('./utils/applyStyleParams.js');
var mapFormatToGlFormat = require('./utils/mapFormatToGlFormat.js');
var mapFormatToGlInternalFormat = require('./utils/mapFormatToGlInternalFormat.js');
var mapFormatToGlType = require('./utils/mapFormatToGlType.js');
require('./utils/unpremultiplyAlpha.js');
"use strict";
const BYTES_PER_PIXEL = 4;
class GlTextureSystem {
constructor(renderer) {
this.managedTextures = [];
this._glTextures = /* @__PURE__ */ Object.create(null);
this._glSamplers = /* @__PURE__ */ Object.create(null);
this._boundTextures = [];
this._activeTextureLocation = -1;
this._boundSamplers = /* @__PURE__ */ Object.create(null);
this._uploads = {
image: glUploadImageResource.glUploadImageResource,
buffer: glUploadBufferImageResource.glUploadBufferImageResource,
video: glUploadVideoResource.glUploadVideoResource,
compressed: glUploadCompressedTextureResource.glUploadCompressedTextureResource
};
// TODO - separate samplers will be a cool thing to add, but not right now!
this._useSeparateSamplers = false;
this._renderer = renderer;
}
contextChange(gl) {
this._gl = gl;
if (!this._mapFormatToInternalFormat) {
this._mapFormatToInternalFormat = mapFormatToGlInternalFormat.mapFormatToGlInternalFormat(gl, this._renderer.context.extensions);
this._mapFormatToType = mapFormatToGlType.mapFormatToGlType(gl);
this._mapFormatToFormat = mapFormatToGlFormat.mapFormatToGlFormat(gl);
}
this._glTextures = /* @__PURE__ */ Object.create(null);
this._glSamplers = /* @__PURE__ */ Object.create(null);
this._boundSamplers = /* @__PURE__ */ Object.create(null);
for (let i = 0; i < 16; i++) {
this.bind(Texture.Texture.EMPTY, i);
}
}
initSource(source) {
this.bind(source);
}
bind(texture, location = 0) {
const source = texture.source;
if (texture) {
this.bindSource(source, location);
if (this._useSeparateSamplers) {
this._bindSampler(source.style, location);
}
} else {
this.bindSource(null, location);
if (this._useSeparateSamplers) {
this._bindSampler(null, location);
}
}
}
bindSource(source, location = 0) {
const gl = this._gl;
source._touched = this._renderer.textureGC.count;
if (this._boundTextures[location] !== source) {
this._boundTextures[location] = source;
this._activateLocation(location);
source = source || Texture.Texture.EMPTY.source;
const glTexture = this.getGlSource(source);
gl.bindTexture(glTexture.target, glTexture.texture);
}
}
_bindSampler(style, location = 0) {
const gl = this._gl;
if (!style) {
this._boundSamplers[location] = null;
gl.bindSampler(location, null);
return;
}
const sampler = this._getGlSampler(style);
if (this._boundSamplers[location] !== sampler) {
this._boundSamplers[location] = sampler;
gl.bindSampler(location, sampler);
}
}
unbind(texture) {
const source = texture.source;
const boundTextures = this._boundTextures;
const gl = this._gl;
for (let i = 0; i < boundTextures.length; i++) {
if (boundTextures[i] === source) {
this._activateLocation(i);
const glTexture = this.getGlSource(source);
gl.bindTexture(glTexture.target, null);
boundTextures[i] = null;
}
}
}
_activateLocation(location) {
if (this._activeTextureLocation !== location) {
this._activeTextureLocation = location;
this._gl.activeTexture(this._gl.TEXTURE0 + location);
}
}
_initSource(source) {
const gl = this._gl;
const glTexture = new GlTexture.GlTexture(gl.createTexture());
glTexture.type = this._mapFormatToType[source.format];
glTexture.internalFormat = this._mapFormatToInternalFormat[source.format];
glTexture.format = this._mapFormatToFormat[source.format];
if (source.autoGenerateMipmaps && (this._renderer.context.supports.nonPowOf2mipmaps || source.isPowerOfTwo)) {
const biggestDimension = Math.max(source.width, source.height);
source.mipLevelCount = Math.floor(Math.log2(biggestDimension)) + 1;
}
this._glTextures[source.uid] = glTexture;
if (!this.managedTextures.includes(source)) {
source.on("update", this.onSourceUpdate, this);
source.on("resize", this.onSourceUpdate, this);
source.on("styleChange", this.onStyleChange, this);
source.on("destroy", this.onSourceDestroy, this);
source.on("unload", this.onSourceUnload, this);
source.on("updateMipmaps", this.onUpdateMipmaps, this);
this.managedTextures.push(source);
}
this.onSourceUpdate(source);
this.updateStyle(source, false);
return glTexture;
}
onStyleChange(source) {
this.updateStyle(source, false);
}
updateStyle(source, firstCreation) {
const gl = this._gl;
const glTexture = this.getGlSource(source);
gl.bindTexture(gl.TEXTURE_2D, glTexture.texture);
this._boundTextures[this._activeTextureLocation] = source;
applyStyleParams.applyStyleParams(
source.style,
gl,
source.mipLevelCount > 1,
this._renderer.context.extensions.anisotropicFiltering,
"texParameteri",
gl.TEXTURE_2D,
// will force a clamp to edge if the texture is not a power of two
!this._renderer.context.supports.nonPowOf2wrapping && !source.isPowerOfTwo,
firstCreation
);
}
onSourceUnload(source) {
const glTexture = this._glTextures[source.uid];
if (!glTexture)
return;
this.unbind(source);
this._glTextures[source.uid] = null;
this._gl.deleteTexture(glTexture.texture);
}
onSourceUpdate(source) {
const gl = this._gl;
const glTexture = this.getGlSource(source);
gl.bindTexture(gl.TEXTURE_2D, glTexture.texture);
this._boundTextures[this._activeTextureLocation] = source;
if (this._uploads[source.uploadMethodId]) {
this._uploads[source.uploadMethodId].upload(source, glTexture, gl, this._renderer.context.webGLVersion);
} else {
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, source.pixelWidth, source.pixelHeight, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
}
if (source.autoGenerateMipmaps && source.mipLevelCount > 1) {
this.onUpdateMipmaps(source, false);
}
}
onUpdateMipmaps(source, bind = true) {
if (bind)
this.bindSource(source, 0);
const glTexture = this.getGlSource(source);
this._gl.generateMipmap(glTexture.target);
}
onSourceDestroy(source) {
source.off("destroy", this.onSourceDestroy, this);
source.off("update", this.onSourceUpdate, this);
source.off("resize", this.onSourceUpdate, this);
source.off("unload", this.onSourceUnload, this);
source.off("styleChange", this.onStyleChange, this);
source.off("updateMipmaps", this.onUpdateMipmaps, this);
this.managedTextures.splice(this.managedTextures.indexOf(source), 1);
this.onSourceUnload(source);
}
_initSampler(style) {
const gl = this._gl;
const glSampler = this._gl.createSampler();
this._glSamplers[style._resourceId] = glSampler;
applyStyleParams.applyStyleParams(
style,
gl,
this._boundTextures[this._activeTextureLocation].mipLevelCount > 1,
this._renderer.context.extensions.anisotropicFiltering,
"samplerParameteri",
glSampler,
false,
true
);
return this._glSamplers[style._resourceId];
}
_getGlSampler(sampler) {
return this._glSamplers[sampler._resourceId] || this._initSampler(sampler);
}
getGlSource(source) {
return this._glTextures[source.uid] || this._initSource(source);
}
generateCanvas(texture) {
const { pixels, width, height } = this.getPixels(texture);
const canvas = adapter.DOMAdapter.get().createCanvas();
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext("2d");
if (ctx) {
const imageData = ctx.createImageData(width, height);
imageData.data.set(pixels);
ctx.putImageData(imageData, 0, 0);
}
return canvas;
}
getPixels(texture) {
const resolution = texture.source.resolution;
const frame = texture.frame;
const width = Math.max(Math.round(frame.width * resolution), 1);
const height = Math.max(Math.round(frame.height * resolution), 1);
const pixels = new Uint8Array(BYTES_PER_PIXEL * width * height);
const renderer = this._renderer;
const renderTarget = renderer.renderTarget.getRenderTarget(texture);
const glRenterTarget = renderer.renderTarget.getGpuRenderTarget(renderTarget);
const gl = renderer.gl;
gl.bindFramebuffer(gl.FRAMEBUFFER, glRenterTarget.resolveTargetFramebuffer);
gl.readPixels(
Math.round(frame.x * resolution),
Math.round(frame.y * resolution),
width,
height,
gl.RGBA,
gl.UNSIGNED_BYTE,
pixels
);
if (false) {
unpremultiplyAlpha(pixels);
}
return { pixels: new Uint8ClampedArray(pixels.buffer), width, height };
}
destroy() {
this.managedTextures.slice().forEach((source) => this.onSourceDestroy(source));
this.managedTextures = null;
this._renderer = null;
}
}
/** @ignore */
GlTextureSystem.extension = {
type: [
Extensions.ExtensionType.WebGLSystem
],
name: "texture"
};
exports.GlTextureSystem = GlTextureSystem;
//# sourceMappingURL=GlTextureSystem.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,266 @@
import { DOMAdapter } from '../../../../environment/adapter.mjs';
import { ExtensionType } from '../../../../extensions/Extensions.mjs';
import { Texture } from '../../shared/texture/Texture.mjs';
import { GlTexture } from './GlTexture.mjs';
import { glUploadBufferImageResource } from './uploaders/glUploadBufferImageResource.mjs';
import { glUploadCompressedTextureResource } from './uploaders/glUploadCompressedTextureResource.mjs';
import { glUploadImageResource } from './uploaders/glUploadImageResource.mjs';
import { glUploadVideoResource } from './uploaders/glUploadVideoResource.mjs';
import { applyStyleParams } from './utils/applyStyleParams.mjs';
import { mapFormatToGlFormat } from './utils/mapFormatToGlFormat.mjs';
import { mapFormatToGlInternalFormat } from './utils/mapFormatToGlInternalFormat.mjs';
import { mapFormatToGlType } from './utils/mapFormatToGlType.mjs';
import './utils/unpremultiplyAlpha.mjs';
"use strict";
const BYTES_PER_PIXEL = 4;
class GlTextureSystem {
constructor(renderer) {
this.managedTextures = [];
this._glTextures = /* @__PURE__ */ Object.create(null);
this._glSamplers = /* @__PURE__ */ Object.create(null);
this._boundTextures = [];
this._activeTextureLocation = -1;
this._boundSamplers = /* @__PURE__ */ Object.create(null);
this._uploads = {
image: glUploadImageResource,
buffer: glUploadBufferImageResource,
video: glUploadVideoResource,
compressed: glUploadCompressedTextureResource
};
// TODO - separate samplers will be a cool thing to add, but not right now!
this._useSeparateSamplers = false;
this._renderer = renderer;
}
contextChange(gl) {
this._gl = gl;
if (!this._mapFormatToInternalFormat) {
this._mapFormatToInternalFormat = mapFormatToGlInternalFormat(gl, this._renderer.context.extensions);
this._mapFormatToType = mapFormatToGlType(gl);
this._mapFormatToFormat = mapFormatToGlFormat(gl);
}
this._glTextures = /* @__PURE__ */ Object.create(null);
this._glSamplers = /* @__PURE__ */ Object.create(null);
this._boundSamplers = /* @__PURE__ */ Object.create(null);
for (let i = 0; i < 16; i++) {
this.bind(Texture.EMPTY, i);
}
}
initSource(source) {
this.bind(source);
}
bind(texture, location = 0) {
const source = texture.source;
if (texture) {
this.bindSource(source, location);
if (this._useSeparateSamplers) {
this._bindSampler(source.style, location);
}
} else {
this.bindSource(null, location);
if (this._useSeparateSamplers) {
this._bindSampler(null, location);
}
}
}
bindSource(source, location = 0) {
const gl = this._gl;
source._touched = this._renderer.textureGC.count;
if (this._boundTextures[location] !== source) {
this._boundTextures[location] = source;
this._activateLocation(location);
source = source || Texture.EMPTY.source;
const glTexture = this.getGlSource(source);
gl.bindTexture(glTexture.target, glTexture.texture);
}
}
_bindSampler(style, location = 0) {
const gl = this._gl;
if (!style) {
this._boundSamplers[location] = null;
gl.bindSampler(location, null);
return;
}
const sampler = this._getGlSampler(style);
if (this._boundSamplers[location] !== sampler) {
this._boundSamplers[location] = sampler;
gl.bindSampler(location, sampler);
}
}
unbind(texture) {
const source = texture.source;
const boundTextures = this._boundTextures;
const gl = this._gl;
for (let i = 0; i < boundTextures.length; i++) {
if (boundTextures[i] === source) {
this._activateLocation(i);
const glTexture = this.getGlSource(source);
gl.bindTexture(glTexture.target, null);
boundTextures[i] = null;
}
}
}
_activateLocation(location) {
if (this._activeTextureLocation !== location) {
this._activeTextureLocation = location;
this._gl.activeTexture(this._gl.TEXTURE0 + location);
}
}
_initSource(source) {
const gl = this._gl;
const glTexture = new GlTexture(gl.createTexture());
glTexture.type = this._mapFormatToType[source.format];
glTexture.internalFormat = this._mapFormatToInternalFormat[source.format];
glTexture.format = this._mapFormatToFormat[source.format];
if (source.autoGenerateMipmaps && (this._renderer.context.supports.nonPowOf2mipmaps || source.isPowerOfTwo)) {
const biggestDimension = Math.max(source.width, source.height);
source.mipLevelCount = Math.floor(Math.log2(biggestDimension)) + 1;
}
this._glTextures[source.uid] = glTexture;
if (!this.managedTextures.includes(source)) {
source.on("update", this.onSourceUpdate, this);
source.on("resize", this.onSourceUpdate, this);
source.on("styleChange", this.onStyleChange, this);
source.on("destroy", this.onSourceDestroy, this);
source.on("unload", this.onSourceUnload, this);
source.on("updateMipmaps", this.onUpdateMipmaps, this);
this.managedTextures.push(source);
}
this.onSourceUpdate(source);
this.updateStyle(source, false);
return glTexture;
}
onStyleChange(source) {
this.updateStyle(source, false);
}
updateStyle(source, firstCreation) {
const gl = this._gl;
const glTexture = this.getGlSource(source);
gl.bindTexture(gl.TEXTURE_2D, glTexture.texture);
this._boundTextures[this._activeTextureLocation] = source;
applyStyleParams(
source.style,
gl,
source.mipLevelCount > 1,
this._renderer.context.extensions.anisotropicFiltering,
"texParameteri",
gl.TEXTURE_2D,
// will force a clamp to edge if the texture is not a power of two
!this._renderer.context.supports.nonPowOf2wrapping && !source.isPowerOfTwo,
firstCreation
);
}
onSourceUnload(source) {
const glTexture = this._glTextures[source.uid];
if (!glTexture)
return;
this.unbind(source);
this._glTextures[source.uid] = null;
this._gl.deleteTexture(glTexture.texture);
}
onSourceUpdate(source) {
const gl = this._gl;
const glTexture = this.getGlSource(source);
gl.bindTexture(gl.TEXTURE_2D, glTexture.texture);
this._boundTextures[this._activeTextureLocation] = source;
if (this._uploads[source.uploadMethodId]) {
this._uploads[source.uploadMethodId].upload(source, glTexture, gl, this._renderer.context.webGLVersion);
} else {
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, source.pixelWidth, source.pixelHeight, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
}
if (source.autoGenerateMipmaps && source.mipLevelCount > 1) {
this.onUpdateMipmaps(source, false);
}
}
onUpdateMipmaps(source, bind = true) {
if (bind)
this.bindSource(source, 0);
const glTexture = this.getGlSource(source);
this._gl.generateMipmap(glTexture.target);
}
onSourceDestroy(source) {
source.off("destroy", this.onSourceDestroy, this);
source.off("update", this.onSourceUpdate, this);
source.off("resize", this.onSourceUpdate, this);
source.off("unload", this.onSourceUnload, this);
source.off("styleChange", this.onStyleChange, this);
source.off("updateMipmaps", this.onUpdateMipmaps, this);
this.managedTextures.splice(this.managedTextures.indexOf(source), 1);
this.onSourceUnload(source);
}
_initSampler(style) {
const gl = this._gl;
const glSampler = this._gl.createSampler();
this._glSamplers[style._resourceId] = glSampler;
applyStyleParams(
style,
gl,
this._boundTextures[this._activeTextureLocation].mipLevelCount > 1,
this._renderer.context.extensions.anisotropicFiltering,
"samplerParameteri",
glSampler,
false,
true
);
return this._glSamplers[style._resourceId];
}
_getGlSampler(sampler) {
return this._glSamplers[sampler._resourceId] || this._initSampler(sampler);
}
getGlSource(source) {
return this._glTextures[source.uid] || this._initSource(source);
}
generateCanvas(texture) {
const { pixels, width, height } = this.getPixels(texture);
const canvas = DOMAdapter.get().createCanvas();
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext("2d");
if (ctx) {
const imageData = ctx.createImageData(width, height);
imageData.data.set(pixels);
ctx.putImageData(imageData, 0, 0);
}
return canvas;
}
getPixels(texture) {
const resolution = texture.source.resolution;
const frame = texture.frame;
const width = Math.max(Math.round(frame.width * resolution), 1);
const height = Math.max(Math.round(frame.height * resolution), 1);
const pixels = new Uint8Array(BYTES_PER_PIXEL * width * height);
const renderer = this._renderer;
const renderTarget = renderer.renderTarget.getRenderTarget(texture);
const glRenterTarget = renderer.renderTarget.getGpuRenderTarget(renderTarget);
const gl = renderer.gl;
gl.bindFramebuffer(gl.FRAMEBUFFER, glRenterTarget.resolveTargetFramebuffer);
gl.readPixels(
Math.round(frame.x * resolution),
Math.round(frame.y * resolution),
width,
height,
gl.RGBA,
gl.UNSIGNED_BYTE,
pixels
);
if (false) {
unpremultiplyAlpha(pixels);
}
return { pixels: new Uint8ClampedArray(pixels.buffer), width, height };
}
destroy() {
this.managedTextures.slice().forEach((source) => this.onSourceDestroy(source));
this.managedTextures = null;
this._renderer = null;
}
}
/** @ignore */
GlTextureSystem.extension = {
type: [
ExtensionType.WebGLSystem
],
name: "texture"
};
export { GlTextureSystem };
//# sourceMappingURL=GlTextureSystem.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,151 @@
/**
* Various GL texture/resources formats.
* @static
* @name FORMATS
* @enum {number}
* @property {number} [RGBA=6408] -
* @property {number} [RGB=6407] -
* @property {number} [RG=33319] -
* @property {number} [RED=6403] -
* @property {number} [RGBA_INTEGER=36249] -
* @property {number} [RGB_INTEGER=36248] -
* @property {number} [RG_INTEGER=33320] -
* @property {number} [RED_INTEGER=36244] -
* @property {number} [ALPHA=6406] -
* @property {number} [LUMINANCE=6409] -
* @property {number} [LUMINANCE_ALPHA=6410] -
* @property {number} [DEPTH_COMPONENT=6402] -
* @property {number} [DEPTH_STENCIL=34041] -
*/
export declare enum GL_FORMATS {
RGBA = 6408,
RGB = 6407,
RG = 33319,
RED = 6403,
RGBA_INTEGER = 36249,
RGB_INTEGER = 36248,
RG_INTEGER = 33320,
RED_INTEGER = 36244,
ALPHA = 6406,
LUMINANCE = 6409,
LUMINANCE_ALPHA = 6410,
DEPTH_COMPONENT = 6402,
DEPTH_STENCIL = 34041
}
/**
* Various GL target types.
* @static
* @name TARGETS
* @enum {number}
* @property {number} [TEXTURE_2D=3553] -
* @property {number} [TEXTURE_CUBE_MAP=34067] -
* @property {number} [TEXTURE_2D_ARRAY=35866] -
* @property {number} [TEXTURE_CUBE_MAP_POSITIVE_X=34069] -
* @property {number} [TEXTURE_CUBE_MAP_NEGATIVE_X=34070] -
* @property {number} [TEXTURE_CUBE_MAP_POSITIVE_Y=34071] -
* @property {number} [TEXTURE_CUBE_MAP_NEGATIVE_Y=34072] -
* @property {number} [TEXTURE_CUBE_MAP_POSITIVE_Z=34073] -
* @property {number} [TEXTURE_CUBE_MAP_NEGATIVE_Z=34074] -
*/
export declare enum GL_TARGETS {
TEXTURE_2D = 3553,
TEXTURE_CUBE_MAP = 34067,
TEXTURE_2D_ARRAY = 35866,
TEXTURE_CUBE_MAP_POSITIVE_X = 34069,
TEXTURE_CUBE_MAP_NEGATIVE_X = 34070,
TEXTURE_CUBE_MAP_POSITIVE_Y = 34071,
TEXTURE_CUBE_MAP_NEGATIVE_Y = 34072,
TEXTURE_CUBE_MAP_POSITIVE_Z = 34073,
TEXTURE_CUBE_MAP_NEGATIVE_Z = 34074
}
/**
* The wrap modes that are supported by pixi.
*
* The {@link settings.WRAP_MODE} wrap mode affects the default wrapping mode of future operations.
* It can be re-assigned to either CLAMP or REPEAT, depending upon suitability.
* If the texture is non power of two then clamp will be used regardless as WebGL can
* only use REPEAT if the texture is po2.
*
* This property only affects WebGL.
* @name WRAP_MODES
* @static
* @enum {number}
* @property {number} CLAMP - The textures uvs are clamped
* @property {number} REPEAT - The texture uvs tile and repeat
* @property {number} MIRRORED_REPEAT - The texture uvs tile and repeat with mirroring
*/
export declare enum GL_WRAP_MODES {
CLAMP = 33071,
REPEAT = 10497,
MIRRORED_REPEAT = 33648
}
export declare enum GL_TYPES {
/**
* 8 bits per channel for gl.RGBA
* @default 5121
*/
UNSIGNED_BYTE = 5121,
/**
* @default 5123
*/
UNSIGNED_SHORT = 5123,
/**
* 5 red bits, 6 green bits, 5 blue bits.
* @default 33635
*/
UNSIGNED_SHORT_5_6_5 = 33635,
/**
* 4 red bits, 4 green bits, 4 blue bits, 4 alpha bits.
* @default 32819
*/
UNSIGNED_SHORT_4_4_4_4 = 32819,
/**
* 5 red bits, 5 green bits, 5 blue bits, 1 alpha bit.
* @default 32820
*/
UNSIGNED_SHORT_5_5_5_1 = 32820,
/**
* @default 5125
*/
UNSIGNED_INT = 5125,
/**
* @default 35899
*/
UNSIGNED_INT_10F_11F_11F_REV = 35899,
/**
* @default 33640
*/
UNSIGNED_INT_2_10_10_10_REV = 33640,
/**
* @default 34042
*/
UNSIGNED_INT_24_8 = 34042,
/**
* @default 35902
*/
UNSIGNED_INT_5_9_9_9_REV = 35902,
/**
* @default 5120
*/
BYTE = 5120,
/**
* @default 5122
*/
SHORT = 5122,
/**
* @default 5124
*/
INT = 5124,
/**
* @default 5126
*/
FLOAT = 5126,
/**
* @default 36269
*/
FLOAT_32_UNSIGNED_INT_24_8_REV = 36269,
/**
* @default 36193
*/
HALF_FLOAT = 36193
}

View File

@@ -0,0 +1,62 @@
'use strict';
"use strict";
var GL_FORMATS = /* @__PURE__ */ ((GL_FORMATS2) => {
GL_FORMATS2[GL_FORMATS2["RGBA"] = 6408] = "RGBA";
GL_FORMATS2[GL_FORMATS2["RGB"] = 6407] = "RGB";
GL_FORMATS2[GL_FORMATS2["RG"] = 33319] = "RG";
GL_FORMATS2[GL_FORMATS2["RED"] = 6403] = "RED";
GL_FORMATS2[GL_FORMATS2["RGBA_INTEGER"] = 36249] = "RGBA_INTEGER";
GL_FORMATS2[GL_FORMATS2["RGB_INTEGER"] = 36248] = "RGB_INTEGER";
GL_FORMATS2[GL_FORMATS2["RG_INTEGER"] = 33320] = "RG_INTEGER";
GL_FORMATS2[GL_FORMATS2["RED_INTEGER"] = 36244] = "RED_INTEGER";
GL_FORMATS2[GL_FORMATS2["ALPHA"] = 6406] = "ALPHA";
GL_FORMATS2[GL_FORMATS2["LUMINANCE"] = 6409] = "LUMINANCE";
GL_FORMATS2[GL_FORMATS2["LUMINANCE_ALPHA"] = 6410] = "LUMINANCE_ALPHA";
GL_FORMATS2[GL_FORMATS2["DEPTH_COMPONENT"] = 6402] = "DEPTH_COMPONENT";
GL_FORMATS2[GL_FORMATS2["DEPTH_STENCIL"] = 34041] = "DEPTH_STENCIL";
return GL_FORMATS2;
})(GL_FORMATS || {});
var GL_TARGETS = /* @__PURE__ */ ((GL_TARGETS2) => {
GL_TARGETS2[GL_TARGETS2["TEXTURE_2D"] = 3553] = "TEXTURE_2D";
GL_TARGETS2[GL_TARGETS2["TEXTURE_CUBE_MAP"] = 34067] = "TEXTURE_CUBE_MAP";
GL_TARGETS2[GL_TARGETS2["TEXTURE_2D_ARRAY"] = 35866] = "TEXTURE_2D_ARRAY";
GL_TARGETS2[GL_TARGETS2["TEXTURE_CUBE_MAP_POSITIVE_X"] = 34069] = "TEXTURE_CUBE_MAP_POSITIVE_X";
GL_TARGETS2[GL_TARGETS2["TEXTURE_CUBE_MAP_NEGATIVE_X"] = 34070] = "TEXTURE_CUBE_MAP_NEGATIVE_X";
GL_TARGETS2[GL_TARGETS2["TEXTURE_CUBE_MAP_POSITIVE_Y"] = 34071] = "TEXTURE_CUBE_MAP_POSITIVE_Y";
GL_TARGETS2[GL_TARGETS2["TEXTURE_CUBE_MAP_NEGATIVE_Y"] = 34072] = "TEXTURE_CUBE_MAP_NEGATIVE_Y";
GL_TARGETS2[GL_TARGETS2["TEXTURE_CUBE_MAP_POSITIVE_Z"] = 34073] = "TEXTURE_CUBE_MAP_POSITIVE_Z";
GL_TARGETS2[GL_TARGETS2["TEXTURE_CUBE_MAP_NEGATIVE_Z"] = 34074] = "TEXTURE_CUBE_MAP_NEGATIVE_Z";
return GL_TARGETS2;
})(GL_TARGETS || {});
var GL_WRAP_MODES = /* @__PURE__ */ ((GL_WRAP_MODES2) => {
GL_WRAP_MODES2[GL_WRAP_MODES2["CLAMP"] = 33071] = "CLAMP";
GL_WRAP_MODES2[GL_WRAP_MODES2["REPEAT"] = 10497] = "REPEAT";
GL_WRAP_MODES2[GL_WRAP_MODES2["MIRRORED_REPEAT"] = 33648] = "MIRRORED_REPEAT";
return GL_WRAP_MODES2;
})(GL_WRAP_MODES || {});
var GL_TYPES = /* @__PURE__ */ ((GL_TYPES2) => {
GL_TYPES2[GL_TYPES2["UNSIGNED_BYTE"] = 5121] = "UNSIGNED_BYTE";
GL_TYPES2[GL_TYPES2["UNSIGNED_SHORT"] = 5123] = "UNSIGNED_SHORT";
GL_TYPES2[GL_TYPES2["UNSIGNED_SHORT_5_6_5"] = 33635] = "UNSIGNED_SHORT_5_6_5";
GL_TYPES2[GL_TYPES2["UNSIGNED_SHORT_4_4_4_4"] = 32819] = "UNSIGNED_SHORT_4_4_4_4";
GL_TYPES2[GL_TYPES2["UNSIGNED_SHORT_5_5_5_1"] = 32820] = "UNSIGNED_SHORT_5_5_5_1";
GL_TYPES2[GL_TYPES2["UNSIGNED_INT"] = 5125] = "UNSIGNED_INT";
GL_TYPES2[GL_TYPES2["UNSIGNED_INT_10F_11F_11F_REV"] = 35899] = "UNSIGNED_INT_10F_11F_11F_REV";
GL_TYPES2[GL_TYPES2["UNSIGNED_INT_2_10_10_10_REV"] = 33640] = "UNSIGNED_INT_2_10_10_10_REV";
GL_TYPES2[GL_TYPES2["UNSIGNED_INT_24_8"] = 34042] = "UNSIGNED_INT_24_8";
GL_TYPES2[GL_TYPES2["UNSIGNED_INT_5_9_9_9_REV"] = 35902] = "UNSIGNED_INT_5_9_9_9_REV";
GL_TYPES2[GL_TYPES2["BYTE"] = 5120] = "BYTE";
GL_TYPES2[GL_TYPES2["SHORT"] = 5122] = "SHORT";
GL_TYPES2[GL_TYPES2["INT"] = 5124] = "INT";
GL_TYPES2[GL_TYPES2["FLOAT"] = 5126] = "FLOAT";
GL_TYPES2[GL_TYPES2["FLOAT_32_UNSIGNED_INT_24_8_REV"] = 36269] = "FLOAT_32_UNSIGNED_INT_24_8_REV";
GL_TYPES2[GL_TYPES2["HALF_FLOAT"] = 36193] = "HALF_FLOAT";
return GL_TYPES2;
})(GL_TYPES || {});
exports.GL_FORMATS = GL_FORMATS;
exports.GL_TARGETS = GL_TARGETS;
exports.GL_TYPES = GL_TYPES;
exports.GL_WRAP_MODES = GL_WRAP_MODES;
//# sourceMappingURL=const.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,57 @@
"use strict";
var GL_FORMATS = /* @__PURE__ */ ((GL_FORMATS2) => {
GL_FORMATS2[GL_FORMATS2["RGBA"] = 6408] = "RGBA";
GL_FORMATS2[GL_FORMATS2["RGB"] = 6407] = "RGB";
GL_FORMATS2[GL_FORMATS2["RG"] = 33319] = "RG";
GL_FORMATS2[GL_FORMATS2["RED"] = 6403] = "RED";
GL_FORMATS2[GL_FORMATS2["RGBA_INTEGER"] = 36249] = "RGBA_INTEGER";
GL_FORMATS2[GL_FORMATS2["RGB_INTEGER"] = 36248] = "RGB_INTEGER";
GL_FORMATS2[GL_FORMATS2["RG_INTEGER"] = 33320] = "RG_INTEGER";
GL_FORMATS2[GL_FORMATS2["RED_INTEGER"] = 36244] = "RED_INTEGER";
GL_FORMATS2[GL_FORMATS2["ALPHA"] = 6406] = "ALPHA";
GL_FORMATS2[GL_FORMATS2["LUMINANCE"] = 6409] = "LUMINANCE";
GL_FORMATS2[GL_FORMATS2["LUMINANCE_ALPHA"] = 6410] = "LUMINANCE_ALPHA";
GL_FORMATS2[GL_FORMATS2["DEPTH_COMPONENT"] = 6402] = "DEPTH_COMPONENT";
GL_FORMATS2[GL_FORMATS2["DEPTH_STENCIL"] = 34041] = "DEPTH_STENCIL";
return GL_FORMATS2;
})(GL_FORMATS || {});
var GL_TARGETS = /* @__PURE__ */ ((GL_TARGETS2) => {
GL_TARGETS2[GL_TARGETS2["TEXTURE_2D"] = 3553] = "TEXTURE_2D";
GL_TARGETS2[GL_TARGETS2["TEXTURE_CUBE_MAP"] = 34067] = "TEXTURE_CUBE_MAP";
GL_TARGETS2[GL_TARGETS2["TEXTURE_2D_ARRAY"] = 35866] = "TEXTURE_2D_ARRAY";
GL_TARGETS2[GL_TARGETS2["TEXTURE_CUBE_MAP_POSITIVE_X"] = 34069] = "TEXTURE_CUBE_MAP_POSITIVE_X";
GL_TARGETS2[GL_TARGETS2["TEXTURE_CUBE_MAP_NEGATIVE_X"] = 34070] = "TEXTURE_CUBE_MAP_NEGATIVE_X";
GL_TARGETS2[GL_TARGETS2["TEXTURE_CUBE_MAP_POSITIVE_Y"] = 34071] = "TEXTURE_CUBE_MAP_POSITIVE_Y";
GL_TARGETS2[GL_TARGETS2["TEXTURE_CUBE_MAP_NEGATIVE_Y"] = 34072] = "TEXTURE_CUBE_MAP_NEGATIVE_Y";
GL_TARGETS2[GL_TARGETS2["TEXTURE_CUBE_MAP_POSITIVE_Z"] = 34073] = "TEXTURE_CUBE_MAP_POSITIVE_Z";
GL_TARGETS2[GL_TARGETS2["TEXTURE_CUBE_MAP_NEGATIVE_Z"] = 34074] = "TEXTURE_CUBE_MAP_NEGATIVE_Z";
return GL_TARGETS2;
})(GL_TARGETS || {});
var GL_WRAP_MODES = /* @__PURE__ */ ((GL_WRAP_MODES2) => {
GL_WRAP_MODES2[GL_WRAP_MODES2["CLAMP"] = 33071] = "CLAMP";
GL_WRAP_MODES2[GL_WRAP_MODES2["REPEAT"] = 10497] = "REPEAT";
GL_WRAP_MODES2[GL_WRAP_MODES2["MIRRORED_REPEAT"] = 33648] = "MIRRORED_REPEAT";
return GL_WRAP_MODES2;
})(GL_WRAP_MODES || {});
var GL_TYPES = /* @__PURE__ */ ((GL_TYPES2) => {
GL_TYPES2[GL_TYPES2["UNSIGNED_BYTE"] = 5121] = "UNSIGNED_BYTE";
GL_TYPES2[GL_TYPES2["UNSIGNED_SHORT"] = 5123] = "UNSIGNED_SHORT";
GL_TYPES2[GL_TYPES2["UNSIGNED_SHORT_5_6_5"] = 33635] = "UNSIGNED_SHORT_5_6_5";
GL_TYPES2[GL_TYPES2["UNSIGNED_SHORT_4_4_4_4"] = 32819] = "UNSIGNED_SHORT_4_4_4_4";
GL_TYPES2[GL_TYPES2["UNSIGNED_SHORT_5_5_5_1"] = 32820] = "UNSIGNED_SHORT_5_5_5_1";
GL_TYPES2[GL_TYPES2["UNSIGNED_INT"] = 5125] = "UNSIGNED_INT";
GL_TYPES2[GL_TYPES2["UNSIGNED_INT_10F_11F_11F_REV"] = 35899] = "UNSIGNED_INT_10F_11F_11F_REV";
GL_TYPES2[GL_TYPES2["UNSIGNED_INT_2_10_10_10_REV"] = 33640] = "UNSIGNED_INT_2_10_10_10_REV";
GL_TYPES2[GL_TYPES2["UNSIGNED_INT_24_8"] = 34042] = "UNSIGNED_INT_24_8";
GL_TYPES2[GL_TYPES2["UNSIGNED_INT_5_9_9_9_REV"] = 35902] = "UNSIGNED_INT_5_9_9_9_REV";
GL_TYPES2[GL_TYPES2["BYTE"] = 5120] = "BYTE";
GL_TYPES2[GL_TYPES2["SHORT"] = 5122] = "SHORT";
GL_TYPES2[GL_TYPES2["INT"] = 5124] = "INT";
GL_TYPES2[GL_TYPES2["FLOAT"] = 5126] = "FLOAT";
GL_TYPES2[GL_TYPES2["FLOAT_32_UNSIGNED_INT_24_8_REV"] = 36269] = "FLOAT_32_UNSIGNED_INT_24_8_REV";
GL_TYPES2[GL_TYPES2["HALF_FLOAT"] = 36193] = "HALF_FLOAT";
return GL_TYPES2;
})(GL_TYPES || {});
export { GL_FORMATS, GL_TARGETS, GL_TYPES, GL_WRAP_MODES };
//# sourceMappingURL=const.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,7 @@
import type { TextureSource } from '../../../shared/texture/sources/TextureSource';
import type { GlRenderingContext } from '../../context/GlRenderingContext';
import type { GlTexture } from '../GlTexture';
export interface GLTextureUploader {
id: string;
upload(source: TextureSource, glTexture: GlTexture, gl: GlRenderingContext, webGLVersion: number): void;
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,2 @@
import type { GLTextureUploader } from './GLTextureUploader';
export declare const glUploadBufferImageResource: GLTextureUploader;

View File

@@ -0,0 +1,38 @@
'use strict';
"use strict";
const glUploadBufferImageResource = {
id: "buffer",
upload(source, glTexture, gl) {
if (glTexture.width === source.width || glTexture.height === source.height) {
gl.texSubImage2D(
gl.TEXTURE_2D,
0,
0,
0,
source.width,
source.height,
glTexture.format,
glTexture.type,
source.resource
);
} else {
gl.texImage2D(
glTexture.target,
0,
glTexture.internalFormat,
source.width,
source.height,
0,
glTexture.format,
glTexture.type,
source.resource
);
}
glTexture.width = source.width;
glTexture.height = source.height;
}
};
exports.glUploadBufferImageResource = glUploadBufferImageResource;
//# sourceMappingURL=glUploadBufferImageResource.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"glUploadBufferImageResource.js","sources":["../../../../../../src/rendering/renderers/gl/texture/uploaders/glUploadBufferImageResource.ts"],"sourcesContent":["import type { TextureSource } from '../../../shared/texture/sources/TextureSource';\nimport type { GlRenderingContext } from '../../context/GlRenderingContext';\nimport type { GlTexture } from '../GlTexture';\nimport type { GLTextureUploader } from './GLTextureUploader';\n\nexport const glUploadBufferImageResource = {\n\n id: 'buffer',\n\n upload(source: TextureSource, glTexture: GlTexture, gl: GlRenderingContext)\n {\n if (glTexture.width === source.width || glTexture.height === source.height)\n {\n gl.texSubImage2D(\n gl.TEXTURE_2D,\n 0,\n 0,\n 0,\n source.width,\n source.height,\n glTexture.format,\n glTexture.type,\n source.resource\n );\n }\n else\n {\n gl.texImage2D(\n glTexture.target,\n 0,\n glTexture.internalFormat,\n source.width,\n source.height,\n 0,\n glTexture.format,\n glTexture.type,\n source.resource\n );\n }\n\n glTexture.width = source.width;\n glTexture.height = source.height;\n }\n} as GLTextureUploader;\n\n"],"names":[],"mappings":";;;AAKO,MAAM,2BAA8B,GAAA;AAAA,EAEvC,EAAI,EAAA,QAAA;AAAA,EAEJ,MAAA,CAAO,MAAuB,EAAA,SAAA,EAAsB,EACpD,EAAA;AACI,IAAA,IAAI,UAAU,KAAU,KAAA,MAAA,CAAO,SAAS,SAAU,CAAA,MAAA,KAAW,OAAO,MACpE,EAAA;AACI,MAAG,EAAA,CAAA,aAAA;AAAA,QACC,EAAG,CAAA,UAAA;AAAA,QACH,CAAA;AAAA,QACA,CAAA;AAAA,QACA,CAAA;AAAA,QACA,MAAO,CAAA,KAAA;AAAA,QACP,MAAO,CAAA,MAAA;AAAA,QACP,SAAU,CAAA,MAAA;AAAA,QACV,SAAU,CAAA,IAAA;AAAA,QACV,MAAO,CAAA,QAAA;AAAA,OACX,CAAA;AAAA,KAGJ,MAAA;AACI,MAAG,EAAA,CAAA,UAAA;AAAA,QACC,SAAU,CAAA,MAAA;AAAA,QACV,CAAA;AAAA,QACA,SAAU,CAAA,cAAA;AAAA,QACV,MAAO,CAAA,KAAA;AAAA,QACP,MAAO,CAAA,MAAA;AAAA,QACP,CAAA;AAAA,QACA,SAAU,CAAA,MAAA;AAAA,QACV,SAAU,CAAA,IAAA;AAAA,QACV,MAAO,CAAA,QAAA;AAAA,OACX,CAAA;AAAA,KACJ;AAEA,IAAA,SAAA,CAAU,QAAQ,MAAO,CAAA,KAAA,CAAA;AACzB,IAAA,SAAA,CAAU,SAAS,MAAO,CAAA,MAAA,CAAA;AAAA,GAC9B;AACJ;;;;"}

View File

@@ -0,0 +1,36 @@
"use strict";
const glUploadBufferImageResource = {
id: "buffer",
upload(source, glTexture, gl) {
if (glTexture.width === source.width || glTexture.height === source.height) {
gl.texSubImage2D(
gl.TEXTURE_2D,
0,
0,
0,
source.width,
source.height,
glTexture.format,
glTexture.type,
source.resource
);
} else {
gl.texImage2D(
glTexture.target,
0,
glTexture.internalFormat,
source.width,
source.height,
0,
glTexture.format,
glTexture.type,
source.resource
);
}
glTexture.width = source.width;
glTexture.height = source.height;
}
};
export { glUploadBufferImageResource };
//# sourceMappingURL=glUploadBufferImageResource.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"glUploadBufferImageResource.mjs","sources":["../../../../../../src/rendering/renderers/gl/texture/uploaders/glUploadBufferImageResource.ts"],"sourcesContent":["import type { TextureSource } from '../../../shared/texture/sources/TextureSource';\nimport type { GlRenderingContext } from '../../context/GlRenderingContext';\nimport type { GlTexture } from '../GlTexture';\nimport type { GLTextureUploader } from './GLTextureUploader';\n\nexport const glUploadBufferImageResource = {\n\n id: 'buffer',\n\n upload(source: TextureSource, glTexture: GlTexture, gl: GlRenderingContext)\n {\n if (glTexture.width === source.width || glTexture.height === source.height)\n {\n gl.texSubImage2D(\n gl.TEXTURE_2D,\n 0,\n 0,\n 0,\n source.width,\n source.height,\n glTexture.format,\n glTexture.type,\n source.resource\n );\n }\n else\n {\n gl.texImage2D(\n glTexture.target,\n 0,\n glTexture.internalFormat,\n source.width,\n source.height,\n 0,\n glTexture.format,\n glTexture.type,\n source.resource\n );\n }\n\n glTexture.width = source.width;\n glTexture.height = source.height;\n }\n} as GLTextureUploader;\n\n"],"names":[],"mappings":";AAKO,MAAM,2BAA8B,GAAA;AAAA,EAEvC,EAAI,EAAA,QAAA;AAAA,EAEJ,MAAA,CAAO,MAAuB,EAAA,SAAA,EAAsB,EACpD,EAAA;AACI,IAAA,IAAI,UAAU,KAAU,KAAA,MAAA,CAAO,SAAS,SAAU,CAAA,MAAA,KAAW,OAAO,MACpE,EAAA;AACI,MAAG,EAAA,CAAA,aAAA;AAAA,QACC,EAAG,CAAA,UAAA;AAAA,QACH,CAAA;AAAA,QACA,CAAA;AAAA,QACA,CAAA;AAAA,QACA,MAAO,CAAA,KAAA;AAAA,QACP,MAAO,CAAA,MAAA;AAAA,QACP,SAAU,CAAA,MAAA;AAAA,QACV,SAAU,CAAA,IAAA;AAAA,QACV,MAAO,CAAA,QAAA;AAAA,OACX,CAAA;AAAA,KAGJ,MAAA;AACI,MAAG,EAAA,CAAA,UAAA;AAAA,QACC,SAAU,CAAA,MAAA;AAAA,QACV,CAAA;AAAA,QACA,SAAU,CAAA,cAAA;AAAA,QACV,MAAO,CAAA,KAAA;AAAA,QACP,MAAO,CAAA,MAAA;AAAA,QACP,CAAA;AAAA,QACA,SAAU,CAAA,MAAA;AAAA,QACV,SAAU,CAAA,IAAA;AAAA,QACV,MAAO,CAAA,QAAA;AAAA,OACX,CAAA;AAAA,KACJ;AAEA,IAAA,SAAA,CAAU,QAAQ,MAAO,CAAA,KAAA,CAAA;AACzB,IAAA,SAAA,CAAU,SAAS,MAAO,CAAA,MAAA,CAAA;AAAA,GAC9B;AACJ;;;;"}

View File

@@ -0,0 +1,2 @@
import type { GLTextureUploader } from './GLTextureUploader';
export declare const glUploadCompressedTextureResource: GLTextureUploader;

View File

@@ -0,0 +1,101 @@
'use strict';
"use strict";
const compressedFormatMap = {
"bc1-rgba-unorm": true,
"bc1-rgba-unorm-srgb": true,
"bc2-rgba-unorm": true,
"bc2-rgba-unorm-srgb": true,
"bc3-rgba-unorm": true,
"bc3-rgba-unorm-srgb": true,
"bc4-r-unorm": true,
"bc4-r-snorm": true,
"bc5-rg-unorm": true,
"bc5-rg-snorm": true,
"bc6h-rgb-ufloat": true,
"bc6h-rgb-float": true,
"bc7-rgba-unorm": true,
"bc7-rgba-unorm-srgb": true,
// ETC2 compressed formats usable if "texture-compression-etc2" is both
// supported by the device/user agent and enabled in requestDevice.
"etc2-rgb8unorm": true,
"etc2-rgb8unorm-srgb": true,
"etc2-rgb8a1unorm": true,
"etc2-rgb8a1unorm-srgb": true,
"etc2-rgba8unorm": true,
"etc2-rgba8unorm-srgb": true,
"eac-r11unorm": true,
"eac-r11snorm": true,
"eac-rg11unorm": true,
"eac-rg11snorm": true,
// ASTC compressed formats usable if "texture-compression-astc" is both
// supported by the device/user agent and enabled in requestDevice.
"astc-4x4-unorm": true,
"astc-4x4-unorm-srgb": true,
"astc-5x4-unorm": true,
"astc-5x4-unorm-srgb": true,
"astc-5x5-unorm": true,
"astc-5x5-unorm-srgb": true,
"astc-6x5-unorm": true,
"astc-6x5-unorm-srgb": true,
"astc-6x6-unorm": true,
"astc-6x6-unorm-srgb": true,
"astc-8x5-unorm": true,
"astc-8x5-unorm-srgb": true,
"astc-8x6-unorm": true,
"astc-8x6-unorm-srgb": true,
"astc-8x8-unorm": true,
"astc-8x8-unorm-srgb": true,
"astc-10x5-unorm": true,
"astc-10x5-unorm-srgb": true,
"astc-10x6-unorm": true,
"astc-10x6-unorm-srgb": true,
"astc-10x8-unorm": true,
"astc-10x8-unorm-srgb": true,
"astc-10x10-unorm": true,
"astc-10x10-unorm-srgb": true,
"astc-12x10-unorm": true,
"astc-12x10-unorm-srgb": true,
"astc-12x12-unorm": true,
"astc-12x12-unorm-srgb": true
};
const glUploadCompressedTextureResource = {
id: "compressed",
upload(source, glTexture, gl) {
gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4);
let mipWidth = source.pixelWidth;
let mipHeight = source.pixelHeight;
const compressed = !!compressedFormatMap[source.format];
for (let i = 0; i < source.resource.length; i++) {
const levelBuffer = source.resource[i];
if (compressed) {
gl.compressedTexImage2D(
gl.TEXTURE_2D,
i,
glTexture.internalFormat,
mipWidth,
mipHeight,
0,
levelBuffer
);
} else {
gl.texImage2D(
gl.TEXTURE_2D,
i,
glTexture.internalFormat,
mipWidth,
mipHeight,
0,
glTexture.format,
glTexture.type,
levelBuffer
);
}
mipWidth = Math.max(mipWidth >> 1, 1);
mipHeight = Math.max(mipHeight >> 1, 1);
}
}
};
exports.glUploadCompressedTextureResource = glUploadCompressedTextureResource;
//# sourceMappingURL=glUploadCompressedTextureResource.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,99 @@
"use strict";
const compressedFormatMap = {
"bc1-rgba-unorm": true,
"bc1-rgba-unorm-srgb": true,
"bc2-rgba-unorm": true,
"bc2-rgba-unorm-srgb": true,
"bc3-rgba-unorm": true,
"bc3-rgba-unorm-srgb": true,
"bc4-r-unorm": true,
"bc4-r-snorm": true,
"bc5-rg-unorm": true,
"bc5-rg-snorm": true,
"bc6h-rgb-ufloat": true,
"bc6h-rgb-float": true,
"bc7-rgba-unorm": true,
"bc7-rgba-unorm-srgb": true,
// ETC2 compressed formats usable if "texture-compression-etc2" is both
// supported by the device/user agent and enabled in requestDevice.
"etc2-rgb8unorm": true,
"etc2-rgb8unorm-srgb": true,
"etc2-rgb8a1unorm": true,
"etc2-rgb8a1unorm-srgb": true,
"etc2-rgba8unorm": true,
"etc2-rgba8unorm-srgb": true,
"eac-r11unorm": true,
"eac-r11snorm": true,
"eac-rg11unorm": true,
"eac-rg11snorm": true,
// ASTC compressed formats usable if "texture-compression-astc" is both
// supported by the device/user agent and enabled in requestDevice.
"astc-4x4-unorm": true,
"astc-4x4-unorm-srgb": true,
"astc-5x4-unorm": true,
"astc-5x4-unorm-srgb": true,
"astc-5x5-unorm": true,
"astc-5x5-unorm-srgb": true,
"astc-6x5-unorm": true,
"astc-6x5-unorm-srgb": true,
"astc-6x6-unorm": true,
"astc-6x6-unorm-srgb": true,
"astc-8x5-unorm": true,
"astc-8x5-unorm-srgb": true,
"astc-8x6-unorm": true,
"astc-8x6-unorm-srgb": true,
"astc-8x8-unorm": true,
"astc-8x8-unorm-srgb": true,
"astc-10x5-unorm": true,
"astc-10x5-unorm-srgb": true,
"astc-10x6-unorm": true,
"astc-10x6-unorm-srgb": true,
"astc-10x8-unorm": true,
"astc-10x8-unorm-srgb": true,
"astc-10x10-unorm": true,
"astc-10x10-unorm-srgb": true,
"astc-12x10-unorm": true,
"astc-12x10-unorm-srgb": true,
"astc-12x12-unorm": true,
"astc-12x12-unorm-srgb": true
};
const glUploadCompressedTextureResource = {
id: "compressed",
upload(source, glTexture, gl) {
gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4);
let mipWidth = source.pixelWidth;
let mipHeight = source.pixelHeight;
const compressed = !!compressedFormatMap[source.format];
for (let i = 0; i < source.resource.length; i++) {
const levelBuffer = source.resource[i];
if (compressed) {
gl.compressedTexImage2D(
gl.TEXTURE_2D,
i,
glTexture.internalFormat,
mipWidth,
mipHeight,
0,
levelBuffer
);
} else {
gl.texImage2D(
gl.TEXTURE_2D,
i,
glTexture.internalFormat,
mipWidth,
mipHeight,
0,
glTexture.format,
glTexture.type,
levelBuffer
);
}
mipWidth = Math.max(mipWidth >> 1, 1);
mipHeight = Math.max(mipHeight >> 1, 1);
}
}
};
export { glUploadCompressedTextureResource };
//# sourceMappingURL=glUploadCompressedTextureResource.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
import type { GLTextureUploader } from './GLTextureUploader';
export declare const glUploadImageResource: GLTextureUploader;

View File

@@ -0,0 +1,90 @@
'use strict';
"use strict";
const glUploadImageResource = {
id: "image",
upload(source, glTexture, gl, webGLVersion) {
const premultipliedAlpha = source.alphaMode === "premultiply-alpha-on-upload";
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, premultipliedAlpha);
const glWidth = glTexture.width;
const glHeight = glTexture.height;
const textureWidth = source.pixelWidth;
const textureHeight = source.pixelHeight;
const resourceWidth = source.resourceWidth;
const resourceHeight = source.resourceHeight;
if (resourceWidth < textureWidth || resourceHeight < textureHeight) {
if (glWidth !== textureWidth || glHeight !== textureHeight) {
gl.texImage2D(
glTexture.target,
0,
glTexture.internalFormat,
textureWidth,
textureHeight,
0,
glTexture.format,
glTexture.type,
null
);
}
if (webGLVersion === 2) {
gl.texSubImage2D(
gl.TEXTURE_2D,
0,
0,
0,
resourceWidth,
resourceHeight,
glTexture.format,
glTexture.type,
source.resource
);
} else {
gl.texSubImage2D(
gl.TEXTURE_2D,
0,
0,
0,
glTexture.format,
glTexture.type,
source.resource
);
}
} else if (glWidth === textureWidth || glHeight === textureHeight) {
gl.texSubImage2D(
gl.TEXTURE_2D,
0,
0,
0,
glTexture.format,
glTexture.type,
source.resource
);
} else if (webGLVersion === 2) {
gl.texImage2D(
glTexture.target,
0,
glTexture.internalFormat,
textureWidth,
textureHeight,
0,
glTexture.format,
glTexture.type,
source.resource
);
} else {
gl.texImage2D(
glTexture.target,
0,
glTexture.internalFormat,
glTexture.format,
glTexture.type,
source.resource
);
}
glTexture.width = textureWidth;
glTexture.height = textureHeight;
}
};
exports.glUploadImageResource = glUploadImageResource;
//# sourceMappingURL=glUploadImageResource.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,88 @@
"use strict";
const glUploadImageResource = {
id: "image",
upload(source, glTexture, gl, webGLVersion) {
const premultipliedAlpha = source.alphaMode === "premultiply-alpha-on-upload";
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, premultipliedAlpha);
const glWidth = glTexture.width;
const glHeight = glTexture.height;
const textureWidth = source.pixelWidth;
const textureHeight = source.pixelHeight;
const resourceWidth = source.resourceWidth;
const resourceHeight = source.resourceHeight;
if (resourceWidth < textureWidth || resourceHeight < textureHeight) {
if (glWidth !== textureWidth || glHeight !== textureHeight) {
gl.texImage2D(
glTexture.target,
0,
glTexture.internalFormat,
textureWidth,
textureHeight,
0,
glTexture.format,
glTexture.type,
null
);
}
if (webGLVersion === 2) {
gl.texSubImage2D(
gl.TEXTURE_2D,
0,
0,
0,
resourceWidth,
resourceHeight,
glTexture.format,
glTexture.type,
source.resource
);
} else {
gl.texSubImage2D(
gl.TEXTURE_2D,
0,
0,
0,
glTexture.format,
glTexture.type,
source.resource
);
}
} else if (glWidth === textureWidth || glHeight === textureHeight) {
gl.texSubImage2D(
gl.TEXTURE_2D,
0,
0,
0,
glTexture.format,
glTexture.type,
source.resource
);
} else if (webGLVersion === 2) {
gl.texImage2D(
glTexture.target,
0,
glTexture.internalFormat,
textureWidth,
textureHeight,
0,
glTexture.format,
glTexture.type,
source.resource
);
} else {
gl.texImage2D(
glTexture.target,
0,
glTexture.internalFormat,
glTexture.format,
glTexture.type,
source.resource
);
}
glTexture.width = textureWidth;
glTexture.height = textureHeight;
}
};
export { glUploadImageResource };
//# sourceMappingURL=glUploadImageResource.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
import type { GLTextureUploader } from './GLTextureUploader';
export declare const glUploadVideoResource: GLTextureUploader;

View File

@@ -0,0 +1,28 @@
'use strict';
var glUploadImageResource = require('./glUploadImageResource.js');
"use strict";
const glUploadVideoResource = {
id: "video",
upload(source, glTexture, gl, webGLVersion) {
if (!source.isValid) {
gl.texImage2D(
glTexture.target,
0,
glTexture.internalFormat,
1,
1,
0,
glTexture.format,
glTexture.type,
null
);
return;
}
glUploadImageResource.glUploadImageResource.upload(source, glTexture, gl, webGLVersion);
}
};
exports.glUploadVideoResource = glUploadVideoResource;
//# sourceMappingURL=glUploadVideoResource.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"glUploadVideoResource.js","sources":["../../../../../../src/rendering/renderers/gl/texture/uploaders/glUploadVideoResource.ts"],"sourcesContent":["import { glUploadImageResource } from './glUploadImageResource';\n\nimport type { VideoSource } from '../../../shared/texture/sources/VideoSource';\nimport type { GlRenderingContext } from '../../context/GlRenderingContext';\nimport type { GlTexture } from '../GlTexture';\nimport type { GLTextureUploader } from './GLTextureUploader';\n\nexport const glUploadVideoResource = {\n\n id: 'video',\n\n upload(source: VideoSource, glTexture: GlTexture, gl: GlRenderingContext, webGLVersion: number)\n {\n if (!source.isValid)\n {\n gl.texImage2D(\n glTexture.target,\n 0,\n glTexture.internalFormat,\n 1,\n 1,\n 0,\n glTexture.format,\n glTexture.type,\n null\n );\n\n return;\n }\n\n glUploadImageResource.upload(source, glTexture, gl, webGLVersion);\n }\n} as GLTextureUploader;\n\n"],"names":["glUploadImageResource"],"mappings":";;;;;AAOO,MAAM,qBAAwB,GAAA;AAAA,EAEjC,EAAI,EAAA,OAAA;AAAA,EAEJ,MAAO,CAAA,MAAA,EAAqB,SAAsB,EAAA,EAAA,EAAwB,YAC1E,EAAA;AACI,IAAI,IAAA,CAAC,OAAO,OACZ,EAAA;AACI,MAAG,EAAA,CAAA,UAAA;AAAA,QACC,SAAU,CAAA,MAAA;AAAA,QACV,CAAA;AAAA,QACA,SAAU,CAAA,cAAA;AAAA,QACV,CAAA;AAAA,QACA,CAAA;AAAA,QACA,CAAA;AAAA,QACA,SAAU,CAAA,MAAA;AAAA,QACV,SAAU,CAAA,IAAA;AAAA,QACV,IAAA;AAAA,OACJ,CAAA;AAEA,MAAA,OAAA;AAAA,KACJ;AAEA,IAAAA,2CAAA,CAAsB,MAAO,CAAA,MAAA,EAAQ,SAAW,EAAA,EAAA,EAAI,YAAY,CAAA,CAAA;AAAA,GACpE;AACJ;;;;"}

View File

@@ -0,0 +1,26 @@
import { glUploadImageResource } from './glUploadImageResource.mjs';
"use strict";
const glUploadVideoResource = {
id: "video",
upload(source, glTexture, gl, webGLVersion) {
if (!source.isValid) {
gl.texImage2D(
glTexture.target,
0,
glTexture.internalFormat,
1,
1,
0,
glTexture.format,
glTexture.type,
null
);
return;
}
glUploadImageResource.upload(source, glTexture, gl, webGLVersion);
}
};
export { glUploadVideoResource };
//# sourceMappingURL=glUploadVideoResource.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"glUploadVideoResource.mjs","sources":["../../../../../../src/rendering/renderers/gl/texture/uploaders/glUploadVideoResource.ts"],"sourcesContent":["import { glUploadImageResource } from './glUploadImageResource';\n\nimport type { VideoSource } from '../../../shared/texture/sources/VideoSource';\nimport type { GlRenderingContext } from '../../context/GlRenderingContext';\nimport type { GlTexture } from '../GlTexture';\nimport type { GLTextureUploader } from './GLTextureUploader';\n\nexport const glUploadVideoResource = {\n\n id: 'video',\n\n upload(source: VideoSource, glTexture: GlTexture, gl: GlRenderingContext, webGLVersion: number)\n {\n if (!source.isValid)\n {\n gl.texImage2D(\n glTexture.target,\n 0,\n glTexture.internalFormat,\n 1,\n 1,\n 0,\n glTexture.format,\n glTexture.type,\n null\n );\n\n return;\n }\n\n glUploadImageResource.upload(source, glTexture, gl, webGLVersion);\n }\n} as GLTextureUploader;\n\n"],"names":[],"mappings":";;;AAOO,MAAM,qBAAwB,GAAA;AAAA,EAEjC,EAAI,EAAA,OAAA;AAAA,EAEJ,MAAO,CAAA,MAAA,EAAqB,SAAsB,EAAA,EAAA,EAAwB,YAC1E,EAAA;AACI,IAAI,IAAA,CAAC,OAAO,OACZ,EAAA;AACI,MAAG,EAAA,CAAA,UAAA;AAAA,QACC,SAAU,CAAA,MAAA;AAAA,QACV,CAAA;AAAA,QACA,SAAU,CAAA,cAAA;AAAA,QACV,CAAA;AAAA,QACA,CAAA;AAAA,QACA,CAAA;AAAA,QACA,SAAU,CAAA,MAAA;AAAA,QACV,SAAU,CAAA,IAAA;AAAA,QACV,IAAA;AAAA,OACJ,CAAA;AAEA,MAAA,OAAA;AAAA,KACJ;AAEA,IAAA,qBAAA,CAAsB,MAAO,CAAA,MAAA,EAAQ,SAAW,EAAA,EAAA,EAAI,YAAY,CAAA,CAAA;AAAA,GACpE;AACJ;;;;"}

View File

@@ -0,0 +1,4 @@
import type { TextureStyle } from '../../../shared/texture/TextureStyle';
export declare function applyStyleParams(style: TextureStyle, gl: WebGL2RenderingContext, mipmaps: boolean, anisotropicExt: EXT_texture_filter_anisotropic, glFunctionName: 'samplerParameteri' | 'texParameteri', firstParam: 3553 | WebGLSampler, forceClamp: boolean,
/** if true we can skip setting certain values if the values is the same as the default gl values */
firstCreation: boolean): void;

View File

@@ -0,0 +1,38 @@
'use strict';
var pixiToGlMaps = require('./pixiToGlMaps.js');
"use strict";
function applyStyleParams(style, gl, mipmaps, anisotropicExt, glFunctionName, firstParam, forceClamp, firstCreation) {
const castParam = firstParam;
if (!firstCreation || style.addressModeU !== "repeat" || style.addressModeV !== "repeat" || style.addressModeW !== "repeat") {
const wrapModeS = pixiToGlMaps.wrapModeToGlAddress[forceClamp ? "clamp-to-edge" : style.addressModeU];
const wrapModeT = pixiToGlMaps.wrapModeToGlAddress[forceClamp ? "clamp-to-edge" : style.addressModeV];
const wrapModeR = pixiToGlMaps.wrapModeToGlAddress[forceClamp ? "clamp-to-edge" : style.addressModeW];
gl[glFunctionName](castParam, gl.TEXTURE_WRAP_S, wrapModeS);
gl[glFunctionName](castParam, gl.TEXTURE_WRAP_T, wrapModeT);
if (gl.TEXTURE_WRAP_R)
gl[glFunctionName](castParam, gl.TEXTURE_WRAP_R, wrapModeR);
}
if (!firstCreation || style.magFilter !== "linear") {
gl[glFunctionName](castParam, gl.TEXTURE_MAG_FILTER, pixiToGlMaps.scaleModeToGlFilter[style.magFilter]);
}
if (mipmaps) {
if (!firstCreation || style.mipmapFilter !== "linear") {
const glFilterMode = pixiToGlMaps.mipmapScaleModeToGlFilter[style.minFilter][style.mipmapFilter];
gl[glFunctionName](castParam, gl.TEXTURE_MIN_FILTER, glFilterMode);
}
} else {
gl[glFunctionName](castParam, gl.TEXTURE_MIN_FILTER, pixiToGlMaps.scaleModeToGlFilter[style.minFilter]);
}
if (anisotropicExt && style.maxAnisotropy > 1) {
const level = Math.min(style.maxAnisotropy, gl.getParameter(anisotropicExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT));
gl[glFunctionName](castParam, anisotropicExt.TEXTURE_MAX_ANISOTROPY_EXT, level);
}
if (style.compare) {
gl[glFunctionName](castParam, gl.TEXTURE_COMPARE_FUNC, pixiToGlMaps.compareModeToGlCompare[style.compare]);
}
}
exports.applyStyleParams = applyStyleParams;
//# sourceMappingURL=applyStyleParams.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"applyStyleParams.js","sources":["../../../../../../src/rendering/renderers/gl/texture/utils/applyStyleParams.ts"],"sourcesContent":["import {\n compareModeToGlCompare,\n mipmapScaleModeToGlFilter,\n scaleModeToGlFilter,\n wrapModeToGlAddress\n} from './pixiToGlMaps';\n\nimport type { TextureStyle } from '../../../shared/texture/TextureStyle';\n\nexport function applyStyleParams(\n style: TextureStyle,\n gl: WebGL2RenderingContext,\n mipmaps: boolean,\n // eslint-disable-next-line camelcase\n anisotropicExt: EXT_texture_filter_anisotropic,\n glFunctionName: 'samplerParameteri' | 'texParameteri',\n firstParam: 3553 | WebGLSampler,\n forceClamp: boolean,\n /** if true we can skip setting certain values if the values is the same as the default gl values */\n firstCreation: boolean\n)\n{\n const castParam = firstParam as 3553;\n\n if (!firstCreation\n || style.addressModeU !== 'repeat'\n || style.addressModeV !== 'repeat'\n || style.addressModeW !== 'repeat'\n )\n {\n // 1. set the wrapping mode\n const wrapModeS = wrapModeToGlAddress[forceClamp ? 'clamp-to-edge' : style.addressModeU];\n const wrapModeT = wrapModeToGlAddress[forceClamp ? 'clamp-to-edge' : style.addressModeV];\n const wrapModeR = wrapModeToGlAddress[forceClamp ? 'clamp-to-edge' : style.addressModeW];\n\n gl[glFunctionName](castParam, gl.TEXTURE_WRAP_S, wrapModeS);\n gl[glFunctionName](castParam, gl.TEXTURE_WRAP_T, wrapModeT);\n\n // does not exist in webGL1\n if (gl.TEXTURE_WRAP_R) gl[glFunctionName](castParam, gl.TEXTURE_WRAP_R, wrapModeR);\n }\n\n if (!firstCreation || style.magFilter !== 'linear')\n {\n // 2. set the filtering mode\n gl[glFunctionName](castParam, gl.TEXTURE_MAG_FILTER, scaleModeToGlFilter[style.magFilter]);\n }\n\n // assuming the currently bound texture is the one we want to set the filter for\n // the only smelly part of this code, WebGPU is much better here :P\n if (mipmaps)\n {\n if (!firstCreation || style.mipmapFilter !== 'linear')\n {\n const glFilterMode = mipmapScaleModeToGlFilter[style.minFilter][style.mipmapFilter];\n\n gl[glFunctionName](castParam, gl.TEXTURE_MIN_FILTER, glFilterMode);\n }\n }\n\n else\n {\n gl[glFunctionName](castParam, gl.TEXTURE_MIN_FILTER, scaleModeToGlFilter[style.minFilter]);\n }\n\n // 3. set the anisotropy\n if (anisotropicExt && style.maxAnisotropy > 1)\n {\n const level = Math.min(style.maxAnisotropy, gl.getParameter(anisotropicExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT));\n\n gl[glFunctionName](castParam, anisotropicExt.TEXTURE_MAX_ANISOTROPY_EXT, level);\n }\n\n // 4. set the compare mode\n if (style.compare)\n {\n gl[glFunctionName](castParam, gl.TEXTURE_COMPARE_FUNC, compareModeToGlCompare[style.compare]);\n }\n}\n"],"names":["wrapModeToGlAddress","scaleModeToGlFilter","mipmapScaleModeToGlFilter","compareModeToGlCompare"],"mappings":";;;;;AASgB,SAAA,gBAAA,CACZ,OACA,EACA,EAAA,OAAA,EAEA,gBACA,cACA,EAAA,UAAA,EACA,YAEA,aAEJ,EAAA;AACI,EAAA,MAAM,SAAY,GAAA,UAAA,CAAA;AAElB,EAAI,IAAA,CAAC,aACE,IAAA,KAAA,CAAM,YAAiB,KAAA,QAAA,IACvB,MAAM,YAAiB,KAAA,QAAA,IACvB,KAAM,CAAA,YAAA,KAAiB,QAE9B,EAAA;AAEI,IAAA,MAAM,SAAY,GAAAA,gCAAA,CAAoB,UAAa,GAAA,eAAA,GAAkB,MAAM,YAAY,CAAA,CAAA;AACvF,IAAA,MAAM,SAAY,GAAAA,gCAAA,CAAoB,UAAa,GAAA,eAAA,GAAkB,MAAM,YAAY,CAAA,CAAA;AACvF,IAAA,MAAM,SAAY,GAAAA,gCAAA,CAAoB,UAAa,GAAA,eAAA,GAAkB,MAAM,YAAY,CAAA,CAAA;AAEvF,IAAA,EAAA,CAAG,cAAc,CAAA,CAAE,SAAW,EAAA,EAAA,CAAG,gBAAgB,SAAS,CAAA,CAAA;AAC1D,IAAA,EAAA,CAAG,cAAc,CAAA,CAAE,SAAW,EAAA,EAAA,CAAG,gBAAgB,SAAS,CAAA,CAAA;AAG1D,IAAA,IAAI,EAAG,CAAA,cAAA;AAAgB,MAAA,EAAA,CAAG,cAAc,CAAA,CAAE,SAAW,EAAA,EAAA,CAAG,gBAAgB,SAAS,CAAA,CAAA;AAAA,GACrF;AAEA,EAAA,IAAI,CAAC,aAAA,IAAiB,KAAM,CAAA,SAAA,KAAc,QAC1C,EAAA;AAEI,IAAG,EAAA,CAAA,cAAc,EAAE,SAAW,EAAA,EAAA,CAAG,oBAAoBC,gCAAoB,CAAA,KAAA,CAAM,SAAS,CAAC,CAAA,CAAA;AAAA,GAC7F;AAIA,EAAA,IAAI,OACJ,EAAA;AACI,IAAA,IAAI,CAAC,aAAA,IAAiB,KAAM,CAAA,YAAA,KAAiB,QAC7C,EAAA;AACI,MAAA,MAAM,eAAeC,sCAA0B,CAAA,KAAA,CAAM,SAAS,CAAA,CAAE,MAAM,YAAY,CAAA,CAAA;AAElF,MAAA,EAAA,CAAG,cAAc,CAAA,CAAE,SAAW,EAAA,EAAA,CAAG,oBAAoB,YAAY,CAAA,CAAA;AAAA,KACrE;AAAA,GAIJ,MAAA;AACI,IAAG,EAAA,CAAA,cAAc,EAAE,SAAW,EAAA,EAAA,CAAG,oBAAoBD,gCAAoB,CAAA,KAAA,CAAM,SAAS,CAAC,CAAA,CAAA;AAAA,GAC7F;AAGA,EAAI,IAAA,cAAA,IAAkB,KAAM,CAAA,aAAA,GAAgB,CAC5C,EAAA;AACI,IAAM,MAAA,KAAA,GAAQ,KAAK,GAAI,CAAA,KAAA,CAAM,eAAe,EAAG,CAAA,YAAA,CAAa,cAAe,CAAA,8BAA8B,CAAC,CAAA,CAAA;AAE1G,IAAA,EAAA,CAAG,cAAc,CAAA,CAAE,SAAW,EAAA,cAAA,CAAe,4BAA4B,KAAK,CAAA,CAAA;AAAA,GAClF;AAGA,EAAA,IAAI,MAAM,OACV,EAAA;AACI,IAAG,EAAA,CAAA,cAAc,EAAE,SAAW,EAAA,EAAA,CAAG,sBAAsBE,mCAAuB,CAAA,KAAA,CAAM,OAAO,CAAC,CAAA,CAAA;AAAA,GAChG;AACJ;;;;"}

View File

@@ -0,0 +1,36 @@
import { wrapModeToGlAddress, scaleModeToGlFilter, mipmapScaleModeToGlFilter, compareModeToGlCompare } from './pixiToGlMaps.mjs';
"use strict";
function applyStyleParams(style, gl, mipmaps, anisotropicExt, glFunctionName, firstParam, forceClamp, firstCreation) {
const castParam = firstParam;
if (!firstCreation || style.addressModeU !== "repeat" || style.addressModeV !== "repeat" || style.addressModeW !== "repeat") {
const wrapModeS = wrapModeToGlAddress[forceClamp ? "clamp-to-edge" : style.addressModeU];
const wrapModeT = wrapModeToGlAddress[forceClamp ? "clamp-to-edge" : style.addressModeV];
const wrapModeR = wrapModeToGlAddress[forceClamp ? "clamp-to-edge" : style.addressModeW];
gl[glFunctionName](castParam, gl.TEXTURE_WRAP_S, wrapModeS);
gl[glFunctionName](castParam, gl.TEXTURE_WRAP_T, wrapModeT);
if (gl.TEXTURE_WRAP_R)
gl[glFunctionName](castParam, gl.TEXTURE_WRAP_R, wrapModeR);
}
if (!firstCreation || style.magFilter !== "linear") {
gl[glFunctionName](castParam, gl.TEXTURE_MAG_FILTER, scaleModeToGlFilter[style.magFilter]);
}
if (mipmaps) {
if (!firstCreation || style.mipmapFilter !== "linear") {
const glFilterMode = mipmapScaleModeToGlFilter[style.minFilter][style.mipmapFilter];
gl[glFunctionName](castParam, gl.TEXTURE_MIN_FILTER, glFilterMode);
}
} else {
gl[glFunctionName](castParam, gl.TEXTURE_MIN_FILTER, scaleModeToGlFilter[style.minFilter]);
}
if (anisotropicExt && style.maxAnisotropy > 1) {
const level = Math.min(style.maxAnisotropy, gl.getParameter(anisotropicExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT));
gl[glFunctionName](castParam, anisotropicExt.TEXTURE_MAX_ANISOTROPY_EXT, level);
}
if (style.compare) {
gl[glFunctionName](castParam, gl.TEXTURE_COMPARE_FUNC, compareModeToGlCompare[style.compare]);
}
}
export { applyStyleParams };
//# sourceMappingURL=applyStyleParams.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"applyStyleParams.mjs","sources":["../../../../../../src/rendering/renderers/gl/texture/utils/applyStyleParams.ts"],"sourcesContent":["import {\n compareModeToGlCompare,\n mipmapScaleModeToGlFilter,\n scaleModeToGlFilter,\n wrapModeToGlAddress\n} from './pixiToGlMaps';\n\nimport type { TextureStyle } from '../../../shared/texture/TextureStyle';\n\nexport function applyStyleParams(\n style: TextureStyle,\n gl: WebGL2RenderingContext,\n mipmaps: boolean,\n // eslint-disable-next-line camelcase\n anisotropicExt: EXT_texture_filter_anisotropic,\n glFunctionName: 'samplerParameteri' | 'texParameteri',\n firstParam: 3553 | WebGLSampler,\n forceClamp: boolean,\n /** if true we can skip setting certain values if the values is the same as the default gl values */\n firstCreation: boolean\n)\n{\n const castParam = firstParam as 3553;\n\n if (!firstCreation\n || style.addressModeU !== 'repeat'\n || style.addressModeV !== 'repeat'\n || style.addressModeW !== 'repeat'\n )\n {\n // 1. set the wrapping mode\n const wrapModeS = wrapModeToGlAddress[forceClamp ? 'clamp-to-edge' : style.addressModeU];\n const wrapModeT = wrapModeToGlAddress[forceClamp ? 'clamp-to-edge' : style.addressModeV];\n const wrapModeR = wrapModeToGlAddress[forceClamp ? 'clamp-to-edge' : style.addressModeW];\n\n gl[glFunctionName](castParam, gl.TEXTURE_WRAP_S, wrapModeS);\n gl[glFunctionName](castParam, gl.TEXTURE_WRAP_T, wrapModeT);\n\n // does not exist in webGL1\n if (gl.TEXTURE_WRAP_R) gl[glFunctionName](castParam, gl.TEXTURE_WRAP_R, wrapModeR);\n }\n\n if (!firstCreation || style.magFilter !== 'linear')\n {\n // 2. set the filtering mode\n gl[glFunctionName](castParam, gl.TEXTURE_MAG_FILTER, scaleModeToGlFilter[style.magFilter]);\n }\n\n // assuming the currently bound texture is the one we want to set the filter for\n // the only smelly part of this code, WebGPU is much better here :P\n if (mipmaps)\n {\n if (!firstCreation || style.mipmapFilter !== 'linear')\n {\n const glFilterMode = mipmapScaleModeToGlFilter[style.minFilter][style.mipmapFilter];\n\n gl[glFunctionName](castParam, gl.TEXTURE_MIN_FILTER, glFilterMode);\n }\n }\n\n else\n {\n gl[glFunctionName](castParam, gl.TEXTURE_MIN_FILTER, scaleModeToGlFilter[style.minFilter]);\n }\n\n // 3. set the anisotropy\n if (anisotropicExt && style.maxAnisotropy > 1)\n {\n const level = Math.min(style.maxAnisotropy, gl.getParameter(anisotropicExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT));\n\n gl[glFunctionName](castParam, anisotropicExt.TEXTURE_MAX_ANISOTROPY_EXT, level);\n }\n\n // 4. set the compare mode\n if (style.compare)\n {\n gl[glFunctionName](castParam, gl.TEXTURE_COMPARE_FUNC, compareModeToGlCompare[style.compare]);\n }\n}\n"],"names":[],"mappings":";;;AASgB,SAAA,gBAAA,CACZ,OACA,EACA,EAAA,OAAA,EAEA,gBACA,cACA,EAAA,UAAA,EACA,YAEA,aAEJ,EAAA;AACI,EAAA,MAAM,SAAY,GAAA,UAAA,CAAA;AAElB,EAAI,IAAA,CAAC,aACE,IAAA,KAAA,CAAM,YAAiB,KAAA,QAAA,IACvB,MAAM,YAAiB,KAAA,QAAA,IACvB,KAAM,CAAA,YAAA,KAAiB,QAE9B,EAAA;AAEI,IAAA,MAAM,SAAY,GAAA,mBAAA,CAAoB,UAAa,GAAA,eAAA,GAAkB,MAAM,YAAY,CAAA,CAAA;AACvF,IAAA,MAAM,SAAY,GAAA,mBAAA,CAAoB,UAAa,GAAA,eAAA,GAAkB,MAAM,YAAY,CAAA,CAAA;AACvF,IAAA,MAAM,SAAY,GAAA,mBAAA,CAAoB,UAAa,GAAA,eAAA,GAAkB,MAAM,YAAY,CAAA,CAAA;AAEvF,IAAA,EAAA,CAAG,cAAc,CAAA,CAAE,SAAW,EAAA,EAAA,CAAG,gBAAgB,SAAS,CAAA,CAAA;AAC1D,IAAA,EAAA,CAAG,cAAc,CAAA,CAAE,SAAW,EAAA,EAAA,CAAG,gBAAgB,SAAS,CAAA,CAAA;AAG1D,IAAA,IAAI,EAAG,CAAA,cAAA;AAAgB,MAAA,EAAA,CAAG,cAAc,CAAA,CAAE,SAAW,EAAA,EAAA,CAAG,gBAAgB,SAAS,CAAA,CAAA;AAAA,GACrF;AAEA,EAAA,IAAI,CAAC,aAAA,IAAiB,KAAM,CAAA,SAAA,KAAc,QAC1C,EAAA;AAEI,IAAG,EAAA,CAAA,cAAc,EAAE,SAAW,EAAA,EAAA,CAAG,oBAAoB,mBAAoB,CAAA,KAAA,CAAM,SAAS,CAAC,CAAA,CAAA;AAAA,GAC7F;AAIA,EAAA,IAAI,OACJ,EAAA;AACI,IAAA,IAAI,CAAC,aAAA,IAAiB,KAAM,CAAA,YAAA,KAAiB,QAC7C,EAAA;AACI,MAAA,MAAM,eAAe,yBAA0B,CAAA,KAAA,CAAM,SAAS,CAAA,CAAE,MAAM,YAAY,CAAA,CAAA;AAElF,MAAA,EAAA,CAAG,cAAc,CAAA,CAAE,SAAW,EAAA,EAAA,CAAG,oBAAoB,YAAY,CAAA,CAAA;AAAA,KACrE;AAAA,GAIJ,MAAA;AACI,IAAG,EAAA,CAAA,cAAc,EAAE,SAAW,EAAA,EAAA,CAAG,oBAAoB,mBAAoB,CAAA,KAAA,CAAM,SAAS,CAAC,CAAA,CAAA;AAAA,GAC7F;AAGA,EAAI,IAAA,cAAA,IAAkB,KAAM,CAAA,aAAA,GAAgB,CAC5C,EAAA;AACI,IAAM,MAAA,KAAA,GAAQ,KAAK,GAAI,CAAA,KAAA,CAAM,eAAe,EAAG,CAAA,YAAA,CAAa,cAAe,CAAA,8BAA8B,CAAC,CAAA,CAAA;AAE1G,IAAA,EAAA,CAAG,cAAc,CAAA,CAAE,SAAW,EAAA,cAAA,CAAe,4BAA4B,KAAK,CAAA,CAAA;AAAA,GAClF;AAGA,EAAA,IAAI,MAAM,OACV,EAAA;AACI,IAAG,EAAA,CAAA,cAAc,EAAE,SAAW,EAAA,EAAA,CAAG,sBAAsB,sBAAuB,CAAA,KAAA,CAAM,OAAO,CAAC,CAAA,CAAA;AAAA,GAChG;AACJ;;;;"}

View File

@@ -0,0 +1,2 @@
import type { TEXTURE_FORMATS } from '../../../shared/texture/const';
export declare function getSupportedGlCompressedTextureFormats(): TEXTURE_FORMATS[];

View File

@@ -0,0 +1,101 @@
'use strict';
"use strict";
let supportedGLCompressedTextureFormats;
function getSupportedGlCompressedTextureFormats() {
if (supportedGLCompressedTextureFormats)
return supportedGLCompressedTextureFormats;
const canvas = document.createElement("canvas");
const gl = canvas.getContext("webgl");
if (!gl) {
return [];
}
supportedGLCompressedTextureFormats = [
// BC compressed formats usable if "texture-compression-bc" is both
// supported by the device/user agent and enabled in requestDevice.
// 'bc6h-rgb-ufloat'
// 'bc6h-rgb-float'
// 'bc7-rgba-unorm',
// 'bc7-rgba-unorm-srgb',
...gl.getExtension("EXT_texture_compression_bptc") ? [
"bc6h-rgb-ufloat",
"bc6h-rgb-float",
"bc7-rgba-unorm",
"bc7-rgba-unorm-srgb"
] : [],
// BC compressed formats usable if "texture-compression-bc" is both
// supported by the device/user agent and enabled in requestDevice.
// 'bc1-rgba-unorm',
// 'bc1-rgba-unorm-srgb',
// 'bc4-r-unorm'
// 'bc4-r-snorm'
// 'bc5-rg-unorm'
// 'bc5-rg-snorm'
...gl.getExtension("WEBGL_compressed_texture_s3tc") ? [
"bc1-rgba-unorm",
"bc2-rgba-unorm",
"bc3-rgba-unorm"
] : [],
...gl.getExtension("WEBGL_compressed_texture_s3tc_srgb") ? [
"bc1-rgba-unorm-srgb",
"bc2-rgba-unorm-srgb",
"bc3-rgba-unorm-srgb"
] : [],
...gl.getExtension("EXT_texture_compression_rgtc") ? [
"bc4-r-unorm",
"bc4-r-snorm",
"bc5-rg-unorm",
"bc5-rg-snorm"
] : [],
// ETC2 compressed formats usable if "texture-compression-etc2" is both
// supported by the device/user agent and enabled in requestDevice.
...gl.getExtension("WEBGL_compressed_texture_etc") ? [
"etc2-rgb8unorm",
"etc2-rgb8unorm-srgb",
"etc2-rgba8unorm",
"etc2-rgba8unorm-srgb",
"etc2-rgb8a1unorm",
"etc2-rgb8a1unorm-srgb",
"eac-r11unorm",
"eac-rg11unorm"
] : [],
// 'eac-r11snorm',
// 'eac-rg11snorm',
// ASTC compressed formats usable if "texture-compression-astc" is both
// supported by the device/user agent and enabled in requestDevice.
...gl.getExtension("WEBGL_compressed_texture_astc") ? [
"astc-4x4-unorm",
"astc-4x4-unorm-srgb",
"astc-5x4-unorm",
"astc-5x4-unorm-srgb",
"astc-5x5-unorm",
"astc-5x5-unorm-srgb",
"astc-6x5-unorm",
"astc-6x5-unorm-srgb",
"astc-6x6-unorm",
"astc-6x6-unorm-srgb",
"astc-8x5-unorm",
"astc-8x5-unorm-srgb",
"astc-8x6-unorm",
"astc-8x6-unorm-srgb",
"astc-8x8-unorm",
"astc-8x8-unorm-srgb",
"astc-10x5-unorm",
"astc-10x5-unorm-srgb",
"astc-10x6-unorm",
"astc-10x6-unorm-srgb",
"astc-10x8-unorm",
"astc-10x8-unorm-srgb",
"astc-10x10-unorm",
"astc-10x10-unorm-srgb",
"astc-12x10-unorm",
"astc-12x10-unorm-srgb",
"astc-12x12-unorm",
"astc-12x12-unorm-srgb"
] : []
];
return supportedGLCompressedTextureFormats;
}
exports.getSupportedGlCompressedTextureFormats = getSupportedGlCompressedTextureFormats;
//# sourceMappingURL=getSupportedGlCompressedTextureFormats.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,99 @@
"use strict";
let supportedGLCompressedTextureFormats;
function getSupportedGlCompressedTextureFormats() {
if (supportedGLCompressedTextureFormats)
return supportedGLCompressedTextureFormats;
const canvas = document.createElement("canvas");
const gl = canvas.getContext("webgl");
if (!gl) {
return [];
}
supportedGLCompressedTextureFormats = [
// BC compressed formats usable if "texture-compression-bc" is both
// supported by the device/user agent and enabled in requestDevice.
// 'bc6h-rgb-ufloat'
// 'bc6h-rgb-float'
// 'bc7-rgba-unorm',
// 'bc7-rgba-unorm-srgb',
...gl.getExtension("EXT_texture_compression_bptc") ? [
"bc6h-rgb-ufloat",
"bc6h-rgb-float",
"bc7-rgba-unorm",
"bc7-rgba-unorm-srgb"
] : [],
// BC compressed formats usable if "texture-compression-bc" is both
// supported by the device/user agent and enabled in requestDevice.
// 'bc1-rgba-unorm',
// 'bc1-rgba-unorm-srgb',
// 'bc4-r-unorm'
// 'bc4-r-snorm'
// 'bc5-rg-unorm'
// 'bc5-rg-snorm'
...gl.getExtension("WEBGL_compressed_texture_s3tc") ? [
"bc1-rgba-unorm",
"bc2-rgba-unorm",
"bc3-rgba-unorm"
] : [],
...gl.getExtension("WEBGL_compressed_texture_s3tc_srgb") ? [
"bc1-rgba-unorm-srgb",
"bc2-rgba-unorm-srgb",
"bc3-rgba-unorm-srgb"
] : [],
...gl.getExtension("EXT_texture_compression_rgtc") ? [
"bc4-r-unorm",
"bc4-r-snorm",
"bc5-rg-unorm",
"bc5-rg-snorm"
] : [],
// ETC2 compressed formats usable if "texture-compression-etc2" is both
// supported by the device/user agent and enabled in requestDevice.
...gl.getExtension("WEBGL_compressed_texture_etc") ? [
"etc2-rgb8unorm",
"etc2-rgb8unorm-srgb",
"etc2-rgba8unorm",
"etc2-rgba8unorm-srgb",
"etc2-rgb8a1unorm",
"etc2-rgb8a1unorm-srgb",
"eac-r11unorm",
"eac-rg11unorm"
] : [],
// 'eac-r11snorm',
// 'eac-rg11snorm',
// ASTC compressed formats usable if "texture-compression-astc" is both
// supported by the device/user agent and enabled in requestDevice.
...gl.getExtension("WEBGL_compressed_texture_astc") ? [
"astc-4x4-unorm",
"astc-4x4-unorm-srgb",
"astc-5x4-unorm",
"astc-5x4-unorm-srgb",
"astc-5x5-unorm",
"astc-5x5-unorm-srgb",
"astc-6x5-unorm",
"astc-6x5-unorm-srgb",
"astc-6x6-unorm",
"astc-6x6-unorm-srgb",
"astc-8x5-unorm",
"astc-8x5-unorm-srgb",
"astc-8x6-unorm",
"astc-8x6-unorm-srgb",
"astc-8x8-unorm",
"astc-8x8-unorm-srgb",
"astc-10x5-unorm",
"astc-10x5-unorm-srgb",
"astc-10x6-unorm",
"astc-10x6-unorm-srgb",
"astc-10x8-unorm",
"astc-10x8-unorm-srgb",
"astc-10x10-unorm",
"astc-10x10-unorm-srgb",
"astc-12x10-unorm",
"astc-12x10-unorm-srgb",
"astc-12x12-unorm",
"astc-12x12-unorm-srgb"
] : []
];
return supportedGLCompressedTextureFormats;
}
export { getSupportedGlCompressedTextureFormats };
//# sourceMappingURL=getSupportedGlCompressedTextureFormats.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,9 @@
import type { GlRenderingContext } from '../../context/GlRenderingContext';
/**
* Returns a lookup table that maps each type-format pair to a compatible internal format.
* @function mapTypeAndFormatToInternalFormat
* @private
* @param {WebGLRenderingContext} gl - The rendering context.
* @returns Lookup table.
*/
export declare function mapFormatToGlFormat(gl: GlRenderingContext): Record<string, number>;

View File

@@ -0,0 +1,59 @@
'use strict';
"use strict";
function mapFormatToGlFormat(gl) {
return {
// 8-bit formats
r8unorm: gl.RED,
r8snorm: gl.RED,
r8uint: gl.RED,
r8sint: gl.RED,
// 16-bit formats
r16uint: gl.RED,
r16sint: gl.RED,
r16float: gl.RED,
rg8unorm: gl.RG,
rg8snorm: gl.RG,
rg8uint: gl.RG,
rg8sint: gl.RG,
// 32-bit formats
r32uint: gl.RED,
r32sint: gl.RED,
r32float: gl.RED,
rg16uint: gl.RG,
rg16sint: gl.RG,
rg16float: gl.RG,
rgba8unorm: gl.RGBA,
"rgba8unorm-srgb": gl.RGBA,
// Packed 32-bit formats
rgba8snorm: gl.RGBA,
rgba8uint: gl.RGBA,
rgba8sint: gl.RGBA,
bgra8unorm: gl.RGBA,
"bgra8unorm-srgb": gl.RGBA,
rgb9e5ufloat: gl.RGB,
rgb10a2unorm: gl.RGBA,
rg11b10ufloat: gl.RGB,
// 64-bit formats
rg32uint: gl.RG,
rg32sint: gl.RG,
rg32float: gl.RG,
rgba16uint: gl.RGBA,
rgba16sint: gl.RGBA,
rgba16float: gl.RGBA,
// 128-bit formats
rgba32uint: gl.RGBA,
rgba32sint: gl.RGBA,
rgba32float: gl.RGBA,
// Depth/stencil formats
stencil8: gl.STENCIL_INDEX8,
depth16unorm: gl.DEPTH_COMPONENT,
depth24plus: gl.DEPTH_COMPONENT,
"depth24plus-stencil8": gl.DEPTH_STENCIL,
depth32float: gl.DEPTH_COMPONENT,
"depth32float-stencil8": gl.DEPTH_STENCIL
};
}
exports.mapFormatToGlFormat = mapFormatToGlFormat;
//# sourceMappingURL=mapFormatToGlFormat.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"mapFormatToGlFormat.js","sources":["../../../../../../src/rendering/renderers/gl/texture/utils/mapFormatToGlFormat.ts"],"sourcesContent":["import type { GlRenderingContext } from '../../context/GlRenderingContext';\n\n/**\n * Returns a lookup table that maps each type-format pair to a compatible internal format.\n * @function mapTypeAndFormatToInternalFormat\n * @private\n * @param {WebGLRenderingContext} gl - The rendering context.\n * @returns Lookup table.\n */\nexport function mapFormatToGlFormat(gl: GlRenderingContext): Record<string, number>\n{\n return {\n // 8-bit formats\n r8unorm: gl.RED,\n r8snorm: gl.RED,\n r8uint: gl.RED,\n r8sint: gl.RED,\n\n // 16-bit formats\n r16uint: gl.RED,\n r16sint: gl.RED,\n r16float: gl.RED,\n rg8unorm: gl.RG,\n rg8snorm: gl.RG,\n rg8uint: gl.RG,\n rg8sint: gl.RG,\n\n // 32-bit formats\n r32uint: gl.RED,\n r32sint: gl.RED,\n r32float: gl.RED,\n rg16uint: gl.RG,\n rg16sint: gl.RG,\n rg16float: gl.RG,\n rgba8unorm: gl.RGBA,\n 'rgba8unorm-srgb': gl.RGBA,\n\n // Packed 32-bit formats\n rgba8snorm: gl.RGBA,\n rgba8uint: gl.RGBA,\n rgba8sint: gl.RGBA,\n bgra8unorm: gl.RGBA,\n 'bgra8unorm-srgb': gl.RGBA,\n rgb9e5ufloat: gl.RGB,\n rgb10a2unorm: gl.RGBA,\n rg11b10ufloat: gl.RGB,\n\n // 64-bit formats\n rg32uint: gl.RG,\n rg32sint: gl.RG,\n rg32float: gl.RG,\n rgba16uint: gl.RGBA,\n rgba16sint: gl.RGBA,\n rgba16float: gl.RGBA,\n\n // 128-bit formats\n rgba32uint: gl.RGBA,\n rgba32sint: gl.RGBA,\n rgba32float: gl.RGBA,\n\n // Depth/stencil formats\n stencil8: gl.STENCIL_INDEX8,\n depth16unorm: gl.DEPTH_COMPONENT,\n depth24plus: gl.DEPTH_COMPONENT,\n 'depth24plus-stencil8': gl.DEPTH_STENCIL,\n depth32float: gl.DEPTH_COMPONENT,\n 'depth32float-stencil8': gl.DEPTH_STENCIL,\n\n };\n}\n"],"names":[],"mappings":";;;AASO,SAAS,oBAAoB,EACpC,EAAA;AACI,EAAO,OAAA;AAAA;AAAA,IAEH,SAAS,EAAG,CAAA,GAAA;AAAA,IACZ,SAAS,EAAG,CAAA,GAAA;AAAA,IACZ,QAAQ,EAAG,CAAA,GAAA;AAAA,IACX,QAAQ,EAAG,CAAA,GAAA;AAAA;AAAA,IAGX,SAAS,EAAG,CAAA,GAAA;AAAA,IACZ,SAAY,EAAG,CAAA,GAAA;AAAA,IACf,UAAU,EAAG,CAAA,GAAA;AAAA,IACb,UAAW,EAAG,CAAA,EAAA;AAAA,IACd,UAAY,EAAG,CAAA,EAAA;AAAA,IACf,SAAU,EAAG,CAAA,EAAA;AAAA,IACb,SAAU,EAAG,CAAA,EAAA;AAAA;AAAA,IAGb,SAAS,EAAG,CAAA,GAAA;AAAA,IACZ,SAAS,EAAG,CAAA,GAAA;AAAA,IACZ,UAAU,EAAG,CAAA,GAAA;AAAA,IACb,UAAY,EAAG,CAAA,EAAA;AAAA,IACf,UAAW,EAAG,CAAA,EAAA;AAAA,IACd,WAAY,EAAG,CAAA,EAAA;AAAA,IACf,YAAY,EAAG,CAAA,IAAA;AAAA,IACf,mBAAmB,EAAG,CAAA,IAAA;AAAA;AAAA,IAGtB,YAAY,EAAG,CAAA,IAAA;AAAA,IACf,WAAW,EAAG,CAAA,IAAA;AAAA,IACd,WAAW,EAAG,CAAA,IAAA;AAAA,IACd,YAAY,EAAG,CAAA,IAAA;AAAA,IACf,mBAAmB,EAAG,CAAA,IAAA;AAAA,IACtB,cAAc,EAAG,CAAA,GAAA;AAAA,IACjB,cAAc,EAAG,CAAA,IAAA;AAAA,IACjB,eAAe,EAAG,CAAA,GAAA;AAAA;AAAA,IAGlB,UAAU,EAAG,CAAA,EAAA;AAAA,IACb,UAAU,EAAG,CAAA,EAAA;AAAA,IACb,WAAY,EAAG,CAAA,EAAA;AAAA,IACf,YAAY,EAAG,CAAA,IAAA;AAAA,IACf,YAAY,EAAG,CAAA,IAAA;AAAA,IACf,aAAa,EAAG,CAAA,IAAA;AAAA;AAAA,IAGhB,YAAY,EAAG,CAAA,IAAA;AAAA,IACf,YAAY,EAAG,CAAA,IAAA;AAAA,IACf,aAAa,EAAG,CAAA,IAAA;AAAA;AAAA,IAGhB,UAAU,EAAG,CAAA,cAAA;AAAA,IACb,cAAc,EAAG,CAAA,eAAA;AAAA,IACjB,aAAa,EAAG,CAAA,eAAA;AAAA,IAChB,wBAAwB,EAAG,CAAA,aAAA;AAAA,IAC3B,cAAc,EAAG,CAAA,eAAA;AAAA,IACjB,yBAAyB,EAAG,CAAA,aAAA;AAAA,GAEhC,CAAA;AACJ;;;;"}

View File

@@ -0,0 +1,57 @@
"use strict";
function mapFormatToGlFormat(gl) {
return {
// 8-bit formats
r8unorm: gl.RED,
r8snorm: gl.RED,
r8uint: gl.RED,
r8sint: gl.RED,
// 16-bit formats
r16uint: gl.RED,
r16sint: gl.RED,
r16float: gl.RED,
rg8unorm: gl.RG,
rg8snorm: gl.RG,
rg8uint: gl.RG,
rg8sint: gl.RG,
// 32-bit formats
r32uint: gl.RED,
r32sint: gl.RED,
r32float: gl.RED,
rg16uint: gl.RG,
rg16sint: gl.RG,
rg16float: gl.RG,
rgba8unorm: gl.RGBA,
"rgba8unorm-srgb": gl.RGBA,
// Packed 32-bit formats
rgba8snorm: gl.RGBA,
rgba8uint: gl.RGBA,
rgba8sint: gl.RGBA,
bgra8unorm: gl.RGBA,
"bgra8unorm-srgb": gl.RGBA,
rgb9e5ufloat: gl.RGB,
rgb10a2unorm: gl.RGBA,
rg11b10ufloat: gl.RGB,
// 64-bit formats
rg32uint: gl.RG,
rg32sint: gl.RG,
rg32float: gl.RG,
rgba16uint: gl.RGBA,
rgba16sint: gl.RGBA,
rgba16float: gl.RGBA,
// 128-bit formats
rgba32uint: gl.RGBA,
rgba32sint: gl.RGBA,
rgba32float: gl.RGBA,
// Depth/stencil formats
stencil8: gl.STENCIL_INDEX8,
depth16unorm: gl.DEPTH_COMPONENT,
depth24plus: gl.DEPTH_COMPONENT,
"depth24plus-stencil8": gl.DEPTH_STENCIL,
depth32float: gl.DEPTH_COMPONENT,
"depth32float-stencil8": gl.DEPTH_STENCIL
};
}
export { mapFormatToGlFormat };
//# sourceMappingURL=mapFormatToGlFormat.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"mapFormatToGlFormat.mjs","sources":["../../../../../../src/rendering/renderers/gl/texture/utils/mapFormatToGlFormat.ts"],"sourcesContent":["import type { GlRenderingContext } from '../../context/GlRenderingContext';\n\n/**\n * Returns a lookup table that maps each type-format pair to a compatible internal format.\n * @function mapTypeAndFormatToInternalFormat\n * @private\n * @param {WebGLRenderingContext} gl - The rendering context.\n * @returns Lookup table.\n */\nexport function mapFormatToGlFormat(gl: GlRenderingContext): Record<string, number>\n{\n return {\n // 8-bit formats\n r8unorm: gl.RED,\n r8snorm: gl.RED,\n r8uint: gl.RED,\n r8sint: gl.RED,\n\n // 16-bit formats\n r16uint: gl.RED,\n r16sint: gl.RED,\n r16float: gl.RED,\n rg8unorm: gl.RG,\n rg8snorm: gl.RG,\n rg8uint: gl.RG,\n rg8sint: gl.RG,\n\n // 32-bit formats\n r32uint: gl.RED,\n r32sint: gl.RED,\n r32float: gl.RED,\n rg16uint: gl.RG,\n rg16sint: gl.RG,\n rg16float: gl.RG,\n rgba8unorm: gl.RGBA,\n 'rgba8unorm-srgb': gl.RGBA,\n\n // Packed 32-bit formats\n rgba8snorm: gl.RGBA,\n rgba8uint: gl.RGBA,\n rgba8sint: gl.RGBA,\n bgra8unorm: gl.RGBA,\n 'bgra8unorm-srgb': gl.RGBA,\n rgb9e5ufloat: gl.RGB,\n rgb10a2unorm: gl.RGBA,\n rg11b10ufloat: gl.RGB,\n\n // 64-bit formats\n rg32uint: gl.RG,\n rg32sint: gl.RG,\n rg32float: gl.RG,\n rgba16uint: gl.RGBA,\n rgba16sint: gl.RGBA,\n rgba16float: gl.RGBA,\n\n // 128-bit formats\n rgba32uint: gl.RGBA,\n rgba32sint: gl.RGBA,\n rgba32float: gl.RGBA,\n\n // Depth/stencil formats\n stencil8: gl.STENCIL_INDEX8,\n depth16unorm: gl.DEPTH_COMPONENT,\n depth24plus: gl.DEPTH_COMPONENT,\n 'depth24plus-stencil8': gl.DEPTH_STENCIL,\n depth32float: gl.DEPTH_COMPONENT,\n 'depth32float-stencil8': gl.DEPTH_STENCIL,\n\n };\n}\n"],"names":[],"mappings":";AASO,SAAS,oBAAoB,EACpC,EAAA;AACI,EAAO,OAAA;AAAA;AAAA,IAEH,SAAS,EAAG,CAAA,GAAA;AAAA,IACZ,SAAS,EAAG,CAAA,GAAA;AAAA,IACZ,QAAQ,EAAG,CAAA,GAAA;AAAA,IACX,QAAQ,EAAG,CAAA,GAAA;AAAA;AAAA,IAGX,SAAS,EAAG,CAAA,GAAA;AAAA,IACZ,SAAY,EAAG,CAAA,GAAA;AAAA,IACf,UAAU,EAAG,CAAA,GAAA;AAAA,IACb,UAAW,EAAG,CAAA,EAAA;AAAA,IACd,UAAY,EAAG,CAAA,EAAA;AAAA,IACf,SAAU,EAAG,CAAA,EAAA;AAAA,IACb,SAAU,EAAG,CAAA,EAAA;AAAA;AAAA,IAGb,SAAS,EAAG,CAAA,GAAA;AAAA,IACZ,SAAS,EAAG,CAAA,GAAA;AAAA,IACZ,UAAU,EAAG,CAAA,GAAA;AAAA,IACb,UAAY,EAAG,CAAA,EAAA;AAAA,IACf,UAAW,EAAG,CAAA,EAAA;AAAA,IACd,WAAY,EAAG,CAAA,EAAA;AAAA,IACf,YAAY,EAAG,CAAA,IAAA;AAAA,IACf,mBAAmB,EAAG,CAAA,IAAA;AAAA;AAAA,IAGtB,YAAY,EAAG,CAAA,IAAA;AAAA,IACf,WAAW,EAAG,CAAA,IAAA;AAAA,IACd,WAAW,EAAG,CAAA,IAAA;AAAA,IACd,YAAY,EAAG,CAAA,IAAA;AAAA,IACf,mBAAmB,EAAG,CAAA,IAAA;AAAA,IACtB,cAAc,EAAG,CAAA,GAAA;AAAA,IACjB,cAAc,EAAG,CAAA,IAAA;AAAA,IACjB,eAAe,EAAG,CAAA,GAAA;AAAA;AAAA,IAGlB,UAAU,EAAG,CAAA,EAAA;AAAA,IACb,UAAU,EAAG,CAAA,EAAA;AAAA,IACb,WAAY,EAAG,CAAA,EAAA;AAAA,IACf,YAAY,EAAG,CAAA,IAAA;AAAA,IACf,YAAY,EAAG,CAAA,IAAA;AAAA,IACf,aAAa,EAAG,CAAA,IAAA;AAAA;AAAA,IAGhB,YAAY,EAAG,CAAA,IAAA;AAAA,IACf,YAAY,EAAG,CAAA,IAAA;AAAA,IACf,aAAa,EAAG,CAAA,IAAA;AAAA;AAAA,IAGhB,UAAU,EAAG,CAAA,cAAA;AAAA,IACb,cAAc,EAAG,CAAA,eAAA;AAAA,IACjB,aAAa,EAAG,CAAA,eAAA;AAAA,IAChB,wBAAwB,EAAG,CAAA,aAAA;AAAA,IAC3B,cAAc,EAAG,CAAA,eAAA;AAAA,IACjB,yBAAyB,EAAG,CAAA,aAAA;AAAA,GAEhC,CAAA;AACJ;;;;"}

View File

@@ -0,0 +1,11 @@
import type { GlRenderingContext } from '../../context/GlRenderingContext';
import type { WebGLExtensions } from '../../context/WebGLExtensions';
/**
* Returns a lookup table that maps each type-format pair to a compatible internal format.
* @function mapTypeAndFormatToInternalFormat
* @private
* @param gl - The rendering context.
* @param extensions - The WebGL extensions.
* @returns Lookup table.
*/
export declare function mapFormatToGlInternalFormat(gl: GlRenderingContext, extensions: WebGLExtensions): Record<string, number>;

View File

@@ -0,0 +1,139 @@
'use strict';
var adapter = require('../../../../../environment/adapter.js');
"use strict";
function mapFormatToGlInternalFormat(gl, extensions) {
let srgb = {};
let bgra8unorm = gl.RGBA;
if (!(gl instanceof adapter.DOMAdapter.get().getWebGLRenderingContext())) {
srgb = {
"rgba8unorm-srgb": gl.SRGB8_ALPHA8,
"bgra8unorm-srgb": gl.SRGB8_ALPHA8
};
bgra8unorm = gl.RGBA8;
} else if (extensions.srgb) {
srgb = {
"rgba8unorm-srgb": extensions.srgb.SRGB8_ALPHA8_EXT,
"bgra8unorm-srgb": extensions.srgb.SRGB8_ALPHA8_EXT
};
}
return {
// 8-bit formats
r8unorm: gl.R8,
r8snorm: gl.R8_SNORM,
r8uint: gl.R8UI,
r8sint: gl.R8I,
// 16-bit formats
r16uint: gl.R16UI,
r16sint: gl.R16I,
r16float: gl.R16F,
rg8unorm: gl.RG8,
rg8snorm: gl.RG8_SNORM,
rg8uint: gl.RG8UI,
rg8sint: gl.RG8I,
// 32-bit formats
r32uint: gl.R32UI,
r32sint: gl.R32I,
r32float: gl.R32F,
rg16uint: gl.RG16UI,
rg16sint: gl.RG16I,
rg16float: gl.RG16F,
rgba8unorm: gl.RGBA,
...srgb,
// Packed 32-bit formats
rgba8snorm: gl.RGBA8_SNORM,
rgba8uint: gl.RGBA8UI,
rgba8sint: gl.RGBA8I,
bgra8unorm,
rgb9e5ufloat: gl.RGB9_E5,
rgb10a2unorm: gl.RGB10_A2,
rg11b10ufloat: gl.R11F_G11F_B10F,
// 64-bit formats
rg32uint: gl.RG32UI,
rg32sint: gl.RG32I,
rg32float: gl.RG32F,
rgba16uint: gl.RGBA16UI,
rgba16sint: gl.RGBA16I,
rgba16float: gl.RGBA16F,
// 128-bit formats
rgba32uint: gl.RGBA32UI,
rgba32sint: gl.RGBA32I,
rgba32float: gl.RGBA32F,
// Depth/stencil formats
stencil8: gl.STENCIL_INDEX8,
depth16unorm: gl.DEPTH_COMPONENT16,
depth24plus: gl.DEPTH_COMPONENT24,
"depth24plus-stencil8": gl.DEPTH24_STENCIL8,
depth32float: gl.DEPTH_COMPONENT32F,
"depth32float-stencil8": gl.DEPTH32F_STENCIL8,
// Compressed formats
...extensions.s3tc ? {
"bc1-rgba-unorm": extensions.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,
"bc2-rgba-unorm": extensions.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,
"bc3-rgba-unorm": extensions.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT
} : {},
...extensions.s3tc_sRGB ? {
"bc1-rgba-unorm-srgb": extensions.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
"bc2-rgba-unorm-srgb": extensions.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
"bc3-rgba-unorm-srgb": extensions.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
} : {},
...extensions.rgtc ? {
"bc4-r-unorm": extensions.rgtc.COMPRESSED_RED_RGTC1_EXT,
"bc4-r-snorm": extensions.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,
"bc5-rg-unorm": extensions.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,
"bc5-rg-snorm": extensions.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT
} : {},
...extensions.bptc ? {
"bc6h-rgb-float": extensions.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,
"bc6h-rgb-ufloat": extensions.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,
"bc7-rgba-unorm": extensions.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,
"bc7-rgba-unorm-srgb": extensions.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT
} : {},
...extensions.etc ? {
"etc2-rgb8unorm": extensions.etc.COMPRESSED_RGB8_ETC2,
"etc2-rgb8unorm-srgb": extensions.etc.COMPRESSED_SRGB8_ETC2,
"etc2-rgb8a1unorm": extensions.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
"etc2-rgb8a1unorm-srgb": extensions.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
"etc2-rgba8unorm": extensions.etc.COMPRESSED_RGBA8_ETC2_EAC,
"etc2-rgba8unorm-srgb": extensions.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
"eac-r11unorm": extensions.etc.COMPRESSED_R11_EAC,
// 'eac-r11snorm'
"eac-rg11unorm": extensions.etc.COMPRESSED_SIGNED_RG11_EAC
// 'eac-rg11snorm'
} : {},
...extensions.astc ? {
"astc-4x4-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,
"astc-4x4-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
"astc-5x4-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,
"astc-5x4-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
"astc-5x5-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,
"astc-5x5-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
"astc-6x5-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,
"astc-6x5-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
"astc-6x6-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,
"astc-6x6-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
"astc-8x5-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,
"astc-8x5-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
"astc-8x6-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,
"astc-8x6-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
"astc-8x8-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,
"astc-8x8-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
"astc-10x5-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,
"astc-10x5-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
"astc-10x6-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,
"astc-10x6-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
"astc-10x8-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,
"astc-10x8-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
"astc-10x10-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,
"astc-10x10-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
"astc-12x10-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,
"astc-12x10-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
"astc-12x12-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,
"astc-12x12-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR
} : {}
};
}
exports.mapFormatToGlInternalFormat = mapFormatToGlInternalFormat;
//# sourceMappingURL=mapFormatToGlInternalFormat.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,137 @@
import { DOMAdapter } from '../../../../../environment/adapter.mjs';
"use strict";
function mapFormatToGlInternalFormat(gl, extensions) {
let srgb = {};
let bgra8unorm = gl.RGBA;
if (!(gl instanceof DOMAdapter.get().getWebGLRenderingContext())) {
srgb = {
"rgba8unorm-srgb": gl.SRGB8_ALPHA8,
"bgra8unorm-srgb": gl.SRGB8_ALPHA8
};
bgra8unorm = gl.RGBA8;
} else if (extensions.srgb) {
srgb = {
"rgba8unorm-srgb": extensions.srgb.SRGB8_ALPHA8_EXT,
"bgra8unorm-srgb": extensions.srgb.SRGB8_ALPHA8_EXT
};
}
return {
// 8-bit formats
r8unorm: gl.R8,
r8snorm: gl.R8_SNORM,
r8uint: gl.R8UI,
r8sint: gl.R8I,
// 16-bit formats
r16uint: gl.R16UI,
r16sint: gl.R16I,
r16float: gl.R16F,
rg8unorm: gl.RG8,
rg8snorm: gl.RG8_SNORM,
rg8uint: gl.RG8UI,
rg8sint: gl.RG8I,
// 32-bit formats
r32uint: gl.R32UI,
r32sint: gl.R32I,
r32float: gl.R32F,
rg16uint: gl.RG16UI,
rg16sint: gl.RG16I,
rg16float: gl.RG16F,
rgba8unorm: gl.RGBA,
...srgb,
// Packed 32-bit formats
rgba8snorm: gl.RGBA8_SNORM,
rgba8uint: gl.RGBA8UI,
rgba8sint: gl.RGBA8I,
bgra8unorm,
rgb9e5ufloat: gl.RGB9_E5,
rgb10a2unorm: gl.RGB10_A2,
rg11b10ufloat: gl.R11F_G11F_B10F,
// 64-bit formats
rg32uint: gl.RG32UI,
rg32sint: gl.RG32I,
rg32float: gl.RG32F,
rgba16uint: gl.RGBA16UI,
rgba16sint: gl.RGBA16I,
rgba16float: gl.RGBA16F,
// 128-bit formats
rgba32uint: gl.RGBA32UI,
rgba32sint: gl.RGBA32I,
rgba32float: gl.RGBA32F,
// Depth/stencil formats
stencil8: gl.STENCIL_INDEX8,
depth16unorm: gl.DEPTH_COMPONENT16,
depth24plus: gl.DEPTH_COMPONENT24,
"depth24plus-stencil8": gl.DEPTH24_STENCIL8,
depth32float: gl.DEPTH_COMPONENT32F,
"depth32float-stencil8": gl.DEPTH32F_STENCIL8,
// Compressed formats
...extensions.s3tc ? {
"bc1-rgba-unorm": extensions.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,
"bc2-rgba-unorm": extensions.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,
"bc3-rgba-unorm": extensions.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT
} : {},
...extensions.s3tc_sRGB ? {
"bc1-rgba-unorm-srgb": extensions.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
"bc2-rgba-unorm-srgb": extensions.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
"bc3-rgba-unorm-srgb": extensions.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
} : {},
...extensions.rgtc ? {
"bc4-r-unorm": extensions.rgtc.COMPRESSED_RED_RGTC1_EXT,
"bc4-r-snorm": extensions.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,
"bc5-rg-unorm": extensions.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,
"bc5-rg-snorm": extensions.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT
} : {},
...extensions.bptc ? {
"bc6h-rgb-float": extensions.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,
"bc6h-rgb-ufloat": extensions.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,
"bc7-rgba-unorm": extensions.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,
"bc7-rgba-unorm-srgb": extensions.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT
} : {},
...extensions.etc ? {
"etc2-rgb8unorm": extensions.etc.COMPRESSED_RGB8_ETC2,
"etc2-rgb8unorm-srgb": extensions.etc.COMPRESSED_SRGB8_ETC2,
"etc2-rgb8a1unorm": extensions.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
"etc2-rgb8a1unorm-srgb": extensions.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
"etc2-rgba8unorm": extensions.etc.COMPRESSED_RGBA8_ETC2_EAC,
"etc2-rgba8unorm-srgb": extensions.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
"eac-r11unorm": extensions.etc.COMPRESSED_R11_EAC,
// 'eac-r11snorm'
"eac-rg11unorm": extensions.etc.COMPRESSED_SIGNED_RG11_EAC
// 'eac-rg11snorm'
} : {},
...extensions.astc ? {
"astc-4x4-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,
"astc-4x4-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
"astc-5x4-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,
"astc-5x4-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
"astc-5x5-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,
"astc-5x5-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
"astc-6x5-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,
"astc-6x5-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
"astc-6x6-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,
"astc-6x6-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
"astc-8x5-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,
"astc-8x5-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
"astc-8x6-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,
"astc-8x6-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
"astc-8x8-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,
"astc-8x8-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
"astc-10x5-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,
"astc-10x5-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
"astc-10x6-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,
"astc-10x6-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
"astc-10x8-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,
"astc-10x8-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
"astc-10x10-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,
"astc-10x10-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
"astc-12x10-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,
"astc-12x10-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
"astc-12x12-unorm": extensions.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,
"astc-12x12-unorm-srgb": extensions.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR
} : {}
};
}
export { mapFormatToGlInternalFormat };
//# sourceMappingURL=mapFormatToGlInternalFormat.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,9 @@
import type { GlRenderingContext } from '../../context/GlRenderingContext';
/**
* Returns a lookup table that maps each type-format pair to a compatible internal format.
* @function mapTypeAndFormatToInternalFormat
* @private
* @param {WebGLRenderingContext} gl - The rendering context.
* @returns Lookup table.
*/
export declare function mapFormatToGlType(gl: GlRenderingContext): Record<string, number>;

View File

@@ -0,0 +1,59 @@
'use strict';
"use strict";
function mapFormatToGlType(gl) {
return {
// 8-bit formats
r8unorm: gl.UNSIGNED_BYTE,
r8snorm: gl.BYTE,
r8uint: gl.UNSIGNED_BYTE,
r8sint: gl.BYTE,
// 16-bit formats
r16uint: gl.UNSIGNED_SHORT,
r16sint: gl.SHORT,
r16float: gl.HALF_FLOAT,
rg8unorm: gl.UNSIGNED_BYTE,
rg8snorm: gl.BYTE,
rg8uint: gl.UNSIGNED_BYTE,
rg8sint: gl.BYTE,
// 32-bit formats
r32uint: gl.UNSIGNED_INT,
r32sint: gl.INT,
r32float: gl.FLOAT,
rg16uint: gl.UNSIGNED_SHORT,
rg16sint: gl.SHORT,
rg16float: gl.HALF_FLOAT,
rgba8unorm: gl.UNSIGNED_BYTE,
"rgba8unorm-srgb": gl.UNSIGNED_BYTE,
// Packed 32-bit formats
rgba8snorm: gl.BYTE,
rgba8uint: gl.UNSIGNED_BYTE,
rgba8sint: gl.BYTE,
bgra8unorm: gl.UNSIGNED_BYTE,
"bgra8unorm-srgb": gl.UNSIGNED_BYTE,
rgb9e5ufloat: gl.UNSIGNED_INT_5_9_9_9_REV,
rgb10a2unorm: gl.UNSIGNED_INT_2_10_10_10_REV,
rg11b10ufloat: gl.UNSIGNED_INT_10F_11F_11F_REV,
// 64-bit formats
rg32uint: gl.UNSIGNED_INT,
rg32sint: gl.INT,
rg32float: gl.FLOAT,
rgba16uint: gl.UNSIGNED_SHORT,
rgba16sint: gl.SHORT,
rgba16float: gl.HALF_FLOAT,
// 128-bit formats
rgba32uint: gl.UNSIGNED_INT,
rgba32sint: gl.INT,
rgba32float: gl.FLOAT,
// Depth/stencil formats
stencil8: gl.UNSIGNED_BYTE,
depth16unorm: gl.UNSIGNED_SHORT,
depth24plus: gl.UNSIGNED_INT,
"depth24plus-stencil8": gl.UNSIGNED_INT_24_8,
depth32float: gl.FLOAT,
"depth32float-stencil8": gl.FLOAT_32_UNSIGNED_INT_24_8_REV
};
}
exports.mapFormatToGlType = mapFormatToGlType;
//# sourceMappingURL=mapFormatToGlType.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"mapFormatToGlType.js","sources":["../../../../../../src/rendering/renderers/gl/texture/utils/mapFormatToGlType.ts"],"sourcesContent":["import type { GlRenderingContext } from '../../context/GlRenderingContext';\n\n/**\n * Returns a lookup table that maps each type-format pair to a compatible internal format.\n * @function mapTypeAndFormatToInternalFormat\n * @private\n * @param {WebGLRenderingContext} gl - The rendering context.\n * @returns Lookup table.\n */\nexport function mapFormatToGlType(gl: GlRenderingContext): Record<string, number>\n{\n return {\n // 8-bit formats\n r8unorm: gl.UNSIGNED_BYTE,\n r8snorm: gl.BYTE,\n r8uint: gl.UNSIGNED_BYTE,\n r8sint: gl.BYTE,\n\n // 16-bit formats\n r16uint: gl.UNSIGNED_SHORT,\n r16sint: gl.SHORT,\n r16float: gl.HALF_FLOAT,\n rg8unorm: gl.UNSIGNED_BYTE,\n rg8snorm: gl.BYTE,\n rg8uint: gl.UNSIGNED_BYTE,\n rg8sint: gl.BYTE,\n\n // 32-bit formats\n r32uint: gl.UNSIGNED_INT,\n r32sint: gl.INT,\n r32float: gl.FLOAT,\n rg16uint: gl.UNSIGNED_SHORT,\n rg16sint: gl.SHORT,\n rg16float: gl.HALF_FLOAT,\n rgba8unorm: gl.UNSIGNED_BYTE,\n 'rgba8unorm-srgb': gl.UNSIGNED_BYTE,\n\n // Packed 32-bit formats\n rgba8snorm: gl.BYTE,\n rgba8uint: gl.UNSIGNED_BYTE,\n rgba8sint: gl.BYTE,\n bgra8unorm: gl.UNSIGNED_BYTE,\n 'bgra8unorm-srgb': gl.UNSIGNED_BYTE,\n rgb9e5ufloat: gl.UNSIGNED_INT_5_9_9_9_REV,\n rgb10a2unorm: gl.UNSIGNED_INT_2_10_10_10_REV,\n rg11b10ufloat: gl.UNSIGNED_INT_10F_11F_11F_REV,\n\n // 64-bit formats\n rg32uint: gl.UNSIGNED_INT,\n rg32sint: gl.INT,\n rg32float: gl.FLOAT,\n rgba16uint: gl.UNSIGNED_SHORT,\n rgba16sint: gl.SHORT,\n rgba16float: gl.HALF_FLOAT,\n\n // 128-bit formats\n rgba32uint: gl.UNSIGNED_INT,\n rgba32sint: gl.INT,\n rgba32float: gl.FLOAT,\n\n // Depth/stencil formats\n stencil8: gl.UNSIGNED_BYTE,\n depth16unorm: gl.UNSIGNED_SHORT,\n depth24plus: gl.UNSIGNED_INT,\n 'depth24plus-stencil8': gl.UNSIGNED_INT_24_8,\n depth32float: gl.FLOAT,\n 'depth32float-stencil8': gl.FLOAT_32_UNSIGNED_INT_24_8_REV,\n\n };\n}\n"],"names":[],"mappings":";;;AASO,SAAS,kBAAkB,EAClC,EAAA;AACI,EAAO,OAAA;AAAA;AAAA,IAEH,SAAS,EAAG,CAAA,aAAA;AAAA,IACZ,SAAS,EAAG,CAAA,IAAA;AAAA,IACZ,QAAQ,EAAG,CAAA,aAAA;AAAA,IACX,QAAQ,EAAG,CAAA,IAAA;AAAA;AAAA,IAGX,SAAS,EAAG,CAAA,cAAA;AAAA,IACZ,SAAS,EAAG,CAAA,KAAA;AAAA,IACZ,UAAU,EAAG,CAAA,UAAA;AAAA,IACb,UAAU,EAAG,CAAA,aAAA;AAAA,IACb,UAAU,EAAG,CAAA,IAAA;AAAA,IACb,SAAS,EAAG,CAAA,aAAA;AAAA,IACZ,SAAS,EAAG,CAAA,IAAA;AAAA;AAAA,IAGZ,SAAS,EAAG,CAAA,YAAA;AAAA,IACZ,SAAS,EAAG,CAAA,GAAA;AAAA,IACZ,UAAU,EAAG,CAAA,KAAA;AAAA,IACb,UAAU,EAAG,CAAA,cAAA;AAAA,IACb,UAAU,EAAG,CAAA,KAAA;AAAA,IACb,WAAW,EAAG,CAAA,UAAA;AAAA,IACd,YAAY,EAAG,CAAA,aAAA;AAAA,IACf,mBAAmB,EAAG,CAAA,aAAA;AAAA;AAAA,IAGtB,YAAY,EAAG,CAAA,IAAA;AAAA,IACf,WAAW,EAAG,CAAA,aAAA;AAAA,IACd,WAAW,EAAG,CAAA,IAAA;AAAA,IACd,YAAY,EAAG,CAAA,aAAA;AAAA,IACf,mBAAmB,EAAG,CAAA,aAAA;AAAA,IACtB,cAAc,EAAG,CAAA,wBAAA;AAAA,IACjB,cAAc,EAAG,CAAA,2BAAA;AAAA,IACjB,eAAe,EAAG,CAAA,4BAAA;AAAA;AAAA,IAGlB,UAAU,EAAG,CAAA,YAAA;AAAA,IACb,UAAU,EAAG,CAAA,GAAA;AAAA,IACb,WAAW,EAAG,CAAA,KAAA;AAAA,IACd,YAAY,EAAG,CAAA,cAAA;AAAA,IACf,YAAY,EAAG,CAAA,KAAA;AAAA,IACf,aAAa,EAAG,CAAA,UAAA;AAAA;AAAA,IAGhB,YAAY,EAAG,CAAA,YAAA;AAAA,IACf,YAAY,EAAG,CAAA,GAAA;AAAA,IACf,aAAa,EAAG,CAAA,KAAA;AAAA;AAAA,IAGhB,UAAU,EAAG,CAAA,aAAA;AAAA,IACb,cAAc,EAAG,CAAA,cAAA;AAAA,IACjB,aAAa,EAAG,CAAA,YAAA;AAAA,IAChB,wBAAwB,EAAG,CAAA,iBAAA;AAAA,IAC3B,cAAc,EAAG,CAAA,KAAA;AAAA,IACjB,yBAAyB,EAAG,CAAA,8BAAA;AAAA,GAEhC,CAAA;AACJ;;;;"}

View File

@@ -0,0 +1,57 @@
"use strict";
function mapFormatToGlType(gl) {
return {
// 8-bit formats
r8unorm: gl.UNSIGNED_BYTE,
r8snorm: gl.BYTE,
r8uint: gl.UNSIGNED_BYTE,
r8sint: gl.BYTE,
// 16-bit formats
r16uint: gl.UNSIGNED_SHORT,
r16sint: gl.SHORT,
r16float: gl.HALF_FLOAT,
rg8unorm: gl.UNSIGNED_BYTE,
rg8snorm: gl.BYTE,
rg8uint: gl.UNSIGNED_BYTE,
rg8sint: gl.BYTE,
// 32-bit formats
r32uint: gl.UNSIGNED_INT,
r32sint: gl.INT,
r32float: gl.FLOAT,
rg16uint: gl.UNSIGNED_SHORT,
rg16sint: gl.SHORT,
rg16float: gl.HALF_FLOAT,
rgba8unorm: gl.UNSIGNED_BYTE,
"rgba8unorm-srgb": gl.UNSIGNED_BYTE,
// Packed 32-bit formats
rgba8snorm: gl.BYTE,
rgba8uint: gl.UNSIGNED_BYTE,
rgba8sint: gl.BYTE,
bgra8unorm: gl.UNSIGNED_BYTE,
"bgra8unorm-srgb": gl.UNSIGNED_BYTE,
rgb9e5ufloat: gl.UNSIGNED_INT_5_9_9_9_REV,
rgb10a2unorm: gl.UNSIGNED_INT_2_10_10_10_REV,
rg11b10ufloat: gl.UNSIGNED_INT_10F_11F_11F_REV,
// 64-bit formats
rg32uint: gl.UNSIGNED_INT,
rg32sint: gl.INT,
rg32float: gl.FLOAT,
rgba16uint: gl.UNSIGNED_SHORT,
rgba16sint: gl.SHORT,
rgba16float: gl.HALF_FLOAT,
// 128-bit formats
rgba32uint: gl.UNSIGNED_INT,
rgba32sint: gl.INT,
rgba32float: gl.FLOAT,
// Depth/stencil formats
stencil8: gl.UNSIGNED_BYTE,
depth16unorm: gl.UNSIGNED_SHORT,
depth24plus: gl.UNSIGNED_INT,
"depth24plus-stencil8": gl.UNSIGNED_INT_24_8,
depth32float: gl.FLOAT,
"depth32float-stencil8": gl.FLOAT_32_UNSIGNED_INT_24_8_REV
};
}
export { mapFormatToGlType };
//# sourceMappingURL=mapFormatToGlType.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"mapFormatToGlType.mjs","sources":["../../../../../../src/rendering/renderers/gl/texture/utils/mapFormatToGlType.ts"],"sourcesContent":["import type { GlRenderingContext } from '../../context/GlRenderingContext';\n\n/**\n * Returns a lookup table that maps each type-format pair to a compatible internal format.\n * @function mapTypeAndFormatToInternalFormat\n * @private\n * @param {WebGLRenderingContext} gl - The rendering context.\n * @returns Lookup table.\n */\nexport function mapFormatToGlType(gl: GlRenderingContext): Record<string, number>\n{\n return {\n // 8-bit formats\n r8unorm: gl.UNSIGNED_BYTE,\n r8snorm: gl.BYTE,\n r8uint: gl.UNSIGNED_BYTE,\n r8sint: gl.BYTE,\n\n // 16-bit formats\n r16uint: gl.UNSIGNED_SHORT,\n r16sint: gl.SHORT,\n r16float: gl.HALF_FLOAT,\n rg8unorm: gl.UNSIGNED_BYTE,\n rg8snorm: gl.BYTE,\n rg8uint: gl.UNSIGNED_BYTE,\n rg8sint: gl.BYTE,\n\n // 32-bit formats\n r32uint: gl.UNSIGNED_INT,\n r32sint: gl.INT,\n r32float: gl.FLOAT,\n rg16uint: gl.UNSIGNED_SHORT,\n rg16sint: gl.SHORT,\n rg16float: gl.HALF_FLOAT,\n rgba8unorm: gl.UNSIGNED_BYTE,\n 'rgba8unorm-srgb': gl.UNSIGNED_BYTE,\n\n // Packed 32-bit formats\n rgba8snorm: gl.BYTE,\n rgba8uint: gl.UNSIGNED_BYTE,\n rgba8sint: gl.BYTE,\n bgra8unorm: gl.UNSIGNED_BYTE,\n 'bgra8unorm-srgb': gl.UNSIGNED_BYTE,\n rgb9e5ufloat: gl.UNSIGNED_INT_5_9_9_9_REV,\n rgb10a2unorm: gl.UNSIGNED_INT_2_10_10_10_REV,\n rg11b10ufloat: gl.UNSIGNED_INT_10F_11F_11F_REV,\n\n // 64-bit formats\n rg32uint: gl.UNSIGNED_INT,\n rg32sint: gl.INT,\n rg32float: gl.FLOAT,\n rgba16uint: gl.UNSIGNED_SHORT,\n rgba16sint: gl.SHORT,\n rgba16float: gl.HALF_FLOAT,\n\n // 128-bit formats\n rgba32uint: gl.UNSIGNED_INT,\n rgba32sint: gl.INT,\n rgba32float: gl.FLOAT,\n\n // Depth/stencil formats\n stencil8: gl.UNSIGNED_BYTE,\n depth16unorm: gl.UNSIGNED_SHORT,\n depth24plus: gl.UNSIGNED_INT,\n 'depth24plus-stencil8': gl.UNSIGNED_INT_24_8,\n depth32float: gl.FLOAT,\n 'depth32float-stencil8': gl.FLOAT_32_UNSIGNED_INT_24_8_REV,\n\n };\n}\n"],"names":[],"mappings":";AASO,SAAS,kBAAkB,EAClC,EAAA;AACI,EAAO,OAAA;AAAA;AAAA,IAEH,SAAS,EAAG,CAAA,aAAA;AAAA,IACZ,SAAS,EAAG,CAAA,IAAA;AAAA,IACZ,QAAQ,EAAG,CAAA,aAAA;AAAA,IACX,QAAQ,EAAG,CAAA,IAAA;AAAA;AAAA,IAGX,SAAS,EAAG,CAAA,cAAA;AAAA,IACZ,SAAS,EAAG,CAAA,KAAA;AAAA,IACZ,UAAU,EAAG,CAAA,UAAA;AAAA,IACb,UAAU,EAAG,CAAA,aAAA;AAAA,IACb,UAAU,EAAG,CAAA,IAAA;AAAA,IACb,SAAS,EAAG,CAAA,aAAA;AAAA,IACZ,SAAS,EAAG,CAAA,IAAA;AAAA;AAAA,IAGZ,SAAS,EAAG,CAAA,YAAA;AAAA,IACZ,SAAS,EAAG,CAAA,GAAA;AAAA,IACZ,UAAU,EAAG,CAAA,KAAA;AAAA,IACb,UAAU,EAAG,CAAA,cAAA;AAAA,IACb,UAAU,EAAG,CAAA,KAAA;AAAA,IACb,WAAW,EAAG,CAAA,UAAA;AAAA,IACd,YAAY,EAAG,CAAA,aAAA;AAAA,IACf,mBAAmB,EAAG,CAAA,aAAA;AAAA;AAAA,IAGtB,YAAY,EAAG,CAAA,IAAA;AAAA,IACf,WAAW,EAAG,CAAA,aAAA;AAAA,IACd,WAAW,EAAG,CAAA,IAAA;AAAA,IACd,YAAY,EAAG,CAAA,aAAA;AAAA,IACf,mBAAmB,EAAG,CAAA,aAAA;AAAA,IACtB,cAAc,EAAG,CAAA,wBAAA;AAAA,IACjB,cAAc,EAAG,CAAA,2BAAA;AAAA,IACjB,eAAe,EAAG,CAAA,4BAAA;AAAA;AAAA,IAGlB,UAAU,EAAG,CAAA,YAAA;AAAA,IACb,UAAU,EAAG,CAAA,GAAA;AAAA,IACb,WAAW,EAAG,CAAA,KAAA;AAAA,IACd,YAAY,EAAG,CAAA,cAAA;AAAA,IACf,YAAY,EAAG,CAAA,KAAA;AAAA,IACf,aAAa,EAAG,CAAA,UAAA;AAAA;AAAA,IAGhB,YAAY,EAAG,CAAA,YAAA;AAAA,IACf,YAAY,EAAG,CAAA,GAAA;AAAA,IACf,aAAa,EAAG,CAAA,KAAA;AAAA;AAAA,IAGhB,UAAU,EAAG,CAAA,aAAA;AAAA,IACb,cAAc,EAAG,CAAA,cAAA;AAAA,IACjB,aAAa,EAAG,CAAA,YAAA;AAAA,IAChB,wBAAwB,EAAG,CAAA,iBAAA;AAAA,IAC3B,cAAc,EAAG,CAAA,KAAA;AAAA,IACjB,yBAAyB,EAAG,CAAA,8BAAA;AAAA,GAEhC,CAAA;AACJ;;;;"}

View File

@@ -0,0 +1,29 @@
export declare const scaleModeToGlFilter: {
linear: number;
nearest: number;
};
export declare const mipmapScaleModeToGlFilter: {
linear: {
linear: number;
nearest: number;
};
nearest: {
linear: number;
nearest: number;
};
};
export declare const wrapModeToGlAddress: {
'clamp-to-edge': number;
repeat: number;
'mirror-repeat': number;
};
export declare const compareModeToGlCompare: {
never: number;
less: number;
equal: number;
'less-equal': number;
greater: number;
'not-equal': number;
'greater-equal': number;
always: number;
};

View File

@@ -0,0 +1,38 @@
'use strict';
"use strict";
const scaleModeToGlFilter = {
linear: 9729,
nearest: 9728
};
const mipmapScaleModeToGlFilter = {
linear: {
linear: 9987,
nearest: 9985
},
nearest: {
linear: 9986,
nearest: 9984
}
};
const wrapModeToGlAddress = {
"clamp-to-edge": 33071,
repeat: 10497,
"mirror-repeat": 33648
};
const compareModeToGlCompare = {
never: 512,
less: 513,
equal: 514,
"less-equal": 515,
greater: 516,
"not-equal": 517,
"greater-equal": 518,
always: 519
};
exports.compareModeToGlCompare = compareModeToGlCompare;
exports.mipmapScaleModeToGlFilter = mipmapScaleModeToGlFilter;
exports.scaleModeToGlFilter = scaleModeToGlFilter;
exports.wrapModeToGlAddress = wrapModeToGlAddress;
//# sourceMappingURL=pixiToGlMaps.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"pixiToGlMaps.js","sources":["../../../../../../src/rendering/renderers/gl/texture/utils/pixiToGlMaps.ts"],"sourcesContent":["export const scaleModeToGlFilter = {\n linear: 9729,\n nearest: 9728,\n};\n\nexport const mipmapScaleModeToGlFilter = {\n linear: {\n linear: 9987,\n nearest: 9985,\n },\n nearest: {\n linear: 9986,\n nearest: 9984,\n }\n};\n\nexport const wrapModeToGlAddress = {\n 'clamp-to-edge': 33071,\n repeat: 10497,\n 'mirror-repeat': 33648,\n};\n\nexport const compareModeToGlCompare = {\n never: 512,\n less: 513,\n equal: 514,\n 'less-equal': 515,\n greater: 516,\n 'not-equal': 517,\n 'greater-equal': 518,\n always: 519,\n};\n\n"],"names":[],"mappings":";;;AAAO,MAAM,mBAAsB,GAAA;AAAA,EAC/B,MAAQ,EAAA,IAAA;AAAA,EACR,OAAS,EAAA,IAAA;AACb,EAAA;AAEO,MAAM,yBAA4B,GAAA;AAAA,EACrC,MAAQ,EAAA;AAAA,IACJ,MAAQ,EAAA,IAAA;AAAA,IACR,OAAS,EAAA,IAAA;AAAA,GACb;AAAA,EACA,OAAS,EAAA;AAAA,IACL,MAAQ,EAAA,IAAA;AAAA,IACR,OAAS,EAAA,IAAA;AAAA,GACb;AACJ,EAAA;AAEO,MAAM,mBAAsB,GAAA;AAAA,EAC/B,eAAiB,EAAA,KAAA;AAAA,EACjB,MAAQ,EAAA,KAAA;AAAA,EACR,eAAiB,EAAA,KAAA;AACrB,EAAA;AAEO,MAAM,sBAAyB,GAAA;AAAA,EAClC,KAAO,EAAA,GAAA;AAAA,EACP,IAAM,EAAA,GAAA;AAAA,EACN,KAAO,EAAA,GAAA;AAAA,EACP,YAAc,EAAA,GAAA;AAAA,EACd,OAAS,EAAA,GAAA;AAAA,EACT,WAAa,EAAA,GAAA;AAAA,EACb,eAAiB,EAAA,GAAA;AAAA,EACjB,MAAQ,EAAA,GAAA;AACZ;;;;;;;"}

View File

@@ -0,0 +1,33 @@
"use strict";
const scaleModeToGlFilter = {
linear: 9729,
nearest: 9728
};
const mipmapScaleModeToGlFilter = {
linear: {
linear: 9987,
nearest: 9985
},
nearest: {
linear: 9986,
nearest: 9984
}
};
const wrapModeToGlAddress = {
"clamp-to-edge": 33071,
repeat: 10497,
"mirror-repeat": 33648
};
const compareModeToGlCompare = {
never: 512,
less: 513,
equal: 514,
"less-equal": 515,
greater: 516,
"not-equal": 517,
"greater-equal": 518,
always: 519
};
export { compareModeToGlCompare, mipmapScaleModeToGlFilter, scaleModeToGlFilter, wrapModeToGlAddress };
//# sourceMappingURL=pixiToGlMaps.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"pixiToGlMaps.mjs","sources":["../../../../../../src/rendering/renderers/gl/texture/utils/pixiToGlMaps.ts"],"sourcesContent":["export const scaleModeToGlFilter = {\n linear: 9729,\n nearest: 9728,\n};\n\nexport const mipmapScaleModeToGlFilter = {\n linear: {\n linear: 9987,\n nearest: 9985,\n },\n nearest: {\n linear: 9986,\n nearest: 9984,\n }\n};\n\nexport const wrapModeToGlAddress = {\n 'clamp-to-edge': 33071,\n repeat: 10497,\n 'mirror-repeat': 33648,\n};\n\nexport const compareModeToGlCompare = {\n never: 512,\n less: 513,\n equal: 514,\n 'less-equal': 515,\n greater: 516,\n 'not-equal': 517,\n 'greater-equal': 518,\n always: 519,\n};\n\n"],"names":[],"mappings":";AAAO,MAAM,mBAAsB,GAAA;AAAA,EAC/B,MAAQ,EAAA,IAAA;AAAA,EACR,OAAS,EAAA,IAAA;AACb,EAAA;AAEO,MAAM,yBAA4B,GAAA;AAAA,EACrC,MAAQ,EAAA;AAAA,IACJ,MAAQ,EAAA,IAAA;AAAA,IACR,OAAS,EAAA,IAAA;AAAA,GACb;AAAA,EACA,OAAS,EAAA;AAAA,IACL,MAAQ,EAAA,IAAA;AAAA,IACR,OAAS,EAAA,IAAA;AAAA,GACb;AACJ,EAAA;AAEO,MAAM,mBAAsB,GAAA;AAAA,EAC/B,eAAiB,EAAA,KAAA;AAAA,EACjB,MAAQ,EAAA,KAAA;AAAA,EACR,eAAiB,EAAA,KAAA;AACrB,EAAA;AAEO,MAAM,sBAAyB,GAAA;AAAA,EAClC,KAAO,EAAA,GAAA;AAAA,EACP,IAAM,EAAA,GAAA;AAAA,EACN,KAAO,EAAA,GAAA;AAAA,EACP,YAAc,EAAA,GAAA;AAAA,EACd,OAAS,EAAA,GAAA;AAAA,EACT,WAAa,EAAA,GAAA;AAAA,EACb,eAAiB,EAAA,GAAA;AAAA,EACjB,MAAQ,EAAA,GAAA;AACZ;;;;"}

View File

@@ -0,0 +1 @@
export declare function unpremultiplyAlpha(pixels: Uint8Array | Uint8ClampedArray): void;

View File

@@ -0,0 +1,21 @@
'use strict';
"use strict";
function unpremultiplyAlpha(pixels) {
if (pixels instanceof Uint8ClampedArray) {
pixels = new Uint8Array(pixels.buffer);
}
const n = pixels.length;
for (let i = 0; i < n; i += 4) {
const alpha = pixels[i + 3];
if (alpha !== 0) {
const a = 255.001 / alpha;
pixels[i] = pixels[i] * a + 0.5;
pixels[i + 1] = pixels[i + 1] * a + 0.5;
pixels[i + 2] = pixels[i + 2] * a + 0.5;
}
}
}
exports.unpremultiplyAlpha = unpremultiplyAlpha;
//# sourceMappingURL=unpremultiplyAlpha.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"unpremultiplyAlpha.js","sources":["../../../../../../src/rendering/renderers/gl/texture/utils/unpremultiplyAlpha.ts"],"sourcesContent":["export function unpremultiplyAlpha(pixels: Uint8Array | Uint8ClampedArray): void\n{\n if (pixels instanceof Uint8ClampedArray)\n {\n pixels = new Uint8Array(pixels.buffer);\n }\n\n const n = pixels.length;\n\n for (let i = 0; i < n; i += 4)\n {\n const alpha = pixels[i + 3];\n\n if (alpha !== 0)\n {\n const a = 255.001 / alpha;\n\n pixels[i] = (pixels[i] * a) + 0.5;\n pixels[i + 1] = (pixels[i + 1] * a) + 0.5;\n pixels[i + 2] = (pixels[i + 2] * a) + 0.5;\n }\n }\n}\n"],"names":[],"mappings":";;;AAAO,SAAS,mBAAmB,MACnC,EAAA;AACI,EAAA,IAAI,kBAAkB,iBACtB,EAAA;AACI,IAAS,MAAA,GAAA,IAAI,UAAW,CAAA,MAAA,CAAO,MAAM,CAAA,CAAA;AAAA,GACzC;AAEA,EAAA,MAAM,IAAI,MAAO,CAAA,MAAA,CAAA;AAEjB,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,CAAA,EAAG,KAAK,CAC5B,EAAA;AACI,IAAM,MAAA,KAAA,GAAQ,MAAO,CAAA,CAAA,GAAI,CAAC,CAAA,CAAA;AAE1B,IAAA,IAAI,UAAU,CACd,EAAA;AACI,MAAA,MAAM,IAAI,OAAU,GAAA,KAAA,CAAA;AAEpB,MAAA,MAAA,CAAO,CAAC,CAAA,GAAK,MAAO,CAAA,CAAC,IAAI,CAAK,GAAA,GAAA,CAAA;AAC9B,MAAA,MAAA,CAAO,IAAI,CAAC,CAAA,GAAK,OAAO,CAAI,GAAA,CAAC,IAAI,CAAK,GAAA,GAAA,CAAA;AACtC,MAAA,MAAA,CAAO,IAAI,CAAC,CAAA,GAAK,OAAO,CAAI,GAAA,CAAC,IAAI,CAAK,GAAA,GAAA,CAAA;AAAA,KAC1C;AAAA,GACJ;AACJ;;;;"}

View File

@@ -0,0 +1,19 @@
"use strict";
function unpremultiplyAlpha(pixels) {
if (pixels instanceof Uint8ClampedArray) {
pixels = new Uint8Array(pixels.buffer);
}
const n = pixels.length;
for (let i = 0; i < n; i += 4) {
const alpha = pixels[i + 3];
if (alpha !== 0) {
const a = 255.001 / alpha;
pixels[i] = pixels[i] * a + 0.5;
pixels[i + 1] = pixels[i + 1] * a + 0.5;
pixels[i + 2] = pixels[i + 2] * a + 0.5;
}
}
}
export { unpremultiplyAlpha };
//# sourceMappingURL=unpremultiplyAlpha.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"unpremultiplyAlpha.mjs","sources":["../../../../../../src/rendering/renderers/gl/texture/utils/unpremultiplyAlpha.ts"],"sourcesContent":["export function unpremultiplyAlpha(pixels: Uint8Array | Uint8ClampedArray): void\n{\n if (pixels instanceof Uint8ClampedArray)\n {\n pixels = new Uint8Array(pixels.buffer);\n }\n\n const n = pixels.length;\n\n for (let i = 0; i < n; i += 4)\n {\n const alpha = pixels[i + 3];\n\n if (alpha !== 0)\n {\n const a = 255.001 / alpha;\n\n pixels[i] = (pixels[i] * a) + 0.5;\n pixels[i + 1] = (pixels[i + 1] * a) + 0.5;\n pixels[i + 2] = (pixels[i + 2] * a) + 0.5;\n }\n }\n}\n"],"names":[],"mappings":";AAAO,SAAS,mBAAmB,MACnC,EAAA;AACI,EAAA,IAAI,kBAAkB,iBACtB,EAAA;AACI,IAAS,MAAA,GAAA,IAAI,UAAW,CAAA,MAAA,CAAO,MAAM,CAAA,CAAA;AAAA,GACzC;AAEA,EAAA,MAAM,IAAI,MAAO,CAAA,MAAA,CAAA;AAEjB,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,CAAA,EAAG,KAAK,CAC5B,EAAA;AACI,IAAM,MAAA,KAAA,GAAQ,MAAO,CAAA,CAAA,GAAI,CAAC,CAAA,CAAA;AAE1B,IAAA,IAAI,UAAU,CACd,EAAA;AACI,MAAA,MAAM,IAAI,OAAU,GAAA,KAAA,CAAA;AAEpB,MAAA,MAAA,CAAO,CAAC,CAAA,GAAK,MAAO,CAAA,CAAC,IAAI,CAAK,GAAA,GAAA,CAAA;AAC9B,MAAA,MAAA,CAAO,IAAI,CAAC,CAAA,GAAK,OAAO,CAAI,GAAA,CAAC,IAAI,CAAK,GAAA,GAAA,CAAA;AACtC,MAAA,MAAA,CAAO,IAAI,CAAC,CAAA,GAAK,OAAO,CAAI,GAAA,CAAC,IAAI,CAAK,GAAA,GAAA,CAAA;AAAA,KAC1C;AAAA,GACJ;AACJ;;;;"}