diff options
author | Dave Airlie <[email protected]> | 2017-12-05 08:34:26 +0000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2017-12-05 20:07:07 +0000 |
commit | 275293b2b45eae013c461ee4bf3e179983936b12 (patch) | |
tree | f768c3114e87c9e4caa7b8016dd0685e8bfe74c9 | |
parent | df21cd5248d20ced6aa31837511afdf61da213d0 (diff) |
r600: refactor out the immediate setup code.
This just refactors the same code out of the images/buffers paths.
Signed-off-by: Dave Airlie <[email protected]>
-rw-r--r-- | src/gallium/drivers/r600/evergreen_state.c | 66 |
1 files changed, 28 insertions, 38 deletions
diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index a1d2e0cd14b..e46f55bb79c 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -3853,6 +3853,32 @@ static void evergreen_set_tess_state(struct pipe_context *ctx, rctx->tess_state_dirty = true; } +static void evergreen_setup_immed_buffer(struct r600_context *rctx, + struct r600_image_view *rview, + enum pipe_format pformat) +{ + struct r600_screen *rscreen = (struct r600_screen *)rctx->b.b.screen; + uint32_t immed_size = rscreen->b.info.max_se * 256 * 64 * util_format_get_blocksize(pformat); + struct eg_buf_res_params buf_params; + bool skip_reloc = false; + struct r600_resource *resource = (struct r600_resource *)rview->base.resource; + if (!resource->immed_buffer) { + eg_resource_alloc_immed(&rscreen->b, resource, immed_size); + } + + memset(&buf_params, 0, sizeof(buf_params)); + buf_params.pipe_format = pformat; + buf_params.size = resource->immed_buffer->b.b.width0; + buf_params.swizzle[0] = PIPE_SWIZZLE_X; + buf_params.swizzle[1] = PIPE_SWIZZLE_Y; + buf_params.swizzle[2] = PIPE_SWIZZLE_Z; + buf_params.swizzle[3] = PIPE_SWIZZLE_W; + buf_params.uncached = 1; + evergreen_fill_buffer_resource_words(rctx, &resource->immed_buffer->b.b, + &buf_params, &skip_reloc, + rview->immed_resource_words); +} + static void evergreen_set_hw_atomic_buffers(struct pipe_context *ctx, unsigned start_slot, unsigned count, @@ -3891,7 +3917,6 @@ static void evergreen_set_shader_buffers(struct pipe_context *ctx, const struct pipe_shader_buffer *buffers) { struct r600_context *rctx = (struct r600_context *)ctx; - struct r600_screen *rscreen = (struct r600_screen *)ctx->screen; struct r600_image_state *istate = NULL; struct r600_image_view *rview; struct r600_tex_color_info color; @@ -3899,7 +3924,6 @@ static void evergreen_set_shader_buffers(struct pipe_context *ctx, struct r600_resource *resource; int i, idx; unsigned old_mask; - bool skip_reloc = false; if (shader != PIPE_SHADER_FRAGMENT && count == 0) return; @@ -3924,11 +3948,8 @@ static void evergreen_set_shader_buffers(struct pipe_context *ctx, pipe_resource_reference((struct pipe_resource **)&rview->base.resource, buf->buffer); resource = (struct r600_resource *)rview->base.resource; - if (!resource->immed_buffer) { - int immed_size = (rscreen->b.info.max_se * 256 * 64) * util_format_get_blocksize(resource->b.b.format); - eg_resource_alloc_immed(&rscreen->b, resource, immed_size); - } + evergreen_setup_immed_buffer(rctx, rview, resource->b.b.format); color.offset = 0; color.view = 0; @@ -3953,18 +3974,6 @@ static void evergreen_set_shader_buffers(struct pipe_context *ctx, rview->cb_color_fmask_slice = color.fmask_slice; memset(&buf_params, 0, sizeof(buf_params)); - buf_params.pipe_format = resource->b.b.format; - buf_params.size = resource->immed_buffer->b.b.width0; - buf_params.swizzle[0] = PIPE_SWIZZLE_X; - buf_params.swizzle[1] = PIPE_SWIZZLE_Y; - buf_params.swizzle[2] = PIPE_SWIZZLE_Z; - buf_params.swizzle[3] = PIPE_SWIZZLE_W; - buf_params.uncached = 1; - evergreen_fill_buffer_resource_words(rctx, &resource->immed_buffer->b.b, - &buf_params, &skip_reloc, - rview->immed_resource_words); - - memset(&buf_params, 0, sizeof(buf_params)); buf_params.pipe_format = PIPE_FORMAT_R32_FLOAT; buf_params.offset = buf->buffer_offset; buf_params.size = buf->buffer_size; @@ -4001,7 +4010,6 @@ static void evergreen_set_shader_images(struct pipe_context *ctx, const struct pipe_image_view *images) { struct r600_context *rctx = (struct r600_context *)ctx; - struct r600_screen *rscreen = (struct r600_screen *)ctx->screen; int i; struct r600_image_view *rview; struct pipe_resource *image; @@ -4010,7 +4018,6 @@ static void evergreen_set_shader_images(struct pipe_context *ctx, struct eg_buf_res_params buf_params; struct eg_tex_res_params tex_params; unsigned old_mask; - bool skip_reloc = false; struct r600_image_state *istate = NULL; int idx; if (shader != PIPE_SHADER_FRAGMENT && count == 0) @@ -4041,11 +4048,7 @@ static void evergreen_set_shader_images(struct pipe_context *ctx, rview->base.resource = NULL; pipe_resource_reference((struct pipe_resource **)&rview->base.resource, image); - if (!resource->immed_buffer) { - int immed_size = (rscreen->b.info.max_se * 256 * 64) * util_format_get_blocksize(iview->format); - - eg_resource_alloc_immed(&rscreen->b, resource, immed_size); - } + evergreen_setup_immed_buffer(rctx, rview, iview->format); bool is_buffer = image->target == PIPE_BUFFER; struct r600_texture *rtex = (struct r600_texture *)image; @@ -4118,19 +4121,6 @@ static void evergreen_set_shader_images(struct pipe_context *ctx, rview->cb_color_fmask = color.fmask; rview->cb_color_fmask_slice = color.fmask_slice; - memset(&buf_params, 0, sizeof(buf_params)); - buf_params.pipe_format = iview->format; - buf_params.size = resource->immed_buffer->b.b.width0; - buf_params.swizzle[0] = PIPE_SWIZZLE_X; - buf_params.swizzle[1] = PIPE_SWIZZLE_Y; - buf_params.swizzle[2] = PIPE_SWIZZLE_Z; - buf_params.swizzle[3] = PIPE_SWIZZLE_W; - buf_params.uncached = 1; - evergreen_fill_buffer_resource_words(rctx, &resource->immed_buffer->b.b, - &buf_params, &skip_reloc, - rview->immed_resource_words); - - if (image->target != PIPE_BUFFER) { memset(&tex_params, 0, sizeof(tex_params)); tex_params.pipe_format = iview->format; |