2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
* Copyright 2020 Blender Foundation. All rights reserved. */
|
2020-08-21 12:30:55 +02:00
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
|
* \ingroup gpu
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "gpu_uniform_buffer_private.hh"
|
|
|
|
|
|
|
|
|
|
#include "glew-mx.h"
|
|
|
|
|
|
|
|
|
|
namespace blender {
|
|
|
|
|
namespace gpu {
|
|
|
|
|
|
2020-08-21 14:14:56 +02:00
|
|
|
/**
|
|
|
|
|
* Implementation of Uniform Buffers using OpenGL.
|
2021-01-04 12:00:18 +11:00
|
|
|
*/
|
2020-08-21 12:30:55 +02:00
|
|
|
class GLUniformBuf : public UniformBuf {
|
|
|
|
|
private:
|
2020-09-01 02:41:29 +02:00
|
|
|
/** Slot to which this UBO is currently bound. -1 if not bound. */
|
2020-08-21 12:30:55 +02:00
|
|
|
int slot_ = -1;
|
2020-09-01 02:41:29 +02:00
|
|
|
/** OpenGL Object handle. */
|
2020-08-21 12:30:55 +02:00
|
|
|
GLuint ubo_id_ = 0;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
GLUniformBuf(size_t size, const char *name);
|
|
|
|
|
~GLUniformBuf();
|
|
|
|
|
|
|
|
|
|
void update(const void *data) override;
|
|
|
|
|
void bind(int slot) override;
|
2022-01-05 21:44:03 -05:00
|
|
|
void unbind() override;
|
2020-08-21 12:30:55 +02:00
|
|
|
|
|
|
|
|
private:
|
2022-01-05 21:44:03 -05:00
|
|
|
void init();
|
2020-08-21 12:30:55 +02:00
|
|
|
|
|
|
|
|
MEM_CXX_CLASS_ALLOC_FUNCS("GLUniformBuf");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace gpu
|
|
|
|
|
} // namespace blender
|