3#ifndef vtkWebGPURenderer_h
4#define vtkWebGPURenderer_h
8#include "vtkRenderingWebGPUModule.h"
15#include <unordered_set>
23VTK_ABI_NAMESPACE_BEGIN
48 vtkGetMacro(LightingComplexity,
int);
104 const std::vector<vtkSmartPointer<vtkWebGPUComputePipeline>>&
120 layouts.emplace_back(this->SceneBindGroupLayout);
163 vtkSetMacro(UseRenderBundles,
bool);
164 vtkBooleanMacro(UseRenderBundles,
bool);
165 vtkGetMacro(UseRenderBundles,
bool);
204 this->RebuildRenderBundle =
true;
205 this->Bundle =
nullptr;
211 vtkGetMacro(RebuildRenderBundle,
bool);
237 void SetupBindGroupLayouts();
239 void CreateBuffers();
241 void SetupSceneBindGroup();
244 void BeginRecording();
247 std::size_t WriteLightsBuffer(std::size_t offset = 0);
248 std::size_t WriteSceneTransformsBuffer(std::size_t offset = 0);
263 void PreRenderComputePipelines();
264 void PostRenderComputePipelines();
277 void PostRasterizationRender();
282 void AddPostRasterizationActor(
vtkActor* actor);
288 std::vector<vtkSmartPointer<vtkWebGPUComputePipeline>> SetupPreRenderComputePipelines;
289 std::vector<vtkSmartPointer<vtkWebGPUComputePipeline>> SetupPostRenderComputePipelines;
294 std::vector<vtkSmartPointer<vtkWebGPUComputePipeline>> NotSetupPreRenderComputePipelines;
295 std::vector<vtkSmartPointer<vtkWebGPUComputePipeline>> NotSetupPostRenderComputePipelines;
304 std::vector<vtkActor*> PostRasterizationActors;
309 wgpu::CommandBuffer EncodePropListRenderCommand(
vtkProp** propList,
int listLength);
316 void RecordRenderCommands();
318 wgpu::RenderPassEncoder WGPURenderEncoder;
319 wgpu::RenderBundleEncoder WGPUBundleEncoder;
320 wgpu::Buffer SceneTransformBuffer;
321 wgpu::Buffer SceneLightsBuffer;
323 wgpu::BindGroup SceneBindGroup;
324 wgpu::BindGroupLayout SceneBindGroupLayout;
327 bool UseRenderBundles =
true;
328 bool RebuildRenderBundle =
false;
330 wgpu::RenderBundle Bundle;
332 int LightingComplexity = 0;
333 std::size_t NumberOfLightsUsed = 0;
334 std::vector<std::size_t> LightIDs;
335 std::size_t AllocatedLightsBufferSize = 0;
336 std::size_t PreviousLightCount = 0;
350 bool ComputeBuffersInitialized =
false;
361 bool DrawBackgroundInClearPass =
true;
369 std::unordered_set<vtkProp*> PropsRendered;
381 std::vector<vtkProp*> LastVisibleProps;
388 std::vector<vtkProp*> VisibleProps;
394 bool VisiblePropSetChanged();
401 bool CanReuseRenderBundle()
const
403 return this->UseRenderBundles && !this->RebuildRenderBundle && this->Bundle !=
nullptr;
411 bool PropSupportsReusingRenderBundle(
vtkProp*)
const;
418 void WarnIfCullingWithRenderBundles();
422 bool WarnedAboutCullingWithRenderBundles =
false;
425#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
a weak reference to a vtkObjectBase.
This culler does both frustum culling and occlusion culling.
void ConfigureComputeRenderBuffers(vtkSmartPointer< vtkWebGPUComputePipeline > computePipeline)
Set up the buffers of a given vtkWebGPUComputePass.
friend class vtkWebGPUComputePointCloudMapper
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...
wgpu::BindGroup GetSceneBindGroup()
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.
friend class vtkWebGPUComputeOcclusionCuller
int UpdateLights() override
Ask all lights to load themselves into rendering pipeline.
void SetUserLightTransform(vtkTransform *transform)
Set the user light transform applied after the camera transform.
void PopulateBindgroupLayouts(std::vector< wgpu::BindGroupLayout > &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.
vtkTransform * GetUserLightTransform()
Set the user light transform applied after the camera transform.
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...
wgpu::RenderBundleEncoder GetRenderBundleEncoder()
~vtkWebGPURenderer() override
wgpu::RenderPassEncoder GetRenderPassEncoder()
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
vtkGetEnumMacro(RenderStage, RenderStageEnum)
Query the stage in the rendering process.
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.
window superclass for vtkRenderWindow
vtkTypeUInt32 vtkMTimeType