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.
This commit is contained in:
Chia-I Wu 2013-06-06 11:28:02 +08:00
parent 39e947569e
commit 2d82885d3c
10 changed files with 69 additions and 99 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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;

View file

@ -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;
@ -4209,39 +4216,6 @@ gen6_emit_surf_SURFACE_STATE(const struct ilo_dev_info *dev,
return gen6_emit_SURFACE_STATE(dev, &surf, true, cp);
}
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,
@ -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),

View file

@ -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);

View file

@ -1717,39 +1717,6 @@ gen7_emit_surf_SURFACE_STATE(const struct ilo_dev_info *dev,
return gen7_emit_SURFACE_STATE(dev, &surf, true, cp);
}
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,
@ -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);

View file

@ -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);

View file

@ -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;

View file

@ -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;
return view;
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->base;
}
static void