Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*
   Copyright (c) 2018 DIVIDE-Studio
   Copyright (c) 2009 Ionut Cava

   This file is part of DIVIDE Framework.

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software
   and associated documentation files (the "Software"), to deal in the Software
   without restriction,
   including without limitation the rights to use, copy, modify, merge, publish,
   distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the
   Software is furnished to do so,
   subject to the following conditions:

   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED,
   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
   PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
   DAMAGES OR OTHER LIABILITY,
   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
   IN CONNECTION WITH THE SOFTWARE
   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 */

#ifndef RESOURCE_DESCRIPTOR_H_
#define RESOURCE_DESCRIPTOR_H_

#include "Platform/Headers/PlatformDefines.h"
#include "Core/Headers/Hashable.h"

namespace Divide {

/// Dummy class so that resource loaders can have fast access to extra
/// information in a general format
class NOINITVTABLE PropertyDescriptor : public Hashable {
   public:
    enum class DescriptorType : U32 {
        DESCRIPTOR_TEXTURE = 0,
        DESCRIPTOR_PARTICLE = 1,
        DESCRIPTOR_TERRAIN_INFO = 2,
        DESCRIPTOR_COUNT
    };

    explicit PropertyDescriptor(const DescriptorType& type) noexcept : _type(type)
    {
    }

    virtual ~PropertyDescriptor()
    {
    }

    virtual size_t getHash() const override;

   protected:
    friend class ResourceDescriptor;
    /// Initialize descriptor values to their safe defaults
    virtual void setDefaultValues() = 0;
    /// Used to clone the property descriptor pointer
    virtual PropertyDescriptor* clone() const = 0;

   protected:
    /// useful for switch statements
    DescriptorType _type;
};

class CachedResource;
FWD_DECLARE_MANAGED_CLASS(CachedResource);

class ResourceDescriptor : public Hashable {
   public:
    explicit ResourceDescriptor(const stringImpl& resourceName);

    ~ResourceDescriptor();

    ResourceDescriptor(const ResourceDescriptor& old);
    ResourceDescriptor& operator=(ResourceDescriptor const& old);
    ResourceDescriptor(ResourceDescriptor&& old) noexcept;

    inline const stringImpl& getPropertyListString() const {
        return _properties;
    }
    inline const stringImpl& getResourceName() const {
        return _resourceName;
    }
    inline const stringImpl& getResourceLocation() const {
        return _resourceLocation;
    }
    inline const stringImpl& getName() const { return _name; }

    template <typename T>
    inline const std::shared_ptr<T> getPropertyDescriptor() const {
        static_assert(std::is_base_of<PropertyDescriptor, T>::value, "Invalid Property Descriptor");
        return std::dynamic_pointer_cast<T>(_propertyDescriptor);
    }

    inline bool hasPropertyDescriptor() const {
        return _propertyDescriptor != nullptr;
    }
    inline bool getFlag() const { return _flag; }
    inline bool getThreaded() const { return _threaded; }
    inline U32  getEnumValue() const { return _enumValue; }
    inline U32  getID() const { return _ID; }
    inline P32  getMask() const { return _mask; }
    inline void* getUserPtr() const { return _userPtr; }

    const DELEGATE_CBK<void, CachedResource_wptr>& onLoadCallback() const {
        return _onLoadCallback;
    }

    inline void setPropertyList(const stringImpl& propertyListString) {
        _properties = propertyListString;
    }
    inline void setResourceLocation(const stringImpl& resourceLocation) {
        _resourceLocation = resourceLocation;
    }
    inline void setResourceName(const stringImpl& resourceName) {
        _resourceName = resourceName;
    }
    inline void setEnumValue(U32 enumValue) { _enumValue = enumValue; }
    inline void setName(const stringImpl& name) { _name = name; }
    inline void setFlag(bool flag) { _flag = flag; }
    inline void setID(U32 ID) { _ID = ID; }
    inline void setBoolMask(P32 mask) { _mask = mask; }
    inline void setUserPtr(void* ptr) { _userPtr = ptr; }

    inline void setThreadedLoading(const bool threaded) {
        _threaded = threaded;
    }

