Line data Source code
1 :
2 : /* Copyright (c) 2013-2014, Stefan.Eilemann@epfl.ch
3 : *
4 : * This file is part of Pression <https://github.com/Eyescale/Pression>
5 : *
6 : * This library is free software; you can redistribute it and/or modify it under
7 : * the terms of the GNU Lesser General Public License version 2.1 as published
8 : * by the Free Software Foundation.
9 : *
10 : * This library is distributed in the hope that it will be useful, but WITHOUT
11 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 : * details.
14 : *
15 : * You should have received a copy of the GNU Lesser General Public License
16 : * along with this library; if not, write to the Free Software Foundation, Inc.,
17 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 : */
19 :
20 : #ifndef PRESSION_UPLOADER_H
21 : #define PRESSION_UPLOADER_H
22 :
23 : #include <pression/api.h>
24 : #include <pression/types.h>
25 : #include <lunchbox/thread.h> // thread-safety macros
26 :
27 : namespace pression
28 : {
29 : namespace detail { class Uploader; }
30 :
31 : /** A C++ class to handle one uploader plugin instance. */
32 : class Uploader
33 : {
34 : public:
35 : /** Construct a new, invalid uploader instance. @version 1.7.1 */
36 : PRESSION_API Uploader();
37 :
38 : /**
39 : * Construct a new, named uploader instance.
40 : *
41 : * @param from the plugin registry.
42 : * @param name the name of the uploader.
43 : * @version 1.7.1
44 : */
45 : PRESSION_API Uploader( PluginRegistry& from, const uint32_t name );
46 :
47 : /** Destruct this uploader. @version 1.7.1 */
48 : PRESSION_API virtual ~Uploader();
49 :
50 : /** @return true if the instance is usable. @version 1.7.1 */
51 : PRESSION_API bool isGood( const GLEWContext* gl ) const;
52 :
53 : /**
54 : * @return true if the instance is usable for the given name.
55 : * @version 1.7.1
56 : */
57 : PRESSION_API bool uses( const uint32_t name ) const;
58 :
59 : /**
60 : * @return true if the uploader supports the given parameters.
61 : * @version 1.7.1
62 : */
63 : PRESSION_API bool supports( const uint32_t externalFormat,
64 : const uint32_t internalFormat,
65 : const uint64_t capabilities,
66 : const GLEWContext* gl ) const;
67 :
68 : /**
69 : * Find the best uploader in all plugins for the given parameters.
70 : *
71 : * This convenience method searches all compressors in all plugins to find
72 : * the uploader which supports the given parameters and provides the highest
73 : * speed.
74 : * @version 1.7.1
75 : */
76 : static PRESSION_API uint32_t choose( const PluginRegistry& from,
77 : const uint32_t externalFormat,
78 : const uint32_t internalFormat,
79 : const uint64_t capabilities,
80 : const GLEWContext* gl );
81 :
82 : /** @return the information about the allocated uploader. @version 1.7.1 */
83 : PRESSION_API const EqCompressorInfo& getInfo() const;
84 :
85 : /**
86 : * Set up a new, named uploader instance.
87 : *
88 : * @param from the plugin registry
89 : * @param name the name of the uploader
90 : * @return true on success, false otherwise.
91 : * @version 1.7.1
92 : */
93 : PRESSION_API bool setup( PluginRegistry& from, const uint32_t name );
94 :
95 : /**
96 : * Set up a new, auto-selected uploader instance.
97 : * @sa choose() for parameters.
98 : * @version 1.7.1
99 : */
100 : PRESSION_API bool setup( PluginRegistry& from,
101 : const uint32_t externalFormat,
102 : const uint32_t internalFormat,
103 : const uint64_t capabilities,
104 : const GLEWContext* gl );
105 :
106 : /** Reset to EQ_COMPRESSOR_NONE. @version 1.7.1 */
107 : PRESSION_API void clear();
108 :
109 : /**
110 : * Upload data from cpu to the frame buffer or texture
111 : *
112 : * @param buffer data source
113 : * @param inDims the dimensions of the input data
114 : * @param flags capability flags for the compression
115 : * @param outDims the dimensions of the output data
116 : * @param destination the destination texture name, or 0 for framebuffer
117 : * @param gl the OpenGL function table
118 : * @version 1.7.1
119 : */
120 : PRESSION_API void upload( const void* buffer, const uint64_t inDims[4],
121 : const uint64_t flags, const uint64_t outDims[4],
122 : const unsigned destination,
123 : const GLEWContext* gl );
124 : private:
125 : Uploader( const Uploader& );
126 : Uploader operator=( const Uploader& );
127 : detail::Uploader* const impl_;
128 0 : LB_TS_VAR( _thread );
129 : };
130 : }
131 : #endif // PRESSION_UPLOADER_H
|