This commit does nothing to do with compositor. Please report a bug to the tracker and attach .blend file which demonstrates the issue.
On Wed, Apr 3, 2013 at 1:50 PM, IRIE Shinsuke <[email protected]>wrote: > Hi Sergey, > > This commit breaks the compositor. The input from primary renderlayer > is replaced with another renderlayer that is currently selected in the > renderlayer panel, so the expected result cannot be obtained unless the > primary renderlayer is selected. > > Thanks, > > IRIE Shinsuke > > 13/04/03, Sergey Sharybin wrote: > > Revision: 55733 > > > http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55733 > > Author: nazgul > > Date: 2013-04-02 17:28:37 +0000 (Tue, 02 Apr 2013) > > Log Message: > > ----------- > > More usage of GLSL for color managed image drawing > > > > Uses GLSL for drawing image in Image Editor space. > > > > This requires change in image_buffer_rect_update, so > > original float buffer is being updated as well. This > > is unlikely be something bad, but will keep an eye > > on this change. > > > > Also no byte buffer allocation happens there, this > > is so because byte buffer used for display only > > and in case of GLSL display such allocation and > > partial update is just waste of time. > > > > Also switched OpenGL render from using CPU color > > space linearization to GLSL color space transform. > > Makes OpenGL rendering pretty much faster (but > > still slower than in 2.60). > > > > internal changes: > > > > - Added functions to setup GLSL shader for color > > space conversion in colormanagement.c. Currently > > conversion form a colorspace defined by a role to > > linear space is implemented. Easy to extend to > > other cases. > > > > - Added helper functions to glutil.c which does > > smarter image buffer draw (calling all needed OCIO > > stuff, editors now could draw image buffer with a > > single function call -- all the checks are done in > > glutil.c). > > > > - Also added helper function for buffer linearization > > from a given role to glutil.c. Everyone now able to > > linearize buffer with a single call. > > > > This function will do nothing is GLSL routines fails > > or not supported. > > > > And one last this: this function uses offscreen > > drawing, could potentially give issues on some > > cards, also will keep an eye on this. > > > > Modified Paths: > > -------------- > > trunk/blender/source/blender/editors/include/BIF_glutil.h > > trunk/blender/source/blender/editors/render/render_internal.c > > trunk/blender/source/blender/editors/render/render_opengl.c > > trunk/blender/source/blender/editors/screen/CMakeLists.txt > > trunk/blender/source/blender/editors/screen/glutil.c > > trunk/blender/source/blender/editors/space_clip/clip_draw.c > > trunk/blender/source/blender/editors/space_image/image_draw.c > > trunk/blender/source/blender/imbuf/IMB_colormanagement.h > > trunk/blender/source/blender/imbuf/intern/colormanagement.c > > > > Modified: trunk/blender/source/blender/editors/include/BIF_glutil.h > > =================================================================== > > --- trunk/blender/source/blender/editors/include/BIF_glutil.h 2013-04-02 > 17:28:29 UTC (rev 55732) > > +++ trunk/blender/source/blender/editors/include/BIF_glutil.h 2013-04-02 > 17:28:37 UTC (rev 55733) > > @@ -33,6 +33,9 @@ > > struct rcti; > > struct rctf; > > > > +struct ImBuf; > > +struct bContext; > > + > > void fdrawbezier(float vec[4][3]); > > void fdrawline(float x1, float y1, float x2, float y2); > > void fdrawbox(float x1, float y1, float x2, float y2); > > @@ -223,5 +226,13 @@ > > } bglMats; > > void bgl_get_mats(bglMats *mats); > > > > +/* **** Color management helper functions for GLSL display/transform > ***** */ > > + > > +/* Draw imbuf on a screen, preferably using GLSL display transform */ > > +void glaDrawImBuf_glsl_ctx(const struct bContext *C, struct ImBuf > *ibuf, float x, float y, int zoomfilter); > > + > > +/* Transform buffer from role to scene linear space using GLSL OCIO > conversion */ > > +int glaBufferTransformFromRole_glsl(float *buffer, int width, int > height, int role); > > + > > #endif /* __BIF_GLUTIL_H__ */ > > > > > > Modified: trunk/blender/source/blender/editors/render/render_internal.c > > =================================================================== > > --- trunk/blender/source/blender/editors/render/render_internal.c > 2013-04-02 17:28:29 UTC (rev 55732) > > +++ trunk/blender/source/blender/editors/render/render_internal.c > 2013-04-02 17:28:37 UTC (rev 55733) > > @@ -140,15 +140,23 @@ > > } > > } > > if (rectf == NULL) return; > > - > > - if (ibuf->rect == NULL) > > - imb_addrectImBuf(ibuf); > > > > rectf += 4 * (rr->rectx * ymin + xmin); > > > > - IMB_partial_display_buffer_update(ibuf, rectf, NULL, rr->rectx, > rxmin, rymin, > > - &scene->view_settings, > &scene->display_settings, > > - rxmin, rymin, rxmin + xmax, > rymin + ymax, TRUE); > > + if (ibuf->rect) { > > + IMB_partial_display_buffer_update(ibuf, rectf, NULL, > rr->rectx, rxmin, rymin, > > + &scene->view_settings, > &scene->display_settings, > > + rxmin, rymin, rxmin + > xmax, rymin + ymax, TRUE); > > + } > > + > > + /* update float buffer as well, so fast GLSL display could use it > > + * > > + * TODO(sergey): not actually sure it is nice thing to modify > something here > > + * but ibuf->rect used to be modified here > > + */ > > + IMB_buffer_float_from_float(ibuf->rect_float + 4 * (ibuf->x * > rymin + rxmin), rectf, > > + 4, IB_PROFILE_LINEAR_RGB, > IB_PROFILE_LINEAR_RGB, FALSE, > > + xmax, ymax, ibuf->x, rr->rectx); > > } > > > > /* ****************************** render invoking ***************** */ > > > > Modified: trunk/blender/source/blender/editors/render/render_opengl.c > > =================================================================== > > --- trunk/blender/source/blender/editors/render/render_opengl.c > 2013-04-02 17:28:29 UTC (rev 55732) > > +++ trunk/blender/source/blender/editors/render/render_opengl.c > 2013-04-02 17:28:37 UTC (rev 55733) > > @@ -69,6 +69,8 @@ > > #include "RNA_access.h" > > #include "RNA_define.h" > > > > +#include "BIF_gl.h" > > +#include "BIF_glutil.h" > > > > #include "GPU_extensions.h" > > > > @@ -261,11 +263,14 @@ > > */ > > > > if (!oglrender->is_sequencer) { > > - /* sequencer has got tricker ocnversion happened above */ > > - > > - IMB_buffer_float_from_float(rr->rectf, rr->rectf, > > - 4, IB_PROFILE_LINEAR_RGB, > IB_PROFILE_SRGB, TRUE, > > - oglrender->sizex, > oglrender->sizey, oglrender->sizex, oglrender->sizex); > > + /* sequencer has got trickier conversion happened above > > + * also assume opengl's space matches byte buffer color > space > > + */ > > + if (!glaBufferTransformFromRole_glsl(rr->rectf, > oglrender->sizex, oglrender->sizey, COLOR_ROLE_DEFAULT_BYTE)) { > > + IMB_buffer_float_from_float(rr->rectf, rr->rectf, > > + 4, > IB_PROFILE_LINEAR_RGB, IB_PROFILE_SRGB, TRUE, > > + oglrender->sizex, > oglrender->sizey, oglrender->sizex, oglrender->sizex); > > + } > > } > > > > /* rr->rectf is now filled with image data */ > > > > Modified: trunk/blender/source/blender/editors/screen/CMakeLists.txt > > =================================================================== > > --- trunk/blender/source/blender/editors/screen/CMakeLists.txt > 2013-04-02 17:28:29 UTC (rev 55732) > > +++ trunk/blender/source/blender/editors/screen/CMakeLists.txt > 2013-04-02 17:28:37 UTC (rev 55733) > > @@ -25,6 +25,7 @@ > > ../../blenlib > > ../../blenloader > > ../../bmesh > > + ../../gpu > > ../../imbuf > > ../../makesdna > > ../../makesrna > > > > Modified: trunk/blender/source/blender/editors/screen/glutil.c > > =================================================================== > > --- trunk/blender/source/blender/editors/screen/glutil.c 2013-04-02 > 17:28:29 UTC (rev 55732) > > +++ trunk/blender/source/blender/editors/screen/glutil.c 2013-04-02 > 17:28:37 UTC (rev 55733) > > @@ -43,10 +43,16 @@ > > > > #include "BKE_blender.h" > > #include "BKE_colortools.h" > > +#include "BKE_context.h" > > > > #include "BIF_gl.h" > > #include "BIF_glutil.h" > > > > +#include "GPU_extensions.h" > > + > > +#include "IMB_colormanagement.h" > > +#include "IMB_imbuf_types.h" > > + > > #ifndef GL_CLAMP_TO_EDGE > > #define GL_CLAMP_TO_EDGE 0x812F > > #endif > > @@ -983,3 +989,89 @@ > > #endif > > } > > #endif > > + > > +/* **** Color management helper functions for GLSL display/transform > ***** */ > > + > > +/* Draw given image buffer on a screen using GLSL for display transform > */ > > +void glaDrawImBuf_glsl_ctx(const bContext *C, ImBuf *ibuf, float x, > float y, int zoomfilter) > > +{ > > + bool need_fallback = true; > > + > > + /* Bytes and dithering are not supported on GLSL yet */ > > + if (ibuf->rect_float && ibuf->dither == 0.0f) { > > + if (IMB_colormanagement_setup_glsl_draw_from_ctx(C)) { > > + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, > GL_MODULATE); > > + glColor4f(1.0, 1.0, 1.0, 1.0); > > + > > + glaDrawPixelsTex(x, y, ibuf->x, ibuf->y, GL_FLOAT, > zoomfilter, ibuf->rect_float); > > + > > + IMB_colormanagement_finish_glsl_draw(); > > + > > + need_fallback = false; > > + } > > + } > > + > > + if (need_fallback) { > > + unsigned char *display_buffer; > > + void *cache_handle; > > + > > + display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, > &cache_handle); > > + > > + if (display_buffer) > > + glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, > GL_UNSIGNED_BYTE, zoomfilter, display_buffer); > > + > > + IMB_display_buffer_release(cache_handle); > > + } > > +} > > + > > +/* Transform buffer from role to scene linear space using GLSL OCIO > conversion > > + * > > + * See IMB_colormanagement_setup_transform_from_role_glsl description > for > > + * some more details > > + */ > > +int glaBufferTransformFromRole_glsl(float *buffer, int width, int > height, int role) > > +{ > > + GPUOffScreen *ofs; > > + char err_out[256]; > > + rcti display_rect; > > + > > + ofs = GPU_offscreen_create(width, height, err_out); > > + > > + if (!ofs) > > + return FALSE; > > + > > + GPU_offscreen_bind(ofs); > > + > > + if (!IMB_colormanagement_setup_transform_from_role_glsl(role)) { > > + GPU_offscreen_unbind(ofs); > > + GPU_offscreen_free(ofs); > > + return FALSE; > > + } > > + > > + BLI_rcti_init(&display_rect, 0, width, 0, height); > > + > > + glMatrixMode(GL_PROJECTION); > > + glPushMatrix(); > > + glMatrixMode(GL_MODELVIEW); > > + glPushMatrix(); > > + > > + glaDefine2DArea(&display_rect); > > + glLoadIdentity(); > > + > > + glaDrawPixelsTex(0, 0, width, height, GL_FLOAT, GL_NEAREST, > buffer); > > + > > + glMatrixMode(GL_PROJECTION); > > + glPopMatrix(); > > + glMatrixMode(GL_MODELVIEW); > > + glPopMatrix(); > > + > > + GPU_offscreen_read_pixels(ofs, GL_FLOAT, buffer); > > + > > + IMB_colormanagement_finish_glsl_transform(); > > + > > + /* unbind */ > > + GPU_offscreen_unbind(ofs); > > + GPU_offscreen_free(ofs); > > + > > + return TRUE; > > +} > > > > Modified: trunk/blender/source/blender/editors/space_clip/clip_draw.c > > =================================================================== > > --- trunk/blender/source/blender/editors/space_clip/clip_draw.c > 2013-04-02 17:28:29 UTC (rev 55732) > > +++ trunk/blender/source/blender/editors/space_clip/clip_draw.c > 2013-04-02 17:28:37 UTC (rev 55733) > > @@ -248,53 +248,6 @@ > > ED_region_info_draw(ar, str, block, 0.6f); > > } > > > > -static void draw_movieclip_buffer_glsl(SpaceClip *sc, ImBuf *ibuf, int > x, int y, > > - float zoomx, float zoomy) > > -{ > > - MovieClip *clip = ED_space_clip_get_clip(sc); > > - int filter = GL_LINEAR; > > - > > - glPushMatrix(); > > - glTranslatef(x, y, 0.0f); > > - glScalef(zoomx, zoomy, 1.0f); > > - > > - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); > > - > > - glColor4f(1.0, 1.0, 1.0, 1.0); > > - > > - /* non-scaled proxy shouldn;t use diltering */ > > - if ((clip->flag & MCLIP_USE_PROXY) == 0 || > > - ELEM(sc->user.render_size, MCLIP_PROXY_RENDER_SIZE_FULL, > MCLIP_PROXY_RENDER_SIZE_100)) > > - { > > - filter = GL_NEAREST; > > - } > > - > > - glaDrawPixelsTex(0, 0, ibuf->x, ibuf->y, GL_FLOAT, filter, > ibuf->rect_float); > > - > > - glPopMatrix(); > > -} > > - > > -static void draw_movieclip_buffer_fallback(const bContext *C, ImBuf > *ibuf, int x, int y, > > - int width, int height, float > zoomx, float zoomy) > > -{ > > - unsigned char *display_buffer; > > - void *cache_handle; > > - > > - display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, > &cache_handle); > > - > > - if (display_buffer) { > > - /* set zoom */ > > - glPixelZoom(zoomx * width / ibuf->x, zoomy * height / > ibuf->y); > > - > > - glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, > GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer); > > - > > - /* reset zoom */ > > - glPixelZoom(1.0f, 1.0f); > > - } > > - > > - IMB_display_buffer_release(cache_handle); > > -} > > - > > static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, > ARegion *ar, ImBuf *ibuf, > > int width, int height, float zoomx, > float zoomy) > > { > > @@ -308,7 +261,8 @@ > > glRectf(x, y, x + zoomx * width, y + zoomy * height); > > } > > else { > > - bool need_fallback = true; > > + MovieClip *clip = ED_space_clip_get_clip(sc); > > + int filter = GL_LINEAR; > > > > /* checkerboard for case alpha */ > > if (ibuf->planes == 32) { > > @@ -318,20 +272,15 @@ > > fdrawcheckerboard(x, y, x + zoomx * ibuf->x, y + > zoomy * ibuf->y); > > } > > > > - /* GLSL display transform for byte buffers is not > supported yet */ > > - if (ibuf->rect_float && > IMB_coloemanagement_setup_glsl_draw_from_ctx(C)) { > > - draw_movieclip_buffer_glsl(sc, ibuf, x, y, zoomx, > zoomy); > > + /* non-scaled proxy shouldn't use filtering */ > > + if ((clip->flag & MCLIP_USE_PROXY) == 0 || > > + ELEM(sc->user.render_size, > MCLIP_PROXY_RENDER_SIZE_FULL, MCLIP_PROXY_RENDER_SIZE_100)) > > + { > > + filter = GL_NEAREST; > > + } > > > > - IMB_coloemanagement_finish_glsl_draw(); > > + glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST); > > > > - need_fallback = false; > > - } > > - > > - /* if GLSL display failed, fallback to regular > glaDrawPixelsAuto method */ > > - if (need_fallback) { > > - draw_movieclip_buffer_fallback(C, ibuf, x, y, > width, height, zoomx, zoomy); > > - } > > - > > > > @@ Diff output truncated at 10240 characters. @@ > > _______________________________________________ > > Bf-blender-cvs mailing list > > [email protected] > > http://lists.blender.org/mailman/listinfo/bf-blender-cvs > > > _______________________________________________ > Bf-committers mailing list > [email protected] > http://lists.blender.org/mailman/listinfo/bf-committers > -- With best regards, Sergey Sharybin _______________________________________________ Bf-committers mailing list [email protected] http://lists.blender.org/mailman/listinfo/bf-committers
