14 int inBindPoint,
int inNumBytes,
unsigned int inExtra,
19 bindPoint(inBindPoint),
22 isGpuWritable(inIsGpuWritable)
26 #if defined(GTE_DEV_OPENGL) 36 GLint sizeX, sizeY, sizeZ;
47 for (
auto const& uni : uniforms)
49 if (uni.referencedBy[
type])
171 int numUniformBlockReferences = 0;
172 for (
auto const& block : uniformBlocks)
174 if (block.referencedBy[
type])
176 ++numUniformBlockReferences;
179 if (numUniformBlockReferences > 0)
187 for (
auto const& block : uniformBlocks)
189 if (block.referencedBy[
type])
193 block.bufferDataSize, 0,
false));
196 for (
auto const& uniform : uniforms)
198 if (uniform.blockIndex != blockIndex)
204 item.
name = uniform.name;
205 item.
offset = uniform.offset;
212 (uniform.arraySize > 1 ? uniform.arraySize : 0);
226 int numAtomicCounterBufferReferences = 0;
227 for (
auto const& block : atomicCounterBuffers)
229 if (block.referencedBy[
type])
231 ++numAtomicCounterBufferReferences;
234 if (numAtomicCounterBufferReferences > 0)
236 unsigned blockIndex = 0;
237 for (
auto const& block : atomicCounterBuffers)
239 if (block.referencedBy[
type])
245 unsigned bufferDataSize = block.bufferDataSize;
246 for (
unsigned i=0; i < block.activeVariables.size(); ++i)
248 auto const& ac = uniforms[block.activeVariables[i]];
249 unsigned const lastByte = ac.offset + 4;
251 bufferDataSize = std::max(bufferDataSize, lastByte);
254 mData[AtomicCounterBufferShaderDataLookup].push_back(
256 block.bufferBinding, bufferDataSize, 0,
true));
264 int numBufferBlockReferences = 0;
265 for (
auto const& block : bufferBlocks)
267 if (block.referencedBy[
type])
269 ++numBufferBlockReferences;
272 if (numBufferBlockReferences > 0)
275 mSBufferLayouts.resize(numBufferBlockReferences);
281 for (
auto const& block : bufferBlocks)
283 if (block.referencedBy[
type])
289 bool hasAtomicCounter =
false;
290 unsigned int idAtomicCounter = ~0U;
291 for (
auto const& uniform : uniforms)
293 if ((
counterName == uniform.name) && (uniform.atomicCounterBufferIndex >= 0))
295 hasAtomicCounter =
true;
296 idAtomicCounter =
static_cast<unsigned int>(
mData[AtomicCounterShaderDataLookup].size());
297 mData[AtomicCounterShaderDataLookup].push_back(
299 4, uniform.offset,
false));
309 auto& layout = mSBufferLayouts[layoutIndex];
310 GLint structSize = 0;
311 for (
unsigned v = 0;
v < block.activeVariables.size(); ++
v)
313 auto const& bufferVar = bufferVariables[block.activeVariables[
v]];
315 if (bufferVar.topLevelArrayStride != structSize)
323 structSize = bufferVar.topLevelArrayStride;
330 item.
name = bufferVar.name;
331 item.
offset = bufferVar.offset;
338 (bufferVar.arraySize > 1 ? bufferVar.arraySize : 0);
340 layout.push_back(item);
348 structSize, idAtomicCounter, hasAtomicCounter));
375 cb.GetNumBytes(), 0,
false));
387 tb.GetNumBytes(), 0,
false));
395 unsigned int ctrtype = 0xFFFFFFFFu;
396 switch (sb.GetType())
407 case HLSLStructuredBuffer::SBT_COUNTER:
408 ctrtype = StructuredBuffer::CT_COUNTER;
412 LogError(
"Unexpected structured buffer option: " +
413 std::to_string(static_cast<int>(sb.GetType())));
418 sb.GetNumBytes(), ctrtype, sb.IsGpuWritable()));
425 rb.GetNumBytes(), 0, rb.IsGpuWritable()));
432 tx.GetNumDimensions(), tx.IsGpuWritable()));
439 ta.GetNumDimensions(), ta.IsGpuWritable()));
463 if (name ==
data.name)
476 if (0 <= handle && handle < static_cast<int>(
data.size()))
478 return data[handle].numBytes;
481 LogError(
"Invalid handle for object.");
490 if (name ==
data.name)
492 return data.numBytes;
497 LogError(
"Cannot find object " + name +
".");
504 if (0 <= handle && handle < static_cast<int>(
data.size()))
506 return data[handle].numBytes;
509 LogError(
"Invalid handle for object.");
518 if (name ==
data.name)
520 return data.numBytes;
525 LogError(
"Cannot find object " + name +
".");
532 if (0 <= handle && handle < static_cast<int>(
data.size()))
534 return data[handle].numBytes;
537 LogError(
"Invalid handle for object.");
546 if (name ==
data.name)
548 return data.numBytes;
553 LogError(
"Cannot find object " + name +
".");
560 if (0 <= handle && handle < static_cast<int>(
data.size()))
566 LogError(
"Invalid handle for object.");
575 if (name ==
data.name)
583 LogError(
"Cannot find object " + name +
".");
590 if (0 <= handle && handle < static_cast<int>(
data.size()))
596 LogError(
"Invalid handle for object.");
605 if (name ==
data.name)
613 LogError(
"Cannot find object " + name +
".");
617 #if defined(GTE_DEV_OPENGL) 618 bool Shader::GetStructuredBufferLayout(
int handle,
BufferLayout& layout)
const 621 if (0 <= handle && handle < static_cast<int>(
data.size()))
623 layout = mSBufferLayouts[handle];
627 LogError(
"Invalid handle for object.");
638 layout = mSBufferLayouts[handle];
659 LogError(
"Mismatch of buffer type.");
668 LogError(
"Invalid number of bytes.");
682 LogError(
"Mismatch of buffer type.");
691 LogError(
"Invalid number of bytes.");
705 LogError(
"Mismatch of buffer type.");
709 #if !defined(GTE_DEV_OPENGL) 716 LogError(
"Mismatch of GPU write flag.");
721 #if defined(GTE_DEV_OPENGL) 729 LogError(
"Mismatch of counter type.");
740 LogError(
"Mismatch of counter type.");
758 LogError(
"Mismatch of buffer type.");
764 LogError(
"Mismatch of GPU write flag.");
781 LogError(
"Mismatch of texture type.");
785 #if !defined(GTE_DEV_OPENGL) 792 LogError(
"Mismatch of GPU write flag.");
799 LogError(
"Mismatch of texture dimensions.");
818 LogError(
"Mismatch of texture type.");
822 #if !defined(GTE_DEV_OPENGL) 829 LogError(
"Mismatch of GPU write flag.");
836 LogError(
"Mismatch of texture dimensions.");
std::vector< HLSLStructuredBuffer > const & GetSBuffers() const
#define GL_INT_SAMPLER_1D_ARRAY
#define GL_INT_SAMPLER_2D_ARRAY
static int const shaderDataLookup
CounterType GetCounterType() const
std::vector< BufferLayout > mTBufferLayouts
#define GL_UNSIGNED_INT_SAMPLER_CUBE
#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY
static int const shaderDataLookup
#define GL_INT_IMAGE_1D_ARRAY
std::vector< BufferVariable > const & GetBufferVariables() const
#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY
std::vector< AtomicCounterBuffer > const & GetAtomicCounterBuffers() const
#define GL_UNSIGNED_INT_IMAGE_2D
std::vector< MemberLayout > BufferLayout
std::vector< HLSLTextureArray > const & GetTextureArrays() const
#define GL_UNSIGNED_INT_SAMPLER_2D
GLbitfield GLuint program
#define GL_UNSIGNED_INT_SAMPLER_1D
#define GL_UNSIGNED_INT_SAMPLER_3D
std::vector< Data > mData[NUM_LOOKUP_INDICES]
std::vector< DataBlock > const & GetBufferBlocks() const
#define GL_SAMPLER_CUBE_MAP_ARRAY
GLuint const GLchar * name
#define GL_UNSIGNED_INT_IMAGE_1D
#define GL_INT_IMAGE_2D_ARRAY
#define GL_INT_SAMPLER_CUBE
static int const shaderDataLookup
#define GL_INT_SAMPLER_CUBE_MAP_ARRAY
static int const shaderDataLookup
#define GL_IMAGE_CUBE_MAP_ARRAY
unsigned int GetStructuredBufferSize(int handle) const
unsigned int GetNumDimensions() const
int Get(std::string const &name) const
#define GL_INT_SAMPLER_1D
static int const shaderDataLookup
int GetShaderTypeIndex() const
std::vector< HLSLByteAddressBuffer > const & GetRBuffers() const
std::vector< HLSLSamplerState > const & GetSamplerStates() const
GLuint GLuint GLchar * counterName
#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY
unsigned int GetTextureBufferSize(int handle) const
#define GL_UNSIGNED_INT_IMAGE_CUBE
GLsizei const GLchar *const * string
#define LogError(message)
bool GetConstantBufferLayout(int handle, BufferLayout &layout) const
#define GL_INT_IMAGE_CUBE
std::vector< HLSLTexture > const & GetTextures() const
#define GL_INT_IMAGE_CUBE_MAP_ARRAY
static int const shaderDataLookup
unsigned int GetNumYThreads() const
bool GetTextureBufferLayout(int handle, BufferLayout &layout) const
unsigned int GetNumBytes() const
unsigned int GetConstantBufferSize(int handle) const
#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY
#define GL_SAMPLER_1D_ARRAY
#define GL_IMAGE_1D_ARRAY
unsigned int mNumXThreads
std::vector< HLSLConstantBuffer > const & GetCBuffers() const
bool IsValid(Data const &goal, ConstantBuffer *resource) const
unsigned int mNumYThreads
#define GL_UNSIGNED_INT_IMAGE_3D
std::vector< BufferLayout > mCBufferLayouts
void GetComputeShaderWorkGroupSize(GLint &numXThreads, GLint &numYThreads, GLint &numZThreads) const
std::vector< unsigned char > mCompiledCode
std::vector< HLSLTextureBuffer > const & GetTBuffers() const
unsigned int mNumZThreads
Data(GraphicsObjectType inType, std::string const &inName, int inBindPoint, int inNumBytes, unsigned int inExtra, bool inIsGpuWritable)
#define GL_IMAGE_2D_ARRAY
static int const shaderDataLookup
#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY
Shader(HLSLShader const &program)
#define GL_SAMPLER_2D_ARRAY
unsigned int GetNumZThreads() const
#define GL_INT_SAMPLER_2D
unsigned int GetNumXThreads() const
std::vector< DataBlock > const & GetUniformBlocks() const
std::vector< unsigned char > const & GetCompiledCode() const
#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY
GLint GLint GLsizei GLint GLenum GLenum type
#define GL_INT_SAMPLER_3D
std::vector< Uniform > const & GetUniforms() const