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:
Dave Airlie 2021-07-02 04:52:23 +10:00
parent b4f55712da
commit a2f5b917f5
6 changed files with 19 additions and 20 deletions

View File

@ -746,7 +746,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
* have instanced arrays, but this is not always the case.
* 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"))
glamor_priv->glsl_version = 120;
} else {
@ -799,7 +799,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
epoxy_gl_version() >= 30 ||
epoxy_has_gl_extension("GL_NV_pack_subimage");
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");
glamor_priv->has_clear_texture =
epoxy_gl_version() >= 44 ||

View File

@ -208,11 +208,6 @@ static const glamor_facet glamor_facet_composite_glyphs_120 = {
.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
glamor_glyphs_init_facet(ScreenPtr screen)
{
@ -274,7 +269,7 @@ glamor_glyphs_flush(CARD8 op, PicturePtr src, PicturePtr dst,
box->y2 - box->y1);
box++;
if (glamor_glyph_use_130(glamor_priv))
if (glamor_glsl_has_ints(glamor_priv))
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, nglyph);
else
glamor_glDrawArrays_GL_QUADS(glamor_priv, nglyph);
@ -287,7 +282,7 @@ glamor_glyphs_flush(CARD8 op, PicturePtr src, PicturePtr dst,
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_POS, 0);
}
@ -305,7 +300,7 @@ glamor_glyph_start(ScreenPtr screen, int count)
/* 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);
glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
@ -439,7 +434,7 @@ glamor_composite_glyphs(CARD8 op,
/* First glyph in the current atlas?
*/
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,
glyphs_program,
&glamor_facet_composite_glyphs_130,
@ -458,7 +453,7 @@ glamor_composite_glyphs(CARD8 op,
*/
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[1] = y - glyph->info.y;
v[2] = glyph_draw->width;

View File

@ -47,7 +47,7 @@ glamor_font_get(ScreenPtr screen, FontPtr font)
unsigned long count;
char *bits;
if (glamor_priv->glsl_version < 130)
if (!glamor_glsl_has_ints(glamor_priv))
return NULL;
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);
if (glamor_priv->glsl_version < 130)
if (!glamor_glsl_has_ints(glamor_priv))
return TRUE;
if (glamor_font_generation != serverGeneration) {

View File

@ -69,7 +69,7 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
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,
&glamor_priv->poly_fill_rect_program,
&glamor_facet_polyfillrect_130);
@ -151,7 +151,7 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
scissor.y1 + off_y,
scissor.x2 - scissor.x1,
scissor.y2 - scissor.y1);
if (glamor_priv->glsl_version >= 130)
if (glamor_glsl_has_ints(glamor_priv))
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, nrect);
else {
glamor_glDrawArrays_GL_QUADS(glamor_priv, nrect);
@ -163,7 +163,7 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
bail:
glDisable(GL_SCISSOR_TEST);
if (glamor_priv->glsl_version >= 130) {
if (glamor_glsl_has_ints(glamor_priv)) {
glVertexAttribDivisor(GLAMOR_VERTEX_SOURCE, 0);
glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);

View File

@ -64,7 +64,7 @@ glamor_fill_spans_gl(DrawablePtr drawable,
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,
&glamor_facet_fillspans_130);
@ -134,7 +134,7 @@ glamor_fill_spans_gl(DrawablePtr drawable,
box->x2 - box->x1,
box->y2 - box->y1);
box++;
if (glamor_priv->glsl_version >= 130)
if (glamor_glsl_has_ints(glamor_priv))
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, n);
else {
glamor_glDrawArrays_GL_QUADS(glamor_priv, n);
@ -146,7 +146,7 @@ glamor_fill_spans_gl(DrawablePtr drawable,
bail:
glDisable(GL_SCISSOR_TEST);
if (glamor_priv->glsl_version >= 130)
if (glamor_glsl_has_ints(glamor_priv))
glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);

View File

@ -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