From 6ab915960c5d2e9cbb81ccf151cfdf17bfbd3366 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 28 Oct 2021 11:30:11 -0400 Subject: [PATCH] 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 Part-of: --- 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;