From d1a84d9b51a7145f9f7665805cf71050aac7bc63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Thu, 29 Sep 2016 11:45:28 +0200 Subject: [PATCH] [core] rename VAO => VertexArray, FBO => Framebuffer --- src/mbgl/geometry/vao.cpp | 6 +++--- src/mbgl/geometry/vao.hpp | 8 ++++---- src/mbgl/gl/context.cpp | 18 ++++++++++-------- src/mbgl/gl/context.hpp | 22 +++++++++++----------- src/mbgl/gl/object.cpp | 8 ++++---- src/mbgl/gl/object.hpp | 8 ++++---- src/mbgl/gl/value.cpp | 2 +- src/mbgl/gl/value.hpp | 8 ++++---- src/mbgl/util/offscreen_texture.cpp | 8 ++++---- src/mbgl/util/offscreen_texture.hpp | 2 +- test/gl/object.test.cpp | 2 +- 11 files changed, 47 insertions(+), 45 deletions(-) diff --git a/src/mbgl/geometry/vao.cpp b/src/mbgl/geometry/vao.cpp index 6a9512797..0f29d65cf 100644 --- a/src/mbgl/geometry/vao.cpp +++ b/src/mbgl/geometry/vao.cpp @@ -19,13 +19,13 @@ void VertexArrayObject::bindVertexArrayObject(gl::Context& context) { return; } - if (!vao) { - vao = context.createVAO(); + if (!vertexArray) { + vertexArray = context.createVertexArray(); context.vertexBuffer.setDirty(); context.elementBuffer.setDirty(); } - context.vertexArrayObject = *vao; + context.vertexArrayObject = *vertexArray; } void VertexArrayObject::verifyBinding(Shader& shader, GLuint vertexBuffer, GLuint elementsBuffer, diff --git a/src/mbgl/geometry/vao.hpp b/src/mbgl/geometry/vao.hpp index 2cb81481f..a9e69c938 100644 --- a/src/mbgl/geometry/vao.hpp +++ b/src/mbgl/geometry/vao.hpp @@ -24,7 +24,7 @@ public: if (bound_shader == 0) { vertexBuffer.bind(context); shader.bind(offset); - if (vao) { + if (vertexArray) { storeBinding(shader, vertexBuffer.getID(), 0, offset); } } else { @@ -43,7 +43,7 @@ public: vertexBuffer.bind(context); elementsBuffer.bind(context); shader.bind(offset); - if (vao) { + if (vertexArray) { storeBinding(shader, vertexBuffer.getID(), elementsBuffer.getID(), offset); } } else { @@ -52,7 +52,7 @@ public: } GLuint getID() const { - return *vao; + return *vertexArray; } private: @@ -60,7 +60,7 @@ private: void storeBinding(Shader &shader, GLuint vertexBuffer, GLuint elementsBuffer, GLbyte *offset); void verifyBinding(Shader &shader, GLuint vertexBuffer, GLuint elementsBuffer, GLbyte *offset); - mbgl::optional vao; + mbgl::optional vertexArray; // For debug reasons, we're storing the bind information so that we can // detect errors and report diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index 504e522da..e70affd0b 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -95,24 +95,26 @@ void Context::performCleanup() { abandonedTextures.clear(); } - if (!abandonedVAOs.empty()) { - for (const auto id : abandonedVAOs) { + if (!abandonedVertexArrays.empty()) { + for (const auto id : abandonedVertexArrays) { if (vertexArrayObject == id) { vertexArrayObject.setDirty(); } } - MBGL_CHECK_ERROR(gl::DeleteVertexArrays(int(abandonedVAOs.size()), abandonedVAOs.data())); - abandonedVAOs.clear(); + MBGL_CHECK_ERROR(gl::DeleteVertexArrays(int(abandonedVertexArrays.size()), + abandonedVertexArrays.data())); + abandonedVertexArrays.clear(); } - if (!abandonedFBOs.empty()) { - for (const auto id : abandonedFBOs) { + if (!abandonedFramebuffers.empty()) { + for (const auto id : abandonedFramebuffers) { if (bindFramebuffer == id) { bindFramebuffer.setDirty(); } } - MBGL_CHECK_ERROR(glDeleteFramebuffers(int(abandonedFBOs.size()), abandonedFBOs.data())); - abandonedFBOs.clear(); + MBGL_CHECK_ERROR( + glDeleteFramebuffers(int(abandonedFramebuffers.size()), abandonedFramebuffers.data())); + abandonedFramebuffers.clear(); } } diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp index 5aa55b6a2..cd42e02fc 100644 --- a/src/mbgl/gl/context.hpp +++ b/src/mbgl/gl/context.hpp @@ -42,16 +42,16 @@ public: return UniqueTexture { std::move(id), { this } }; } - UniqueVAO createVAO() { + UniqueVertexArray createVertexArray() { GLuint id = 0; MBGL_CHECK_ERROR(gl::GenVertexArrays(1, &id)); - return UniqueVAO { std::move(id), { this } }; + return UniqueVertexArray { std::move(id), { this } }; } - UniqueFBO createFBO() { + UniqueFramebuffer createFramebuffer() { GLuint id = 0; MBGL_CHECK_ERROR(glGenFramebuffers(1, &id)); - return UniqueFBO { std::move(id), { this } }; + return UniqueFramebuffer { std::move(id), { this } }; } // Actually remove the objects we marked as abandoned with the above methods. @@ -68,8 +68,8 @@ public: && abandonedShaders.empty() && abandonedBuffers.empty() && abandonedTextures.empty() - && abandonedVAOs.empty() - && abandonedFBOs.empty(); + && abandonedVertexArrays.empty() + && abandonedFramebuffers.empty(); } void resetState(); @@ -103,15 +103,15 @@ public: std::array, 2> texture; State> vertexBuffer; State> elementBuffer; - State vertexArrayObject; + State vertexArrayObject; private: friend detail::ProgramDeleter; friend detail::ShaderDeleter; friend detail::BufferDeleter; friend detail::TextureDeleter; - friend detail::VAODeleter; - friend detail::FBODeleter; + friend detail::VertexArrayDeleter; + friend detail::FramebufferDeleter; std::vector pooledTextures; @@ -119,8 +119,8 @@ private: std::vector abandonedShaders; std::vector abandonedBuffers; std::vector abandonedTextures; - std::vector abandonedVAOs; - std::vector abandonedFBOs; + std::vector abandonedVertexArrays; + std::vector abandonedFramebuffers; }; } // namespace gl diff --git a/src/mbgl/gl/object.cpp b/src/mbgl/gl/object.cpp index b9cabb8d9..90451da71 100644 --- a/src/mbgl/gl/object.cpp +++ b/src/mbgl/gl/object.cpp @@ -31,14 +31,14 @@ void TextureDeleter::operator()(GLuint id) const { } } -void VAODeleter::operator()(GLuint id) const { +void VertexArrayDeleter::operator()(GLuint id) const { assert(context); - context->abandonedVAOs.push_back(id); + context->abandonedVertexArrays.push_back(id); } -void FBODeleter::operator()(GLuint id) const { +void FramebufferDeleter::operator()(GLuint id) const { assert(context); - context->abandonedFBOs.push_back(id); + context->abandonedFramebuffers.push_back(id); } } // namespace detail diff --git a/src/mbgl/gl/object.hpp b/src/mbgl/gl/object.hpp index 44da13042..785e73e8a 100644 --- a/src/mbgl/gl/object.hpp +++ b/src/mbgl/gl/object.hpp @@ -31,12 +31,12 @@ struct TextureDeleter { void operator()(GLuint) const; }; -struct VAODeleter { +struct VertexArrayDeleter { Context* context; void operator()(GLuint) const; }; -struct FBODeleter { +struct FramebufferDeleter { Context* context; void operator()(GLuint) const; }; @@ -47,8 +47,8 @@ using UniqueProgram = std_experimental::unique_resource; using UniqueBuffer = std_experimental::unique_resource; using UniqueTexture = std_experimental::unique_resource; -using UniqueVAO = std_experimental::unique_resource; -using UniqueFBO = std_experimental::unique_resource; +using UniqueVertexArray = std_experimental::unique_resource; +using UniqueFramebuffer = std_experimental::unique_resource; } // namespace gl } // namespace mbgl diff --git a/src/mbgl/gl/value.cpp b/src/mbgl/gl/value.cpp index 7df3f4e3b..af316786f 100644 --- a/src/mbgl/gl/value.cpp +++ b/src/mbgl/gl/value.cpp @@ -23,7 +23,7 @@ const constexpr Program::Type Program::Default; const constexpr LineWidth::Type LineWidth::Default; const constexpr ActiveTexture::Type ActiveTexture::Default; const constexpr BindTexture::Type BindTexture::Default; -const constexpr BindVAO::Type BindVAO::Default; +const constexpr BindVertexArray::Type BindVertexArray::Default; #ifndef GL_ES_VERSION_2_0 const constexpr PixelZoom::Type PixelZoom::Default; diff --git a/src/mbgl/gl/value.hpp b/src/mbgl/gl/value.hpp index 6436228ed..bfa4dce77 100644 --- a/src/mbgl/gl/value.hpp +++ b/src/mbgl/gl/value.hpp @@ -278,9 +278,9 @@ struct BindFramebuffer { MBGL_CHECK_ERROR(glBindFramebuffer(GL_FRAMEBUFFER, value)); } static Type Get() { - Type activeFBO; - MBGL_CHECK_ERROR(glGetIntegerv(GL_FRAMEBUFFER_BINDING, &activeFBO)); - return activeFBO; + Type activeFramebuffer; + MBGL_CHECK_ERROR(glGetIntegerv(GL_FRAMEBUFFER_BINDING, &activeFramebuffer)); + return activeFramebuffer; } }; @@ -366,7 +366,7 @@ struct BindBuffer { template const typename BindBuffer::Type BindBuffer::Default; -struct BindVAO { +struct BindVertexArray { using Type = GLuint; static const constexpr Type Default = 0; static void Set(const Type& value) { diff --git a/src/mbgl/util/offscreen_texture.cpp b/src/mbgl/util/offscreen_texture.cpp index 602dd8092..e396aabef 100644 --- a/src/mbgl/util/offscreen_texture.cpp +++ b/src/mbgl/util/offscreen_texture.cpp @@ -14,9 +14,9 @@ void OffscreenTexture::bind(gl::Context& context, raster.upload(context, 0); } - if (!fbo) { - fbo = context.createFBO(); - context.bindFramebuffer = *fbo; + if (!framebuffer) { + framebuffer = context.createFramebuffer(); + context.bindFramebuffer = *framebuffer; MBGL_CHECK_ERROR(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, raster.getID(), 0)); @@ -48,7 +48,7 @@ void OffscreenTexture::bind(gl::Context& context, } } } else { - context.bindFramebuffer = *fbo; + context.bindFramebuffer = *framebuffer; } context.viewport = { { 0, 0, static_cast(size[0]), static_cast(size[1]) } }; diff --git a/src/mbgl/util/offscreen_texture.hpp b/src/mbgl/util/offscreen_texture.hpp index e0a61eb4a..2f5fa75d6 100644 --- a/src/mbgl/util/offscreen_texture.hpp +++ b/src/mbgl/util/offscreen_texture.hpp @@ -16,7 +16,7 @@ public: std::array getSize() const; private: - mbgl::optional fbo; + mbgl::optional framebuffer; Raster raster; }; diff --git a/test/gl/object.test.cpp b/test/gl/object.test.cpp index 2722669e8..ba3580080 100644 --- a/test/gl/object.test.cpp +++ b/test/gl/object.test.cpp @@ -103,7 +103,7 @@ TEST(GLObject, Store) { context.reset(); EXPECT_TRUE(context.empty()); - mbgl::gl::UniqueVAO vao = context.createVAO(); + mbgl::gl::UniqueVertexArray vao = context.createVertexArray(); EXPECT_NE(vao.get(), 0u); vao.reset(); EXPECT_FALSE(context.empty());