104
104
key->uses_kill = fp->UsesKill || ctx->Color.AlphaEnabled;
105
105
key->is_glsl = bfp->isGLSL;
107
/* temporary sanity check assertion */
108
ASSERT(bfp->isGLSL == brw_wm_is_glsl(fp));
107
/* If using the fragment shader backend, the program is always
110
if (ctx->Shader.CurrentProgram) {
113
for (i = 0; i < ctx->Shader.CurrentProgram->_NumLinkedShaders; i++) {
114
struct brw_shader *shader =
115
(struct brw_shader *)ctx->Shader.CurrentProgram->_LinkedShaders[i];;
117
if (shader->base.Type == GL_FRAGMENT_SHADER &&
118
shader->ir != NULL) {
119
key->is_glsl = GL_TRUE;
111
125
key->stats_wm = intel->stats_wm;
123
137
* Setup wm hardware state. See page 225 of Volume 2
139
static drm_intel_bo *
126
140
wm_unit_create_from_key(struct brw_context *brw, struct brw_wm_unit_key *key,
141
drm_intel_bo **reloc_bufs)
129
143
struct intel_context *intel = &brw->intel;
130
144
struct brw_wm_unit_state wm;
133
147
memset(&wm, 0, sizeof(wm));
213
227
&wm, sizeof(wm));
215
229
/* Emit WM program relocation */
216
dri_bo_emit_reloc(bo,
217
I915_GEM_DOMAIN_INSTRUCTION, 0,
218
wm.thread0.grf_reg_count << 1,
219
offsetof(struct brw_wm_unit_state, thread0),
230
drm_intel_bo_emit_reloc(bo, offsetof(struct brw_wm_unit_state, thread0),
231
brw->wm.prog_bo, wm.thread0.grf_reg_count << 1,
232
I915_GEM_DOMAIN_INSTRUCTION, 0);
222
234
/* Emit scratch space relocation */
223
235
if (key->total_scratch != 0) {
224
dri_bo_emit_reloc(bo,
226
wm.thread2.per_thread_scratch_space,
227
offsetof(struct brw_wm_unit_state, thread2),
236
drm_intel_bo_emit_reloc(bo, offsetof(struct brw_wm_unit_state, thread2),
238
wm.thread2.per_thread_scratch_space,
239
I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
231
242
/* Emit sampler state relocation */
232
243
if (key->sampler_count != 0) {
233
dri_bo_emit_reloc(bo,
234
I915_GEM_DOMAIN_INSTRUCTION, 0,
235
wm.wm4.stats_enable | (wm.wm4.sampler_count << 2),
236
offsetof(struct brw_wm_unit_state, wm4),
244
drm_intel_bo_emit_reloc(bo, offsetof(struct brw_wm_unit_state, wm4),
245
brw->wm.sampler_bo, (wm.wm4.stats_enable |
246
(wm.wm4.sampler_count << 2)),
247
I915_GEM_DOMAIN_INSTRUCTION, 0);
246
256
struct intel_context *intel = &brw->intel;
247
257
struct brw_wm_unit_key key;
248
dri_bo *reloc_bufs[3];
258
drm_intel_bo *reloc_bufs[3];
249
259
wm_unit_populate_key(brw, &key);
251
261
/* Allocate the necessary scratch space if we haven't already. Don't
257
267
GLuint total = key.total_scratch * brw->wm_max_threads;
259
269
if (brw->wm.scratch_bo && total > brw->wm.scratch_bo->size) {
260
dri_bo_unreference(brw->wm.scratch_bo);
270
drm_intel_bo_unreference(brw->wm.scratch_bo);
261
271
brw->wm.scratch_bo = NULL;
263
273
if (brw->wm.scratch_bo == NULL) {
264
brw->wm.scratch_bo = dri_bo_alloc(intel->bufmgr,
274
brw->wm.scratch_bo = drm_intel_bo_alloc(intel->bufmgr,
272
282
reloc_bufs[1] = brw->wm.scratch_bo;
273
283
reloc_bufs[2] = brw->wm.sampler_bo;
275
dri_bo_unreference(brw->wm.state_bo);
285
drm_intel_bo_unreference(brw->wm.state_bo);
276
286
brw->wm.state_bo = brw_search_cache(&brw->cache, BRW_WM_UNIT,
277
287
&key, sizeof(key),