Mesa (main): zink: be more spec-compliant for unnormalizedCoordinates samplers
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Nov 1 00:48:11 UTC 2021
Module: Mesa
Branch: main
Commit: 6ab915960c5d2e9cbb81ccf151cfdf17bfbd3366
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6ab915960c5d2e9cbb81ccf151cfdf17bfbd3366
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Thu Oct 28 11:30:11 2021 -0400
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 at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13587>
---
src/gallium/drivers/zink/zink_context.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 606ebe9adf4..48d701a139e 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -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;
More information about the mesa-commit
mailing list