From 96ee78778b515d5b71038c6ac16ad6f627c5062e Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Tue, 20 Oct 2020 13:23:31 -0500 Subject: [PATCH] intel/isl: Add support for scratch buffers XeHP adds support for a new surface type for scratch. It's similar to SURFTYPE_STRBUF in that it's a 2D array-of-struct format but the one key difference is that the U coordinate is computed automatically based on the thread ID and only the V coordinate is provided in the dataport message. Reviewed-by: Jordan Justen Part-of: --- src/intel/isl/isl.h | 2 ++ src/intel/isl/isl_surface_state.c | 28 +++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h index d393846..88e3d65 100644 --- a/src/intel/isl/isl.h +++ b/src/intel/isl/isl.h @@ -1689,6 +1689,8 @@ struct isl_buffer_fill_state_info { struct isl_swizzle swizzle; uint32_t stride_B; + + bool is_scratch; }; struct isl_depth_stencil_hiz_emit_info { diff --git a/src/intel/isl/isl_surface_state.c b/src/intel/isl/isl_surface_state.c index e9d8c00..72e9d03 100644 --- a/src/intel/isl/isl_surface_state.c +++ b/src/intel/isl/isl_surface_state.c @@ -826,8 +826,9 @@ isl_genX(buffer_fill_state_s)(const struct isl_device *dev, void *state, * * buffer_size = (surface_size & ~3) - (surface_size & 3) */ - if (info->format == ISL_FORMAT_RAW || - info->stride_B < isl_format_get_layout(info->format)->bpb / 8) { + if ((info->format == ISL_FORMAT_RAW || + info->stride_B < isl_format_get_layout(info->format)->bpb / 8) && + !info->is_scratch) { assert(info->stride_B == 1); uint64_t aligned_size = isl_align(buffer_size, 4); buffer_size = aligned_size + (aligned_size - buffer_size); @@ -855,9 +856,28 @@ isl_genX(buffer_fill_state_s)(const struct isl_device *dev, void *state, struct GENX(RENDER_SURFACE_STATE) s = { 0, }; - s.SurfaceType = SURFTYPE_BUFFER; s.SurfaceFormat = info->format; + s.SurfaceType = SURFTYPE_BUFFER; +#if GFX_VERx10 >= 125 + if (info->is_scratch) { + /* From the BSpec: + * + * "For surfaces of type SURFTYPE_SCRATCH, valid range of pitch is: + * [63,262143] -> [64B, 256KB]. Also, for SURFTYPE_SCRATCH, the + * pitch must be a multiple of 64bytes." + */ + assert(info->format == ISL_FORMAT_RAW); + assert(info->stride_B % 64 == 0); + assert(info->stride_B <= 256 * 1024); + s.SurfaceType = SURFTYPE_SCRATCH; + } +#else + assert(!info->is_scratch); +#endif + + s.SurfacePitch = info->stride_B - 1; + #if GFX_VER >= 6 s.SurfaceVerticalAlignment = isl_encode_valign[4]; #if GFX_VER >= 7 @@ -895,8 +915,6 @@ isl_genX(buffer_fill_state_s)(const struct isl_device *dev, void *state, } } - s.SurfacePitch = info->stride_B - 1; - #if GFX_VER >= 6 s.NumberofMultisamples = MULTISAMPLECOUNT_1; #endif -- 2.7.4