mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 03:18:08 +02:00
radv: Refactor S_FIXED to radv_float_to_{s,u}fixed
We'll need to use this in radv_image for VK_EXT_image_view_min_lod. Additionally, creates signed/unsigned variants to avoid sign-extending where we don't need to. Signed-off-by: Joshua Ashton <joshua@froggi.es> Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13820>
This commit is contained in:
parent
35ffadb9e7
commit
c6471ef918
2 changed files with 15 additions and 9 deletions
|
|
@ -7214,12 +7214,6 @@ radv_get_max_anisotropy(struct radv_device *device, const VkSamplerCreateInfo *p
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
S_FIXED(float value, unsigned frac_bits)
|
||||
{
|
||||
return value * (1 << frac_bits);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
radv_register_border_color(struct radv_device *device, VkClearColorValue value)
|
||||
{
|
||||
|
|
@ -7312,10 +7306,10 @@ radv_init_sampler(struct radv_device *device, struct radv_sampler *sampler,
|
|||
S_008F30_ANISO_THRESHOLD(max_aniso_ratio >> 1) | S_008F30_ANISO_BIAS(max_aniso_ratio) |
|
||||
S_008F30_DISABLE_CUBE_WRAP(0) | S_008F30_COMPAT_MODE(compat_mode) |
|
||||
S_008F30_FILTER_MODE(filter_mode) | S_008F30_TRUNC_COORD(trunc_coord));
|
||||
sampler->state[1] = (S_008F34_MIN_LOD(S_FIXED(CLAMP(pCreateInfo->minLod, 0, 15), 8)) |
|
||||
S_008F34_MAX_LOD(S_FIXED(CLAMP(pCreateInfo->maxLod, 0, 15), 8)) |
|
||||
sampler->state[1] = (S_008F34_MIN_LOD(radv_float_to_ufixed(CLAMP(pCreateInfo->minLod, 0, 15), 8)) |
|
||||
S_008F34_MAX_LOD(radv_float_to_ufixed(CLAMP(pCreateInfo->maxLod, 0, 15), 8)) |
|
||||
S_008F34_PERF_MIP(max_aniso_ratio ? max_aniso_ratio + 6 : 0));
|
||||
sampler->state[2] = (S_008F38_LOD_BIAS(S_FIXED(CLAMP(pCreateInfo->mipLodBias, -16, 16), 8)) |
|
||||
sampler->state[2] = (S_008F38_LOD_BIAS(radv_float_to_sfixed(CLAMP(pCreateInfo->mipLodBias, -16, 16), 8)) |
|
||||
S_008F38_XY_MAG_FILTER(radv_tex_filter(pCreateInfo->magFilter, max_aniso)) |
|
||||
S_008F38_XY_MIN_FILTER(radv_tex_filter(pCreateInfo->minFilter, max_aniso)) |
|
||||
S_008F38_MIP_FILTER(radv_tex_mipfilter(pCreateInfo->mipmapMode)) |
|
||||
|
|
|
|||
|
|
@ -203,6 +203,18 @@ radv_clear_mask(uint32_t *inout_mask, uint32_t clear_mask)
|
|||
}
|
||||
}
|
||||
|
||||
static inline int
|
||||
radv_float_to_sfixed(float value, unsigned frac_bits)
|
||||
{
|
||||
return value * (1 << frac_bits);
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
radv_float_to_ufixed(float value, unsigned frac_bits)
|
||||
{
|
||||
return value * (1 << frac_bits);
|
||||
}
|
||||
|
||||
/* Whenever we generate an error, pass it through this function. Useful for
|
||||
* debugging, where we can break on it. Only call at error site, not when
|
||||
* propagating errors. Might be useful to plug in a stack trace here.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue