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