Diligent Engine API Reference
ResourceMapping.h
1 /* Copyright 2015-2018 Egor Yusov
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  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
12  *
13  * In no event and under no legal theory, whether in tort (including negligence),
14  * contract, or otherwise, unless required by applicable law (such as deliberate
15  * and grossly negligent acts) or agreed to in writing, shall any Contributor be
16  * liable for any damages, including any direct, indirect, special, incidental,
17  * or consequential damages of any character arising as a result of this License or
18  * out of the use or inability to use the software (including but not limited to damages
19  * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
20  * all other commercial damages or losses), even if such Contributor has been advised
21  * of the possibility of such damages.
22  */
23 
24 #pragma once
25 
28 
29 #include "DeviceObject.h"
30 
31 namespace Diligent
32 {
33  // {6C1AC7A6-B429-4139-9433-9E54E93E384A}
34  static constexpr INTERFACE_ID IID_ResourceMapping =
35  { 0x6c1ac7a6, 0xb429, 0x4139, { 0x94, 0x33, 0x9e, 0x54, 0xe9, 0x3e, 0x38, 0x4a } };
36 
39  {
41  const Char* Name;
42 
45 
46  Uint32 ArrayIndex;
48 
52  ResourceMappingEntry( const Char* _Name = nullptr, IDeviceObject *_pObject = nullptr, Uint32 _ArrayIndex = 0) :
53  Name( _Name ),
54  pObject( _pObject ),
55  ArrayIndex(_ArrayIndex)
56  {}
57  };
58 
61  {
66 
68 
72  ResourceMappingDesc() : pEntries( nullptr ){}
73  };
74 
76 
80  class IResourceMapping : public IObject
81  {
82  public:
84  virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ) = 0;
85 
87 
96  virtual void AddResource( const Char *Name, IDeviceObject *pObject, bool bIsUnique ) = 0;
97 
98 
100 
111  virtual void AddResourceArray( const Char *Name, Uint32 StartIndex, IDeviceObject* const* ppObjects, Uint32 NumElements, bool bIsUnique ) = 0;
112 
113 
115 
118  virtual void RemoveResourceByName( const Char *Name, Uint32 ArrayIndex = 0 ) = 0;
119 
121 
129  virtual void GetResource( const Char *Name, IDeviceObject **ppResource, Uint32 ArrayIndex = 0 ) = 0;
130 
132  virtual size_t GetSize() = 0;
133  };
134 }
Base interface for all objects created by the render device Diligent::IRenderDevice.
Definition: DeviceObject.h:40
ResourceMappingEntry * pEntries
Pointer to the array of resource mapping entries. The last element in the array must be default value...
Definition: ResourceMapping.h:65
virtual size_t GetSize()=0
Returns the size of the resource mapping, i.e. the number of objects.
virtual void AddResourceArray(const Char *Name, Uint32 StartIndex, IDeviceObject *const *ppObjects, Uint32 NumElements, bool bIsUnique)=0
Adds resource array to the mapping.
ResourceMappingEntry(const Char *_Name=nullptr, IDeviceObject *_pObject=nullptr, Uint32 _ArrayIndex=0)
Initializes the structure members.
Definition: ResourceMapping.h:52
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34
Resouce mapping.
Definition: ResourceMapping.h:80
ResourceMappingDesc()
Initializes the structure members with default values.
Definition: ResourceMapping.h:72
virtual void RemoveResourceByName(const Char *Name, Uint32 ArrayIndex=0)=0
Removes a resource from the mapping using its literal name.
Resource mapping description.
Definition: ResourceMapping.h:60
virtual void QueryInterface(const Diligent::INTERFACE_ID &IID, IObject **ppInterface)=0
Queries the specific interface, see IObject::QueryInterface() for details.
virtual void GetResource(const Char *Name, IDeviceObject **ppResource, Uint32 ArrayIndex=0)=0
Finds a resource in the mapping.
const Char * Name
Object name.
Definition: ResourceMapping.h:41
virtual void AddResource(const Char *Name, IDeviceObject *pObject, bool bIsUnique)=0
Adds a resource to the mapping.
Describes the resourse mapping object entry.
Definition: ResourceMapping.h:38
IDeviceObject * pObject
Pointer to the object's interface.
Definition: ResourceMapping.h:44