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,16 @@
/// <reference types="@webgpu/types" />
import type { TextureSource } from '../../shared/texture/sources/TextureSource';
/**
* A class which holds the canvas contexts and textures for a render target.
* @memberof rendering
* @ignore
*/
export declare class GpuRenderTarget {
contexts: GPUCanvasContext[];
msaaTextures: TextureSource[];
msaa: boolean;
msaaSamples: number;
width: number;
height: number;
descriptor: GPURenderPassDescriptor;
}

View File

@@ -0,0 +1,13 @@
'use strict';
"use strict";
class GpuRenderTarget {
constructor() {
this.contexts = [];
this.msaaTextures = [];
this.msaaSamples = 1;
}
}
exports.GpuRenderTarget = GpuRenderTarget;
//# sourceMappingURL=GpuRenderTarget.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"GpuRenderTarget.js","sources":["../../../../../src/rendering/renderers/gpu/renderTarget/GpuRenderTarget.ts"],"sourcesContent":["import type { TextureSource } from '../../shared/texture/sources/TextureSource';\n\n/**\n * A class which holds the canvas contexts and textures for a render target.\n * @memberof rendering\n * @ignore\n */\nexport class GpuRenderTarget\n{\n public contexts: GPUCanvasContext[] = [];\n public msaaTextures: TextureSource[] = [];\n public msaa: boolean;\n public msaaSamples = 1;\n public width: number;\n public height: number;\n public descriptor: GPURenderPassDescriptor;\n}\n"],"names":[],"mappings":";;;AAOO,MAAM,eACb,CAAA;AAAA,EADO,WAAA,GAAA;AAEH,IAAA,IAAA,CAAO,WAA+B,EAAC,CAAA;AACvC,IAAA,IAAA,CAAO,eAAgC,EAAC,CAAA;AAExC,IAAA,IAAA,CAAO,WAAc,GAAA,CAAA,CAAA;AAAA,GAAA;AAIzB;;;;"}

View File

@@ -0,0 +1,11 @@
"use strict";
class GpuRenderTarget {
constructor() {
this.contexts = [];
this.msaaTextures = [];
this.msaaSamples = 1;
}
}
export { GpuRenderTarget };
//# sourceMappingURL=GpuRenderTarget.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"GpuRenderTarget.mjs","sources":["../../../../../src/rendering/renderers/gpu/renderTarget/GpuRenderTarget.ts"],"sourcesContent":["import type { TextureSource } from '../../shared/texture/sources/TextureSource';\n\n/**\n * A class which holds the canvas contexts and textures for a render target.\n * @memberof rendering\n * @ignore\n */\nexport class GpuRenderTarget\n{\n public contexts: GPUCanvasContext[] = [];\n public msaaTextures: TextureSource[] = [];\n public msaa: boolean;\n public msaaSamples = 1;\n public width: number;\n public height: number;\n public descriptor: GPURenderPassDescriptor;\n}\n"],"names":[],"mappings":";AAOO,MAAM,eACb,CAAA;AAAA,EADO,WAAA,GAAA;AAEH,IAAA,IAAA,CAAO,WAA+B,EAAC,CAAA;AACvC,IAAA,IAAA,CAAO,eAAgC,EAAC,CAAA;AAExC,IAAA,IAAA,CAAO,WAAc,GAAA,CAAA,CAAA;AAAA,GAAA;AAIzB;;;;"}

View File

