3#ifndef vtkWebGPURenderer_h
4#define vtkWebGPURenderer_h
8#include "vtkRenderingWebGPUModule.h"
15#include <unordered_set>
23VTK_ABI_NAMESPACE_BEGIN
49 vtkGetMacro(LightingComplexity,
int);
105 const std::vector<vtkSmartPointer<vtkWebGPUComputePipeline>>&
121 layouts.emplace_back(this->SceneBindGroupLayout);
155 vtkSetMacro(UseRenderBundles,
bool);
156 vtkBooleanMacro(UseRenderBundles,
bool);
157 vtkGetMacro(UseRenderBundles,
bool);
169 vtkSetMacro(UseDeepFramebufferTransparency,
bool);
170 vtkBooleanMacro(UseDeepFramebufferTransparency,
bool);
171 vtkGetMacro(UseDeepFramebufferTransparency,
bool);
222 vtkGetMacro(RecordingTranslucentPass,
bool);
249 this->RebuildRenderBundle =
true;
250 this->Bundle =
nullptr;
256 vtkGetMacro(RebuildRenderBundle,
bool);
284 void SetupBindGroupLayouts();
285 void CreateBuffers();
286 void SetupSceneBindGroup();
288 void BeginRecording();
291 std::size_t WriteLightsBuffer(std::size_t offset = 0);
292 std::size_t WriteSceneTransformsBuffer(std::size_t offset = 0);
307 void PreRenderComputePipelines();
308 void PostRenderComputePipelines();
321 void PostRasterizationRender();
326 void AddPostRasterizationActor(
vtkActor* actor);
332 std::vector<vtkSmartPointer<vtkWebGPUComputePipeline>> SetupPreRenderComputePipelines;
333 std::vector<vtkSmartPointer<vtkWebGPUComputePipeline>> SetupPostRenderComputePipelines;
338 std::vector<vtkSmartPointer<vtkWebGPUComputePipeline>> NotSetupPreRenderComputePipelines;
339 std::vector<vtkSmartPointer<vtkWebGPUComputePipeline>> NotSetupPostRenderComputePipelines;
348 std::vector<vtkActor*> PostRasterizationActors;
353 WGPUCommandBuffer EncodePropListRenderCommand(
vtkProp** propList,
int listLength);
360 void RecordRenderCommands();
366 void ClearGradientBackground();
368 WGPURenderPassEncoder WGPURenderEncoder =
nullptr;
369 WGPURenderBundleEncoder WGPUBundleEncoder =
nullptr;
370 WGPUBuffer SceneTransformBuffer =
nullptr;
371 WGPUBuffer SceneLightsBuffer =
nullptr;
375 WGPUBuffer BackgroundGradientBuffer =
nullptr;
377 WGPUBindGroup SceneBindGroup =
nullptr;
378 WGPUBindGroupLayout SceneBindGroupLayout =
nullptr;
380 bool UseDeepFramebufferTransparency =
true;
381 bool DeepFramebufferPopulated =
false;
383 WGPUBuffer DeepFramebufferPlaceholders[3] = {
nullptr,
nullptr,
nullptr };
389 void ResolveDeepFramebuffer(WGPURenderPassEncoder encoder);
391 std::string DeepFramebufferResolveKey;
394 bool UseRenderBundles =
true;
395 bool RebuildRenderBundle =
false;
397 WGPURenderBundle Bundle =
nullptr;
399 int LightingComplexity = 0;
400 std::size_t NumberOfLightsUsed = 0;
401 std::vector<std::size_t> LightIDs;
402 std::size_t AllocatedLightsBufferSize = 0;
403 std::size_t PreviousLightCount = 0;
412 bool ComputeBuffersInitialized =
false;
418 RenderStageEnum RenderStage = RenderStageEnum::AwaitingPreparation;
419 bool RecordingTranslucentPass =
false;
424 bool DrawBackgroundInClearPass =
true;
432 std::unordered_set<vtkProp*> PropsRendered;
444 std::vector<vtkProp*> LastVisibleProps;
451 std::vector<vtkProp*> VisibleProps;
457 bool VisiblePropSetChanged();
464 bool CanReuseRenderBundle()
const
466 return this->UseRenderBundles && !this->RebuildRenderBundle && this->Bundle !=
nullptr;
474 bool PropSupportsReusingRenderBundle(vtkProp*)
const;
481 void WarnIfCullingWithRenderBundles();
484 vtkTimeStamp RenderBundleBuildTime;
487 vtkWeakPtr<vtkCuller> DefaultCuller;
488 bool WarnedAboutCullingWithRenderBundles =
false;
491#define vtkWebGPURenderer_OVERRIDE_ATTRIBUTES vtkWebGPURenderer::CreateOverrideAttributes()
abstract class specifies interface to map data
represents an object (geometry & properties) in a rendered scene
a superclass for prop cullers
abstract interface to OpenGL FBOs
a simple class to control print indentation
Attribute for vtkObjectFactory overrides.
abstract superclass for all actors, volumes and annotations
Context in which a vtkRenderPass will render.
Hold a reference to a vtkObjectBase instance.
handles properties associated with a texture map
record modification and/or execution time
This culler does both frustum culling and occlusion culling.
Per-pixel fragment lists for order independent transparency.
void ConfigureComputeRenderBuffers(vtkSmartPointer< vtkWebGPUComputePipeline > computePipeline)
Set up the buffers of a given vtkWebGPUComputePass.
friend class vtkWebGPUComputePointCloudMapper
WGPURenderBundleEncoder GetRenderBundleEncoder()
void ReleaseGraphicsResources(vtkWindow *w) override
static vtkWebGPURenderer * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void ConfigureComputePipelines()
Sets the adapter and the device of the render window of this renderer to the compute pipelines of thi...
void AddPostRenderComputePipeline(vtkSmartPointer< vtkWebGPUComputePipeline > pipeline)
Adds a compute pipeline to the renderer that will be executed each frame before/after the rendering p...
friend class vtkWebGPUActor
int UpdateOpaquePolygonalGeometry() override
Request mappers to run the vtkAlgorithm pipeline (if needed) and consequently update device buffers c...
int UpdateTranslucentPolygonalGeometry() override
Ask all props to update and draw any translucent polygonal geometry.
int UpdateGeometry(vtkFrameBufferObjectBase *fbo=nullptr) override
Ask all props to update and draw any opaque and translucent geometry.
vtkProp * GetPropWithId(vtkTypeUInt32 id)
The prop that was drawn with id in the ids attachment, or nullptr when the id names no prop.
friend class vtkWebGPUComputeOcclusionCuller
int UpdateLights() override
Ask all lights to load themselves into rendering pipeline.
void PopulateBindgroupLayouts(std::vector< WGPUBindGroupLayout > &layouts)
std::unordered_set< vtkProp * > GetPropsRendered()
Returns the list of the actors that were rendered last frame.
void Clear() override
Clear the image to the background color.
vtkWebGPUDeepFramebuffer * GetDeepFramebuffer()
The per-pixel fragment lists used when UseDeepFramebufferTransparency is on.
static vtkOverrideAttribute * CreateOverrideAttributes()
void DeviceRender() override
Create an image.
void InvalidateBundle()
Forces the renderer to re-record draw commands into a render bundle.
void AddPreRenderComputePipeline(vtkSmartPointer< vtkWebGPUComputePipeline > pipeline)
Adds a compute pipeline to the renderer that will be executed each frame before/after the rendering p...
~vtkWebGPURenderer() override
bool PrepareDeepFramebuffer()
Ensure the deep framebuffer and its bind group exist and match the current viewport.
void UpdateBuffers()
Updates / creates the various buffer necessary for the rendering of the props.
@ RenderPostRasterization
const std::vector< vtkSmartPointer< vtkWebGPUComputePipeline > > & GetSetupPostRenderComputePipelines()
Returns the list of compute pipelines of this renderer that have been setup for execution before/afte...
friend class vtkWebGPURenderWindow
WGPUBindGroup GetSceneBindGroup()
vtkGetEnumMacro(RenderStage, RenderStageEnum)
Layout and bind group holding the deep framebuffer's storage buffers.
const std::vector< vtkSmartPointer< vtkWebGPUComputePipeline > > & GetSetupPreRenderComputePipelines()
Returns the list of compute pipelines of this renderer that have been setup for execution before/afte...
void SetEnvironmentTexture(vtkTexture *texture, bool isSRGB=false) override
Set/Get the environment texture used for image based lighting.
WGPURenderPassEncoder GetRenderPassEncoder()
window superclass for vtkRenderWindow
vtkTypeUInt32 vtkMTimeType