Mesa (main): virgl: add support for anisotropic texture filtering
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Aug 4 11:36:34 UTC 2021
Module: Mesa
Branch: main
Commit: 2116a4f5cc3a570a30a1378d03dbe5bd9c1ae50c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2116a4f5cc3a570a30a1378d03dbe5bd9c1ae50c
Author: Dave Airlie <airlied at redhat.com>
Date: Mon Jul 19 06:36:01 2021 +1000
virgl: add support for anisotropic texture filtering
This is the guest side for adding correct anisotropic filtering support
Reviewed-by: Gert Wollny <gert.wollny at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11944>
---
src/gallium/drivers/virgl/virgl_encode.c | 3 ++-
src/gallium/drivers/virgl/virgl_screen.c | 4 ++--
src/virtio/virtio-gpu/virgl_hw.h | 1 +
src/virtio/virtio-gpu/virgl_protocol.h | 1 +
4 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/gallium/drivers/virgl/virgl_encode.c b/src/gallium/drivers/virgl/virgl_encode.c
index 01e5637f5bf..27595b6817c 100644
--- a/src/gallium/drivers/virgl/virgl_encode.c
+++ b/src/gallium/drivers/virgl/virgl_encode.c
@@ -949,7 +949,8 @@ int virgl_encode_sampler_state(struct virgl_context *ctx,
VIRGL_OBJ_SAMPLE_STATE_S0_MAG_IMG_FILTER(state->mag_img_filter) |
VIRGL_OBJ_SAMPLE_STATE_S0_COMPARE_MODE(state->compare_mode) |
VIRGL_OBJ_SAMPLE_STATE_S0_COMPARE_FUNC(state->compare_func) |
- VIRGL_OBJ_SAMPLE_STATE_S0_SEAMLESS_CUBE_MAP(state->seamless_cube_map);
+ VIRGL_OBJ_SAMPLE_STATE_S0_SEAMLESS_CUBE_MAP(state->seamless_cube_map) |
+ VIRGL_OBJ_SAMPLE_STATE_S0_MAX_ANISOTROPY((int)(state->max_anisotropy));
virgl_encoder_write_dword(ctx->cbuf, tmp);
virgl_encoder_write_dword(ctx->cbuf, fui(state->lod_bias));
diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c
index cf0d2e0ea80..56cfdc6e524 100644
--- a/src/gallium/drivers/virgl/virgl_screen.c
+++ b/src/gallium/drivers/virgl/virgl_screen.c
@@ -82,7 +82,7 @@ virgl_get_param(struct pipe_screen *screen, enum pipe_cap param)
case PIPE_CAP_VERTEX_SHADER_SATURATE:
return 1;
case PIPE_CAP_ANISOTROPIC_FILTER:
- return 0;
+ return vscreen->caps.caps.v2.max_anisotropy > 1.0;
case PIPE_CAP_POINT_SPRITE:
return 1;
case PIPE_CAP_MAX_RENDER_TARGETS:
@@ -460,7 +460,7 @@ virgl_get_paramf(struct pipe_screen *screen, enum pipe_capf param)
case PIPE_CAPF_MAX_POINT_WIDTH_AA:
return vscreen->caps.caps.v2.max_smooth_point_size;
case PIPE_CAPF_MAX_TEXTURE_ANISOTROPY:
- return 16.0;
+ return vscreen->caps.caps.v2.max_anisotropy;
case PIPE_CAPF_MAX_TEXTURE_LOD_BIAS:
return vscreen->caps.caps.v2.max_texture_lod_bias;
case PIPE_CAPF_MIN_CONSERVATIVE_RASTER_DILATE:
diff --git a/src/virtio/virtio-gpu/virgl_hw.h b/src/virtio/virtio-gpu/virgl_hw.h
index 2cba19307d4..55f974d7883 100644
--- a/src/virtio/virtio-gpu/virgl_hw.h
+++ b/src/virtio/virtio-gpu/virgl_hw.h
@@ -597,6 +597,7 @@ struct virgl_caps_v2 {
uint32_t capability_bits_v2;
uint32_t max_video_memory;
char renderer[64];
+ float max_anisotropy;
};
union virgl_caps {
diff --git a/src/virtio/virtio-gpu/virgl_protocol.h b/src/virtio/virtio-gpu/virgl_protocol.h
index 79d22add1f9..d5eeb0f55b2 100644
--- a/src/virtio/virtio-gpu/virgl_protocol.h
+++ b/src/virtio/virtio-gpu/virgl_protocol.h
@@ -370,6 +370,7 @@ enum virgl_context_cmd {
#define VIRGL_OBJ_SAMPLE_STATE_S0_COMPARE_MODE(x) (((x) & 0x1) << 15)
#define VIRGL_OBJ_SAMPLE_STATE_S0_COMPARE_FUNC(x) (((x) & 0x7) << 16)
#define VIRGL_OBJ_SAMPLE_STATE_S0_SEAMLESS_CUBE_MAP(x) (((x) & 0x1) << 19)
+#define VIRGL_OBJ_SAMPLE_STATE_S0_MAX_ANISOTROPY(x) (((x & 0x3f)) << 20)
#define VIRGL_OBJ_SAMPLER_STATE_LOD_BIAS 3
#define VIRGL_OBJ_SAMPLER_STATE_MIN_LOD 4
More information about the mesa-commit
mailing list