From 609101415c28e280fd76029651b155f31ee31243 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 28 Jul 2017 10:31:13 +1000 Subject: [PATCH] vrend: add support for stencil texturing. This should fix stencil drawpixels if the host supports stencil texturing. --- src/virgl_hw.h | 2 ++ src/vrend_renderer.c | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/virgl_hw.h b/src/virgl_hw.h index 89b6e4a..85e31d2 100644 --- a/src/virgl_hw.h +++ b/src/virgl_hw.h @@ -112,6 +112,8 @@ enum virgl_formats { VIRGL_FORMAT_B10G10R10A2_UNORM = 131, VIRGL_FORMAT_R8G8B8X8_UNORM = 134, VIRGL_FORMAT_B4G4R4X4_UNORM = 135, + VIRGL_FORMAT_X24S8_UINT = 136, + VIRGL_FORMAT_S8X24_UINT = 137, VIRGL_FORMAT_B2G3R3_UNORM = 139, VIRGL_FORMAT_L16A16_UNORM = 140, diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 58e182b..a70167a 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -107,6 +107,7 @@ struct global_renderer_state { bool have_bit_encoding; bool have_vertex_attrib_binding; bool have_tf2; + bool have_stencil_texturing; /* these appeared broken on at least one driver */ bool use_explicit_locations; @@ -1930,6 +1931,14 @@ void vrend_set_single_sampler_view(struct vrend_context *ctx, view->depth_texture_mode = GL_RED; } } + if (vrend_state.have_stencil_texturing) { + const struct util_format_description *desc = util_format_description(view->format); + if (!util_format_has_depth(desc)) { + glTexParameteri(view->texture->target, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX); + } else { + glTexParameteri(view->texture->target, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_DEPTH_COMPONENT); + } + } } if (view->cur_base != (view->val1 & 0xff)) { @@ -3853,6 +3862,8 @@ int vrend_renderer_init(struct vrend_if_cbs *cbs, uint32_t flags) if (gl_ver >= 40 || epoxy_has_gl_extension("GL_ARB_transform_feedback2")) vrend_state.have_tf2 = true; + if (epoxy_has_gl_extension("GL_ARB_stencil_texturing")) + vrend_state.have_stencil_texturing = true; if (epoxy_has_gl_extension("GL_EXT_framebuffer_multisample") && epoxy_has_gl_extension("GL_ARB_texture_multisample")) { vrend_state.have_multisample = true; if (epoxy_has_gl_extension("GL_EXT_framebuffer_multisample_blit_scaled"))