summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2017-06-12 18:21:09 -0700
committerJason Ekstrand <[email protected]>2017-07-12 21:15:46 -0700
commit76f683e91dc5dcca670c987a0a12ae6d95cc016e (patch)
treeb9ce03a0f23d46cdd06ad141bdee676326047f72
parent5b3363e3f17db887fedc58b8e15fa8b78a14e088 (diff)
i965/screen: Use ISL for allocating image BOs
Reviewed-by: Topi Pohjolainen <[email protected]> Reviewed-by: Chad Versace <[email protected]>
-rw-r--r--src/mesa/drivers/dri/i965/intel_screen.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index 6c23834b2f4..fd9bbb11b9d 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -37,6 +37,7 @@
#include "swrast/s_renderbuffer.h"
#include "util/ralloc.h"
#include "brw_defines.h"
+#include "brw_state.h"
#include "compiler/nir/nir.h"
#include "utils.h"
@@ -321,19 +322,6 @@ modifier_is_supported(uint64_t modifier)
return false;
}
-static uint32_t
-modifier_to_tiling(uint64_t modifier)
-{
- int i;
-
- for (i = 0; i < ARRAY_SIZE(tiling_modifier_map); i++) {
- if (tiling_modifier_map[i].modifier == modifier)
- return tiling_modifier_map[i].tiling;
- }
-
- unreachable("modifier_to_tiling should only receive known modifiers");
-}
-
static uint64_t
tiling_to_modifier(uint32_t tiling)
{
@@ -641,10 +629,8 @@ intel_create_image_common(__DRIscreen *dri_screen,
{
__DRIimage *image;
struct intel_screen *screen = dri_screen->driverPrivate;
- uint32_t tiling;
uint64_t modifier = DRM_FORMAT_MOD_INVALID;
- unsigned tiled_height;
- int cpp;
+ bool ok;
/* Callers of this may specify a modifier, or a dri usage, but not both. The
* newer modifier interface deprecates the older usage flags newer modifier
@@ -674,23 +660,44 @@ intel_create_image_common(__DRIscreen *dri_screen,
modifier = I915_FORMAT_MOD_X_TILED;
}
}
- tiling = modifier_to_tiling(modifier);
- tiled_height = get_tiled_height(modifier, height);
image = intel_allocate_image(screen, format, loaderPrivate);
if (image == NULL)
return NULL;
- cpp = _mesa_get_format_bytes(image->format);
- image->bo = brw_bo_alloc_tiled_2d(screen->bufmgr, "image",
- width, tiled_height, cpp, tiling,
- &image->pitch, 0);
+ const struct isl_drm_modifier_info *mod_info =
+ isl_drm_modifier_get_info(modifier);
+
+ struct isl_surf surf;
+ ok = isl_surf_init(&screen->isl_dev, &surf,
+ .dim = ISL_SURF_DIM_2D,
+ .format = brw_isl_format_for_mesa_format(image->format),
+ .width = width,
+ .height = height,
+ .depth = 1,
+ .levels = 1,
+ .array_len = 1,
+ .samples = 1,
+ .usage = ISL_SURF_USAGE_RENDER_TARGET_BIT |
+ ISL_SURF_USAGE_TEXTURE_BIT |
+ ISL_SURF_USAGE_STORAGE_BIT,
+ .tiling_flags = (1 << mod_info->tiling));
+ assert(ok);
+ if (!ok) {
+ free(image);
+ return NULL;
+ }
+
+ image->bo = brw_bo_alloc_tiled(screen->bufmgr, "image", surf.size,
+ isl_tiling_to_i915_tiling(mod_info->tiling),
+ surf.row_pitch, 0);
if (image->bo == NULL) {
free(image);
return NULL;
}
image->width = width;
image->height = height;
+ image->pitch = surf.row_pitch;
image->modifier = modifier;
return image;