diff options
author | Zou Nan hai <nanhai.zou@intel.com> | 2008-03-13 14:46:38 +0800 |
---|---|---|
committer | Zou Nan hai <nanhai.zou@intel.com> | 2008-03-13 14:46:38 +0800 |
commit | fcb7cb9e72ecac7c165a3a6ed7a033e2e6793a26 (patch) | |
tree | 8508705f5659c61d28f972307faacae97bfa5795 /src/mesa/drivers/dri/i965/brw_wm_surface_state.c | |
parent | 9110425c72e45f618131b559eba883fd6c5536b4 (diff) |
[i965] multiple rendering target support
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_wm_surface_state.c')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index f2ae210c38..d0f86b5687 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -226,13 +226,13 @@ brw_update_texture_surface( GLcontext *ctx, GLuint unit ) key.depth = firstImage->Depth; key.tiled = intelObj->mt->region->tiled; - dri_bo_unreference(brw->wm.surf_bo[unit + 1]); - brw->wm.surf_bo[unit + 1] = brw_search_cache(&brw->cache, BRW_SS_SURFACE, + dri_bo_unreference(brw->wm.surf_bo[unit + MAX_DRAW_BUFFERS]); + brw->wm.surf_bo[unit + MAX_DRAW_BUFFERS] = brw_search_cache(&brw->cache, BRW_SS_SURFACE, &key, sizeof(key), &key.bo, 1, NULL); - if (brw->wm.surf_bo[unit + 1] == NULL) - brw->wm.surf_bo[unit + 1] = brw_create_texture_surface(brw, &key); + if (brw->wm.surf_bo[unit + MAX_DRAW_BUFFERS] == NULL) + brw->wm.surf_bo[unit + MAX_DRAW_BUFFERS] = brw_create_texture_surface(brw, &key); } /** @@ -242,7 +242,7 @@ brw_update_texture_surface( GLcontext *ctx, GLuint unit ) */ static void brw_update_region_surface(struct brw_context *brw, struct intel_region *region, - unsigned int unit) + unsigned int unit, GLboolean cached) { dri_bo *region_bo = NULL; @@ -254,8 +254,6 @@ brw_update_region_surface(struct brw_context *brw, struct intel_region *region, GLboolean tiled, color_blend; } key; - memset(&key, 0, sizeof(key)); - if (region != NULL) { region_bo = region->buffer; @@ -276,17 +274,19 @@ brw_update_region_surface(struct brw_context *brw, struct intel_region *region, key.height = 1; key.cpp = 4; } - memcpy(key.color_mask, brw->attribs.Color->ColorMask, sizeof(key.color_mask)); key.color_blend = (!brw->attribs.Color->_LogicOpEnabled && brw->attribs.Color->BlendEnabled); dri_bo_unreference(brw->wm.surf_bo[unit]); - brw->wm.surf_bo[unit] = brw_search_cache(&brw->cache, BRW_SS_SURFACE, - &key, sizeof(key), - ®ion_bo, 1, - NULL); + brw->wm.surf_bo[unit] = NULL; + if (cached) + brw->wm.surf_bo[unit] = brw_search_cache(&brw->cache, BRW_SS_SURFACE, + &key, sizeof(key), + ®ion_bo, 1, + NULL); + if (brw->wm.surf_bo[unit] == NULL) { struct brw_surface_state surf; @@ -312,11 +312,10 @@ brw_update_region_surface(struct brw_context *brw, struct intel_region *region, /* Key size will never match key size for textures, so we're safe. */ brw->wm.surf_bo[unit] = brw_upload_cache(&brw->cache, BRW_SS_SURFACE, - &key, sizeof(key), + &key, sizeof(key), ®ion_bo, 1, &surf, sizeof(surf), NULL, NULL); - if (region_bo != NULL) { dri_emit_reloc(brw->wm.surf_bo[unit], DRM_BO_FLAG_MEM_TT | @@ -345,7 +344,7 @@ brw_wm_get_binding_table(struct brw_context *brw) NULL); if (bind_bo == NULL) { - GLuint data_size = brw->wm.nr_surfaces * 4; + GLuint data_size = brw->wm.nr_surfaces * sizeof(GLuint); uint32_t *data = malloc(data_size); int i; @@ -369,7 +368,7 @@ brw_wm_get_binding_table(struct brw_context *brw) DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, - i * 4, + i * sizeof(GLuint), brw->wm.surf_bo[i]); } } @@ -385,9 +384,14 @@ static void upload_wm_surfaces(struct brw_context *brw ) GLcontext *ctx = &brw->intel.ctx; struct intel_context *intel = &brw->intel; GLuint i; + if (brw->state.nr_draw_regions > 1) { + for (i = 0; i < brw->state.nr_draw_regions; i++) + brw_update_region_surface(brw, brw->state.draw_regions[i], i, + GL_FALSE); + }else + brw_update_region_surface(brw, brw->state.draw_regions[0], 0, GL_TRUE); - brw_update_region_surface(brw, brw->state.draw_region, 0); - brw->wm.nr_surfaces = 1; + brw->wm.nr_surfaces = MAX_DRAW_BUFFERS; for (i = 0; i < BRW_MAX_TEX_UNIT; i++) { struct gl_texture_unit *texUnit = &brw->attribs.Texture->Unit[i]; @@ -396,16 +400,16 @@ static void upload_wm_surfaces(struct brw_context *brw ) if(texUnit->_ReallyEnabled && texUnit->_Current == intel->frame_buffer_texobj) { - dri_bo_unreference(brw->wm.surf_bo[i+1]); - brw->wm.surf_bo[i+1] = brw->wm.surf_bo[0]; - dri_bo_reference(brw->wm.surf_bo[i+1]); - brw->wm.nr_surfaces = i+2; + dri_bo_unreference(brw->wm.surf_bo[i+MAX_DRAW_BUFFERS]); + brw->wm.surf_bo[i+MAX_DRAW_BUFFERS] = brw->wm.surf_bo[0]; + dri_bo_reference(brw->wm.surf_bo[i+MAX_DRAW_BUFFERS]); + brw->wm.nr_surfaces = i + MAX_DRAW_BUFFERS + 1; } else if (texUnit->_ReallyEnabled) { brw_update_texture_surface(ctx, i); - brw->wm.nr_surfaces = i+2; + brw->wm.nr_surfaces = i + MAX_DRAW_BUFFERS + 1; } else { - dri_bo_unreference(brw->wm.surf_bo[i+1]); - brw->wm.surf_bo[i+1] = NULL; + dri_bo_unreference(brw->wm.surf_bo[i+MAX_DRAW_BUFFERS]); + brw->wm.surf_bo[i+MAX_DRAW_BUFFERS] = NULL; } } |