zink: fix RA textures

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24839>
This commit is contained in:
Karol Herbst 2023-09-19 14:44:26 +02:00 committed by Marge Bot
parent a5ef1067be
commit e36c49b69a
3 changed files with 44 additions and 0 deletions

View file

@ -55,6 +55,8 @@
#include "nir.h"
#include "nir_builder.h"
#include "vk_format.h"
#include "driver_trace/tr_context.h"
#include "util/u_memory.h"
@ -1161,6 +1163,10 @@ zink_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *pres,
} else
assert(state->format == linear);
}
} else if (util_format_is_red_alpha(pres->format)) {
/* RA formats are mapped to RG with adjusted swizzle */
assert(util_format_is_red_green(vk_format_to_pipe_format(ivci.format)));
swizzle[3] = PIPE_SWIZZLE_Y;
}
ivci.components.r = zink_component_mapping(swizzle[0]);

View file

@ -299,6 +299,39 @@ util_format_is_luminance_alpha(enum pipe_format format)
return false;
}
bool
util_format_is_red_alpha(enum pipe_format format)
{
const struct util_format_description *desc =
util_format_description(format);
if ((desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB ||
desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) &&
desc->swizzle[0] == PIPE_SWIZZLE_X &&
desc->swizzle[1] == PIPE_SWIZZLE_0 &&
desc->swizzle[2] == PIPE_SWIZZLE_0 &&
desc->swizzle[3] == PIPE_SWIZZLE_Y) {
return true;
}
return false;
}
bool
util_format_is_red_green(enum pipe_format format)
{
const struct util_format_description *desc =
util_format_description(format);
if ((desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB ||
desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) &&
desc->swizzle[0] == PIPE_SWIZZLE_X &&
desc->swizzle[1] == PIPE_SWIZZLE_Y &&
desc->swizzle[2] == PIPE_SWIZZLE_0 &&
desc->swizzle[3] == PIPE_SWIZZLE_1) {
return true;
}
return false;
}
bool
util_format_is_intensity(enum pipe_format format)

View file

@ -751,6 +751,11 @@ util_format_is_alpha(enum pipe_format format) ATTRIBUTE_CONST;
bool
util_format_is_luminance_alpha(enum pipe_format format) ATTRIBUTE_CONST;
bool
util_format_is_red_alpha(enum pipe_format format) ATTRIBUTE_CONST;
bool
util_format_is_red_green(enum pipe_format format) ATTRIBUTE_CONST;
bool
util_format_is_intensity(enum pipe_format format) ATTRIBUTE_CONST;