summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Hellstrom <[email protected]>2017-05-30 15:54:38 +0200
committerThomas Hellstrom <[email protected]>2017-06-07 19:43:54 +0200
commit2c4ec3f93fcab3fddcbe132200b210e7def1facc (patch)
treed40f3ddb09ecacb7edc0ac105f5c4aa5fecca8ad /src
parentdf4d6003dc75395f8ded57fdf59046f0d008eea3 (diff)
svga: Always set the alpha value to 1 when sampling using an XRGB view
If the XRGB view is sampling from an ARGB svga format, change PIPE_SWIZZLE_W to PIPE_SWIZZLE_1 for all channels. Previously we unconditionally set PIPE_SWIZZLE_1 on the alpha channel which could be both insufficient and incorrect. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Charmaine Lee <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/svga/svga_shader.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/src/gallium/drivers/svga/svga_shader.c b/src/gallium/drivers/svga/svga_shader.c
index 795531773bf..d069b0d29c4 100644
--- a/src/gallium/drivers/svga/svga_shader.c
+++ b/src/gallium/drivers/svga/svga_shader.c
@@ -31,7 +31,6 @@
#include "svga_format.h"
#include "svga_shader.h"
#include "svga_resource_texture.h"
-#include "svga3d_surfacedefs.h"
/**
@@ -163,6 +162,25 @@ svga_remap_generic_index(int8_t remap_table[MAX_GENERIC_VARYING],
return remap_table[generic_index];
}
+static const enum pipe_swizzle copy_alpha[PIPE_SWIZZLE_MAX] = {
+ PIPE_SWIZZLE_X,
+ PIPE_SWIZZLE_Y,
+ PIPE_SWIZZLE_Z,
+ PIPE_SWIZZLE_W,
+ PIPE_SWIZZLE_0,
+ PIPE_SWIZZLE_1,
+ PIPE_SWIZZLE_NONE
+};
+
+static const enum pipe_swizzle set_alpha[PIPE_SWIZZLE_MAX] = {
+ PIPE_SWIZZLE_X,
+ PIPE_SWIZZLE_Y,
+ PIPE_SWIZZLE_Z,
+ PIPE_SWIZZLE_1,
+ PIPE_SWIZZLE_0,
+ PIPE_SWIZZLE_1,
+ PIPE_SWIZZLE_NONE
+};
/**
* Initialize the shader-neutral fields of svga_compile_key from context
@@ -174,6 +192,7 @@ svga_init_shader_key_common(const struct svga_context *svga,
struct svga_compile_key *key)
{
unsigned i, idx = 0;
+ const enum pipe_swizzle *swizzle_tab;
assert(shader < ARRAY_SIZE(svga->curr.num_sampler_views));
@@ -212,22 +231,20 @@ svga_init_shader_key_common(const struct svga_context *svga,
++key->num_unnormalized_coords;
}
- key->tex[i].swizzle_r = view->swizzle_r;
- key->tex[i].swizzle_g = view->swizzle_g;
- key->tex[i].swizzle_b = view->swizzle_b;
+ swizzle_tab = (!util_format_has_alpha(view->format) &&
+ svga_texture_device_format_has_alpha(view->texture)) ?
+ set_alpha : copy_alpha;
/* If we have a non-alpha view into an svga3d surface with an
* alpha channel, then explicitly set the alpha channel to 1
- * when sampling. Note that we need to check the svga3d format
- * in the svga texture key, since the imported format is
- * stored here and it may differ from the gallium format.
+ * when sampling. Note that we need to check the
+ * actual device format to cover also imported surface cases.
*/
- if (!util_format_has_alpha(view->format) &&
- svga_texture_device_format_has_alpha(view->texture)) {
- key->tex[i].swizzle_a = PIPE_SWIZZLE_1;
- } else {
- key->tex[i].swizzle_a = view->swizzle_a;
- }
+
+ key->tex[i].swizzle_r = swizzle_tab[view->swizzle_r];
+ key->tex[i].swizzle_g = swizzle_tab[view->swizzle_g];
+ key->tex[i].swizzle_b = swizzle_tab[view->swizzle_b];
+ key->tex[i].swizzle_a = swizzle_tab[view->swizzle_a];
}
}
}