1 /* 2 * Copyright (C) 2024 Huawei Device Co., Ltd. 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 16 #ifndef API_RENDER_DEVICE_IGPU_RESOURCE_MANAGER_H 17 #define API_RENDER_DEVICE_IGPU_RESOURCE_MANAGER_H 18 19 #include <cstdint> 20 21 #include <base/containers/array_view.h> 22 #include <base/containers/string.h> 23 #include <base/containers/string_view.h> 24 #include <core/image/intf_image_container.h> 25 #include <render/device/gpu_resource_desc.h> 26 #include <render/device/pipeline_state_desc.h> 27 #include <render/namespace.h> 28 #include <render/resource_handle.h> 29 30 RENDER_BEGIN_NAMESPACE() 31 /** \addtogroup group_igpuresourcemanager 32 * @{ 33 */ 34 /** Backend specific image descriptor */ 35 struct BackendSpecificImageDesc {}; 36 37 /** Backend specific buffer descriptor */ 38 struct BackendSpecificBufferDesc {}; 39 40 class IGpuResourceCache; 41 42 /** Gpu resource manager. 43 * Internally synchronized. 44 * (except WaitForIdleAndDestroyGpuResources, MapBuffer, and UnmapBuffer are not internally synchronized) 45 * 46 * Handles waiting of gpu resource destruction internally. 47 * 48 * Create methods take a unique name (if named). 49 * Object is re-created if the name is already in use. 50 * Therefore do not use scoped handles if you're recreating them. 51 * Create method with a given GpuResourceHandle will replace the handle and return the same valid handle. 52 */ 53 class IGpuResourceManager { 54 public: 55 IGpuResourceManager(const IGpuResourceManager&) = delete; 56 IGpuResourceManager& operator=(const IGpuResourceManager&) = delete; 57 58 /** Get render handle reference of raw handle. 59 * @param handle Raw render handle 60 * @return Returns A render handle reference for the handle. 61 */ 62 virtual RenderHandleReference Get(const RenderHandle& handle) const = 0; 63 64 /** Create a GpuBuffer with unique buffer name. 65 * @param name Name of buffer 66 * @param desc Descriptor 67 * @return Returns A valid resource handle if the creation was successfull. 68 */ 69 virtual RenderHandleReference Create(const BASE_NS::string_view name, const GpuBufferDesc& desc) = 0; 70 71 /** Create a GpuBuffer with unique buffer name and data. 72 * @param name Name of buffer 73 * @param desc Descriptor 74 * @param data Gpu buffer data 75 * @return Returns A valid resource handle if the creation was successfull. 76 */ 77 virtual RenderHandleReference Create( 78 const BASE_NS::string_view name, const GpuBufferDesc& desc, const BASE_NS::array_view<const uint8_t> data) = 0; 79 80 /** Create an unnamed GpuBuffer with data. 81 * @param desc Descriptor 82 * @param data Gpu buffer data 83 * @return Returns A valid resource handle if the creation was successfull. 84 */ 85 virtual RenderHandleReference Create(const GpuBufferDesc& desc, const BASE_NS::array_view<const uint8_t> data) = 0; 86 87 /** Create a new GPU resource for a given GpuResourceHandle. (Old handle and name (if given) are valid) 88 * @param replacedHandle A valid handle which current resource will be destroyed and replaced with a new one. 89 * @param desc Descriptor 90 * @return Returns the same handle that was given if the resource handle was valid. 91 */ 92 virtual RenderHandleReference Create(const RenderHandleReference& replacedHandle, const GpuBufferDesc& desc) = 0; 93 94 /** Create an unnamed GpuBuffer. 95 * @param desc Descriptor 96 * @return Returns A valid resource handle if the creation was successfull. 97 */ 98 virtual RenderHandleReference Create(const GpuBufferDesc& desc) = 0; 99 100 /** Create a GpuImage with unique image name. 101 * @param name Name of image 102 * @param desc Descriptor 103 * @return Returns A valid resource handle if the creation was successfull. 104 */ 105 virtual RenderHandleReference Create(const BASE_NS::string_view name, const GpuImageDesc& desc) = 0; 106 107 /** Create a GpuImage with unique image name and data. 108 * @param name Name of image 109 * @param desc Descriptor 110 * @param data Gpu image data 111 * @return Returns A valid resource handle if the creation was successfull. 112 */ 113 virtual RenderHandleReference Create( 114 const BASE_NS::string_view name, const GpuImageDesc& desc, const BASE_NS::array_view<const uint8_t> data) = 0; 115 116 /** Create a GpuImage with unique image name and data with image copy description. 117 * @param name Name of image 118 * @param desc Descriptor 119 * @param data Gpu image data 120 * @param bufferImageCopies Array of buffer image copies 121 * @return Returns A valid resource handle if the creation was successfull. 122 */ 123 virtual RenderHandleReference Create(const BASE_NS::string_view name, const GpuImageDesc& desc, 124 const BASE_NS::array_view<const uint8_t> data, 125 const BASE_NS::array_view<const BufferImageCopy> bufferImageCopies) = 0; 126 127 /** Create a new GPU resource for a given GpuResourceHandle. (Old handle and name (if given) are valid) 128 * @param replacedHandle A valid handle which current resource will be destroyed and replaced with a new one. 129 * @param desc Descriptor 130 * @return Returns the same handle that was given if the resource handle was valid. 131 */ 132 virtual RenderHandleReference Create(const RenderHandleReference& replacedHandle, const GpuImageDesc& desc) = 0; 133 134 /** Create an unnamed GpuImage. 135 * @param desc Descriptor 136 * @return Returns A valid resource handle if the creation was successfull. 137 */ 138 virtual RenderHandleReference Create(const GpuImageDesc& desc) = 0; 139 140 /** Create an unnamed GpuImage with data. 141 * @param desc Descriptor 142 * @param data Gpu image data 143 * @return Returns A valid resource handle if the creation was successfull. 144 */ 145 virtual RenderHandleReference Create(const GpuImageDesc& desc, const BASE_NS::array_view<const uint8_t> data) = 0; 146 147 /** Create an unnamed GpuImage with data and image copy description. 148 * @param desc Descriptor 149 * @param data Gpu image data 150 * @param bufferImageCopies Array of buffer image copies 151 * @return Returns A valid resource handle if the creation was successfull. 152 */ 153 virtual RenderHandleReference Create(const GpuImageDesc& desc, const BASE_NS::array_view<const uint8_t> data, 154 const BASE_NS::array_view<const BufferImageCopy> bufferImageCopies) = 0; 155 156 /** Create GpuImage with unique image name from IImageContainer::Ptr 157 * @param name Name of image 158 * @param desc Descriptor 159 * @param image Image container 160 * @return Returns A valid resource handle if the creation was successfull. 161 */ 162 virtual RenderHandleReference Create( 163 const BASE_NS::string_view name, const GpuImageDesc& desc, CORE_NS::IImageContainer::Ptr image) = 0; 164 165 /** Create Unnamed GpuImage from IImageContainer::Ptr 166 * @param desc Descriptor 167 * @param image Image container 168 * @return Returns A valid resource handle if the creation was successfull. 169 */ 170 virtual RenderHandleReference Create(const GpuImageDesc& desc, CORE_NS::IImageContainer::Ptr image) = 0; 171 172 /** Create a GpuImage with unique image name from external image resource 173 * NOTE: the external image resource is not owned and not deleted by the manager when the handle is destroyed 174 * (e.g. if using hw buffers the hw buffer reference is released) 175 * @param name Name of image 176 * @param desc Descriptor 177 * @param backendSpecificData Image description 178 * @return Returns A valid resource handle if the creation was successfull. 179 */ 180 virtual RenderHandleReference CreateView(const BASE_NS::string_view name, const GpuImageDesc& desc, 181 const BackendSpecificImageDesc& backendSpecificData) = 0; 182 183 /** Create a GpuSampler with unique image name. 184 * @param name Name of image 185 * @param desc Descriptor 186 * @return Returns A valid resource handle if the creation was successfull. 187 */ 188 virtual RenderHandleReference Create(const BASE_NS::string_view name, const GpuSamplerDesc& desc) = 0; 189 190 /** Create a GpuSampler with replaced handle. 191 * @param replacedHandle Replaced handle 192 * @param desc Descriptor 193 * @return Returns A valid resource handle if the creation was successfull. 194 */ 195 virtual RenderHandleReference Create(const RenderHandleReference& replacedHandle, const GpuSamplerDesc& desc) = 0; 196 197 /** Create unnamed GpuSampler. 198 * @param desc Descriptor 199 * @return Returns A valid resource handle if the creation was successfull. 200 */ 201 virtual RenderHandleReference Create(const GpuSamplerDesc& desc) = 0; 202 203 /** Create unnamed GpuAccelerationStructure. A GPU buffer handle is returned with additional acceleration structure. 204 * @param desc Descriptor 205 * @return Returns A valid resource handle if the creation was successfull. 206 */ 207 virtual RenderHandleReference Create(const GpuAccelerationStructureDesc& desc) = 0; 208 209 /** Create uniquely named GpuAccelerationStructure. If name is found, the handle is replaced 210 * A GPU buffer handle is returned with additional acceleration structure. 211 * @param name Unique name for the acceleration structure 212 * @param desc Descriptor 213 * @return Returns A valid resource handle if the creation was successfull. 214 */ 215 virtual RenderHandleReference Create(const BASE_NS::string_view name, const GpuAccelerationStructureDesc& desc) = 0; 216 217 /** Create GpuAccelerationStructure and replace the given handle if it's valid (the same is returned in valid case). 218 * A GPU buffer handle is returned with additional acceleration structure. 219 * @param replacedHandle A valid handle which current resource will be destroyed and replaced with a new one. 220 * @param desc Descriptor 221 * @return Returns A valid resource handle if the creation was successfull. 222 */ 223 virtual RenderHandleReference Create( 224 const RenderHandleReference& replacedHandle, const GpuAccelerationStructureDesc& desc) = 0; 225 226 /** Get buffer handle. (Invalid handle if not found.) 227 * @param name Name of buffer 228 * @return Returns A valid resource handle if the named resource is available. 229 */ 230 virtual RenderHandleReference GetBufferHandle(const BASE_NS::string_view name) const = 0; 231 232 /** Get image handle. (Invalid handle if not found.) 233 * @param name Name of image 234 * @return Returns A valid resource handle if the named resource is available. 235 */ 236 virtual RenderHandleReference GetImageHandle(const BASE_NS::string_view name) const = 0; 237 238 /** Get sampler handle. (Invalid handle if not found.) 239 * @param name Name of sampler 240 * @return Returns A valid resource handle if the named resource is available. 241 */ 242 virtual RenderHandleReference GetSamplerHandle(const BASE_NS::string_view name) const = 0; 243 244 /** Get buffer descriptor 245 * @param handle Handle to resource 246 * @return Returns A GpuBufferDesc of a given GPU resource handle. 247 */ 248 virtual GpuBufferDesc GetBufferDescriptor(const RenderHandleReference& handle) const = 0; 249 250 /** Get image descriptor 251 * @param handle Handle to resource 252 * @return Returns A GpuImageDesc of a given GPU resource handle. 253 */ 254 virtual GpuImageDesc GetImageDescriptor(const RenderHandleReference& handle) const = 0; 255 256 /** Get sampler descriptor 257 * @param handle Handle to resource 258 * @return Returns A GpuSamplerDesc of a given GPU resource handle. 259 */ 260 virtual GpuSamplerDesc GetSamplerDescriptor(const RenderHandleReference& handle) const = 0; 261 262 /** Get acceleration structure descriptor 263 * @param handle Handle to resource 264 * @return Returns A GpuAccelerationStructureDesc of a given GPU resource handle. 265 */ 266 virtual GpuAccelerationStructureDesc GetAccelerationStructureDescriptor( 267 const RenderHandleReference& handle) const = 0; 268 269 /** Wait for Gpu to become idle and destroy all Gpu resources of destroyed handles. 270 * Not internally syncronized. Needs to be called from render thread where renderFrame is called. 271 * 272 * This is a hazardous method and should be called with extreme caution. 273 * In normal rendering situation RenderFrame() does the resource management automatically. 274 * This method is provided for forced destruction of Gpu resurces when RenderFrame() is not called. 275 * 276 * Do not call this method per frame. 277 */ 278 virtual void WaitForIdleAndDestroyGpuResources() = 0; 279 280 /** Map buffer memory. Always maps from the beginning of buffer. 281 * Preferrably use only for staging kind of data (e.g. fill data in another thread and then pass to staging). 282 * 1. Map once and get the pointer to memory 283 * 2. Write data to memory 284 * 3. Unmap and pass the handle to rendering/staging or whatever (with offset) 285 * The buffer needs to created with CORE_ENGINE_BUFFER_CREATION_MAP_OUTSIDE_RENDERER, 286 * CORE_ENGINE_BUFFER_CREATION_CREATE_IMMEDIATE and CORE_ENGINE_BUFFER_CREATION_DEFERRED_DESTROY and cannot be 287 * replaced with name or handle. 288 * @param handle Handle to resource 289 */ 290 virtual void* MapBufferMemory(const RenderHandleReference& handle) const = 0; 291 292 /** Unmap buffer 293 * @param handle Handle to resource 294 */ 295 virtual void UnmapBuffer(const RenderHandleReference& handle) const = 0; 296 297 /** Checks if resource is a GPU buffer */ 298 virtual bool IsGpuBuffer(const RenderHandleReference& handle) const = 0; 299 /** Checks if resource is a GPU image */ 300 virtual bool IsGpuImage(const RenderHandleReference& handle) const = 0; 301 /** Checks if resource is a GPU sampler */ 302 virtual bool IsGpuSampler(const RenderHandleReference& handle) const = 0; 303 /** Checks if resource is a GPU acceleration structure. If is GPU acceleration structure, it is GPU buffer as well. 304 */ 305 virtual bool IsGpuAccelerationStructure(const RenderHandleReference& handle) const = 0; 306 /** Image has been created to be used as a swapchain image. Fast check based on handle. 307 * Due to possible remapping with built-in CORE_DEFAULT_BACKBUFFER might not be an actual swapchain. 308 */ 309 virtual bool IsSwapchain(const RenderHandleReference& handle) const = 0; 310 311 /** Checks if resource is a client mappable */ 312 virtual bool IsMappableOutsideRender(const RenderHandleReference& handle) const = 0; 313 314 /** Returns supported flags for given resource handle format. */ 315 virtual FormatProperties GetFormatProperties(const RenderHandleReference& handle) const = 0; 316 /** Returns supported flags for given format. */ 317 virtual FormatProperties GetFormatProperties(const BASE_NS::Format format) const = 0; 318 319 /** Returns GpuImageDesc based on image container's ImageDesc. 320 * Conversion helper when loading images with image loaders. 321 * Sets automatically basic values which are needed for typical image usage: 322 * imageTiling = CORE_IMAGE_TILING_OPTIMAL 323 * usageFlags |= CORE_IMAGE_USAGE_SAMPLED_BIT | CORE_IMAGE_USAGE_TRANSFER_DST_BIT 324 * memoryPropertyFlags = CORE_MEMORY_PROPERTY_DEVICE_LOCAL_BIT 325 * if mips are requested adds mips related flags 326 * @param desc ImageDesc from IImageContainer. 327 * @return GpuImageDesc GPU image desc based on input. 328 */ 329 virtual GpuImageDesc CreateGpuImageDesc(const CORE_NS::IImageContainer::ImageDesc& desc) const = 0; 330 331 /** Returns name for the resource "" if no name found. 332 * NOTE: method should not be used during run-time on hot path. 333 * @param handle Handle of the resource. 334 * @return string Name of the resource. 335 */ 336 virtual BASE_NS::string GetName(const RenderHandleReference& handle) const = 0; 337 338 /** Returns all valid GPU buffer render handles. 339 * @return vector of handles. 340 */ 341 virtual BASE_NS::vector<RenderHandleReference> GetGpuBufferHandles() const = 0; 342 /** Returns all valid GPU image render handles. 343 * @return vector of handles. 344 */ 345 virtual BASE_NS::vector<RenderHandleReference> GetGpuImageHandles() const = 0; 346 /** Returns all valid GPU sampler render handles. 347 * @return vector of handles. 348 */ 349 virtual BASE_NS::vector<RenderHandleReference> GetGpuSamplerHandles() const = 0; 350 351 /** Force default GPU buffer creation usage flags. Used as bitwise OR with given descs. 352 * NOTE: Reduced performance expected 353 * Use only in situtation when necessary and not in real products. 354 * @param bufferUsageFlags Default buffer usage flags. With zero no flags (default) 355 */ 356 virtual void SetDefaultGpuBufferCreationFlags(const BufferUsageFlags usageFlags) = 0; 357 /** Force default GPU image creation usage flags. Used as bitwise OR with given descs. 358 * NOTE: Reduced performance expected 359 * Use only in situtation when necessary and not in real products. 360 * @param bufferUsageFlags Default buffer usage flags. With zero no flags (default) 361 */ 362 virtual void SetDefaultGpuImageCreationFlags(const ImageUsageFlags usageFlags) = 0; 363 364 /** Get gpu resource cache. 365 * @return Reference to GPU resource cache interface. 366 */ 367 virtual IGpuResourceCache& GetGpuResourceCache() const = 0; 368 369 /** Get image aspect flags for a given resource handle format. 370 * @param handle Render handle reference. 371 * @return Image aspect flags for a given format. 372 */ 373 virtual ImageAspectFlags GetImageAspectFlags(const RenderHandleReference& handle) const = 0; 374 375 /** Get image aspect flags for a given format. 376 * @param format Format. 377 * @return Image aspect flags for a given format. 378 */ 379 virtual ImageAspectFlags GetImageAspectFlags(const BASE_NS::Format format) const = 0; 380 381 protected: 382 IGpuResourceManager() = default; 383 virtual ~IGpuResourceManager() = default; 384 }; 385 386 /** IRenderNodeGpuResourceManager. 387 * Gpu resource manager interface to be used inside render nodes. 388 * Has management for per render node graph resources. 389 * All resources, created through this interface, are automatically tracked 390 * and destroyed when the render node graph which uses this render node is destroyed. 391 * 392 * Create methods take a unique name (if named). 393 * Object is re-created if the name is already in use. 394 * Therefore do not use scoped handles if you're recreating them. 395 */ 396 class IRenderNodeGpuResourceManager { 397 public: 398 /** Get render handle reference of raw handle. 399 * @param handle Raw render handle 400 * @return Returns A render handle reference for the handle. 401 */ 402 virtual RenderHandleReference Get(const RenderHandle& handle) const = 0; 403 404 /** Create a GpuBuffer. 405 * @param desc Descriptor 406 */ 407 virtual RenderHandleReference Create(const GpuBufferDesc& desc) = 0; 408 409 /** Create a GpuBuffer with unique buffer name. 410 * @param name Name used for creation 411 * @param desc Descriptor 412 */ 413 virtual RenderHandleReference Create(const BASE_NS::string_view name, const GpuBufferDesc& desc) = 0; 414 415 /** Create a GpuBuffer with replaced handle. 416 * @param handle Replaced handle 417 * @param desc Descriptor 418 */ 419 virtual RenderHandleReference Create(const RenderHandleReference& handle, const GpuBufferDesc& desc) = 0; 420 421 /** Create a GpuBuffer with unique buffer name and data. 422 * @param name Name for buffer 423 * @param desc Descriptor 424 * @param data Buffer data 425 */ 426 virtual RenderHandleReference Create( 427 const BASE_NS::string_view name, const GpuBufferDesc& desc, const BASE_NS::array_view<const uint8_t> data) = 0; 428 429 /** Create a GpuImage. 430 * @param desc Descriptor 431 */ 432 virtual RenderHandleReference Create(const GpuImageDesc& desc) = 0; 433 434 /** Create a GpuImage with unique image name. 435 * @param name Name for image 436 * @param desc Descriptor 437 */ 438 virtual RenderHandleReference Create(const BASE_NS::string_view name, const GpuImageDesc& desc) = 0; 439 440 /** Create a GpuImage with replaced handle. 441 * @param handle Replaced handle 442 * @param desc Descriptor 443 */ 444 virtual RenderHandleReference Create(const RenderHandleReference& handle, const GpuImageDesc& desc) = 0; 445 446 /** Create a GpuImage with unique image name and data. 447 * @param name Name for image 448 * @param desc Descriptor 449 * @param data Image buffer data 450 */ 451 virtual RenderHandleReference Create( 452 const BASE_NS::string_view name, const GpuImageDesc& desc, const BASE_NS::array_view<const uint8_t> data) = 0; 453 454 /** Create a GpuSampler. 455 * @param desc Descriptor 456 */ 457 virtual RenderHandleReference Create(const GpuSamplerDesc& desc) = 0; 458 459 /** Create a GpuSampler with unique sampler name. 460 * @param name Name for sampler 461 * @param desc Descriptor 462 */ 463 virtual RenderHandleReference Create(const BASE_NS::string_view name, const GpuSamplerDesc& desc) = 0; 464 465 /** Create a GpuSampler with replaced handle. 466 * @param handle Replaced handle 467 * @param desc Descriptor 468 */ 469 virtual RenderHandleReference Create(const RenderHandleReference& handle, const GpuSamplerDesc& desc) = 0; 470 471 /** Create a GpuAccelerationStructureDesc. 472 * @param desc Descriptor 473 */ 474 virtual RenderHandleReference Create(const GpuAccelerationStructureDesc& desc) = 0; 475 476 /** Create a GpuAccelerationStructureDesc with unique name. A GPU buffer handle is returned with additional 477 * acceleration structure. 478 * @param name Name for acceleration structure. 479 * @param desc Descriptor 480 */ 481 virtual RenderHandleReference Create(const BASE_NS::string_view name, const GpuAccelerationStructureDesc& desc) = 0; 482 483 /** Create a GpuAccelerationStructureDesc with replaced handle. A GPU buffer handle is returned with additional 484 * acceleration structure. 485 * @param handle Replaced handle 486 * @param desc Descriptor 487 */ 488 virtual RenderHandleReference Create( 489 const RenderHandleReference& handle, const GpuAccelerationStructureDesc& desc) = 0; 490 491 /** Get buffer handle 492 * @param name Name of buffer 493 */ 494 virtual RenderHandle GetBufferHandle(const BASE_NS::string_view name) const = 0; 495 496 /** Get image handle 497 * @param name Name of image 498 */ 499 virtual RenderHandle GetImageHandle(const BASE_NS::string_view name) const = 0; 500 501 /** Get sampler handle 502 * @param name Name of sampler 503 */ 504 virtual RenderHandle GetSamplerHandle(const BASE_NS::string_view name) const = 0; 505 506 /** Get buffer descriptor 507 * @param handle Handle to resource 508 */ 509 virtual GpuBufferDesc GetBufferDescriptor(const RenderHandle& handle) const = 0; 510 511 /** Get image descriptor 512 * @param handle Handle to resource 513 */ 514 virtual GpuImageDesc GetImageDescriptor(const RenderHandle& handle) const = 0; 515 516 /** Get sampler descriptor 517 * @param handle Handle to resource 518 */ 519 virtual GpuSamplerDesc GetSamplerDescriptor(const RenderHandle& handle) const = 0; 520 521 /** Get acceleration structure descriptor 522 * @param handle Handle to resource 523 */ 524 virtual GpuAccelerationStructureDesc GetAccelerationStructureDescriptor(const RenderHandle& handle) const = 0; 525 526 /** Map buffer, Only available in render nodes. 527 * Automatically advances buffered dynamic ring buffer offset. 528 * @param handle Handle to resource 529 */ 530 virtual void* MapBuffer(const RenderHandle& handle) const = 0; 531 532 /** Map buffer memory, Only available in render nodes. 533 * Always maps from the beginning of buffer. 534 * @param handle Handle to resource 535 */ 536 virtual void* MapBufferMemory(const RenderHandle& handle) const = 0; 537 538 /** Unmap buffer 539 * @param handle Handle to resource 540 */ 541 virtual void UnmapBuffer(const RenderHandle& handle) const = 0; 542 543 /** Checks validity of a handle */ 544 virtual bool IsValid(const RenderHandle& handle) const = 0; 545 /** Checks if resource is a GPU buffer */ 546 virtual bool IsGpuBuffer(const RenderHandle& handle) const = 0; 547 /** Checks if resource is a GPU image */ 548 virtual bool IsGpuImage(const RenderHandle& handle) const = 0; 549 /** Checks if resource is a GPU sampler */ 550 virtual bool IsGpuSampler(const RenderHandle& handle) const = 0; 551 /** Checks if resource is a GPU acceleration structure. If is GPU acceleration structure, it is GPU buffer as 552 * well. */ 553 virtual bool IsGpuAccelerationStructure(const RenderHandle& handle) const = 0; 554 /** Image has been created to be used as a swapchain image. Fast check based on handle. 555 * Due to possible remapping with built-in CORE_DEFAULT_BACKBUFFER might not be an actual swapchain. 556 */ 557 virtual bool IsSwapchain(const RenderHandle& handle) const = 0; 558 559 /** Returns supported flags for given resource handle format. */ 560 virtual FormatProperties GetFormatProperties(const RenderHandle& handle) const = 0; 561 /** Returns supported flags for given format. */ 562 virtual FormatProperties GetFormatProperties(const BASE_NS::Format format) const = 0; 563 564 /** Returns name for the resource "" if no name found. 565 * NOTE: method should not be used during run-time on hot path. 566 * @param handle Handle of the resource. 567 * @return string Name of the resource. 568 */ 569 virtual BASE_NS::string GetName(const RenderHandle& handle) const = 0; 570 571 /** Get gpu resource cache. 572 * @return Reference to GPU resource cache interface. 573 */ 574 virtual IGpuResourceCache& GetGpuResourceCache() const = 0; 575 576 /** Get image aspect flags for given format. 577 * @param handle Render handle of the resource 578 * @return Image aspect flags for given format. 579 */ 580 virtual ImageAspectFlags GetImageAspectFlags(const RenderHandle& handle) const = 0; 581 582 /** Get image aspect flags for given format. 583 * @param format Format. 584 * @return Image aspect flags for given format. 585 */ 586 virtual ImageAspectFlags GetImageAspectFlags(const BASE_NS::Format format) const = 0; 587 588 protected: 589 IRenderNodeGpuResourceManager() = default; 590 virtual ~IRenderNodeGpuResourceManager() = default; 591 }; 592 /** @} */ 593 RENDER_END_NAMESPACE() 594 595 #endif // API_RENDER_DEVICE_IGPU_RESOURCE_MANAGER_H 596