[virglrenderer-devel] [PATCH 3/6] renderer: refactor sampler binding.

Dave Airlie airlied at gmail.com
Fri Jun 8 01:18:52 UTC 2018


From: Dave Airlie <airlied at redhat.com>

This is just a cleanup that makes it easier to add texture view support.
---
 src/vrend_renderer.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index 1115aaa..be597a2 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -2835,11 +2835,7 @@ static void vrend_draw_bind_samplers(struct vrend_context *ctx)
    for (shader_type = PIPE_SHADER_VERTEX; shader_type <= ctx->sub->last_shader_idx; shader_type++) {
       int index = 0;
       for (i = 0; i < ctx->sub->views[shader_type].num_views; i++) {
-         struct vrend_resource *texture = NULL;
-
-         if (ctx->sub->views[shader_type].views[i]) {
-            texture = ctx->sub->views[shader_type].views[i]->texture;
-         }
+         struct vrend_sampler_view *tview = ctx->sub->views[shader_type].views[i];
 
          if (!(ctx->sub->prog->samplers_used_mask[shader_type] & (1 << i)))
             continue;
@@ -2848,7 +2844,6 @@ static void vrend_draw_bind_samplers(struct vrend_context *ctx)
             glUniform1i(ctx->sub->prog->samp_locs[shader_type][index], sampler_id);
 
          if (ctx->sub->prog->shadow_samp_mask[shader_type] & (1 << i)) {
-            struct vrend_sampler_view *tview = ctx->sub->views[shader_type].views[i];
             glUniform4f(ctx->sub->prog->shadow_samp_mask_locs[shader_type][index],
                         (tview->gl_swizzle_r == GL_ZERO || tview->gl_swizzle_r == GL_ONE) ? 0.0 : 1.0,
                         (tview->gl_swizzle_g == GL_ZERO || tview->gl_swizzle_g == GL_ONE) ? 0.0 : 1.0,
@@ -2862,8 +2857,9 @@ static void vrend_draw_bind_samplers(struct vrend_context *ctx)
          }
 
          glActiveTexture(GL_TEXTURE0 + sampler_id);
-         if (texture) {
+         if (tview->texture) {
             int id;
+            struct vrend_resource *texture = tview->texture;
             GLenum target = texture->target;
 
             if (texture->is_buffer) {
@@ -2874,7 +2870,7 @@ static void vrend_draw_bind_samplers(struct vrend_context *ctx)
 
             glBindTexture(target, id);
             if (ctx->sub->views[shader_type].old_ids[i] != id || ctx->sub->sampler_state_dirty) {
-               vrend_apply_sampler_state(ctx, texture, shader_type, i, sampler_id, ctx->sub->views[shader_type].views[i]->srgb_decode);
+               vrend_apply_sampler_state(ctx, texture, shader_type, i, sampler_id, tview->srgb_decode);
                ctx->sub->views[shader_type].old_ids[i] = id;
             }
             if (ctx->sub->rs_state.point_quad_rasterization) {
-- 
2.14.3



More information about the virglrenderer-devel mailing list