#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
+#include <inttypes.h>
+#include "dev/intel_debug.h"
#include "genxml/genX_bits.h"
+#include "util/log.h"
#include "isl.h"
#include "isl_gfx4.h"
#undef CHOOSE
/* No tiling mode accommodates the inputs. */
- return false;
+ assert(tiling_flags == 0);
+ return notify_failure(info, "no supported tiling");
}
static bool
return likely(bits != 0 && 1 <= n && n <= (1 << bits));
}
+void PRINTFLIKE(4, 5)
+_isl_notify_failure(const struct isl_surf_init_info *surf_info,
+ const char *file, int line, const char *fmt, ...)
+{
+ if (!INTEL_DEBUG(DEBUG_ISL))
+ return;
+
+ char msg[512];
+ va_list ap;
+ va_start(ap, fmt);
+ int ret = vsnprintf(msg, sizeof(msg), fmt, ap);
+ assert(ret < sizeof(msg));
+ va_end(ap);
+
+#define PRINT_USAGE(bit, str) \
+ (surf_info->usage & ISL_SURF_USAGE_##bit##_BIT) ? ("+"str) : ""
+#define PRINT_TILING(bit, str) \
+ (surf_info->tiling_flags & ISL_TILING_##bit##_BIT) ? ("+"str) : ""
+
+ snprintf(msg + ret, sizeof(msg) - ret,
+ " extent=%ux%ux%u dim=%s msaa=%ux levels=%u rpitch=%u fmt=%s "
+ "usages=%s%s%s%s%s%s%s%s%s%s%s%s%s%s "
+ "tiling_flags=%s%s%s%s%s%s%s%s%s%s%s",
+ surf_info->width, surf_info->height,
+ surf_info->dim == ISL_SURF_DIM_3D ?
+ surf_info->depth : surf_info->array_len,
+ surf_info->dim == ISL_SURF_DIM_1D ? "1d" :
+ surf_info->dim == ISL_SURF_DIM_2D ? "2d" : "3d",
+ surf_info->samples, surf_info->levels,
+ surf_info->row_pitch_B,
+ isl_format_get_name(surf_info->format) + strlen("ISL_FORMAT_"),
+
+ PRINT_USAGE(RENDER_TARGET, "rt"),
+ PRINT_USAGE(DEPTH, "depth"),
+ PRINT_USAGE(STENCIL, "stenc"),
+ PRINT_USAGE(TEXTURE, "tex"),
+ PRINT_USAGE(CUBE, "cube"),
+ PRINT_USAGE(DISABLE_AUX, "noaux"),
+ PRINT_USAGE(DISPLAY, "disp"),
+ PRINT_USAGE(HIZ, "hiz"),
+ PRINT_USAGE(MCS, "mcs"),
+ PRINT_USAGE(CCS, "ccs"),
+ PRINT_USAGE(VERTEX_BUFFER, "vb"),
+ PRINT_USAGE(INDEX_BUFFER, "ib"),
+ PRINT_USAGE(CONSTANT_BUFFER, "const"),
+ PRINT_USAGE(STAGING, "stage"),
+
+ PRINT_TILING(LINEAR, "linear"),
+ PRINT_TILING(W, "W"),
+ PRINT_TILING(X, "X"),
+ PRINT_TILING(Y0, "Y0"),
+ PRINT_TILING(Yf, "Yf"),
+ PRINT_TILING(Ys, "Ys"),
+ PRINT_TILING(4, "4"),
+ PRINT_TILING(64, "64"),
+ PRINT_TILING(HIZ, "hiz"),
+ PRINT_TILING(CCS, "ccs"),
+ PRINT_TILING(GFX12_CCS, "ccs12"));
+
+#undef PRINT_USAGE
+#undef PRINT_TILING
+
+ mesa_logd("%s:%i: %s", file, line, msg);
+}
+
static bool
isl_calc_row_pitch(const struct isl_device *dev,
const struct isl_surf_init_info *surf_info,
alignment_B);
if (surf_info->row_pitch_B != 0) {
- if (surf_info->row_pitch_B < min_row_pitch_B)
- return false;
+ if (surf_info->row_pitch_B < min_row_pitch_B) {
+ return notify_failure(surf_info,
+ "requested row pitch (%uB) less than minimum "
+ "allowed (%uB)",
+ surf_info->row_pitch_B, min_row_pitch_B);
+ }
- if (surf_info->row_pitch_B % alignment_B != 0)
- return false;
+ if (surf_info->row_pitch_B % alignment_B != 0) {
+ return notify_failure(surf_info,
+ "requested row pitch (%uB) doesn't satisfy the "
+ "minimum alignment requirement (%uB)",
+ surf_info->row_pitch_B, alignment_B);
+ }
}
const uint32_t row_pitch_B =
const uint32_t row_pitch_tl = row_pitch_B / tile_info->phys_extent_B.width;
if (row_pitch_B == 0)
- return false;
+ return notify_failure(surf_info, "calculated row pitch is zero");
if (dim_layout == ISL_DIM_LAYOUT_GFX9_1D) {
/* SurfacePitch is ignored for this layout. */
if ((surf_info->usage & (ISL_SURF_USAGE_RENDER_TARGET_BIT |
ISL_SURF_USAGE_TEXTURE_BIT |
ISL_SURF_USAGE_STORAGE_BIT)) &&
- !pitch_in_range(row_pitch_B, RENDER_SURFACE_STATE_SurfacePitch_bits(dev->info)))
- return false;
+ !pitch_in_range(row_pitch_B, RENDER_SURFACE_STATE_SurfacePitch_bits(dev->info))) {
+ return notify_failure(surf_info,
+ "row pitch (%uB) not in range of "
+ "RENDER_SURFACE_STATE::SurfacePitch",
+ row_pitch_B);
+ }
if ((surf_info->usage & (ISL_SURF_USAGE_CCS_BIT |
ISL_SURF_USAGE_MCS_BIT)) &&
- !pitch_in_range(row_pitch_tl, RENDER_SURFACE_STATE_AuxiliarySurfacePitch_bits(dev->info)))
- return false;
+ !pitch_in_range(row_pitch_tl, RENDER_SURFACE_STATE_AuxiliarySurfacePitch_bits(dev->info))) {
+ return notify_failure(surf_info,
+ "row_pitch_tl=%u not in range of "
+ "RENDER_SURFACE_STATE::AuxiliarySurfacePitch",
+ row_pitch_tl);
+ }
if ((surf_info->usage & ISL_SURF_USAGE_DEPTH_BIT) &&
- !pitch_in_range(row_pitch_B, _3DSTATE_DEPTH_BUFFER_SurfacePitch_bits(dev->info)))
- return false;
+ !pitch_in_range(row_pitch_B, _3DSTATE_DEPTH_BUFFER_SurfacePitch_bits(dev->info))) {
+ return notify_failure(surf_info,
+ "row pitch (%uB) not in range of "
+ "3DSTATE_DEPTH_BUFFER::SurfacePitch",
+ row_pitch_B);
+ }
if ((surf_info->usage & ISL_SURF_USAGE_HIZ_BIT) &&
- !pitch_in_range(row_pitch_B, _3DSTATE_HIER_DEPTH_BUFFER_SurfacePitch_bits(dev->info)))
- return false;
+ !pitch_in_range(row_pitch_B, _3DSTATE_HIER_DEPTH_BUFFER_SurfacePitch_bits(dev->info))) {
+ return notify_failure(surf_info,
+ "row pitch (%uB) not in range of "
+ "3DSTATE_HIER_DEPTH_BUFFER::SurfacePitch",
+ row_pitch_B);
+ }
const uint32_t stencil_pitch_bits = dev->use_separate_stencil ?
_3DSTATE_STENCIL_BUFFER_SurfacePitch_bits(dev->info) :
_3DSTATE_DEPTH_BUFFER_SurfacePitch_bits(dev->info);
if ((surf_info->usage & ISL_SURF_USAGE_STENCIL_BIT) &&
- !pitch_in_range(row_pitch_B, stencil_pitch_bits))
- return false;
+ !pitch_in_range(row_pitch_B, stencil_pitch_bits)) {
+ return notify_failure(surf_info,
+ "row pitch (%uB) not in range of "
+ "3DSTATE_STENCIL_BUFFER/3DSTATE_DEPTH_BUFFER::SurfacePitch",
+ row_pitch_B);
+ }
if ((surf_info->usage & ISL_SURF_USAGE_CPB_BIT) &&
!pitch_in_range(row_pitch_B, _3DSTATE_CPSIZE_CONTROL_BUFFER_SurfacePitch_bits(dev->info)))
static bool
isl_calc_size(const struct isl_device *dev,
+ const struct isl_surf_init_info *info,
const struct isl_tile_info *tile_info,
const struct isl_extent4d *phys_total_el,
uint32_t array_pitch_el_rows,
*
* This comment is applicable to all Pre-gfx9 platforms.
*/
- if (size_B > (uint64_t) 1 << 31)
- return false;
+ if (size_B > (uint64_t) 1 << 31) {
+ return notify_failure(
+ info,
+ "calculated size (%"PRIu64"B) exceeds platform limit of (1 << 31)",
+ size_B);
+ }
} else if (ISL_GFX_VER(dev) < 11) {
/* From the Skylake PRM Vol 5, Maximum Surface Size in Bytes:
* "In addition to restrictions on maximum height, width, and depth,
* All pixels within the surface must be contained within 2^38 bytes
* of the base address."
*/
- if (size_B > (uint64_t) 1 << 38)
- return false;
+ if (size_B > (uint64_t) 1 << 38) {
+ return notify_failure(
+ info,
+ "calculated size (%"PRIu64"B) exceeds platform limit of (1 << 38)",
+ size_B);
+ }
} else {
/* gfx11+ platforms raised this limit to 2^44 bytes. */
- if (size_B > (uint64_t) 1 << 44)
- return false;
+ if (size_B > (uint64_t) 1 << 44) {
+ return notify_failure(
+ info,
+ "calculated size (%"PRIu64"B) exceeds platform limit of (1 << 44)",
+ size_B);
+ }
}
*out_size_B = size_B;
return false;
uint64_t size_B;
- if (!isl_calc_size(dev, &tile_info, &phys_total_el, array_pitch_el_rows,
- row_pitch_B, &size_B))
+ if (!isl_calc_size(dev, info, &tile_info, &phys_total_el,
+ array_pitch_el_rows, row_pitch_B, &size_B))
return false;
const uint32_t base_alignment_B =