[Mesa-stable] [PATCH 3/6] freedreno/a3xx: handle first/last level properly
Rob Clark
robdclark at gmail.com
Tue Sep 2 13:16:22 PDT 2014
From: Rob Clark <robclark at freedesktop.org>
Fixes some assumptions about first_level being zero.
Signed-off-by: Rob Clark <robclark at freedesktop.org>
---
src/gallium/drivers/freedreno/a3xx/fd3_emit.c | 11 ++++++++---
src/gallium/drivers/freedreno/a3xx/fd3_texture.c | 10 +++++-----
src/gallium/drivers/freedreno/a3xx/fd3_texture.h | 1 -
3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
index 44932dc..aae8ff1 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
@@ -215,14 +215,19 @@ emit_textures(struct fd_ringbuffer *ring,
OUT_RING(ring, CP_LOAD_STATE_1_STATE_TYPE(ST_CONSTANTS) |
CP_LOAD_STATE_1_EXT_SRC_ADDR(0));
for (i = 0; i < tex->num_textures; i++) {
- static const struct fd3_pipe_sampler_view dummy_view = {};
+ static const struct fd3_pipe_sampler_view dummy_view = {
+ .base.u.tex.first_level = 1,
+ };
const struct fd3_pipe_sampler_view *view = tex->textures[i] ?
fd3_pipe_sampler_view(tex->textures[i]) :
&dummy_view;
struct fd_resource *rsc = view->tex_resource;
+ unsigned start = view->base.u.tex.first_level;
+ unsigned end = view->base.u.tex.last_level;
- for (j = 0; j < view->mipaddrs; j++) {
- struct fd_resource_slice *slice = fd_resource_slice(rsc, j);
+ for (j = 0; j < (end - start + 1); j++) {
+ struct fd_resource_slice *slice =
+ fd_resource_slice(rsc, j + start);
OUT_RELOC(ring, rsc->bo, slice->offset, 0, 0);
}
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_texture.c b/src/gallium/drivers/freedreno/a3xx/fd3_texture.c
index f28919f..b0e5efb 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_texture.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_texture.c
@@ -144,7 +144,8 @@ fd3_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
{
struct fd3_pipe_sampler_view *so = CALLOC_STRUCT(fd3_pipe_sampler_view);
struct fd_resource *rsc = fd_resource(prsc);
- unsigned miplevels = cso->u.tex.last_level - cso->u.tex.first_level;
+ unsigned lvl = cso->u.tex.first_level;
+ unsigned miplevels = cso->u.tex.last_level - lvl;
if (!so)
return NULL;
@@ -156,7 +157,6 @@ fd3_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
so->base.context = pctx;
so->tex_resource = rsc;
- so->mipaddrs = 1 + miplevels;
so->texconst0 =
A3XX_TEX_CONST_0_TYPE(tex_type(prsc->target)) |
@@ -170,11 +170,11 @@ fd3_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
so->texconst1 =
A3XX_TEX_CONST_1_FETCHSIZE(fd3_pipe2fetchsize(cso->format)) |
- A3XX_TEX_CONST_1_WIDTH(prsc->width0) |
- A3XX_TEX_CONST_1_HEIGHT(prsc->height0);
+ A3XX_TEX_CONST_1_WIDTH(u_minify(prsc->width0, lvl)) |
+ A3XX_TEX_CONST_1_HEIGHT(u_minify(prsc->height0, lvl));
/* when emitted, A3XX_TEX_CONST_2_INDX() must be OR'd in: */
so->texconst2 =
- A3XX_TEX_CONST_2_PITCH(rsc->slices[0].pitch * rsc->cpp);
+ A3XX_TEX_CONST_2_PITCH(rsc->slices[lvl].pitch * rsc->cpp);
so->texconst3 = 0x00000000; /* ??? */
return &so->base;
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_texture.h b/src/gallium/drivers/freedreno/a3xx/fd3_texture.h
index f7e5f0e..a83f527 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_texture.h
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_texture.h
@@ -51,7 +51,6 @@ fd3_sampler_stateobj(struct pipe_sampler_state *samp)
struct fd3_pipe_sampler_view {
struct pipe_sampler_view base;
struct fd_resource *tex_resource;
- uint32_t mipaddrs;
uint32_t texconst0, texconst1, texconst2, texconst3;
};
--
1.9.3
More information about the mesa-stable
mailing list