summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/vega/shader.c
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2010-11-29 11:49:18 +0800
committerChia-I Wu <[email protected]>2010-12-01 11:23:52 +0800
commite360f91f152615b35857a4d008d0439a3c3285a8 (patch)
tree0567639af63cafa34dcb26adbb6928432ff1870a /src/gallium/state_trackers/vega/shader.c
parent213e288e78bf5b0fb0a996cc17dfd959756c2c53 (diff)
st/vega: Add color transformation support.
Per OpenVG 1.1. A new shader stage is added. It uses the first two constants of the fragment shader for color transformation parameters.
Diffstat (limited to 'src/gallium/state_trackers/vega/shader.c')
-rw-r--r--src/gallium/state_trackers/vega/shader.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/gallium/state_trackers/vega/shader.c b/src/gallium/state_trackers/vega/shader.c
index 080b37c586e..39c4bb0dfd6 100644
--- a/src/gallium/state_trackers/vega/shader.c
+++ b/src/gallium/state_trackers/vega/shader.c
@@ -38,12 +38,14 @@
#include "pipe/p_state.h"
#include "util/u_inlines.h"
#include "util/u_memory.h"
+#include "util/u_math.h"
-#define MAX_CONSTANTS 20
+#define MAX_CONSTANTS 28
struct shader {
struct vg_context *context;
+ VGboolean color_transform;
VGboolean masking;
struct vg_paint *paint;
struct vg_image *image;
@@ -72,6 +74,11 @@ void shader_destroy(struct shader *shader)
FREE(shader);
}
+void shader_set_color_transform(struct shader *shader, VGboolean set)
+{
+ shader->color_transform = set;
+}
+
void shader_set_masking(struct shader *shader, VGboolean set)
{
shader->masking = set;
@@ -94,10 +101,25 @@ struct vg_paint * shader_paint(struct shader *shader)
static VGint setup_constant_buffer(struct shader *shader)
{
+ const struct vg_state *state = &shader->context->state.vg;
VGint param_bytes = paint_constant_buffer_size(shader->paint);
+ VGint i;
+ param_bytes += sizeof(VGfloat) * 8;
assert(param_bytes <= sizeof(shader->constants));
- paint_fill_constant_buffer(shader->paint, shader->constants);
+
+ if (state->color_transform) {
+ for (i = 0; i < 8; i++) {
+ VGfloat val = (i < 4) ? 127.0f : 1.0f;
+ shader->constants[i] =
+ CLAMP(state->color_transform_values[i], -val, val);
+ }
+ }
+ else {
+ memset(shader->constants, 0, sizeof(VGfloat) * 8);
+ }
+
+ paint_fill_constant_buffer(shader->paint, shader->constants + 8);
return param_bytes;
}
@@ -227,6 +249,9 @@ static void setup_shader_program(struct shader *shader)
}
}
+ if (shader->color_transform)
+ shader_id |= VEGA_COLOR_TRANSFORM_SHADER;
+
if (shader->masking)
shader_id |= VEGA_MASK_SHADER;