Skip to content

Commit

Permalink
Removing RasterClipper
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Aug 11, 2024
1 parent 058e79f commit f4a795b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1,120 deletions.
26 changes: 8 additions & 18 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,16 @@ <h2 id="overview">Overview</h2>
</p>

<p class="TODO">
Get the scan-based rasterization also working - we are being VERY LIMITED by coarse face limit, since we can't
dispatch 65536 or more workgroups (and we have one workgroup per coarse face).
Phong and radial gradients seem off in WebGPU - rasterTest() reproduces, unit test catches it.
</p>

<p class="TODO">
Get set up with phet-lib npm module and... vite(?) for our index page? Temporary switch to non-phet-lib (e.g. transpiled) for now.
Get the scan-based rasterization also working - we are being VERY LIMITED by coarse face limit, since we can't
dispatch 65536 or more workgroups (and we have one workgroup per coarse face).
</p>

<p class="TODO">
Replace RasterClipper and old code with the new style - do we need phet-lib working first?
Get set up with phet-lib npm module and... vite(?) for our index page? Temporary switch to non-phet-lib (e.g. transpiled) for now.
</p>

<p class="TODO">
Expand Down Expand Up @@ -4207,6 +4207,10 @@ <h3 id="stage-rasterize">Rasterize</h3>
Two-pass bind-group optimizations?
</p>

<p class="TODO">
Two-pass deduplication of repeated RenderPrograms? We have an insane number of instructions as output.
</p>

<p class="TODO">
Is it crazy to do delta-based rendering ever? (i.e. figure out which places changed, and render the before/after pixels as a subtraction)
</p>
Expand Down Expand Up @@ -4297,12 +4301,6 @@ <h3 id="stage-rasterize">Rasterize</h3>
tests.
</p>

<p class="TODO">
THERE IS SOMETHING WRONG with RasterClipper's completed edge output. It's bugging up actual centroid computation.
Create assertions on the "parallel" side for this to track it down.
--- This disappeared?!?
</p>

<p class="TODO">
IMPORTANT! Our resulting edge-clipped counts should be cyclic, right? Only use 2 bits per count!!
They should wrap around or accumulate as long as we do arithmetic mod 4.
Expand Down Expand Up @@ -4352,14 +4350,6 @@ <h3 id="stage-rasterize">Rasterize</h3>
is technically possible.
</p>

<p class="TODO">
For RasterClipper approach, consider pipeline-overridable constants to change the reduce behavior for the last level.
</p>

<p class="TODO">
Measure RasterClipper progression of chunk/edge counts every stage.
</p>

<p class="TODO">
Raking and other better primitives in raster-clip!
</p>
Expand Down
2 changes: 0 additions & 2 deletions js/imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -652,8 +652,6 @@ export type { TiledTwoPassModuleOptions, TiledTwoPassRunSize } from './webgpu/mo
export { default as TestRenderProgram } from './webgpu/TestRenderProgram.js';
export { default as PerformanceTesting } from './webgpu/PerformanceTesting.js';
export { default as GPUProfiling } from './webgpu/GPUProfiling.js';
export { default as RasterClipper } from './webgpu/old/RasterClipper.js';
export type { RasterClipperOptions } from './webgpu/old/RasterClipper.js';
export { default as FaceRasterizer } from './webgpu/FaceRasterizer.js';

// testing
Expand Down
32 changes: 2 additions & 30 deletions js/raster/Rasterize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* @author Jonathan Olson <[email protected]>
*/

import { alpenglow, BoundedSubpath, ClippableFace, ClippableFaceAccumulator, DeviceContext, EdgedClippedFace, EdgedFace, EdgedFaceAccumulator, FaceConversion, getPolygonFilterGridBounds, getPolygonFilterGridOffset, getPolygonFilterWidth, HilbertMapping, IntegerEdge, LineIntersector, LineSplitter, OutputRaster, PolygonalFace, PolygonalFaceAccumulator, PolygonFilterType, PolygonMitchellNetravali, RasterClipper, RasterClipperOptions, RasterLog, RasterTileLog, RationalBoundary, RationalFace, RationalHalfEdge, RenderableFace, RenderColor, RenderEvaluationContext, RenderEvaluator, RenderExecutor, RenderPath, RenderPathBoolean, RenderPathReplacer, RenderProgram, RenderProgramNeeds } from '../imports.js';
import { alpenglow, BoundedSubpath, ClippableFace, ClippableFaceAccumulator, EdgedClippedFace, EdgedFace, EdgedFaceAccumulator, FaceConversion, getPolygonFilterGridBounds, getPolygonFilterGridOffset, getPolygonFilterWidth, HilbertMapping, IntegerEdge, LineIntersector, LineSplitter, OutputRaster, PolygonalFace, PolygonalFaceAccumulator, PolygonFilterType, PolygonMitchellNetravali, RasterLog, RasterTileLog, RationalBoundary, RationalFace, RationalHalfEdge, RenderableFace, RenderColor, RenderEvaluationContext, RenderEvaluator, RenderExecutor, RenderPath, RenderPathBoolean, RenderPathReplacer, RenderProgram, RenderProgramNeeds } from '../imports.js';
import Bounds2 from '../../../dot/js/Bounds2.js';
import Vector2 from '../../../dot/js/Vector2.js';
import Vector4 from '../../../dot/js/Vector4.js';
import { combineOptions, optionize3 } from '../../../phet-core/js/optionize.js';
import { optionize3 } from '../../../phet-core/js/optionize.js';
import Matrix3 from '../../../dot/js/Matrix3.js';
import Utils from '../../../dot/js/Utils.js';

Expand Down Expand Up @@ -52,8 +52,6 @@ export type RasterizationOptions = {

executionMethod?: RenderExecutionMethod;

rasterClipperOptions?: RasterClipperOptions;

log?: RasterLog | null;
};

Expand All @@ -68,9 +66,6 @@ const DEFAULT_OPTIONS = {
renderableFaceMethod: 'traced',
splitPrograms: true,
executionMethod: 'instructions',
rasterClipperOptions: {
numStages: 16
},
log: null
} as const;

Expand Down Expand Up @@ -1214,29 +1209,6 @@ export default class Rasterize {
log && Rasterize.markEnd( 'rasterize-accumulate' );
}

public static async hybridRasterize(
renderProgram: RenderProgram,
deviceContext: DeviceContext,
canvasContext: GPUCanvasContext,
bounds: Bounds2,
// TODO: put colorSpace in options? Figure out how we're doing options
colorSpace: 'srgb' | 'display-p3',
providedOptions?: RasterizationOptions
): Promise<void> {

const options = optionize3<RasterizationOptions>()( {}, DEFAULT_OPTIONS, providedOptions );

const renderableFaces = Rasterize.partitionRenderableFaces( renderProgram, bounds, providedOptions );

const rasterClipper = RasterClipper.get( deviceContext );

const rasterClipperOptions = combineOptions<RasterClipperOptions>( {
colorSpace: colorSpace
}, options.rasterClipperOptions );

await rasterClipper.rasterize( renderableFaces, canvasContext.getCurrentTexture(), rasterClipperOptions );
}

public static imageDataToCanvas( imageData: ImageData ): HTMLCanvasElement {
const canvas = document.createElement( 'canvas' );
canvas.width = imageData.width;
Expand Down
Loading

0 comments on commit f4a795b

Please sign in to comment.