@@ -0,0 +1,46 @@
/// <reference types="@webgpu/types" />
import { TextureSource } from '../../shared/texture/sources/TextureSource';
import { GpuRenderTarget } from './GpuRenderTarget';
import type { RgbaArray } from '../../../../color/Color';
import type { Rectangle } from '../../../../maths/shapes/Rectangle';
import type { CLEAR_OR_BOOL } from '../../gl/const';
import type { RenderTarget } from '../../shared/renderTarget/RenderTarget';
import type { RenderTargetAdaptor, RenderTargetSystem } from '../../shared/renderTarget/RenderTargetSystem';
import type { Texture } from '../../shared/texture/Texture';
import type { WebGPURenderer } from '../WebGPURenderer';
/**
* The WebGPU adaptor for the render target system. Allows the Render Target System to
* be used with the WebGPU renderer
* @memberof rendering
* @ignore
*/
export declare class GpuRenderTargetAdaptor implements RenderTargetAdaptor<GpuRenderTarget> {
private _renderTargetSystem;
private _renderer;
init(renderer: WebGPURenderer, renderTargetSystem: RenderTargetSystem<GpuRenderTarget>): void;
copyToTexture(sourceRenderSurfaceTexture: RenderTarget, destinationTexture: Texture, originSrc: {
x: number;
y: number;
}, size: {
width: number;
height: number;
}, originDest: {
x: number;
y: number;
}): Texture<TextureSource<any>>;
startRenderPass(renderTarget: RenderTarget, clear?: CLEAR_OR_BOOL, clearColor?: RgbaArray, viewport?: Rectangle): void;
finishRenderPass(): void;
/**
* returns the gpu texture for the first color texture in the render target
* mainly used by the filter manager to get copy the texture for blending
* @param renderTarget
* @returns a gpu texture
*/
private _getGpuColorTexture;
getDescriptor(renderTarget: RenderTarget, clear: CLEAR_OR_BOOL, clearValue: RgbaArray): GPURenderPassDescriptor;
clear(renderTarget: RenderTarget, clear?: CLEAR_OR_BOOL, clearColor?: RgbaArray, viewport?: Rectangle): void;
initGpuRenderTarget(renderTarget: RenderTarget): GpuRenderTarget;
destroyGpuRenderTarget(gpuRenderTarget: GpuRenderTarget): void;
ensureDepthStencilTexture(renderTarget: RenderTarget): void;
resizeGpuRenderTarget(renderTarget: RenderTarget): void;
}

View File

