23 #if defined(GTE_DEV_OPENGL) 36 #if defined(GTE_DEV_OPENGL) 58 int Set(
std::string const& name, std::shared_ptr<T>
const&
object);
61 std::shared_ptr<T>
const Get(
std::string const& name)
const;
64 void Set(
int handle, std::shared_ptr<T>
const&
object);
67 std::shared_ptr<T>
const Get(
int handle)
const;
72 unsigned int GetConstantBufferSize(
int handle)
const;
73 unsigned int GetConstantBufferSize(
std::string const& name)
const;
74 unsigned int GetTextureBufferSize(
int handle)
const;
75 unsigned int GetTextureBufferSize(
std::string const& name)
const;
76 unsigned int GetStructuredBufferSize(
int handle)
const;
77 unsigned int GetStructuredBufferSize(
std::string const& name)
const;
80 bool GetConstantBufferLayout(
int handle,
BufferLayout& layout)
const;
82 bool GetTextureBufferLayout(
int handle,
BufferLayout& layout)
const;
84 #if defined(GTE_DEV_OPENGL) 85 bool GetStructuredBufferLayout(
int handle,
BufferLayout& layout)
const;
89 inline unsigned int GetNumXThreads()
const;
90 inline unsigned int GetNumYThreads()
const;
91 inline unsigned int GetNumZThreads()
const;
93 #if defined(GTE_DEV_OPENGL) 96 ConstantBufferShaderDataLookup = 0,
97 TextureBufferShaderDataLookup = 1,
98 StructuredBufferShaderDataLookup = 2,
99 RawBufferShaderDataLookup = 3,
100 TextureSingleShaderDataLookup = 4,
101 TextureArrayShaderDataLookup = 5,
102 SamplerStateShaderDataLookup = 6,
103 AtomicCounterBufferShaderDataLookup = 7,
104 AtomicCounterShaderDataLookup = 8,
105 NUM_LOOKUP_INDICES = 9
110 ConstantBufferShaderDataLookup = 0,
111 TextureBufferShaderDataLookup = 1,
112 StructuredBufferShaderDataLookup = 2,
113 RawBufferShaderDataLookup = 3,
114 TextureSingleShaderDataLookup = 4,
115 TextureArrayShaderDataLookup = 5,
116 SamplerStateShaderDataLookup = 6,
117 NUM_LOOKUP_INDICES = 7
134 #if defined(GTE_DEV_OPENGL) 162 int inBindPoint,
int inNumBytes,
unsigned int inExtra,
163 bool inIsGpuWritable);
165 std::shared_ptr<GraphicsObject>
object;
166 GraphicsObjectType
type;
177 int inBindPoint,
int inNumBytes,
unsigned int inExtra,
178 bool inIsGpuWritable);
198 std::vector<Data> mData[NUM_LOOKUP_INDICES];
207 #if defined(GTE_DEV_OPENGL) 208 std::vector<BufferLayout> mSBufferLayouts;
213 inline std::vector<unsigned char>
const& GetCompiledCode()
const;
214 inline std::vector<Data>
const& GetData(
int lookup)
const;
218 template <
typename T>
222 for (
auto&
data : mData[T::shaderDataLookup])
224 if (name ==
data.name)
226 if (IsValid(
data,
object.
get()))
236 LogError(
"Cannot find object " + name +
".");
240 template <
typename T>
243 for (
auto const&
data : mData[T::shaderDataLookup])
245 if (name ==
data.name)
247 return std::static_pointer_cast<T>(
data.object);
253 template <
typename T>
256 std::vector<Data>&
data = mData[T::shaderDataLookup];
257 if (0 <= handle && handle < static_cast<int>(data.size()))
259 auto& d = data[handle];
260 if (IsValid(d,
object.
get()))
267 LogError(
"Invalid handle for object.");
270 template <
typename T>
273 std::vector<Data>
const&
data = mData[T::shaderDataLookup];
274 if (0 <= handle && handle < static_cast<int>(data.size()))
276 return std::static_pointer_cast<T>(data[handle].object);
285 std::shared_ptr<ConstantBuffer>
const&
object)
290 if (name ==
data.name)
292 if (IsValid(
data,
object.
get()))
295 object->SetLayout(mCBufferLayouts[handle]);
303 LogError(
"Cannot find object " + name +
".");
311 std::shared_ptr<TextureBuffer>
const&
object)
316 if (name ==
data.name)
318 if (IsValid(
data,
object.
get()))
321 object->SetLayout(mTBufferLayouts[handle]);
329 LogError(
"Cannot find object " + name +
".");
336 void Shader::Set(
int handle, std::shared_ptr<ConstantBuffer>
const&
object)
339 if (0 <= handle && handle < static_cast<int>(data.size()))
341 auto& d = data[handle];
342 if (IsValid(d,
object.
get()))
345 object->SetLayout(mCBufferLayouts[handle]);
350 LogError(
"Invalid handle for object.");
356 void Shader::Set(
int handle, std::shared_ptr<TextureBuffer>
const&
object)
359 if (0 <= handle && handle < static_cast<int>(data.size()))
361 auto& d = data[handle];
362 if (IsValid(d,
object.
get()))
365 object->SetLayout(mTBufferLayouts[handle]);
370 LogError(
"Invalid handle for object.");
390 return mCompiledCode;
395 return mData[lookup];
std::vector< BufferLayout > mTBufferLayouts
std::vector< MemberLayout > BufferLayout
GLbitfield GLuint program
GLuint const GLchar * name
static int const shaderDataLookup
int Get(std::string const &name) const
int Set(std::string const &name, std::shared_ptr< T > const &object)
GLsizei const GLchar *const * string
#define LogError(message)
static int const shaderDataLookup
unsigned int GetNumYThreads() const
std::shared_ptr< GraphicsObject > object
unsigned int mNumXThreads
unsigned int mNumYThreads
std::vector< BufferLayout > mCBufferLayouts
std::vector< unsigned char > mCompiledCode
unsigned int mNumZThreads
unsigned int GetNumZThreads() const
unsigned int GetNumXThreads() const
std::vector< unsigned char > const & GetCompiledCode() const
GLint GLint GLsizei GLint GLenum GLenum type
std::vector< Data > const & GetData(int lookup) const