Mesa (main): i915g: Compute 3DSTATE_BUF_INFO flags at surface create time.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jun 22 18:38:53 UTC 2021
Module: Mesa
Branch: main
Commit: 5b3840d9613928b97beb26c18d2ca60471c9516f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5b3840d9613928b97beb26c18d2ca60471c9516f
Author: Emma Anholt <emma at anholt.net>
Date: Sun Jun 20 08:52:25 2021 -0700
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>
---
src/gallium/drivers/i915/i915_context.h | 1 +
src/gallium/drivers/i915/i915_state_static.c | 29 ++++------------------------
src/gallium/drivers/i915/i915_surface.c | 20 +++++++++++++++++++
3 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h
index 65e24fb56a9..65de266399d 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -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 {
diff --git a/src/gallium/drivers/i915/i915_state_static.c b/src/gallium/drivers/i915/i915_state_static.c
index 1d8e211c962..3f6923c15ab 100644
--- a/src/gallium/drivers/i915/i915_state_static.c
+++ b/src/gallium/drivers/i915/i915_state_static.c
@@ -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;
diff --git a/src/gallium/drivers/i915/i915_surface.c b/src/gallium/drivers/i915/i915_surface.c
index 095e978c4e7..3c717bccec3 100644
--- a/src/gallium/drivers/i915/i915_surface.c
+++ b/src/gallium/drivers/i915/i915_surface.c
@@ -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;
}
More information about the mesa-commit
mailing list