Commit ee33c947 authored by Zhigang Gong's avatar Zhigang Gong

glamor-es: Use glVertexAttribPointer to replace glVertexPointer.

As GLES2 doesn't support glVertexPointer.
Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
parent 94d884a1
......@@ -176,29 +176,46 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
pixmap_priv_get_scale(dst_pixmap_priv, &dst_xscale, &dst_yscale);
pixmap_priv_get_scale(src_pixmap_priv, &src_xscale, &src_yscale);
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
#if 0
glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, vertices);
glEnableClientState(GL_VERTEX_ARRAY);
#else
glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, GL_FALSE,
2 * sizeof(float),
vertices);
glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
#endif
if (GLAMOR_PIXMAP_PRIV_NO_PENDING(src_pixmap_priv)) {
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
dx += src_x_off;
dy += src_y_off;
pixmap_priv_get_scale(src_pixmap_priv, &src_xscale, &src_yscale);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, src_pixmap_priv->tex);
glEnable(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
#if 0
glClientActiveTexture(GL_TEXTURE0);
glTexCoordPointer(2, GL_FLOAT, sizeof(float) * 2, texcoords);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glUseProgram(glamor_priv->finish_access_prog[0]);
}
#else
glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT, GL_FALSE,
2 * sizeof(float),
texcoords);
glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
glUseProgram(glamor_priv->finish_access_prog[2]);
#endif
}
else {
GLAMOR_CHECK_PENDING_FILL(glamor_priv, src_pixmap_priv);
}
......@@ -223,13 +240,20 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
glUseProgram(0);
#if 0
glDisableClientState(GL_VERTEX_ARRAY);
if (GLAMOR_PIXMAP_PRIV_NO_PENDING(src_pixmap_priv)) {
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable(GL_TEXTURE_2D);
}
#else
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
if (GLAMOR_PIXMAP_PRIV_NO_PENDING(src_pixmap_priv)) {
glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
glDisable(GL_TEXTURE_2D);
}
#endif
glUseProgram(0);
/* The source texture is bound to a fbo, we have to flush it here. */
if (flush_needed)
glFlush();
......
......@@ -162,11 +162,42 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
"{\n"
" gl_FragColor = vec4(texture2D(sampler, gl_TexCoord[0].xy).rgb, 1);\n"
"}\n";
const char *es_vs_source =
"attribute vec4 v_position;\n"
"attribute vec4 v_texcoord0;\n"
"varying vec2 source_texture;\n"
"void main()\n"
"{\n"
" gl_Position = v_position;\n"
" source_texture = v_texcoord0.xy;\n"
"}\n";
const char *es_fs_source =
"varying vec2 source_texture;\n"
"uniform sampler2D sampler;\n"
"void main()\n"
"{\n"
" gl_FragColor = texture2D(sampler, source_texture);\n"
"}\n";
const char *es_aswizzle_source =
"varying vec2 source_texture;\n"
"varying vec2 texcoords;\n"
"uniform sampler2D sampler;\n"
"void main()\n"
"{\n"
" gl_FragColor = vec4(texture2D(sampler, source_texture).rgb, 1);\n"
"}\n";
GLint fs_prog, vs_prog, avs_prog, aswizzle_prog;
GLint es_fs_prog, es_vs_prog, es_avs_prog, es_aswizzle_prog;
glamor_priv->finish_access_prog[0] = glCreateProgram();
glamor_priv->finish_access_prog[1] = glCreateProgram();
glamor_priv->finish_access_prog[2] = glCreateProgram();
glamor_priv->finish_access_prog[3] = glCreateProgram();
if (GLEW_ARB_fragment_shader) {
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, vs_source);
......@@ -178,15 +209,36 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
aswizzle_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, aswizzle_source);
glAttachShader(glamor_priv->finish_access_prog[1], avs_prog);
glAttachShader(glamor_priv->finish_access_prog[1], aswizzle_prog);
es_vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, es_vs_source);
es_fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, es_fs_source);
glAttachShader(glamor_priv->finish_access_prog[2], es_vs_prog);
glAttachShader(glamor_priv->finish_access_prog[2], es_fs_prog);
es_avs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, es_vs_source);
es_aswizzle_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, es_aswizzle_source);
glAttachShader(glamor_priv->finish_access_prog[3], es_avs_prog);
glAttachShader(glamor_priv->finish_access_prog[3], es_aswizzle_prog);
} else {
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, vs_source);
glAttachShader(glamor_priv->finish_access_prog[0], vs_prog);
ErrorF("Lack of framgment shader support.\n");
}
glamor_link_glsl_prog(glamor_priv->finish_access_prog[0]);
glamor_link_glsl_prog(glamor_priv->finish_access_prog[1]);
glBindAttribLocation(glamor_priv->finish_access_prog[2], GLAMOR_VERTEX_POS, "v_position");
glBindAttribLocation(glamor_priv->finish_access_prog[2], GLAMOR_VERTEX_SOURCE, "v_texcoord0");
glamor_link_glsl_prog(glamor_priv->finish_access_prog[2]);
glBindAttribLocation(glamor_priv->finish_access_prog[3], GLAMOR_VERTEX_POS, "v_position");
glBindAttribLocation(glamor_priv->finish_access_prog[3], GLAMOR_VERTEX_SOURCE, "v_texcoord0");
glamor_link_glsl_prog(glamor_priv->finish_access_prog[3]);
if (GLEW_ARB_fragment_shader) {
GLint sampler_uniform_location;
......@@ -201,6 +253,19 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
glUseProgram(glamor_priv->finish_access_prog[1]);
glUniform1i(sampler_uniform_location, 0);
glUseProgram(0);
sampler_uniform_location =
glGetUniformLocation(glamor_priv->finish_access_prog[2], "sampler");
glUseProgram(glamor_priv->finish_access_prog[2]);
glUniform1i(sampler_uniform_location, 0);
glUseProgram(0);
sampler_uniform_location =
glGetUniformLocation(glamor_priv->finish_access_prog[3], "sampler");
glUseProgram(glamor_priv->finish_access_prog[3]);
glUniform1i(sampler_uniform_location, 0);
glUseProgram(0);
}
}
......
......@@ -103,16 +103,32 @@ glamor_init_solid_shader(ScreenPtr screen)
{
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
const char *solid_vs_only =
#if 0
#else
"attribute vec4 v_position;"
#endif
"uniform vec4 color;\n"
"void main()\n"
"{\n"
#if 0
" gl_Position = gl_Vertex;\n"
#else
" gl_Position = v_position;\n"
#endif
" gl_Color = color;\n"
"}\n";
const char *solid_vs =
#if 0
#else
"attribute vec4 v_position;"
#endif
"void main()\n"
"{\n"
#if 0
" gl_Position = gl_Vertex;\n"
#else
" gl_Position = v_position;\n"
#endif
"}\n";
const char *solid_fs =
"uniform vec4 color;\n"
......@@ -132,6 +148,8 @@ glamor_init_solid_shader(ScreenPtr screen)
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, solid_vs_only);
glAttachShader(glamor_priv->solid_prog, vs_prog);
}
glBindAttribLocation(glamor_priv->solid_prog, GLAMOR_VERTEX_POS, "v_position");
glamor_link_glsl_prog(glamor_priv->solid_prog);
glamor_priv->solid_color_uniform_location =
......@@ -188,17 +206,25 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
glUniform4fv(glamor_priv->solid_color_uniform_location, 1, color);
#if 0
glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, vertices);
glEnableClientState(GL_VERTEX_ARRAY);
#else
glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, GL_FALSE,
2 * sizeof(float), vertices);
glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
#endif
pixmap_priv_get_scale(pixmap_priv, &xscale, &yscale);
glamor_set_normalize_vcoords(xscale, yscale, x1, y1, x2, y2,
glamor_priv->yInverted,
vertices);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
#if 0
glDisableClientState(GL_VERTEX_ARRAY);
#else
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
#endif
glUseProgram(0);
return TRUE;
fail:
......
......@@ -32,9 +32,14 @@ _glamor_pixmap_validate_filling(glamor_screen_private *glamor_priv,
glamor_pixmap_private *pixmap_priv)
{
GLfloat vertices[8];
// glamor_set_destination_pixmap_priv_nc(pixmap_priv);
#if 0
glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, vertices);
glEnableClientState(GL_VERTEX_ARRAY);
#else
glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, GL_FALSE,
2 * sizeof(float), vertices);
glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
#endif
glUseProgram(glamor_priv->solid_prog);
glUniform4fv(glamor_priv->solid_color_uniform_location,
1, pixmap_priv->pending_op.fill.color4fv);
......@@ -47,7 +52,11 @@ _glamor_pixmap_validate_filling(glamor_screen_private *glamor_priv,
vertices[6] = -1;
vertices[7] = 1;
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
#if 0
glDisableClientState(GL_VERTEX_ARRAY);
#else
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
#endif
glUseProgram(0);
pixmap_priv->pending_op.type = GLAMOR_PENDING_NONE;
}
......@@ -84,8 +93,10 @@ void
glamor_set_destination_pixmap_priv_nc(glamor_pixmap_private *pixmap_priv)
{
glBindFramebuffer(GL_FRAMEBUFFER, pixmap_priv->fb);
#ifndef GLAMOR_GLES2
glMatrixMode(GL_PROJECTION); glLoadIdentity();
glMatrixMode(GL_MODELVIEW); glLoadIdentity();
#endif
glViewport(0, 0,
pixmap_priv->container->drawable.width,
......@@ -129,6 +140,7 @@ glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask)
void
glamor_set_alu(unsigned char alu)
{
#ifndef GLAMOR_GLES2
if (alu == GXcopy) {
glDisable(GL_COLOR_LOGIC_OP);
return;
......@@ -183,6 +195,10 @@ glamor_set_alu(unsigned char alu)
default:
FatalError("unknown logic op\n");
}
#else
if (alu != GXcopy)
ErrorF("unsupported alu %x \n", alu);
#endif
}
......@@ -219,8 +235,9 @@ __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format, GLenum type,
glBindTexture(GL_TEXTURE_2D, tex);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
#ifndef GLAMOR_GLES2
glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
#endif
if (pixmap_priv->pbo && pixmap_priv->pbo_valid) {
texels = NULL;
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pixmap_priv->pbo);
......@@ -282,12 +299,23 @@ _glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format, GLenum type, i
ptexcoords = texcoords_inv;
/* Slow path, we need to flip y or wire alpha to 1. */
#if 0
glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, vertices);
glEnableClientState(GL_VERTEX_ARRAY);
glClientActiveTexture(GL_TEXTURE0);
glTexCoordPointer(2, GL_FLOAT, sizeof(float) * 2, ptexcoords);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
#else
glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, GL_FALSE,
2 * sizeof(float),
vertices);
glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT, GL_FALSE,
2 * sizeof(float),
ptexcoords);
glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
#endif
glBindFramebuffer(GL_FRAMEBUFFER, pixmap_priv->fb);
glViewport(0, 0, pixmap->drawable.width, pixmap->drawable.height);
......@@ -300,14 +328,23 @@ _glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format, GLenum type, i
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glEnable(GL_TEXTURE_2D);
#if 0
glUseProgram(glamor_priv->finish_access_prog[ax]);
#else
glUseProgram(glamor_priv->finish_access_prog[ax + 2]);
#endif
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisable(GL_TEXTURE_2D);
glUseProgram(0);
#if 0
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
#else
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
#endif
glDeleteTextures(1, &tex);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
......
......@@ -166,6 +166,12 @@ typedef struct {
#define GLAMOR_NUM_GLYPH_CACHES 4
enum glamor_vertex_type {
GLAMOR_VERTEX_POS,
GLAMOR_VERTEX_SOURCE,
GLAMOR_VERTEX_MASK
};
enum shader_source {
SHADER_SOURCE_SOLID,
SHADER_SOURCE_TEXTURE,
......@@ -227,7 +233,7 @@ typedef struct glamor_screen_private {
enum glamor_gl_flavor gl_flavor;
/* glamor_finishaccess */
GLint finish_access_prog[2];
GLint finish_access_prog[4];
/* glamor_solid */
GLint solid_prog;
......
......@@ -298,17 +298,30 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
/* XXX consider to reuse a function to do the following work. */
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
glamor_validate_pixmap(pixmap);
#if 0
glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, vertices);
glEnableClientState(GL_VERTEX_ARRAY);
glClientActiveTexture(GL_TEXTURE0);
glTexCoordPointer(2, GL_FLOAT, sizeof(float) * 2, texcoords);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
#else
glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, GL_FALSE,
2 * sizeof(float),
vertices);
glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT, GL_FALSE,
2 * sizeof(float),
texcoords);
glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
#endif
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
#ifndef GLAMOR_GLES2
glPixelStorei(GL_UNPACK_ROW_LENGTH, src_stride * 8 /
pixmap->drawable.bitsPerPixel);
#endif
glGenTextures(1, &tex);
......@@ -321,8 +334,11 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glEnable(GL_TEXTURE_2D);
assert(GLEW_ARB_fragment_shader);
#if 0
glUseProgram(glamor_priv->finish_access_prog[ax]);
#else
glUseProgram(glamor_priv->finish_access_prog[ax + 2]);
#endif
x += drawable->x;
y += drawable->y;
......@@ -372,11 +388,17 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
glDisable(GL_TEXTURE_2D);
glUseProgram(0);
#if 0
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
#else
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
#endif
glDeleteTextures(1, &tex);
#ifndef GLAMOR_GLES2
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
#endif
glamor_set_alu(GXcopy);
glamor_set_planemask(pixmap, ~0);
return;
......
......@@ -36,7 +36,7 @@
#include "mipict.h"
#include "fbpict.h"
#include "glu3/glu3.h"
//#include "glu3/glu3.h"
struct shader_key {
enum shader_source source;
......@@ -77,16 +77,18 @@ glamor_create_composite_fs(struct shader_key *key)
" return source;\n"
"}\n";
const char *source_alpha_pixmap_fetch =
"varying vec2 source_texture;\n"
"uniform sampler2D source_sampler;\n"
"vec4 get_source()\n"
"{\n"
" return texture2D(source_sampler, gl_TexCoord[0].xy);\n"
" return texture2D(source_sampler, source_texture);\n"
"}\n";
const char *source_pixmap_fetch =
"varying vec2 source_texture;\n"
"uniform sampler2D source_sampler;\n"
"vec4 get_source()\n"
"{\n"
" return vec4(texture2D(source_sampler, gl_TexCoord[0].xy).rgb, 1);\n"
" return vec4(texture2D(source_sampler, source_texture).rgb, 1);\n"
"}\n";
const char *mask_solid_fetch =
"uniform vec4 mask;\n"
......@@ -95,16 +97,18 @@ glamor_create_composite_fs(struct shader_key *key)
" return mask;\n"
"}\n";
const char *mask_alpha_pixmap_fetch =
"varying vec2 mask_texture;\n"
"uniform sampler2D mask_sampler;\n"
"vec4 get_mask()\n"
"{\n"
" return texture2D(mask_sampler, gl_TexCoord[1].xy);\n"
" return texture2D(mask_sampler, mask_texture);\n"
"}\n";
const char *mask_pixmap_fetch =
"varying vec2 mask_texture;\n"
"uniform sampler2D mask_sampler;\n"
"vec4 get_mask()\n"
"{\n"
" return vec4(texture2D(mask_sampler, gl_TexCoord[1].xy).rgb, 1);\n"
" return vec4(texture2D(mask_sampler, mask_texture).rgb, 1);\n"
"}\n";
const char *in_source_only =
"void main()\n"
......@@ -196,13 +200,18 @@ static GLuint
glamor_create_composite_vs(struct shader_key *key)
{
const char *main_opening =
"attribute vec4 v_position;\n"
"attribute vec4 v_texcoord0;\n"
"attribute vec4 v_texcoord1;\n"
"varying vec2 source_texture;\n"
"varying vec2 mask_texture;\n"
"void main()\n"
"{\n"
" gl_Position = gl_Vertex;\n";
" gl_Position = v_position;\n";
const char *source_coords =
" gl_TexCoord[0] = gl_MultiTexCoord0;\n";
" source_texture = v_texcoord0.xy;\n";
const char *mask_coords =
" gl_TexCoord[1] = gl_MultiTexCoord1;\n";
" mask_texture = v_texcoord1.xy;\n";
const char *main_closing =
"}\n";
const char *source_coords_setup = "";
......@@ -246,6 +255,11 @@ glamor_create_composite_shader(ScreenPtr screen, struct shader_key *key,
prog = glCreateProgram();
glAttachShader(prog, vs);
glAttachShader(prog, fs);
glBindAttribLocation(prog, GLAMOR_VERTEX_POS, "v_position");
glBindAttribLocation(prog, GLAMOR_VERTEX_SOURCE, "v_texcoord0");
glBindAttribLocation(prog, GLAMOR_VERTEX_MASK, "v_texcoord1");
glamor_link_glsl_prog(prog);
shader->prog = prog;
......@@ -508,24 +522,48 @@ glamor_setup_composite_vbo(ScreenPtr screen)
glamor_priv->vb_stride += 2 * sizeof(float);
glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
#if 0
glVertexPointer(2, GL_FLOAT, glamor_priv->vb_stride,
(void *)((long)glamor_priv->vbo_offset));
glEnableClientState(GL_VERTEX_ARRAY);
#else
glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, GL_FALSE,
glamor_priv->vb_stride,
(void *)((long)glamor_priv->vbo_offset));
glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
#endif
if (glamor_priv->has_source_coords) {
#if 0
glClientActiveTexture(GL_TEXTURE0);
glTexCoordPointer(2, GL_FLOAT, glamor_priv->vb_stride,
(void *)(glamor_priv->vbo_offset + 2 * sizeof(float)));
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
#else
glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT, GL_FALSE,
glamor_priv->vb_stride,
(void *)((long)glamor_priv->vbo_offset + 2 * sizeof(float)));
glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
#endif
}
if (glamor_priv->has_mask_coords) {
#if 0
glClientActiveTexture(GL_TEXTURE1);
glTexCoordPointer(2, GL_FLOAT, glamor_priv->vb_stride,
(void *)(glamor_priv->vbo_offset +
(glamor_priv->has_source_coords ? 4 : 2) *
sizeof(float)));
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
#else
glVertexAttribPointer(GLAMOR_VERTEX_MASK, 2, GL_FLOAT, GL_FALSE,
glamor_priv->vb_stride,
(void *)((long)glamor_priv->vbo_offset +
(glamor_priv->has_source_coords ? 4 : 2) *
sizeof(float)));
glEnableVertexAttribArray(GLAMOR_VERTEX_MASK);
#endif
}
}
......@@ -888,6 +926,8 @@ glamor_composite_with_shader(CARD8 op,
}
glUseProgram(shader->prog);
if (key.source == SHADER_SOURCE_SOLID) {
glamor_set_composite_solid(source_solid_color, shader->source_uniform_location);
} else {
......@@ -1014,12 +1054,17 @@ glamor_composite_with_shader(CARD8 op,
glamor_flush_composite_rects(screen);
glBindBuffer(GL_ARRAY_BUFFER, 0);
#if 0
glClientActiveTexture(GL_TEXTURE0);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glClientActiveTexture(GL_TEXTURE1);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
#else
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
glDisableVertexAttribArray(GLAMOR_VERTEX_MASK);
#endif
REGION_UNINIT(dst->pDrawable->pScreen, &region);
glDisable(GL_BLEND);
glActiveTexture(GL_TEXTURE0);
......
......@@ -41,16 +41,35 @@ glamor_init_tile_shader(ScreenPtr screen)
{
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
const char *tile_vs =
#if 0
#else
"attribute vec4 v_position;\n"
"attribute vec4 v_texcoord0;\n"
"varying vec2 tile_texture;\n"
#endif
"void main()\n"
"{\n"
#if 0
" gl_Position = gl_Vertex;\n"
" gl_TexCoord[0] = gl_MultiTexCoord0;\n"
#else
" gl_Position = v_position;\n"
" tile_texture = v_texcoord0.xy;\n"
#endif
"}\n";
const char *tile_fs =
#if 0
#else
"varying vec2 tile_texture;\n"
#endif
"uniform sampler2D sampler;\n"
"void main()\n"
"{\n"
#if 0
" gl_FragColor = texture2D(sampler, gl_TexCoord[0].xy);\n"
#else
" gl_FragColor = texture2D(sampler, tile_texture);\n"
#endif
"}\n";
GLint fs_prog, vs_prog;
GLint sampler_uniform_location;
......@@ -63,6 +82,9 @@ glamor_init_tile_shader(ScreenPtr screen)
fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, tile_fs);
glAttachShader(glamor_priv->tile_prog, vs_prog);
glAttachShader(glamor_priv->tile_prog, fs_prog);
glBindAttribLocation(glamor_priv->tile_prog, GLAMOR_VERTEX_POS, "v_position");
glBindAttribLocation(glamor_priv->tile_prog, GLAMOR_VERTEX_SOURCE, "v_texcoord0");
glamor_link_glsl_prog(glamor_priv->tile_prog);
sampler_uniform_location =
......@@ -144,9 +166,16 @@ glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
tile_x2, tile_y2,
glamor_priv->yInverted,
source_texcoords);
#if 0
glClientActiveTexture(GL_TEXTURE0);
glTexCoordPointer(2, GL_FLOAT, sizeof(float) * 2, source_texcoords);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
#else
glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT, GL_FALSE,
2 * sizeof(float),
source_texcoords);
glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
#endif
}
else {