WebGPU Classes
See the WebGPU section for tutorials and usage guides.
WebGPUWidget
Bases: QWidget
An abstract base class for offscreen WebGPU widgets.
The rendered content is presented via QPainter.
The scene is rendered to an offscreen texture, read back to a numpy buffer, and blitted to the widget with QPainter. This keeps the whole data flow visible and allows QPainter text overlays via render_text().
By default the readback is synchronous: the frame is copied into a buffer, that same buffer is mapped, and what you see is what the paint just drew. Mapping a copy that was only submitted a moment ago means waiting for the GPU to drain, which costs on the order of a millisecond at typical window sizes.
Setting pipelined_readback = True trades that latency for throughput. The copy still goes into one buffer of the ring, but the buffer mapped and read is the previous frame's, whose copy the GPU has had a whole frame to finish, so the map returns almost immediately and the CPU never stalls. The catch is that the presented image then lags the simulation by one frame. Under continuous repaints that is imperceptible, which is what it is for; a widget that only repaints in response to events must leave it off, or a one-off change such as a mouse click renders to the texture but is not shown until whatever event happens to trigger the next paint.
Subclasses must implement paintWebGPU() and resizeWebGPU(), and must set self.device to a wgpu device before any rendering can occur. The base class owns the render target textures and the readback machinery; resizeWebGPU() should only update subclass state (projection matrix, per-pipeline sizes etc.) and must NOT recreate render buffers itself.
Source code in ncca/ngl/webgpu/webgpu_widget.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | |
__init__()
Initialize the widget.
Note the wgpu device is not created here; subclasses are responsible for creating it (self.device) before the first paint.
Source code in ncca/ngl/webgpu/webgpu_widget.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
paintEvent(event)
Handle the paint event to render and present the WebGPU content.
Source code in ncca/ngl/webgpu/webgpu_widget.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
paintWebGPU()
abstractmethod
Render the WebGPU content.
Called on every paint event; all the main rendering code goes here. Implementations should end by calling _update_colour_buffer() so the rendered frame is read back for presentation.
Source code in ncca/ngl/webgpu/webgpu_widget.py
127 128 129 130 131 132 133 134 135 136 | |
render_text(x, y, text, size=10, font='Arial', colour=Qt.black)
Queue text to be drawn over the rendered frame.
The text buffer is cleared each frame, so text must be re-added every frame (typically from paintWebGPU or a timer callback). Note that with pipelined_readback on, the rendered image lags the simulation by one frame while the text is drawn from the current one, so text meant to track a moving 3D object's screen position will swim slightly during fast motion; HUD-style labels are unaffected, and neither happens with the default readback.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/webgpu_widget.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
resizeEvent(event)
Handle window resize.
Recreates the render targets and the readback frame buffer at the new size (in device pixels), then notifies the subclass via resizeWebGPU().
Source code in ncca/ngl/webgpu/webgpu_widget.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
resizeWebGPU(width, height)
abstractmethod
Handle a resize, after the buffers are recreated at the new size.
Subclasses should update projection matrices and any per-pipeline sizes here. Width and height are in device pixels.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/webgpu_widget.py
114 115 116 117 118 119 120 121 122 123 124 125 | |
start_update_timer(interval_ms)
Start the update timer with the given interval.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/webgpu_widget.py
99 100 101 102 103 104 105 | |
stop_update_timer()
Stop the update timer.
Source code in ncca/ngl/webgpu/webgpu_widget.py
107 108 109 | |
PipelineType
Bases: Enum
Enumeration of available pipeline types.
Source code in ncca/ngl/webgpu/pipeline_factory.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
PipelineFactory
PipelineFactory is a module-level singleton instance of the factory
class below — use it directly
(PipelineFactory.create_pipeline(device, pipeline_type)) rather than
instantiating your own.
Factory for creating pipeline instances with various configurations.
Source code in ncca/ngl/webgpu/pipeline_factory.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
__init__()
Initialize the pipeline factory with default pipeline types.
Source code in ncca/ngl/webgpu/pipeline_factory.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
create_pipeline(device, pipeline_type, **kwargs)
Create a pipeline instance.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
Source code in ncca/ngl/webgpu/pipeline_factory.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
register_pipeline(pipeline_type, pipeline_factory)
Register a custom pipeline type.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/pipeline_factory.py
124 125 126 127 128 129 130 131 132 133 134 135 | |
NGLToWebGPU
Maps NGL type names to WebGPU strides and vertex formats.
Source code in ncca/ngl/webgpu/webgpu_constants.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
stride_from_type(type)
staticmethod
Return the byte stride for the given NGL type name.
Source code in ncca/ngl/webgpu/webgpu_constants.py
26 27 28 29 | |
vertex_format(type)
staticmethod
Return the WebGPU vertex format for the given NGL type name.
Source code in ncca/ngl/webgpu/webgpu_constants.py
31 32 33 34 | |
BaseWebGPUPipeline
Bases: ABC
Abstract base class for all WebGPU rendering pipelines.
Provides common functionality for: - Buffer management and creation - Pipeline configuration - Uniform buffer handling - Resource cleanup
Source code in ncca/ngl/webgpu/base_webgpu_pipeline.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
__init__(device, texture_format=wgpu.TextureFormat.rgba8unorm, depth_format=wgpu.TextureFormat.depth24plus, msaa_sample_count=4, data_type='Vec3', stride=0)
Initialize base pipeline.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/base_webgpu_pipeline.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
cleanup()
Release pipeline resources. Can be overridden for additional cleanup.
Source code in ncca/ngl/webgpu/base_webgpu_pipeline.py
259 260 261 262 | |
get_dtype()
abstractmethod
Get the numpy dtype for the uniform buffer structure.
Source code in ncca/ngl/webgpu/base_webgpu_pipeline.py
67 68 69 70 | |
render(render_pass, **kwargs)
abstractmethod
Render using this pipeline.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/base_webgpu_pipeline.py
249 250 251 252 253 254 255 256 257 | |
set_data(**kwargs)
abstractmethod
Set rendering data (vertices, colours, etc.).
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/base_webgpu_pipeline.py
231 232 233 234 235 236 237 238 | |
update_uniforms(**kwargs)
abstractmethod
Update uniform buffer values.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/base_webgpu_pipeline.py
240 241 242 243 244 245 246 247 | |
BasePointPipeline
Bases: BaseWebGPUPipeline
Base class for point rendering pipelines.
Provides common functionality for: - Point billboarding - Quad generation - Circle clipping in fragment shader
Source code in ncca/ngl/webgpu/base_webgpu_pipeline.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
CustomShaderPipeline
Bases: BaseWebGPUPipeline
A WebGPU pipeline that uses custom shader source provided by the user.
This pipeline allows users to provide their own WGSL shader source code while handling the boilerplate for buffer management, uniform updates, and rendering setup.
Source code in ncca/ngl/webgpu/custom_shader_pipeline.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init__(device, shader_source, vertex_formats=None, primitive_topology=wgpu.PrimitiveTopology.triangle_list, texture_format=wgpu.TextureFormat.rgba8unorm, depth_format=wgpu.TextureFormat.depth24plus, msaa_sample_count=4, uniform_struct_definition=None, pipeline_label='CustomShaderPipeline')
Initialize custom shader pipeline.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/custom_shader_pipeline.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
from_file(device, shader_file, **kwargs)
classmethod
Create a CustomShaderPipeline from a WGSL file.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in ncca/ngl/webgpu/custom_shader_pipeline.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
get_dtype()
Get the numpy dtype for the uniform buffer structure.
Source code in ncca/ngl/webgpu/custom_shader_pipeline.py
72 73 74 75 76 77 | |
render(render_pass, **kwargs)
Render using this pipeline.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/custom_shader_pipeline.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
set_data(positions=None, colours=None, interleaved_data=None, **kwargs)
Set vertex data for rendering.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/custom_shader_pipeline.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
update_uniforms(**kwargs)
Update uniform buffer values.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/custom_shader_pipeline.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |
Built-in pipeline classes
These are the concrete classes behind each
PipelineType; you normally create them through
PipelineFactory rather than directly.
PointPipelineMultiColour
Bases: BasePointPipeline
A reusable pipeline for rendering points in WebGPU.
Features: - Instanced rendering of points as quads - Per-point colours - Configurable point size - Model, View Projection matrix support pass a projection only for 2D - MSAA support
Source code in ncca/ngl/webgpu/point_pipeline.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
__init__(device, data_type='Vec3', texture_format=wgpu.TextureFormat.rgba8unorm, depth_format=wgpu.TextureFormat.depth24plus, msaa_sample_count=4, stride=0)
Initialize the point rendering pipeline.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/point_pipeline.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
cleanup()
Release resources.
Source code in ncca/ngl/webgpu/point_pipeline.py
186 187 188 189 190 191 192 | |
get_dtype()
Get the data type of the pipeline.
Source code in ncca/ngl/webgpu/point_pipeline.py
59 60 61 62 63 64 65 66 67 68 | |
render(render_pass, **kwargs)
Render the points.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/point_pipeline.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
set_data(positions, colours=None)
Set the point data for rendering.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/point_pipeline.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
update_uniforms(**kwargs)
Update uniform buffer values.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/point_pipeline.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
PointPipelineSingleColour
Bases: BasePointPipeline
A reusable pipeline for rendering points in WebGPU.
Features: - Instanced rendering of points as quads - Single colour for all points - Configurable point size - Model, View Projection matrix support pass a projection only for 2D - MSAA support
Source code in ncca/ngl/webgpu/point_pipeline.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | |
__init__(device, data_type='Vec3', texture_format=wgpu.TextureFormat.rgba8unorm, depth_format=wgpu.TextureFormat.depth24plus, msaa_sample_count=4, stride=0)
Initialize the point rendering pipeline.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/point_pipeline.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
cleanup()
Release resources.
Source code in ncca/ngl/webgpu/point_pipeline.py
338 339 340 341 342 | |
get_dtype()
Get the data type of the pipeline.
Source code in ncca/ngl/webgpu/point_pipeline.py
238 239 240 241 242 243 244 245 246 | |
render(render_pass, **kwargs)
Render the points.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/point_pipeline.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | |
set_data(positions, colours=None)
Set the point data for rendering.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/point_pipeline.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
update_uniforms(**kwargs)
Update uniform buffer values.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/point_pipeline.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |
PointListPipelineMultiColour
Bases: BaseWebGPUPipeline
A pipeline for rendering points using WebGPU's native point-list topology.
Features: - Native WebGPU point-list rendering (no billboarding) - Model, View Projection matrix support - MSAA support
Source code in ncca/ngl/webgpu/point_list_pipeline.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
__init__(device, data_type='Vec3', texture_format=wgpu.TextureFormat.rgba8unorm, depth_format=wgpu.TextureFormat.depth24plus, msaa_sample_count=4, stride=0)
Initialize the point list rendering pipeline.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/point_list_pipeline.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
cleanup()
Release resources.
Source code in ncca/ngl/webgpu/point_list_pipeline.py
192 193 194 195 196 197 198 | |
get_dtype()
Get the data type of the pipeline.
Source code in ncca/ngl/webgpu/point_list_pipeline.py
61 62 63 64 65 66 67 | |
render(render_pass, **kwargs)
Render the points.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/point_list_pipeline.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
set_data(positions, colours=None)
Set the point data for rendering.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/point_list_pipeline.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
update_uniforms(**kwargs)
Update uniform buffer values.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/point_list_pipeline.py
156 157 158 159 160 161 162 163 164 165 166 167 168 | |
PointListPipelineSingleColour
Bases: BaseWebGPUPipeline
A pipeline for rendering points using WebGPU's native point-list topology.
Features: - Native WebGPU point-list rendering (no billboarding) - Single colour for all points - Model, View Projection matrix support - MSAA support
Source code in ncca/ngl/webgpu/point_list_pipeline.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | |
__init__(device, data_type='Vec3', texture_format=wgpu.TextureFormat.rgba8unorm, depth_format=wgpu.TextureFormat.depth24plus, msaa_sample_count=4, stride=0)
Initialize the point list rendering pipeline.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/point_list_pipeline.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
cleanup()
Release resources.
Source code in ncca/ngl/webgpu/point_list_pipeline.py
352 353 354 355 356 | |
get_dtype()
Get the data type of the pipeline.
Source code in ncca/ngl/webgpu/point_list_pipeline.py
243 244 245 246 247 248 249 250 251 | |
render(render_pass, **kwargs)
Render the points.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/point_list_pipeline.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | |
set_data(positions, colours=None)
Set the point data for rendering.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/point_list_pipeline.py
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
update_uniforms(**kwargs)
Update uniform buffer values.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/point_list_pipeline.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
LinePipelineMultiColour
Bases: BaseLinePipeline
A reusable pipeline for rendering lines in WebGPU with per-vertex colors.
Features: - Line strips or line segments - Per-vertex colors - MVP matrix support - MSAA support
Source code in ncca/ngl/webgpu/line_pipeline.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
__init__(device, data_type='Vec3', texture_format=wgpu.TextureFormat.rgba8unorm, depth_format=wgpu.TextureFormat.depth24plus, msaa_sample_count=4, stride=0, topology=wgpu.PrimitiveTopology.line_list)
Initialize the line rendering pipeline.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/line_pipeline.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
cleanup()
Release resources.
Source code in ncca/ngl/webgpu/line_pipeline.py
227 228 229 230 231 232 233 | |
get_dtype()
Get the data type of the pipeline.
Source code in ncca/ngl/webgpu/line_pipeline.py
101 102 103 104 105 106 107 | |
render(render_pass, **kwargs)
Render the lines.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/line_pipeline.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
set_data(positions=None, colors=None, **kwargs)
Set the line data for rendering.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/line_pipeline.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
update_uniforms(**kwargs)
Update uniform buffer values.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/line_pipeline.py
191 192 193 194 195 196 197 198 199 200 201 202 203 | |
LinePipelineSingleColour
Bases: BaseLinePipeline
A reusable pipeline for rendering lines in WebGPU with single color.
Features: - Line strips or line segments - Single color for all lines - MVP matrix support - MSAA support
Source code in ncca/ngl/webgpu/line_pipeline.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | |
__init__(device, data_type='Vec3', texture_format=wgpu.TextureFormat.rgba8unorm, depth_format=wgpu.TextureFormat.depth24plus, msaa_sample_count=4, stride=0, topology=wgpu.PrimitiveTopology.line_list, colour=(1.0, 1.0, 1.0))
Initialize line rendering pipeline.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/line_pipeline.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | |
cleanup()
Release resources.
Source code in ncca/ngl/webgpu/line_pipeline.py
404 405 406 407 408 | |
get_dtype()
Get the data type of the pipeline.
Source code in ncca/ngl/webgpu/line_pipeline.py
284 285 286 287 288 289 290 291 292 | |
render(render_pass, **kwargs)
Render the lines.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/line_pipeline.py
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | |
set_color(colour)
Set the color for the lines.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/line_pipeline.py
369 370 371 372 373 374 375 376 377 378 379 380 381 | |
set_data(positions=None, colors=None, **kwargs)
Set the line data for rendering.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/line_pipeline.py
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | |
update_uniforms(**kwargs)
Update uniform buffer values.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/line_pipeline.py
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | |
TrianglePipelineMultiColour
Bases: BaseTrianglePipeline
A reusable pipeline for rendering triangles in WebGPU with per-vertex colors.
Features: - Triangle lists or triangle strips - Per-vertex colors - MVP matrix support - MSAA support
Source code in ncca/ngl/webgpu/triangle_pipeline.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | |
__init__(device, data_type='Vec3', texture_format=wgpu.TextureFormat.rgba8unorm, depth_format=wgpu.TextureFormat.depth24plus, msaa_sample_count=4, stride=0, topology=wgpu.PrimitiveTopology.triangle_list)
Initialize the triangle rendering pipeline.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/triangle_pipeline.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
cleanup()
Release resources.
Source code in ncca/ngl/webgpu/triangle_pipeline.py
236 237 238 239 240 241 242 | |
get_dtype()
Get the data type of the pipeline.
Source code in ncca/ngl/webgpu/triangle_pipeline.py
104 105 106 107 108 109 110 111 | |
render(render_pass, **kwargs)
Render the triangles.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/triangle_pipeline.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
set_data(positions=None, colors=None, **kwargs)
Set the triangle data for rendering.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/triangle_pipeline.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
update_uniforms(**kwargs)
Update uniform buffer values.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/triangle_pipeline.py
200 201 202 203 204 205 206 207 208 209 210 211 212 | |
TrianglePipelineSingleColour
Bases: BaseTrianglePipeline
A reusable pipeline for rendering triangles in WebGPU with single color.
Features: - Triangle lists or triangle strips - Single color for all triangles - MVP matrix support - MSAA support
Source code in ncca/ngl/webgpu/triangle_pipeline.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | |
__init__(device, data_type='Vec3', texture_format=wgpu.TextureFormat.rgba8unorm, depth_format=wgpu.TextureFormat.depth24plus, msaa_sample_count=4, stride=0, topology=wgpu.PrimitiveTopology.triangle_list, colour=(1.0, 1.0, 1.0))
Initialize the triangle rendering pipeline.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/triangle_pipeline.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
cleanup()
Release resources.
Source code in ncca/ngl/webgpu/triangle_pipeline.py
418 419 420 421 422 | |
get_dtype()
Get the data type of the pipeline.
Source code in ncca/ngl/webgpu/triangle_pipeline.py
293 294 295 296 297 298 299 300 301 | |
render(render_pass, **kwargs)
Render the triangles.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/triangle_pipeline.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
set_color(colour)
Set the color for the triangles.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/triangle_pipeline.py
383 384 385 386 387 388 389 390 391 392 393 394 395 | |
set_data(positions=None, colors=None, **kwargs)
Set the triangle data for rendering.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/triangle_pipeline.py
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | |
update_uniforms(**kwargs)
Update uniform buffer values.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/triangle_pipeline.py
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | |
InstancedGeometryPipelineMultiColour
Bases: BaseInstancedGeometryPipeline
A reusable pipeline for rendering instanced geometry in WebGPU with per-instance colors.
Features: - Instanced rendering of arbitrary geometry using interleaved x,y,z,nx,ny,nz,u,v format - Per-instance colors - Per-instance positioning - Configurable instance transformation matrix - Model, View Projection matrix support - MSAA support
Source code in ncca/ngl/webgpu/instanced_geometry_pipeline.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | |
cleanup()
Release resources.
Source code in ncca/ngl/webgpu/instanced_geometry_pipeline.py
375 376 377 378 379 380 381 382 383 384 385 386 | |
get_dtype()
Get the data type of the pipeline.
Source code in ncca/ngl/webgpu/instanced_geometry_pipeline.py
288 289 290 291 292 293 294 295 296 | |
render(render_pass, **kwargs)
Render the instanced geometry.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/instanced_geometry_pipeline.py
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | |
update_uniforms(**kwargs)
Update uniform buffer values.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/instanced_geometry_pipeline.py
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | |
InstancedGeometryPipelineSingleColour
Bases: BaseInstancedGeometryPipeline
A reusable pipeline for rendering instanced geometry in WebGPU with single color.
Features: - Instanced rendering of arbitrary geometry using interleaved x,y,z,nx,ny,nz,u,v format - Single color for all instances - Per-instance positioning - Configurable instance transformation matrix - Model, View Projection matrix support - MSAA support
Source code in ncca/ngl/webgpu/instanced_geometry_pipeline.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 | |
cleanup()
Release resources.
Source code in ncca/ngl/webgpu/instanced_geometry_pipeline.py
494 495 496 497 498 499 500 501 502 503 504 505 | |
get_dtype()
Get the data type of the pipeline.
Source code in ncca/ngl/webgpu/instanced_geometry_pipeline.py
401 402 403 404 405 406 407 408 409 410 | |
render(render_pass, **kwargs)
Render the instanced geometry.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/instanced_geometry_pipeline.py
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | |
update_uniforms(**kwargs)
Update uniform buffer values.
| Parameters: |
|
|---|
Source code in ncca/ngl/webgpu/instanced_geometry_pipeline.py
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | |