Skip to content

Commit

Permalink
Merge pull request #467 from paroj/vaofix
Browse files Browse the repository at this point in the history
Vaofix
  • Loading branch information
paroj authored Jul 30, 2017
2 parents 58ea35f + f97ba30 commit 7c93765
Show file tree
Hide file tree
Showing 17 changed files with 139 additions and 392 deletions.
2 changes: 1 addition & 1 deletion OgreMain/include/OgreGpuProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace Ogre {
/** Enumerates the types of programs which can run on the GPU. */
enum GpuProgramType
{
GPT_VERTEX_PROGRAM,
GPT_VERTEX_PROGRAM = 0,
GPT_FRAGMENT_PROGRAM,
GPT_GEOMETRY_PROGRAM,
GPT_DOMAIN_PROGRAM,
Expand Down
3 changes: 0 additions & 3 deletions RenderSystems/GL3Plus/include/GLSL/OgreGLSLProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ namespace Ogre {
GLSLShader* getGeometryShader() const { return mGeometryShader; }
GLSLShader* getFragmentShader() const { return mFragmentShader; }
GLSLShader* getComputeShader() const { return mComputeShader; }
GL3PlusVertexArrayObject* getVertexArrayObject() { return mVertexArrayObject; }

protected:
/// Container of atomic counter uniform references that are active in the program object
Expand All @@ -105,8 +104,6 @@ namespace Ogre {
GLSLShader* mFragmentShader;
/// Linked compute shader.
GLSLShader* mComputeShader;
/// GL handle for the vertex array object
GL3PlusVertexArrayObject* mVertexArrayObject;

Ogre::String getCombinedName(void);
/// Get the the binary data of a program from the microcode cache
Expand Down
21 changes: 3 additions & 18 deletions RenderSystems/GL3Plus/include/GLSL/OgreGLSLProgramManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,14 @@ namespace Ogre {
with its data source. */
static bool findUniformDataSource(
const String& paramName,
const GpuConstantDefinitionMap* vertexConstantDefs,
const GpuConstantDefinitionMap* hullConstantDefs,
const GpuConstantDefinitionMap* domainConstantDefs,
const GpuConstantDefinitionMap* geometryConstantDefs,
const GpuConstantDefinitionMap* fragmentConstantDefs,
const GpuConstantDefinitionMap* computeConstantDefs,
const GpuConstantDefinitionMap* (&constantDefs)[6],
GLUniformReference& refToUpdate);
/** Find the data source definition for a given atomic counter
uniform name and reference. Return true if found and pair
the reference with its data source. */
static bool findAtomicCounterDataSource(
const String& paramName,
const GpuConstantDefinitionMap* vertexConstantDefs,
const GpuConstantDefinitionMap* hullConstantDefs,
const GpuConstantDefinitionMap* domainConstantDefs,
const GpuConstantDefinitionMap* geometryConstantDefs,
const GpuConstantDefinitionMap* fragmentConstantDefs,
const GpuConstantDefinitionMap* computeConstantDefs,
const GpuConstantDefinitionMap* (&constantDefs)[6],
GLAtomicCounterReference& refToUpdate);
public:

Expand All @@ -85,12 +75,7 @@ namespace Ogre {
*/
void extractUniformsFromProgram(
GLuint programObject,
const GpuConstantDefinitionMap* vertexConstantDefs,
const GpuConstantDefinitionMap* hullConstantDefs,
const GpuConstantDefinitionMap* domainConstantDefs,
const GpuConstantDefinitionMap* geometryConstantDefs,
const GpuConstantDefinitionMap* fragmentConstantDefs,
const GpuConstantDefinitionMap* computeConstantDefs,
const GpuConstantDefinitionMap* (&constantDefs)[6],
GLUniformReferenceList& uniformList,
GLAtomicCounterReferenceList& counterList,
GLUniformBufferList& uniformBufferList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ namespace Ogre {

UniformBufferList mShaderStorageBuffers;

VertexDeclaration* createVertexDeclarationImpl(void);
void destroyVertexDeclarationImpl(VertexDeclaration* decl);
public:
GL3PlusHardwareBufferManagerBase();
~GL3PlusHardwareBufferManagerBase();
Expand Down
12 changes: 2 additions & 10 deletions RenderSystems/GL3Plus/include/OgreGL3PlusRenderSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace Ogre {
*/
class GLSLShaderManager;
class GLSLShaderFactory;
class GLSLProgram;
class HardwareBufferManager;

/**
Expand Down Expand Up @@ -117,11 +118,6 @@ namespace Ogre {
/// Check if the GL system has already been initialised
bool mGLInitialised;

// local data members of _render that were moved here to improve performance
// (save allocations)
vector<GLuint>::type mRenderAttribsBound;
vector<GLuint>::type mRenderInstanceAttribsBound;

#if OGRE_NO_QUAD_BUFFER_STEREO == 0
/// @copydoc RenderSystem::setDrawBuffer
virtual bool setDrawBuffer(ColourBufferType colourBuffer);
Expand All @@ -140,10 +136,7 @@ namespace Ogre {
GLenum getBlendMode(SceneBlendFactor ogreBlend) const;

void bindVertexElementToGpu( const VertexElement &elem, HardwareVertexBufferSharedPtr vertexBuffer,
const size_t vertexStart,
vector<GLuint>::type &attribsBound,
vector<GLuint>::type &instanceAttribsBound,
bool updateVAO);
const size_t vertexStart, GLSLProgram* program, bool updateVAO);

public:
// Default constructor / destructor
Expand Down Expand Up @@ -278,7 +271,6 @@ namespace Ogre {

void setVertexDeclaration(VertexDeclaration* decl) {}

void setVertexDeclaration(VertexDeclaration* decl, VertexBufferBinding* binding) {}
/** See
RenderSystem.
*/
Expand Down
6 changes: 4 additions & 2 deletions RenderSystems/GL3Plus/include/OgreGL3PlusVertexArrayObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,19 @@ Copyright (c) 2000-2014 Torus Knot Software Ltd
namespace Ogre {

/** Specialisation of VertexDeclaration for OpenGL Vertex Array Object usage */
class GL3PlusVertexArrayObject
class GL3PlusVertexArrayObject : public VertexDeclaration
{
protected:
/// OpenGL id for the vertex array object
GLuint mVAO;
/// Is this VAO initialised?
bool mInitialised;

protected:
GL3PlusRenderSystem* mRenderSystem;

// TODO: cache used program attributes here and invalidate on change
vector<GLuint>::type mAttribsBound;
vector<GLuint>::type mInstanceAttribsBound;
public:
GL3PlusVertexArrayObject();
~GL3PlusVertexArrayObject();
Expand Down
58 changes: 19 additions & 39 deletions RenderSystems/GL3Plus/src/GLSL/OgreGLSLMonolithicProgram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ namespace Ogre {

void GLSLMonolithicProgram::compileAndLink()
{
mVertexArrayObject = new GL3PlusVertexArrayObject();
mVertexArrayObject->bind();

// Compile and attach Vertex Program
if (mVertexShader)
{
Expand Down Expand Up @@ -208,46 +205,29 @@ namespace Ogre {

void GLSLMonolithicProgram::buildGLUniformReferences(void)
{
if (!mUniformRefsBuilt)
if (mUniformRefsBuilt)
{
const GpuConstantDefinitionMap* vertParams = 0;
const GpuConstantDefinitionMap* hullParams = 0;
const GpuConstantDefinitionMap* domainParams = 0;
const GpuConstantDefinitionMap* fragParams = 0;
const GpuConstantDefinitionMap* geomParams = 0;
const GpuConstantDefinitionMap* computeParams = 0;
if (mVertexShader)
{
vertParams = &(mVertexShader->getConstantDefinitions().map);
}
if (mHullShader)
{
hullParams = &(mHullShader->getConstantDefinitions().map);
}
if (mDomainShader)
{
domainParams = &(mDomainShader->getConstantDefinitions().map);
}
if (mGeometryShader)
{
geomParams = &(mGeometryShader->getConstantDefinitions().map);
}
if (mFragmentShader)
{
fragParams = &(mFragmentShader->getConstantDefinitions().map);
}
if (mComputeShader)
{
computeParams = &(mComputeShader->getConstantDefinitions().map);
}
return;
}

// Do we know how many shared params there are yet? Or if there are any blocks defined?
GLSLMonolithicProgramManager::getSingleton().extractUniformsFromProgram(
mGLProgramHandle, vertParams, geomParams, fragParams, hullParams, domainParams, computeParams,
mGLUniformReferences, mGLAtomicCounterReferences, mGLUniformBufferReferences, mSharedParamsBufferMap, mGLCounterBufferReferences);
// order must match GpuProgramType
GLSLShader* shaders[6] = {getVertexShader(), mFragmentShader, mGeometryShader, mDomainShader, mHullShader, mComputeShader};
const GpuConstantDefinitionMap* params[6] = { NULL };

mUniformRefsBuilt = true;
for (int i = 0; i < 6; i++)
{
if (!shaders[i])
continue;

params[i] = &(shaders[i]->getConstantDefinitions().map);
}

// Do we know how many shared params there are yet? Or if there are any blocks defined?
GLSLMonolithicProgramManager::getSingleton().extractUniformsFromProgram(
mGLProgramHandle, params, mGLUniformReferences, mGLAtomicCounterReferences,
mGLUniformBufferReferences, mSharedParamsBufferMap, mGLCounterBufferReferences);

mUniformRefsBuilt = true;
}


Expand Down
4 changes: 0 additions & 4 deletions RenderSystems/GL3Plus/src/GLSL/OgreGLSLProgram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,13 @@ namespace Ogre {
, mGeometryShader(geometryShader)
, mFragmentShader(fragmentShader)
, mComputeShader(computeShader)
, mVertexArrayObject(0)
{
}


GLSLProgram::~GLSLProgram(void)
{
OGRE_CHECK_GL_ERROR(glDeleteProgram(mGLProgramHandle));

delete mVertexArrayObject;
mVertexArrayObject = 0;
}


Expand Down
Loading

0 comments on commit 7c93765

Please sign in to comment.