-/* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
-
/*
* Copyright (C) 2012 Rob Clark <robclark@freedesktop.org>
*
#include "freedreno_texture.h"
#include "freedreno_context.h"
+#include "freedreno_resource.h"
#include "freedreno_util.h"
static void
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;
unsigned p = i + start;
pipe_sampler_view_reference(&tex->textures[p], view);
- if (tex->textures[p])
+ if (tex->textures[p]) {
+ fd_resource_set_usage(tex->textures[p]->texture, FD_DIRTY_TEX);
tex->valid_textures |= (1 << p);
- else
+ } else {
tex->valid_textures &= ~(1 << p);
+ }
}
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
{
struct fd_context *ctx = fd_context(pctx);
- if (shader == PIPE_SHADER_FRAGMENT) {
- bind_sampler_states(&ctx->fragtex, start, nr, hwcso);
- ctx->dirty |= FD_DIRTY_FRAGTEX;
- }
- else if (shader == PIPE_SHADER_VERTEX) {
- bind_sampler_states(&ctx->verttex, start, nr, hwcso);
- ctx->dirty |= FD_DIRTY_VERTTEX;
- }
+ bind_sampler_states(&ctx->tex[shader], start, nr, hwcso);
+ ctx->dirty_shader[shader] |= FD_DIRTY_SHADER_TEX;
+ ctx->dirty |= FD_DIRTY_TEX;
}
void
-fd_set_sampler_views(struct pipe_context *pctx, unsigned shader,
+fd_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
unsigned start, unsigned nr,
struct pipe_sampler_view **views)
{
struct fd_context *ctx = fd_context(pctx);
- switch (shader) {
- case PIPE_SHADER_FRAGMENT:
- /* on a2xx, since there is a flat address space for textures/samplers,
- * a change in # of fragment textures/samplers will trigger patching
- * and re-emitting the vertex shader:
- *
- * (note: later gen's ignore FD_DIRTY_TEXSTATE so fine to set it)
- */
- if (nr != ctx->fragtex.num_textures)
- ctx->dirty |= FD_DIRTY_TEXSTATE;
-
- set_sampler_views(&ctx->fragtex, start, nr, views);
- ctx->dirty |= FD_DIRTY_FRAGTEX;
- break;
- case PIPE_SHADER_VERTEX:
- set_sampler_views(&ctx->verttex, start, nr, views);
- ctx->dirty |= FD_DIRTY_VERTTEX;
- break;
- default:
- break;
- }
+ set_sampler_views(&ctx->tex[shader], start, nr, views);
+ 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: */