@@ -0,0 +1,214 @@
'use strict';
var _const = require('../../gl/const.js');
var CanvasSource = require('../../shared/texture/sources/CanvasSource.js');
var TextureSource = require('../../shared/texture/sources/TextureSource.js');
var GpuRenderTarget = require('./GpuRenderTarget.js');
"use strict";
class GpuRenderTargetAdaptor {
init(renderer, renderTargetSystem) {
this._renderer = renderer;
this._renderTargetSystem = renderTargetSystem;
}
copyToTexture(sourceRenderSurfaceTexture, destinationTexture, originSrc, size, originDest) {
const renderer = this._renderer;
const baseGpuTexture = this._getGpuColorTexture(
sourceRenderSurfaceTexture
);
const backGpuTexture = renderer.texture.getGpuSource(
destinationTexture.source
);
renderer.encoder.commandEncoder.copyTextureToTexture(
{
texture: baseGpuTexture,
origin: originSrc
},
{
texture: backGpuTexture,
origin: originDest
},
size
);
return destinationTexture;
}
startRenderPass(renderTarget, clear = true, clearColor, viewport) {
const renderTargetSystem = this._renderTargetSystem;
const gpuRenderTarget = renderTargetSystem.getGpuRenderTarget(renderTarget);
const descriptor = this.getDescriptor(renderTarget, clear, clearColor);
gpuRenderTarget.descriptor = descriptor;
this._renderer.pipeline.setRenderTarget(gpuRenderTarget);
this._renderer.encoder.beginRenderPass(gpuRenderTarget);
this._renderer.encoder.setViewport(viewport);
}
finishRenderPass() {
this._renderer.encoder.endRenderPass();
}
/**
* returns the gpu texture for the first color texture in the render target
* mainly used by the filter manager to get copy the texture for blending
* @param renderTarget
* @returns a gpu texture
*/
_getGpuColorTexture(renderTarget) {
const gpuRenderTarget = this._renderTargetSystem.getGpuRenderTarget(renderTarget);
if (gpuRenderTarget.contexts[0]) {
return gpuRenderTarget.contexts[0].getCurrentTexture();
}
return this._renderer.texture.getGpuSource(
renderTarget.colorTextures[0].source
);
}
getDescriptor(renderTarget, clear, clearValue) {
if (typeof clear === "boolean") {
clear = clear ? _const.CLEAR.ALL : _const.CLEAR.NONE;
}
const renderTargetSystem = this._renderTargetSystem;
const gpuRenderTarget = renderTargetSystem.getGpuRenderTarget(renderTarget);
const colorAttachments = renderTarget.colorTextures.map(
(texture, i) => {
const context = gpuRenderTarget.contexts[i];
let view;
let resolveTarget;
if (context) {
const currentTexture = context.getCurrentTexture();
const canvasTextureView = currentTexture.createView();
view = canvasTextureView;
} else {
view = this._renderer.texture.getGpuSource(texture).createView({
mipLevelCount: 1
});
}
if (gpuRenderTarget.msaaTextures[i]) {
resolveTarget = view;
view = this._renderer.texture.getTextureView(
gpuRenderTarget.msaaTextures[i]
);
}
const loadOp = clear & _const.CLEAR.COLOR ? "clear" : "load";
clearValue ?? (clearValue = renderTargetSystem.defaultClearColor);
return {
view,
resolveTarget,
clearValue,
storeOp: "store",
loadOp
};
}
);
let depthStencilAttachment;
if ((renderTarget.stencil || renderTarget.depth) && !renderTarget.depthStencilTexture) {
renderTarget.ensureDepthStencilTexture();
renderTarget.depthStencilTexture.source.sampleCount = gpuRenderTarget.msaa ? 4 : 1;
}
if (renderTarget.depthStencilTexture) {
const stencilLoadOp = clear & _const.CLEAR.STENCIL ? "clear" : "load";
const depthLoadOp = clear & _const.CLEAR.DEPTH ? "clear" : "load";
depthStencilAttachment = {
view: this._renderer.texture.getGpuSource(renderTarget.depthStencilTexture.source).createView(),
stencilStoreOp: "store",
stencilLoadOp,
depthClearValue: 1,
depthLoadOp,
depthStoreOp: "store"
};
}
const descriptor = {
colorAttachments,
depthStencilAttachment
};
return descriptor;
}
clear(renderTarget, clear = true, clearColor, viewport) {
if (!clear)
return;
const { gpu, encoder } = this._renderer;
const device = gpu.device;
const standAlone = encoder.commandEncoder === null;
if (standAlone) {
const commandEncoder = device.createCommandEncoder();
const renderPassDescriptor = this.getDescriptor(renderTarget, clear, clearColor);
const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
passEncoder.setViewport(viewport.x, viewport.y, viewport.width, viewport.height, 0, 1);
passEncoder.end();
const gpuCommands = commandEncoder.finish();
device.queue.submit([gpuCommands]);
} else {
this.startRenderPass(renderTarget, clear, clearColor, viewport);
}
}
initGpuRenderTarget(renderTarget) {
renderTarget.isRoot = true;
const gpuRenderTarget = new GpuRenderTarget.GpuRenderTarget();
renderTarget.colorTextures.forEach((colorTexture, i) => {
if (CanvasSource.CanvasSource.test(colorTexture.resource)) {
const context = colorTexture.resource.getContext(
"webgpu"
);
const alphaMode = colorTexture.transparent ? "premultiplied" : "opaque";
try {
context.configure({
device: this._renderer.gpu.device,
// eslint-disable-next-line max-len
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC,
format: "bgra8unorm",
alphaMode
});
} catch (e) {
console.error(e);
}
gpuRenderTarget.contexts[i] = context;
}
gpuRenderTarget.msaa = colorTexture.source.antialias;
if (colorTexture.source.antialias) {
const msaaTexture = new TextureSource.TextureSource({
width: 0,
height: 0,
sampleCount: 4
});
gpuRenderTarget.msaaTextures[i] = msaaTexture;
}
});
if (gpuRenderTarget.msaa) {
gpuRenderTarget.msaaSamples = 4;
if (renderTarget.depthStencilTexture) {
renderTarget.depthStencilTexture.source.sampleCount = 4;
}
}
return gpuRenderTarget;
}
destroyGpuRenderTarget(gpuRenderTarget) {
gpuRenderTarget.contexts.forEach((context) => {
context.unconfigure();
});
gpuRenderTarget.msaaTextures.forEach((texture) => {
texture.destroy();
});
gpuRenderTarget.msaaTextures.length = 0;
gpuRenderTarget.contexts.length = 0;
}
ensureDepthStencilTexture(renderTarget) {
const gpuRenderTarget = this._renderTargetSystem.getGpuRenderTarget(renderTarget);
if (renderTarget.depthStencilTexture && gpuRenderTarget.msaa) {
renderTarget.depthStencilTexture.source.sampleCount = 4;
}
}
resizeGpuRenderTarget(renderTarget) {
const gpuRenderTarget = this._renderTargetSystem.getGpuRenderTarget(renderTarget);
gpuRenderTarget.width = renderTarget.width;
gpuRenderTarget.height = renderTarget.height;
if (gpuRenderTarget.msaa) {
renderTarget.colorTextures.forEach((colorTexture, i) => {
const msaaTexture = gpuRenderTarget.msaaTextures[i];
msaaTexture?.resize(
colorTexture.source.width,
colorTexture.source.height,
colorTexture.source._resolution
);
});
}
}
}
exports.GpuRenderTargetAdaptor = GpuRenderTargetAdaptor;
//# sourceMappingURL=GpuRenderTargetAdaptor.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,212 @@
import { CLEAR } from '../../gl/const.mjs';
import { CanvasSource } from '../../shared/texture/sources/CanvasSource.mjs';
import { TextureSource } from '../../shared/texture/sources/TextureSource.mjs';
import { GpuRenderTarget } from './GpuRenderTarget.mjs';
"use strict";
class GpuRenderTargetAdaptor {
init(renderer, renderTargetSystem) {
this._renderer = renderer;
this._renderTargetSystem = renderTargetSystem;
}
copyToTexture(sourceRenderSurfaceTexture, destinationTexture, originSrc, size, originDest) {
const renderer = this._renderer;
const baseGpuTexture = this._getGpuColorTexture(
sourceRenderSurfaceTexture
);
const backGpuTexture = renderer.texture.getGpuSource(
destinationTexture.source
);
renderer.encoder.commandEncoder.copyTextureToTexture(
{
texture: baseGpuTexture,
origin: originSrc
},
{
texture: backGpuTexture,
origin: originDest
},
size
);
return destinationTexture;
}
startRenderPass(renderTarget, clear = true, clearColor, viewport) {
const renderTargetSystem = this._renderTargetSystem;
const gpuRenderTarget = renderTargetSystem.getGpuRenderTarget(renderTarget);
const descriptor = this.getDescriptor(renderTarget, clear, clearColor);
gpuRenderTarget.descriptor = descriptor;
this._renderer.pipeline.setRenderTarget(gpuRenderTarget);
this._renderer.encoder.beginRenderPass(gpuRenderTarget);
this._renderer.encoder.setViewport(viewport);
}
finishRenderPass() {
this._renderer.encoder.endRenderPass();
}
/**
* returns the gpu texture for the first color texture in the render target
* mainly used by the filter manager to get copy the texture for blending
* @param renderTarget
* @returns a gpu texture
*/
_getGpuColorTexture(renderTarget) {
const gpuRenderTarget = this._renderTargetSystem.getGpuRenderTarget(renderTarget);
if (gpuRenderTarget.contexts[0]) {
return gpuRenderTarget.contexts[0].getCurrentTexture();
}
return this._renderer.texture.getGpuSource(
renderTarget.colorTextures[0].source
);
}
getDescriptor(renderTarget, clear, clearValue) {
if (typeof clear === "boolean") {
clear = clear ? CLEAR.ALL : CLEAR.NONE;
}
const renderTargetSystem = this._renderTargetSystem;
const gpuRenderTarget = renderTargetSystem.getGpuRenderTarget(renderTarget);
const colorAttachments = renderTarget.colorTextures.map(
(texture, i) => {
const context = gpuRenderTarget.contexts[i];
let view;
let resolveTarget;
if (context) {
const currentTexture = context.getCurrentTexture();
const canvasTextureView = currentTexture.createView();
view = canvasTextureView;
} else {
view = this._renderer.texture.getGpuSource(texture).createView({
mipLevelCount: 1
});
}
if (gpuRenderTarget.msaaTextures[i]) {
resolveTarget = view;
view = this._renderer.texture.getTextureView(
gpuRenderTarget.msaaTextures[i]
);
}
const loadOp = clear & CLEAR.COLOR ? "clear" : "load";
clearValue ?? (clearValue = renderTargetSystem.defaultClearColor);
return {
view,
resolveTarget,
clearValue,
storeOp: "store",
loadOp
};
}
);
let depthStencilAttachment;
if ((renderTarget.stencil || renderTarget.depth) && !renderTarget.depthStencilTexture) {
renderTarget.ensureDepthStencilTexture();
renderTarget.depthStencilTexture.source.sampleCount = gpuRenderTarget.msaa ? 4 : 1;
}
if (renderTarget.depthStencilTexture) {
const stencilLoadOp = clear & CLEAR.STENCIL ? "clear" : "load";
const depthLoadOp = clear & CLEAR.DEPTH ? "clear" : "load";
depthStencilAttachment = {
view: this._renderer.texture.getGpuSource(renderTarget.depthStencilTexture.source).createView(),
stencilStoreOp: "store",
stencilLoadOp,
depthClearValue: 1,
depthLoadOp,
depthStoreOp: "store"
};
}
const descriptor = {
colorAttachments,
depthStencilAttachment
};
return descriptor;
}
clear(renderTarget, clear = true, clearColor, viewport) {
if (!clear)
return;
const { gpu, encoder } = this._renderer;
const device = gpu.device;
const standAlone = encoder.commandEncoder === null;
if (standAlone) {
const commandEncoder = device.createCommandEncoder();
const renderPassDescriptor = this.getDescriptor(renderTarget, clear, clearColor);
const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
passEncoder.setViewport(viewport.x, viewport.y, viewport.width, viewport.height, 0, 1);
passEncoder.end();
const gpuCommands = commandEncoder.finish();
device.queue.submit([gpuCommands]);
} else {
this.startRenderPass(renderTarget, clear, clearColor, viewport);
}
}
initGpuRenderTarget(renderTarget) {
renderTarget.isRoot = true;
const gpuRenderTarget = new GpuRenderTarget();
renderTarget.colorTextures.forEach((colorTexture, i) => {
if (CanvasSource.test(colorTexture.resource)) {
const context = colorTexture.resource.getContext(
"webgpu"
);
const alphaMode = colorTexture.transparent ? "premultiplied" : "opaque";
try {
context.configure({
device: this._renderer.gpu.device,
// eslint-disable-next-line max-len
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC,
format: "bgra8unorm",
alphaMode
});
} catch (e) {
console.error(e);
}
gpuRenderTarget.contexts[i] = context;
}
gpuRenderTarget.msaa = colorTexture.source.antialias;
if (colorTexture.source.antialias) {
const msaaTexture = new TextureSource({
width: 0,
height: 0,
sampleCount: 4
});
gpuRenderTarget.msaaTextures[i] = msaaTexture;
}
});
if (gpuRenderTarget.msaa) {
gpuRenderTarget.msaaSamples = 4;
if (renderTarget.depthStencilTexture) {
renderTarget.depthStencilTexture.source.sampleCount = 4;
}
}
return gpuRenderTarget;
}
destroyGpuRenderTarget(gpuRenderTarget) {
gpuRenderTarget.contexts.forEach((context) => {
context.unconfigure();
});
gpuRenderTarget.msaaTextures.forEach((texture) => {
texture.destroy();
});
gpuRenderTarget.msaaTextures.length = 0;
gpuRenderTarget.contexts.length = 0;
}
ensureDepthStencilTexture(renderTarget) {
const gpuRenderTarget = this._renderTargetSystem.getGpuRenderTarget(renderTarget);
if (renderTarget.depthStencilTexture && gpuRenderTarget.msaa) {
renderTarget.depthStencilTexture.source.sampleCount = 4;
}
}
resizeGpuRenderTarget(renderTarget) {
const gpuRenderTarget = this._renderTargetSystem.getGpuRenderTarget(renderTarget);
gpuRenderTarget.width = renderTarget.width;
gpuRenderTarget.height = renderTarget.height;
if (gpuRenderTarget.msaa) {
renderTarget.colorTextures.forEach((colorTexture, i) => {
const msaaTexture = gpuRenderTarget.msaaTextures[i];
msaaTexture?.resize(
colorTexture.source.width,
colorTexture.source.height,
colorTexture.source._resolution
);
});
}
}
}
export { GpuRenderTargetAdaptor };
//# sourceMappingURL=GpuRenderTargetAdaptor.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,18 @@
import { ExtensionType } from '../../../../extensions/Extensions';
import { RenderTargetSystem } from '../../shared/renderTarget/RenderTargetSystem';
import { GpuRenderTargetAdaptor } from './GpuRenderTargetAdaptor';
import type { WebGPURenderer } from '../WebGPURenderer';
import type { GpuRenderTarget } from './GpuRenderTarget';
/**
* The WebGL adaptor for the render target system. Allows the Render Target System to be used with the WebGl renderer
* @memberof rendering
*/
export declare class GpuRenderTargetSystem extends RenderTargetSystem<GpuRenderTarget> {
/** @ignore */
static extension: {
readonly type: readonly [ExtensionType.WebGPUSystem];
readonly name: "renderTarget";
};
adaptor: GpuRenderTargetAdaptor;
constructor(renderer: WebGPURenderer);
}

