From c59c65b02b2c256a6cf92ff0fea3a9a3a0397f09 Mon Sep 17 00:00:00 2001 From: Francisco Zurita Date: Sat, 26 Jan 2019 14:33:31 -0500 Subject: [PATCH] Fix issues after rebase to latest master --- .../GLSL/glsl_CombinerProgramImpl.cpp | 2 +- .../glsl_CombinerProgramUniformFactory.cpp | 2 + ...pengl_TextureManipulationObjectFactory.cpp | 4 +- .../OpenGLContext/opengl_WrappedFunctions.cpp | 2 +- .../OpenGLContext/opengl_WrappedFunctions.h | 198 ++++++++++++++++-- src/Graphics/OpenGLContext/opengl_Wrapper.cpp | 47 ++++- src/Graphics/OpenGLContext/opengl_Wrapper.h | 7 +- 7 files changed, 232 insertions(+), 30 deletions(-) diff --git a/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramImpl.cpp b/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramImpl.cpp index 375e32eaf..0f3c58ced 100644 --- a/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramImpl.cpp +++ b/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramImpl.cpp @@ -114,7 +114,7 @@ bool CombinerProgramImpl::getBinaryForm(std::vector & _buffer) std::copy_n(binaryLengthData, sizeof(binaryLength), _buffer.begin() + offset); offset += sizeof(binaryLength); - std::copy_n(binary.data(), binaryLength, _buffer.begin() + offset); + std::copy_n(binary.begin(), binaryLength, _buffer.begin() + offset); return true; } diff --git a/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramUniformFactory.cpp b/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramUniformFactory.cpp index c2d6ac814..59f059bef 100644 --- a/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramUniformFactory.cpp +++ b/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramUniformFactory.cpp @@ -67,6 +67,7 @@ struct fv3Uniform { values.get()[0] = _pVal[0]; values.get()[1] = _pVal[1]; values.get()[2] = _pVal[2]; + FunctionWrapper::glUniform3fv(loc, 1, std::move(values)); } } @@ -85,6 +86,7 @@ struct fv4Uniform { values.get()[1] = _pVal[1]; values.get()[2] = _pVal[2]; values.get()[3] = _pVal[3]; + FunctionWrapper::glUniform4fv(loc, 1, std::move(values)); } } diff --git a/src/Graphics/OpenGLContext/opengl_TextureManipulationObjectFactory.cpp b/src/Graphics/OpenGLContext/opengl_TextureManipulationObjectFactory.cpp index 5537543f6..6b8f3ed07 100644 --- a/src/Graphics/OpenGLContext/opengl_TextureManipulationObjectFactory.cpp +++ b/src/Graphics/OpenGLContext/opengl_TextureManipulationObjectFactory.cpp @@ -224,8 +224,8 @@ namespace opengl { class Update2DTexSubImage : public Update2DTexture { public: - Update2DTexSubImage(CachedBindTexture* _bind) - : m_bind(_bind) {} + Update2DTexSubImage(const GLInfo & _glinfo, CachedBindTexture* _bind) + : m_glinfo(_glinfo), m_bind(_bind) {} void update2DTexture(const graphics::Context::UpdateTextureDataParams & _params) override { diff --git a/src/Graphics/OpenGLContext/opengl_WrappedFunctions.cpp b/src/Graphics/OpenGLContext/opengl_WrappedFunctions.cpp index 4e31f8e1b..c326c1783 100644 --- a/src/Graphics/OpenGLContext/opengl_WrappedFunctions.cpp +++ b/src/Graphics/OpenGLContext/opengl_WrappedFunctions.cpp @@ -2,7 +2,7 @@ namespace opengl { - std::unique_ptr GlVertexAttribPointerUnbufferedCommand::m_attribsData; + std::vector GlVertexAttribPointerUnbufferedCommand::m_attribsData; std::unordered_map>> GlMapBufferRangeReadAsyncCommand::m_data; std::mutex GlMapBufferRangeReadAsyncCommand::m_mapMutex; } diff --git a/src/Graphics/OpenGLContext/opengl_WrappedFunctions.h b/src/Graphics/OpenGLContext/opengl_WrappedFunctions.h index 7b34f458b..426afd547 100644 --- a/src/Graphics/OpenGLContext/opengl_WrappedFunctions.h +++ b/src/Graphics/OpenGLContext/opengl_WrappedFunctions.h @@ -470,6 +470,68 @@ namespace opengl { GLenum m_cap; }; + class GlDisableiCommand : public OpenGlCommand + { + public: + GlDisableiCommand(void) : + OpenGlCommand(false, false, "glDisablei") + { + } + + static std::shared_ptr get(GLenum target, GLuint index) + { + static int poolId = OpenGlCommandPool::get().getNextAvailablePool(); + auto ptr = getFromPool(poolId); + ptr->set(target, index); + return ptr; + } + + void commandToExecute(void) override + { + g_glDisablei(m_target, m_index); + } + private: + void set(GLenum target, GLuint index) + { + m_target = target; + m_index = index; + } + + GLenum m_target; + GLuint m_index; + }; + + class GlEnableiCommand : public OpenGlCommand + { + public: + GlEnableiCommand(void) : + OpenGlCommand(false, false, "glEnablei") + { + } + + static std::shared_ptr get(GLenum target, GLuint index) + { + static int poolId = OpenGlCommandPool::get().getNextAvailablePool(); + auto ptr = getFromPool(poolId); + ptr->set(target, index); + return ptr; + } + + void commandToExecute(void) override + { + g_glEnablei(m_target, m_index); + } + private: + void set(GLenum target, GLuint index) + { + m_target = target; + m_index = index; + } + + GLenum m_target; + GLuint m_index; + }; + class GlPolygonOffsetCommand : public OpenGlCommand { public: @@ -973,16 +1035,19 @@ namespace opengl { void commandToExecute(void) override { - if (m_attribsData == nullptr) { - m_attribsData = std::unique_ptr(new char[2*1024*1024]); + static bool attribsDataInitialized = false; + + if (!attribsDataInitialized) { + m_attribsData.resize(2*1024*1024, 0); + attribsDataInitialized = true; } - g_glVertexAttribPointer(m_index, m_size, m_type, m_normalized, m_stride, (const GLvoid *)(m_attribsData.get()+m_offset)); + g_glVertexAttribPointer(m_index, m_size, m_type, m_normalized, m_stride, (const GLvoid *)(m_attribsData.data()+m_offset)); } - static char* getDrawingData() + static std::vector& getDrawingData() { - return m_attribsData.get(); + return m_attribsData; } private: void set(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, @@ -1003,7 +1068,7 @@ namespace opengl { GLsizei m_stride; std::size_t m_offset; - static std::unique_ptr m_attribsData; + static std::vector m_attribsData; }; class GlDrawArraysUnbufferedCommand : public OpenGlCommand @@ -1024,8 +1089,8 @@ namespace opengl { void commandToExecute(void) override { - char* data = GlVertexAttribPointerUnbufferedCommand::getDrawingData(); - std::copy_n(m_data->data(), m_data->size(), data); + std::vector& drawingData = GlVertexAttribPointerUnbufferedCommand::getDrawingData(); + std::copy_n(m_data->begin(), m_data->size(), drawingData.begin()); g_glDrawArrays(m_mode, m_first, m_count); } private: @@ -1092,8 +1157,8 @@ namespace opengl { void commandToExecute(void) override { - char* data = GlVertexAttribPointerUnbufferedCommand::getDrawingData(); - std::copy_n(m_data->data(), m_data->size(), data); + std::vector& drawingData = GlVertexAttribPointerUnbufferedCommand::getDrawingData(); + std::copy_n(m_data->begin(), m_data->size(), drawingData.begin()); g_glDrawElements(m_mode, m_count, m_type, m_indices.get()); } private: @@ -1172,6 +1237,39 @@ namespace opengl { GLbitfield m_mask; }; + class GlClearBufferfvCommand : public OpenGlCommand + { + public: + GlClearBufferfvCommand(void) : + OpenGlCommand(false, false, "glClearBufferfv") + { + } + + static std::shared_ptr get(GLenum buffer, GLint drawbuffer, std::unique_ptr value) + { + static int poolId = OpenGlCommandPool::get().getNextAvailablePool(); + auto ptr = getFromPool(poolId); + ptr->set(buffer, drawbuffer, std::move(value)); + return ptr; + } + + void commandToExecute(void) override + { + g_glClearBufferfv(m_buffer, m_drawbuffer, m_value.get()); + } + private: + void set(GLenum buffer, GLint drawbuffer, std::unique_ptr value) + { + m_buffer = buffer; + m_drawbuffer = drawbuffer; + m_value = std::move(value); + } + + GLenum m_buffer; + GLint m_drawbuffer; + std::unique_ptr m_value; + }; + class GlGetFloatvCommand : public OpenGlCommand { public: @@ -3436,6 +3534,58 @@ namespace opengl { GLbitfield m_barriers; }; + class GlTextureBarrierCommand : public OpenGlCommand + { + public: + GlTextureBarrierCommand(void) : + OpenGlCommand(false, false, "glTextureBarrier") + { + } + + static std::shared_ptr get(void) + { + static int poolId = OpenGlCommandPool::get().getNextAvailablePool(); + auto ptr = getFromPool(poolId); + ptr->set(); + return ptr; + } + + void commandToExecute(void) override + { + g_glTextureBarrier(); + } + private: + void set(void) + { + } + }; + + class GlTextureBarrierNVCommand : public OpenGlCommand + { + public: + GlTextureBarrierNVCommand(void) : + OpenGlCommand(false, false, "glTextureBarrierNV") + { + } + + static std::shared_ptr get(void) + { + static int poolId = OpenGlCommandPool::get().getNextAvailablePool(); + auto ptr = getFromPool(poolId); + ptr->set(); + return ptr; + } + + void commandToExecute(void) override + { + g_glTextureBarrierNV(); + } + private: + void set(void) + { + } + }; + class GlGetStringiCommand : public OpenGlCommand { public: @@ -4396,32 +4546,34 @@ namespace opengl { GLint m_level; }; - class GlDrawElementsBaseVertexCommand : public OpenGlCommand + class GlDrawRangeElementsBaseVertexCommand : public OpenGlCommand { public: - GlDrawElementsBaseVertexCommand(void) : - OpenGlCommand(false, false, "glDrawElementsBaseVertex") + GlDrawRangeElementsBaseVertexCommand(void) : + OpenGlCommand(false, false, "glDrawRangeElementsBaseVertex") { } - static std::shared_ptr get(GLenum mode, GLsizei count, GLenum type, const char* indices, - GLint basevertex) + static std::shared_ptr get(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, + const u16* indices, GLint basevertex) { static int poolId = OpenGlCommandPool::get().getNextAvailablePool(); - auto ptr = getFromPool(poolId); - ptr->set(mode, count, type, indices, basevertex); + auto ptr = getFromPool(poolId); + ptr->set(mode, start, end, count, type, indices, basevertex); return ptr; } void commandToExecute(void) override { - g_glDrawElementsBaseVertex(m_mode, m_count, m_type, m_indices, m_basevertex); + g_glDrawRangeElementsBaseVertex(m_mode, m_start, m_end, m_count, m_type, m_indices, m_basevertex); } private: - void set(GLenum mode, GLsizei count, GLenum type, const char* indices, - GLint basevertex) + void set(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, + const u16* indices, GLint basevertex) { - m_mode = mode; + m_mode = mode; + m_start = start; + m_end = end; m_count = count; m_type = type; m_indices = indices; @@ -4429,9 +4581,11 @@ namespace opengl { } GLenum m_mode; + GLuint m_start; + GLuint m_end; GLsizei m_count; GLenum m_type; - const char* m_indices; + const u16* m_indices; GLint m_basevertex; }; diff --git a/src/Graphics/OpenGLContext/opengl_Wrapper.cpp b/src/Graphics/OpenGLContext/opengl_Wrapper.cpp index de92417b6..408b44dbc 100644 --- a/src/Graphics/OpenGLContext/opengl_Wrapper.cpp +++ b/src/Graphics/OpenGLContext/opengl_Wrapper.cpp @@ -113,6 +113,22 @@ namespace opengl { g_glEnable(cap); } + void FunctionWrapper::glDisablei(GLenum target, GLuint index) + { + if (m_threaded_wrapper) + executeCommand(GlDisableiCommand::get(target, index)); + else + g_glDisablei(target, index); + } + + void FunctionWrapper::glEnablei(GLenum target, GLuint index) + { + if (m_threaded_wrapper) + executeCommand(GlEnableiCommand::get(target, index)); + else + g_glEnablei(target, index); + } + void FunctionWrapper::glPolygonOffset(GLfloat factor, GLfloat units) { if (m_threaded_wrapper) @@ -252,6 +268,14 @@ namespace opengl { g_glClear(mask); } + void FunctionWrapper::glClearBufferfv(GLenum buffer, GLint drawbuffer, std::unique_ptr value) + { + if (m_threaded_wrapper) + executeCommand(GlClearBufferfvCommand::get(buffer, drawbuffer, std::move(value))); + else + g_glClearBufferfv(buffer, drawbuffer, value.get()); + } + void FunctionWrapper::glGetFloatv(GLenum pname, GLfloat* data) { if (m_threaded_wrapper) @@ -841,6 +865,22 @@ namespace opengl { g_glMemoryBarrier(barriers); } + void FunctionWrapper::glTextureBarrier(void) + { + if (m_threaded_wrapper) + executeCommand(GlTextureBarrierCommand::get()); + else + g_glTextureBarrier(); + } + + void FunctionWrapper::glTextureBarrierNV(void) + { + if (m_threaded_wrapper) + executeCommand(GlTextureBarrierNVCommand::get()); + else + g_glTextureBarrierNV(); + } + const GLubyte* FunctionWrapper::glGetStringi(GLenum name, GLuint index) { const GLubyte* returnValue; @@ -1037,12 +1077,13 @@ namespace opengl { g_glNamedFramebufferTexture(framebuffer, attachment, texture, level); } - void FunctionWrapper::glDrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, const char* indices, GLint basevertex) + void FunctionWrapper::glDrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, + const u16* indices, GLint basevertex) { if (m_threaded_wrapper) - executeCommand(GlDrawElementsBaseVertexCommand::get(mode, count, type, std::move(indices), basevertex)); + executeCommand(GlDrawRangeElementsBaseVertexCommand::get(mode, start, end, count, type, std::move(indices), basevertex)); else - g_glDrawElementsBaseVertex(mode, count, type, std::move(indices), basevertex); + g_glDrawRangeElementsBaseVertex(mode, start, end, count, type, std::move(indices), basevertex); } void FunctionWrapper::glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) diff --git a/src/Graphics/OpenGLContext/opengl_Wrapper.h b/src/Graphics/OpenGLContext/opengl_Wrapper.h index 9cc1e5272..a0b5110c5 100644 --- a/src/Graphics/OpenGLContext/opengl_Wrapper.h +++ b/src/Graphics/OpenGLContext/opengl_Wrapper.h @@ -42,6 +42,8 @@ namespace opengl { static void glDepthMask(GLboolean flag); static void glDisable(GLenum cap); static void glEnable(GLenum cap); + static void glDisablei(GLenum target, GLuint index); + static void glEnablei(GLenum target, GLuint index); static void glPolygonOffset(GLfloat factor, GLfloat units); static void glScissor(GLint x, GLint y, GLsizei width, GLsizei height); @@ -66,6 +68,7 @@ namespace opengl { static void glDrawElementsUnbuffered(GLenum mode, GLsizei count, GLenum type, std::unique_ptr indices, std::unique_ptr> data); static void glLineWidth(GLfloat width); static void glClear(GLbitfield mask); + static void glClearBufferfv(GLenum buffer, GLint drawbuffer, std::unique_ptr value); static void glGetFloatv(GLenum pname, GLfloat* data); static void glDeleteTextures(GLsizei n, std::unique_ptr textures); static void glGenTextures(GLsizei n, GLuint* textures); @@ -142,6 +145,8 @@ namespace opengl { static void glDeleteBuffers(GLsizei n, std::unique_ptr buffers); static void glBindImageTexture(GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); static void glMemoryBarrier(GLbitfield barriers); + static void glTextureBarrier(void); + static void glTextureBarrierNV(void); static const GLubyte* glGetStringi(GLenum name, GLuint index); static void glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, std::unique_ptr attachments); template @@ -176,7 +181,7 @@ namespace opengl { static void glCreateBuffers(GLsizei n, GLuint* buffers); static void glCreateFramebuffers(GLsizei n, GLuint* framebuffers); static void glNamedFramebufferTexture(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); - static void glDrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, const char* indices, GLint basevertex); + static void glDrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const u16* indices, GLint basevertex); static void glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length); static void glFinish(void);