Don't pass binding manually, link named call correctly

This commit is contained in:
Atlante45 2016-01-15 14:19:19 -08:00
parent eb55e55367
commit 78cd4407db
4 changed files with 11 additions and 6 deletions

View file

@ -92,9 +92,9 @@ void makeBindings(GLBackend::GLShader* shader) {
// now assign the ubo binding, then DON't relink!
//Check for gpu specific uniform slotBindings
loc = glGetUniformBlockIndex(glprogram, "transformObjectBuffer");
loc = glGetProgramResourceIndex(glprogram, GL_SHADER_STORAGE_BLOCK, "transformObjectBuffer");
if (loc >= 0) {
glUniformBlockBinding(glprogram, loc, gpu::TRANSFORM_OBJECT_SLOT);
glShaderStorageBlockBinding(glprogram, loc, gpu::TRANSFORM_OBJECT_SLOT);
shader->_transformObjectSlot = gpu::TRANSFORM_OBJECT_SLOT;
}

View file

@ -183,8 +183,14 @@ void GLBackend::TransformStageState::update(size_t commandIndex, const StereoSta
void GLBackend::updateTransform() {
_transform.update(_commandIndex, _stereo);
auto& drawCallInfo = getDrawCallInfoBuffer()[_currentDraw];
glVertexAttribI2i(gpu::Stream::DRAW_CALL_INFO, drawCallInfo.index, drawCallInfo.unused);
auto& drawCallInfoBuffer = getDrawCallInfoBuffer();
if (_currentNamedCall.empty()) {
auto& drawCallInfo = drawCallInfoBuffer[_currentDraw];
glVertexAttribI2i(gpu::Stream::DRAW_CALL_INFO, (GLint)drawCallInfo.index, (GLint)drawCallInfo.unused);
} else {
glEnableVertexAttribArray(gpu::Stream::DRAW_CALL_INFO);
glVertexAttribIPointer(gpu::Stream::DRAW_CALL_INFO, 2, GL_SHORT, 4, drawCallInfoBuffer.data());
}
}
void GLBackend::resetTransformStage() {

View file

@ -40,7 +40,6 @@ public:
INSTANCE_SCALE = 8,
INSTANCE_TRANSLATE = 9,
DRAW_CALL_INFO = 15, // Reserve last input slot for draw call infos
NUM_INPUT_SLOTS = DRAW_CALL_INFO + 1,
};

View file

@ -27,7 +27,7 @@ struct TransformCamera {
in ivec2 _drawCallInfo;
layout(std430, binding=6) buffer transformObjectBuffer {
layout(std140) buffer transformObjectBuffer {
TransformObject _object[];
};
TransformObject getTransformObject() {