View File

@@ -0,0 +1,22 @@
'use strict';
var Extensions = require('../../../../extensions/Extensions.js');
var RenderTargetSystem = require('../../shared/renderTarget/RenderTargetSystem.js');
var GpuRenderTargetAdaptor = require('./GpuRenderTargetAdaptor.js');
"use strict";
class GpuRenderTargetSystem extends RenderTargetSystem.RenderTargetSystem {
constructor(renderer) {
super(renderer);
this.adaptor = new GpuRenderTargetAdaptor.GpuRenderTargetAdaptor();
this.adaptor.init(renderer, this);
}
}
/** @ignore */
GpuRenderTargetSystem.extension = {
type: [Extensions.ExtensionType.WebGPUSystem],
name: "renderTarget"
};
exports.GpuRenderTargetSystem = GpuRenderTargetSystem;
//# sourceMappingURL=GpuRenderTargetSystem.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"GpuRenderTargetSystem.js","sources":["../../../../../src/rendering/renderers/gpu/renderTarget/GpuRenderTargetSystem.ts"],"sourcesContent":["import { ExtensionType } from '../../../../extensions/Extensions';\nimport { RenderTargetSystem } from '../../shared/renderTarget/RenderTargetSystem';\nimport { GpuRenderTargetAdaptor } from './GpuRenderTargetAdaptor';\n\nimport type { WebGPURenderer } from '../WebGPURenderer';\nimport type { GpuRenderTarget } from './GpuRenderTarget';\n\n/**\n * The WebGL adaptor for the render target system. Allows the Render Target System to be used with the WebGl renderer\n * @memberof rendering\n */\nexport class GpuRenderTargetSystem extends RenderTargetSystem<GpuRenderTarget>\n{\n /** @ignore */\n public static extension = {\n type: [ExtensionType.WebGPUSystem],\n name: 'renderTarget',\n } as const;\n\n public adaptor = new GpuRenderTargetAdaptor();\n\n constructor(renderer: WebGPURenderer)\n {\n super(renderer);\n\n this.adaptor.init(renderer, this);\n }\n}\n"],"names":["RenderTargetSystem","GpuRenderTargetAdaptor","ExtensionType"],"mappings":";;;;;;;AAWO,MAAM,8BAA8BA,qCAC3C,CAAA;AAAA,EASI,YAAY,QACZ,EAAA;AACI,IAAA,KAAA,CAAM,QAAQ,CAAA,CAAA;AAJlB,IAAO,IAAA,CAAA,OAAA,GAAU,IAAIC,6CAAuB,EAAA,CAAA;AAMxC,IAAK,IAAA,CAAA,OAAA,CAAQ,IAAK,CAAA,QAAA,EAAU,IAAI,CAAA,CAAA;AAAA,GACpC;AACJ,CAAA;AAAA;AAhBa,qBAAA,CAGK,SAAY,GAAA;AAAA,EACtB,IAAA,EAAM,CAACC,wBAAA,CAAc,YAAY,CAAA;AAAA,EACjC,IAAM,EAAA,cAAA;AACV,CAAA;;;;"}

