2017-02-07 11:20:15 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2016, Blender Foundation.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Institute
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file DRW_render.h
|
|
|
|
* \ingroup draw
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* This is the Render Functions used by Realtime engines to draw with OpenGL */
|
|
|
|
|
|
|
|
#ifndef __DRW_RENDER_H__
|
|
|
|
#define __DRW_RENDER_H__
|
|
|
|
|
|
|
|
#include "BLI_listbase.h"
|
|
|
|
#include "BLI_math_matrix.h"
|
|
|
|
#include "BLI_math_vector.h"
|
|
|
|
#include "BLI_string.h"
|
|
|
|
|
2017-11-14 17:00:10 +11:00
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_layer.h"
|
|
|
|
#include "BKE_material.h"
|
|
|
|
#include "BKE_scene.h"
|
|
|
|
|
2017-02-07 11:20:15 +01:00
|
|
|
#include "BLT_translation.h"
|
|
|
|
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_lamp_types.h"
|
|
|
|
#include "DNA_material_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
2017-03-08 20:00:09 +01:00
|
|
|
#include "draw_common.h"
|
2017-02-07 11:20:15 +01:00
|
|
|
#include "draw_cache.h"
|
2017-02-14 17:48:16 +01:00
|
|
|
#include "draw_view.h"
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-07-26 19:57:46 +02:00
|
|
|
#include "draw_manager_profiling.h"
|
|
|
|
|
2017-02-07 11:20:15 +01:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "RE_engine.h"
|
|
|
|
|
2018-02-23 13:26:28 -03:00
|
|
|
struct rcti;
|
2017-02-14 17:48:16 +01:00
|
|
|
struct bContext;
|
2017-02-07 11:20:15 +01:00
|
|
|
struct GPUFrameBuffer;
|
|
|
|
struct GPUShader;
|
2017-04-27 22:27:09 +02:00
|
|
|
struct GPUMaterial;
|
2017-02-07 11:20:15 +01:00
|
|
|
struct GPUTexture;
|
|
|
|
struct GPUUniformBuffer;
|
|
|
|
struct Object;
|
2017-06-19 20:18:04 +10:00
|
|
|
struct Gwn_Batch;
|
2017-03-08 20:00:09 +01:00
|
|
|
struct DefaultFramebufferList;
|
|
|
|
struct DefaultTextureList;
|
2017-04-28 04:33:58 +10:00
|
|
|
struct DRWTextStore;
|
2017-04-10 12:06:17 +02:00
|
|
|
struct LampEngineData;
|
|
|
|
struct RenderEngineType;
|
2017-04-12 19:49:19 +10:00
|
|
|
struct ViewportEngineData;
|
|
|
|
struct ViewportEngineData_Info;
|
2017-02-07 11:20:15 +01:00
|
|
|
|
|
|
|
typedef struct DRWUniform DRWUniform;
|
|
|
|
typedef struct DRWInterface DRWInterface;
|
|
|
|
typedef struct DRWPass DRWPass;
|
|
|
|
typedef struct DRWShadingGroup DRWShadingGroup;
|
|
|
|
|
2017-05-03 05:20:58 +10:00
|
|
|
/* declare members as empty (unused) */
|
|
|
|
typedef char DRWViewportEmptyList;
|
|
|
|
|
|
|
|
#define DRW_VIEWPORT_LIST_SIZE(list) \
|
|
|
|
(sizeof(list) == sizeof(DRWViewportEmptyList) ? 0 : ((sizeof(list)) / sizeof(void *)))
|
2017-04-12 19:49:19 +10:00
|
|
|
|
|
|
|
/* Unused members must be either pass list or 'char *' when not usd. */
|
|
|
|
#define DRW_VIEWPORT_DATA_SIZE(ty) { \
|
|
|
|
DRW_VIEWPORT_LIST_SIZE(*(((ty *)NULL)->fbl)), \
|
|
|
|
DRW_VIEWPORT_LIST_SIZE(*(((ty *)NULL)->txl)), \
|
|
|
|
DRW_VIEWPORT_LIST_SIZE(*(((ty *)NULL)->psl)), \
|
|
|
|
DRW_VIEWPORT_LIST_SIZE(*(((ty *)NULL)->stl)) \
|
|
|
|
}
|
|
|
|
|
2017-09-23 20:47:42 +02:00
|
|
|
/* Use of multisample framebuffers. */
|
|
|
|
#define MULTISAMPLE_SYNC_ENABLE(dfbl) { \
|
|
|
|
if (dfbl->multisample_fb != NULL) { \
|
|
|
|
DRW_stats_query_start("Multisample Blit"); \
|
2017-11-10 23:36:05 +01:00
|
|
|
DRW_framebuffer_blit(dfbl->default_fb, dfbl->multisample_fb, false, false); \
|
|
|
|
DRW_framebuffer_blit(dfbl->default_fb, dfbl->multisample_fb, true, false); \
|
2017-09-23 20:47:42 +02:00
|
|
|
DRW_framebuffer_bind(dfbl->multisample_fb); \
|
|
|
|
DRW_stats_query_end(); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MULTISAMPLE_SYNC_DISABLE(dfbl) { \
|
|
|
|
if (dfbl->multisample_fb != NULL) { \
|
|
|
|
DRW_stats_query_start("Multisample Resolve"); \
|
2017-11-10 23:36:05 +01:00
|
|
|
DRW_framebuffer_blit(dfbl->multisample_fb, dfbl->default_fb, false, false); \
|
|
|
|
DRW_framebuffer_blit(dfbl->multisample_fb, dfbl->default_fb, true, false); \
|
2017-09-23 20:47:42 +02:00
|
|
|
DRW_framebuffer_bind(dfbl->default_fb); \
|
|
|
|
DRW_stats_query_end(); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-12 19:49:19 +10:00
|
|
|
typedef struct DrawEngineDataSize {
|
|
|
|
int fbl_len;
|
|
|
|
int txl_len;
|
|
|
|
int psl_len;
|
|
|
|
int stl_len;
|
|
|
|
} DrawEngineDataSize;
|
|
|
|
|
2017-03-08 20:00:09 +01:00
|
|
|
typedef struct DrawEngineType {
|
|
|
|
struct DrawEngineType *next, *prev;
|
|
|
|
|
|
|
|
char idname[32];
|
|
|
|
|
2017-04-12 19:49:19 +10:00
|
|
|
const DrawEngineDataSize *vedata_size;
|
|
|
|
|
2017-03-26 19:10:53 +02:00
|
|
|
void (*engine_init)(void *vedata);
|
2017-03-08 20:00:09 +01:00
|
|
|
void (*engine_free)(void);
|
|
|
|
|
2017-03-26 19:10:53 +02:00
|
|
|
void (*cache_init)(void *vedata);
|
|
|
|
void (*cache_populate)(void *vedata, struct Object *ob);
|
|
|
|
void (*cache_finish)(void *vedata);
|
2017-03-08 20:00:09 +01:00
|
|
|
|
2017-03-26 19:10:53 +02:00
|
|
|
void (*draw_background)(void *vedata);
|
|
|
|
void (*draw_scene)(void *vedata);
|
2017-09-25 20:07:02 +02:00
|
|
|
|
|
|
|
void (*view_update)(void *vedata);
|
2017-11-28 17:05:52 +01:00
|
|
|
void (*id_update)(void *vedata, struct ID *id);
|
2018-01-29 14:56:16 +01:00
|
|
|
|
2018-02-23 13:26:28 -03:00
|
|
|
void (*render_to_image)(void *vedata, struct RenderEngine *engine, struct RenderLayer *layer, const struct rcti *rect);
|
2017-03-08 20:00:09 +01:00
|
|
|
} DrawEngineType;
|
|
|
|
|
|
|
|
#ifndef __DRW_ENGINE_H__
|
|
|
|
/* Buffer and textures used by the viewport by default */
|
|
|
|
typedef struct DefaultFramebufferList {
|
|
|
|
struct GPUFrameBuffer *default_fb;
|
2017-09-23 20:47:42 +02:00
|
|
|
struct GPUFrameBuffer *multisample_fb;
|
2017-03-08 20:00:09 +01:00
|
|
|
} DefaultFramebufferList;
|
|
|
|
|
|
|
|
typedef struct DefaultTextureList {
|
|
|
|
struct GPUTexture *color;
|
|
|
|
struct GPUTexture *depth;
|
2017-09-23 20:47:42 +02:00
|
|
|
struct GPUTexture *multisample_color;
|
|
|
|
struct GPUTexture *multisample_depth;
|
2017-03-08 20:00:09 +01:00
|
|
|
} DefaultTextureList;
|
|
|
|
#endif
|
|
|
|
|
2017-02-07 11:20:15 +01:00
|
|
|
/* Textures */
|
2018-01-13 17:14:01 +01:00
|
|
|
/* NOTE naming in this struct is broken.
|
|
|
|
* There should either be suffixes for Normalized int formats or float formats.
|
|
|
|
* Right now every 8bit texture is Normalized int and others are Floating point. */
|
2017-02-07 11:20:15 +01:00
|
|
|
typedef enum {
|
|
|
|
DRW_TEX_RGBA_8,
|
|
|
|
DRW_TEX_RGBA_16,
|
|
|
|
DRW_TEX_RGBA_32,
|
2017-05-16 20:18:57 +02:00
|
|
|
DRW_TEX_RGB_11_11_10,
|
2017-02-07 11:20:15 +01:00
|
|
|
DRW_TEX_RGB_8,
|
|
|
|
DRW_TEX_RGB_16,
|
|
|
|
DRW_TEX_RGB_32,
|
|
|
|
DRW_TEX_RG_8,
|
|
|
|
DRW_TEX_RG_16,
|
2018-01-13 17:14:01 +01:00
|
|
|
DRW_TEX_RG_16I,
|
2017-02-07 11:20:15 +01:00
|
|
|
DRW_TEX_RG_32,
|
|
|
|
DRW_TEX_R_8,
|
|
|
|
DRW_TEX_R_16,
|
|
|
|
DRW_TEX_R_32,
|
|
|
|
DRW_TEX_DEPTH_16,
|
|
|
|
DRW_TEX_DEPTH_24,
|
2017-11-13 23:33:06 +01:00
|
|
|
DRW_TEX_DEPTH_24_STENCIL_8,
|
2017-02-07 11:20:15 +01:00
|
|
|
DRW_TEX_DEPTH_32,
|
|
|
|
} DRWTextureFormat;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
DRW_TEX_FILTER = (1 << 0),
|
|
|
|
DRW_TEX_WRAP = (1 << 1),
|
|
|
|
DRW_TEX_COMPARE = (1 << 2),
|
2017-04-18 12:50:09 +02:00
|
|
|
DRW_TEX_MIPMAP = (1 << 3),
|
2017-05-16 03:03:58 +02:00
|
|
|
DRW_TEX_TEMP = (1 << 4),
|
2017-02-07 11:20:15 +01:00
|
|
|
} DRWTextureFlag;
|
|
|
|
|
|
|
|
struct GPUTexture *DRW_texture_create_1D(
|
2017-02-22 18:52:07 +01:00
|
|
|
int w, DRWTextureFormat format, DRWTextureFlag flags, const float *fpixels);
|
2017-02-07 11:20:15 +01:00
|
|
|
struct GPUTexture *DRW_texture_create_2D(
|
2017-02-22 18:52:07 +01:00
|
|
|
int w, int h, DRWTextureFormat format, DRWTextureFlag flags, const float *fpixels);
|
2017-02-07 11:20:15 +01:00
|
|
|
struct GPUTexture *DRW_texture_create_2D_array(
|
2017-04-04 14:48:42 +02:00
|
|
|
int w, int h, int d, DRWTextureFormat format, DRWTextureFlag flags, const float *fpixels);
|
2017-10-24 02:03:58 +02:00
|
|
|
struct GPUTexture *DRW_texture_create_3D(
|
|
|
|
int w, int h, int d, DRWTextureFormat format, DRWTextureFlag flags, const float *fpixels);
|
2017-04-04 14:48:42 +02:00
|
|
|
struct GPUTexture *DRW_texture_create_cube(
|
|
|
|
int w, DRWTextureFormat format, DRWTextureFlag flags, const float *fpixels);
|
2017-04-18 12:50:09 +02:00
|
|
|
void DRW_texture_generate_mipmaps(struct GPUTexture *tex);
|
2017-08-22 10:22:11 +02:00
|
|
|
void DRW_texture_update(struct GPUTexture *tex, const float *pixels);
|
2017-02-07 11:20:15 +01:00
|
|
|
void DRW_texture_free(struct GPUTexture *tex);
|
2017-04-13 13:30:53 +10:00
|
|
|
#define DRW_TEXTURE_FREE_SAFE(tex) do { \
|
|
|
|
if (tex != NULL) { \
|
|
|
|
DRW_texture_free(tex); \
|
|
|
|
tex = NULL; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2017-02-07 11:20:15 +01:00
|
|
|
|
|
|
|
/* UBOs */
|
|
|
|
struct GPUUniformBuffer *DRW_uniformbuffer_create(int size, const void *data);
|
|
|
|
void DRW_uniformbuffer_update(struct GPUUniformBuffer *ubo, const void *data);
|
|
|
|
void DRW_uniformbuffer_free(struct GPUUniformBuffer *ubo);
|
2017-05-30 22:29:20 +02:00
|
|
|
#define DRW_UBO_FREE_SAFE(ubo) do { \
|
|
|
|
if (ubo != NULL) { \
|
|
|
|
DRW_uniformbuffer_free(ubo); \
|
|
|
|
ubo = NULL; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2017-02-07 11:20:15 +01:00
|
|
|
|
|
|
|
/* Buffers */
|
|
|
|
#define MAX_FBO_TEX 5
|
|
|
|
|
|
|
|
typedef struct DRWFboTexture {
|
|
|
|
struct GPUTexture **tex;
|
|
|
|
int format;
|
2017-04-05 12:57:32 +02:00
|
|
|
DRWTextureFlag flag;
|
2017-02-07 11:20:15 +01:00
|
|
|
} DRWFboTexture;
|
|
|
|
|
2018-01-17 13:47:47 +01:00
|
|
|
struct GPUFrameBuffer *DRW_framebuffer_create(void);
|
2017-04-22 16:11:12 +10:00
|
|
|
void DRW_framebuffer_init(
|
2017-05-16 03:03:58 +02:00
|
|
|
struct GPUFrameBuffer **fb, void *engine_type, int width, int height,
|
2017-04-22 16:11:12 +10:00
|
|
|
DRWFboTexture textures[MAX_FBO_TEX], int textures_len);
|
2017-02-07 11:20:15 +01:00
|
|
|
void DRW_framebuffer_bind(struct GPUFrameBuffer *fb);
|
2017-03-18 01:55:41 +01:00
|
|
|
void DRW_framebuffer_clear(bool color, bool depth, bool stencil, float clear_col[4], float clear_depth);
|
2017-04-18 21:02:02 +02:00
|
|
|
void DRW_framebuffer_read_data(int x, int y, int w, int h, int channels, int slot, float *data);
|
2018-01-29 21:59:34 +01:00
|
|
|
void DRW_framebuffer_read_depth(int x, int y, int w, int h, float *data);
|
2017-04-18 12:50:09 +02:00
|
|
|
void DRW_framebuffer_texture_attach(struct GPUFrameBuffer *fb, struct GPUTexture *tex, int slot, int mip);
|
2017-06-16 13:25:22 +02:00
|
|
|
void DRW_framebuffer_texture_layer_attach(struct GPUFrameBuffer *fb, struct GPUTexture *tex, int slot, int layer, int mip);
|
2017-06-08 20:19:42 +02:00
|
|
|
void DRW_framebuffer_cubeface_attach(struct GPUFrameBuffer *fb, struct GPUTexture *tex, int slot, int face, int mip);
|
2017-02-07 11:20:15 +01:00
|
|
|
void DRW_framebuffer_texture_detach(struct GPUTexture *tex);
|
2017-11-10 23:36:05 +01:00
|
|
|
void DRW_framebuffer_blit(struct GPUFrameBuffer *fb_read, struct GPUFrameBuffer *fb_write, bool depth, bool stencil);
|
2017-06-22 02:01:58 +02:00
|
|
|
void DRW_framebuffer_recursive_downsample(
|
|
|
|
struct GPUFrameBuffer *fb, struct GPUTexture *tex, int num_iter,
|
|
|
|
void (*callback)(void *userData, int level), void *userData);
|
2017-06-13 17:39:39 +02:00
|
|
|
void DRW_framebuffer_viewport_size(struct GPUFrameBuffer *fb_read, int x, int y, int w, int h);
|
2017-05-30 22:29:20 +02:00
|
|
|
void DRW_framebuffer_free(struct GPUFrameBuffer *fb);
|
|
|
|
#define DRW_FRAMEBUFFER_FREE_SAFE(fb) do { \
|
|
|
|
if (fb != NULL) { \
|
|
|
|
DRW_framebuffer_free(fb); \
|
|
|
|
fb = NULL; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2017-04-04 14:48:42 +02:00
|
|
|
|
2017-05-11 16:20:10 +02:00
|
|
|
void DRW_transform_to_display(struct GPUTexture *tex);
|
|
|
|
|
2017-02-07 11:20:15 +01:00
|
|
|
/* Shaders */
|
2017-04-22 16:11:12 +10:00
|
|
|
struct GPUShader *DRW_shader_create(
|
|
|
|
const char *vert, const char *geom, const char *frag, const char *defines);
|
|
|
|
struct GPUShader *DRW_shader_create_with_lib(
|
2018-01-17 20:35:06 +11:00
|
|
|
const char *vert, const char *geom, const char *frag, const char *lib, const char *defines);
|
2017-02-07 11:20:15 +01:00
|
|
|
struct GPUShader *DRW_shader_create_2D(const char *frag, const char *defines);
|
|
|
|
struct GPUShader *DRW_shader_create_3D(const char *frag, const char *defines);
|
2017-03-16 23:58:30 +01:00
|
|
|
struct GPUShader *DRW_shader_create_fullscreen(const char *frag, const char *defines);
|
2017-02-07 11:20:15 +01:00
|
|
|
struct GPUShader *DRW_shader_create_3D_depth_only(void);
|
|
|
|
void DRW_shader_free(struct GPUShader *shader);
|
2017-04-13 13:30:53 +10:00
|
|
|
#define DRW_SHADER_FREE_SAFE(shader) do { \
|
|
|
|
if (shader != NULL) { \
|
|
|
|
DRW_shader_free(shader); \
|
|
|
|
shader = NULL; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2017-02-07 11:20:15 +01:00
|
|
|
|
|
|
|
/* Batches */
|
|
|
|
|
|
|
|
typedef enum {
|
2017-03-03 02:48:34 +01:00
|
|
|
DRW_STATE_WRITE_DEPTH = (1 << 0),
|
|
|
|
DRW_STATE_WRITE_COLOR = (1 << 1),
|
|
|
|
DRW_STATE_DEPTH_LESS = (1 << 2),
|
|
|
|
DRW_STATE_DEPTH_EQUAL = (1 << 3),
|
|
|
|
DRW_STATE_DEPTH_GREATER = (1 << 4),
|
2017-06-22 18:53:36 +02:00
|
|
|
DRW_STATE_DEPTH_ALWAYS = (1 << 5),
|
|
|
|
DRW_STATE_CULL_BACK = (1 << 6),
|
|
|
|
DRW_STATE_CULL_FRONT = (1 << 7),
|
|
|
|
DRW_STATE_WIRE = (1 << 8),
|
|
|
|
DRW_STATE_WIRE_LARGE = (1 << 9),
|
|
|
|
DRW_STATE_POINT = (1 << 10),
|
|
|
|
DRW_STATE_STIPPLE_2 = (1 << 11),
|
|
|
|
DRW_STATE_STIPPLE_3 = (1 << 12),
|
|
|
|
DRW_STATE_STIPPLE_4 = (1 << 13),
|
|
|
|
DRW_STATE_BLEND = (1 << 14),
|
|
|
|
DRW_STATE_ADDITIVE = (1 << 15),
|
|
|
|
DRW_STATE_MULTIPLY = (1 << 16),
|
2017-07-03 16:28:20 +02:00
|
|
|
DRW_STATE_TRANSMISSION = (1 << 17),
|
|
|
|
DRW_STATE_CLIP_PLANES = (1 << 18),
|
2018-01-11 15:11:59 +01:00
|
|
|
DRW_STATE_ADDITIVE_FULL = (1 << 19), /* Same as DRW_STATE_ADDITIVE but let alpha accumulate without premult. */
|
2017-03-18 01:55:41 +01:00
|
|
|
|
2017-11-13 23:33:06 +01:00
|
|
|
DRW_STATE_WRITE_STENCIL = (1 << 27),
|
|
|
|
DRW_STATE_STENCIL_EQUAL = (1 << 28),
|
2017-02-07 11:20:15 +01:00
|
|
|
} DRWState;
|
|
|
|
|
2017-05-03 20:09:17 +10:00
|
|
|
#define DRW_STATE_DEFAULT (DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS)
|
|
|
|
|
2018-02-14 18:59:15 +01:00
|
|
|
typedef enum {
|
|
|
|
DRW_ATTRIB_INT,
|
|
|
|
DRW_ATTRIB_FLOAT,
|
|
|
|
} DRWAttribType;
|
|
|
|
|
|
|
|
typedef struct DRWInstanceAttribFormat {
|
|
|
|
char name[32];
|
|
|
|
DRWAttribType type;
|
|
|
|
int components;
|
|
|
|
} DRWInstanceAttribFormat;
|
|
|
|
|
|
|
|
struct Gwn_VertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttribFormat attribs[], int arraysize);
|
|
|
|
#define DRW_shgroup_instance_format(format, ...) do { \
|
|
|
|
if (format == NULL) { \
|
|
|
|
DRWInstanceAttribFormat drw_format[] = __VA_ARGS__;\
|
|
|
|
format = DRW_shgroup_instance_format_array(drw_format, (sizeof(drw_format) / sizeof(DRWInstanceAttribFormat))); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2017-05-03 08:20:11 +10:00
|
|
|
|
2017-02-07 11:20:15 +01:00
|
|
|
DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass);
|
2017-04-27 22:27:09 +02:00
|
|
|
DRWShadingGroup *DRW_shgroup_material_create(struct GPUMaterial *material, DRWPass *pass);
|
2017-09-12 15:06:07 +02:00
|
|
|
DRWShadingGroup *DRW_shgroup_material_instance_create(
|
2018-02-14 18:59:15 +01:00
|
|
|
struct GPUMaterial *material, DRWPass *pass, struct Gwn_Batch *geom, struct Object *ob,
|
|
|
|
struct Gwn_VertFormat *format);
|
2017-10-24 14:49:00 +02:00
|
|
|
DRWShadingGroup *DRW_shgroup_material_empty_tri_batch_create(struct GPUMaterial *material, DRWPass *pass, int size);
|
2018-02-14 18:59:15 +01:00
|
|
|
DRWShadingGroup *DRW_shgroup_instance_create(
|
|
|
|
struct GPUShader *shader, DRWPass *pass, struct Gwn_Batch *geom, struct Gwn_VertFormat *format);
|
2017-02-09 17:26:13 +01:00
|
|
|
DRWShadingGroup *DRW_shgroup_point_batch_create(struct GPUShader *shader, DRWPass *pass);
|
|
|
|
DRWShadingGroup *DRW_shgroup_line_batch_create(struct GPUShader *shader, DRWPass *pass);
|
2017-05-09 21:51:30 +02:00
|
|
|
DRWShadingGroup *DRW_shgroup_empty_tri_batch_create(struct GPUShader *shader, DRWPass *pass, int size);
|
2017-02-09 17:26:13 +01:00
|
|
|
|
2017-05-11 21:21:59 +10:00
|
|
|
typedef void (DRWCallGenerateFn)(
|
|
|
|
DRWShadingGroup *shgroup,
|
2017-06-19 20:18:04 +10:00
|
|
|
void (*draw_fn)(DRWShadingGroup *shgroup, struct Gwn_Batch *geom),
|
2017-05-11 21:21:59 +10:00
|
|
|
void *user_data);
|
|
|
|
|
2018-02-20 01:55:19 +01:00
|
|
|
void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct Gwn_Batch *batch);
|
2017-05-16 20:27:14 +02:00
|
|
|
|
2017-02-07 11:20:15 +01:00
|
|
|
void DRW_shgroup_free(struct DRWShadingGroup *shgroup);
|
2017-06-19 20:18:04 +10:00
|
|
|
void DRW_shgroup_call_add(DRWShadingGroup *shgroup, struct Gwn_Batch *geom, float (*obmat)[4]);
|
|
|
|
void DRW_shgroup_call_object_add(DRWShadingGroup *shgroup, struct Gwn_Batch *geom, struct Object *ob);
|
2017-05-12 17:54:14 +02:00
|
|
|
void DRW_shgroup_call_sculpt_add(DRWShadingGroup *shgroup, struct Object *ob, float (*obmat)[4]);
|
2017-05-11 21:21:59 +10:00
|
|
|
void DRW_shgroup_call_generate_add(
|
|
|
|
DRWShadingGroup *shgroup, DRWCallGenerateFn *geometry_fn, void *user_data, float (*obmat)[4]);
|
2017-04-22 15:53:11 +10:00
|
|
|
void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup, const void *attr[], unsigned int attr_len);
|
|
|
|
#define DRW_shgroup_call_dynamic_add(shgroup, ...) do { \
|
2017-04-11 21:19:23 +10:00
|
|
|
const void *array[] = {__VA_ARGS__}; \
|
2017-04-22 15:53:11 +10:00
|
|
|
DRW_shgroup_call_dynamic_add_array(shgroup, array, (sizeof(array) / sizeof(*array))); \
|
2017-04-11 21:19:23 +10:00
|
|
|
} while (0)
|
2017-11-06 16:54:33 +01:00
|
|
|
/* Use this to set a high number of instances. */
|
2018-02-14 18:59:15 +01:00
|
|
|
void DRW_shgroup_set_instance_count(DRWShadingGroup *shgroup, unsigned int count);
|
2018-02-14 18:16:52 +01:00
|
|
|
unsigned int DRW_shgroup_get_instance_count(const DRWShadingGroup *shgroup);
|
2017-04-11 21:19:23 +10:00
|
|
|
|
2017-05-03 08:20:11 +10:00
|
|
|
void DRW_shgroup_state_enable(DRWShadingGroup *shgroup, DRWState state);
|
2017-07-10 11:26:16 +02:00
|
|
|
void DRW_shgroup_state_disable(DRWShadingGroup *shgroup, DRWState state);
|
2017-11-13 23:33:06 +01:00
|
|
|
void DRW_shgroup_stencil_mask(DRWShadingGroup *shgroup, unsigned int mask);
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-05-09 22:08:25 +02:00
|
|
|
void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const struct GPUTexture *tex);
|
2017-05-09 23:55:02 +02:00
|
|
|
void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup, const char *name, const struct GPUUniformBuffer *ubo);
|
2017-05-09 22:08:25 +02:00
|
|
|
void DRW_shgroup_uniform_buffer(DRWShadingGroup *shgroup, const char *name, struct GPUTexture **tex);
|
2017-02-07 11:20:15 +01:00
|
|
|
void DRW_shgroup_uniform_float(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize);
|
|
|
|
void DRW_shgroup_uniform_vec2(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize);
|
|
|
|
void DRW_shgroup_uniform_vec3(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize);
|
|
|
|
void DRW_shgroup_uniform_vec4(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize);
|
2017-05-23 13:59:44 +02:00
|
|
|
void DRW_shgroup_uniform_short_to_int(DRWShadingGroup *shgroup, const char *name, const short *value, int arraysize);
|
|
|
|
void DRW_shgroup_uniform_short_to_float(DRWShadingGroup *shgroup, const char *name, const short *value, int arraysize);
|
2018-01-03 20:39:44 +01:00
|
|
|
/* Boolean are expected to be 4bytes longs for opengl! */
|
|
|
|
void DRW_shgroup_uniform_bool(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize);
|
2017-02-07 11:20:15 +01:00
|
|
|
void DRW_shgroup_uniform_int(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize);
|
|
|
|
void DRW_shgroup_uniform_ivec2(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize);
|
|
|
|
void DRW_shgroup_uniform_ivec3(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize);
|
|
|
|
void DRW_shgroup_uniform_mat3(DRWShadingGroup *shgroup, const char *name, const float *value);
|
|
|
|
void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const float *value);
|
|
|
|
|
|
|
|
/* Passes */
|
|
|
|
DRWPass *DRW_pass_create(const char *name, DRWState state);
|
2018-01-21 19:12:59 +01:00
|
|
|
void DRW_pass_state_set(DRWPass *pass, DRWState state);
|
2017-05-02 19:04:55 +02:00
|
|
|
void DRW_pass_foreach_shgroup(DRWPass *pass, void (*callback)(void *userData, DRWShadingGroup *shgrp), void *userData);
|
2017-07-10 14:45:19 +02:00
|
|
|
void DRW_pass_sort_shgroup_z(DRWPass *pass);
|
2017-02-07 11:20:15 +01:00
|
|
|
|
|
|
|
/* Viewport */
|
|
|
|
typedef enum {
|
2017-06-08 20:19:42 +02:00
|
|
|
DRW_MAT_PERS = 0,
|
2017-05-04 17:36:40 +02:00
|
|
|
DRW_MAT_PERSINV,
|
2017-03-22 21:28:59 +01:00
|
|
|
DRW_MAT_VIEW,
|
|
|
|
DRW_MAT_VIEWINV,
|
2017-02-07 11:20:15 +01:00
|
|
|
DRW_MAT_WIN,
|
2017-05-27 12:48:25 +02:00
|
|
|
DRW_MAT_WININV,
|
2017-02-07 11:20:15 +01:00
|
|
|
} DRWViewportMatrixType;
|
|
|
|
|
2017-02-17 17:29:43 +01:00
|
|
|
void DRW_viewport_init(const bContext *C);
|
2017-02-07 11:20:15 +01:00
|
|
|
void DRW_viewport_matrix_get(float mat[4][4], DRWViewportMatrixType type);
|
2017-06-08 20:19:42 +02:00
|
|
|
void DRW_viewport_matrix_override_set(float mat[4][4], DRWViewportMatrixType type);
|
|
|
|
void DRW_viewport_matrix_override_unset(DRWViewportMatrixType type);
|
2017-04-12 12:10:01 +10:00
|
|
|
const float *DRW_viewport_size_get(void);
|
|
|
|
const float *DRW_viewport_screenvecs_get(void);
|
|
|
|
const float *DRW_viewport_pixelsize_get(void);
|
2017-02-07 11:20:15 +01:00
|
|
|
bool DRW_viewport_is_persp_get(void);
|
|
|
|
|
2017-03-08 20:00:09 +01:00
|
|
|
struct DefaultFramebufferList *DRW_viewport_framebuffer_list_get(void);
|
|
|
|
struct DefaultTextureList *DRW_viewport_texture_list_get(void);
|
|
|
|
|
2017-06-08 20:25:20 +02:00
|
|
|
void DRW_viewport_request_redraw(void);
|
|
|
|
|
2018-01-29 14:56:16 +01:00
|
|
|
void DRW_render_to_image(struct RenderEngine *re, struct Depsgraph *depsgraph);
|
|
|
|
void DRW_render_object_iter(
|
|
|
|
void *vedata, struct RenderEngine *engine, struct Depsgraph *graph,
|
|
|
|
void (*callback)(void *vedata, struct Object *ob, struct RenderEngine *engine, struct Depsgraph *graph));
|
2018-02-14 18:59:15 +01:00
|
|
|
void DRW_render_instance_buffer_finish(void);
|
2018-01-29 14:56:16 +01:00
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
/* ViewLayers */
|
2017-11-29 11:00:50 +01:00
|
|
|
void *DRW_view_layer_engine_data_get(DrawEngineType *engine_type);
|
2017-11-29 10:48:42 +01:00
|
|
|
void **DRW_view_layer_engine_data_ensure(DrawEngineType *engine_type, void (*callback)(void *storage));
|
2017-05-30 22:28:47 +02:00
|
|
|
|
2017-04-03 19:01:10 +02:00
|
|
|
/* Objects */
|
2018-01-29 16:28:24 +01:00
|
|
|
ObjectEngineData *DRW_object_engine_data_get(Object *ob, DrawEngineType *engine_type);
|
|
|
|
ObjectEngineData *DRW_object_engine_data_ensure(
|
|
|
|
Object *ob,
|
|
|
|
DrawEngineType *engine_type,
|
|
|
|
size_t size,
|
|
|
|
ObjectEngineDataInitCb init_cb,
|
|
|
|
ObjectEngineDataFreeCb free_cb);
|
2017-11-29 10:48:42 +01:00
|
|
|
struct LampEngineData *DRW_lamp_engine_data_ensure(Object *ob, struct RenderEngineType *engine_type);
|
2017-04-10 12:06:17 +02:00
|
|
|
void DRW_lamp_engine_data_free(struct LampEngineData *led);
|
2017-04-03 19:01:10 +02:00
|
|
|
|
2017-02-07 11:20:15 +01:00
|
|
|
/* Settings */
|
2017-05-08 11:15:28 +10:00
|
|
|
bool DRW_object_is_renderable(struct Object *ob);
|
2017-12-21 13:29:14 -02:00
|
|
|
bool DRW_check_object_visible_within_active_context(struct Object *ob);
|
2017-07-13 00:27:06 +10:00
|
|
|
bool DRW_object_is_flat_normal(const struct Object *ob);
|
|
|
|
int DRW_object_is_mode_shade(const struct Object *ob);
|
2017-02-07 11:20:15 +01:00
|
|
|
|
|
|
|
/* Draw commands */
|
|
|
|
void DRW_draw_pass(DRWPass *pass);
|
2017-06-26 20:42:58 +02:00
|
|
|
void DRW_draw_pass_subset(DRWPass *pass, DRWShadingGroup *start_group, DRWShadingGroup *end_group);
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-04-28 04:33:58 +10:00
|
|
|
void DRW_draw_text_cache_queue(struct DRWTextStore *dt);
|
|
|
|
|
2017-03-05 18:09:43 +01:00
|
|
|
void DRW_draw_callbacks_pre_scene(void);
|
|
|
|
void DRW_draw_callbacks_post_scene(void);
|
|
|
|
|
2017-05-04 15:46:09 +02:00
|
|
|
int DRW_draw_region_engine_info_offset(void);
|
|
|
|
void DRW_draw_region_engine_info(void);
|
|
|
|
|
2017-05-03 20:09:17 +10:00
|
|
|
void DRW_state_reset_ex(DRWState state);
|
2017-02-07 11:20:15 +01:00
|
|
|
void DRW_state_reset(void);
|
2017-06-16 14:23:30 +02:00
|
|
|
|
2017-06-16 13:27:09 +02:00
|
|
|
void DRW_state_invert_facing(void);
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-06-16 14:23:30 +02:00
|
|
|
void DRW_state_clip_planes_add(float plane_eq[4]);
|
|
|
|
void DRW_state_clip_planes_reset(void);
|
|
|
|
|
2017-04-26 16:11:37 +10:00
|
|
|
/* Selection */
|
|
|
|
void DRW_select_load_id(unsigned int id);
|
|
|
|
|
2017-04-27 02:04:56 +10:00
|
|
|
/* Draw State */
|
|
|
|
void DRW_state_dfdy_factors_get(float dfdyfac[2]);
|
|
|
|
bool DRW_state_is_fbo(void);
|
|
|
|
bool DRW_state_is_select(void);
|
2017-04-28 04:33:58 +10:00
|
|
|
bool DRW_state_is_depth(void);
|
2017-06-20 18:33:58 +02:00
|
|
|
bool DRW_state_is_image_render(void);
|
|
|
|
bool DRW_state_is_scene_render(void);
|
2018-02-16 16:52:08 +01:00
|
|
|
bool DRW_state_is_opengl_render(void);
|
2017-04-28 04:33:58 +10:00
|
|
|
bool DRW_state_show_text(void);
|
2017-07-03 16:16:24 +02:00
|
|
|
bool DRW_state_draw_support(void);
|
2017-12-20 15:28:12 -02:00
|
|
|
bool DRW_state_draw_background(void);
|
2017-04-28 04:33:58 +10:00
|
|
|
|
2017-12-21 13:29:14 -02:00
|
|
|
enum eDepsObjectIteratorMode DRW_iterator_mode_get(void);
|
|
|
|
|
2017-04-28 04:33:58 +10:00
|
|
|
struct DRWTextStore *DRW_state_text_cache_get(void);
|
2017-04-26 00:35:08 +10:00
|
|
|
|
|
|
|
/* Avoid too many lookups while drawing */
|
|
|
|
typedef struct DRWContextState {
|
2018-02-06 16:10:03 +11:00
|
|
|
|
2017-05-17 11:03:09 +10:00
|
|
|
struct ARegion *ar; /* 'CTX_wm_region(C)' */
|
|
|
|
struct RegionView3D *rv3d; /* 'CTX_wm_region_view3d(C)' */
|
|
|
|
struct View3D *v3d; /* 'CTX_wm_view3d(C)' */
|
2017-04-26 00:35:08 +10:00
|
|
|
|
2017-05-17 11:03:09 +10:00
|
|
|
struct Scene *scene; /* 'CTX_data_scene(C)' */
|
2017-11-22 10:52:39 -02:00
|
|
|
struct ViewLayer *view_layer; /* 'CTX_data_view_layer(C)' */
|
2017-04-26 00:35:08 +10:00
|
|
|
|
2018-02-13 18:15:47 +11:00
|
|
|
/* Use 'object_edit' for edit-mode */
|
2017-11-09 13:23:01 -02:00
|
|
|
struct Object *obact; /* 'OBACT' */
|
2017-05-17 11:03:09 +10:00
|
|
|
|
2017-11-28 15:06:32 +01:00
|
|
|
struct RenderEngineType *engine_type;
|
2017-10-16 17:15:03 -02:00
|
|
|
|
2018-01-16 15:42:03 +01:00
|
|
|
struct Depsgraph *depsgraph;
|
|
|
|
|
2018-02-06 23:27:49 +11:00
|
|
|
eObjectMode object_mode;
|
2018-02-06 16:10:03 +11:00
|
|
|
|
2017-05-17 11:03:09 +10:00
|
|
|
/* Last resort (some functions take this as an arg so we can't easily avoid).
|
|
|
|
* May be NULL when used for selection or depth buffer. */
|
2017-04-26 00:35:08 +10:00
|
|
|
const struct bContext *evil_C;
|
2018-02-06 16:10:03 +11:00
|
|
|
|
2018-02-13 18:15:47 +11:00
|
|
|
/* ---- */
|
|
|
|
|
|
|
|
/* Cache: initialized by 'drw_context_state_init'. */
|
2018-02-09 02:31:09 +11:00
|
|
|
struct Object *object_pose;
|
2018-02-13 18:15:47 +11:00
|
|
|
struct Object *object_edit;
|
2018-02-09 02:31:09 +11:00
|
|
|
|
2017-04-26 00:35:08 +10:00
|
|
|
} DRWContextState;
|
|
|
|
|
|
|
|
const DRWContextState *DRW_context_state_get(void);
|
|
|
|
|
2017-02-22 18:52:07 +01:00
|
|
|
#endif /* __DRW_RENDER_H__ */
|