diff options
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 55 |
1 files changed, 32 insertions, 23 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 67438b0f7e3..af629a17bfa 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -639,26 +639,14 @@ brw_emit_buffer_surface_state(struct brw_context *brw, .mocs = brw_get_bo_mocs(devinfo, bo)); } -void -brw_update_buffer_texture_surface(struct gl_context *ctx, - unsigned unit, - uint32_t *surf_offset) +static unsigned +buffer_texture_range_size(struct brw_context *brw, + struct gl_texture_object *obj) { - struct brw_context *brw = brw_context(ctx); - struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current; - struct intel_buffer_object *intel_obj = - intel_buffer_object(tObj->BufferObject); - uint32_t size = tObj->BufferSize; - struct brw_bo *bo = NULL; - mesa_format format = tObj->_BufferObjectFormat; - const enum isl_format isl_format = brw_isl_format_for_mesa_format(format); - int texel_size = _mesa_get_format_bytes(format); - - if (intel_obj) { - size = MIN2(size, intel_obj->Base.Size); - bo = intel_bufferobj_buffer(brw, intel_obj, tObj->BufferOffset, size, - false); - } + assert(obj->Target == GL_TEXTURE_BUFFER); + const unsigned texel_size = _mesa_get_format_bytes(obj->_BufferObjectFormat); + const unsigned buffer_size = (!obj->BufferObject ? 0 : + obj->BufferObject->Size); /* The ARB_texture_buffer_specification says: * @@ -676,7 +664,28 @@ brw_update_buffer_texture_surface(struct gl_context *ctx, * so that when ISL divides by stride to obtain the number of texels, that * texel count is clamped to MAX_TEXTURE_BUFFER_SIZE. */ - size = MIN2(size, ctx->Const.MaxTextureBufferSize * (unsigned) texel_size); + return MIN3((unsigned)obj->BufferSize, buffer_size, + brw->ctx.Const.MaxTextureBufferSize * texel_size); +} + +void +brw_update_buffer_texture_surface(struct gl_context *ctx, + unsigned unit, + uint32_t *surf_offset) +{ + struct brw_context *brw = brw_context(ctx); + struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current; + struct intel_buffer_object *intel_obj = + intel_buffer_object(tObj->BufferObject); + const unsigned size = buffer_texture_range_size(brw, tObj); + struct brw_bo *bo = NULL; + mesa_format format = tObj->_BufferObjectFormat; + const enum isl_format isl_format = brw_isl_format_for_mesa_format(format); + int texel_size = _mesa_get_format_bytes(format); + + if (intel_obj) + bo = intel_bufferobj_buffer(brw, intel_obj, tObj->BufferOffset, size, + false); if (isl_format == ISL_FORMAT_UNSUPPORTED) { _mesa_problem(NULL, "bad format %s for texture buffer\n", @@ -1477,8 +1486,7 @@ update_buffer_image_param(struct brw_context *brw, unsigned surface_idx, struct brw_image_param *param) { - struct gl_buffer_object *obj = u->TexObj->BufferObject; - const uint32_t size = MIN2((uint32_t)u->TexObj->BufferSize, obj->Size); + const unsigned size = buffer_texture_range_size(brw, u->TexObj); update_default_image_param(brw, u, surface_idx, param); param->size[0] = size / _mesa_get_format_bytes(u->_ActualFormat); @@ -1514,10 +1522,11 @@ update_image_surface(struct brw_context *brw, intel_buffer_object(obj->BufferObject); const unsigned texel_size = (format == ISL_FORMAT_RAW ? 1 : _mesa_get_format_bytes(u->_ActualFormat)); + const unsigned buffer_size = buffer_texture_range_size(brw, obj); brw_emit_buffer_surface_state( brw, surf_offset, intel_obj->buffer, obj->BufferOffset, - format, intel_obj->Base.Size, texel_size, + format, buffer_size, texel_size, access != GL_READ_ONLY ? RELOC_WRITE : 0); update_buffer_image_param(brw, u, surface_idx, param); |