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);
154 vtkSetMacro(UseRenderBundles,
bool);
155 vtkBooleanMacro(UseRenderBundles,
bool);
156 vtkGetMacro(UseRenderBundles,
bool);
208 this->RebuildRenderBundle =
true;
209 this->Bundle =
nullptr;
215 vtkGetMacro(RebuildRenderBundle,
bool);
241 void SetupBindGroupLayouts();
243 void CreateBuffers();
245 void SetupSceneBindGroup();
248 void BeginRecording();
251 std::size_t WriteLightsBuffer(std::size_t offset = 0);
252 std::size_t WriteSceneTransformsBuffer(std::size_t offset = 0);
267 void PreRenderComputePipelines();
268 void PostRenderComputePipelines();
281 void PostRasterizationRender();
286 void AddPostRasterizationActor(
vtkActor* actor);
292 std::vector<vtkSmartPointer<vtkWebGPUComputePipeline>> SetupPreRenderComputePipelines;
293 std::vector<vtkSmartPointer<vtkWebGPUComputePipeline>> SetupPostRenderComputePipelines;
298 std::vector<vtkSmartPointer<vtkWebGPUComputePipeline>> NotSetupPreRenderComputePipelines;
299 std::vector<vtkSmartPointer<vtkWebGPUComputePipeline>> NotSetupPostRenderComputePipelines;
308 std::vector<vtkActor*> PostRasterizationActors;
313 WGPUCommandBuffer EncodePropListRenderCommand(
vtkProp** propList,
int listLength);
320 void RecordRenderCommands();
326 void ClearGradientBackground();
328 WGPURenderPassEncoder WGPURenderEncoder =
nullptr;
329 WGPURenderBundleEncoder WGPUBundleEncoder =
nullptr;
330 WGPUBuffer SceneTransformBuffer =
nullptr;
331 WGPUBuffer SceneLightsBuffer =
nullptr;
335 WGPUBuffer BackgroundGradientBuffer =
nullptr;
337 WGPUBindGroup SceneBindGroup =
nullptr;
338 WGPUBindGroupLayout SceneBindGroupLayout =
nullptr;
341 bool UseRenderBundles =
true;
342 bool RebuildRenderBundle =
false;
344 WGPURenderBundle Bundle =
nullptr;
346 int LightingComplexity = 0;
347 std::size_t NumberOfLightsUsed = 0;
348 std::vector<std::size_t> LightIDs;
349 std::size_t AllocatedLightsBufferSize = 0;
350 std::size_t PreviousLightCount = 0;
359 bool ComputeBuffersInitialized =
false;
370 bool DrawBackgroundInClearPass =
true;
378 std::unordered_set<vtkProp*> PropsRendered;
390 std::vector<vtkProp*> LastVisibleProps;
397 std::vector<vtkProp*> VisibleProps;
403 bool VisiblePropSetChanged();
410 bool CanReuseRenderBundle()
const
412 return this->UseRenderBundles && !this->RebuildRenderBundle && this->Bundle !=
nullptr;
420 bool PropSupportsReusingRenderBundle(
vtkProp*)
const;
427 void WarnIfCullingWithRenderBundles();
431 bool WarnedAboutCullingWithRenderBundles =
false;
434#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
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...
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.
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
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)
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.
WGPURenderPassEncoder GetRenderPassEncoder()
window superclass for vtkRenderWindow
vtkTypeUInt32 vtkMTimeType