glamor: add glamor_glsl_has_ints wrapper
This should make adding gpu shader4 support cleaner Reviewed-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
parent
b4f55712da
commit
a2f5b917f5
|
@ -746,7 +746,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
||||||
* have instanced arrays, but this is not always the case.
|
* have instanced arrays, but this is not always the case.
|
||||||
* etnaviv offers GLSL 140 with OpenGL 2.1.
|
* etnaviv offers GLSL 140 with OpenGL 2.1.
|
||||||
*/
|
*/
|
||||||
if (glamor_priv->glsl_version >= 130 &&
|
if (glamor_glsl_has_ints(glamor_priv) &&
|
||||||
!epoxy_has_gl_extension("GL_ARB_instanced_arrays"))
|
!epoxy_has_gl_extension("GL_ARB_instanced_arrays"))
|
||||||
glamor_priv->glsl_version = 120;
|
glamor_priv->glsl_version = 120;
|
||||||
} else {
|
} else {
|
||||||
|
@ -799,7 +799,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
||||||
epoxy_gl_version() >= 30 ||
|
epoxy_gl_version() >= 30 ||
|
||||||
epoxy_has_gl_extension("GL_NV_pack_subimage");
|
epoxy_has_gl_extension("GL_NV_pack_subimage");
|
||||||
glamor_priv->has_dual_blend =
|
glamor_priv->has_dual_blend =
|
||||||
glamor_priv->glsl_version >= 130 &&
|
glamor_glsl_has_ints(glamor_priv) &&
|
||||||
epoxy_has_gl_extension("GL_ARB_blend_func_extended");
|
epoxy_has_gl_extension("GL_ARB_blend_func_extended");
|
||||||
glamor_priv->has_clear_texture =
|
glamor_priv->has_clear_texture =
|
||||||
epoxy_gl_version() >= 44 ||
|
epoxy_gl_version() >= 44 ||
|
||||||
|
|
|
@ -208,11 +208,6 @@ static const glamor_facet glamor_facet_composite_glyphs_120 = {
|
||||||
.locations = glamor_program_location_atlas,
|
.locations = glamor_program_location_atlas,
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline Bool
|
|
||||||
glamor_glyph_use_130(glamor_screen_private *glamor_priv) {
|
|
||||||
return glamor_priv->glsl_version >= 130;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
glamor_glyphs_init_facet(ScreenPtr screen)
|
glamor_glyphs_init_facet(ScreenPtr screen)
|
||||||
{
|
{
|
||||||
|
@ -274,7 +269,7 @@ glamor_glyphs_flush(CARD8 op, PicturePtr src, PicturePtr dst,
|
||||||
box->y2 - box->y1);
|
box->y2 - box->y1);
|
||||||
box++;
|
box++;
|
||||||
|
|
||||||
if (glamor_glyph_use_130(glamor_priv))
|
if (glamor_glsl_has_ints(glamor_priv))
|
||||||
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, nglyph);
|
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, nglyph);
|
||||||
else
|
else
|
||||||
glamor_glDrawArrays_GL_QUADS(glamor_priv, nglyph);
|
glamor_glDrawArrays_GL_QUADS(glamor_priv, nglyph);
|
||||||
|
@ -287,7 +282,7 @@ glamor_glyphs_flush(CARD8 op, PicturePtr src, PicturePtr dst,
|
||||||
|
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
if (glamor_glyph_use_130(glamor_priv)) {
|
if (glamor_glsl_has_ints(glamor_priv)) {
|
||||||
glVertexAttribDivisor(GLAMOR_VERTEX_SOURCE, 0);
|
glVertexAttribDivisor(GLAMOR_VERTEX_SOURCE, 0);
|
||||||
glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);
|
glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);
|
||||||
}
|
}
|
||||||
|
@ -305,7 +300,7 @@ glamor_glyph_start(ScreenPtr screen, int count)
|
||||||
|
|
||||||
/* Set up the vertex buffers for the font and destination */
|
/* Set up the vertex buffers for the font and destination */
|
||||||
|
|
||||||
if (glamor_glyph_use_130(glamor_priv)) {
|
if (glamor_glsl_has_ints(glamor_priv)) {
|
||||||
v = glamor_get_vbo_space(screen, count * (6 * sizeof (GLshort)), &vbo_offset);
|
v = glamor_get_vbo_space(screen, count * (6 * sizeof (GLshort)), &vbo_offset);
|
||||||
|
|
||||||
glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||||
|
@ -439,7 +434,7 @@ glamor_composite_glyphs(CARD8 op,
|
||||||
/* First glyph in the current atlas?
|
/* First glyph in the current atlas?
|
||||||
*/
|
*/
|
||||||
if (_X_UNLIKELY(glyphs_queued == 0)) {
|
if (_X_UNLIKELY(glyphs_queued == 0)) {
|
||||||
if (glamor_glyph_use_130(glamor_priv))
|
if (glamor_glsl_has_ints(glamor_priv))
|
||||||
prog = glamor_setup_program_render(op, src, glyph_pict, dst,
|
prog = glamor_setup_program_render(op, src, glyph_pict, dst,
|
||||||
glyphs_program,
|
glyphs_program,
|
||||||
&glamor_facet_composite_glyphs_130,
|
&glamor_facet_composite_glyphs_130,
|
||||||
|
@ -458,7 +453,7 @@ glamor_composite_glyphs(CARD8 op,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
glyphs_queued++;
|
glyphs_queued++;
|
||||||
if (_X_LIKELY(glamor_glyph_use_130(glamor_priv))) {
|
if (_X_LIKELY(glamor_glsl_has_ints(glamor_priv))) {
|
||||||
v[0] = x - glyph->info.x;
|
v[0] = x - glyph->info.x;
|
||||||
v[1] = y - glyph->info.y;
|
v[1] = y - glyph->info.y;
|
||||||
v[2] = glyph_draw->width;
|
v[2] = glyph_draw->width;
|
||||||
|
|
|
@ -47,7 +47,7 @@ glamor_font_get(ScreenPtr screen, FontPtr font)
|
||||||
unsigned long count;
|
unsigned long count;
|
||||||
char *bits;
|
char *bits;
|
||||||
|
|
||||||
if (glamor_priv->glsl_version < 130)
|
if (!glamor_glsl_has_ints(glamor_priv))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
privates = FontGetPrivate(font, glamor_font_private_index);
|
privates = FontGetPrivate(font, glamor_font_private_index);
|
||||||
|
@ -210,7 +210,7 @@ glamor_font_init(ScreenPtr screen)
|
||||||
{
|
{
|
||||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||||
|
|
||||||
if (glamor_priv->glsl_version < 130)
|
if (!glamor_glsl_has_ints(glamor_priv))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (glamor_font_generation != serverGeneration) {
|
if (glamor_font_generation != serverGeneration) {
|
||||||
|
|
|
@ -69,7 +69,7 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
|
||||||
glamor_bounds_union_rect(&bounds, &prect[i]);
|
glamor_bounds_union_rect(&bounds, &prect[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glamor_priv->glsl_version >= 130) {
|
if (glamor_glsl_has_ints(glamor_priv)) {
|
||||||
prog = glamor_use_program_fill(pixmap, gc,
|
prog = glamor_use_program_fill(pixmap, gc,
|
||||||
&glamor_priv->poly_fill_rect_program,
|
&glamor_priv->poly_fill_rect_program,
|
||||||
&glamor_facet_polyfillrect_130);
|
&glamor_facet_polyfillrect_130);
|
||||||
|
@ -151,7 +151,7 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
|
||||||
scissor.y1 + off_y,
|
scissor.y1 + off_y,
|
||||||
scissor.x2 - scissor.x1,
|
scissor.x2 - scissor.x1,
|
||||||
scissor.y2 - scissor.y1);
|
scissor.y2 - scissor.y1);
|
||||||
if (glamor_priv->glsl_version >= 130)
|
if (glamor_glsl_has_ints(glamor_priv))
|
||||||
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, nrect);
|
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, nrect);
|
||||||
else {
|
else {
|
||||||
glamor_glDrawArrays_GL_QUADS(glamor_priv, nrect);
|
glamor_glDrawArrays_GL_QUADS(glamor_priv, nrect);
|
||||||
|
@ -163,7 +163,7 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
|
||||||
|
|
||||||
bail:
|
bail:
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
if (glamor_priv->glsl_version >= 130) {
|
if (glamor_glsl_has_ints(glamor_priv)) {
|
||||||
glVertexAttribDivisor(GLAMOR_VERTEX_SOURCE, 0);
|
glVertexAttribDivisor(GLAMOR_VERTEX_SOURCE, 0);
|
||||||
glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||||
glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);
|
glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);
|
||||||
|
|
|
@ -64,7 +64,7 @@ glamor_fill_spans_gl(DrawablePtr drawable,
|
||||||
|
|
||||||
glamor_make_current(glamor_priv);
|
glamor_make_current(glamor_priv);
|
||||||
|
|
||||||
if (glamor_priv->glsl_version >= 130) {
|
if (glamor_glsl_has_ints(glamor_priv)) {
|
||||||
prog = glamor_use_program_fill(pixmap, gc, &glamor_priv->fill_spans_program,
|
prog = glamor_use_program_fill(pixmap, gc, &glamor_priv->fill_spans_program,
|
||||||
&glamor_facet_fillspans_130);
|
&glamor_facet_fillspans_130);
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ glamor_fill_spans_gl(DrawablePtr drawable,
|
||||||
box->x2 - box->x1,
|
box->x2 - box->x1,
|
||||||
box->y2 - box->y1);
|
box->y2 - box->y1);
|
||||||
box++;
|
box++;
|
||||||
if (glamor_priv->glsl_version >= 130)
|
if (glamor_glsl_has_ints(glamor_priv))
|
||||||
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, n);
|
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, n);
|
||||||
else {
|
else {
|
||||||
glamor_glDrawArrays_GL_QUADS(glamor_priv, n);
|
glamor_glDrawArrays_GL_QUADS(glamor_priv, n);
|
||||||
|
@ -146,7 +146,7 @@ glamor_fill_spans_gl(DrawablePtr drawable,
|
||||||
|
|
||||||
bail:
|
bail:
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
if (glamor_priv->glsl_version >= 130)
|
if (glamor_glsl_has_ints(glamor_priv))
|
||||||
glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);
|
glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);
|
||||||
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||||
|
|
||||||
|
|
|
@ -732,5 +732,9 @@ glamor_glDrawArrays_GL_QUADS(glamor_screen_private *glamor_priv, unsigned count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline Bool
|
||||||
|
glamor_glsl_has_ints(glamor_screen_private *glamor_priv) {
|
||||||
|
return glamor_priv->glsl_version >= 130;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue