diff options
author | Rohan Garg <rohan.garg@intel.com> | 2022-12-01 19:56:37 +0530 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2023-01-06 17:22:15 +0000 |
commit | 1e9fb7c6960dc0b27c6805f3b3bf1839896cd388 (patch) | |
tree | b0825e315ea5cedb33fcb55d782e521bc66c8f31 /src/intel/vulkan | |
parent | 0030d6d2249dee532c1921bfbf35d640d32bccb4 (diff) |
anv,hasvk: Use the inbuilt macro from src/util for clamping int64_t
Signed-off-by: Rohan Garg <rohan.garg@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20104>
Diffstat (limited to 'src/intel/vulkan')
-rw-r--r-- | src/intel/vulkan/anv_private.h | 13 | ||||
-rw-r--r-- | src/intel/vulkan/genX_cmd_buffer.c | 31 | ||||
-rw-r--r-- | src/intel/vulkan/genX_state.c | 8 |
3 files changed, 14 insertions, 38 deletions
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 4c9d566c0ac..447aad06a76 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -351,19 +351,6 @@ anv_minify(uint32_t n, uint32_t levels) return MAX2(n >> levels, 1); } -static inline float -anv_clamp_f(float f, float min, float max) -{ - assert(min < max); - - if (f > max) - return max; - else if (f < min) - return min; - else - return f; -} - static inline union isl_color_value vk_to_isl_color(VkClearColorValue color) { diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index 96fc1475350..c6e4c64fddf 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -3047,17 +3047,6 @@ cmd_buffer_emit_depth_viewport(struct anv_cmd_buffer *cmd_buffer) } } -static int64_t -clamp_int64(int64_t x, int64_t min, int64_t max) -{ - if (x < min) - return min; - else if (x < max) - return x; - else - return max; -} - static void cmd_buffer_emit_scissor(struct anv_cmd_buffer *cmd_buffer) { @@ -3103,19 +3092,19 @@ cmd_buffer_emit_scissor(struct anv_cmd_buffer *cmd_buffer) int64_t x_max = MIN2(s->offset.x + s->extent.width - 1, vp->x + vp->width - 1); - y_max = clamp_int64(y_max, 0, INT16_MAX >> 1); - x_max = clamp_int64(x_max, 0, INT16_MAX >> 1); + y_max = CLAMP(y_max, 0, INT16_MAX >> 1); + x_max = CLAMP(x_max, 0, INT16_MAX >> 1); /* Do this math using int64_t so overflow gets clamped correctly. */ if (cmd_buffer->vk.level == VK_COMMAND_BUFFER_LEVEL_PRIMARY) { - y_min = clamp_int64((uint64_t) y_min, gfx->render_area.offset.y, max); - x_min = clamp_int64((uint64_t) x_min, gfx->render_area.offset.x, max); - y_max = clamp_int64((uint64_t) y_max, 0, - gfx->render_area.offset.y + - gfx->render_area.extent.height - 1); - x_max = clamp_int64((uint64_t) x_max, 0, - gfx->render_area.offset.x + - gfx->render_area.extent.width - 1); + y_min = CLAMP((uint64_t) y_min, gfx->render_area.offset.y, max); + x_min = CLAMP((uint64_t) x_min, gfx->render_area.offset.x, max); + y_max = CLAMP((uint64_t) y_max, 0, + gfx->render_area.offset.y + + gfx->render_area.extent.height - 1); + x_max = CLAMP((uint64_t) x_max, 0, + gfx->render_area.offset.x + + gfx->render_area.extent.width - 1); } const struct GENX(SCISSOR_RECT) scissor = { diff --git a/src/intel/vulkan/genX_state.c b/src/intel/vulkan/genX_state.c index cb5f3dcc9a9..ae9ec5b5ca5 100644 --- a/src/intel/vulkan/genX_state.c +++ b/src/intel/vulkan/genX_state.c @@ -756,7 +756,7 @@ vk_to_intel_tex_filter(VkFilter filter, bool anisotropyEnable) static uint32_t vk_to_intel_max_anisotropy(float ratio) { - return (anv_clamp_f(ratio, 2, 16) - 2) / 2; + return (CLAMP(ratio, 2, 16) - 2) / 2; } static const uint32_t vk_to_intel_mipmap_mode[] = { @@ -949,11 +949,11 @@ VkResult genX(CreateSampler)( .MipModeFilter = mip_filter_mode, .MagModeFilter = vk_to_intel_tex_filter(mag_filter, pCreateInfo->anisotropyEnable), .MinModeFilter = vk_to_intel_tex_filter(min_filter, pCreateInfo->anisotropyEnable), - .TextureLODBias = anv_clamp_f(pCreateInfo->mipLodBias, -16, 15.996), + .TextureLODBias = CLAMP(pCreateInfo->mipLodBias, -16, 15.996), .AnisotropicAlgorithm = pCreateInfo->anisotropyEnable ? EWAApproximation : LEGACY, - .MinLOD = anv_clamp_f(pCreateInfo->minLod, 0, 14), - .MaxLOD = anv_clamp_f(pCreateInfo->maxLod, 0, 14), + .MinLOD = CLAMP(pCreateInfo->minLod, 0, 14), + .MaxLOD = CLAMP(pCreateInfo->maxLod, 0, 14), .ChromaKeyEnable = 0, .ChromaKeyIndex = 0, .ChromaKeyMode = 0, |