Skip to content

Commit

Permalink
Chore: Use Program.from for Caching (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbazukun123 authored Feb 8, 2024
1 parent a0feaeb commit 64b4114
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/adjustment/AdjustmentFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class AdjustmentFilter extends Filter
{
options = { ...AdjustmentFilter.DEFAULT_OPTIONS, ...options };

const gpuProgram = new GpuProgram({
const gpuProgram = GpuProgram.from({
vertex: {
source: wgslVertex,
entryPoint: 'mainVertex',
Expand All @@ -95,7 +95,7 @@ export class AdjustmentFilter extends Filter
},
});

const glProgram = new GlProgram({
const glProgram = GlProgram.from({
vertex,
fragment,
name: 'adjustment-filter'
Expand Down
4 changes: 2 additions & 2 deletions src/advanced-bloom/ExtractBrightnessFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class ExtractBrightnessFilter extends Filter
{
options = { ...ExtractBrightnessFilter.DEFAULT_OPTIONS, ...options };

const gpuProgram = new GpuProgram({
const gpuProgram = GpuProgram.from({
vertex: {
source: wgslVertex,
entryPoint: 'mainVertex',
Expand All @@ -42,7 +42,7 @@ export class ExtractBrightnessFilter extends Filter
},
});

const glProgram = new GlProgram({
const glProgram = GlProgram.from({
vertex,
fragment,
name: 'extract-brightness-filter',
Expand Down
4 changes: 2 additions & 2 deletions src/bevel/BevelFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class BevelFilter extends Filter

const rotation = (options.rotation ?? 45) * DEG_TO_RAD;

const gpuProgram = new GpuProgram({
const gpuProgram = GpuProgram.from({
vertex: {
source: wgslVertex,
entryPoint: 'mainVertex',
Expand All @@ -89,7 +89,7 @@ export class BevelFilter extends Filter
},
});

const glProgram = new GlProgram({
const glProgram = GlProgram.from({
vertex,
fragment,
name: 'bevel-filter',
Expand Down
4 changes: 2 additions & 2 deletions src/color-gradient/ColorGradientFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class ColorGradientFilter extends Filter
throw new Error('ColorGradientFilter requires at least 2 color stops.');
}

const gpuProgram = new GpuProgram({
const gpuProgram = GpuProgram.from({
vertex: {
source,
entryPoint: 'mainVertex',
Expand All @@ -108,7 +108,7 @@ export class ColorGradientFilter extends Filter
},
});

const glProgram = new GlProgram({
const glProgram = GlProgram.from({
vertex,
fragment,
name: 'color-gradient-filter',
Expand Down
4 changes: 2 additions & 2 deletions src/cross-hatch/CrossHatchFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class CrossHatchFilter extends Filter
{
constructor()
{
const gpuProgram = new GpuProgram({
const gpuProgram = GpuProgram.from({
vertex: {
source: wgslVertex,
entryPoint: 'mainVertex',
Expand All @@ -26,7 +26,7 @@ export class CrossHatchFilter extends Filter
},
});

const glProgram = new GlProgram({
const glProgram = GlProgram.from({
vertex,
fragment,
name: 'cross-hatch-filter',
Expand Down
4 changes: 2 additions & 2 deletions src/crt/CRTFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class CRTFilter extends Filter
{
options = { ...CRTFilter.DEFAULT_OPTIONS, ...options };

const gpuProgram = new GpuProgram({
const gpuProgram = GpuProgram.from({
vertex: {
source: wgslVertex,
entryPoint: 'mainVertex',
Expand All @@ -127,7 +127,7 @@ export class CRTFilter extends Filter
},
});

const glProgram = new GlProgram({
const glProgram = GlProgram.from({
vertex,
fragment,
name: 'crt-filter',
Expand Down
4 changes: 2 additions & 2 deletions src/glow/GlowFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class GlowFilter extends Filter
const distance = options.distance ?? 10;
const quality = options.quality ?? 0.1;

const gpuProgram = new GpuProgram({
const gpuProgram = GpuProgram.from({
vertex: {
source: wgslVertex,
entryPoint: 'mainVertex',
Expand All @@ -108,7 +108,7 @@ export class GlowFilter extends Filter
* since we hard-assign them during creation to allow
* for the values to be used in GLSL loops
*/
const glProgram = new GlProgram({
const glProgram = GlProgram.from({
vertex,
fragment: fragment
.replace(/__ANGLE_STEP_SIZE__/gi, `${(1 / quality / distance).toFixed(7)}`)
Expand Down
4 changes: 2 additions & 2 deletions src/grayscale/GrayscaleFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class GrayscaleFilter extends Filter
{
constructor()
{
const gpuProgram = new GpuProgram({
const gpuProgram = GpuProgram.from({
vertex: {
source: wgslVertex,
entryPoint: 'mainVertex',
Expand All @@ -26,7 +26,7 @@ export class GrayscaleFilter extends Filter
},
});

const glProgram = new GlProgram({
const glProgram = GlProgram.from({
vertex,
fragment,
name: 'grayscale-filter',
Expand Down
4 changes: 2 additions & 2 deletions src/hsl-adjustment/HslAdjustmentFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class HslAdjustmentFilter extends Filter
{
options = { ...HslAdjustmentFilter.DEFAULT_OPTIONS, ...options };

const gpuProgram = new GpuProgram({
const gpuProgram = GpuProgram.from({
vertex: {
source: wgslVertex,
entryPoint: 'mainVertex',
Expand All @@ -75,7 +75,7 @@ export class HslAdjustmentFilter extends Filter
},
});

const glProgram = new GlProgram({
const glProgram = GlProgram.from({
vertex,
fragment,
name: 'hsl-adjustment-filter',
Expand Down
4 changes: 2 additions & 2 deletions src/tilt-shift/TiltShiftAxisFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class TiltShiftAxisFilter extends Filter
{
options = { ...TiltShiftAxisFilter.DEFAULT_OPTIONS, ...options } as TiltShiftAxisFilterOptions;

const gpuProgram = new GpuProgram({
const gpuProgram = GpuProgram.from({
vertex: {
source: wgslVertex,
entryPoint: 'mainVertex',
Expand All @@ -70,7 +70,7 @@ export class TiltShiftAxisFilter extends Filter
},
});

const glProgram = new GlProgram({
const glProgram = GlProgram.from({
vertex,
fragment,
name: 'tilt-shift-axis-filter',
Expand Down
4 changes: 2 additions & 2 deletions src/twist/TwistFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class TwistFilter extends Filter
{
options = { ...TwistFilter.DEFAULT_OPTIONS, ...options };

const gpuProgram = new GpuProgram({
const gpuProgram = GpuProgram.from({
vertex: {
source: wgslVertex,
entryPoint: 'mainVertex',
Expand All @@ -67,7 +67,7 @@ export class TwistFilter extends Filter
},
});

const glProgram = new GlProgram({
const glProgram = GlProgram.from({
vertex,
fragment,
name: 'twist-filter',
Expand Down

0 comments on commit 64b4114

Please sign in to comment.