📄 i830_vtbl.c
字号:
OUT_BATCH(_3DSTATE_W_STATE_CMD); OUT_BATCH(MAGIC_W_STATE_DWORD1); OUT_BATCH(0x3f800000 /* 1.0 in IEEE float */ ); OUT_BATCH(_3DSTATE_COLOR_FACTOR_CMD); OUT_BATCH(0x80808080); /* .5 required in alpha for GL_DOT3_RGBA_EXT */ ADVANCE_BATCH();}#define emit( intel, state, size ) \ intel_batchbuffer_data(intel->batch, state, size, IGNORE_CLIPRECTS )static GLuintget_dirty(struct i830_hw_state *state){ return state->active & ~state->emitted;}static GLuintget_state_size(struct i830_hw_state *state){ GLuint dirty = get_dirty(state); GLuint sz = 0; GLuint i; if (dirty & I830_UPLOAD_INVARIENT) sz += 40 * sizeof(int); if (dirty & I830_UPLOAD_CTX) sz += sizeof(state->Ctx); if (dirty & I830_UPLOAD_BUFFERS) sz += sizeof(state->Buffer); if (dirty & I830_UPLOAD_STIPPLE) sz += sizeof(state->Stipple); for (i = 0; i < I830_TEX_UNITS; i++) { if ((dirty & I830_UPLOAD_TEX(i))) sz += sizeof(state->Tex[i]); if (dirty & I830_UPLOAD_TEXBLEND(i)) sz += state->TexBlendWordsUsed[i] * 4; } return sz;}/* Push the state into the sarea and/or texture memory. */static voidi830_emit_state(struct intel_context *intel){ struct i830_context *i830 = i830_context(&intel->ctx); struct i830_hw_state *state = i830->current; int i, ret, count; GLuint dirty; GET_CURRENT_CONTEXT(ctx); BATCH_LOCALS; /* We don't hold the lock at this point, so want to make sure that * there won't be a buffer wrap between the state emits and the primitive * emit header. * * It might be better to talk about explicit places where * scheduling is allowed, rather than assume that it is whenever a * batchbuffer fills up. * * Set the space as LOOP_CLIPRECTS now, since that's what our primitives * will be emitted under. */ intel_batchbuffer_require_space(intel->batch, get_state_size(state) + 8, LOOP_CLIPRECTS); count = 0; again: dirty = get_dirty(state); ret = 0; if (dirty & I830_UPLOAD_BUFFERS) { ret |= dri_bufmgr_check_aperture_space(state->draw_region->buffer); ret |= dri_bufmgr_check_aperture_space(state->depth_region->buffer); } for (i = 0; i < I830_TEX_UNITS; i++) if (dirty & I830_UPLOAD_TEX(i)) { if (state->tex_buffer[i]) { ret |= dri_bufmgr_check_aperture_space(state->tex_buffer[i]); } } if (ret) { if (count == 0) { count++; intel_batchbuffer_flush(intel->batch); goto again; } else { _mesa_error(ctx, GL_OUT_OF_MEMORY, "i830 emit state"); assert(0); } } /* Do this here as we may have flushed the batchbuffer above, * causing more state to be dirty! */ dirty = get_dirty(state); state->emitted |= dirty; assert(get_dirty(state) == 0); if (dirty & I830_UPLOAD_INVARIENT) { DBG("I830_UPLOAD_INVARIENT:\n"); i830_emit_invarient_state(intel); } if (dirty & I830_UPLOAD_CTX) { DBG("I830_UPLOAD_CTX:\n"); emit(intel, state->Ctx, sizeof(state->Ctx)); } if (dirty & I830_UPLOAD_BUFFERS) { DBG("I830_UPLOAD_BUFFERS:\n"); BEGIN_BATCH(I830_DEST_SETUP_SIZE + 2, IGNORE_CLIPRECTS); OUT_BATCH(state->Buffer[I830_DESTREG_CBUFADDR0]); OUT_BATCH(state->Buffer[I830_DESTREG_CBUFADDR1]); OUT_RELOC(state->draw_region->buffer, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE, state->draw_region->draw_offset); if (state->depth_region) { OUT_BATCH(state->Buffer[I830_DESTREG_DBUFADDR0]); OUT_BATCH(state->Buffer[I830_DESTREG_DBUFADDR1]); OUT_RELOC(state->depth_region->buffer, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE, state->depth_region->draw_offset); } OUT_BATCH(state->Buffer[I830_DESTREG_DV0]); OUT_BATCH(state->Buffer[I830_DESTREG_DV1]); OUT_BATCH(state->Buffer[I830_DESTREG_SENABLE]); OUT_BATCH(state->Buffer[I830_DESTREG_SR0]); OUT_BATCH(state->Buffer[I830_DESTREG_SR1]); OUT_BATCH(state->Buffer[I830_DESTREG_SR2]); ADVANCE_BATCH(); } if (dirty & I830_UPLOAD_STIPPLE) { DBG("I830_UPLOAD_STIPPLE:\n"); emit(intel, state->Stipple, sizeof(state->Stipple)); } for (i = 0; i < I830_TEX_UNITS; i++) { if ((dirty & I830_UPLOAD_TEX(i))) { DBG("I830_UPLOAD_TEX(%d):\n", i); BEGIN_BATCH(I830_TEX_SETUP_SIZE + 1, IGNORE_CLIPRECTS); OUT_BATCH(state->Tex[i][I830_TEXREG_TM0LI]); if (state->tex_buffer[i]) { OUT_RELOC(state->tex_buffer[i], DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ, state->tex_offset[i] | TM0S0_USE_FENCE); } else if (state == &i830->meta) { assert(i == 0); OUT_BATCH(0); } else { OUT_BATCH(state->tex_offset[i]); } OUT_BATCH(state->Tex[i][I830_TEXREG_TM0S1]); OUT_BATCH(state->Tex[i][I830_TEXREG_TM0S2]); OUT_BATCH(state->Tex[i][I830_TEXREG_TM0S3]); OUT_BATCH(state->Tex[i][I830_TEXREG_TM0S4]); OUT_BATCH(state->Tex[i][I830_TEXREG_MCS]); OUT_BATCH(state->Tex[i][I830_TEXREG_CUBE]); } if (dirty & I830_UPLOAD_TEXBLEND(i)) { DBG("I830_UPLOAD_TEXBLEND(%d): %d words\n", i, state->TexBlendWordsUsed[i]); emit(intel, state->TexBlend[i], state->TexBlendWordsUsed[i] * 4); } } intel->batch->dirty_state &= ~dirty; assert(get_dirty(state) == 0); assert((intel->batch->dirty_state & (1<<1)) == 0);}static voidi830_destroy_context(struct intel_context *intel){ GLuint i; struct i830_context *i830 = i830_context(&intel->ctx); for (i = 0; i < I830_TEX_UNITS; i++) { if (i830->state.tex_buffer[i] != NULL) { dri_bo_unreference(i830->state.tex_buffer[i]); i830->state.tex_buffer[i] = NULL; } } _tnl_free_vertices(&intel->ctx);}voidi830_state_draw_region(struct intel_context *intel, struct i830_hw_state *state, struct intel_region *color_region, struct intel_region *depth_region){ struct i830_context *i830 = i830_context(&intel->ctx); GLuint value; ASSERT(state == &i830->state || state == &i830->meta); if (state->draw_region != color_region) { intel_region_release(&state->draw_region); intel_region_reference(&state->draw_region, color_region); } if (state->depth_region != depth_region) { intel_region_release(&state->depth_region); intel_region_reference(&state->depth_region, depth_region); } /* * Set stride/cpp values */ if (color_region) { state->Buffer[I830_DESTREG_CBUFADDR0] = _3DSTATE_BUF_INFO_CMD; state->Buffer[I830_DESTREG_CBUFADDR1] = (BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(color_region->pitch * color_region->cpp) | BUF_3D_USE_FENCE); } if (depth_region) { state->Buffer[I830_DESTREG_DBUFADDR0] = _3DSTATE_BUF_INFO_CMD; state->Buffer[I830_DESTREG_DBUFADDR1] = (BUF_3D_ID_DEPTH | BUF_3D_PITCH(depth_region->pitch * depth_region->cpp) | BUF_3D_USE_FENCE); } /* * Compute/set I830_DESTREG_DV1 value */ value = (DSTORG_HORT_BIAS(0x8) | /* .5 */ DSTORG_VERT_BIAS(0x8) | DEPTH_IS_Z); /* .5 */ if (color_region && color_region->cpp == 4) { value |= DV_PF_8888; } else { value |= DV_PF_565; } if (depth_region && depth_region->cpp == 4) { value |= DEPTH_FRMT_24_FIXED_8_OTHER; } else { value |= DEPTH_FRMT_16_FIXED; } state->Buffer[I830_DESTREG_DV1] = value; I830_STATECHANGE(i830, I830_UPLOAD_BUFFERS);}static voidi830_set_draw_region(struct intel_context *intel, struct intel_region *color_regions[], struct intel_region *depth_region, GLuint num_regions){ struct i830_context *i830 = i830_context(&intel->ctx); i830_state_draw_region(intel, &i830->state, color_regions[0], depth_region);}#if 0static voidi830_update_color_z_regions(intelContextPtr intel, const intelRegion * colorRegion, const intelRegion * depthRegion){ i830ContextPtr i830 = I830_CONTEXT(intel); i830->state.Buffer[I830_DESTREG_CBUFADDR1] = (BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(colorRegion->pitch) | BUF_3D_USE_FENCE); i830->state.Buffer[I830_DESTREG_CBUFADDR2] = colorRegion->offset; i830->state.Buffer[I830_DESTREG_DBUFADDR1] = (BUF_3D_ID_DEPTH | BUF_3D_PITCH(depthRegion->pitch) | BUF_3D_USE_FENCE); i830->state.Buffer[I830_DESTREG_DBUFADDR2] = depthRegion->offset;}#endif/* This isn't really handled at the moment. */static voidi830_new_batch(struct intel_context *intel){ struct i830_context *i830 = i830_context(&intel->ctx); i830->state.emitted = 0; /* Check that we didn't just wrap our batchbuffer at a bad time. */ assert(!intel->no_batch_wrap);}static GLuinti830_flush_cmd(void){ return MI_FLUSH | FLUSH_MAP_CACHE;}static void i830_assert_not_dirty( struct intel_context *intel ){ struct i830_context *i830 = i830_context(&intel->ctx); struct i830_hw_state *state = i830->current; assert(!get_dirty(state));}static voidi830_note_unlock( struct intel_context *intel ){ /* nothing */}voidi830InitVtbl(struct i830_context *i830){ i830->intel.vtbl.check_vertex_size = i830_check_vertex_size; i830->intel.vtbl.destroy = i830_destroy_context; i830->intel.vtbl.emit_state = i830_emit_state; i830->intel.vtbl.new_batch = i830_new_batch; i830->intel.vtbl.reduced_primitive_state = i830_reduced_primitive_state; i830->intel.vtbl.set_draw_region = i830_set_draw_region; i830->intel.vtbl.update_texture_state = i830UpdateTextureState; i830->intel.vtbl.flush_cmd = i830_flush_cmd; i830->intel.vtbl.render_start = i830_render_start; i830->intel.vtbl.render_prevalidate = i830_render_prevalidate; i830->intel.vtbl.assert_not_dirty = i830_assert_not_dirty; i830->intel.vtbl.note_unlock = i830_note_unlock; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -