Skip to content

Commit

Permalink
feat: support multiple render target (#43)
Browse files Browse the repository at this point in the history
* feat: support multiple render targets #42

* chore: split utils

* chore: commit changeset
  • Loading branch information
xiaoiver authored Sep 28, 2023
1 parent c6f2498 commit 5d930c0
Show file tree
Hide file tree
Showing 28 changed files with 415 additions and 297 deletions.
5 changes: 5 additions & 0 deletions .changeset/nasty-eggs-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@antv/g-device-api': minor
---

Support multiple render targets.
21 changes: 5 additions & 16 deletions examples/demos/add-2-vectors.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
import {
DeviceContribution,
VertexStepMode,
Format,
TransparentWhite,
Buffer,
Bindings,
BufferUsage,
} from '../../src';
import { initExample } from './utils';
import { DeviceContribution, BufferUsage } from '../../src';

/**
* Use Compute Shader with WebGPU
Expand Down Expand Up @@ -94,9 +85,7 @@ export async function render(
};
}

export async function Add2Vectors($container: HTMLDivElement) {
return initExample($container, render, {
targets: ['webgpu'],
default: 'webgpu',
});
}
render.params = {
targets: ['webgpu'],
default: 'webgpu',
};
13 changes: 5 additions & 8 deletions examples/demos/ar-three.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ARButton } from 'three/examples/jsm/webxr/ARButton';
import { initExample } from './utils';
import { DeviceContribution } from '../../src';
import {
AmbientLight,
Expand Down Expand Up @@ -65,10 +64,8 @@ export async function render(
return () => {};
}

export async function ARThree($container: HTMLDivElement) {
return initExample($container, render, {
targets: ['webgl1', 'webgl2'],
xrCompatible: true,
default: 'webgl1',
});
}
render.params = {
targets: ['webgl1', 'webgl2'],
xrCompatible: true,
default: 'webgl1',
};
13 changes: 5 additions & 8 deletions examples/demos/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
CompareFunction,
TransparentWhite,
} from '../../src';
import { initExample } from './utils';
import { vec3, mat4, quat } from 'gl-matrix';
import {
cubeVertexArray,
Expand Down Expand Up @@ -279,10 +278,8 @@ export async function render(
};
}

export async function AR($container: HTMLDivElement) {
return initExample($container, render, {
targets: ['webgl1', 'webgl2'],
xrCompatible: true,
default: 'webgl2',
});
}
render.params = {
targets: ['webgl1', 'webgl2'],
xrCompatible: true,
default: 'webgl2',
};
11 changes: 4 additions & 7 deletions examples/demos/blit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
TransparentBlack,
CompareFunction,
} from '../../src';
import { initExample } from './utils';
import { vec3, mat4 } from 'gl-matrix';
import {
cubeVertexArray,
Expand Down Expand Up @@ -234,9 +233,7 @@ void main() {
};
}

export async function Blit($container: HTMLDivElement) {
return initExample($container, render, {
targets: ['webgl1', 'webgl2', 'webgpu'],
default: 'webgl2',
});
}
render.params = {
targets: ['webgl1', 'webgl2', 'webgpu'],
default: 'webgl2',
};
11 changes: 4 additions & 7 deletions examples/demos/compute-boids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
Bindings,
BufferUsage,
} from '../../src';
import { initExample } from './utils';

/**
* Use Compute Shader with WebGPU
Expand Down Expand Up @@ -350,9 +349,7 @@ fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
};
}

export async function ComputeBoids($container: HTMLDivElement) {
return initExample($container, render, {
targets: ['webgpu'],
default: 'webgpu',
});
}
render.params = {
targets: ['webgpu'],
default: 'webgpu',
};
12 changes: 5 additions & 7 deletions examples/demos/cubemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
MipmapFilterMode,
TextureDimension,
} from '../../src';
import { initExample, loadImage } from './utils';
import { loadImage } from '../utils/image';
import { vec3, mat4 } from 'gl-matrix';
import {
cubeVertexArray,
Expand Down Expand Up @@ -314,9 +314,7 @@ void main() {
};
}

export async function Cubemap($container: HTMLDivElement) {
return initExample($container, render, {
targets: ['webgl1', 'webgl2', 'webgpu'],
default: 'webgl2',
});
}
render.params = {
targets: ['webgl1', 'webgl2', 'webgpu'],
default: 'webgl2',
};
11 changes: 4 additions & 7 deletions examples/demos/draw-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
BufferFrequencyHint,
TextureUsage,
} from '../../src';
import { initExample } from './utils';

export async function render(
deviceContribution: DeviceContribution,
Expand Down Expand Up @@ -142,9 +141,7 @@ void main() {
};
}

export async function DrawIndex($container: HTMLDivElement) {
return initExample($container, render, {
targets: ['webgl1', 'webgl2', 'webgpu'],
default: 'webgl2',
});
}
render.params = {
targets: ['webgl1', 'webgl2', 'webgpu'],
default: 'webgl2',
};
35 changes: 18 additions & 17 deletions examples/demos/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
export { PrimitiveTopologyPoints } from './primitive-topology-points';
export { PrimitiveTopologyTriangles } from './primitive-topology-triangles';
export { DrawIndex } from './draw-index';
export { MSAA } from './msaa';
export { Blit } from './blit';
export { RotatingCube } from './rotating-cube';
export { Stencil } from './stencil';
export { Scissor } from './scissor';
export { TwoCubes } from './two-cubes';
export { TexturedCube } from './textured-cube';
export { Sampler } from './sampler';
export { InstancedCubes } from './instanced-cubes';
export { Cubemap } from './cubemap';
export { Add2Vectors } from './add-2-vectors';
export { ComputeBoids } from './compute-boids';
export { AR } from './ar';
export { ARThree } from './ar-three';
export { render as PrimitiveTopologyPoints } from './primitive-topology-points';
export { render as PrimitiveTopologyTriangles } from './primitive-topology-triangles';
export { render as DrawIndex } from './draw-index';
export { render as MSAA } from './msaa';
export { render as MultipleRenderTargets } from './multiple-render-targets';
export { render as Blit } from './blit';
export { render as RotatingCube } from './rotating-cube';
export { render as Stencil } from './stencil';
export { render as Scissor } from './scissor';
export { render as TwoCubes } from './two-cubes';
export { render as TexturedCube } from './textured-cube';
export { render as Sampler } from './sampler';
export { render as InstancedCubes } from './instanced-cubes';
export { render as Cubemap } from './cubemap';
export { render as Add2Vectors } from './add-2-vectors';
export { render as ComputeBoids } from './compute-boids';
export { render as AR } from './ar';
export { render as ARThree } from './ar-three';
11 changes: 4 additions & 7 deletions examples/demos/instanced-cubes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
CompareFunction,
CullMode,
} from '../../src';
import { initExample } from './utils';
import { vec3, mat4 } from 'gl-matrix';
import {
cubeVertexArray,
Expand Down Expand Up @@ -277,9 +276,7 @@ void main() {
};
}

export async function InstancedCubes($container: HTMLDivElement) {
return initExample($container, render, {
targets: ['webgl2', 'webgpu'],
default: 'webgl2',
});
}
render.params = {
targets: ['webgl2', 'webgpu'],
default: 'webgl2',
};
11 changes: 4 additions & 7 deletions examples/demos/msaa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
BufferUsage,
BufferFrequencyHint,
} from '../../src';
import { initExample } from './utils';

export async function render(
deviceContribution: DeviceContribution,
Expand Down Expand Up @@ -131,9 +130,7 @@ void main() {
};
}

export async function MSAA($container: HTMLDivElement) {
return initExample($container, render, {
targets: ['webgl2', 'webgpu'],
default: 'webgl2',
});
}
render.params = {
targets: ['webgl2', 'webgpu'],
default: 'webgl2',
};
Loading

0 comments on commit 5d930c0

Please sign in to comment.