diff --git a/RenderSystems/GL3Plus/include/OgreGL3PlusHardwareBuffer.h b/RenderSystems/GL3Plus/include/OgreGL3PlusHardwareBuffer.h index dfc8fd20c96..43cad24384d 100644 --- a/RenderSystems/GL3Plus/include/OgreGL3PlusHardwareBuffer.h +++ b/RenderSystems/GL3Plus/include/OgreGL3PlusHardwareBuffer.h @@ -66,7 +66,7 @@ namespace Ogre { GLenum getTarget() const { return mTarget; } - void setGLBufferBinding(GLint binding); + void setGLBufferBinding(GLint binding, GLenum target = 0); GLint getGLBufferBinding(void) const { return mBindingPoint; } void bind() { setGLBufferBinding(mBindingPoint); } }; diff --git a/RenderSystems/GL3Plus/include/OgreGL3PlusTextureManager.h b/RenderSystems/GL3Plus/include/OgreGL3PlusTextureManager.h index 323f77e6ecc..0078cd6d462 100644 --- a/RenderSystems/GL3Plus/include/OgreGL3PlusTextureManager.h +++ b/RenderSystems/GL3Plus/include/OgreGL3PlusTextureManager.h @@ -61,8 +61,6 @@ namespace Ogre { /// @copydoc TextureManager::getNativeFormat PixelFormat getNativeFormat(TextureType ttype, PixelFormat format, int usage) override; - // void bindImages(); - /* TexturePtr createManual(const String & name, const String& group, */ /* TextureType texType, uint width, uint height, uint depth, int numMipmaps, */ /* PixelFormat format, int usage, ManualResourceLoader* loader, bool hwGamma, */ diff --git a/RenderSystems/GL3Plus/src/GLSL/src/OgreGLSLSeparableProgram.cpp b/RenderSystems/GL3Plus/src/GLSL/src/OgreGLSLSeparableProgram.cpp index 23783563a87..1d712c2f6fe 100644 --- a/RenderSystems/GL3Plus/src/GLSL/src/OgreGLSLSeparableProgram.cpp +++ b/RenderSystems/GL3Plus/src/GLSL/src/OgreGLSLSeparableProgram.cpp @@ -68,6 +68,7 @@ namespace Ogre } #define GL_MESH_SHADER_BIT_NV 0x00000040 + #define GL_TASK_SHADER_BIT_NV 0x00000080 GLenum ogre2gltype[GPT_COUNT] = { GL_VERTEX_SHADER_BIT, GL_FRAGMENT_SHADER_BIT, @@ -75,7 +76,8 @@ namespace Ogre GL_TESS_EVALUATION_SHADER_BIT, GL_TESS_CONTROL_SHADER_BIT, GL_MESH_SHADER_BIT_NV, - GL_COMPUTE_SHADER_BIT + GL_COMPUTE_SHADER_BIT, + GL_TASK_SHADER_BIT_NV }; for (auto s : mShaders) diff --git a/RenderSystems/GL3Plus/src/OgreGL3PlusHardwareBuffer.cpp b/RenderSystems/GL3Plus/src/OgreGL3PlusHardwareBuffer.cpp index c00174081a9..437a2606ec9 100644 --- a/RenderSystems/GL3Plus/src/OgreGL3PlusHardwareBuffer.cpp +++ b/RenderSystems/GL3Plus/src/OgreGL3PlusHardwareBuffer.cpp @@ -200,11 +200,11 @@ namespace Ogre { : (usage == HBU_GPU_ONLY) ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW; } - void GL3PlusHardwareBuffer::setGLBufferBinding(GLint binding) + void GL3PlusHardwareBuffer::setGLBufferBinding(GLint binding, GLenum target) { mBindingPoint = binding; // Attach the buffer to the binding index. - OGRE_CHECK_GL_ERROR(glBindBufferBase(mTarget, mBindingPoint, mBufferId)); + OGRE_CHECK_GL_ERROR(glBindBufferBase( target ? target : mTarget, mBindingPoint, mBufferId)); } } diff --git a/RenderSystems/GL3Plus/src/OgreGL3PlusRenderSystem.cpp b/RenderSystems/GL3Plus/src/OgreGL3PlusRenderSystem.cpp index 5117caac271..83e25029fae 100644 --- a/RenderSystems/GL3Plus/src/OgreGL3PlusRenderSystem.cpp +++ b/RenderSystems/GL3Plus/src/OgreGL3PlusRenderSystem.cpp @@ -1003,6 +1003,16 @@ namespace Ogre { LogManager::getSingleton().logError("Failed to create shader program."); } + bool hasMeshShader = mCurrentShader[GPT_MESH_PROGRAM] != 0; + if(hasMeshShader) + { + for(auto it : op.vertexData->vertexBufferBinding->getBindings()) + { + auto buf = it.second->_getImpl(); + buf->setGLBufferBinding(it.first, GL_SHADER_STORAGE_BUFFER); + } + } + GLVertexArrayObject* vao = static_cast(op.vertexData->vertexDeclaration); // Bind VAO (set of per-vertex attributes: position, normal, etc.). @@ -1110,7 +1120,7 @@ namespace Ogre { // OGRE_CHECK_GL_ERROR(glDrawArraysInstanced(GL_PATCHES, 0, primCount, 1)); } } - else if (mCurrentShader[GPT_MESH_PROGRAM]) + else if (hasMeshShader) { OgreAssert(op.indexData, "indexData required for mesh shader"); @@ -1640,10 +1650,6 @@ namespace Ogre { // Pass on parameters from params to program object uniforms. program->updateUniforms(params, mask, gptype); - - // FIXME This needs to be moved somewhere texture specific. - // Update image bindings for image load/store - // static_cast(mTextureManager)->bindImages(); } void GL3PlusRenderSystem::beginProfileEvent( const String &eventName ) diff --git a/RenderSystems/GL3Plus/src/OgreGL3PlusTexture.cpp b/RenderSystems/GL3Plus/src/OgreGL3PlusTexture.cpp index 6caa2f58be3..3a2392b1f05 100644 --- a/RenderSystems/GL3Plus/src/OgreGL3PlusTexture.cpp +++ b/RenderSystems/GL3Plus/src/OgreGL3PlusTexture.cpp @@ -383,29 +383,6 @@ namespace Ogre { // TODO // * add memory barrier - // * material script access (can have multiple instances for a single texture_unit) - // shader_access [] [] [] [] - // shader_access 2 read_write 0 0 PF_UINT32_R - // binding point - location to bind for shader access; for OpenGL this must be unique and is not related to texture binding point - // access - give the shader read, write, or read_write privileges [default read_write] - // mipmap level - texture mipmap level to use [default 0] - // texture array layer - layer of texture array to use: 'all', or layer number (if not layered, just use 0) [default 0] - // format - texture format to be read in shader; for OpenGL this may be different than bound texture format - not sure about DX11 [default same format as texture] - // Note that for OpenGL the shader access (image) binding point - // must be specified, it is NOT the same as the texture binding point, - // and it must be unique among textures in this pass. - // * enforce binding point uniqueness by checking against - // image binding point allocation list in GL3PlusTextureManager - // * generalize for other render systems by introducing vitual method in Texture - // for (image in mImages) - // { - // OGRE_CHECK_GL_ERROR( - // glBindImageTexture( - // mImageBind, mTextureID, - // mMipmapLevel, - // mLayered.find('all') != str::npos ? GL_TRUE : GL_FALSE, mLayer, - // mImageAccess (READ, WRITE, READ_WRITE), - // toImageFormat(mFormatInShader))); //GL_RGBA8)); //GL_R32UI)); GL_READ_WRITE if (mRenderSystem->hasMinGLVersion(4, 2) || mRenderSystem->checkExtension("GL_ARB_shader_image_load_store")) { OGRE_CHECK_GL_ERROR(glBindImageTexture(bindPoint, mTextureID, mipmapLevel, isArrayTexture, textureArrayIndex, GlAccess, GlFormat)); diff --git a/RenderSystems/GL3Plus/src/OgreGL3PlusTextureManager.cpp b/RenderSystems/GL3Plus/src/OgreGL3PlusTextureManager.cpp index 82d5488eea2..1ad9a8d8013 100644 --- a/RenderSystems/GL3Plus/src/OgreGL3PlusTextureManager.cpp +++ b/RenderSystems/GL3Plus/src/OgreGL3PlusTextureManager.cpp @@ -245,33 +245,4 @@ namespace Ogre { // Supported return format; } - - // void GL3PlusTextureManager::registerImage(TexturePtr texture) - // { - // mImages.push_back(texture); - // } - - //FIXME Should this become a standard Texture class feature? - // void GL3PlusTextureManager::bindImages() - // { - // //FIXME currently produces a GL_INVALID_OPERATION, so temporarily run once - // // static bool images_bound = false; - - // TexturePtrList::iterator texture = mImages.begin(); - // TexturePtrList::iterator end = mImages.end(); - - // // if (!images_bound && !mImages.empty()) { - // for (; texture != end; texture++) - // { - // //std::cout << "IMAGE LOAD/STORE" << std::endl; - // GL3PlusTexturePtr tex = texture->staticCast(); - // //TODO This needs to be redone so that: - // // * binding point (first parameter) and possibly other parameters come from shader - // // * simple conversion of shader format to GLenum format - // // * material scripts can create images - // //OGRE_CHECK_GL_ERROR(glBindImageTexture(0, tex->getGLID(), 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA8)); - // } - // // images_bound = true; - // // } - // } }