diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-08-31 03:49:35 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-08-31 03:49:35 +0400 |
commit | 60ff60dcdc9f43891fb8a19e10f9bb7964a539bf (patch) | |
tree | ced8e2887295b713d67dfd496728703c71f53442 /source/blender/makesrna | |
parent | 6785874e7adf5ef15e7a28b134b2bd4e8b3a8988 (diff) |
RenderEngine API: add viewport draw utility functions to bind a GLSL fragment
shader for converting colors from linear to display space, based on the scene
color management settings.
if engine.support_display_space_shader(scene): # test graphics card support
engine.bind_display_space_shader(scene)
# draw pixels ..
engine.unbind_display_space_shader()
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_color.c | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_render.c | 47 |
2 files changed, 46 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index ebd06475c79..933f06cec8c 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -584,6 +584,7 @@ static void rna_ColorManagement_update(Main *UNUSED(bmain), Scene *UNUSED(scene) return; if (GS(id->name) == ID_SCE) { + DAG_id_tag_update(id, 0); WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL); } } diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index 82cdfcdd631..5b809a51705 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -49,6 +49,9 @@ #include "BKE_context.h" #include "BKE_report.h" +#include "IMB_colormanagement.h" +#include "GPU_extensions.h" + /* RenderEngine Callbacks */ static void engine_tag_redraw(RenderEngine *engine) @@ -61,6 +64,23 @@ static void engine_tag_update(RenderEngine *engine) engine->flag |= RE_ENGINE_DO_UPDATE; } +static int engine_support_display_space_shader(RenderEngine *UNUSED(engine), Scene *scene) +{ + return IMB_colormanagement_support_glsl_draw(&scene->view_settings, true); +} + +static void engine_bind_display_space_shader(RenderEngine *UNUSED(engine), Scene *scene) +{ + IMB_colormanagement_setup_glsl_draw(&scene->view_settings, + &scene->display_settings, + false, true); +} + +static void engine_unbind_display_space_shader(RenderEngine *UNUSED(engine)) +{ + IMB_colormanagement_finish_glsl_draw(); +} + static void engine_update(RenderEngine *engine, Main *bmain, Scene *scene) { extern FunctionRNA rna_RenderEngine_update_func; @@ -342,14 +362,15 @@ static void rna_def_render_engine(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_RNAPTR); /* tag for redraw */ - RNA_def_function(srna, "tag_redraw", "engine_tag_redraw"); + func = RNA_def_function(srna, "tag_redraw", "engine_tag_redraw"); RNA_def_function_ui_description(func, "Request redraw for viewport rendering"); /* tag for update */ - RNA_def_function(srna, "tag_update", "engine_tag_update"); + func = RNA_def_function(srna, "tag_update", "engine_tag_update"); RNA_def_function_ui_description(func, "Request update call for viewport rendering"); func = RNA_def_function(srna, "begin_result", "RE_engine_begin_result"); + RNA_def_function_ui_description(func, "Create render result to write linear floating point render layers and passes"); prop = RNA_def_int(func, "x", 0, 0, INT_MAX, "X", "", 0, INT_MAX); RNA_def_property_flag(prop, PROP_REQUIRED); prop = RNA_def_int(func, "y", 0, 0, INT_MAX, "Y", "", 0, INT_MAX); @@ -363,39 +384,61 @@ static void rna_def_render_engine(BlenderRNA *brna) RNA_def_function_return(func, prop); func = RNA_def_function(srna, "update_result", "RE_engine_update_result"); + RNA_def_function_ui_description(func, "Signal that pixels have been updated and can be redrawn in the user interface"); prop = RNA_def_pointer(func, "result", "RenderResult", "Result", ""); RNA_def_property_flag(prop, PROP_REQUIRED); func = RNA_def_function(srna, "end_result", "RE_engine_end_result"); + RNA_def_function_ui_description(func, "All pixels in the render result have been set and are final"); prop = RNA_def_pointer(func, "result", "RenderResult", "Result", ""); RNA_def_property_flag(prop, PROP_REQUIRED); RNA_def_boolean(func, "cancel", 0, "Cancel", "Don't merge back results"); func = RNA_def_function(srna, "test_break", "RE_engine_test_break"); + RNA_def_function_ui_description(func, "Test if the render operation should been cancelled, this is a fast call that should be used regularly for responsiveness"); prop = RNA_def_boolean(func, "do_break", 0, "Break", ""); RNA_def_function_return(func, prop); func = RNA_def_function(srna, "update_stats", "RE_engine_update_stats"); + RNA_def_function_ui_description(func, "Update and signal to redraw render status text"); prop = RNA_def_string(func, "stats", "", 0, "Stats", ""); RNA_def_property_flag(prop, PROP_REQUIRED); prop = RNA_def_string(func, "info", "", 0, "Info", ""); RNA_def_property_flag(prop, PROP_REQUIRED); func = RNA_def_function(srna, "update_progress", "RE_engine_update_progress"); + RNA_def_function_ui_description(func, "Update progress percentage of render"); prop = RNA_def_float(func, "progress", 0, 0.0f, 1.0f, "", "Percentage of render that's done", 0.0f, 1.0f); RNA_def_property_flag(prop, PROP_REQUIRED); func = RNA_def_function(srna, "update_memory_stats", "RE_engine_update_memory_stats"); + RNA_def_function_ui_description(func, "Update memory usage statistics"); RNA_def_float(func, "memory_used", 0, 0.0f, FLT_MAX, "", "Current memory usage in megabytes", 0.0f, FLT_MAX); RNA_def_float(func, "memory_peak", 0, 0.0f, FLT_MAX, "", "Peak memory usage in megabytes", 0.0f, FLT_MAX); RNA_def_property_flag(prop, PROP_REQUIRED); func = RNA_def_function(srna, "report", "RE_engine_report"); + RNA_def_function_ui_description(func, "Report info, warning or error messages"); prop = RNA_def_enum_flag(func, "type", wm_report_items, 0, "Type", ""); RNA_def_property_flag(prop, PROP_REQUIRED); prop = RNA_def_string(func, "message", "", 0, "Report Message", ""); RNA_def_property_flag(prop, PROP_REQUIRED); + func = RNA_def_function(srna, "bind_display_space_shader", "engine_bind_display_space_shader"); + RNA_def_function_ui_description(func, "Bind GLSL fragment shader that converts linear colors to display space colors using scene color management settings"); + prop = RNA_def_pointer(func, "scene", "Scene", "", ""); + RNA_def_property_flag(prop, PROP_REQUIRED); + + func = RNA_def_function(srna, "unbind_display_space_shader", "engine_unbind_display_space_shader"); + RNA_def_function_ui_description(func, "Unbind GLSL display space shader, must always be called after binding the shader"); + + func = RNA_def_function(srna, "support_display_space_shader", "engine_support_display_space_shader"); + RNA_def_function_ui_description(func, "Test if GLSL display space shader is supported for the combination of graphics card and scene settings"); + prop = RNA_def_pointer(func, "scene", "Scene", "", ""); + RNA_def_property_flag(prop, PROP_REQUIRED); + prop = RNA_def_boolean(func, "supported", 0, "Supported", ""); + RNA_def_function_return(func, prop); + RNA_define_verify_sdna(0); prop = RNA_def_property(srna, "is_animation", PROP_BOOLEAN, PROP_NONE); |