mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 11:18:08 +02:00
zink: clamp zs samplers to XXXX swizzle for all non-zero/one swizzles
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10649>
This commit is contained in:
parent
77f3dd85a2
commit
567bdf2e8f
1 changed files with 31 additions and 20 deletions
|
|
@ -509,6 +509,21 @@ clamp_void_swizzle(const struct util_format_description *desc, enum pipe_swizzle
|
|||
return swizzle;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE static enum pipe_swizzle
|
||||
clamp_zs_swizzle(enum pipe_swizzle swizzle)
|
||||
{
|
||||
switch (swizzle) {
|
||||
case PIPE_SWIZZLE_X:
|
||||
case PIPE_SWIZZLE_Y:
|
||||
case PIPE_SWIZZLE_Z:
|
||||
case PIPE_SWIZZLE_W:
|
||||
return PIPE_SWIZZLE_X;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return swizzle;
|
||||
}
|
||||
|
||||
static struct pipe_sampler_view *
|
||||
zink_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *pres,
|
||||
const struct pipe_sampler_view *state)
|
||||
|
|
@ -530,33 +545,29 @@ zink_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *pres,
|
|||
ivci.image = res->obj->image;
|
||||
ivci.viewType = image_view_type(state->target);
|
||||
|
||||
ivci.components.r = component_mapping(sampler_view->base.swizzle_r);
|
||||
ivci.components.g = component_mapping(sampler_view->base.swizzle_g);
|
||||
ivci.components.b = component_mapping(sampler_view->base.swizzle_b);
|
||||
ivci.components.a = component_mapping(sampler_view->base.swizzle_a);
|
||||
|
||||
ivci.subresourceRange.aspectMask = sampler_aspect_from_format(state->format);
|
||||
ivci.format = zink_get_format(screen, state->format);
|
||||
/* samplers for stencil aspects of packed formats need to always use stencil swizzle */
|
||||
if (ivci.subresourceRange.aspectMask == VK_IMAGE_ASPECT_STENCIL_BIT) {
|
||||
ivci.components.g = VK_COMPONENT_SWIZZLE_R;
|
||||
if (ivci.subresourceRange.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) {
|
||||
ivci.components.r = component_mapping(clamp_zs_swizzle(sampler_view->base.swizzle_r));
|
||||
ivci.components.g = component_mapping(clamp_zs_swizzle(sampler_view->base.swizzle_g));
|
||||
ivci.components.b = component_mapping(clamp_zs_swizzle(sampler_view->base.swizzle_b));
|
||||
ivci.components.a = component_mapping(clamp_zs_swizzle(sampler_view->base.swizzle_a));
|
||||
} else {
|
||||
/* if we have e.g., R8G8B8X8, then we have to ignore alpha since we're just emulating
|
||||
* these formats
|
||||
*/
|
||||
if (ivci.subresourceRange.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT) {
|
||||
const struct util_format_description *desc = util_format_description(state->format);
|
||||
if (util_format_is_rgba8_variant(desc)) {
|
||||
sampler_view->base.swizzle_r = clamp_void_swizzle(desc, sampler_view->base.swizzle_r);
|
||||
sampler_view->base.swizzle_g = clamp_void_swizzle(desc, sampler_view->base.swizzle_g);
|
||||
sampler_view->base.swizzle_b = clamp_void_swizzle(desc, sampler_view->base.swizzle_b);
|
||||
sampler_view->base.swizzle_a = clamp_void_swizzle(desc, sampler_view->base.swizzle_a);
|
||||
ivci.components.r = component_mapping(sampler_view->base.swizzle_r);
|
||||
ivci.components.g = component_mapping(sampler_view->base.swizzle_g);
|
||||
ivci.components.b = component_mapping(sampler_view->base.swizzle_b);
|
||||
ivci.components.a = component_mapping(sampler_view->base.swizzle_a);
|
||||
}
|
||||
}
|
||||
const struct util_format_description *desc = util_format_description(state->format);
|
||||
if (util_format_is_rgba8_variant(desc)) {
|
||||
sampler_view->base.swizzle_r = clamp_void_swizzle(desc, sampler_view->base.swizzle_r);
|
||||
sampler_view->base.swizzle_g = clamp_void_swizzle(desc, sampler_view->base.swizzle_g);
|
||||
sampler_view->base.swizzle_b = clamp_void_swizzle(desc, sampler_view->base.swizzle_b);
|
||||
sampler_view->base.swizzle_a = clamp_void_swizzle(desc, sampler_view->base.swizzle_a);
|
||||
}
|
||||
ivci.components.r = component_mapping(sampler_view->base.swizzle_r);
|
||||
ivci.components.g = component_mapping(sampler_view->base.swizzle_g);
|
||||
ivci.components.b = component_mapping(sampler_view->base.swizzle_b);
|
||||
ivci.components.a = component_mapping(sampler_view->base.swizzle_a);
|
||||
}
|
||||
assert(ivci.format);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue