zink: track depth swizzle on samplerviews

this will provide info for shader rewrites

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20598>
This commit is contained in:
Mike Blumenkrantz
2023-01-05 16:28:33 -05:00
committed by Marge Bot
parent c20c79f584
commit f62ccaacb8
3 changed files with 24 additions and 0 deletions

View File

@@ -1022,6 +1022,19 @@ zink_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *pres,
ivci.components.b = zink_component_mapping(clamp_zs_swizzle(sampler_view->base.swizzle_b));
ivci.components.a = zink_component_mapping(clamp_zs_swizzle(sampler_view->base.swizzle_a));
}
if (ivci.subresourceRange.aspectMask == VK_IMAGE_ASPECT_DEPTH_BIT) {
VkComponentSwizzle *swizzle = (VkComponentSwizzle*)&ivci.components;
for (unsigned i = 0; i < 4; i++) {
/* these require shader rewrites to correctly emulate */
if (swizzle[i] == VK_COMPONENT_SWIZZLE_ONE || swizzle[i] == VK_COMPONENT_SWIZZLE_ZERO)
sampler_view->shadow_needs_shader_swizzle = true;
}
/* this is the data that will be used in shader rewrites */
sampler_view->swizzle.s[0] = clamp_zs_swizzle(sampler_view->base.swizzle_r);
sampler_view->swizzle.s[1] = clamp_zs_swizzle(sampler_view->base.swizzle_g);
sampler_view->swizzle.s[2] = clamp_zs_swizzle(sampler_view->base.swizzle_b);
sampler_view->swizzle.s[3] = clamp_zs_swizzle(sampler_view->base.swizzle_a);
}
} else {
enum pipe_swizzle swizzle[4] = {
sampler_view->base.swizzle_r,

View File

@@ -67,6 +67,15 @@ struct zink_gs_key {
unsigned size;
};
struct zink_fs_shadow_swizzle {
uint8_t s[4];
};
struct zink_fs_shadow_key {
uint32_t mask;
struct zink_fs_shadow_swizzle swizzle[32];
};
struct zink_fs_key_base {
bool coord_replace_yinvert : 1;
bool samples : 1;

View File

@@ -1468,6 +1468,8 @@ struct zink_sampler_view {
struct zink_buffer_view *buffer_view;
};
struct zink_surface *cube_array;
bool shadow_needs_shader_swizzle;
struct zink_fs_shadow_swizzle swizzle;
};
struct zink_image_view {