zink: support emulating alpha formats using new border color quirk

this works for texturing only because swizzles can be used

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17687>
This commit is contained in:
Mike Blumenkrantz
2022-08-02 08:34:12 -04:00
committed by Marge Bot
parent d5bf01e214
commit d49586cfae
7 changed files with 70 additions and 11 deletions
+1 -1
View File
@@ -128,7 +128,7 @@ traces:
- device: freedreno-a630
checksum: 730692659fbb9eefa44d6b1a2df2fa8e
- device: zink-a630
checksum: 5a97da6dbb6c10d615f92030c03d116c
checksum: 165d3c13c8143fbc2265a55758afc04c
- path: behdad-glyphy/glyphy.trace
expectations:
- device: freedreno-a306
@@ -245,10 +245,6 @@ spec@!opengl 1.0@rasterpos,Fail
spec@!opengl 1.0@rasterpos@glsl_vs_gs_linked,Fail
spec@!opengl 1.0@rasterpos@glsl_vs_tes_linked,Fail
#these need format conversions that gallium doesn't implement yet
spec@arb_texture_buffer_object@formats (fs- arb),Crash
spec@arb_texture_buffer_object@formats (vs- arb),Crash
spec@arb_arrays_of_arrays@execution@image_store@basic-imagestore-mixed-const-non-const-uniform-index,Fail
spec@arb_arrays_of_arrays@execution@image_store@basic-imagestore-mixed-const-non-const-uniform-index2,Fail
@@ -42,3 +42,7 @@ glx@glx-tfp
# These tests started hitting timeouts when we upgraded LLVM from v11 to 13
spec@arb_texture_rg@fbo-blending-formats
#these need format conversions that gallium doesn't implement yet
spec@arb_texture_buffer_object@formats.*arb.*
@@ -239,8 +239,6 @@ spec@arb_shader_texture_lod@execution@glsl-fs-shadow2dgradarb-cumulative,Fail
spec@arb_shading_language_packing@execution@built-in-functions@fs-packhalf2x16,Fail
spec@arb_shading_language_packing@execution@built-in-functions@vs-packhalf2x16,Fail
spec@arb_tessellation_shader@arb_tessellation_shader-tes-gs-max-output -small -scan 1 50,Crash
spec@arb_texture_buffer_object@formats (fs- arb),Crash
spec@arb_texture_buffer_object@formats (vs- arb),Crash
spec@arb_texture_float@fbo-blending-formats,Fail
spec@arb_texture_float@fbo-blending-formats@GL_INTENSITY16F_ARB,Fail
spec@arb_texture_float@fbo-blending-formats@GL_INTENSITY32F_ARB,Fail
@@ -18,3 +18,6 @@ glx@glx-tfp
# Tests below timeout most of the time.
KHR-GL46.copy_image.functional
KHR-GL46.texture_swizzle.smoke
#these need format conversions that gallium doesn't implement yet
spec@arb_texture_buffer_object@formats.*arb.*
+45
View File
@@ -871,6 +871,36 @@ clamp_zs_swizzle(enum pipe_swizzle swizzle)
return swizzle;
}
ALWAYS_INLINE static enum pipe_swizzle
clamp_alpha_swizzle(enum pipe_swizzle swizzle)
{
if (swizzle == PIPE_SWIZZLE_W)
return PIPE_SWIZZLE_X;
if (swizzle < PIPE_SWIZZLE_W)
return PIPE_SWIZZLE_0;
return swizzle;
}
ALWAYS_INLINE static enum pipe_swizzle
clamp_luminance_swizzle(enum pipe_swizzle swizzle)
{
if (swizzle == PIPE_SWIZZLE_W)
return PIPE_SWIZZLE_1;
if (swizzle < PIPE_SWIZZLE_W)
return PIPE_SWIZZLE_X;
return swizzle;
}
ALWAYS_INLINE static enum pipe_swizzle
clamp_luminance_alpha_swizzle(enum pipe_swizzle swizzle)
{
if (swizzle == PIPE_SWIZZLE_W)
return PIPE_SWIZZLE_Y;
if (swizzle < PIPE_SWIZZLE_W)
return PIPE_SWIZZLE_X;
return swizzle;
}
ALWAYS_INLINE static bool
viewtype_is_cube(const VkImageViewCreateInfo *ivci)
{
@@ -945,6 +975,21 @@ zink_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *pres,
ivci.components.g = zink_component_mapping(zink_clamp_void_swizzle(desc, sampler_view->base.swizzle_g));
ivci.components.b = zink_component_mapping(zink_clamp_void_swizzle(desc, sampler_view->base.swizzle_b));
ivci.components.a = zink_component_mapping(zink_clamp_void_swizzle(desc, sampler_view->base.swizzle_a));
} else if (util_format_is_alpha(state->format)) {
ivci.components.r = zink_component_mapping(clamp_alpha_swizzle(sampler_view->base.swizzle_r));
ivci.components.g = zink_component_mapping(clamp_alpha_swizzle(sampler_view->base.swizzle_g));
ivci.components.b = zink_component_mapping(clamp_alpha_swizzle(sampler_view->base.swizzle_b));
ivci.components.a = zink_component_mapping(clamp_alpha_swizzle(sampler_view->base.swizzle_a));
} else if (util_format_is_luminance(state->format)) {
ivci.components.r = zink_component_mapping(clamp_luminance_swizzle(sampler_view->base.swizzle_r));
ivci.components.g = zink_component_mapping(clamp_luminance_swizzle(sampler_view->base.swizzle_g));
ivci.components.b = zink_component_mapping(clamp_luminance_swizzle(sampler_view->base.swizzle_b));
ivci.components.a = zink_component_mapping(clamp_luminance_swizzle(sampler_view->base.swizzle_a));
} else if (util_format_is_luminance_alpha(state->format)) {
ivci.components.r = zink_component_mapping(clamp_luminance_alpha_swizzle(sampler_view->base.swizzle_r));
ivci.components.g = zink_component_mapping(clamp_luminance_alpha_swizzle(sampler_view->base.swizzle_g));
ivci.components.b = zink_component_mapping(clamp_luminance_alpha_swizzle(sampler_view->base.swizzle_b));
ivci.components.a = zink_component_mapping(clamp_luminance_alpha_swizzle(sampler_view->base.swizzle_a));
} else {
ivci.components.r = zink_component_mapping(sampler_view->base.swizzle_r);
ivci.components.g = zink_component_mapping(sampler_view->base.swizzle_g);
+17 -4
View File
@@ -550,9 +550,10 @@ zink_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_GL_CLAMP:
return 0;
case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK: {
enum pipe_quirk_texture_border_color_swizzle quirk = PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_ALPHA_NOT_W;
if (!screen->info.border_color_feats.customBorderColorWithoutFormat)
return PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_FREEDRENO;
return quirk | PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_FREEDRENO;
/* assume that if drivers don't implement this extension they either:
* - don't support custom border colors
* - handle things correctly
@@ -560,8 +561,9 @@ zink_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
*/
if (screen->info.have_EXT_border_color_swizzle &&
!screen->info.border_swizzle_feats.borderColorSwizzleFromImage)
return PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50;
return 0;
return quirk | PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50;
return quirk;
}
case PIPE_CAP_MAX_TEXTURE_2D_SIZE:
return screen->info.props.limits.maxImageDimension2D;
@@ -1515,6 +1517,8 @@ emulate_x8(enum pipe_format format)
VkFormat
zink_get_format(struct zink_screen *screen, enum pipe_format format)
{
format = zink_format_get_emulated_alpha(format);
VkFormat ret = zink_pipe_format_to_vk_format(emulate_x8(format));
if (format == PIPE_FORMAT_X32_S8X24_UINT &&
@@ -1544,6 +1548,9 @@ zink_get_format(struct zink_screen *screen, enum pipe_format format)
!screen->info.format_4444_feats.formatA4R4G4B4))
return VK_FORMAT_UNDEFINED;
if (format == PIPE_FORMAT_R4A4_UNORM)
return VK_FORMAT_R4G4_UNORM_PACK8;
return ret;
}
@@ -1755,6 +1762,12 @@ populate_format_props(struct zink_screen *screen)
}
} else
VKSCR(GetPhysicalDeviceFormatProperties)(screen->pdev, format, &screen->format_props[i]);
if (zink_format_is_emulated_alpha(i)) {
VkFormatFeatureFlags blocked = VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT;
screen->format_props[i].linearTilingFeatures &= ~blocked;
screen->format_props[i].optimalTilingFeatures &= ~blocked;
screen->format_props[i].bufferFeatures = 0;
}
}
VkImageFormatProperties image_props;
VkResult ret = VKSCR(GetPhysicalDeviceImageFormatProperties)(screen->pdev, VK_FORMAT_D32_SFLOAT,