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);
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;
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;
{
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;
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);
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);
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;
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;
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);
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;
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,
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)
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;
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),
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
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);
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);
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,
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);
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;
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);
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;
#include "util/u_helpers.h"
#include "ilo_context.h"
+#include "ilo_resource.h"
#include "ilo_shader.h"
#include "ilo_state.h"
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