[core] rename VAO => VertexArray, FBO => Framebuffer
This commit is contained in:
committed by
John Firebaugh
parent
2b05776f97
commit
d1a84d9b51
@@ -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,
|
||||
|
||||
@@ -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<gl::UniqueVAO> vao;
|
||||
mbgl::optional<gl::UniqueVertexArray> vertexArray;
|
||||
|
||||
// For debug reasons, we're storing the bind information so that we can
|
||||
// detect errors and report
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<State<value::BindTexture>, 2> texture;
|
||||
State<value::BindBuffer<GL_ARRAY_BUFFER>> vertexBuffer;
|
||||
State<value::BindBuffer<GL_ELEMENT_ARRAY_BUFFER>> elementBuffer;
|
||||
State<value::BindVAO> vertexArrayObject;
|
||||
State<value::BindVertexArray> 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<GLuint> pooledTextures;
|
||||
|
||||
@@ -119,8 +119,8 @@ private:
|
||||
std::vector<GLuint> abandonedShaders;
|
||||
std::vector<GLuint> abandonedBuffers;
|
||||
std::vector<GLuint> abandonedTextures;
|
||||
std::vector<GLuint> abandonedVAOs;
|
||||
std::vector<GLuint> abandonedFBOs;
|
||||
std::vector<GLuint> abandonedVertexArrays;
|
||||
std::vector<GLuint> abandonedFramebuffers;
|
||||
};
|
||||
|
||||
} // namespace gl
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<GLuint, detail::ProgramD
|
||||
using UniqueShader = std_experimental::unique_resource<GLuint, detail::ShaderDeleter>;
|
||||
using UniqueBuffer = std_experimental::unique_resource<GLuint, detail::BufferDeleter>;
|
||||
using UniqueTexture = std_experimental::unique_resource<GLuint, detail::TextureDeleter>;
|
||||
using UniqueVAO = std_experimental::unique_resource<GLuint, detail::VAODeleter>;
|
||||
using UniqueFBO = std_experimental::unique_resource<GLuint, detail::FBODeleter>;
|
||||
using UniqueVertexArray = std_experimental::unique_resource<GLuint, detail::VertexArrayDeleter>;
|
||||
using UniqueFramebuffer = std_experimental::unique_resource<GLuint, detail::FramebufferDeleter>;
|
||||
|
||||
} // namespace gl
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 <GLenum target>
|
||||
const typename BindBuffer<target>::Type BindBuffer<target>::Default;
|
||||
|
||||
struct BindVAO {
|
||||
struct BindVertexArray {
|
||||
using Type = GLuint;
|
||||
static const constexpr Type Default = 0;
|
||||
static void Set(const Type& value) {
|
||||
|
||||
@@ -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<GLint>(size[0]), static_cast<GLint>(size[1]) } };
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
std::array<uint16_t, 2> getSize() const;
|
||||
|
||||
private:
|
||||
mbgl::optional<gl::UniqueFBO> fbo;
|
||||
mbgl::optional<gl::UniqueFramebuffer> framebuffer;
|
||||
Raster raster;
|
||||
};
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user