[Mesa-dev] [PATCH] gallium postprocess: Add brightness filter
Yaroslav Andrusyak
pontostroy at gmail.com
Sun May 25 03:30:20 PDT 2014
In many games open source video drivers can't adjust screen brightness.It
would be nice to have a way to change the brightness
diff --git src/gallium/auxiliary/postprocess/filters.h
src/gallium/auxiliary/postprocess/filters.h
index 321f333..4423c2e 100644
--- src/gallium/auxiliary/postprocess/filters.h
+++ src/gallium/auxiliary/postprocess/filters.h
@@ -30,7 +30,7 @@
#include "postprocess/postprocess.h"
-#define PP_FILTERS 6 /* Increment this if you add filters */
+#define PP_FILTERS 7 /* Increment this if you add filters */
#define PP_MAX_PASSES 6
@@ -59,6 +59,7 @@ static const struct pp_filter_t pp_filters[PP_FILTERS] = {
{ "pp_celshade", 0, 2, 1, pp_celshade_init, pp_nocolor,
pp_celshade_free },
{ "pp_jimenezmlaa", 2, 5, 2, pp_jimenezmlaa_init, pp_jimenezmlaa,
pp_jimenezmlaa_free },
{ "pp_jimenezmlaa_color", 2, 5, 2, pp_jimenezmlaa_init_color,
pp_jimenezmlaa_color, pp_jimenezmlaa_free },
+ { "pp_bright", 0, 2, 1, pp_bright_init, pp_nocolor,
pp_nocolor_free },
};
#endif
diff --git src/gallium/auxiliary/postprocess/postprocess.h
src/gallium/auxiliary/postprocess/postprocess.h
index c72f2c4..e43241e 100644
--- src/gallium/auxiliary/postprocess/postprocess.h
+++ src/gallium/auxiliary/postprocess/postprocess.h
@@ -78,6 +78,7 @@ bool pp_noblue_init(struct pp_queue_t *, unsigned int,
unsigned int);
bool pp_jimenezmlaa_init(struct pp_queue_t *, unsigned int, unsigned int);
bool pp_jimenezmlaa_init_color(struct pp_queue_t *, unsigned int,
unsigned int);
+bool pp_bright_init(struct pp_queue_t *, unsigned int, unsigned int);
/* The filter free functions */
diff --git src/gallium/auxiliary/postprocess/pp_colors.c
src/gallium/auxiliary/postprocess/pp_colors.c
index 247e4df..9915bd1 100644
--- src/gallium/auxiliary/postprocess/pp_colors.c
+++ src/gallium/auxiliary/postprocess/pp_colors.c
@@ -87,6 +87,16 @@ pp_noblue_init(struct pp_queue_t *ppq, unsigned int n,
unsigned int val)
return (ppq->shaders[n][1] != NULL) ? TRUE : FALSE;
}
+
+bool
+pp_bright_init(struct pp_queue_t *ppq, unsigned int n, unsigned int val)
+{
+ ppq->shaders[n][1] =
+ pp_tgsi_to_state(ppq->p->pipe, bright, false, "bright");
+
+ return (ppq->shaders[n][1] != NULL) ? TRUE : FALSE;
+}
+
/* Free functions */
void
pp_nocolor_free(struct pp_queue_t *ppq, unsigned int n)
diff --git src/gallium/auxiliary/postprocess/pp_colors.h
src/gallium/auxiliary/postprocess/pp_colors.h
index a79858e..66b9690 100644
--- src/gallium/auxiliary/postprocess/pp_colors.h
+++ src/gallium/auxiliary/postprocess/pp_colors.h
@@ -65,5 +65,20 @@ static const char noblue[] = "FRAG\n"
" 1: MOV TEMP[0].z, IMM[0].xxxx\n"
" 2: MOV OUT[0], TEMP[0]\n"
" 3: END\n";
-
+
+
+static const char bright[] = "FRAG\n"
+ "PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n"
+ "DCL IN[0], GENERIC[0], PERSPECTIVE\n"
+ "DCL OUT[0], COLOR\n"
+ "DCL SAMP[0]\n"
+ "DCL TEMP[0..1]\n"
+ "IMM FLT32 { 0.0000, 1.5000, 0.0000, 0.0000}\n"
+ " 0: MOV TEMP[0].w, IMM[0].xxxx\n"
+ " 1: MOV TEMP[1].xy, IN[0].xyyy\n"
+ " 2: TEX TEMP[1].xyz, TEMP[1], SAMP[0], 2D\n"
+ " 3: MUL TEMP[0].xyz, TEMP[1].xyzz, IMM[0].yyyy\n"
+ " 4: MOV OUT[0], TEMP[0]\n"
+ " 5: END\n";
+
#endif
diff --git src/gallium/state_trackers/dri/common/dri_screen.c
src/gallium/state_trackers/dri/common/dri_screen.c
index 7a6dcb2..66cf785 100644
--- src/gallium/state_trackers/dri/common/dri_screen.c
+++ src/gallium/state_trackers/dri/common/dri_screen.c
@@ -58,6 +58,7 @@ const __DRIconfigOptionsExtension gallium_config_options
= {
DRI_CONF_PP_NORED(0)
DRI_CONF_PP_NOGREEN(0)
DRI_CONF_PP_NOBLUE(0)
+ DRI_CONF_PP_BRIGHT(0)
DRI_CONF_PP_JIMENEZMLAA(0, 0, 32)
DRI_CONF_PP_JIMENEZMLAA_COLOR(0, 0, 32)
DRI_CONF_SECTION_END
diff --git src/mesa/drivers/dri/common/xmlpool/t_options.h
src/mesa/drivers/dri/common/xmlpool/t_options.h
index 3bf804a..bd428c2 100644
--- src/mesa/drivers/dri/common/xmlpool/t_options.h
+++ src/mesa/drivers/dri/common/xmlpool/t_options.h
@@ -195,6 +195,11 @@ DRI_CONF_OPT_BEGIN_V(pp_nored,enum,def,"0:1") \
DRI_CONF_DESC(en,gettext("A post-processing filter to remove the
red channel")) \
DRI_CONF_OPT_END
+#define DRI_CONF_PP_BRIGHT(def) \
+DRI_CONF_OPT_BEGIN_V(pp_bright,enum,def,"0:1") \
+ DRI_CONF_DESC(en,gettext("A post-processing filter to adjust
brightness")) \
+DRI_CONF_OPT_END
+
#define DRI_CONF_PP_NOGREEN(def) \
DRI_CONF_OPT_BEGIN_V(pp_nogreen,enum,def,"0:1") \
DRI_CONF_DESC(en,gettext("A post-processing filter to remove the
green channel")) \
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140525/4f14f1e4/attachment-0001.html>
More information about the mesa-dev
mailing list