-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a6eb7b
commit 957abcd
Showing
7 changed files
with
28 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
/** | ||
* TODO: doc | ||
* | ||
* Should be dispatched with one workgroup PER coarse renderable face (one thread per face-X-bin). | ||
* | ||
* @author Jonathan Olson <[email protected]> | ||
*/ | ||
|
||
|
@@ -51,7 +53,7 @@ const mainTwoPassCoarseWGSL = ( | |
fineEdgesSlot, | ||
addressesSlot | ||
], wgsl` | ||
const low_area_multiplier = 1e-4f; | ||
const low_area_multiplier = 0.002f; | ||
var<workgroup> coarse_face: ${TwoPassCoarseRenderableFaceWGSL}; | ||
var<workgroup> scratch_data: array<vec2u, 256>; | ||
|
@@ -145,7 +147,7 @@ const mainTwoPassCoarseWGSL = ( | |
// TODO: don't use low_area_multiplier with full area! | ||
let is_full_area = is_source_full_area || area + low_area_multiplier >= max_area; | ||
let needs_write_face = area > low_area_multiplier; | ||
let needs_write_face = area > low_area_multiplier && ( num_clipped_edges > 0u || clipped_clip_counts[ 0u ] != 0i || clipped_clip_counts[ 1u ] != 0i || clipped_clip_counts[ 2u ] != 0i || clipped_clip_counts[ 3u ] != 0i ); | ||
let needs_write_edges = needs_write_face && !is_full_area; | ||
let required_edge_count = select( 0u, num_clipped_edges, needs_write_edges ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,12 +16,14 @@ | |
* a full 16x16 grid of integrals (and colors), which will then be combined into the proper (e.g. 15x15) set of pixels. | ||
* Thus the bin size can be 15x15 (if bilinear and filter_scale=1), or 13x13 (if Mitchell-Netravali and filter_scale=1). | ||
* | ||
* Should be dispatched with one workgroup PER bin (one thread per grid "pixel") | ||
* | ||
* TODO: optimize is_constant | ||
* | ||
* @author Jonathan Olson <[email protected]> | ||
*/ | ||
|
||
import { blend_composeWGSL, bounds_clip_edgeWGSL, BufferBindingType, BufferSlot, decimalS, extend_f32WGSL, f32S, F32Type, gamut_map_linear_displayP3WGSL, gamut_map_linear_sRGBWGSL, linear_displayP3_to_linear_sRGBWGSL, linear_sRGB_to_linear_displayP3WGSL, linear_sRGB_to_oklabWGSL, linear_sRGB_to_sRGBWGSL, LinearEdge, LinearEdgeWGSL, logValueWGSL, oklab_to_linear_sRGBWGSL, premultiplyWGSL, RadialGradientType, RenderInstruction, sRGB_to_linear_sRGBWGSL, StorageTextureBindingType, TextureViewSlot, TwoPassConfig, TwoPassFineRenderableFace, TwoPassFineRenderableFaceWGSL, u32S, U32Type, unpremultiplyWGSL, wgsl, wgslBlueprint, WGSLExpressionU32, WGSLMainModule, WGSLSlot } from '../../../imports.js'; | ||
import { blend_composeWGSL, bounds_clip_edgeWGSL, BufferBindingType, BufferSlot, decimalS, extend_f32WGSL, f32S, gamut_map_linear_displayP3WGSL, gamut_map_linear_sRGBWGSL, linear_displayP3_to_linear_sRGBWGSL, linear_sRGB_to_linear_displayP3WGSL, linear_sRGB_to_oklabWGSL, linear_sRGB_to_sRGBWGSL, LinearEdge, LinearEdgeWGSL, oklab_to_linear_sRGBWGSL, premultiplyWGSL, RadialGradientType, RenderInstruction, sRGB_to_linear_sRGBWGSL, StorageTextureBindingType, TextureViewSlot, TwoPassConfig, TwoPassFineRenderableFace, TwoPassFineRenderableFaceWGSL, u32S, unpremultiplyWGSL, wgsl, wgslBlueprint, WGSLExpressionU32, WGSLMainModule, WGSLSlot } from '../../../imports.js'; | ||
import { optionize3 } from '../../../../../phet-core/js/optionize.js'; | ||
|
||
export type mainTwoPassFineWGSLOptions = { | ||
|
@@ -64,10 +66,6 @@ const mainTwoPassFineWGSL = ( | |
const stackSize = 10; | ||
const instructionStackSize = 8; | ||
|
||
// const logIndex = Math.floor( Math.random() * 1000 ); | ||
const logIndex = 4794; | ||
console.log( logIndex ); | ||
|
||
const getInstructionWGSL = ( index: WGSLExpressionU32 ) => wgsl`render_program_instructions[ ${index} ]`; | ||
|
||
// TODO: find a way so that this isn't needed(!) | ||
|
@@ -87,7 +85,7 @@ const mainTwoPassFineWGSL = ( | |
], wgsl` | ||
const oops_inifinite_loop_code = vec4f( 0.5f, 0.5f, 0f, 0.5f ); | ||
const low_area_multiplier = 1e-4f; | ||
const low_area_multiplier = 0.002f; | ||
var<workgroup> bin_xy: vec2<u32>; | ||
var<workgroup> workgroup_exit: bool; | ||
|
@@ -134,30 +132,9 @@ const mainTwoPassFineWGSL = ( | |
let pixel_xy = bin_xy * config.bin_size + vec2( local_id.x % 16u, local_id.x / 16u ); | ||
// 21, 13 ish | ||
${logValueWGSL( { | ||
value: 'pixel_xy.x', | ||
type: U32Type, | ||
lineToLog: line => line.dataArray.flat()[ logIndex ] | ||
} )} | ||
${logValueWGSL( { | ||
value: 'pixel_xy.y', | ||
type: U32Type, | ||
lineToLog: line => line.dataArray.flat()[ logIndex ] | ||
} )} | ||
let skip_pixel = pixel_xy.x >= config.raster_width || pixel_xy.y >= config.raster_height; | ||
var accumulation = vec4f( 0f, 0f, 0f, 0f ); | ||
//accumulation = vec4( f32( bin_xy.x ) / 16f, 0f, f32( bin_xy.y ) / 16f, 1f ); // TODO: remove | ||
${logValueWGSL( { | ||
value: 'next_address', | ||
type: U32Type, | ||
lineToLog: line => line.dataArray.flat()[ logIndex ] | ||
} )} | ||
var oops_count = 0u; | ||
while ( workgroupUniformLoad( &next_address ) != 0xffffffffu ) { | ||
|
@@ -174,12 +151,6 @@ const mainTwoPassFineWGSL = ( | |
workgroupBarrier(); | ||
${logValueWGSL( { | ||
value: 'select( 0u, 1u, skip_pixel )', | ||
type: U32Type, | ||
lineToLog: line => line.dataArray.flat()[ logIndex ] | ||
} )} | ||
let needs_centroid = ( current_face.bits & 0x10000000u ) != 0u; | ||
let needs_face = ( current_face.bits & 0x20000000u ) != 0u; | ||
let is_full_area = ( current_face.bits & 0x80000000u ) != 0u; | ||
|
@@ -236,30 +207,6 @@ const mainTwoPassFineWGSL = ( | |
// TODO: stuff integrals + color in workgroup memory, barrier, then have each pixel (subset of threads) sum up | ||
} | ||
${logValueWGSL( { | ||
value: 'accumulation.r', | ||
type: F32Type, | ||
lineToLog: line => line.dataArray.flat()[ logIndex ] | ||
} )} | ||
${logValueWGSL( { | ||
value: 'accumulation.g', | ||
type: F32Type, | ||
lineToLog: line => line.dataArray.flat()[ logIndex ] | ||
} )} | ||
${logValueWGSL( { | ||
value: 'accumulation.b', | ||
type: F32Type, | ||
lineToLog: line => line.dataArray.flat()[ logIndex ] | ||
} )} | ||
${logValueWGSL( { | ||
value: 'accumulation.a', | ||
type: F32Type, | ||
lineToLog: line => line.dataArray.flat()[ logIndex ] | ||
} )} | ||
var will_store_pixel = !skip_pixel; | ||
${options.supportsGridFiltering ? wgsl` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters