Skip to content

Commit f8984b9

Browse files
committed
isl: Add support for filling out surface states all the way back to gen4
Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Chad Versace <[email protected]>
1 parent 815847e commit f8984b9

File tree

6 files changed

+182
-5
lines changed

6 files changed

+182
-5
lines changed

src/intel/isl/Android.mk

+60
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,63 @@ LIBISL_GENX_COMMON_INCLUDES := \
2929
$(MESA_TOP)/src/ \
3030
$(MESA_TOP)/src/mesa/drivers/dri/i965
3131

32+
# ---------------------------------------
33+
# Build libisl_gen4
34+
# ---------------------------------------
35+
36+
include $(CLEAR_VARS)
37+
38+
LOCAL_MODULE := libmesa_isl_gen4
39+
40+
LOCAL_SRC_FILES := $(ISL_GEN4_FILES)
41+
42+
LOCAL_CFLAGS := -DGEN_VERSIONx10=40
43+
44+
LOCAL_C_INCLUDES := $(LIBISL_GENX_COMMON_INCLUDES)
45+
46+
LOCAL_WHOLE_STATIC_LIBRARIES := libmesa_genxml
47+
48+
include $(MESA_COMMON_MK)
49+
include $(BUILD_STATIC_LIBRARY)
50+
51+
# ---------------------------------------
52+
# Build libisl_gen5
53+
# ---------------------------------------
54+
55+
include $(CLEAR_VARS)
56+
57+
LOCAL_MODULE := libmesa_isl_gen5
58+
59+
LOCAL_SRC_FILES := $(ISL_GEN5_FILES)
60+
61+
LOCAL_CFLAGS := -DGEN_VERSIONx10=50
62+
63+
LOCAL_C_INCLUDES := $(LIBISL_GENX_COMMON_INCLUDES)
64+
65+
LOCAL_WHOLE_STATIC_LIBRARIES := libmesa_genxml
66+
67+
include $(MESA_COMMON_MK)
68+
include $(BUILD_STATIC_LIBRARY)
69+
70+
# ---------------------------------------
71+
# Build libisl_gen6
72+
# ---------------------------------------
73+
74+
include $(CLEAR_VARS)
75+
76+
LOCAL_MODULE := libmesa_isl_gen6
77+
78+
LOCAL_SRC_FILES := $(ISL_GEN6_FILES)
79+
80+
LOCAL_CFLAGS := -DGEN_VERSIONx10=60
81+
82+
LOCAL_C_INCLUDES := $(LIBISL_GENX_COMMON_INCLUDES)
83+
84+
LOCAL_WHOLE_STATIC_LIBRARIES := libmesa_genxml
85+
86+
include $(MESA_COMMON_MK)
87+
include $(BUILD_STATIC_LIBRARY)
88+
3289
# ---------------------------------------
3390
# Build libisl_gen7
3491
# ---------------------------------------
@@ -125,6 +182,9 @@ LOCAL_C_INCLUDES := \
125182
LOCAL_EXPORT_C_INCLUDE_DIRS := $(MESA_TOP)/src/intel
126183

127184
LOCAL_WHOLE_STATIC_LIBRARIES := \
185+
libmesa_isl_gen4 \
186+
libmesa_isl_gen5 \
187+
libmesa_isl_gen6 \
128188
libmesa_isl_gen7 \
129189
libmesa_isl_gen75 \
130190
libmesa_isl_gen8 \

src/intel/isl/Makefile.am

+12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
include Makefile.sources
2323

2424
ISL_GEN_LIBS = \
25+
libisl-gen4.la \
26+
libisl-gen5.la \
27+
libisl-gen6.la \
2528
libisl-gen7.la \
2629
libisl-gen75.la \
2730
libisl-gen8.la \
@@ -52,6 +55,15 @@ libisl_la_LIBADD = $(ISL_GEN_LIBS)
5255

