[cairo-commit]
glitz/src glitz_program.c, 1.6, 1.7 glitzint.h, 1.10, 1.11
David Reveman
commit at pdx.freedesktop.org
Tue May 11 01:48:56 PDT 2004
Committed by: davidr
Update of /cvs/cairo/glitz/src
In directory pdx:/tmp/cvs-serv11951/src
Modified Files:
glitz_program.c glitzint.h
Log Message:
Convolution filter optimizations
Index: glitz_program.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_program.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** a/glitz_program.c 9 May 2004 20:54:51 -0000 1.6
--- b/glitz_program.c 11 May 2004 08:48:53 -0000 1.7
***************
*** 170,175 ****
"END";
/*
! * 3x3 convolution filter.
* Convolution kernel must be normalized.
*
--- 170,180 ----
"END";
+ typedef enum {
+ GLITZ_CONVOLUTION_3X3_GENERAL = 1,
+ GLITZ_CONVOLUTION_3X3_SIMPLE = 2
+ } glitz_convolution_type_t;
+
/*
! * General 3x3 convolution filter.
* Convolution kernel must be normalized.
*
***************
*** 240,243 ****
--- 245,297 ----
"END";
+ /*
+ * Simple 3x3 convolution filter (corners are zero).
+ * Convolution kernel must be normalized.
+ *
+ * program.local[0]: Top convolution kernel row
+ * program.local[1]: Middle convolution kernel row
+ * program.local[2]: Bottom convolution kernel row
+ *
+ * Author: David Reveman <c99drn at cs.umu.se>
+ */
+ static char *_glitz_fragment_program_convolution_simple =
+ "!!ARBfp1.0\n"
+ "ATTRIB east = fragment.texcoord[2];\n"
+ "ATTRIB west = fragment.texcoord[3];\n"
+ "ATTRIB south = fragment.texcoord[4];\n"
+ "ATTRIB north = fragment.texcoord[5];\n"
+ "PARAM k0 = program.local[0];\n"
+ "PARAM k1 = program.local[1];\n"
+ "PARAM k2 = program.local[2];\n"
+ "TEMP color, in, coord;\n"
+
+ /* temporary */
+ "%s"
+
+ /* center */
+ "TEX in, fragment.texcoord[%d], texture[%d], %s;\n"
+ "MUL color, in, k1.y;\n"
+
+ /* north */
+ "TEX in, north, texture[%d], %s;\n"
+ "MAD color, in, k0.y, color;\n"
+
+ /* east */
+ "TEX in, east, texture[%d], %s;\n"
+ "MAD color, in, k1.x, color;\n"
+
+ /* south */
+ "TEX in, south, texture[%d], %s;\n"
+ "MAD color, in, k2.y, color;\n"
+
+ /* west */
+ "TEX in, west, texture[%d], %s;\n"
+ "MAD color, in, k1.x, color;\n"
+
+ /* pd operation */
+ "%s"
+
+ "END";
+
char *_glitz_fragment_program_programmatic[] = {
/*
***************
*** 504,508 ****
glitz_program_compile_convolution (glitz_gl_proc_address_list_t *gl,
int offset,
! int solid_offset)
{
char *solid_op_table[] = {
--- 558,563 ----
glitz_program_compile_convolution (glitz_gl_proc_address_list_t *gl,
int offset,
! int solid_offset,
! glitz_convolution_type_t type)
{
char *solid_op_table[] = {
***************
*** 522,538 ****
}
! sprintf (program_buffer,
! _glitz_fragment_program_convolution,
! temporary,
! expand->index, expand->index, expand->tex,
! expand->index, expand->tex,
! expand->index, expand->tex,
! expand->index, expand->tex,
! expand->index, expand->tex,
! expand->index, expand->tex,
! expand->index, expand->tex,
! expand->index, expand->tex,
! expand->index, expand->tex,
! operation);
return glitz_program_compile_fragment_arb (gl, program_buffer);
--- 577,608 ----
}
! switch (type) {
! case GLITZ_CONVOLUTION_3X3_GENERAL:
! sprintf (program_buffer,
! _glitz_fragment_program_convolution,
! temporary,
! expand->index, expand->index, expand->tex,
! expand->index, expand->tex,
! expand->index, expand->tex,
! expand->index, expand->tex,
! expand->index, expand->tex,
! expand->index, expand->tex,
! expand->index, expand->tex,
! expand->index, expand->tex,
! expand->index, expand->tex,
! operation);
! break;
! case GLITZ_CONVOLUTION_3X3_SIMPLE:
! sprintf (program_buffer,
! _glitz_fragment_program_convolution_simple,
! temporary,
! expand->index, expand->index, expand->tex,
! expand->index, expand->tex,
! expand->index, expand->tex,
! expand->index, expand->tex,
! expand->index, expand->tex,
! operation);
! break;
! }
return glitz_program_compile_fragment_arb (gl, program_buffer);
***************
*** 605,608 ****
--- 675,679 ----
glitz_surface_t *surface;
int fragment_offset, vertex_offset = (offset)? 1: 0;
+ glitz_convolution_type_t type;
if (offset) {
***************
*** 616,620 ****
offset += _glitz_program_offset (src_texture, mask_texture);
! fragment_offset = offset + GLITZ_FRAGMENT_PROGRAM_TYPES * solid_offset;
if (!programs->vertex_convolution[vertex_offset])
--- 687,700 ----
offset += _glitz_program_offset (src_texture, mask_texture);
! if (surface->convolution->m[0][0] == 0.0 &&
! surface->convolution->m[0][2] == 0.0 &&
! surface->convolution->m[2][2] == 0.0 &&
! surface->convolution->m[2][0] == 0.0)
! type = GLITZ_CONVOLUTION_3X3_SIMPLE;
! else
! type = GLITZ_CONVOLUTION_3X3_GENERAL;
!
! fragment_offset = GLITZ_FRAGMENT_PROGRAM_TYPES * solid_offset * type +
! offset;
if (!programs->vertex_convolution[vertex_offset])
***************
*** 624,628 ****
if (!programs->fragment_convolution[fragment_offset])
programs->fragment_convolution[fragment_offset] =
! glitz_program_compile_convolution (gl, offset, solid_offset);
if (programs->fragment_convolution[fragment_offset] &&
--- 704,708 ----
if (!programs->fragment_convolution[fragment_offset])
programs->fragment_convolution[fragment_offset] =
! glitz_program_compile_convolution (gl, offset, solid_offset, type);
if (programs->fragment_convolution[fragment_offset] &&
Index: glitzint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitzint.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** a/glitzint.h 10 May 2004 21:00:31 -0000 1.10
--- b/glitzint.h 11 May 2004 08:48:53 -0000 1.11
***************
*** 182,185 ****
--- 182,189 ----
#define GLITZ_VERTEX_PROGRAM_TYPES 2
#define GLITZ_FRAGMENT_PROGRAM_TYPES 18
+
+ #define GLITZ_CONVOLUTION_TYPES 2
+ #define GLITZ_FRAGMENT_CONVOLUTION_PROGRAM_TYPES \
+ (GLITZ_FRAGMENT_PROGRAM_TYPES * GLITZ_CONVOLUTION_TYPES * 3)
#define GLITZ_FRAGMENT_PROGRAMMATIC_PROGRAM_TYPES \
(GLITZ_FRAGMENT_PROGRAM_TYPES * GLITZ_PROGRAMMATIC_SURFACE_NUM)
***************
*** 188,192 ****
glitz_gl_uint_t vertex_convolution[GLITZ_VERTEX_PROGRAM_TYPES];
glitz_gl_uint_t fragment_simple[GLITZ_FRAGMENT_PROGRAM_TYPES];
! glitz_gl_uint_t fragment_convolution[GLITZ_FRAGMENT_PROGRAM_TYPES * 3];
glitz_gl_uint_t
fragment_programmatic[GLITZ_FRAGMENT_PROGRAMMATIC_PROGRAM_TYPES];
--- 192,197 ----
glitz_gl_uint_t vertex_convolution[GLITZ_VERTEX_PROGRAM_TYPES];
glitz_gl_uint_t fragment_simple[GLITZ_FRAGMENT_PROGRAM_TYPES];
! glitz_gl_uint_t
! fragment_convolution[GLITZ_FRAGMENT_CONVOLUTION_PROGRAM_TYPES];
glitz_gl_uint_t
fragment_programmatic[GLITZ_FRAGMENT_PROGRAMMATIC_PROGRAM_TYPES];
More information about the cairo-commit
mailing list