mirror of
				https://github.com/intel/intel-graphics-compiler.git
				synced 2025-10-30 08:18:26 +08:00 
			
		
		
		
	Internal metadata changes
Internal metadata changes
This commit is contained in:
		| @ -198,6 +198,9 @@ private: | ||||
|   inline typename iterator::pointer allocate(size_t NumElts) { | ||||
|     return static_cast<typename iterator::pointer>(::operator new(NumElts * sizeof(typename iterator::value_type))); | ||||
|   } | ||||
|  | ||||
|   template <typename A, typename B> friend class UnorderedMap; | ||||
| }; | ||||
|  | ||||
|  | ||||
| } // namespace Interface | ||||
|  | ||||
							
								
								
									
										180
									
								
								IGC/AdaptorCommon/RayTracing/API/ADT/UnorderedMap.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										180
									
								
								IGC/AdaptorCommon/RayTracing/API/ADT/UnorderedMap.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,180 @@ | ||||
| /*========================== begin_copyright_notice ============================ | ||||
|  | ||||
| Copyright (C) 2020-2025 Intel Corporation | ||||
|  | ||||
| SPDX-License-Identifier: MIT | ||||
|  | ||||
| ============================= end_copyright_notice ===========================*/ | ||||
|  | ||||
| //===----------------------------------------------------------------------===// | ||||
| /// | ||||
| /// This is a simplified unordered map container that is suitable for use in an | ||||
| /// interface with the UMD. It uses the Array class for internal storage. | ||||
| /// | ||||
| //===----------------------------------------------------------------------===// | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #include "Array.h" | ||||
| #include <utility> | ||||
|  | ||||
| namespace Interface { | ||||
|  | ||||
| template <typename KeyT, typename ValueT> | ||||
| class UnorderedMap { | ||||
| private: | ||||
|   Array<KeyT> Keys; | ||||
|   Array<ValueT> Values; | ||||
|  | ||||
| public: | ||||
|   using key_type = KeyT; | ||||
|   using mapped_type = ValueT; | ||||
|   using value_type = std::pair<const key_type, mapped_type>; | ||||
|   using reference_type = std::pair<const key_type &, mapped_type &>; | ||||
|   using const_reference_type = std::pair<const key_type &, const mapped_type &>; | ||||
|  | ||||
|   UnorderedMap() = default; | ||||
|  | ||||
|   void destroy() { | ||||
|     Keys.destroy(); | ||||
|     Values.destroy(); | ||||
|   } | ||||
|  | ||||
|   size_t size() const { return Keys.size(); } | ||||
|   bool empty() const { return Keys.empty(); } | ||||
|  | ||||
|   // Find index of key, or size() if not found | ||||
|   size_t findIndex(const key_type& key) const { | ||||
|     for (size_t i = 0; i < Keys.size(); ++i) { | ||||
|       if (Keys[i] == key) | ||||
|         return i; | ||||
|     } | ||||
|     return Keys.size(); | ||||
|   } | ||||
|  | ||||
|   // Returns pointer to value if found, nullptr otherwise | ||||
|   mapped_type* find(const key_type& key) { | ||||
|     size_t idx = findIndex(key); | ||||
|     if (idx < Values.size()) | ||||
|       return &Values[idx]; | ||||
|     return nullptr; | ||||
|   } | ||||
|   const mapped_type* find(const key_type& key) const { | ||||
|     size_t idx = findIndex(key); | ||||
|     if (idx < Values.size()) | ||||
|       return &Values[idx]; | ||||
|     return nullptr; | ||||
|   } | ||||
|  | ||||
|   // Insert or assign | ||||
|   void insert(const key_type& key, const mapped_type& value) { | ||||
|     size_t idx = findIndex(key); | ||||
|     if (idx < Keys.size()) { | ||||
|       Values[idx] = value; | ||||
|     } else { | ||||
|       // Grow arrays by 1 | ||||
|       Array<KeyT> newKeys(Keys.size() + 1); | ||||
|       Array<ValueT> newValues(Values.size() + 1); | ||||
|       for (size_t i = 0; i < Keys.size(); ++i) { | ||||
|         newKeys[i] = Keys[i]; | ||||
|         newValues[i] = Values[i]; | ||||
|       } | ||||
|       newKeys[Keys.size()] = key; | ||||
|       newValues[Values.size()] = value; | ||||
|       Keys.destroy(); | ||||
|       Values.destroy(); | ||||
|       Keys = std::move(newKeys); | ||||
|       Values = std::move(newValues); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   // Insert or assign | ||||
|   void insert(const key_type& key, mapped_type&& value) { | ||||
|     size_t idx = findIndex(key); | ||||
|     if (idx < Keys.size()) { | ||||
|       Values[idx] = std::move(value); | ||||
|     } else { | ||||
|       uint32_t currSize = Keys.size(); | ||||
|  | ||||
|       Array<KeyT> oldKeys = std::move(Keys); | ||||
|       Array<ValueT> oldValues = std::move(Values); | ||||
|  | ||||
|       Keys = Array<KeyT>(currSize + 1); | ||||
|       Values = Array<ValueT>(currSize + 1); | ||||
|  | ||||
|       for (uint32_t i = 0; i < currSize; ++i) { | ||||
|         Keys[i] = std::move(oldKeys[i]); | ||||
|         Values[i] = std::move(oldValues[i]); | ||||
|       } | ||||
|  | ||||
|       Keys[currSize] = key; | ||||
|       Values[currSize] = std::move(value); | ||||
|  | ||||
|       oldKeys.destroy(); | ||||
|       oldValues.destroy(); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   // operator[] | ||||
|   mapped_type& operator[](const key_type& key) { | ||||
|     size_t idx = findIndex(key); | ||||
|     if (idx < Values.size()) | ||||
|       return Values[idx]; | ||||
|     // Insert default value | ||||
|     insert(key, std::move(mapped_type())); | ||||
|     return Values[Values.size() - 1]; | ||||
|   } | ||||
|  | ||||
|   struct iterator { | ||||
|  | ||||
|   private: | ||||
|     using keyIt = typename Array<KeyT>::iterator; | ||||
|     using ValueIt = typename Array<ValueT>::iterator; | ||||
|  | ||||
|     keyIt m_k; | ||||
|     ValueIt m_v; | ||||
|  | ||||
|   public: | ||||
|  | ||||
|     iterator(keyIt k, ValueIt v) : m_k(k), m_v(v) {} | ||||
|     reference_type operator*() const { return reference_type(*m_k, *m_v); } | ||||
|     iterator &operator++() { | ||||
|       m_k++; | ||||
|       m_v++; | ||||
|       return *this; | ||||
|     } | ||||
|  | ||||
|     bool operator==(const iterator &other) const { return m_k == other.m_k && m_v == other.m_v; } | ||||
|     bool operator!=(const iterator &other) const { return !(*this == other); } | ||||
|   }; | ||||
|  | ||||
|   iterator begin() { return iterator(Keys.begin(), Values.begin()); } | ||||
|   iterator end() { return iterator(Keys.end(), Values.end()); } | ||||
|  | ||||
|   struct const_iterator { | ||||
|  | ||||
|   private: | ||||
|     using keyIt = typename Array<KeyT>::const_iterator; | ||||
|     using ValueIt = typename Array<ValueT>::const_iterator; | ||||
|  | ||||
|     keyIt m_k; | ||||
|     ValueIt m_v; | ||||
|  | ||||
|   public: | ||||
|     const_iterator(keyIt k, ValueIt v) : m_k(k), m_v(v) {} | ||||
|     const_reference_type operator*() const { return const_reference_type(*m_k, *m_v); } | ||||
|     const_iterator &operator++() { | ||||
|       m_k++; | ||||
|       m_v++; | ||||
|       return *this; | ||||
|     } | ||||
|  | ||||
|     bool operator==(const const_iterator &other) const { return m_k == other.m_k && m_v == other.m_v; } | ||||
|     bool operator!=(const const_iterator &other) const { return !(*this == other); } | ||||
|   }; | ||||
|  | ||||
|   const_iterator begin() const { return const_iterator(Keys.begin(), Values.begin()); } | ||||
|   const_iterator end() const { return const_iterator(Keys.end(), Values.end()); } | ||||
| }; | ||||
|  | ||||
| } // namespace Interface | ||||
| @ -11,6 +11,7 @@ SPDX-License-Identifier: MIT | ||||
| #include "common/EmUtils.h" | ||||
|  | ||||
| #include "ADT/Array.h" | ||||
| #include "ADT/UnorderedMap.h" | ||||
| #include "ADT/Optional.h" | ||||
|  | ||||
| #include "BVHInfo.h" | ||||
|  | ||||
| @ -391,6 +391,7 @@ public: | ||||
|  | ||||
|   virtual bool supportsUniformPrivateMemorySpace() const { return false; } | ||||
|  | ||||
|  | ||||
|   virtual bool UseNewTraceRayInlineLoweringInRaytracingShaders() const { | ||||
|     return (IGC_GET_FLAG_VALUE(UseNewInlineRaytracing) & static_cast<uint32_t>(NewInlineRaytracingMask::RTShaders)) != | ||||
|            0; | ||||
|  | ||||
| @ -486,6 +486,10 @@ struct SBindlessProgram : SKernelProgram { | ||||
|   // a collection of other names that they go by. | ||||
|   std::vector<std::string> Aliases; | ||||
|  | ||||
|   // if the shader was created by cloning another shader | ||||
|   // this will contain the name of the original shader | ||||
|   std::string OriginatingShaderName; | ||||
|  | ||||
|   // We maintain this information to provide to GTPin. These are all | ||||
|   // offsets in bytes from the base of GRF. | ||||
|   uint32_t GlobalPtrOffset = 0; // pointer to RTGlobals | ||||
|  | ||||
| @ -115,6 +115,7 @@ set(IGC_BUILD__HDR__DriverInterface | ||||
|     ) | ||||
|   set(IGC_BUILD__HDR__RAYTRACING_API__ADT | ||||
|     "${CMAKE_CURRENT_SOURCE_DIR}/../AdaptorCommon/RayTracing/API/ADT/Array.h" | ||||
|     "${CMAKE_CURRENT_SOURCE_DIR}/../AdaptorCommon/RayTracing/API/ADT/UnorderedMap.h" | ||||
|     "${CMAKE_CURRENT_SOURCE_DIR}/../AdaptorCommon/RayTracing/API/ADT/Optional.h" | ||||
|     ) | ||||
|  | ||||
|  | ||||
| @ -324,6 +324,10 @@ enum class ShaderTypeMD | ||||
|  | ||||
|         // for continuations used in ReorderThread, this field indicates the maximum value of the coherence hint | ||||
|         uint32_t NumCoherenceHintBits = 0; | ||||
|  | ||||
|         // if the function was created by cloning another function | ||||
|         // this will contain the name of the original shader | ||||
|         std::string OriginatingShaderName; | ||||
|     }; | ||||
|  | ||||
|     struct ConstantAddress | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Jakacki, Jakub
					Jakacki, Jakub