5356
libisl_la_SOURCES = $(ISL_FILES) $(ISL_GENERATED_FILES)
5457

58+
libisl_gen4_la_SOURCES = $(ISL_GEN4_FILES)
59+
libisl_gen4_la_CFLAGS = $(libisl_la_CFLAGS) -DGEN_VERSIONx10=40
60+
61+
libisl_gen5_la_SOURCES = $(ISL_GEN5_FILES)
62+
libisl_gen5_la_CFLAGS = $(libisl_la_CFLAGS) -DGEN_VERSIONx10=50
63+
64+
libisl_gen6_la_SOURCES = $(ISL_GEN6_FILES)
65+
libisl_gen6_la_CFLAGS = $(libisl_la_CFLAGS) -DGEN_VERSIONx10=60
66+
5567
libisl_gen7_la_SOURCES = $(ISL_GEN7_FILES)
5668
libisl_gen7_la_CFLAGS = $(libisl_la_CFLAGS) -DGEN_VERSIONx10=70
5769

src/intel/isl/Makefile.sources

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@ ISL_FILES = \
22
isl.c \
33
isl.h \
44
isl_format.c \
5+
isl_priv.h \
6+
isl_storage_image.c
7+
8+
ISL_GEN4_FILES = \
59
isl_gen4.c \
610
isl_gen4.h \
11+
isl_surface_state.c
12+
13+
ISL_GEN5_FILES = \
14+
isl_surface_state.c
15+
16+
ISL_GEN6_FILES = \
717
isl_gen6.c \
818
isl_gen6.h \
9-
isl_priv.h \
10-
isl_storage_image.c
19+
isl_surface_state.c
1120

1221
ISL_GEN7_FILES = \
1322
isl_gen7.c \

src/intel/isl/isl.c

+22
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,20 @@ isl_surf_fill_state_s(const struct isl_device *dev, void *state,
12761276
}
12771277

12781278
switch (ISL_DEV_GEN(dev)) {
1279+
case 4:
1280+
if (ISL_DEV_IS_G4X(dev)) {
1281+
/* G45 surface state is the same as gen5 */
1282+
isl_gen5_surf_fill_state_s(dev, state, info);
1283+
} else {
1284+
isl_gen4_surf_fill_state_s(dev, state, info);
1285+
}
1286+
break;
1287+
case 5:
1288+
isl_gen5_surf_fill_state_s(dev, state, info);
1289+
break;
1290+
case 6:
1291+
isl_gen6_surf_fill_state_s(dev, state, info);
1292+
break;
12791293
case 7:
12801294
if (ISL_DEV_IS_HASWELL(dev)) {
12811295
isl_gen75_surf_fill_state_s(dev, state, info);
@@ -1299,6 +1313,14 @@ isl_buffer_fill_state_s(const struct isl_device *dev, void *state,
12991313
const struct isl_buffer_fill_state_info *restrict info)
13001314
{
13011315
switch (ISL_DEV_GEN(dev)) {
1316+
case 4:
1317+
case 5:
1318+
/* Gen 4-5 are all the same when it comes to buffer surfaces */
1319+
isl_gen5_buffer_fill_state_s(state, info);
1320+
break;
1321+
case 6:
1322+
isl_gen6_buffer_fill_state_s(state, info);
1323+
break;
13021324
case 7:
13031325
if (ISL_DEV_IS_HASWELL(dev)) {
13041326
isl_gen75_buffer_fill_state_s(state, info);

src/intel/isl/isl_priv.h

+24
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,18 @@ isl_extent3d_el_to_sa(enum isl_format fmt, struct isl_extent3d extent_el)
135135
};
136136
}
137137

138+
void
139+
isl_gen4_surf_fill_state_s(const struct isl_device *dev, void *state,
140+
const struct isl_surf_fill_state_info *restrict info);
141+
142+
void
143+
isl_gen5_surf_fill_state_s(const struct isl_device *dev, void *state,
144+
const struct isl_surf_fill_state_info *restrict info);
145+
146+
void
147+
isl_gen6_surf_fill_state_s(const struct isl_device *dev, void *state,
148+
const struct isl_surf_fill_state_info *restrict info);
149+
138150
void
139151
isl_gen7_surf_fill_state_s(const struct isl_device *dev, void *state,
140152
const struct isl_surf_fill_state_info *restrict info);
@@ -149,6 +161,18 @@ void
149161
isl_gen9_surf_fill_state_s(const struct isl_device *dev, void *state,
150162
const struct isl_surf_fill_state_info *restrict info);
151163

164+
void
165+
isl_gen4_buffer_fill_state_s(void *state,
166+
const struct isl_buffer_fill_state_info *restrict info);
167+
168+
void
169+
isl_gen5_buffer_fill_state_s(void *state,
170+
const struct isl_buffer_fill_state_info *restrict info);
171+
172+
void
173+
isl_gen6_buffer_fill_state_s(void *state,
174+
const struct isl_buffer_fill_state_info *restrict info);
175+
152176
void
153177
isl_gen7_buffer_fill_state_s(void *state,
154178
const struct isl_buffer_fill_state_info *restrict info);

src/intel/isl/isl_surface_state.c

+53-3
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,13 @@ static const uint8_t isl_to_gen_tiling[] = {
7878
};
7979
#endif
8080

81+
#if GEN_GEN >= 7
8182
static const uint32_t isl_to_gen_multisample_layout[] = {
8283
[ISL_MSAA_LAYOUT_NONE] = MSFMT_MSS,
8384
[ISL_MSAA_LAYOUT_INTERLEAVED] = MSFMT_DEPTH_STENCIL,
8485
[ISL_MSAA_LAYOUT_ARRAY] = MSFMT_MSS,
8586
};
87+
#endif
8688

8789
#if GEN_GEN >= 9
8890
static const uint32_t isl_to_gen_aux_mode[] = {
@@ -130,7 +132,7 @@ get_surftype(enum isl_surf_dim dim, isl_surf_usage_flags_t usage)
130132
* hardware. Note that this does NOT give you the actual hardware enum values
131133
* but an index into the isl_to_gen_[hv]align arrays above.
132134
*/
133-
static struct isl_extent3d
135+
static inline struct isl_extent3d
134136
get_image_alignment(const struct isl_surf *surf)
135137
{
136138
if (GEN_GEN >= 9) {
@@ -217,6 +219,23 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,
217219
s.Width = info->surf->logical_level0_px.width - 1;
218220
s.Height = info->surf->logical_level0_px.height - 1;
219221

222+
/* In the gen6 PRM Volume 1 Part 1: Graphics Core, Section 7.18.3.7.1
223+
* (Surface Arrays For all surfaces other than separate stencil buffer):
224+
*
225+
* "[DevSNB] Errata: Sampler MSAA Qpitch will be 4 greater than the value
226+
* calculated in the equation above , for every other odd Surface Height
227+
* starting from 1 i.e. 1,5,9,13"
228+
*
229+
* Since this Qpitch errata only impacts the sampler, we have to adjust the
230+
* input for the rendering surface to achieve the same qpitch. For the
231+
* affected heights, we increment the height by 1 for the rendering
232+
* surface.
233+
*/
234+
if (GEN_GEN == 6 && (info->view->usage & ISL_SURF_USAGE_RENDER_TARGET_BIT) &&
235+
info->surf->samples > 1 &&
236+
(info->surf->logical_level0_px.height % 4) == 1)
237+
s.Height++;
238+
220239
switch (s.SurfaceType) {
221240
case SURFTYPE_1D:
222241
case SURFTYPE_2D:
@@ -283,7 +302,9 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,
283302
unreachable("bad SurfaceType");
284303
}
285304

305+
#if GEN_GEN >= 7
286306
s.SurfaceArray = info->surf->dim != ISL_SURF_DIM_3D;
307+
#endif
287308

288309
if (info->view->usage & ISL_SURF_USAGE_RENDER_TARGET_BIT) {
289310
/* For render target surfaces, the hardware interprets field
@@ -311,9 +332,13 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,
311332
s.MipTailStartLOD = 15;
312333
#endif
313334

335+
#if GEN_GEN >= 6
314336
const struct isl_extent3d image_align = get_image_alignment(info->surf);
315337
s.SurfaceVerticalAlignment = isl_to_gen_valign[image_align.height];
338+
#if GEN_GEN >= 7
316339
s.SurfaceHorizontalAlignment = isl_to_gen_halign[image_align.width];
340+
#endif
341+
#endif
317342

318343
if (info->surf->dim_layout == ISL_DIM_LAYOUT_GEN9_1D) {
319344
/* For gen9 1-D textures, surface pitch is ignored */
@@ -356,9 +381,13 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,
356381
#endif
357382
}
358383

384+
#if GEN_GEN >= 6
385+
s.NumberofMultisamples = ffs(info->surf->samples) - 1;
386+
#if GEN_GEN >= 7
359387
s.MultisampledSurfaceStorageFormat =
360388
isl_to_gen_multisample_layout[info->surf->msaa_layout];
361-
s.NumberofMultisamples = ffs(info->surf->samples) - 1;
389+
#endif
390+
#endif
362391

363392
#if (GEN_GEN >= 8 || GEN_IS_HASWELL)
364393
s.ShaderChannelSelectRed = info->view->channel_select[0];
@@ -368,7 +397,10 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,
368397
#endif
369398

370399
s.SurfaceBaseAddress = info->address;
400+
401+
#if GEN_GEN >= 6
371402
s.MOCS = info->mocs;
403+
#endif
372404

373405
#if GEN_GEN >= 7
374406
if (info->aux_surf && info->aux_usage != ISL_AUX_USAGE_NONE) {
@@ -480,15 +512,31 @@ isl_genX(buffer_fill_state_s)(void *state,
480512
struct GENX(RENDER_SURFACE_STATE) s = { 0, };
481513

482514
s.SurfaceType = SURFTYPE_BUFFER;
483-
s.SurfaceArray = false;
484515
s.SurfaceFormat = info->format;
516+
517+
#if GEN_GEN >= 6
485518
s.SurfaceVerticalAlignment = isl_to_gen_valign[4];
519+
#if GEN_GEN >= 7
486520
s.SurfaceHorizontalAlignment = isl_to_gen_halign[4];
521+
s.SurfaceArray = false;
522+
#endif
523+
#endif
524+
525+
#if GEN_GEN >= 7
487526
s.Height = ((num_elements - 1) >> 7) & 0x3fff;
488527
s.Width = (num_elements - 1) & 0x7f;
489528
s.Depth = ((num_elements - 1) >> 21) & 0x3ff;
529+
#else
530+
s.Height = ((num_elements - 1) >> 7) & 0x1fff;
531+
s.Width = (num_elements - 1) & 0x7f;
532+
s.Depth = ((num_elements - 1) >> 20) & 0x7f;
533+
#endif
534+
490535
s.SurfacePitch = info->stride - 1;
536+
537+
#if GEN_GEN >= 6
491538
s.NumberofMultisamples = MULTISAMPLECOUNT_1;
539+
#endif
492540

493541
#if (GEN_GEN >= 8)
494542
s.TileMode = LINEAR;
@@ -503,7 +551,9 @@ isl_genX(buffer_fill_state_s)(void *state,
503551
#endif
504552

505553
s.SurfaceBaseAddress = info->address;
554+
#if GEN_GEN >= 6
506555
s.MOCS = info->mocs;
556+
#endif
507557

508558
#if (GEN_GEN >= 8 || GEN_IS_HASWELL)
509559
s.ShaderChannelSelectRed = SCS_RED;

0 commit comments

Comments
 (0)