Skip to content

Commit

Permalink
Use a simpler clearValue
Browse files Browse the repository at this point in the history
This is obviously a personal preference but, ... I feel like
the `{ r: ?, g: ?, b: ?, a: ? }` format is left over from before
the time when an array of numbers was allowed?

The array of numbers is arguably more useful since all kinds of things
can easily provide an array of numbers. So, it seems like it would be good
for the samples to show the more useful usage. That way devs are not
mislead into thinking they need to take some array of numbers and
convert it into the more verbose format.
  • Loading branch information
greggman committed Apr 3, 2024
1 parent e6793c6 commit c653759
Show file tree
Hide file tree
Showing 28 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion sample/a-buffer/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const opaquePassDescriptor: GPURenderPassDescriptor = {
colorAttachments: [
{
view: undefined,
clearValue: { r: 0, g: 0, b: 0, a: 1.0 },
clearValue: [0, 0, 0, 1.0],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/animometer/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ function configure() {
colorAttachments: [
{
view: undefined as GPUTextureView, // Assigned later
clearValue: { r: 0.0, g: 0.0, b: 0.0, a: 1.0 },
clearValue: [0, 0, 0, 1],
loadOp: 'clear' as const,
storeOp: 'store' as const,
},
Expand Down
2 changes: 1 addition & 1 deletion sample/bitonicSort/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ SampleInitFactoryWebGPU(
{
view: undefined, // Assigned later

clearValue: { r: 0.1, g: 0.4, b: 0.5, a: 1.0 },
clearValue: [0.1, 0.4, 0.5, 1.0],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/cameras/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const renderPassDescriptor: GPURenderPassDescriptor = {
{
view: undefined, // Assigned later

clearValue: { r: 0.5, g: 0.5, b: 0.5, a: 1.0 },
clearValue: [0.5, 0.5, 0.5, 1.0],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/computeBoids/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const renderPassDescriptor: GPURenderPassDescriptor = {
colorAttachments: [
{
view: undefined as GPUTextureView, // Assigned later
clearValue: { r: 0.0, g: 0.0, b: 0.0, a: 1.0 },
clearValue: [0, 0, 0, 1],
loadOp: 'clear' as const,
storeOp: 'store' as const,
},
Expand Down
6 changes: 3 additions & 3 deletions sample/deferredRendering/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,14 @@ const writeGBufferPassDescriptor: GPURenderPassDescriptor = {
{
view: gBufferTextureViews[0],

clearValue: { r: 0.0, g: 0.0, b: 1.0, a: 1.0 },
clearValue: [0.0, 0.0, 1.0, 1.0],
loadOp: 'clear',
storeOp: 'store',
},
{
view: gBufferTextureViews[1],

clearValue: { r: 0.0, g: 0.0, b: 0.0, a: 1.0 },
clearValue: [0, 0, 0, 1],
loadOp: 'clear',
storeOp: 'store',
},
Expand All @@ -279,7 +279,7 @@ const textureQuadPassDescriptor: GPURenderPassDescriptor = {
// view is acquired and set in render loop.
view: undefined,

clearValue: { r: 0.0, g: 0.0, b: 0.0, a: 1.0 },
clearValue: [0, 0, 0, 1],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/fractalCube/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const renderPassDescriptor: GPURenderPassDescriptor = {
{
view: undefined, // Assigned later

clearValue: { r: 0.5, g: 0.5, b: 0.5, a: 1.0 },
clearValue: [0.5, 0.5, 0.5, 1.0],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/helloTriangle/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function frame() {
colorAttachments: [
{
view: textureView,
clearValue: { r: 0.0, g: 0.0, b: 0.0, a: 1.0 },
clearValue: [0, 0, 0, 1],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/helloTriangleMSAA/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function frame() {
{
view,
resolveTarget: context.getCurrentTexture().createView(),
clearValue: { r: 0.0, g: 0.0, b: 0.0, a: 1.0 },
clearValue: [0, 0, 0, 1],
loadOp: 'clear',
storeOp: 'discard',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/imageBlur/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ function frame() {
colorAttachments: [
{
view: context.getCurrentTexture().createView(),
clearValue: { r: 0.0, g: 0.0, b: 0.0, a: 1.0 },
clearValue: [0, 0, 0, 1],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/instancedCube/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const renderPassDescriptor: GPURenderPassDescriptor = {
{
view: undefined, // Assigned later

clearValue: { r: 0.5, g: 0.5, b: 0.5, a: 1.0 },
clearValue: [0.5, 0.5, 0.5, 1.0],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/normalMap/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const renderPassDescriptor: GPURenderPassDescriptor = {
{
view: undefined, // Assigned later

clearValue: { r: 0.0, g: 0.0, b: 0.0, a: 1.0 },
clearValue: [0, 0, 0, 1],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/particles/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const renderPassDescriptor: GPURenderPassDescriptor = {
colorAttachments: [
{
view: undefined, // Assigned later
clearValue: { r: 0.0, g: 0.0, b: 0.0, a: 1.0 },
clearValue: [0, 0, 0, 1],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/renderBundles/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ const renderPassDescriptor: GPURenderPassDescriptor = {
{
view: undefined, // Assigned later

clearValue: { r: 0.0, g: 0.0, b: 0.0, a: 1.0 },
clearValue: [0, 0, 0, 1],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/resizeCanvas/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function frame() {
{
view: renderTargetView,
resolveTarget: context.getCurrentTexture().createView(),
clearValue: { r: 0.2, g: 0.2, b: 0.2, a: 1.0 },
clearValue: [0.2, 0.2, 0.2, 1.0],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/resizeObserverHDDPI/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function frame() {
colorAttachments: [
{
view: context.getCurrentTexture().createView(),
clearValue: { r: 0.2, g: 0.2, b: 0.2, a: 1.0 },
clearValue: [0.2, 0.2, 0.2, 1.0],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
4 changes: 2 additions & 2 deletions sample/reversedZ/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ const drawPassDescriptor: GPURenderPassDescriptor = {
// view is acquired and set in render loop.
view: undefined,

clearValue: { r: 0.0, g: 0.0, b: 0.5, a: 1.0 },
clearValue: [0.0, 0.0, 0.5, 1.0],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down Expand Up @@ -396,7 +396,7 @@ const textureQuadPassDescriptor: GPURenderPassDescriptor = {
// view is acquired and set in render loop.
view: undefined,

clearValue: { r: 0.0, g: 0.0, b: 0.5, a: 1.0 },
clearValue: [0.0, 0.0, 0.5, 1.0],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/rotatingCube/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const renderPassDescriptor: GPURenderPassDescriptor = {
{
view: undefined, // Assigned later

clearValue: { r: 0.5, g: 0.5, b: 0.5, a: 1.0 },
clearValue: [0.5, 0.5, 0.5, 1.0],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/samplerParameters/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ function frame() {
colorAttachments: [
{
view: textureView,
clearValue: { r: 0.2, g: 0.2, b: 0.2, a: 1.0 },
clearValue: [0.2, 0.2, 0.2, 1.0],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/shadowMapping/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const renderPassDescriptor: GPURenderPassDescriptor = {
// view is acquired and set in render loop.
view: undefined,

clearValue: { r: 0.5, g: 0.5, b: 0.5, a: 1.0 },
clearValue: [0.5, 0.5, 0.5, 1.0],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
4 changes: 2 additions & 2 deletions sample/skinnedMesh/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ const gltfRenderPassDescriptor: GPURenderPassDescriptor = {
{
view: undefined, // Assigned later

clearValue: { r: 0.3, g: 0.3, b: 0.3, a: 1.0 },
clearValue: [0.3, 0.3, 0.3, 1.0],
loadOp: 'clear',
storeOp: 'store',
},
Expand All @@ -367,7 +367,7 @@ const skinnedGridRenderPassDescriptor: GPURenderPassDescriptor = {
{
view: undefined, // Assigned later

clearValue: { r: 0.3, g: 0.3, b: 0.3, a: 1.0 },
clearValue: [0.3, 0.3, 0.3, 1.0],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/texturedCube/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const renderPassDescriptor: GPURenderPassDescriptor = {
{
view: undefined, // Assigned later

clearValue: { r: 0.5, g: 0.5, b: 0.5, a: 1.0 },
clearValue: [0.5, 0.5, 0.5, 1.0],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/twoCubes/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const renderPassDescriptor: GPURenderPassDescriptor = {
{
view: undefined, // Assigned later

clearValue: { r: 0.5, g: 0.5, b: 0.5, a: 1.0 },
clearValue: [0.5, 0.5, 0.5, 1.0],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/videoUploading/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function frame() {
colorAttachments: [
{
view: textureView,
clearValue: { r: 0.0, g: 0.0, b: 0.0, a: 1.0 },
clearValue: [0, 0, 0, 1],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/videoUploading/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default async function ({ useVideoFrame }: { useVideoFrame: boolean }) {
colorAttachments: [
{
view: textureView,
clearValue: { r: 0.0, g: 0.0, b: 0.0, a: 1.0 },
clearValue: [0, 0, 0, 1],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/volumeRenderingTexture3D/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const renderPassDescriptor: GPURenderPassDescriptor = {
{
view: undefined, // Assigned later

clearValue: { r: 0.5, g: 0.5, b: 0.5, a: 1.0 },
clearValue: [0.5, 0.5, 0.5, 1.0],
loadOp: 'clear',
storeOp: 'discard',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/worker/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ async function init(canvas) {
{
view: undefined, // Assigned later

clearValue: { r: 0.5, g: 0.5, b: 0.5, a: 1.0 },
clearValue: [0.5, 0.5, 0.5, 1.0],
loadOp: 'clear',
storeOp: 'store',
},
Expand Down
2 changes: 1 addition & 1 deletion sample/workloadSimulator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ <h2><center>Web graphics workload simulator</center></h2>
view: renderAttachment,
resolveTarget: multisampling.checked ? canvasView : undefined,
loadOp: 'clear',
clearValue: { r: 1, g: 1, b: 1, a: 1 },
clearValue: [1, 1, 1, 1],
storeOp: multisampling.checked ? 'discard' : 'store',
}, ],
});
Expand Down

0 comments on commit c653759

Please sign in to comment.