summaryrefslogtreecommitdiffstats
path: root/src/amd/vulkan
diff options
context:
space:
mode:
authorFredrik Höglund <fredrik@kde.org>2016-10-27 03:02:14 +0200
committerEmil Velikov <emil.l.velikov@gmail.com>2016-11-09 13:52:16 +0000
commit2478cfe41db41b5ab9b2ed2c0da9b1dcfc1cfe50 (patch)
treea1d0c1415ca179803e7c73820611379f82e24777 /src/amd/vulkan
parent4514ce8bc7d7aedcb2ecbf366245f0eb5b037663 (diff)
downloadexternal_mesa3d-2478cfe41db41b5ab9b2ed2c0da9b1dcfc1cfe50.zip
external_mesa3d-2478cfe41db41b5ab9b2ed2c0da9b1dcfc1cfe50.tar.gz
external_mesa3d-2478cfe41db41b5ab9b2ed2c0da9b1dcfc1cfe50.tar.bz2
radv: add support for anisotropic filtering on VI+
Ported from radeonsi. Cc: "13.0" <mesa-stable@lists.freedesktop.org> Signed-off-by: Dave Airlie <airlied@redhat.com> (cherry picked from commit e7b9c5eb74619dbda3f24928196ab8c8d9408c0b)
Diffstat (limited to 'src/amd/vulkan')
-rw-r--r--src/amd/vulkan/radv_device.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index e9efe31..1118e3c 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -1734,26 +1734,50 @@ radv_tex_bordercolor(VkBorderColor bcolor)
return 0;
}
+static unsigned
+radv_tex_aniso_filter(unsigned filter)
+{
+ if (filter < 2)
+ return 0;
+ if (filter < 4)
+ return 1;
+ if (filter < 8)
+ return 2;
+ if (filter < 16)
+ return 3;
+ return 4;
+}
+
static void
radv_init_sampler(struct radv_device *device,
struct radv_sampler *sampler,
const VkSamplerCreateInfo *pCreateInfo)
{
- uint32_t max_aniso = 0;
- uint32_t max_aniso_ratio = 0;//TODO
+ uint32_t max_aniso = pCreateInfo->anisotropyEnable && pCreateInfo->maxAnisotropy > 1.0 ?
+ (uint32_t) pCreateInfo->maxAnisotropy : 0;
+ uint32_t max_aniso_ratio = radv_tex_aniso_filter(max_aniso);
bool is_vi;
is_vi = (device->instance->physicalDevice.rad_info.chip_class >= VI);
+ if (!is_vi && max_aniso > 0) {
+ radv_finishme("Anisotropic filtering must be disabled manually "
+ "by the shader on SI-CI when BASE_LEVEL == LAST_LEVEL\n");
+ max_aniso = max_aniso_ratio = 0;
+ }
+
sampler->state[0] = (S_008F30_CLAMP_X(radv_tex_wrap(pCreateInfo->addressModeU)) |
S_008F30_CLAMP_Y(radv_tex_wrap(pCreateInfo->addressModeV)) |
S_008F30_CLAMP_Z(radv_tex_wrap(pCreateInfo->addressModeW)) |
S_008F30_MAX_ANISO_RATIO(max_aniso_ratio) |
S_008F30_DEPTH_COMPARE_FUNC(radv_tex_compare(pCreateInfo->compareOp)) |
S_008F30_FORCE_UNNORMALIZED(pCreateInfo->unnormalizedCoordinates ? 1 : 0) |
+ 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(is_vi));
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)));
+ S_008F34_MAX_LOD(S_FIXED(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)) |
S_008F38_XY_MAG_FILTER(radv_tex_filter(pCreateInfo->magFilter, max_aniso)) |
S_008F38_XY_MIN_FILTER(radv_tex_filter(pCreateInfo->minFilter, max_aniso)) |