summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2014-08-23 11:35:31 -0400
committerRob Clark <[email protected]>2014-08-24 13:09:23 -0400
commitbd3b0964675d36e753e273d5667b922cc9baac4a (patch)
treee141a7bc71746cb4c68729b5a698aaf57ee87466 /src/gallium
parentb40a6c2b17de1f63d70d62608737ed9a259da1c5 (diff)
freedreno/a3xx: handle first/last level properly
Fixes some assumptions about first_level being zero. Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/freedreno/a3xx/fd3_emit.c11
-rw-r--r--src/gallium/drivers/freedreno/a3xx/fd3_texture.c10
-rw-r--r--src/gallium/drivers/freedreno/a3xx/fd3_texture.h1
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 44932dc241d..aae8ff13d19 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 f28919f474e..b0e5efb10a4 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 f7e5f0e650f..a83f527366b 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;
};