    template <typename T>
    inline void setPropertyDescriptor(const T& descriptor) {
        static_assert(std::is_base_of<PropertyDescriptor, T>::value, "Invalid Property Descriptor");
        _propertyDescriptor.reset(MemoryManager_NEW T(descriptor));
    }

    void setOnLoadCallback(const DELEGATE_CBK<void, CachedResource_wptr>& callback) {
        _onLoadCallback = callback;
    }

    size_t getHash() const override;

   private:
    /// Item name
    stringImpl _name;
    /// Physical file location
    stringImpl _resourceLocation;
    /// Physical file name
    stringImpl _resourceName;
    /// Comma separated list of properties
    stringImpl _properties;
    bool _flag;
    bool _threaded;
    U32 _ID;
    /// 4 bool values representing  ... anything ...
    P32 _mask;
    U32 _enumValue;
    /// Use for extra resource properties: textures, samplers, terrain etc.
    std::shared_ptr<PropertyDescriptor> _propertyDescriptor;
    /// Callback to use when the resource finished loading (includes threaded loading)
    DELEGATE_CBK<void, CachedResource_wptr> _onLoadCallback;
    /// General Data
    void *_userPtr;
};

};  // namespace Divide

#endif

Commits for Divide-Framework/trunk/Source Code/Core/Resources/Headers/ResourceDescriptor.h

Diff revisions: vs.
Revision Author Commited Message
1029 Diff Diff IonutCava picture IonutCava Tue 30 Jan, 2018 17:28:39 +0000

[Ionut]
- Update copyright notices

993 Diff Diff IonutCava picture IonutCava Sun 10 Dec, 2017 20:07:57 +0000

[Ionut]
- Finished initial port of the old scene graph system to the new ECS based system.
- Finished converting 2 components to the new ECS system: Transform and RigidBody
- Fixed the “Deploy” build error with the CEGUI OpenGL renderer.
- Compilation now needs C++14 support (it’s sufficiently wide-spread now)

955 Diff Diff IonutCava picture IonutCava Sun 29 Oct, 2017 20:45:04 +0000

[Ionut]
- Modify the CEGUI opengl renderer to interact with the state in GLWrapper better
- Performance optimizations

953 Diff Diff IonutCava picture IonutCava Sat 28 Oct, 2017 21:57:10 +0000

[Ionut]
- Fix blinking issue by caching and hashing pipelines to that we don’t overwrite pipelines used by other elements

907 Diff Diff IonutCava picture IonutCava Wed 28 Jun, 2017 23:16:40 +0000

[Ionut]
- Rework texture loading, mip map generation, sampler usage, etc
- ResourceDescriptor for textures now ONLY takes a TextureDescriptor as a property descriptor. Sampler must be assigned to the tex descriptor:
— ToDo: Separate samplers completely from textures and assign them from a pool to textures at bind time

863 Diff Diff IonutCava picture IonutCava Wed 15 Feb, 2017 16:27:26 +0000

[IonutCava]
- Split Resource class into Resource and CachedResource
— CachedResource is the only resource held in a ResourceCache and loaded from a ResourceDescriptor
— CachedResource is mapped by its creation descriptor’s hash value, instead of the resource name
-— Multiple cached resources can now exist with the same name if the have different properties, for example.

860 Diff Diff IonutCava picture IonutCava Mon 13 Feb, 2017 21:07:59 +0000

[IonutCava]
- Fix shared_ptr leak in resource loading callbacks

859 Diff Diff IonutCava picture IonutCava Mon 13 Feb, 2017 17:18:06 +0000

[IonutCava]
- Multi-threaded mesh load
- ByteBuffer fixes and unit test

856 Diff Diff IonutCava picture IonutCava Fri 10 Feb, 2017 17:19:06 +0000

[IonutCava]
- Attempt to improve resource creation mechanism by adding a callback for when the resource finishes loading
— This is useful for multi-threaded loading: shaders, textures, terrain, etc

836 IonutCava picture IonutCava Fri 27 Jan, 2017 14:59:56 +0000

[IonutCava]
- Update copyright notice