From 78cd4407dba8c2286904288a02ede582e6314610 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 15 Jan 2016 14:19:19 -0800 Subject: [PATCH] Don't pass binding manually, link named call correctly --- libraries/gpu/src/gpu/GLBackendShader.cpp | 4 ++-- libraries/gpu/src/gpu/GLBackendTransform.cpp | 10 ++++++++-- libraries/gpu/src/gpu/Stream.h | 1 - libraries/gpu/src/gpu/Transform.slh | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/libraries/gpu/src/gpu/GLBackendShader.cpp b/libraries/gpu/src/gpu/GLBackendShader.cpp index ece1a980d4..45bd67f70c 100755 --- a/libraries/gpu/src/gpu/GLBackendShader.cpp +++ b/libraries/gpu/src/gpu/GLBackendShader.cpp @@ -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; } diff --git a/libraries/gpu/src/gpu/GLBackendTransform.cpp b/libraries/gpu/src/gpu/GLBackendTransform.cpp index b2f2e414ff..33d60eaac5 100755 --- a/libraries/gpu/src/gpu/GLBackendTransform.cpp +++ b/libraries/gpu/src/gpu/GLBackendTransform.cpp @@ -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() { diff --git a/libraries/gpu/src/gpu/Stream.h b/libraries/gpu/src/gpu/Stream.h index faaac82b63..4214b99b74 100644 --- a/libraries/gpu/src/gpu/Stream.h +++ b/libraries/gpu/src/gpu/Stream.h @@ -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, }; diff --git a/libraries/gpu/src/gpu/Transform.slh b/libraries/gpu/src/gpu/Transform.slh index 692e345e0d..109af2835f 100644 --- a/libraries/gpu/src/gpu/Transform.slh +++ b/libraries/gpu/src/gpu/Transform.slh @@ -27,7 +27,7 @@ struct TransformCamera { in ivec2 _drawCallInfo; -layout(std430, binding=6) buffer transformObjectBuffer { +layout(std140) buffer transformObjectBuffer { TransformObject _object[]; }; TransformObject getTransformObject() {