i915g: Create an i915_surface for our pipe_surfaces.
authorEmma Anholt <emma@anholt.net>
Sun, 20 Jun 2021 15:41:50 +0000 (08:41 -0700)
committerEmma Anholt <emma@anholt.net>
Tue, 22 Jun 2021 18:06:37 +0000 (11:06 -0700)
Nothing added in yet, just wrapping the struct.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11512>

src/gallium/drivers/i915/i915_context.h
src/gallium/drivers/i915/i915_surface.c

index 579cfd8..65e24fb 100644 (file)
@@ -211,6 +211,10 @@ struct i915_sampler_state {
    unsigned maxlod;
 };
 
+struct i915_surface {
+   struct pipe_surface templ;
+};
+
 struct i915_velems_state {
    unsigned count;
    struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS];
@@ -401,5 +405,10 @@ i915_context( struct pipe_context *pipe )
    return (struct i915_context *)pipe;
 }
 
+static inline struct i915_surface *
+i915_surface(struct pipe_surface *pipe)
+{
+   return (struct i915_surface *)pipe;
+}
 
 #endif
index 4322ff9..095e978 100644 (file)
@@ -357,26 +357,29 @@ i915_create_surface_custom(struct pipe_context *ctx,
                            unsigned width0,
                            unsigned height0)
 {
-   struct pipe_surface *ps;
+   struct i915_surface *surf;
 
    assert(surf_tmpl->u.tex.first_layer == surf_tmpl->u.tex.last_layer);
    if (pt->target != PIPE_TEXTURE_CUBE &&
        pt->target != PIPE_TEXTURE_3D)
       assert(surf_tmpl->u.tex.first_layer == 0);
 
-   ps = CALLOC_STRUCT(pipe_surface);
-   if (ps) {
-      /* could subclass pipe_surface and store offset as it used to do */
-      pipe_reference_init(&ps->reference, 1);
-      pipe_resource_reference(&ps->texture, pt);
-      ps->format = surf_tmpl->format;
-      ps->width = u_minify(width0, surf_tmpl->u.tex.level);
-      ps->height = u_minify(height0, surf_tmpl->u.tex.level);
-      ps->u.tex.level = surf_tmpl->u.tex.level;
-      ps->u.tex.first_layer = surf_tmpl->u.tex.first_layer;
-      ps->u.tex.last_layer = surf_tmpl->u.tex.last_layer;
-      ps->context = ctx;
-   }
+   surf = CALLOC_STRUCT(i915_surface);
+   if (!surf)
+      return NULL;
+
+   struct pipe_surface *ps = &surf->templ;
+
+   pipe_reference_init(&ps->reference, 1);
+   pipe_resource_reference(&ps->texture, pt);
+   ps->format = surf_tmpl->format;
+   ps->width = u_minify(width0, surf_tmpl->u.tex.level);
+   ps->height = u_minify(height0, surf_tmpl->u.tex.level);
+   ps->u.tex.level = surf_tmpl->u.tex.level;
+   ps->u.tex.first_layer = surf_tmpl->u.tex.first_layer;
+   ps->u.tex.last_layer = surf_tmpl->u.tex.last_layer;
+   ps->context = ctx;
+
    return ps;
 }