zink: be more spec-compliant for unnormalizedCoordinates samplers

the spec prohibits using most stuff with these, but also they probably
are just texelfetch anyway so it doesn't matter

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13587>
This commit is contained in:
Mike Blumenkrantz
2021-10-28 11:30:11 -04:00
committed by Marge Bot
parent 75dc302340
commit 6ab915960c
+17 -7
View File
@@ -301,8 +301,12 @@ zink_create_sampler_state(struct pipe_context *pctx,
VkSamplerCreateInfo sci = {0};
VkSamplerCustomBorderColorCreateInfoEXT cbci = {0};
sci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
sci.unnormalizedCoordinates = !state->normalized_coords;
sci.magFilter = zink_filter(state->mag_img_filter);
sci.minFilter = zink_filter(state->min_img_filter);
if (sci.unnormalizedCoordinates)
sci.minFilter = sci.magFilter;
else
sci.minFilter = zink_filter(state->min_img_filter);
VkSamplerReductionModeCreateInfo rci;
rci.sType = VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO;
@@ -321,7 +325,9 @@ zink_create_sampler_state(struct pipe_context *pctx,
if (state->reduction_mode)
sci.pNext = &rci;
if (state->min_mip_filter != PIPE_TEX_MIPFILTER_NONE) {
if (sci.unnormalizedCoordinates) {
sci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST;
} else if (state->min_mip_filter != PIPE_TEX_MIPFILTER_NONE) {
sci.mipmapMode = sampler_mipmap_mode(state->min_mip_filter);
sci.minLod = state->min_lod;
sci.maxLod = state->max_lod;
@@ -331,9 +337,13 @@ zink_create_sampler_state(struct pipe_context *pctx,
sci.maxLod = 0.25f;
}
sci.addressModeU = sampler_address_mode(state->wrap_s);
sci.addressModeV = sampler_address_mode(state->wrap_t);
sci.addressModeW = sampler_address_mode(state->wrap_r);
if (!sci.unnormalizedCoordinates) {
sci.addressModeU = sampler_address_mode(state->wrap_s);
sci.addressModeV = sampler_address_mode(state->wrap_t);
sci.addressModeW = sampler_address_mode(state->wrap_r);
} else {
sci.addressModeU = sci.addressModeV = sci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
}
sci.mipLodBias = state->lod_bias;
need_custom |= wrap_needs_border_color(state->wrap_s);
@@ -363,10 +373,10 @@ zink_create_sampler_state(struct pipe_context *pctx,
assert(check <= screen->info.border_color_props.maxCustomBorderColorSamplers);
} else
sci.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK; // TODO with custom shader if we're super interested?
if (sci.unnormalizedCoordinates)
sci.addressModeU = sci.addressModeV = sci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER;
}
sci.unnormalizedCoordinates = !state->normalized_coords;
if (state->max_anisotropy > 1) {
sci.maxAnisotropy = state->max_anisotropy;
sci.anisotropyEnable = VK_TRUE;