diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-11-03 19:27:23 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-11-03 20:40:07 +0000 |
commit | a1b40a20bbba4b70990a8983a2916d3d5850d828 (patch) | |
tree | 3c7f77e5d2f4f8967eb74cb3476fcb110b14520a /src/sna/gen5_render.c | |
parent | 31c5eb8e906bf8e59743372edb2d703b50cd311e (diff) |
sna: Support binding of a bo for multiple formats
Applications may use the same pixmap with multiple formats within the
same operation. For instance, you can premultiply and composite a normal
pixmap in this manner. However, as we reused the sampler binding
locations of the source (without an alpha channel) for the mask, we
failed to read and multiply by the alpha channel causing it to remain
black instead of transparent.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=40926
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/gen5_render.c')
-rw-r--r-- | src/sna/gen5_render.c | 38 |
1 files changed, 8 insertions, 30 deletions
diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c index c48e828e..7839d8e1 100644 --- a/src/sna/gen5_render.c +++ b/src/sna/gen5_render.c @@ -505,22 +505,6 @@ static uint32_t gen5_get_card_format_for_depth(int depth) } } -static bool gen5_format_is_dst(uint32_t format) -{ - switch (format) { - case GEN5_SURFACEFORMAT_B8G8R8A8_UNORM: - case GEN5_SURFACEFORMAT_R8G8B8A8_UNORM: - case GEN5_SURFACEFORMAT_B10G10R10A2_UNORM: - case GEN5_SURFACEFORMAT_B5G6R5_UNORM: - case GEN5_SURFACEFORMAT_B5G5R5A1_UNORM: - case GEN5_SURFACEFORMAT_A8_UNORM: - case GEN5_SURFACEFORMAT_B4G4R4A4_UNORM: - return true; - default: - return false; - } -} - typedef struct gen5_surface_state_padded { struct gen5_surface_state state; char pad[32 - sizeof(struct gen5_surface_state)]; @@ -677,26 +661,18 @@ gen5_bind_bo(struct sna *sna, if (is_dst) { domains = I915_GEM_DOMAIN_RENDER << 16 | I915_GEM_DOMAIN_RENDER; kgem_bo_mark_dirty(bo); - } else { + } else domains = I915_GEM_DOMAIN_SAMPLER << 16; - is_dst = gen5_format_is_dst(format); + + if (!DBG_NO_SURFACE_CACHE) { + offset = kgem_bo_get_binding(bo, format); + if (offset) + return offset; } offset = sna->kgem.surface - sizeof(struct gen5_surface_state_padded) / sizeof(uint32_t); offset *= sizeof(uint32_t); - if (is_dst) { - if (!DBG_NO_SURFACE_CACHE && bo->dst_bound) - return bo->dst_bound; - - bo->dst_bound = offset; - } else { - if (!DBG_NO_SURFACE_CACHE && bo->src_bound) - return bo->src_bound; - - bo->src_bound = offset; - } - sna->kgem.surface -= sizeof(struct gen5_surface_state_padded) / sizeof(uint32_t); ss = sna->kgem.batch + sna->kgem.surface; @@ -716,6 +692,8 @@ gen5_bind_bo(struct sna *sna, ss[4] = 0; ss[5] = 0; + kgem_bo_set_binding(bo, format, offset); + DBG(("[%x] bind bo(handle=%d, addr=%d), format=%d, width=%d, height=%d, pitch=%d, tiling=%d -> %s\n", offset, bo->handle, ss[1], format, width, height, bo->pitch, bo->tiling, |