mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 00:54:54 +00:00
Merge pull request #1477 from marauder2k9-torque/development
Fix UBO OpenGL
This commit is contained in:
commit
e557f5962b
2 changed files with 10 additions and 2 deletions
|
|
@ -323,9 +323,13 @@ GLuint GFXGLDevice::getDeviceBuffer(const GFXShaderConstDesc desc)
|
||||||
|
|
||||||
GLuint uboHandle;
|
GLuint uboHandle;
|
||||||
glGenBuffers(1, &uboHandle);
|
glGenBuffers(1, &uboHandle);
|
||||||
|
glBindBuffer(GL_UNIFORM_BUFFER, uboHandle);
|
||||||
|
glBufferData(GL_UNIFORM_BUFFER, desc.size, NULL, GL_DYNAMIC_DRAW); // allocate once
|
||||||
|
|
||||||
mDeviceBufferMap[name] = uboHandle;
|
mDeviceBufferMap[name] = uboHandle;
|
||||||
|
|
||||||
|
glBindBuffer(GL_UNIFORM_BUFFER, 0);
|
||||||
|
|
||||||
return uboHandle;
|
return uboHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -713,7 +713,8 @@ void GFXGLShader::initConstantDescs()
|
||||||
|
|
||||||
// fill out ubo desc.
|
// fill out ubo desc.
|
||||||
desc.name = String((char*)uboName);
|
desc.name = String((char*)uboName);
|
||||||
desc.bindPoint = uboBinding;
|
desc.bindPoint = uboBinding == 0 ? glGetUniformBlockIndex(mProgram, uboName) : uboBinding;
|
||||||
|
glUniformBlockBinding(mProgram, glGetUniformBlockIndex(mProgram, uboName), desc.bindPoint);
|
||||||
desc.size = uboSize;
|
desc.size = uboSize;
|
||||||
desc.constType = GFXSCT_ConstBuffer;
|
desc.constType = GFXSCT_ConstBuffer;
|
||||||
desc.samplerReg = -1;
|
desc.samplerReg = -1;
|
||||||
|
|
@ -888,7 +889,8 @@ void GFXGLShader::initHandles()
|
||||||
// Index element 1 of the name to skip the '$' we inserted earier.
|
// Index element 1 of the name to skip the '$' we inserted earier.
|
||||||
GLint loc = glGetUniformLocation(mProgram, &desc.name.c_str()[1]);
|
GLint loc = glGetUniformLocation(mProgram, &desc.name.c_str()[1]);
|
||||||
|
|
||||||
AssertFatal(loc != -1, avar("uniform %s in shader file Vert: (%s) Frag: (%s)", &desc.name.c_str()[1], mVertexFile.getFullPath().c_str(), mPixelFile.getFullPath().c_str()));
|
// The location for uniforms inside a UBO come back as -1.
|
||||||
|
// AssertFatal(loc != -1, avar("uniform %s in shader file Vert: (%s) Frag: (%s)", &desc.name.c_str()[1], mVertexFile.getFullPath().c_str(), mPixelFile.getFullPath().c_str()));
|
||||||
|
|
||||||
HandleMap::Iterator handle = mHandles.find(desc.name);
|
HandleMap::Iterator handle = mHandles.find(desc.name);
|
||||||
S32 sampler = -1;
|
S32 sampler = -1;
|
||||||
|
|
@ -907,6 +909,7 @@ void GFXGLShader::initHandles()
|
||||||
{
|
{
|
||||||
if (desc.bindPoint == -1)
|
if (desc.bindPoint == -1)
|
||||||
{
|
{
|
||||||
|
AssertFatal(loc != -1, avar("uniform %s in shader file Vert: (%s) Frag: (%s)", &desc.name.c_str()[1], mVertexFile.getFullPath().c_str(), mPixelFile.getFullPath().c_str()));
|
||||||
desc.bindPoint = loc;
|
desc.bindPoint = loc;
|
||||||
mHandles[desc.name]->mUBOUniform = false;
|
mHandles[desc.name]->mUBOUniform = false;
|
||||||
}
|
}
|
||||||
|
|
@ -921,6 +924,7 @@ void GFXGLShader::initHandles()
|
||||||
{
|
{
|
||||||
if (desc.bindPoint == -1)
|
if (desc.bindPoint == -1)
|
||||||
{
|
{
|
||||||
|
AssertFatal(loc != -1, avar("uniform %s in shader file Vert: (%s) Frag: (%s)", &desc.name.c_str()[1], mVertexFile.getFullPath().c_str(), mPixelFile.getFullPath().c_str()));
|
||||||
desc.bindPoint = loc;
|
desc.bindPoint = loc;
|
||||||
mHandles[desc.name] = new GFXGLShaderConstHandle(this, desc);
|
mHandles[desc.name] = new GFXGLShaderConstHandle(this, desc);
|
||||||
mHandles[desc.name]->mUBOUniform = false;
|
mHandles[desc.name]->mUBOUniform = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue