st/mesa: add NV_viewport_swizzle support
authorIlia Mirkin <imirkin@alum.mit.edu>
Mon, 6 Apr 2020 05:57:54 +0000 (01:57 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Sun, 12 Apr 2020 16:01:46 +0000 (12:01 -0400)
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4519>

src/mesa/state_tracker/st_atom_viewport.c
src/mesa/state_tracker/st_extensions.c

index 4a07b2d0914ef00160fa3f70bbe3d521b02c9c62..ad0ad6bd775caac35cc07c83418c5c4ec9826121 100644 (file)
 #include "pipe/p_context.h"
 #include "cso_cache/cso_context.h"
 
+static enum pipe_viewport_swizzle
+viewport_swizzle_from_glenum(GLenum16 swizzle)
+{
+   return swizzle - GL_VIEWPORT_SWIZZLE_POSITIVE_X_NV;
+}
+
 /**
  * Update the viewport transformation matrix.  Depends on:
  *  - viewport pos/size
@@ -60,6 +66,11 @@ st_update_viewport( struct st_context *st )
          scale[1] *= -1;
          translate[1] = st->state.fb_height - translate[1];
       }
+
+      st->state.viewport[i].swizzle_x = viewport_swizzle_from_glenum(ctx->ViewportArray[i].SwizzleX);
+      st->state.viewport[i].swizzle_y = viewport_swizzle_from_glenum(ctx->ViewportArray[i].SwizzleY);
+      st->state.viewport[i].swizzle_z = viewport_swizzle_from_glenum(ctx->ViewportArray[i].SwizzleZ);
+      st->state.viewport[i].swizzle_w = viewport_swizzle_from_glenum(ctx->ViewportArray[i].SwizzleW);
    }
 
    cso_set_viewport(st->cso_context, &st->state.viewport[0]);
index 7d77ed4151d860d578ec7f9296b1b9c35b0f7f3f..9db85a077f652a05fdbca3c5567e7dbe37e7c0b4 100644 (file)
@@ -804,6 +804,7 @@ void st_init_extensions(struct pipe_screen *screen,
       { o(NV_primitive_restart),             PIPE_CAP_PRIMITIVE_RESTART                },
       { o(NV_shader_atomic_float),           PIPE_CAP_TGSI_ATOMFADD                    },
       { o(NV_texture_barrier),               PIPE_CAP_TEXTURE_BARRIER                  },
+      { o(NV_viewport_swizzle),              PIPE_CAP_VIEWPORT_SWIZZLE                 },
       { o(NVX_gpu_memory_info),              PIPE_CAP_QUERY_MEMORY_INFO                },
       /* GL_NV_point_sprite is not supported by gallium because we don't
        * support the GL_POINT_SPRITE_R_MODE_NV option. */