View File

@@ -0,0 +1,20 @@
import { ExtensionType } from '../../../../extensions/Extensions.mjs';
import { RenderTargetSystem } from '../../shared/renderTarget/RenderTargetSystem.mjs';
import { GpuRenderTargetAdaptor } from './GpuRenderTargetAdaptor.mjs';
"use strict";
class GpuRenderTargetSystem extends RenderTargetSystem {
constructor(renderer) {
super(renderer);
this.adaptor = new GpuRenderTargetAdaptor();
this.adaptor.init(renderer, this);
}
}
/** @ignore */
GpuRenderTargetSystem.extension = {
type: [ExtensionType.WebGPUSystem],
name: "renderTarget"
};
export { GpuRenderTargetSystem };
//# sourceMappingURL=GpuRenderTargetSystem.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"GpuRenderTargetSystem.mjs","sources":["../../../../../src/rendering/renderers/gpu/renderTarget/GpuRenderTargetSystem.ts"],"sourcesContent":["import { ExtensionType } from '../../../../extensions/Extensions';\nimport { RenderTargetSystem } from '../../shared/renderTarget/RenderTargetSystem';\nimport { GpuRenderTargetAdaptor } from './GpuRenderTargetAdaptor';\n\nimport type { WebGPURenderer } from '../WebGPURenderer';\nimport type { GpuRenderTarget } from './GpuRenderTarget';\n\n/**\n * The WebGL adaptor for the render target system. Allows the Render Target System to be used with the WebGl renderer\n * @memberof rendering\n */\nexport class GpuRenderTargetSystem extends RenderTargetSystem<GpuRenderTarget>\n{\n /** @ignore */\n public static extension = {\n type: [ExtensionType.WebGPUSystem],\n name: 'renderTarget',\n } as const;\n\n public adaptor = new GpuRenderTargetAdaptor();\n\n constructor(renderer: WebGPURenderer)\n {\n super(renderer);\n\n this.adaptor.init(renderer, this);\n }\n}\n"],"names":[],"mappings":";;;;;AAWO,MAAM,8BAA8B,kBAC3C,CAAA;AAAA,EASI,YAAY,QACZ,EAAA;AACI,IAAA,KAAA,CAAM,QAAQ,CAAA,CAAA;AAJlB,IAAO,IAAA,CAAA,OAAA,GAAU,IAAI,sBAAuB,EAAA,CAAA;AAMxC,IAAK,IAAA,CAAA,OAAA,CAAQ,IAAK,CAAA,QAAA,EAAU,IAAI,CAAA,CAAA;AAAA,GACpC;AACJ,CAAA;AAAA;AAhBa,qBAAA,CAGK,SAAY,GAAA;AAAA,EACtB,IAAA,EAAM,CAAC,aAAA,CAAc,YAAY,CAAA;AAAA,EACjC,IAAM,EAAA,cAAA;AACV,CAAA;;;;"}

