75
75
brwCreateContext(int api,
76
76
const struct gl_config *mesaVis,
77
77
__DRIcontext *driContextPriv,
78
unsigned major_version,
79
unsigned minor_version,
78
81
void *sharedContextPrivate)
80
83
__DRIscreen *sPriv = driContextPriv->driScreenPriv;
81
84
struct intel_screen *screen = sPriv->driverPrivate;
82
85
struct dd_function_table functions;
88
/* Filter against the requested API and version.
92
#ifdef TEXTURE_FLOAT_ENABLED
93
const unsigned max_version =
95
(screen->gen == 7 && screen->kernel_has_gen7_sol_reset))
98
const unsigned max_version = 21;
100
const unsigned req_version = major_version * 10 + minor_version;
102
if (req_version > max_version) {
103
*error = __DRI_CTX_ERROR_BAD_VERSION;
112
*error = __DRI_CTX_ERROR_BAD_API;
83
116
struct brw_context *brw = rzalloc(NULL, struct brw_context);
84
struct intel_context *intel = &brw->intel;
85
struct gl_context *ctx = &intel->ctx;
89
118
printf("%s: failed to alloc context\n", __FUNCTION__);
119
*error = __DRI_CTX_ERROR_NO_MEMORY;
93
123
brwInitDriverFunctions(screen, &functions);
125
struct intel_context *intel = &brw->intel;
126
struct gl_context *ctx = &intel->ctx;
95
128
if (!intelInitContext( intel, api, mesaVis, driContextPriv,
96
129
sharedContextPrivate, &functions )) {
97
130
printf("%s: failed to init intel context\n", __FUNCTION__);
132
*error = __DRI_CTX_ERROR_NO_MEMORY;
109
143
TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline;
145
ctx->Const.MaxDualSourceDrawBuffers = 1;
111
146
ctx->Const.MaxDrawBuffers = BRW_MAX_DRAW_BUFFERS;
112
147
ctx->Const.MaxTextureImageUnits = BRW_MAX_TEX_UNIT;
113
148
ctx->Const.MaxTextureCoordUnits = 8; /* Mesa limit */
137
172
* So we need to override the Mesa default (which is based only on software
140
ctx->Const.MaxTransformFeedbackSeparateAttribs = BRW_MAX_SOL_BUFFERS;
175
ctx->Const.MaxTransformFeedbackBuffers = BRW_MAX_SOL_BUFFERS;
142
177
/* On Gen6, in the worst case, we use up one binding table entry per
143
178
* transform feedback component (see comments above the definition of
153
188
ctx->Const.MaxTransformFeedbackSeparateComponents =
154
189
BRW_MAX_SOL_BINDINGS / BRW_MAX_SOL_BUFFERS;
156
/* Claim to support 4 multisamples, even though we don't. This is a
157
* requirement for GL 3.0 that we missed until the last minute. Go ahead and
158
* claim the limit, so that usage of the 4 multisample-based API that is
159
* guaranteed in 3.0 succeeds, even though we only rasterize a single sample.
162
192
ctx->Const.MaxSamples = 4;
193
else if (intel->gen >= 7)
194
ctx->Const.MaxSamples = 8;
164
196
/* if conformance mode is set, swrast can handle any size AA point */
165
197
ctx->Const.MaxPointSizeAA = 255.0;
247
279
brw->urb.max_vs_entries = 512;
248
280
brw->urb.max_gs_entries = 192;
249
281
} else if (intel->gt == 2) {
250
brw->max_wm_threads = 86;
282
brw->max_wm_threads = 172;
251
283
brw->max_vs_threads = 128;
252
284
brw->max_gs_threads = 128;
253
285
brw->urb.size = 256;
259
291
} else if (intel->gen == 6) {
260
292
if (intel->gt == 2) {
261
/* This could possibly be 80, but is supposed to require
262
* disabling of WIZ hashing (bit 6 of GT_MODE, 0x20d0) and a
263
* GPU reset to change.
265
brw->max_wm_threads = 40;
293
brw->max_wm_threads = 80;
266
294
brw->max_vs_threads = 60;
267
295
brw->max_gs_threads = 60;
268
296
brw->urb.size = 64; /* volume 5c.5 section 5.1 */
273
301
brw->max_vs_threads = 24;
274
302
brw->max_gs_threads = 21; /* conservative; 24 if rendering disabled */
275
303
brw->urb.size = 32; /* volume 5c.5 section 5.1 */
276
brw->urb.max_vs_entries = 128; /* volume 2a (see 3DSTATE_URB) */
304
brw->urb.max_vs_entries = 256; /* volume 2a (see 3DSTATE_URB) */
277
305
brw->urb.max_gs_entries = 256;
279
307
brw->urb.gen6_gs_previously_active = false;
295
323
brw->has_negative_rhw_bug = true;
326
if (intel->gen <= 7) {
327
brw->needs_unlit_centroid_workaround = true;
330
brw->prim_restart.in_progress = false;
331
brw->prim_restart.enable_cut_index = false;
332
intel->hw_ctx = drm_intel_gem_context_create(intel->bufmgr);
298
334
brw_init_state( brw );
300
336
brw->curbe.last_buf = calloc(1, 4096);