From 2e4569abbc6aa19d166ed083c04e046fdc19fce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Sat, 12 Sep 2020 19:48:52 +0200 Subject: Fix remaining GL calls/type preventing from building due to recent cleanup --- source/blender/draw/intern/draw_hair.c | 8 +++---- .../blender/draw/intern/draw_manager_profiling.c | 28 +++++++++++----------- source/blender/editors/interface/interface_icons.c | 4 ++-- source/blender/editors/sculpt_paint/paint_cursor.c | 20 ++++++++-------- source/blender/editors/space_image/image_draw.c | 6 +++-- source/blender/editors/space_view3d/view3d_draw.c | 2 +- source/blender/gpu/GPU_common.h | 4 ---- source/blender/gpu/GPU_texture.h | 1 - source/blender/gpu/GPU_vertex_buffer.h | 3 +++ source/blender/gpu/intern/gpu_immediate.cc | 2 +- source/blender/gpu/intern/gpu_texture.cc | 6 ----- source/blender/gpu/intern/gpu_vertex_buffer.cc | 7 ++++++ .../gpu/intern/gpu_vertex_buffer_private.hh | 2 ++ source/blender/gpu/intern/gpu_vertex_format.cc | 2 +- source/blender/gpu/opengl/gl_vertex_buffer.cc | 5 ++++ source/blender/gpu/opengl/gl_vertex_buffer.hh | 2 ++ source/blender/windowmanager/intern/wm_draw.c | 3 --- 17 files changed, 56 insertions(+), 49 deletions(-) (limited to 'source/blender') diff --git a/source/blender/draw/intern/draw_hair.c b/source/blender/draw/intern/draw_hair.c index 9b503e00b36..cc0aa09ed97 100644 --- a/source/blender/draw/intern/draw_hair.c +++ b/source/blender/draw/intern/draw_hair.c @@ -346,10 +346,10 @@ void DRW_hair_update(void) GPU_framebuffer_read_color(fb, 0, 0, width, height, 4, 0, GPU_DATA_FLOAT, data); /* Upload back to VBO. */ GPU_vertbuf_use(pr_call->vbo); - glBufferSubData(GL_ARRAY_BUFFER, - sizeof(float[4]) * g_tf_id_offset, - sizeof(float[4]) * max_read_px_len, - data); + GPU_vertbuf_update_sub(pr_call->vbo, + sizeof(float[4]) * g_tf_id_offset, + sizeof(float[4]) * max_read_px_len, + data); g_tf_id_offset += max_read_px_len; pr_call->vert_len -= max_read_px_len; diff --git a/source/blender/draw/intern/draw_manager_profiling.c b/source/blender/draw/intern/draw_manager_profiling.c index 57887c11c02..f8587555480 100644 --- a/source/blender/draw/intern/draw_manager_profiling.c +++ b/source/blender/draw/intern/draw_manager_profiling.c @@ -44,8 +44,8 @@ #define GPU_TIMER_FALLOFF 0.1 typedef struct DRWTimer { - GLuint query[2]; - GLuint64 time_average; + uint32_t query[2]; + uint64_t time_average; char name[MAX_TIMER_NAME]; int lvl; /* Hierarchy level for nested timer. */ bool is_query; /* Does this timer actually perform queries or is it just a group. */ @@ -64,10 +64,10 @@ static struct DRWTimerPool { void DRW_stats_free(void) { if (DTP.timers != NULL) { - for (int i = 0; i < DTP.timer_count; i++) { - DRWTimer *timer = &DTP.timers[i]; - glDeleteQueries(2, timer->query); - } + // for (int i = 0; i < DTP.timer_count; i++) { + // DRWTimer *timer = &DTP.timers[i]; + // glDeleteQueries(2, timer->query); + // } MEM_freeN(DTP.timers); DTP.timers = NULL; } @@ -117,12 +117,12 @@ static void drw_stats_timer_start_ex(const char *name, const bool is_query) BLI_assert(!DTP.is_querying); if (timer->is_query) { if (timer->query[0] == 0) { - glGenQueries(1, timer->query); + // glGenQueries(1, timer->query); } - glFinish(); + // glFinish(); /* Issue query for the next frame */ - glBeginQuery(GL_TIME_ELAPSED, timer->query[0]); + // glBeginQuery(GL_TIME_ELAPSED, timer->query[0]); DTP.is_querying = true; } } @@ -154,7 +154,7 @@ void DRW_stats_query_end(void) if (DTP.is_recording) { DTP.end_increment++; BLI_assert(DTP.is_querying); - glEndQuery(GL_TIME_ELAPSED); + // glEndQuery(GL_TIME_ELAPSED); DTP.is_querying = false; } } @@ -167,19 +167,19 @@ void DRW_stats_reset(void) "You forgot a DRW_stats_group/query_start somewhere!"); if (DTP.is_recording) { - GLuint64 lvl_time[MAX_NESTED_TIMER] = {0}; + uint64_t lvl_time[MAX_NESTED_TIMER] = {0}; /* Swap queries for the next frame and sum up each lvl time. */ for (int i = DTP.timer_increment - 1; i >= 0; i--) { DRWTimer *timer = &DTP.timers[i]; - SWAP(GLuint, timer->query[0], timer->query[1]); + SWAP(uint32_t, timer->query[0], timer->query[1]); BLI_assert(timer->lvl < MAX_NESTED_TIMER); if (timer->is_query) { - GLuint64 time; + uint64_t time = 0; if (timer->query[0] != 0) { - glGetQueryObjectui64v(timer->query[0], GL_QUERY_RESULT, &time); + // glGetQueryObjectui64v(timer->query[0], GL_QUERY_RESULT, &time); } else { time = 1000000000; /* 1ms default */ diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index c91b4d826a7..d22ddb5f2b7 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -256,7 +256,7 @@ static void def_internal_vicon(int icon_id, VectorDrawFunc drawFunc) /* Utilities */ -static void viconutil_set_point(GLint pt[2], int x, int y) +static void viconutil_set_point(int pt[2], int x, int y) { pt[0] = x; pt[1] = y; @@ -264,7 +264,7 @@ static void viconutil_set_point(GLint pt[2], int x, int y) static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float alpha) { - GLint pts[3][2]; + int pts[3][2]; const int cx = x + w / 2 - 4; const int cy = y + w / 2; const int d = w / 5, d2 = w / 7; diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 3d8c718c8a9..55abb269660 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -142,7 +142,7 @@ typedef struct LoadTexData { ViewContext *vc; MTex *mtex; - GLubyte *buffer; + uchar *buffer; bool col; struct ImagePool *pool; @@ -160,7 +160,7 @@ static void load_tex_task_cb_ex(void *__restrict userdata, ViewContext *vc = data->vc; MTex *mtex = data->mtex; - GLubyte *buffer = data->buffer; + uchar *buffer = data->buffer; const bool col = data->col; struct ImagePool *pool = data->pool; @@ -230,7 +230,7 @@ static void load_tex_task_cb_ex(void *__restrict userdata, /* Clamp to avoid precision overflow. */ CLAMP(avg, 0.0f, 1.0f); - buffer[index] = 255 - (GLubyte)(255 * avg); + buffer[index] = 255 - (uchar)(255 * avg); } } else { @@ -254,7 +254,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima MTex *mtex = (primary) ? &br->mtex : &br->mask_mtex; ePaintOverlayControlFlags overlay_flags = BKE_paint_get_overlay_flags(); - GLubyte *buffer = NULL; + uchar *buffer = NULL; int size; bool refresh; @@ -309,10 +309,10 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima target->old_col = col; } if (col) { - buffer = MEM_mallocN(sizeof(GLubyte) * size * size * 4, "load_tex"); + buffer = MEM_mallocN(sizeof(uchar) * size * size * 4, "load_tex"); } else { - buffer = MEM_mallocN(sizeof(GLubyte) * size * size, "load_tex"); + buffer = MEM_mallocN(sizeof(uchar) * size * size, "load_tex"); } pool = BKE_image_pool_new(); @@ -381,7 +381,7 @@ static void load_tex_cursor_task_cb(void *__restrict userdata, LoadTexData *data = userdata; Brush *br = data->br; - GLubyte *buffer = data->buffer; + uchar *buffer = data->buffer; const int size = data->size; @@ -398,7 +398,7 @@ static void load_tex_cursor_task_cb(void *__restrict userdata, /* Falloff curve. */ float avg = BKE_brush_curve_strength_clamped(br, len, 1.0f); - buffer[index] = (GLubyte)(255 * avg); + buffer[index] = (uchar)(255 * avg); } else { buffer[index] = 0; @@ -411,7 +411,7 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom) bool init; ePaintOverlayControlFlags overlay_flags = BKE_paint_get_overlay_flags(); - GLubyte *buffer = NULL; + uchar *buffer = NULL; int size; const bool refresh = !cursor_snap.overlay_texture || @@ -452,7 +452,7 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom) cursor_snap.size = size; } - buffer = MEM_mallocN(sizeof(GLubyte) * size * size, "load_tex"); + buffer = MEM_mallocN(sizeof(uchar) * size * size, "load_tex"); BKE_curvemapping_init(br->curve); diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 85d153feb4c..60dd134646d 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -55,6 +55,7 @@ #include "BIF_glutil.h" +#include "GPU_framebuffer.h" #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_matrix.h" @@ -570,7 +571,8 @@ static void draw_image_buffer(const bContext *C, float zoomy) { /* Image are still drawn in display space. */ - glDisable(GL_FRAMEBUFFER_SRGB); + GPUFrameBuffer *fb = GPU_framebuffer_active_get(); + GPU_framebuffer_bind_no_srgb(fb); int x, y; int sima_flag = sima->flag & ED_space_image_get_display_channel_mask(ibuf); @@ -660,7 +662,7 @@ static void draw_image_buffer(const bContext *C, } } - glEnable(GL_FRAMEBUFFER_SRGB); + GPU_framebuffer_bind(fb); } static void draw_image_buffer_repeated(const bContext *C, diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index f3300f21628..0b5daece556 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1065,7 +1065,7 @@ static void draw_rotation_guide(const RegionView3D *rv3d) float o[3]; /* center of rotation */ float end[3]; /* endpoints for drawing */ - GLubyte color[4] = {0, 108, 255, 255}; /* bright blue so it matches device LEDs */ + uchar color[4] = {0, 108, 255, 255}; /* bright blue so it matches device LEDs */ negate_v3_v3(o, rv3d->ofs); diff --git a/source/blender/gpu/GPU_common.h b/source/blender/gpu/GPU_common.h index 8fd1baba2f7..1be74701176 100644 --- a/source/blender/gpu/GPU_common.h +++ b/source/blender/gpu/GPU_common.h @@ -32,10 +32,6 @@ # define TRUST_NO_ONE 1 #endif -#if defined(WITH_OPENGL) -# include -#endif - #include "BLI_sys_types.h" #include #include diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h index fafa45fe0fe..99a7c6a5f0c 100644 --- a/source/blender/gpu/GPU_texture.h +++ b/source/blender/gpu/GPU_texture.h @@ -257,7 +257,6 @@ void GPU_texture_mipmap_mode(GPUTexture *tex, bool use_mipmap, bool use_filter); void GPU_texture_wrap_mode(GPUTexture *tex, bool use_repeat, bool use_clamp); void GPU_texture_swizzle_set(GPUTexture *tex, const char swizzle[4]); -int GPU_texture_target(const GPUTexture *tex); int GPU_texture_width(const GPUTexture *tex); int GPU_texture_height(const GPUTexture *tex); int GPU_texture_orig_width(const GPUTexture *tex); diff --git a/source/blender/gpu/GPU_vertex_buffer.h b/source/blender/gpu/GPU_vertex_buffer.h index 2af9929db35..36caee10072 100644 --- a/source/blender/gpu/GPU_vertex_buffer.h +++ b/source/blender/gpu/GPU_vertex_buffer.h @@ -139,6 +139,9 @@ GPUVertBufStatus GPU_vertbuf_get_status(const GPUVertBuf *verts); void GPU_vertbuf_use(GPUVertBuf *); +/* XXX do not use. */ +void GPU_vertbuf_update_sub(GPUVertBuf *verts, uint start, uint len, void *data); + /* Metrics */ uint GPU_vertbuf_get_memory_usage(void); diff --git a/source/blender/gpu/intern/gpu_immediate.cc b/source/blender/gpu/intern/gpu_immediate.cc index 9c3a88e30f0..8d781978857 100644 --- a/source/blender/gpu/intern/gpu_immediate.cc +++ b/source/blender/gpu/intern/gpu_immediate.cc @@ -416,7 +416,7 @@ static void immEndVertex(void) /* and move on to the next vertex */ printf("copying %s from vertex %u to %u\n", a->name, imm->vertex_idx - 1, imm->vertex_idx); #endif - GLubyte *data = imm->vertex_data + a->offset; + uchar *data = imm->vertex_data + a->offset; memcpy(data, data - imm->vertex_format.stride, a->sz); /* TODO: consolidate copy of adjacent attributes */ } diff --git a/source/blender/gpu/intern/gpu_texture.cc b/source/blender/gpu/intern/gpu_texture.cc index 09dbf04210a..eb6881164b2 100644 --- a/source/blender/gpu/intern/gpu_texture.cc +++ b/source/blender/gpu/intern/gpu_texture.cc @@ -513,12 +513,6 @@ void GPU_texture_ref(GPUTexture *tex) reinterpret_cast(tex)->refcount++; } -/* TODO(fclem) Remove! This is broken as it is! */ -int GPU_texture_target(const GPUTexture *UNUSED(tex)) -{ - return GL_TEXTURE_2D; -} - int GPU_texture_width(const GPUTexture *tex) { return reinterpret_cast(tex)->width_get(); diff --git a/source/blender/gpu/intern/gpu_vertex_buffer.cc b/source/blender/gpu/intern/gpu_vertex_buffer.cc index 4cc2af889e6..ea149aaa254 100644 --- a/source/blender/gpu/intern/gpu_vertex_buffer.cc +++ b/source/blender/gpu/intern/gpu_vertex_buffer.cc @@ -324,4 +324,11 @@ void GPU_vertbuf_use(GPUVertBuf *verts) unwrap(verts)->upload(); } +/* XXX this is just a wrapper for the use of the Hair refine workaround. + * To be used with GPU_vertbuf_use(). */ +void GPU_vertbuf_update_sub(GPUVertBuf *verts, uint start, uint len, void *data) +{ + unwrap(verts)->update_sub(start, len, data); +} + /** \} */ \ No newline at end of file diff --git a/source/blender/gpu/intern/gpu_vertex_buffer_private.hh b/source/blender/gpu/intern/gpu_vertex_buffer_private.hh index f1de0a2ac96..3cce7e79857 100644 --- a/source/blender/gpu/intern/gpu_vertex_buffer_private.hh +++ b/source/blender/gpu/intern/gpu_vertex_buffer_private.hh @@ -95,6 +95,8 @@ class VertBuf { } } + virtual void update_sub(uint start, uint len, void *data) = 0; + protected: virtual void acquire_data(void) = 0; virtual void resize_data(void) = 0; diff --git a/source/blender/gpu/intern/gpu_vertex_format.cc b/source/blender/gpu/intern/gpu_vertex_format.cc index ac8439167e3..3b0aa055588 100644 --- a/source/blender/gpu/intern/gpu_vertex_format.cc +++ b/source/blender/gpu/intern/gpu_vertex_format.cc @@ -70,7 +70,7 @@ static uint comp_sz(GPUVertCompType type) #if TRUST_NO_ONE assert(type <= GPU_COMP_F32); /* other types have irregular sizes (not bytes) */ #endif - const GLubyte sizes[] = {1, 1, 2, 2, 4, 4, 4}; + const uint sizes[] = {1, 1, 2, 2, 4, 4, 4}; return sizes[type]; } diff --git a/source/blender/gpu/opengl/gl_vertex_buffer.cc b/source/blender/gpu/opengl/gl_vertex_buffer.cc index a724c94775e..d97fc2c1600 100644 --- a/source/blender/gpu/opengl/gl_vertex_buffer.cc +++ b/source/blender/gpu/opengl/gl_vertex_buffer.cc @@ -106,4 +106,9 @@ void GLVertBuf::bind(void) } } +void GLVertBuf::update_sub(uint start, uint len, void *data) +{ + glBufferSubData(GL_ARRAY_BUFFER, start, len, data); +} + } // namespace blender::gpu \ No newline at end of file diff --git a/source/blender/gpu/opengl/gl_vertex_buffer.hh b/source/blender/gpu/opengl/gl_vertex_buffer.hh index eee5222f467..e2bf6cd00e8 100644 --- a/source/blender/gpu/opengl/gl_vertex_buffer.hh +++ b/source/blender/gpu/opengl/gl_vertex_buffer.hh @@ -45,6 +45,8 @@ class GLVertBuf : public VertBuf { public: void bind(void); + void update_sub(uint start, uint len, void *data) override; + protected: void acquire_data(void) override; void resize_data(void) override; diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 1d3db3e7609..eb5f8ca5ef1 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -396,9 +396,6 @@ static void wm_draw_offscreen_texture_parameters(GPUOffScreen *offscreen) /* Setup offscreen color texture for drawing. */ GPUTexture *texture = GPU_offscreen_color_texture(offscreen); - /* We don't support multisample textures here. */ - BLI_assert(GPU_texture_target(texture) == GL_TEXTURE_2D); - /* No mipmaps or filtering. */ GPU_texture_mipmap_mode(texture, false, false); } -- cgit v1.2.3