diff options
author | Chia-I Wu <[email protected]> | 2013-06-06 11:28:02 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2013-06-07 11:13:16 +0800 |
commit | 2d82885d3cd9c5ab90e4777da8dfd723da273cd8 (patch) | |
tree | 8994f1566557fdc8a92b914c6b02ee73bcd06bf4 /src/gallium/drivers | |
parent | 39e947569e5c0e159045aa5771e0ee5509eedee4 (diff) |
ilo: add emit_SURFACE_STATE() for sampler views
Introduce ilo_view_cso and initialize it in create_sampler_view(). Add
emit_SURFACE_STATE() to GPE, which can emit SURFACE_STATE from
ilo_view_surface.
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/ilo/ilo_3d_pipeline.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c | 11 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_gpe.h | 6 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_gpe_gen6.c | 50 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_gpe_gen6.h | 15 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_gpe_gen7.c | 35 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_gpe_gen7.h | 4 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_shader.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_state.c | 37 |
10 files changed, 69 insertions, 99 deletions
diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline.h b/src/gallium/drivers/ilo/ilo_3d_pipeline.h index 9aa39bfb17e..800a3396c72 100644 --- a/src/gallium/drivers/ilo/ilo_3d_pipeline.h +++ b/src/gallium/drivers/ilo/ilo_3d_pipeline.h @@ -133,8 +133,8 @@ struct ilo_3d_pipeline { GEN6_EMIT(DEPTH_STENCIL_STATE); GEN6_EMIT(SCISSOR_RECT); GEN6_EMIT(BINDING_TABLE_STATE); + GEN6_EMIT(SURFACE_STATE); GEN6_EMIT(surf_SURFACE_STATE); - GEN6_EMIT(view_SURFACE_STATE); GEN6_EMIT(cbuf_SURFACE_STATE); GEN6_EMIT(so_SURFACE_STATE); GEN6_EMIT(SAMPLER_STATE); diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c index 7b6181457b1..0ac9bcd6f9b 100644 --- a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c +++ b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c @@ -937,7 +937,7 @@ gen6_pipeline_state_surfaces_view(struct ilo_3d_pipeline *p, int shader_type, struct gen6_pipeline_session *session) { - const struct pipe_sampler_view **views = + const struct pipe_sampler_view * const *views = (const struct pipe_sampler_view **) ilo->view[shader_type].states; const int num_views = ilo->view[shader_type].count; uint32_t *surface_state; @@ -978,8 +978,11 @@ gen6_pipeline_state_surfaces_view(struct ilo_3d_pipeline *p, for (i = 0; i < num_views; i++) { if (views[i]) { + const struct ilo_view_cso *cso = + (const struct ilo_view_cso *) views[i]; + surface_state[i] = - p->gen6_view_SURFACE_STATE(p->dev, views[i], p->cp); + p->gen6_SURFACE_STATE(p->dev, &cso->surface, false, p->cp); } else { surface_state[i] = 0; @@ -1120,7 +1123,7 @@ gen6_pipeline_state_samplers(struct ilo_3d_pipeline *p, { const struct ilo_sampler_cso * const *samplers = ilo->sampler[shader_type].cso; - const struct pipe_sampler_view **views = + const struct pipe_sampler_view * const *views = (const struct pipe_sampler_view **) ilo->view[shader_type].states; const int num_samplers = ilo->sampler[shader_type].count; const int num_views = ilo->view[shader_type].count; @@ -1637,8 +1640,8 @@ ilo_3d_pipeline_init_gen6(struct ilo_3d_pipeline *p) GEN6_USE(p, DEPTH_STENCIL_STATE, gen6); GEN6_USE(p, SCISSOR_RECT, gen6); GEN6_USE(p, BINDING_TABLE_STATE, gen6); + GEN6_USE(p, SURFACE_STATE, gen6); GEN6_USE(p, surf_SURFACE_STATE, gen6); - GEN6_USE(p, view_SURFACE_STATE, gen6); GEN6_USE(p, cbuf_SURFACE_STATE, gen6); GEN6_USE(p, so_SURFACE_STATE, gen6); GEN6_USE(p, SAMPLER_STATE, gen6); diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c index 21932c87777..850475a3501 100644 --- a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c +++ b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c @@ -828,8 +828,8 @@ ilo_3d_pipeline_init_gen7(struct ilo_3d_pipeline *p) GEN6_USE(p, DEPTH_STENCIL_STATE, gen7); GEN6_USE(p, SCISSOR_RECT, gen7); GEN6_USE(p, BINDING_TABLE_STATE, gen7); + GEN6_USE(p, SURFACE_STATE, gen7); GEN6_USE(p, surf_SURFACE_STATE, gen7); - GEN6_USE(p, view_SURFACE_STATE, gen7); GEN6_USE(p, cbuf_SURFACE_STATE, gen7); GEN6_USE(p, SAMPLER_STATE, gen7); GEN6_USE(p, SAMPLER_BORDER_COLOR_STATE, gen7); diff --git a/src/gallium/drivers/ilo/ilo_gpe.h b/src/gallium/drivers/ilo/ilo_gpe.h index ccb4ebc1f0e..1b5a38f5d3c 100644 --- a/src/gallium/drivers/ilo/ilo_gpe.h +++ b/src/gallium/drivers/ilo/ilo_gpe.h @@ -168,6 +168,12 @@ struct ilo_view_surface { struct intel_bo *bo; }; +struct ilo_view_cso { + struct pipe_sampler_view base; + + struct ilo_view_surface surface; +}; + struct ilo_view_state { struct pipe_sampler_view *states[ILO_MAX_SAMPLER_VIEWS]; unsigned count; diff --git a/src/gallium/drivers/ilo/ilo_gpe_gen6.c b/src/gallium/drivers/ilo/ilo_gpe_gen6.c index f6d2fab2786..5eb797cef16 100644 --- a/src/gallium/drivers/ilo/ilo_gpe_gen6.c +++ b/src/gallium/drivers/ilo/ilo_gpe_gen6.c @@ -4149,11 +4149,11 @@ gen6_emit_SURFACE_STATE(const struct ilo_dev_info *dev, struct ilo_cp *cp) { const int state_align = 32 / 4; - const int state_len = 6; + const int state_len = (dev->gen >= ILO_GEN(7)) ? 8 : 6; uint32_t state_offset; uint32_t read_domains, write_domain; - ILO_GPE_VALID_GEN(dev, 6, 6); + ILO_GPE_VALID_GEN(dev, 6, 7); if (for_render) { read_domains = INTEL_DOMAIN_RENDER; @@ -4166,6 +4166,8 @@ gen6_emit_SURFACE_STATE(const struct ilo_dev_info *dev, ilo_cp_steal(cp, "SURFACE_STATE", state_len, state_align, &state_offset); + STATIC_ASSERT(Elements(surf->payload) >= 8); + ilo_cp_write(cp, surf->payload[0]); ilo_cp_write_bo(cp, surf->payload[1], surf->bo, read_domains, write_domain); @@ -4174,6 +4176,11 @@ gen6_emit_SURFACE_STATE(const struct ilo_dev_info *dev, ilo_cp_write(cp, surf->payload[4]); ilo_cp_write(cp, surf->payload[5]); + if (dev->gen >= ILO_GEN(7)) { + ilo_cp_write(cp, surf->payload[6]); + ilo_cp_write(cp, surf->payload[7]); + } + ilo_cp_end(cp); return state_offset; @@ -4210,39 +4217,6 @@ gen6_emit_surf_SURFACE_STATE(const struct ilo_dev_info *dev, } static uint32_t -gen6_emit_view_SURFACE_STATE(const struct ilo_dev_info *dev, - const struct pipe_sampler_view *view, - struct ilo_cp *cp) -{ - struct ilo_view_surface surf; - - ILO_GPE_VALID_GEN(dev, 6, 6); - - if (view->texture->target == PIPE_BUFFER) { - const unsigned elem_size = util_format_get_blocksize(view->format); - const unsigned first_elem = view->u.buf.first_element; - const unsigned num_elems = view->u.buf.last_element - first_elem + 1; - struct ilo_buffer *buf = ilo_buffer(view->texture); - - ilo_gpe_init_view_surface_for_buffer_gen6(dev, buf, - first_elem * elem_size, num_elems * elem_size, - elem_size, view->format, false, false, &surf); - } - else { - struct ilo_texture *tex = ilo_texture(view->texture); - - ilo_gpe_init_view_surface_for_texture_gen6(dev, tex, view->format, - view->u.tex.first_level, - view->u.tex.last_level - view->u.tex.first_level + 1, - view->u.tex.first_layer, - view->u.tex.last_layer - view->u.tex.first_layer + 1, - false, false, &surf); - } - - return gen6_emit_SURFACE_STATE(dev, &surf, false, cp); -} - -static uint32_t gen6_emit_cbuf_SURFACE_STATE(const struct ilo_dev_info *dev, const struct pipe_constant_buffer *cbuf, struct ilo_cp *cp) @@ -4664,7 +4638,7 @@ ilo_gpe_init_sampler_cso(const struct ilo_dev_info *dev, static uint32_t gen6_emit_SAMPLER_STATE(const struct ilo_dev_info *dev, const struct ilo_sampler_cso * const *samplers, - const struct pipe_sampler_view * const *sampler_views, + const struct pipe_sampler_view * const *views, const uint32_t *sampler_border_colors, int num_samplers, struct ilo_cp *cp) @@ -4691,7 +4665,7 @@ gen6_emit_SAMPLER_STATE(const struct ilo_dev_info *dev, for (i = 0; i < num_samplers; i++) { const struct ilo_sampler_cso *sampler = samplers[i]; - const struct pipe_sampler_view *view = sampler_views[i]; + const struct pipe_sampler_view *view = views[i]; const uint32_t border_color = sampler_border_colors[i]; uint32_t dw_filter, dw_wrap; @@ -4986,8 +4960,8 @@ static const struct ilo_gpe_gen6 gen6_gpe = { GEN6_SET(DEPTH_STENCIL_STATE), GEN6_SET(SCISSOR_RECT), GEN6_SET(BINDING_TABLE_STATE), + GEN6_SET(SURFACE_STATE), GEN6_SET(surf_SURFACE_STATE), - GEN6_SET(view_SURFACE_STATE), GEN6_SET(cbuf_SURFACE_STATE), GEN6_SET(so_SURFACE_STATE), GEN6_SET(SAMPLER_STATE), diff --git a/src/gallium/drivers/ilo/ilo_gpe_gen6.h b/src/gallium/drivers/ilo/ilo_gpe_gen6.h index a3489c8d8f7..64893b55bf0 100644 --- a/src/gallium/drivers/ilo/ilo_gpe_gen6.h +++ b/src/gallium/drivers/ilo/ilo_gpe_gen6.h @@ -423,13 +423,14 @@ typedef uint32_t struct ilo_cp *cp); typedef uint32_t -(*ilo_gpe_gen6_surf_SURFACE_STATE)(const struct ilo_dev_info *dev, - const struct pipe_surface *surface, - struct ilo_cp *cp); +(*ilo_gpe_gen6_SURFACE_STATE)(const struct ilo_dev_info *dev, + const struct ilo_view_surface *surface, + bool for_render, + struct ilo_cp *cp); typedef uint32_t -(*ilo_gpe_gen6_view_SURFACE_STATE)(const struct ilo_dev_info *dev, - const struct pipe_sampler_view *view, +(*ilo_gpe_gen6_surf_SURFACE_STATE)(const struct ilo_dev_info *dev, + const struct pipe_surface *surface, struct ilo_cp *cp); typedef uint32_t @@ -447,7 +448,7 @@ typedef uint32_t typedef uint32_t (*ilo_gpe_gen6_SAMPLER_STATE)(const struct ilo_dev_info *dev, const struct ilo_sampler_cso * const *samplers, - const struct pipe_sampler_view * const *sampler_views, + const struct pipe_sampler_view * const *views, const uint32_t *sampler_border_colors, int num_samplers, struct ilo_cp *cp); @@ -528,8 +529,8 @@ struct ilo_gpe_gen6 { GEN6_EMIT(DEPTH_STENCIL_STATE); GEN6_EMIT(SCISSOR_RECT); GEN6_EMIT(BINDING_TABLE_STATE); + GEN6_EMIT(SURFACE_STATE); GEN6_EMIT(surf_SURFACE_STATE); - GEN6_EMIT(view_SURFACE_STATE); GEN6_EMIT(cbuf_SURFACE_STATE); GEN6_EMIT(so_SURFACE_STATE); GEN6_EMIT(SAMPLER_STATE); diff --git a/src/gallium/drivers/ilo/ilo_gpe_gen7.c b/src/gallium/drivers/ilo/ilo_gpe_gen7.c index 43b76628d66..5dd75bc3171 100644 --- a/src/gallium/drivers/ilo/ilo_gpe_gen7.c +++ b/src/gallium/drivers/ilo/ilo_gpe_gen7.c @@ -1718,39 +1718,6 @@ gen7_emit_surf_SURFACE_STATE(const struct ilo_dev_info *dev, } static uint32_t -gen7_emit_view_SURFACE_STATE(const struct ilo_dev_info *dev, - const struct pipe_sampler_view *view, - struct ilo_cp *cp) -{ - struct ilo_view_surface surf; - - ILO_GPE_VALID_GEN(dev, 7, 7); - - if (view->texture->target == PIPE_BUFFER) { - const unsigned elem_size = util_format_get_blocksize(view->format); - const unsigned first_elem = view->u.buf.first_element; - const unsigned num_elems = view->u.buf.last_element - first_elem + 1; - struct ilo_buffer *buf = ilo_buffer(view->texture); - - ilo_gpe_init_view_surface_for_buffer_gen7(dev, buf, - first_elem * elem_size, num_elems * elem_size, - elem_size, view->format, false, false, &surf); - } - else { - struct ilo_texture *tex = ilo_texture(view->texture); - - ilo_gpe_init_view_surface_for_texture_gen7(dev, tex, view->format, - view->u.tex.first_level, - view->u.tex.last_level - view->u.tex.first_level + 1, - view->u.tex.first_layer, - view->u.tex.last_layer - view->u.tex.first_layer + 1, - false, false, &surf); - } - - return gen7_emit_SURFACE_STATE(dev, &surf, false, cp); -} - -static uint32_t gen7_emit_cbuf_SURFACE_STATE(const struct ilo_dev_info *dev, const struct pipe_constant_buffer *cbuf, struct ilo_cp *cp) @@ -1993,8 +1960,8 @@ gen7_init(struct ilo_gpe_gen7 *gen7) GEN7_USE(gen7, DEPTH_STENCIL_STATE, gen6); GEN7_USE(gen7, SCISSOR_RECT, gen6); GEN7_USE(gen7, BINDING_TABLE_STATE, gen6); + GEN7_USE(gen7, SURFACE_STATE, gen6); GEN7_SET(gen7, surf_SURFACE_STATE); - GEN7_SET(gen7, view_SURFACE_STATE); GEN7_SET(gen7, cbuf_SURFACE_STATE); GEN7_USE(gen7, SAMPLER_STATE, gen6); GEN7_USE(gen7, SAMPLER_BORDER_COLOR_STATE, gen6); diff --git a/src/gallium/drivers/ilo/ilo_gpe_gen7.h b/src/gallium/drivers/ilo/ilo_gpe_gen7.h index 5cc1fb1aaf8..552b2172247 100644 --- a/src/gallium/drivers/ilo/ilo_gpe_gen7.h +++ b/src/gallium/drivers/ilo/ilo_gpe_gen7.h @@ -385,8 +385,8 @@ typedef ilo_gpe_gen6_BLEND_STATE ilo_gpe_gen7_BLEND_STATE; typedef ilo_gpe_gen6_DEPTH_STENCIL_STATE ilo_gpe_gen7_DEPTH_STENCIL_STATE; typedef ilo_gpe_gen6_SCISSOR_RECT ilo_gpe_gen7_SCISSOR_RECT; typedef ilo_gpe_gen6_BINDING_TABLE_STATE ilo_gpe_gen7_BINDING_TABLE_STATE; +typedef ilo_gpe_gen6_SURFACE_STATE ilo_gpe_gen7_SURFACE_STATE; typedef ilo_gpe_gen6_surf_SURFACE_STATE ilo_gpe_gen7_surf_SURFACE_STATE; -typedef ilo_gpe_gen6_view_SURFACE_STATE ilo_gpe_gen7_view_SURFACE_STATE; typedef ilo_gpe_gen6_cbuf_SURFACE_STATE ilo_gpe_gen7_cbuf_SURFACE_STATE; typedef ilo_gpe_gen6_SAMPLER_STATE ilo_gpe_gen7_SAMPLER_STATE; typedef ilo_gpe_gen6_SAMPLER_BORDER_COLOR_STATE ilo_gpe_gen7_SAMPLER_BORDER_COLOR_STATE; @@ -483,8 +483,8 @@ struct ilo_gpe_gen7 { GEN7_EMIT(DEPTH_STENCIL_STATE); GEN7_EMIT(SCISSOR_RECT); GEN7_EMIT(BINDING_TABLE_STATE); + GEN7_EMIT(SURFACE_STATE); GEN7_EMIT(surf_SURFACE_STATE); - GEN7_EMIT(view_SURFACE_STATE); GEN7_EMIT(cbuf_SURFACE_STATE); GEN7_EMIT(SAMPLER_STATE); GEN7_EMIT(SAMPLER_BORDER_COLOR_STATE); diff --git a/src/gallium/drivers/ilo/ilo_shader.c b/src/gallium/drivers/ilo/ilo_shader.c index 754b59baec2..9c692f26e60 100644 --- a/src/gallium/drivers/ilo/ilo_shader.c +++ b/src/gallium/drivers/ilo/ilo_shader.c @@ -77,10 +77,8 @@ ilo_shader_variant_init(struct ilo_shader_variant *variant, variant->num_sampler_views = info->num_samplers; for (i = 0; i < info->num_samplers; i++) { - const struct pipe_sampler_view *view = - ilo->view[info->type].states[i]; - const struct ilo_sampler_cso *sampler = - ilo->sampler[info->type].cso[i]; + const struct pipe_sampler_view *view = ilo->view[info->type].states[i]; + const struct ilo_sampler_cso *sampler = ilo->sampler[info->type].cso[i]; if (view) { variant->sampler_view_swizzles[i].r = view->swizzle_r; diff --git a/src/gallium/drivers/ilo/ilo_state.c b/src/gallium/drivers/ilo/ilo_state.c index b154ece5a1e..a88d643a3bf 100644 --- a/src/gallium/drivers/ilo/ilo_state.c +++ b/src/gallium/drivers/ilo/ilo_state.c @@ -29,6 +29,7 @@ #include "util/u_helpers.h" #include "ilo_context.h" +#include "ilo_resource.h" #include "ilo_shader.h" #include "ilo_state.h" @@ -845,18 +846,38 @@ ilo_create_sampler_view(struct pipe_context *pipe, struct pipe_resource *res, const struct pipe_sampler_view *templ) { - struct pipe_sampler_view *view; + struct ilo_context *ilo = ilo_context(pipe); + struct ilo_view_cso *view; - view = MALLOC_STRUCT(pipe_sampler_view); + view = MALLOC_STRUCT(ilo_view_cso); assert(view); - *view = *templ; - pipe_reference_init(&view->reference, 1); - view->texture = NULL; - pipe_resource_reference(&view->texture, res); - view->context = pipe; + view->base = *templ; + pipe_reference_init(&view->base.reference, 1); + view->base.texture = NULL; + pipe_resource_reference(&view->base.texture, res); + view->base.context = pipe; + + if (res->target == PIPE_BUFFER) { + const unsigned elem_size = util_format_get_blocksize(templ->format); + const unsigned first_elem = templ->u.buf.first_element; + const unsigned num_elems = templ->u.buf.last_element - first_elem + 1; + + ilo_gpe_init_view_surface_for_buffer(ilo->dev, ilo_buffer(res), + first_elem * elem_size, num_elems * elem_size, + elem_size, templ->format, false, false, &view->surface); + } + else { + ilo_gpe_init_view_surface_for_texture(ilo->dev, ilo_texture(res), + templ->format, + templ->u.tex.first_level, + templ->u.tex.last_level - templ->u.tex.first_level + 1, + templ->u.tex.first_layer, + templ->u.tex.last_layer - templ->u.tex.first_layer + 1, + false, false, &view->surface); + } - return view; + return &view->base; } static void |