------------------------------------------------------------------------------
| 70 | |
| 71 | //------------------------------------------------------------------------------ |
| 72 | void vtkWebGPUTexture::Load(vtkRenderer* renderer) |
| 73 | { |
| 74 | vtkLog(TRACE, "Loading texture host resource=" << this << " to renderer=" << renderer); |
| 75 | auto* wgpuRenderWindow = static_cast<vtkWebGPURenderWindow*>(renderer->GetRenderWindow()); |
| 76 | if (!wgpuRenderWindow) |
| 77 | { |
| 78 | vtkErrorMacro("No WebGPU render window found."); |
| 79 | return; |
| 80 | } |
| 81 | auto* input = this->GetInput(); |
| 82 | if (!input) |
| 83 | { |
| 84 | vtkErrorMacro("No input data found."); |
| 85 | return; |
| 86 | } |
| 87 | std::vector<vtkImageData*> inputs; |
| 88 | vtkMTimeType inputTime = input->GetMTime(); |
| 89 | int dims[3] = { 0, 0, 0 }; |
| 90 | input->GetDimensions(dims); |
| 91 | auto* firstInputScalars = this->GetInputArrayToProcess(0, input); |
| 92 | if (!firstInputScalars) |
| 93 | { |
| 94 | vtkErrorMacro("No scalar values found for texture input 0"); |
| 95 | return; |
| 96 | } |
| 97 | int numComponents = firstInputScalars->GetNumberOfComponents(); |
| 98 | int dataType = firstInputScalars->GetDataType(); |
| 99 | if (this->CubeMap) |
| 100 | { |
| 101 | for (int i = 1; i < this->GetNumberOfInputPorts(); ++i) |
| 102 | { |
| 103 | vtkImageData* image = vtkImageData::SafeDownCast(this->GetInputDataObject(i, 0)); |
| 104 | if (!image) |
| 105 | { |
| 106 | vtkErrorMacro("No input data found for texture input " << i); |
| 107 | continue; |
| 108 | } |
| 109 | inputTime = std::max(inputTime, image->GetMTime()); |
| 110 | inputs.emplace_back(image); |
| 111 | int otherDims[3] = { 0, 0, 0 }; |
| 112 | image->GetDimensions(otherDims); |
| 113 | if (otherDims[0] != dims[0] || otherDims[1] != dims[1] || otherDims[2] != dims[2]) |
| 114 | { |
| 115 | vtkErrorMacro("All cube map faces must have the same dimensions"); |
| 116 | return; |
| 117 | } |
| 118 | auto* otherScalars = this->GetInputArrayToProcess(i, image); |
| 119 | if (!otherScalars) |
| 120 | { |
| 121 | vtkErrorMacro("No scalar values found for texture input " << i); |
| 122 | return; |
| 123 | } |
| 124 | if (otherScalars->GetDataType() != dataType) |
| 125 | { |
| 126 | vtkErrorMacro("All cube map faces must have the same scalar data type"); |
| 127 | return; |
| 128 | } |
| 129 | if (otherScalars->GetNumberOfComponents() != numComponents) |
no test coverage detected