2020-08-07 17:00:28 +02:00
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* Copyright 2020, Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* \ingroup gpu
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "gpu_backend.hh"
|
|
|
|
|
2020-08-08 01:18:18 +02:00
|
|
|
#include "BLI_vector.hh"
|
|
|
|
|
2020-08-10 11:41:22 +02:00
|
|
|
#include "gl_batch.hh"
|
2020-08-07 17:00:28 +02:00
|
|
|
#include "gl_context.hh"
|
2020-08-08 15:24:52 +02:00
|
|
|
#include "gl_drawlist.hh"
|
2020-08-29 01:13:54 +02:00
|
|
|
#include "gl_framebuffer.hh"
|
2020-09-06 02:46:51 +02:00
|
|
|
#include "gl_index_buffer.hh"
|
2020-09-07 23:52:55 +02:00
|
|
|
#include "gl_query.hh"
|
2020-08-14 15:20:35 +02:00
|
|
|
#include "gl_shader.hh"
|
2020-09-02 01:25:32 +02:00
|
|
|
#include "gl_texture.hh"
|
2020-08-21 12:30:55 +02:00
|
|
|
#include "gl_uniform_buffer.hh"
|
2020-09-06 23:45:51 +02:00
|
|
|
#include "gl_vertex_buffer.hh"
|
2020-08-07 17:00:28 +02:00
|
|
|
|
2020-08-08 01:18:18 +02:00
|
|
|
namespace blender {
|
|
|
|
namespace gpu {
|
|
|
|
|
2020-08-07 17:00:28 +02:00
|
|
|
class GLBackend : public GPUBackend {
|
2020-08-08 01:18:18 +02:00
|
|
|
private:
|
|
|
|
GLSharedOrphanLists shared_orphan_list_;
|
|
|
|
|
2020-08-07 17:00:28 +02:00
|
|
|
public:
|
2020-09-05 17:31:53 +02:00
|
|
|
GLBackend()
|
|
|
|
{
|
2020-09-07 15:39:47 +02:00
|
|
|
/* platform_init needs to go first. */
|
|
|
|
GLBackend::platform_init();
|
|
|
|
|
2020-09-07 18:52:30 +02:00
|
|
|
GLBackend::capabilities_init();
|
2020-09-05 17:31:53 +02:00
|
|
|
GLTexture::samplers_init();
|
|
|
|
}
|
|
|
|
~GLBackend()
|
|
|
|
{
|
|
|
|
GLTexture::samplers_free();
|
2020-09-07 15:39:47 +02:00
|
|
|
|
|
|
|
GLBackend::platform_exit();
|
2020-09-05 17:31:53 +02:00
|
|
|
}
|
|
|
|
|
2020-08-21 12:30:55 +02:00
|
|
|
static GLBackend *get(void)
|
|
|
|
{
|
|
|
|
return static_cast<GLBackend *>(GPUBackend::get());
|
|
|
|
}
|
|
|
|
|
2020-09-05 17:31:53 +02:00
|
|
|
void samplers_update(void) override
|
|
|
|
{
|
|
|
|
GLTexture::samplers_update();
|
|
|
|
};
|
|
|
|
|
2020-09-06 03:30:00 +02:00
|
|
|
GPUContext *context_alloc(void *ghost_window) override
|
2020-08-07 17:00:28 +02:00
|
|
|
{
|
2020-08-08 01:18:18 +02:00
|
|
|
return new GLContext(ghost_window, shared_orphan_list_);
|
2020-08-07 17:00:28 +02:00
|
|
|
};
|
2020-08-08 01:18:18 +02:00
|
|
|
|
2020-09-06 03:30:00 +02:00
|
|
|
Batch *batch_alloc(void) override
|
2020-08-10 11:41:22 +02:00
|
|
|
{
|
|
|
|
return new GLBatch();
|
|
|
|
};
|
|
|
|
|
2020-09-06 03:30:00 +02:00
|
|
|
DrawList *drawlist_alloc(int list_length) override
|
2020-08-08 15:24:52 +02:00
|
|
|
{
|
|
|
|
return new GLDrawList(list_length);
|
|
|
|
};
|
|
|
|
|
2020-09-06 03:30:00 +02:00
|
|
|
FrameBuffer *framebuffer_alloc(const char *name) override
|
2020-08-29 01:13:54 +02:00
|
|
|
{
|
|
|
|
return new GLFrameBuffer(name);
|
|
|
|
};
|
|
|
|
|
2020-09-06 03:30:00 +02:00
|
|
|
IndexBuf *indexbuf_alloc(void) override
|
2020-09-06 02:46:51 +02:00
|
|
|
{
|
|
|
|
return new GLIndexBuf();
|
|
|
|
};
|
|
|
|
|
2020-09-07 23:52:55 +02:00
|
|
|
QueryPool *querypool_alloc(void) override
|
|
|
|
{
|
|
|
|
return new GLQueryPool();
|
|
|
|
};
|
|
|
|
|
2020-09-06 03:30:00 +02:00
|
|
|
Shader *shader_alloc(const char *name) override
|
2020-08-14 15:20:35 +02:00
|
|
|
{
|
|
|
|
return new GLShader(name);
|
|
|
|
};
|
|
|
|
|
2020-09-06 03:30:00 +02:00
|
|
|
Texture *texture_alloc(const char *name) override
|
2020-09-02 01:25:32 +02:00
|
|
|
{
|
|
|
|
return new GLTexture(name);
|
|
|
|
};
|
|
|
|
|
2020-09-06 03:30:00 +02:00
|
|
|
UniformBuf *uniformbuf_alloc(int size, const char *name) override
|
2020-08-21 12:30:55 +02:00
|
|
|
{
|
|
|
|
return new GLUniformBuf(size, name);
|
|
|
|
};
|
|
|
|
|
2020-09-06 23:45:51 +02:00
|
|
|
VertBuf *vertbuf_alloc(void) override
|
|
|
|
{
|
|
|
|
return new GLVertBuf();
|
|
|
|
};
|
|
|
|
|
2020-09-07 20:08:25 +02:00
|
|
|
GLSharedOrphanLists &shared_orphan_list_get(void)
|
2020-08-08 01:18:18 +02:00
|
|
|
{
|
2020-09-07 20:08:25 +02:00
|
|
|
return shared_orphan_list_;
|
|
|
|
};
|
2020-09-07 15:39:47 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
static void platform_init(void);
|
|
|
|
static void platform_exit(void);
|
2020-09-07 18:52:30 +02:00
|
|
|
|
|
|
|
static void capabilities_init(void);
|
2020-08-07 17:00:28 +02:00
|
|
|
};
|
2020-08-08 01:18:18 +02:00
|
|
|
|
|
|
|
} // namespace gpu
|
|
|
|
} // namespace blender
|