View File

@@ -0,0 +1,2 @@
import type { Matrix } from '../../../../maths/matrix/Matrix';
export declare function calculateProjection(pm: Matrix, x: number, y: number, width: number, height: number, flipY: boolean): Matrix;

View File

@@ -0,0 +1,15 @@
'use strict';
"use strict";
function calculateProjection(pm, x, y, width, height, flipY) {
const sign = flipY ? 1 : -1;
pm.identity();
pm.a = 1 / width * 2;
pm.d = sign * (1 / height * 2);
pm.tx = -1 - x * pm.a;
pm.ty = -sign - y * pm.d;
return pm;
}
exports.calculateProjection = calculateProjection;
//# sourceMappingURL=calculateProjection.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"calculateProjection.js","sources":["../../../../../src/rendering/renderers/gpu/renderTarget/calculateProjection.ts"],"sourcesContent":["import type { Matrix } from '../../../../maths/matrix/Matrix';\n\nexport function calculateProjection(\n pm: Matrix,\n x: number,\n y: number,\n width: number,\n height: number,\n flipY: boolean\n): Matrix\n{\n const sign = flipY ? 1 : -1;\n\n pm.identity();\n\n pm.a = (1 / width * 2);\n pm.d = sign * (1 / height * 2);\n\n pm.tx = -1 - (x * pm.a);\n pm.ty = -sign - (y * pm.d);\n\n return pm;\n}\n"],"names":[],"mappings":";;;AAEO,SAAS,oBACZ,EACA,EAAA,CAAA,EACA,CACA,EAAA,KAAA,EACA,QACA,KAEJ,EAAA;AACI,EAAM,MAAA,IAAA,GAAO,QAAQ,CAAI,GAAA,CAAA,CAAA,CAAA;AAEzB,EAAA,EAAA,CAAG,QAAS,EAAA,CAAA;AAEZ,EAAG,EAAA,CAAA,CAAA,GAAK,IAAI,KAAQ,GAAA,CAAA,CAAA;AACpB,EAAG,EAAA,CAAA,CAAA,GAAI,IAAQ,IAAA,CAAA,GAAI,MAAS,GAAA,CAAA,CAAA,CAAA;AAE5B,EAAG,EAAA,CAAA,EAAA,GAAK,CAAM,CAAA,GAAA,CAAA,GAAI,EAAG,CAAA,CAAA,CAAA;AACrB,EAAA,EAAA,CAAG,EAAK,GAAA,CAAC,IAAQ,GAAA,CAAA,GAAI,EAAG,CAAA,CAAA,CAAA;AAExB,EAAO,OAAA,EAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,13 @@
"use strict";
function calculateProjection(pm, x, y, width, height, flipY) {
const sign = flipY ? 1 : -1;
pm.identity();
pm.a = 1 / width * 2;
pm.d = sign * (1 / height * 2);
pm.tx = -1 - x * pm.a;
pm.ty = -sign - y * pm.d;
return pm;
}
export { calculateProjection };
//# sourceMappingURL=calculateProjection.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"calculateProjection.mjs","sources":["../../../../../src/rendering/renderers/gpu/renderTarget/calculateProjection.ts"],"sourcesContent":["import type { Matrix } from '../../../../maths/matrix/Matrix';\n\nexport function calculateProjection(\n pm: Matrix,\n x: number,\n y: number,\n width: number,\n height: number,\n flipY: boolean\n): Matrix\n{\n const sign = flipY ? 1 : -1;\n\n pm.identity();\n\n pm.a = (1 / width * 2);\n pm.d = sign * (1 / height * 2);\n\n pm.tx = -1 - (x * pm.a);\n pm.ty = -sign - (y * pm.d);\n\n return pm;\n}\n"],"names":[],"mappings":";AAEO,SAAS,oBACZ,EACA,EAAA,CAAA,EACA,CACA,EAAA,KAAA,EACA,QACA,KAEJ,EAAA;AACI,EAAM,MAAA,IAAA,GAAO,QAAQ,CAAI,GAAA,CAAA,CAAA,CAAA;AAEzB,EAAA,EAAA,CAAG,QAAS,EAAA,CAAA;AAEZ,EAAG,EAAA,CAAA,CAAA,GAAK,IAAI,KAAQ,GAAA,CAAA,CAAA;AACpB,EAAG,EAAA,CAAA,CAAA,GAAI,IAAQ,IAAA,CAAA,GAAI,MAAS,GAAA,CAAA,CAAA,CAAA;AAE5B,EAAG,EAAA,CAAA,EAAA,GAAK,CAAM,CAAA,GAAA,CAAA,GAAI,EAAG,CAAA,CAAA,CAAA;AACrB,EAAA,EAAA,CAAG,EAAK,GAAA,CAAC,IAAQ,GAAA,CAAA,GAAI,EAAG,CAAA,CAAA,CAAA;AAExB,EAAO,OAAA,EAAA,CAAA;AACX;;;;"}