From 4e9fffc2892601b3b11366f115f342ebeeb026f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 25 Feb 2020 15:05:53 +0100 Subject: GPU: Add Image property to allow high bitdepth support on a per image basis This adds the `Half Float Precision` option in the image property panel. This option is only available on float textures and is enabled by default. Adding a flag inside the imbuf (IB_halffloat) on load is done for EXR and PSD formats that can store half floating point (16bits/channels). The option is then not displayed in this case and forced. Related task T73086 Reviewed By: brecht Differential Revision: https://developer.blender.org/D6891 --- source/blender/makesrna/intern/rna_image.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'source/blender/makesrna/intern/rna_image.c') diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 9f5f1635536..94b5786665c 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -193,6 +193,17 @@ static char *rna_ImageUser_path(PointerRNA *ptr) return BLI_strdup(""); } +static void rna_Image_gpu_texture_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Image *ima = (Image *)ptr->owner_id; + + if (!G.background) { + GPU_free_image(ima); + } + + WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, &ima->id); +} + static const EnumPropertyItem *rna_Image_source_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), @@ -1119,6 +1130,13 @@ static void rna_def_image(BlenderRNA *brna) "when saving and loading the image"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_colormanage_update"); + prop = RNA_def_property(srna, "use_half_precision", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMA_HIGH_BITDEPTH); + RNA_def_property_ui_text(prop, + "Half Float Precision", + "Use 16bits per channel to lower the memory usage during rendering"); + RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_gpu_texture_update"); + /* multiview */ prop = RNA_def_property(srna, "views_format", PROP_ENUM, PROP_NONE); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); -- cgit v1.2.3