diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2015-12-06 23:20:19 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2015-12-08 21:00:56 +0300 |
commit | 0dfc8d69392a57e0210644428571dd455cb61241 (patch) | |
tree | df3bdd30f3bbae7693a786b1aa6a8ab0b8921805 /source/blender/gpu/GPU_extensions.h | |
parent | b25e4b310f87fc86942acd29fccf1474ea5120df (diff) |
OpenGL: split off framebuffer, shader and texture code into separate files.
Diffstat (limited to 'source/blender/gpu/GPU_extensions.h')
-rw-r--r-- | source/blender/gpu/GPU_extensions.h | 187 |
1 files changed, 3 insertions, 184 deletions
diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h index ef582b6d97f..f3be52f324b 100644 --- a/source/blender/gpu/GPU_extensions.h +++ b/source/blender/gpu/GPU_extensions.h @@ -36,25 +36,6 @@ extern "C" { #endif -struct Image; -struct ImageUser; -struct PreviewImage; - -struct GPUTexture; -typedef struct GPUTexture GPUTexture; - -struct GPUFrameBuffer; -typedef struct GPUFrameBuffer GPUFrameBuffer; - -struct GPUOffScreen; -typedef struct GPUOffScreen GPUOffScreen; - -struct GPUShader; -typedef struct GPUShader GPUShader; - -struct GPUProgram; -typedef struct GPUProgram GPUProgram; - /* GPU extensions support */ void GPU_extensions_disable(void); @@ -65,9 +46,12 @@ bool GPU_full_non_power_of_two_support(void); bool GPU_display_list_support(void); bool GPU_bicubic_bump_support(void); bool GPU_geometry_shader_support(void); +bool GPU_geometry_shader_support_via_extension(void); bool GPU_instanced_drawing_support(void); int GPU_max_texture_size(void); +int GPU_max_textures(void); +int GPU_max_color_texture_samples(void); int GPU_color_depth(void); void GPU_get_dfdy_factors(float fac[2]); @@ -103,171 +87,6 @@ typedef enum GPUDriverType { bool GPU_type_matches(GPUDeviceType device, GPUOSType os, GPUDriverType driver); -/* GPU Texture - * - always returns unsigned char RGBA textures - * - if texture with non square dimensions is created, depending on the - * graphics card capabilities the texture may actually be stored in a - * larger texture with power of two dimensions. - * - can use reference counting: - * - reference counter after GPU_texture_create is 1 - * - GPU_texture_ref increases by one - * - GPU_texture_free decreases by one, and frees if 0 - * - if created with from_blender, will not free the texture - */ - -typedef enum GPUHDRType { - GPU_HDR_NONE = 0, - GPU_HDR_HALF_FLOAT = 1, - GPU_HDR_FULL_FLOAT = (1 << 1), -} GPUHDRType; - -GPUTexture *GPU_texture_create_1D(int w, const float *pixels, char err_out[256]); -GPUTexture *GPU_texture_create_2D(int w, int h, const float *pixels, GPUHDRType hdr, char err_out[256]); -GPUTexture *GPU_texture_create_3D(int w, int h, int depth, int channels, const float *fpixels); -GPUTexture *GPU_texture_create_depth(int w, int h, char err_out[256]); -GPUTexture *GPU_texture_create_vsm_shadow_map(int size, char err_out[256]); -GPUTexture *GPU_texture_create_2D_procedural(int w, int h, const float *pixels, bool repeat, char err_out[256]); -GPUTexture *GPU_texture_create_1D_procedural(int w, const float *pixels, char err_out[256]); -GPUTexture *GPU_texture_create_2D_multisample(int w, int h, const float *pixels, GPUHDRType hdr, int samples, char err_out[256]); -GPUTexture *GPU_texture_create_depth_multisample(int w, int h, int samples, char err_out[256]); -GPUTexture *GPU_texture_from_blender(struct Image *ima, - struct ImageUser *iuser, bool is_data, double time, int mipmap); -GPUTexture *GPU_texture_from_preview(struct PreviewImage *prv, int mipmap); -void GPU_invalid_tex_init(void); -void GPU_invalid_tex_bind(int mode); -void GPU_invalid_tex_free(void); - -void GPU_texture_free(GPUTexture *tex); - -void GPU_texture_ref(GPUTexture *tex); - -void GPU_texture_bind(GPUTexture *tex, int number); -void GPU_texture_unbind(GPUTexture *tex); - -void GPU_texture_filter_mode(GPUTexture *tex, bool compare, bool use_filter); - -GPUFrameBuffer *GPU_texture_framebuffer(GPUTexture *tex); - -int GPU_texture_target(const GPUTexture *tex); -int GPU_texture_width(const GPUTexture *tex); -int GPU_texture_height(const GPUTexture *tex); -int GPU_texture_opengl_bindcode(const GPUTexture *tex); - -/* GPU Framebuffer - * - this is a wrapper for an OpenGL framebuffer object (FBO). in practice - * multiple FBO's may be created, to get around limitations on the number - * of attached textures and the dimension requirements. - * - after any of the GPU_framebuffer_* functions, GPU_framebuffer_restore must - * be called before rendering to the window framebuffer again */ - -void GPU_texture_bind_as_framebuffer(GPUTexture *tex); - -GPUFrameBuffer *GPU_framebuffer_create(void); -int GPU_framebuffer_texture_attach(GPUFrameBuffer *fb, GPUTexture *tex, int slot, char err_out[256]); -void GPU_framebuffer_texture_detach(GPUTexture *tex); -void GPU_framebuffer_slots_bind(GPUFrameBuffer *fb, int slot); -void GPU_framebuffer_texture_unbind(GPUFrameBuffer *fb, GPUTexture *tex); -void GPU_framebuffer_free(GPUFrameBuffer *fb); -bool GPU_framebuffer_check_valid(GPUFrameBuffer *fb, char err_out[256]); - -void GPU_framebuffer_bind_no_save(GPUFrameBuffer *fb, int slot); - -void GPU_framebuffer_restore(void); -void GPU_framebuffer_blur(GPUFrameBuffer *fb, GPUTexture *tex, GPUFrameBuffer *blurfb, GPUTexture *blurtex); - -/* GPU OffScreen - * - wrapper around framebuffer and texture for simple offscreen drawing - * - changes size if graphics card can't support it */ - -GPUOffScreen *GPU_offscreen_create(int width, int height, int samples, char err_out[256]); -void GPU_offscreen_free(GPUOffScreen *ofs); -void GPU_offscreen_bind(GPUOffScreen *ofs, bool save); -void GPU_offscreen_unbind(GPUOffScreen *ofs, bool restore); -void GPU_offscreen_read_pixels(GPUOffScreen *ofs, int type, void *pixels); -int GPU_offscreen_width(const GPUOffScreen *ofs); -int GPU_offscreen_height(const GPUOffScreen *ofs); -int GPU_offscreen_color_texture(const GPUOffScreen *ofs); - -/* Builtin/Non-generated shaders */ -typedef enum GPUProgramType { - GPU_PROGRAM_TYPE_FRAGMENT = 0 -} GPUProgramType; - -/* TODO: remove ARB program support (recode smoke shader in GLSL) */ -GPUProgram *GPU_program_shader_create(GPUProgramType type, const char *code); -void GPU_program_free(GPUProgram *program); -void GPU_program_parameter_4f(GPUProgram *program, unsigned int location, float x, float y, float z, float w); -void GPU_program_bind(GPUProgram *); -void GPU_program_unbind(GPUProgram *); - -/* GPU Shader - * - only for fragment shaders now - * - must call texture bind before setting a texture as uniform! */ - -GPUShader *GPU_shader_create(const char *vertexcode, const char *fragcode, const char *geocode, const char *libcode, const char *defines, int input, int output, int number); -enum { - GPU_SHADER_FLAGS_NONE = 0, - GPU_SHADER_FLAGS_SPECIAL_OPENSUBDIV = (1 << 0), -}; -GPUShader *GPU_shader_create_ex(const char *vertexcode, - const char *fragcode, - const char *geocode, - const char *libcode, - const char *defines, - int input, - int output, - int number, - const int flags); -void GPU_shader_free(GPUShader *shader); - -void GPU_shader_bind(GPUShader *shader); -void GPU_shader_unbind(void); - -int GPU_shader_get_uniform(GPUShader *shader, const char *name); -void GPU_shader_uniform_vector(GPUShader *shader, int location, int length, - int arraysize, const float *value); -void GPU_shader_uniform_vector_int(GPUShader *shader, int location, int length, - int arraysize, const int *value); - -void GPU_shader_uniform_texture(GPUShader *shader, int location, GPUTexture *tex); -void GPU_shader_uniform_int(GPUShader *shader, int location, int value); -void GPU_shader_geometry_stage_primitive_io(GPUShader *shader, int input, int output, int number); - -int GPU_shader_get_attribute(GPUShader *shader, const char *name); - -/* Builtin/Non-generated shaders */ -typedef enum GPUBuiltinShader { - GPU_SHADER_VSM_STORE = 0, - GPU_SHADER_SEP_GAUSSIAN_BLUR = 1, -} GPUBuiltinShader; - -typedef enum GPUBuiltinProgram { - GPU_PROGRAM_SMOKE = 0, - GPU_PROGRAM_SMOKE_COLORED = 1, -} GPUBuiltinProgram; - -GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader); -GPUProgram *GPU_shader_get_builtin_program(GPUBuiltinProgram program); -GPUShader *GPU_shader_get_builtin_fx_shader(int effects, bool persp); - -void GPU_shader_free_builtin_shaders(void); - -/* Vertex attributes for shaders */ - -#define GPU_MAX_ATTRIB 32 - -typedef struct GPUVertexAttribs { - struct { - int type; - int glindex; - int gltexco; - int attribid; - char name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ - } layer[GPU_MAX_ATTRIB]; - - int totlayer; -} GPUVertexAttribs; - #ifdef __cplusplus } #endif |