VTK  9.7.20261112
vtkWebGPURenderPipelineCache.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
34
35#ifndef vtkWebGPURenderPipelineCache_h
36#define vtkWebGPURenderPipelineCache_h
37
38#include "vtkObject.h"
39
40#include "vtkRenderingWebGPUModule.h" // for export macro
41#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
42#include "vtk_wgpu.h" // for webgpu C API
43
44VTK_ABI_NAMESPACE_BEGIN
45
49class vtkWindow;
50
51class VTKRENDERINGWEBGPU_EXPORT VTK_MARSHALAUTO vtkWebGPURenderPipelineCache : public vtkObject
52{
53public:
56 void PrintSelf(ostream& os, vtkIndent indent) override;
57
63
68 WGPURenderPipeline GetRenderPipeline(const std::string& key);
69
75 std::string GetPipelineKey(WGPURenderPipelineDescriptor* descriptor, const char* shaderSource);
76
83 std::string GetPipelineKey(WGPURenderPipelineDescriptor* descriptor,
84 const char* vertexShaderSource, const char* fragmentShaderSource);
85
93 void CreateRenderPipeline(WGPURenderPipelineDescriptor* descriptor,
94 vtkWebGPURenderWindow* wgpuRenderWindow, const char* shaderSource);
95
104 void CreateRenderPipeline(WGPURenderPipelineDescriptor* descriptor,
105 vtkWebGPURenderWindow* wgpuRenderWindow, const char* vertexShaderSource,
106 const char* fragmentShaderSource);
107
121 void CreateRenderPipelineAsync(WGPURenderPipelineDescriptor* descriptor,
122 vtkWebGPURenderWindow* wgpuRenderWindow, const char* vertexShaderSource,
123 const char* fragmentShaderSource);
124
130
138 static bool Substitute(
139 std::string& source, const std::string& search, const std::string& replace, bool all);
140
145 void DestroyRenderPipeline(const std::string& key);
146
147protected:
150
151private:
153 void operator=(const vtkWebGPURenderPipelineCache&) = delete;
154
159 bool PrepareShaderModules(WGPURenderPipelineDescriptor* descriptor,
160 vtkWebGPURenderWindow* wgpuRenderWindow, const char* vertexShaderSource,
161 const char* fragmentShaderSource);
162
163 class vtkInternals;
164 std::unique_ptr<vtkInternals> Internals;
165 // Only needed to drive the event loop while pipelines are being compiled.
166 vtkWebGPUConfiguration* Configuration = nullptr;
167};
168
169VTK_ABI_NAMESPACE_END
170#endif
a simple class to control print indentation
Definition vtkIndent.h:108
Create a webgpu device for use in rendering and compute pipelines.
WGPURenderPipeline GetRenderPipeline(const std::string &key)
Get a render pipeline associated with the given hash.
static bool Substitute(std::string &source, const std::string &search, const std::string &replace, bool all)
Substitute all occurrences of search with replace in source.
static vtkWebGPURenderPipelineCache * New()
void DestroyRenderPipeline(const std::string &key)
Destroy the render pipeline associated with the given hash.
std::string GetPipelineKey(WGPURenderPipelineDescriptor *descriptor, const char *shaderSource)
Get a unique hash for the given combination of render pipeline descriptor and shader source.
void CreateRenderPipeline(WGPURenderPipelineDescriptor *descriptor, vtkWebGPURenderWindow *wgpuRenderWindow, const char *vertexShaderSource, const char *fragmentShaderSource)
Create a render pipeline for the given combination of render pipeline descriptor and shader source.
std::string GetPipelineKey(WGPURenderPipelineDescriptor *descriptor, const char *vertexShaderSource, const char *fragmentShaderSource)
Get a unique hash for the given combination of render pipeline descriptor and shader source.
void ReleaseGraphicsResources(vtkWindow *window)
Reset the pipeline cache.
void WaitForPendingRenderPipelines()
Wait for every pipeline started by CreateRenderPipelineAsync() to finish compiling and enter the cach...
~vtkWebGPURenderPipelineCache() override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void CreateRenderPipeline(WGPURenderPipelineDescriptor *descriptor, vtkWebGPURenderWindow *wgpuRenderWindow, const char *shaderSource)
Create a render pipeline for the given combination of render pipeline descriptor and shader source.
void CreateRenderPipelineAsync(WGPURenderPipelineDescriptor *descriptor, vtkWebGPURenderWindow *wgpuRenderWindow, const char *vertexShaderSource, const char *fragmentShaderSource)
Start creating a render pipeline without waiting for it to be compiled.
WebGPU rendering window.
window superclass for vtkRenderWindow
Definition vtkWindow.h:62
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define VTK_MARSHALAUTO