1 // Copyright 2021 The Dawn Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef DAWNNATIVE_COMPILATIONMESSAGES_H_ 16 #define DAWNNATIVE_COMPILATIONMESSAGES_H_ 17 18 #include "dawn_native/dawn_platform.h" 19 20 #include "common/NonCopyable.h" 21 22 #include <string> 23 #include <vector> 24 25 namespace tint { namespace diag { 26 class Diagnostic; 27 class List; 28 }} // namespace tint::diag 29 30 namespace dawn_native { 31 32 class OwnedCompilationMessages : public NonCopyable { 33 public: 34 OwnedCompilationMessages(); 35 ~OwnedCompilationMessages() = default; 36 37 void AddMessageForTesting( 38 std::string message, 39 wgpu::CompilationMessageType type = wgpu::CompilationMessageType::Info, 40 uint64_t lineNum = 0, 41 uint64_t linePos = 0, 42 uint64_t offset = 0, 43 uint64_t length = 0); 44 void AddMessages(const tint::diag::List& diagnostics); 45 void ClearMessages(); 46 47 const WGPUCompilationInfo* GetCompilationInfo(); 48 const std::vector<std::string>& GetFormattedTintMessages(); 49 50 private: 51 void AddMessage(const tint::diag::Diagnostic& diagnostic); 52 void AddFormattedTintMessages(const tint::diag::List& diagnostics); 53 54 WGPUCompilationInfo mCompilationInfo; 55 std::vector<std::string> mMessageStrings; 56 std::vector<WGPUCompilationMessage> mMessages; 57 std::vector<std::string> mFormattedTintMessages; 58 }; 59 60 } // namespace dawn_native 61 62 #endif // DAWNNATIVE_COMPILATIONMESSAGES_H_