Fixes some assumptions about first_level being zero.
Signed-off-by: Rob Clark <robclark@freedesktop.org>
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);
}
{
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;
so->base.context = pctx;
so->tex_resource = rsc;
- so->mipaddrs = 1 + miplevels;
so->texconst0 =
A3XX_TEX_CONST_0_TYPE(tex_type(prsc->target)) |
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;
struct fd3_pipe_sampler_view {
struct pipe_sampler_view base;
struct fd_resource *tex_resource;
- uint32_t mipaddrs;
uint32_t texconst0, texconst1, texconst2, texconst3;
};