freedreno/ir3: Add has_gs flag to shader key
[mesa.git] / src / gallium / drivers / freedreno / freedreno_texture.c
index e9d90aa3a77ea2c7e952be306156eabfa67c5326..84b4df6c1dcd81732a53c71c57c3ff3e7303f8e7 100644 (file)
@@ -1,5 +1,3 @@
-/* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
-
 /*
  * Copyright (C) 2012 Rob Clark <robclark@freedesktop.org>
  *
@@ -33,6 +31,7 @@
 
 #include "freedreno_texture.h"
 #include "freedreno_context.h"
+#include "freedreno_resource.h"
 #include "freedreno_util.h"
 
 static void
@@ -70,6 +69,7 @@ static void set_sampler_views(struct fd_texture_stateobj *tex,
                unsigned start, unsigned nr, struct pipe_sampler_view **views)
 {
        unsigned i;
+       unsigned samplers = 0;
 
        for (i = 0; i < nr; i++) {
                struct pipe_sampler_view *view = views ? views[i] : NULL;
@@ -82,6 +82,13 @@ static void set_sampler_views(struct fd_texture_stateobj *tex,
        }
 
        tex->num_textures = util_last_bit(tex->valid_textures);
+
+       for (i = 0; i < tex->num_textures; i++) {
+               uint nr_samples = fd_resource_nr_samples(tex->textures[i]->texture);
+               samplers |= (nr_samples >> 1) << (i * 2);
+       }
+
+       tex->samples = samplers;
 }
 
 void
@@ -92,13 +99,8 @@ fd_sampler_states_bind(struct pipe_context *pctx,
        struct fd_context *ctx = fd_context(pctx);
 
        bind_sampler_states(&ctx->tex[shader], start, nr, hwcso);
-
-       if (shader == PIPE_SHADER_FRAGMENT) {
-               ctx->dirty |= FD_DIRTY_FRAGTEX;
-       }
-       else if (shader == PIPE_SHADER_VERTEX) {
-               ctx->dirty |= FD_DIRTY_VERTTEX;
-       }
+       ctx->dirty_shader[shader] |= FD_DIRTY_SHADER_TEX;
+       ctx->dirty |= FD_DIRTY_TEX;
 }
 
 void
@@ -109,25 +111,17 @@ fd_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
        struct fd_context *ctx = fd_context(pctx);
 
        set_sampler_views(&ctx->tex[shader], start, nr, views);
-
-       switch (shader) {
-       case PIPE_SHADER_FRAGMENT:
-               ctx->dirty |= FD_DIRTY_FRAGTEX;
-               break;
-       case PIPE_SHADER_VERTEX:
-               ctx->dirty |= FD_DIRTY_VERTTEX;
-               break;
-       default:
-               break;
-       }
+       ctx->dirty_shader[shader] |= FD_DIRTY_SHADER_TEX;
+       ctx->dirty |= FD_DIRTY_TEX;
 }
 
 void
 fd_texture_init(struct pipe_context *pctx)
 {
-       pctx->delete_sampler_state = fd_sampler_state_delete;
-
-       pctx->sampler_view_destroy = fd_sampler_view_destroy;
+       if (!pctx->delete_sampler_state)
+               pctx->delete_sampler_state = fd_sampler_state_delete;
+       if (!pctx->sampler_view_destroy)
+               pctx->sampler_view_destroy = fd_sampler_view_destroy;
 }
 
 /* helper for setting up border-color buffer for a3xx/a4xx: */