mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-24 03:44:06 +00:00
glamor: * 1/size is faster than / size in VS
Pass the inverse of the texture size to glamor vertex shaders so that we multiply by that instead of dividing by the size as multiplication is generally faster than division. Signed-off-by: Keith Packard <keithp@keithp.com> Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
committed by
Eric Anholt
parent
82634d2b69
commit
e977b404d7
@@ -42,7 +42,7 @@ use_copyarea(PixmapPtr dst, GCPtr gc, glamor_program *prog, void *arg)
|
||||
glBindTexture(GL_TEXTURE_2D, src->tex);
|
||||
|
||||
glUniform2f(prog->fill_offset_uniform, args->dx, args->dy);
|
||||
glUniform2f(prog->fill_size_uniform, src->width, src->height);
|
||||
glUniform2f(prog->fill_size_inv_uniform, 1.0f/src->width, 1.0f/src->height);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ static const glamor_facet glamor_facet_copyarea = {
|
||||
"copy_area",
|
||||
.vs_vars = "attribute vec2 primitive;\n",
|
||||
.vs_exec = (GLAMOR_POS(gl_Position, primitive.xy)
|
||||
" fill_pos = (fill_offset + primitive.xy) / fill_size;\n"),
|
||||
" fill_pos = (fill_offset + primitive.xy) * fill_size_inv;\n"),
|
||||
.fs_exec = " gl_FragColor = texture2D(sampler, fill_pos);\n",
|
||||
.locations = glamor_program_location_fill,
|
||||
.use = use_copyarea,
|
||||
@@ -71,7 +71,7 @@ use_copyplane(PixmapPtr dst, GCPtr gc, glamor_program *prog, void *arg)
|
||||
glBindTexture(GL_TEXTURE_2D, src->tex);
|
||||
|
||||
glUniform2f(prog->fill_offset_uniform, args->dx, args->dy);
|
||||
glUniform2f(prog->fill_size_uniform, src->width, src->height);
|
||||
glUniform2f(prog->fill_size_inv_uniform, 1.0f/src->width, 1.0f/src->height);
|
||||
|
||||
glamor_set_color(dst, gc->fgPixel, prog->fg_uniform);
|
||||
glamor_set_color(dst, gc->bgPixel, prog->bg_uniform);
|
||||
@@ -134,7 +134,7 @@ static const glamor_facet glamor_facet_copyplane = {
|
||||
.version = 130,
|
||||
.vs_vars = "attribute vec2 primitive;\n",
|
||||
.vs_exec = (GLAMOR_POS(gl_Position, (primitive.xy))
|
||||
" fill_pos = (fill_offset + primitive.xy) / fill_size;\n"),
|
||||
" fill_pos = (fill_offset + primitive.xy) * fill_size_inv;\n"),
|
||||
.fs_exec = (" uvec4 bits = uvec4(round(texture2D(sampler, fill_pos) * bitmul));\n"
|
||||
" if ((bits & bitplane) != uvec4(0,0,0,0))\n"
|
||||
" gl_FragColor = fg;\n"
|
||||
|
||||
Reference in New Issue
Block a user