summaryrefslogtreecommitdiff
path: root/glamor/glamor_render.c
AgeCommit message (Collapse)AuthorFilesLines
2017-09-25glamor: handle NULL source pictureOlivier Fourdan1-2/+3
COMPOSITE_REGION() can pass NULL as a source picture, make sure we handle that nicely in both glamor_composite_clipped_region() and glamor_composite_choose_shader(). Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=101894 Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Adam Jackson <ajax@redhat.com> (cherry picked from commit bd353e9b84e013fc34ed730319d5b63d20977903)
2017-02-23glamor: Two pass won't work on memory pixmapsOlivier Fourdan1-0/+4
When selecting "CA_TWO_PASS" in glamor_composite_clipped_region() when the hardware does not support "GL_ARB_blend_func_extended", we call glamor_composite_choose_shader() twice in a row, which in turn calls glamor_pixmap_ensure_fbo(). On memory pixmaps, the first call will set the FBO and the second one will fail an assertion in glamor_upload_picture_to_texture() because the FBO is already set. Bail out earlier when the mask pixmap is in memory and the hardware capabilities would require to use two pass, so that the assertion is not failed and the rendering is correct. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99346 Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Eric Anholt <eric@anholt.net> (cherry picked from commit 86463981361064dd0352ec215abf1696ce7fc5ea)
2016-09-29glamor: Remove #if 0-ed picture dumping code.Eric Anholt1-5/+0
I don't think anybody has run this code since it was pulled into the server. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Keith Packard <keithp@keithp.com>
2016-09-29glamor: Require GL_OES_texture_border_clamp for GLES2.Eric Anholt1-15/+7
The extension came out in 2000, and all Mesa-supported hardware that can do glamor supports it. We were already relying on the ARB version being present on desktop. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Keith Packard <keithp@keithp.com>
2016-09-26glamor: Properly handle mask formats without alpha.Eric Anholt1-1/+4
Even if the pixmap's storage has alpha, it may have been uploaded with garbage in the alpha channel, so we need to force the shader to set alpha to 1. This was broken way back in 355334fcd99e4dce62e2be1e27290c9a74ea944f. Fixes rendercheck -t composite -f x8r8g8b8. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-09-26glamor: Require that pixmap depths match for Render copies.Eric Anholt1-0/+2
The copy optimization in d37329cba42fa8e72fe4be8a7be18e512268b5bd replicated a bug from last time we did a copy optimization: CopyArea is only defined for matching depths. This is only a problem at 15 vs 16 depth right now (24 vs 32 would also have matching Render formats, but they should work) but be strict in case we store other depths differently in the future. Fixes rendercheck -t blend -o src -f x4r4g4b4,x3r4g4b4 v2: Drop excessive src->depth == dst->depth check that snuck in. v3: Switch back to src->depth == dst->depth v4: Touch up commit message (s/bpp/depth). Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-09-26glamor: Fix some awful formatting of some fallback debug code.Eric Anholt1-6/+6
This was clearly x-indent.sh damage. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-09-25glamor: fix spelling mistakesEric Engestrom1-1/+1
v2: Fix "orignal" too (review feedback by ajax, change by anholt)_ Signed-off-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Eric Anholt <eric@anholt.net>
2016-05-30glamor: Cannot use copies when accessing outside of composite sourceMichel Dänzer1-12/+15
Commit b64108fa ("glamor: Check for composite operations which are equivalent to copies") failed to copy conditions from exaComposite which ensure that the composite operation doesn't access outside of the source picture. This fixes rendercheck regressions from the commit above. Reviewed-by: Keith Packard <keithp@keithp.com>
2016-05-27glamor: Adjust for drawable x/y in composite's copy optimizationKeith Packard1-0/+4
Patch b64108fa305e956e4edaae9d53071ff0abee268e added a short cut that identifies composite operations that can be performed with a simple copy instead. glamor_copy works in absolute coordinates, so the dx and dy values passed in need to be converted from drawable-relative to absolute by adding the drawable x/y values. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-05-26glamor: Preserve GL_RED bits in R channel when destination is GL_RED [v2]Keith Packard1-5/+16
A1 and A8 pixmaps are usually stored in the Red channel to conform with more recent GL versions. When using these pixmaps as mask values, that works great. When using these pixmaps as source values, then the value we want depends on what the destination looks like. For RGBA or RGB destinations, then we want to use the Red channel for A values and leave RGB all set to zero. For A destinations, then we want to leave the R values in the Red channel so that they end up in the Red channel of the output. This patch adds a helper function, glamor_bind_texture, which performs the glBindTexture call along with setting the swizzle parameter correctly for the Red channel. The swizzle parameter for the Alpha channel doesn't depend on the destination as it's safe to leave it always swizzled from the Red channel. This fixes incorrect rendering in firefox for this page: https://gfycat.com/HoarseCheapAmericankestrel while not breaking rendering for this page: https://feedly.com v2: Add change accidentally left in patch for missing glDisable(GL_COLOR_LOGIC_OP). Found by Emil Velikov <emil.l.velikov@gmail.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=63397 Signed-off-by: Keith Packard <keithp@keithp.com> Tested-by: Michel Dänzer <michel.daenzer@amd.com>
2016-05-26glamor: glamor_make_current sooner in glamor_composite_with_shaderKeith Packard1-2/+2
glamor_make_current is supposed to be called before any GL APIs. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-05-26glamor: Disable logic ops when doing compositing [v4]Keith Packard1-0/+3
If the logic op gets left enabled, it overrides the blending operation, causing incorrect contents on the display. v2: Disable only on non-ES2, but disable even for PictOpSrc v3: Found another place this is needed in glamor_composite_set_shader_blend v4: Remove change dependent on new glamor_set_composite_texture API. This belongs in a different patch. Found by Emil Velikov <emil.l.velikov@gmail.com> Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-05-25glamor: Check for composite operations which are equivalent to copiesMichel Dänzer1-0/+23
Increases x11perf -compwinwin500 numbers by a factor of 10 for me with radeonsi. Conditions copied from exaComposite(). Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-05-25glamor: Fix sampling outside of RGBx source/mask picturesMichel Dänzer1-12/+24
RENDER requires that sampling outside of any source/mask picture results in alpha == 0.0. The OpenGL border colour cannot set alpha = 0.0 if the texture format doesn't have an alpha channel, so we have to use the RepeatFix handling in that case. Also, only force alpha = 1.0 when sampling inside of RGBx source/mask pictures. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94514 Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-10glamor: Make sure that GLAMOR_MEMORY pixmaps don't retain an FBO.Eric Anholt1-2/+9
glamor_composite_choose_shader() may upload our scratch pixmaps to get a Render operation completed. We don't want to hang onto GL memory for our scratch pixmaps, since we'll just have to reallocate them at a new w/h next time around, and the contents will be updated as well. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Eric Anholt <eric@anholt.net>
2016-03-10glamor: Simplify temporary picture uploading call stack.Eric Anholt1-16/+11
glamor_upload_sub_pixmap_to_texture() only had the one caller, so we can merge it in, fix its silly return value, and propagate a bunch of constants. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Eric Anholt <eric@anholt.net>
2016-01-29glamor: Flip around conditionals in RepeatNone fixups.Eric Anholt1-2/+2
Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-01-29glamor: Cut down a bunch of conditional handling for RepeatFix.Eric Anholt1-31/+19
For hardware that doesn't do actual jumps for conditionals (i915, current vc4 driver), this reduces the number of texture fetches performed (assuming the driver isn't really smart about noticing that the same sampler is used on each side of an if just with different coordinates). No performance difference on i965 with x11perf -magpixwin100 (n=40). Improves -magpixwin100 by 12.9174% +/- 0.405272% (n=5) on vc4. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-01-29glamor: Clarify how the repeat values being passed around work.Eric Anholt1-6/+6
Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-01-29glamor: Clean up formatting of RepeatFix shader code.Eric Anholt1-27/+30
All sorts of weird indentation, and some cuddled conditional statements deep in the if tree. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-01-29glamor: Clarify some logic in RepeatFix handling.Eric Anholt1-14/+7
wh ratios are != 1.0 only when large, so with that we can simplify down how we end up with RepeatFix being used. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-01-29glamor: Reuse the glamor_program_alpha_* enums for Render.Eric Anholt1-14/+14
This is a step toward using glamor_program.c for Render acceleration. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-01-29glamor: Drop extra SHADER_IN type for no mask present.Eric Anholt1-11/+6
We can just hand in a constant mask and the driver will optimize away the multiplication for us. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-01-29glamor: Clarify when Render fallbacks happen due to an unsupported op.Eric Anholt1-1/+3
Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-01-26glamor: Use GL_RED instead of GL_ALPHA if we have texture_swizzle (v3)Keith Packard1-11/+75
GL_RED is supported by core profiles while GL_ALPHA is not; use GL_RED for one channel objects (depth 1 to 8), and then swizzle them into the alpha channel when used as a mask. [airlied: updated to master, add swizzle to composited glyphs and xv paths] v2: consolidate setting swizzle into the texture creation code, it should work fine there. Handle swizzle when setting color as well. v3: Fix drawing to a8 with Render (changes by anholt, reviewed by airlied). Signed-off-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Eric Anholt <eric@anholt.net>
2016-01-26glamor: Drop duplicated GLAMOR_DEFAULT_PRECISIONs in render accel.Eric Anholt1-13/+4
We only need it once at the top of the shader, so just put it there. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Dave Airlie <airlied@redhat.com>
2016-01-26glamor: Add support for CA rendering in a single pass.Dave Airlie1-22/+70
It's been on the list to add dual source blending support to avoid the two pass componentAlpha code. Radeon has done this for a while in EXA, so let's add support to bring glamor up to using it. This adds dual blend to both render and composite glyphs paths. Initial results show close to doubling of speed of x11perf -rgb10text. v2: Fix breakage of all of CA acceleration for systems without GL_ARB_blend_func_extended. Add CA support for all the ops we support in non-CA mode when blend_func_extended is present. Clean up some comments and formatting. (changes by anholt) Signed-off-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Eric Anholt <eric@anholt.net>
2016-01-26glamor: Drop the composite_with_copy path entirely.Eric Anholt1-92/+0
I originally inherited this from the EXA code, without determining whether it was really needed. Regular composite should end up doing the same thing, since it's all just shaders anyway. To the extent that it doesn't, we should fix composite. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Dave Airlie <airlied@redhat.com>
2016-01-21glamor: Fix copy-like Render operations between 15 and 16 depth.Eric Anholt1-0/+8
Reading and writing to 16-depth pixmaps using PICT_x1r5g5b5 ends up failing, unless you're doing a straight copy at the same bpp where the misinterpretation matches on both sides. Fixes rendercheck/blend/over and renderhceck/blend/src in piglit. Please cherry-pick this to active stable branches. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Dave Airlie <airlied@redhat.com>
2015-11-10glamor: Fix segfault in fallback picture uploading.Eric Anholt1-7/+9
If the source/mask pixmap is a pixmap that doesn't have an FBO attached, and it doesn't match the Render operation's size, then we'll composite it to a CPU temporary (not sure why). We would take the PictFormatShort from the source Picture, make a pixmap of that depth, and try to look up the PictFormat description from the depth and the PictFormatShort. However, the screen's PictFormats are only attached to the screen's visuals' depths. So, with an x2r10g10b10 short format (depth 30), we wouldn't find the screen's PictFormat for it (associated with depth 32). Instead of trying to look up from the screen, just use the pFormat that came from our source picture. The only time we need to look up a PictFormat when we're doing non-shader gradients, which we put in a8r8g8b8. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2015-07-10glamor: Drop tracking of the last picture attached to pixmaps.Eric Anholt1-3/+0
Signed-off-by: Eric Anholt <eric@anholt.net> Acked-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Dave Airlie <airlied@redhat.com>
2015-07-10glamor: Don't try to do rendering with unsupported formats.Eric Anholt1-0/+38
I'm amazed we've made it as far as we have without these checks: if you made an unusual format picture that wasn't the normal a8r8g8b8 or x8r8g8b8 or a8, we'd go ahead and try to render with it, ignoring that the sampler would fetch totally wrong bits. Fixes 260 tests in rendercheck -t blend -o src -f a8r8g8b8,x2r10g10b10 Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Dave Airlie <airlied@redhat.com>
2015-07-02glamor: Use ARRAY_SIZE in a couple more places for consistency.Eric Anholt1-4/+1
Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-07-02glamor: Mark a bunch of single-file data static.Eric Anholt1-1/+1
This gives the compiler a chance to optimize when the data is never changed -- for example, with pict_format_combine_tab, the compiler ends up inlining the 24 bytes of data into just 10 more bytes of code. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-07-02glamor: Make a bunch of single-file glamor functions static.Eric Anholt1-2/+2
Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-06-29glamor: Use the normal GL_QUADS drawing helper in the render code.Eric Anholt1-46/+4
We use this for all of our other performance-sensitive rendering, too. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Dave Airlie <airlied@redhat.com>
2015-06-29glamor: Drop CloseScreen-time GL resource cleanup code.Eric Anholt1-21/+0
These will all be freed when the context is freed. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Dave Airlie <airlied@redhat.com>
2015-06-02glamor: don't do render ops with matching source/dest (v3)Dave Airlie1-1/+8
XRender defines this, GL really doesn't like it. kwin 4.x and qt 4.x seem to make this happen for the gradient in the titlebar, and on radeonsi/r600 hw this draws all kinds of wrong. v2: bump this up a level, and check it earlier. (I assume the XXXX was for this case.) v3: add same code to largepixmap paths (Keith) Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net> Signed-off-by: Dave Airlie <airlied@redhat.com>
2015-05-14glamor: Replace CompositeGlyphs code [v2]Keith Packard1-136/+0
New composite glyphs code uses the updated glamor program infrastructure to create efficient shaders for drawing render text. Glyphs are cached in two atlases (one 8-bit, one 32-bit) in a simple linear fashion. When the atlas fills, it is discarded and a new one constructed. v2: Eric Anholt changed the non-GLSL 130 path to use quads instead of two triangles for a significant performance improvement on hardware with quads. Someone can fix the GLES quads emulation if they want to make it faster there. v3: Eric found more dead code to delete Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Eric Anholt <eric@anholt.net>
2015-03-24glamor: Just set the logic op to what we want at the start of all rendering.Eric Anholt1-0/+1
By dropping the unconditional logic op disable at the end of rendering, this fixes GL errors being thrown in GLES2 contexts (which don't have logic ops). On desktop, this also means a little less overhead per draw call from taking one less trip through the glEnable/glDisable switch statement of doom in Mesa. The exchange here is that we end up taking a trip through it in the XV, Render, and gradient-generation paths. If the glEnable() is actually costly, we should probably cache our logic op state in our screen, since there's no way the GL could make that switch statement as cheap as the caller caching it would be. v2: Don't forget to set the logic op in Xephyr's drawing. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Keith Packard <keithp@keithp.com>
2015-03-24glamor: Create inline tests for small/large pixmapsKeith Packard1-1/+1
This will let us eliminate the pixmap types shortly Signed-off-by: Keith Packard <keithp@keithp.com> Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Eric Anholt <eric@anholt.net>
2015-03-24glamor: Eliminate separate 'large' pixmap private structureKeith Packard1-3/+3
Just embed the large elements in the regular pixmap private and collapse the union to a single struct. Signed-off-by: Keith Packard <keithp@keithp.com> Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Eric Anholt <eric@anholt.net>
2015-03-24glamor: Remove screen private and pixmap ptrs from pixmap private and fboKeith Packard1-86/+87
There's no reason to waste memory storing redundant copies of the same pointer all over the system; just pass in pointers as necessary to each function. Signed-off-by: Keith Packard <keithp@keithp.com> Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Eric Anholt <eric@anholt.net>
2015-03-24glamor: Remove remaining support for FBOs not matching pixmap sizeKeith Packard1-19/+1
The core rendering code already requires that FBOs be allocated at exactly the pixmap size so that tiling and stippling work correctly. Remove the allocation support for that, along with the render code. Signed-off-by: Keith Packard <keithp@keithp.com> Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Eric Anholt <eric@anholt.net>
2015-03-24glamor: Remove _nf rendering functionsKeith Packard1-91/+16
These were used by the non-standard glamor implementation in the intel driver. Signed-off-by: Keith Packard <keithp@keithp.com> Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Eric Anholt <eric@anholt.net>
2014-07-17Merge remote-tracking branch 'origin/master' into glamor-nextEric Anholt1-8/+8
I've done this merge manually to resolve the minor conflict in glamor.c. Signed-off-by: Eric Anholt <eric@anholt.net>
2014-07-17glamor: Drop the "are we doing a series of blits or draws" logic.Eric Anholt1-2/+0
It's unused since keithp's copy acceleration code completely replaced glamor_copyarea.c and removed the blit path. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Keith Packard <keithp@keithp.com>
2014-07-17glamor: Remove always-true yInverted flag.Eric Anholt1-8/+5
All users of glamor had the same value set, and it complicated things for no reason. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Keith Packard <keithp@keithp.com>
2014-07-17glamor: Fix temp picture coordinates in glamor_composite_clipped_regionKeith Packard1-8/+8
To understand this patch, let's start at the protocol interface where the relationship between the coordinate spaces is documented: static Bool _glamor_composite(CARD8 op, PicturePtr source, PicturePtr mask, PicturePtr dest, INT16 x_source, INT16 y_source, INT16 x_mask, INT16 y_mask, INT16 x_dest, INT16 y_dest, CARD16 width, CARD16 height, Bool fallback) The coordinates are passed to this function directly off the wire and are all relative to their respective drawables. For Windows, this means that they are relative to the upper left corner of the window, in whatever pixmap that window is getting drawn to. _glamor_composite calls miComputeCompositeRegion to construct a clipped region to actually render to. In reality, miComputeCompositeRegion clips only to the destination these days; source clip region based clipping would have to respect the transform, which isn't really possible. The returned region is relative to the screen in which dest lives; offset by dest->drawable.x and dest->drawable.y. What is important to realize here is that, because of clipping, the composite region may not have the same position within the destination drawable as x_dest, y_dest. The protocol coordinates now exist solely to 'pin' the three objects together. extents->x1,y1 Screen origin of clipped operation width,height Extents of the clipped operation x_dest,y_dest Unclipped destination-relative operation coordinate x_source,y_source Unclipped source-relative operation coordinate x_mask,y_mask Unclipped mask-relative operation coordinate One thing we want to know is what the offset is from the original operation origin to the clipped origin Destination drawable relative coordinates of the clipped operation: x_dest_clipped = extents->x1 - dest->drawable.x y_dest_clipped = extents->y1 - dest->drawable.y Offset from the original operation origin: x_off_clipped = x_dest_clipped - x_dest y_off_clipped = y_dest_clipped - y_dest Source drawable relative coordinates of the clipped operation: x_source_clipped = x_source + x_off_clipped; y_source_clipped = y_source + y_off_clipped; Mask drawable relative coordinates of the clipped operation: x_mask_clipped = x_source + x_off_clipped; y_mask_clipped = y_source + y_off_clipped; This is where the original code fails -- it doesn't subtract the destination drawable location when computing the distance that the operation has been moved by clipping. Here's what it does when constructing a temporary source picture: temp_src = glamor_convert_gradient_picture(screen, source, extent->x1 + x_source - x_dest, extent->y1 + y_source - y_dest, width, height); ... x_temp_src = -extent->x1 + x_dest; y_temp_src = -extent->y1 + y_dest; glamor_convert_gradient_picture needs source drawable relative coordinates, but that is not what it's getting; it's getting screen-relative coordinates for the destination, adjusted by the distance between the provided source and destination operation coordinates. We want x_source_clipped and y_source_clipped: x_source_clipped = x_source + x_off_clipped = x_source + x_dest_clipped - x_dest = x_source + extents->x1 - dest->drawable.x - x_dest x_temp_src/y_temp_src are supposed to be the coordinates of the original operation translated to the temporary picture: x_temp_src = x_source - x_source_clipped; y_temp_src = y_source - y_source_clipped; Note that x_source_clipped/y_source_clipped will never be less than x_source/y_source because all we're doing is clipping. This means that x_temp_src/y_temp_src will always be non-positive; the original source coordinate can never be strictly *inside* the temporary image or we could have made the temporary image smaller. x_temp_src = x_source - x_source_clipped = x_source - (x_source + x_off_clipped) = -x_off_clipped = x_dest - x_dest_clipped = x_dest - (extents->x1 - dest->drawable.x) Again, this is off by the destination origin within the screen coordinate space. The code should look like: temp_src = glamor_convert_gradient_picture(screen, source, extent->x1 + x_source - x_dest - dest->pDrawable->x, extent->y1 + y_source - y_dest - dest->pDrawable->y, width, height); x_temp_src = -extent->x1 + x_dest + dest->pDrawable->x; y_temp_src = -extent->y1 + y_dest + dest->pDrawable->y; Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Markus Wick <markus@selfnet.de>