diff --git a/src/mesa/drivers/dri/i915/i915_context.h b/src/mesa/drivers/dri/i915/i915_context.h index 5e2e2ae7e4b..7cace1051a6 100644 --- a/src/mesa/drivers/dri/i915/i915_context.h +++ b/src/mesa/drivers/dri/i915/i915_context.h @@ -266,6 +266,12 @@ do { \ */ extern void i915InitVtbl( struct i915_context *i915 ); +extern void +i915_state_draw_region(struct intel_context *intel, + struct i915_hw_state *state, + struct intel_region *color_region, + struct intel_region *depth_region); + #define SZ_TO_HW(sz) ((sz-2)&0x3) diff --git a/src/mesa/drivers/dri/i915/i915_metaops.c b/src/mesa/drivers/dri/i915/i915_metaops.c index c5455976f8c..65360d6dcf0 100644 --- a/src/mesa/drivers/dri/i915/i915_metaops.c +++ b/src/mesa/drivers/dri/i915/i915_metaops.c @@ -431,60 +431,13 @@ static GLboolean meta_tex_rect_source( struct intel_context *intel, /** * Set the color and depth drawing region for meta ops. - * XXX Lots of code duplication here with i915_set_draw_region. */ static void meta_draw_region( struct intel_context *intel, struct intel_region *color_region, struct intel_region *depth_region ) { struct i915_context *i915 = i915_context(&intel->ctx); - GLuint color_format; - GLuint depth_format = DEPTH_FRMT_16_FIXED; - - intel_region_release(intel, &i915->meta.draw_region); - intel_region_reference(&i915->meta.draw_region, color_region); - - intel_region_release(intel, &i915->meta.depth_region); - intel_region_reference(&i915->meta.depth_region, depth_region); - - - if (color_region) { - i915->meta.Buffer[I915_DESTREG_CBUFADDR0] = _3DSTATE_BUF_INFO_CMD; - i915->meta.Buffer[I915_DESTREG_CBUFADDR1] = - (BUF_3D_ID_COLOR_BACK | - BUF_3D_PITCH(color_region->pitch * color_region->cpp) | - BUF_3D_USE_FENCE); - } - - if (depth_region) { - i915->meta.Buffer[I915_DESTREG_DBUFADDR0] = _3DSTATE_BUF_INFO_CMD; - i915->meta.Buffer[I915_DESTREG_DBUFADDR1] = - (BUF_3D_ID_DEPTH | - BUF_3D_PITCH(depth_region->pitch * depth_region->cpp) | - BUF_3D_USE_FENCE); - } - - - /* XXX: 555 support? - */ - if (color_region->cpp == 2) - color_format = DV_PF_565; - else - color_format = DV_PF_8888; - - if (depth_region && depth_region->cpp == 4) - depth_format = DEPTH_FRMT_24_FIXED_8_OTHER; - else - depth_format = DEPTH_FRMT_16_FIXED; - - i915->meta.Buffer[I915_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */ - DSTORG_VERT_BIAS(0x8) | /* .5 */ - color_format | - LOD_PRECLAMP_OGL | - TEX_DEFAULT_COLOR_OGL | - depth_format); - - i915->meta.emitted &= ~I915_UPLOAD_BUFFERS; + i915_state_draw_region(intel, &i915->meta, color_region, depth_region); } diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c b/src/mesa/drivers/dri/i915/i915_vtbl.c index ba6f2de581f..b11382bdd4f 100644 --- a/src/mesa/drivers/dri/i915/i915_vtbl.c +++ b/src/mesa/drivers/dri/i915/i915_vtbl.c @@ -346,34 +346,38 @@ static void i915_destroy_context( struct intel_context *intel ) * Set the drawing regions for the color and depth/stencil buffers. * This involves setting the pitch, cpp and buffer ID/location. * Also set pixel format for color and Z rendering - * XXX Lots of code duplication with i915 meta_draw_region(). + * Used for setting both regular and meta state. */ -static void i915_set_draw_region( struct intel_context *intel, - struct intel_region *color_region, - struct intel_region *depth_region) +void +i915_state_draw_region(struct intel_context *intel, + struct i915_hw_state *state, + struct intel_region *color_region, + struct intel_region *depth_region) { struct i915_context *i915 = i915_context(&intel->ctx); GLuint value; - intel_region_release(intel, &i915->state.draw_region); - intel_region_release(intel, &i915->state.depth_region); - intel_region_reference(&i915->state.draw_region, color_region); - intel_region_reference(&i915->state.depth_region, depth_region); + ASSERT(state == &i915->state || state == &i915->meta); + + intel_region_release(intel, &state->draw_region); + intel_region_release(intel, &state->depth_region); + intel_region_reference(&state->draw_region, color_region); + intel_region_reference(&state->depth_region, depth_region); /* * Set stride/cpp values */ if (color_region) { - i915->state.Buffer[I915_DESTREG_CBUFADDR0] = _3DSTATE_BUF_INFO_CMD; - i915->state.Buffer[I915_DESTREG_CBUFADDR1] = + state->Buffer[I915_DESTREG_CBUFADDR0] = _3DSTATE_BUF_INFO_CMD; + state->Buffer[I915_DESTREG_CBUFADDR1] = (BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(color_region->pitch * color_region->cpp) | BUF_3D_USE_FENCE); } if (depth_region) { - i915->state.Buffer[I915_DESTREG_DBUFADDR0] = _3DSTATE_BUF_INFO_CMD; - i915->state.Buffer[I915_DESTREG_DBUFADDR1] = + state->Buffer[I915_DESTREG_DBUFADDR0] = _3DSTATE_BUF_INFO_CMD; + state->Buffer[I915_DESTREG_DBUFADDR1] = (BUF_3D_ID_DEPTH | BUF_3D_PITCH(depth_region->pitch * depth_region->cpp) | BUF_3D_USE_FENCE); @@ -398,11 +402,23 @@ static void i915_set_draw_region( struct intel_context *intel, else { value |= DEPTH_FRMT_16_FIXED; } - i915->state.Buffer[I915_DESTREG_DV1] = value; + state->Buffer[I915_DESTREG_DV1] = value; I915_STATECHANGE( i915, I915_UPLOAD_BUFFERS ); } + +static void +i915_set_draw_region(struct intel_context *intel, + struct intel_region *color_region, + struct intel_region *depth_region) +{ + struct i915_context *i915 = i915_context(&intel->ctx); + i915_state_draw_region(intel, &i915->state, color_region, depth_region); +} + + + static void i915_lost_hardware( struct intel_context *intel ) { struct i915_context *i915 = i915_context(&intel->ctx);