35 enum GraphicsPipeline2DType :
int
38 GFX_PIPELINE_2D_POINTS = 0,
39 GFX_PIPELINE_2D_POINTS_HOMOGENEOUS_CELL_SIZE,
41 GFX_PIPELINE_2D_LINES,
42 GFX_PIPELINE_2D_LINES_HOMOGENEOUS_CELL_SIZE,
44 GFX_PIPELINE_2D_TRIANGLES,
45 GFX_PIPELINE_2D_TRIANGLES_HOMOGENEOUS_CELL_SIZE,
46 NUM_GFX_PIPELINE_2D_NB_TYPES
51 vtkTypeFloat32 WCVCMatrix[4][4];
52 vtkTypeFloat32 Color[4];
53 vtkTypeFloat32 PointSize;
54 vtkTypeFloat32 LineWidth;
56 vtkTypeUInt32 Padding;
58 static constexpr int BIT_POSITION_USE_CELL_COLOR = 0;
59 static constexpr int BIT_POSITION_USE_POINT_COLOR = 1;
61 struct MeshAttributeArrayDescriptor
63 vtkTypeUInt32 Start = 0;
64 vtkTypeUInt32 NumTuples = 0;
65 vtkTypeUInt32 NumComponents = 0;
70 MeshAttributeArrayDescriptor Positions;
71 MeshAttributeArrayDescriptor UVs;
72 MeshAttributeArrayDescriptor Colors;
82 struct TopologyBindGroupInfo
85 wgpu::Buffer ConnectivityBuffer;
87 wgpu::Buffer CellIdBuffer;
89 wgpu::Buffer CellIdOffsetUniformBuffer;
91 wgpu::BindGroup BindGroup;
93 vtkTypeUInt32 VertexCount = 0;
96 bool RebuildGraphicsPipelines =
false;
97 bool UseCellScalarMapping =
false;
98 bool UsePointScalarMapping =
false;
100 std::map<GraphicsPipeline2DType, vtkWebGPUCellToPrimitiveConverter::TopologySourceType>
101 PipelineBindGroupCombos = {
103 { GFX_PIPELINE_2D_POINTS_HOMOGENEOUS_CELL_SIZE,
106 { GFX_PIPELINE_2D_LINES_HOMOGENEOUS_CELL_SIZE,
109 { GFX_PIPELINE_2D_TRIANGLES_HOMOGENEOUS_CELL_SIZE,
113 const std::array<wgpu::PrimitiveTopology, NUM_GFX_PIPELINE_2D_NB_TYPES>
114 GraphicsPipeline2DPrimitiveTypes = { wgpu::PrimitiveTopology::TriangleStrip,
115 wgpu::PrimitiveTopology::TriangleStrip, wgpu::PrimitiveTopology::TriangleStrip,
116 wgpu::PrimitiveTopology::TriangleStrip, wgpu::PrimitiveTopology::TriangleList,
117 wgpu::PrimitiveTopology::TriangleList };
119 std::string GraphicsPipeline2DKeys[NUM_GFX_PIPELINE_2D_NB_TYPES];
125 MeshDescriptor MeshArraysDescriptor;
127 ShaderSSBO Mapper2DStateData;
128 ShaderSSBO AttributeDescriptorData;
131 TopologyBindGroupInfo
134 wgpu::BindGroup MeshAttributeBindGroup;
136 int ActorTextureUnit = -1;
137 wgpu::BindGroupLayout MeshAttributeBindGroupLayout;
144 static wgpu::BindGroupLayout CreateMeshAttributeBindGroupLayout(
const wgpu::Device& device,
150 static wgpu::BindGroupLayout CreateTopologyBindGroupLayout(
151 const wgpu::Device& device,
const std::string& label,
bool homogeneousCellSize);
156 static const char* GetGraphicsPipelineTypeAsString(GraphicsPipeline2DType graphicsPipelineType);
158 static bool IsPipelineForHomogeneousCellSize(GraphicsPipeline2DType graphicsPipelineType);
160 void ApplyShaderReplacements(GraphicsPipeline2DType pipelineType, std::string& vss,
163 void ReplaceShaderVertexOutputDef(std::string& vss, std::string& fss);
164 void ReplaceShaderMapperBindings(
167 void ReplaceVertexShaderConstantsDef(GraphicsPipeline2DType pipelineType, std::string& vss);
168 void ReplaceVertexShaderMapper2DStateDef(std::string& vss);
169 void ReplaceVertexShaderMeshArraysDescriptorDef(std::string& vss);
170 void ReplaceVertexShaderTopologyBindings(std::string& vss);
171 void ReplaceVertexShaderVertexInputDef(std::string& vss);
172 void ReplaceVertexShaderUtilityMethodsDef(GraphicsPipeline2DType pipelineType, std::string& vss);
173 void ReplaceVertexShaderVertexMainStart(std::string& vss);
174 void ReplaceVertexShaderVertexIdImpl(GraphicsPipeline2DType pipelineType, std::string& vss);
175 void ReplaceVertexShaderPrimitiveIdImpl(GraphicsPipeline2DType pipelineType, std::string& vss);
176 void ReplaceVertexShaderCellIdImpl(GraphicsPipeline2DType pipelineType, std::string& vss);
177 void ReplaceVertexShaderPositionImpl(GraphicsPipeline2DType pipelineType, std::string& vss);
178 void ReplaceVertexShaderPickingImpl(std::string& vss);
179 void ReplaceVertexShaderColorsImpl(std::string& vss);
180 void ReplaceVertexShaderUVsImpl(std::string& vss);
181 void ReplaceVertexShaderVertexMainEnd(std::string& vss);
183 void ReplaceFragmentShaderFragmentOutputDef(std::string& fss);
184 void ReplaceFragmentShaderFragmentMainStart(std::string& fss);
185 void ReplaceFragmentShaderPickingImpl(std::string& fss);
186 void ReplaceFragmentShaderColorImpl(std::string& fss);
187 void ReplaceFragmentShaderFragmentMainEnd(std::string& fss);