i915g: Compute 3DSTATE_BUF_INFO flags at surface create time.

No need to compute them at state emit.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11512>
This commit is contained in:
Emma Anholt
2021-06-20 08:52:25 -07:00
parent f8867b3d98
commit 5b3840d961
3 changed files with 25 additions and 25 deletions
+1
View File
@@ -213,6 +213,7 @@ struct i915_sampler_state {
struct i915_surface {
struct pipe_surface templ;
uint32_t buf_info; /* _3DSTATE_BUF_INFO_CMD flags */
};
struct i915_velems_state {
+4 -25
View File
@@ -75,25 +75,6 @@ static unsigned translate_depth_format(enum pipe_format zformat)
}
}
static inline uint32_t
buf_3d_tiling_bits(enum i915_winsys_buffer_tile tiling)
{
uint32_t tiling_bits = 0;
switch (tiling) {
case I915_TILE_Y:
tiling_bits |= BUF_3D_TILE_WALK_Y;
FALLTHROUGH;
case I915_TILE_X:
tiling_bits |= BUF_3D_TILED_SURFACE;
FALLTHROUGH;
case I915_TILE_NONE:
break;
}
return tiling_bits;
}
static void update_framebuffer(struct i915_context *i915)
{
struct pipe_surface *cbuf_surface = i915->framebuffer.cbufs[0];
@@ -103,13 +84,12 @@ static void update_framebuffer(struct i915_context *i915)
uint32_t draw_offset, draw_size;
if (cbuf_surface) {
struct i915_surface *surf = i915_surface(cbuf_surface);
struct i915_texture *tex = i915_texture(cbuf_surface->texture);
assert(tex);
i915->current.cbuf_bo = tex->buffer;
i915->current.cbuf_flags = BUF_3D_ID_COLOR_BACK |
BUF_3D_PITCH(tex->stride) | /* pitch in bytes */
buf_3d_tiling_bits(tex->tiling);
i915->current.cbuf_flags = surf->buf_info;
layer = cbuf_surface->u.tex.first_layer;
@@ -124,6 +104,7 @@ static void update_framebuffer(struct i915_context *i915)
/* What happens if no zbuf??
*/
if (depth_surface) {
struct i915_surface *surf = i915_surface(depth_surface);
struct i915_texture *tex = i915_texture(depth_surface->texture);
unsigned offset = i915_texture_offset(tex, depth_surface->u.tex.level,
depth_surface->u.tex.first_layer);
@@ -132,9 +113,7 @@ static void update_framebuffer(struct i915_context *i915)
debug_printf("Depth offset is %d\n",offset);
i915->current.depth_bo = tex->buffer;
i915->current.depth_flags = BUF_3D_ID_DEPTH |
BUF_3D_PITCH(tex->stride) | /* pitch in bytes */
buf_3d_tiling_bits(tex->tiling);
i915->current.depth_flags = surf->buf_info;
} else
i915->current.depth_bo = NULL;
i915->static_dirty |= I915_DST_BUF_DEPTH;
+20
View File
@@ -357,6 +357,7 @@ i915_create_surface_custom(struct pipe_context *ctx,
unsigned width0,
unsigned height0)
{
struct i915_texture *tex = i915_texture(pt);
struct i915_surface *surf;
assert(surf_tmpl->u.tex.first_layer == surf_tmpl->u.tex.last_layer);
@@ -380,6 +381,25 @@ i915_create_surface_custom(struct pipe_context *ctx,
ps->u.tex.last_layer = surf_tmpl->u.tex.last_layer;
ps->context = ctx;
if (util_format_is_depth_or_stencil(ps->format)) {
surf->buf_info = BUF_3D_ID_DEPTH;
} else {
surf->buf_info = BUF_3D_ID_COLOR_BACK;
}
surf->buf_info |= BUF_3D_PITCH(tex->stride); /* pitch in bytes */
switch (tex->tiling) {
case I915_TILE_Y:
surf->buf_info |= BUF_3D_TILED_SURFACE | BUF_3D_TILE_WALK_Y;
break;
case I915_TILE_X:
surf->buf_info |= BUF_3D_TILED_SURFACE;
break;
case I915_TILE_NONE:
break;
}
return ps;
}