From 14972df3a63ec1cc2db0ee21f90b60bf66bdd2b0 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Thu, 17 Jan 2019 13:40:32 +0100 Subject: [PATCH] renderer: set more texture-view state up-front MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These settings can't change in the lifetime of the texture-view, so let's set them up front instead of re-setting them on every re-emit. Signed-off-by: Erik Faye-Lund Reviewed-by: Stéphane Marchesin --- src/vrend_renderer.c | 53 ++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 9b723f4..412ccc0 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -1889,6 +1889,25 @@ int vrend_create_sampler_view(struct vrend_context *ctx, base_layer, max_layer - base_layer + 1); glBindTexture(view->texture->target, view->id); + + if (util_format_is_depth_or_stencil(view->format)) { + if (vrend_state.use_core_profile == false) { + /* setting depth texture mode is deprecated in core profile */ + if (view->depth_texture_mode != GL_RED) { + glTexParameteri(view->texture->target, GL_DEPTH_TEXTURE_MODE, GL_RED); + view->depth_texture_mode = GL_RED; + } + } + if (has_feature(feat_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); + } + } + } + glTexParameteri(view->texture->target, GL_TEXTURE_BASE_LEVEL, base_level); glTexParameteri(view->texture->target, GL_TEXTURE_MAX_LEVEL, max_level); glTexParameteri(view->texture->target, GL_TEXTURE_SWIZZLE_R, view->gl_swizzle_r); @@ -2570,27 +2589,27 @@ void vrend_set_single_sampler_view(struct vrend_context *ctx, return; } if (!view->texture->is_buffer) { - glBindTexture(view->target, view->id); - - if (util_format_is_depth_or_stencil(view->format)) { - if (vrend_state.use_core_profile == false) { - /* setting depth texture mode is deprecated in core profile */ - if (view->depth_texture_mode != GL_RED) { - glTexParameteri(view->texture->target, GL_DEPTH_TEXTURE_MODE, GL_RED); - view->depth_texture_mode = GL_RED; + if (view->texture->id == view->id) { + glBindTexture(view->target, view->id); + + if (util_format_is_depth_or_stencil(view->format)) { + if (vrend_state.use_core_profile == false) { + /* setting depth texture mode is deprecated in core profile */ + if (view->depth_texture_mode != GL_RED) { + glTexParameteri(view->texture->target, GL_DEPTH_TEXTURE_MODE, GL_RED); + view->depth_texture_mode = GL_RED; + } } - } - if (has_feature(feat_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 (has_feature(feat_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->texture->id == view->id) { if (tex->cur_base != (view->val1 & 0xff)) { int base_level = view->val1 & 0xff; glTexParameteri(view->texture->target, GL_TEXTURE_BASE_LEVEL, base_level);