Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devel #3212

Merged
merged 3 commits into from
Sep 3, 2024
Merged

Devel #3212

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RenderSystems/GL3Plus/include/OgreGL3PlusHardwareBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
};
Expand Down
2 changes: 0 additions & 2 deletions RenderSystems/GL3Plus/include/OgreGL3PlusTextureManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ 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,
GL_GEOMETRY_SHADER_BIT,
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)
Expand Down
4 changes: 2 additions & 2 deletions RenderSystems/GL3Plus/src/OgreGL3PlusHardwareBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
16 changes: 11 additions & 5 deletions RenderSystems/GL3Plus/src/OgreGL3PlusRenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<GL3PlusHardwareBuffer>();
buf->setGLBufferBinding(it.first, GL_SHADER_STORAGE_BUFFER);
}
}

GLVertexArrayObject* vao =
static_cast<GLVertexArrayObject*>(op.vertexData->vertexDeclaration);
// Bind VAO (set of per-vertex attributes: position, normal, etc.).
Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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<GL3PlusTextureManager*>(mTextureManager)->bindImages();
}

void GL3PlusRenderSystem::beginProfileEvent( const String &eventName )
Expand Down
23 changes: 0 additions & 23 deletions RenderSystems/GL3Plus/src/OgreGL3PlusTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,29 +383,6 @@ namespace Ogre {

// TODO
// * add memory barrier
// * material script access (can have multiple instances for a single texture_unit)
// shader_access <binding point> [<access>] [<mipmap level>] [<texture array layer>] [<format>]
// 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));
Expand Down
29 changes: 0 additions & 29 deletions RenderSystems/GL3Plus/src/OgreGL3PlusTextureManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<GL3PlusTexture>();
// //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;
// // }
// }
}