Re: [Mesa-dev] [PATCH 06/30] i965: Move the DRIimage -> miptree code to intel_mipmap_tree.c
On Fri 16 Jun 2017, Jason Ekstrand wrote: > This is mostly a direct port. The only bit of refactoring that was done > was to make creating a planar miptree be an early return from the > non-planar case. Alternatively, we could have three functions: two > helpers and a main function to just call the right helper. Making the > planar case an early return seemed cleaner. > --- > src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 91 + > src/mesa/drivers/dri/i965/intel_mipmap_tree.h | 5 ++ > src/mesa/drivers/dri/i965/intel_tex_image.c | 97 > +-- > 3 files changed, 97 insertions(+), 96 deletions(-) Reviewed-by: Chad Versace___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 06/30] i965: Move the DRIimage -> miptree code to intel_mipmap_tree.c
On Fri, Jun 16, 2017 at 03:41:28PM -0700, Jason Ekstrand wrote: > This is mostly a direct port. The only bit of refactoring that was done > was to make creating a planar miptree be an early return from the > non-planar case. Alternatively, we could have three functions: two > helpers and a main function to just call the right helper. Making the > planar case an early return seemed cleaner. > --- > src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 91 + > src/mesa/drivers/dri/i965/intel_mipmap_tree.h | 5 ++ > src/mesa/drivers/dri/i965/intel_tex_image.c | 97 > +-- > 3 files changed, 97 insertions(+), 96 deletions(-) Reviewed-by: Topi Pohjolainen> > diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c > b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c > index 101317f..023c6aa 100644 > --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c > +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c > @@ -27,6 +27,7 @@ > #include > > #include "intel_batchbuffer.h" > +#include "intel_image.h" > #include "intel_mipmap_tree.h" > #include "intel_tex.h" > #include "intel_blit.h" > @@ -856,6 +857,96 @@ intel_miptree_create_for_bo(struct brw_context *brw, > return mt; > } > > +static struct intel_mipmap_tree * > +miptree_create_for_planar_image(struct brw_context *brw, > +__DRIimage *image, GLenum target) > +{ > + struct intel_image_format *f = image->planar_format; > + struct intel_mipmap_tree *planar_mt; > + > + for (int i = 0; i < f->nplanes; i++) { > + const int index = f->planes[i].buffer_index; > + const uint32_t dri_format = f->planes[i].dri_format; > + const mesa_format format = driImageFormatToGLFormat(dri_format); > + const uint32_t width = image->width >> f->planes[i].width_shift; > + const uint32_t height = image->height >> f->planes[i].height_shift; > + > + /* Disable creation of the texture's aux buffers because the driver > + * exposes no EGL API to manage them. That is, there is no API for > + * resolving the aux buffer's content to the main buffer nor for > + * invalidating the aux buffer's content. > + */ > + struct intel_mipmap_tree *mt = > + intel_miptree_create_for_bo(brw, image->bo, format, > + image->offsets[index], > + width, height, 1, > + image->strides[index], > + MIPTREE_LAYOUT_DISABLE_AUX); > + if (mt == NULL) > + return NULL; > + > + mt->target = target; > + mt->total_width = width; > + mt->total_height = height; > + > + if (i == 0) > + planar_mt = mt; > + else > + planar_mt->plane[i - 1] = mt; > + } > + > + return planar_mt; > +} > + > +struct intel_mipmap_tree * > +intel_miptree_create_for_dri_image(struct brw_context *brw, > + __DRIimage *image, GLenum target) > +{ > + if (image->planar_format && image->planar_format->nplanes > 0) > + return miptree_create_for_planar_image(brw, image, target); > + > + if (!brw->ctx.TextureFormatSupported[image->format]) > + return NULL; > + > + /* Disable creation of the texture's aux buffers because the driver > exposes > +* no EGL API to manage them. That is, there is no API for resolving the > aux > +* buffer's content to the main buffer nor for invalidating the aux > buffer's > +* content. > +*/ > + struct intel_mipmap_tree *mt = > + intel_miptree_create_for_bo(brw, image->bo, image->format, > + 0, image->width, image->height, 1, > + image->pitch, > + MIPTREE_LAYOUT_DISABLE_AUX); > + if (mt == NULL) > + return NULL; > + > + mt->target = target; > + mt->total_width = image->width; > + mt->total_height = image->height; > + mt->level[0].slice[0].x_offset = image->tile_x; > + mt->level[0].slice[0].y_offset = image->tile_y; > + > + /* From "OES_EGL_image" error reporting. We report GL_INVALID_OPERATION > +* for EGL images from non-tile aligned sufaces in gen4 hw and earlier > which has > +* trouble resolving back to destination image due to alignment issues. > +*/ > + if (!brw->has_surface_tile_offset) { > + uint32_t draw_x, draw_y; > + intel_miptree_get_tile_offsets(mt, 0, 0, _x, _y); > + > + if (draw_x != 0 || draw_y != 0) { > + _mesa_error(>ctx, GL_INVALID_OPERATION, __func__); > + intel_miptree_release(); > + return NULL; > + } > + } > + > + mt->offset = image->offset; > + > + return mt; > +} > + > /** > * For a singlesample renderbuffer, this simply wraps the given BO with a > * miptree. > diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h >
[Mesa-dev] [PATCH 06/30] i965: Move the DRIimage -> miptree code to intel_mipmap_tree.c
This is mostly a direct port. The only bit of refactoring that was done was to make creating a planar miptree be an early return from the non-planar case. Alternatively, we could have three functions: two helpers and a main function to just call the right helper. Making the planar case an early return seemed cleaner. --- src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 91 + src/mesa/drivers/dri/i965/intel_mipmap_tree.h | 5 ++ src/mesa/drivers/dri/i965/intel_tex_image.c | 97 +-- 3 files changed, 97 insertions(+), 96 deletions(-) diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c index 101317f..023c6aa 100644 --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c @@ -27,6 +27,7 @@ #include #include "intel_batchbuffer.h" +#include "intel_image.h" #include "intel_mipmap_tree.h" #include "intel_tex.h" #include "intel_blit.h" @@ -856,6 +857,96 @@ intel_miptree_create_for_bo(struct brw_context *brw, return mt; } +static struct intel_mipmap_tree * +miptree_create_for_planar_image(struct brw_context *brw, +__DRIimage *image, GLenum target) +{ + struct intel_image_format *f = image->planar_format; + struct intel_mipmap_tree *planar_mt; + + for (int i = 0; i < f->nplanes; i++) { + const int index = f->planes[i].buffer_index; + const uint32_t dri_format = f->planes[i].dri_format; + const mesa_format format = driImageFormatToGLFormat(dri_format); + const uint32_t width = image->width >> f->planes[i].width_shift; + const uint32_t height = image->height >> f->planes[i].height_shift; + + /* Disable creation of the texture's aux buffers because the driver + * exposes no EGL API to manage them. That is, there is no API for + * resolving the aux buffer's content to the main buffer nor for + * invalidating the aux buffer's content. + */ + struct intel_mipmap_tree *mt = + intel_miptree_create_for_bo(brw, image->bo, format, + image->offsets[index], + width, height, 1, + image->strides[index], + MIPTREE_LAYOUT_DISABLE_AUX); + if (mt == NULL) + return NULL; + + mt->target = target; + mt->total_width = width; + mt->total_height = height; + + if (i == 0) + planar_mt = mt; + else + planar_mt->plane[i - 1] = mt; + } + + return planar_mt; +} + +struct intel_mipmap_tree * +intel_miptree_create_for_dri_image(struct brw_context *brw, + __DRIimage *image, GLenum target) +{ + if (image->planar_format && image->planar_format->nplanes > 0) + return miptree_create_for_planar_image(brw, image, target); + + if (!brw->ctx.TextureFormatSupported[image->format]) + return NULL; + + /* Disable creation of the texture's aux buffers because the driver exposes +* no EGL API to manage them. That is, there is no API for resolving the aux +* buffer's content to the main buffer nor for invalidating the aux buffer's +* content. +*/ + struct intel_mipmap_tree *mt = + intel_miptree_create_for_bo(brw, image->bo, image->format, + 0, image->width, image->height, 1, + image->pitch, + MIPTREE_LAYOUT_DISABLE_AUX); + if (mt == NULL) + return NULL; + + mt->target = target; + mt->total_width = image->width; + mt->total_height = image->height; + mt->level[0].slice[0].x_offset = image->tile_x; + mt->level[0].slice[0].y_offset = image->tile_y; + + /* From "OES_EGL_image" error reporting. We report GL_INVALID_OPERATION +* for EGL images from non-tile aligned sufaces in gen4 hw and earlier which has +* trouble resolving back to destination image due to alignment issues. +*/ + if (!brw->has_surface_tile_offset) { + uint32_t draw_x, draw_y; + intel_miptree_get_tile_offsets(mt, 0, 0, _x, _y); + + if (draw_x != 0 || draw_y != 0) { + _mesa_error(>ctx, GL_INVALID_OPERATION, __func__); + intel_miptree_release(); + return NULL; + } + } + + mt->offset = image->offset; + + return mt; +} + /** * For a singlesample renderbuffer, this simply wraps the given BO with a * miptree. diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h index f34be9a..9b6bc40 100644 --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h @@ -696,6 +696,11 @@ intel_miptree_create_for_bo(struct brw_context *brw, int pitch, uint32_t layout_flags); +struct intel_mipmap_tree * +intel_miptree_create_for_dri_image(struct