-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove withParametersWebGL method in Pass classes #8636
Conversation
modules/core/src/lib/layer.ts
Outdated
extension.draw.call(this, opts, extension); | ||
} | ||
// Call subclass lifecycle method | ||
const opts: DrawOptions = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try calling model.setParameters
here for all this.getModels()
? I think the exception is rare (ScenegraphLayer comes to mind).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. It works, however I cannot get picking to work if I remove the withParametersWebGL
call below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
model.setParameters
takes RenderPipelineParameters (v9 string format) and device.withParametersWebGL
takes GLParameters (v8 WebGL constant format). Picking pass used the later (blend
and blendColor
).
@@ -182,10 +182,11 @@ export default class LineLayer<DataT = any, ExtraProps extends {} = {}> extends | |||
} | |||
} | |||
|
|||
draw({uniforms}): void { | |||
draw({parameters, uniforms}): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the current caching mechanism, changing parameters will cause a pipeline to rebuild. Because each layer has a unique polygonOffset
to battle z-fighting, calling model.setParameters
will practically disable all program reuse. @ibgreen @donmccurdy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... @ibgreen I assume this is the purpose of the new factory destroy policy 'never' setting? Let's test that and consider a future 'lazy' destroy policy (or similar) if the performance benefits are worthwhile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No the problem is not cache getting removed, it's that the hash is overly aggressive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the hash even need to include the parameters? Could we have a whitelist or exclude list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussing with @ibgreen in a separate channel - basically WebGPU render pipeline does not allow dynamically setting parameters so the unified API does not accept it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on ...
... it might be optional for WebGL, but will require a new pipeline for WebGPU. My hope with the suggestion of a 'lazy' destroy policy would be that if we have N layers and 1 pipeline, we can at least keep N pipelines in the cache rather than creating and destroying pipelines N times per frame.
WebGPU's equivalent of polygonOffset
is depth stencil state bias, and is configured on the render pipeline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would be possible to combat the z-fighting in the vertex shader via a uniform, something like gl_Position.z += 0.0001 * layerIndex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes... we also have instance ID now with WebGL2.
The z fighting work around has long been due for an update. We definitely need to make some changes while working on WebGPU support.
modules/core/src/lib/layer.ts
Outdated
@@ -184,6 +184,14 @@ export type UpdateParameters<LayerT extends Layer> = { | |||
changeFlags: ChangeFlags; | |||
}; | |||
|
|||
export type DrawOptions = { | |||
context: LayerContext; | |||
moduleParameters: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not new in this PR, but the name can be really confusing. I think it's better called moduleSettings or shaderInputProps?
c24ab11
to
11dcd54
Compare
@Pessimistress I've moved the merge to |
PR for the |
@donmccurdy @Pessimistress I've updated |
Co-authored-by: Don McCurdy <donmccurdy@cartodb.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following passes also have withParametersWebGL
and need to be merged in the proper order:
- ShadowPass
- CollisionFilterPass
- MaskPass
- TerrainPass
- TerrainPickingPass
const pickParameters = { | ||
...layer.props.parameters, | ||
scissorTest: true, | ||
scissor: [x, y, width, height], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For both perf and WebGPU readiness it's probably appropriate to align LayersPassRenderOptions
with luma's RenderPassProps
/RenderPassParameters
and set scissor/depth parameters per-pass instead of per-layer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved the scissor test to be performed on the pass, but I'm not sure about depth. It is common for layers to override the depth handling via parameters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The picking pass only resets depth to avoid dirty context state handover (in v8 deck.props.parameters is not set before picking buffer redraw). They can be overwritten by per-layer settings. In this case we should reset the depth parameters in render pass creation. In the other cases depth parameters should override user props.
…k.gl into felix/deck-layer-parameters-v9
const pickParameters = { | ||
...layer.props.parameters, | ||
scissorTest: true, | ||
scissor: [x, y, width, height], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The picking pass only resets depth to avoid dirty context state handover (in v8 deck.props.parameters is not set before picking buffer redraw). They can be overwritten by per-layer settings. In this case we should reset the depth parameters in render pass creation. In the other cases depth parameters should override user props.
This reverts commit 90683b0.
For #8582 requires visgl/luma.gl#2046
Blending via layer
parameters
and Deckparameters
is not working. Comparison before/after fix:Screen.Recording.2024-03-12.at.12.19.42.mov
In general we want to remove
withParametersWebGL
/setParametersWebGL
from the codebaseChange List
setParametersWebGL
&withParametersWebGL
methods for setting GL parameterscolorMask
&scissorRect
inLayerPass.render()