{
/* SF_CLIP_VIEWPORT and CC_VIEWPORT */
if (p->dev->gen >= ILO_GEN(7) && DIRTY(VIEWPORT)) {
- p->state.SF_CLIP_VIEWPORT = gen7_emit_SF_CLIP_VIEWPORT(p->dev,
- ilo->viewport.cso, ilo->viewport.count, p->cp);
+ p->state.SF_CLIP_VIEWPORT = gen7_SF_CLIP_VIEWPORT(&p->cp->builder,
+ ilo->viewport.cso, ilo->viewport.count);
- p->state.CC_VIEWPORT = gen6_emit_CC_VIEWPORT(p->dev,
- ilo->viewport.cso, ilo->viewport.count, p->cp);
+ p->state.CC_VIEWPORT = gen6_CC_VIEWPORT(&p->cp->builder,
+ ilo->viewport.cso, ilo->viewport.count);
session->viewport_state_changed = true;
}
/* SF_VIEWPORT, CLIP_VIEWPORT, and CC_VIEWPORT */
else if (DIRTY(VIEWPORT)) {
- p->state.CLIP_VIEWPORT = gen6_emit_CLIP_VIEWPORT(p->dev,
- ilo->viewport.cso, ilo->viewport.count, p->cp);
+ p->state.CLIP_VIEWPORT = gen6_CLIP_VIEWPORT(&p->cp->builder,
+ ilo->viewport.cso, ilo->viewport.count);
- p->state.SF_VIEWPORT = gen6_emit_SF_VIEWPORT(p->dev,
- ilo->viewport.cso, ilo->viewport.count, p->cp);
+ p->state.SF_VIEWPORT = gen6_SF_VIEWPORT(&p->cp->builder,
+ ilo->viewport.cso, ilo->viewport.count);
- p->state.CC_VIEWPORT = gen6_emit_CC_VIEWPORT(p->dev,
- ilo->viewport.cso, ilo->viewport.count, p->cp);
+ p->state.CC_VIEWPORT = gen6_CC_VIEWPORT(&p->cp->builder,
+ ilo->viewport.cso, ilo->viewport.count);
session->viewport_state_changed = true;
}
{
/* BLEND_STATE */
if (DIRTY(BLEND) || DIRTY(FB) || DIRTY(DSA)) {
- p->state.BLEND_STATE = gen6_emit_BLEND_STATE(p->dev,
- ilo->blend, &ilo->fb, ilo->dsa, p->cp);
+ p->state.BLEND_STATE = gen6_BLEND_STATE(&p->cp->builder,
+ ilo->blend, &ilo->fb, ilo->dsa);
session->cc_state_blend_changed = true;
}
/* COLOR_CALC_STATE */
if (DIRTY(DSA) || DIRTY(STENCIL_REF) || DIRTY(BLEND_COLOR)) {
p->state.COLOR_CALC_STATE =
- gen6_emit_COLOR_CALC_STATE(p->dev, &ilo->stencil_ref,
- ilo->dsa->alpha_ref, &ilo->blend_color, p->cp);
+ gen6_COLOR_CALC_STATE(&p->cp->builder, &ilo->stencil_ref,
+ ilo->dsa->alpha_ref, &ilo->blend_color);
session->cc_state_cc_changed = true;
}
/* DEPTH_STENCIL_STATE */
if (DIRTY(DSA)) {
p->state.DEPTH_STENCIL_STATE =
- gen6_emit_DEPTH_STENCIL_STATE(p->dev, ilo->dsa, p->cp);
+ gen6_DEPTH_STENCIL_STATE(&p->cp->builder, ilo->dsa);
session->cc_state_dsa_changed = true;
}
/* SCISSOR_RECT */
if (DIRTY(SCISSOR) || DIRTY(VIEWPORT)) {
/* there should be as many scissors as there are viewports */
- p->state.SCISSOR_RECT = gen6_emit_SCISSOR_RECT(p->dev,
- &ilo->scissor, ilo->viewport.count, p->cp);
+ p->state.SCISSOR_RECT = gen6_SCISSOR_RECT(&p->cp->builder,
+ &ilo->scissor, ilo->viewport.count);
session->scissor_state_changed = true;
}
for (i = 0; i < num_samplers; i++) {
border_color_state[i] = (samplers[i]) ?
- gen6_emit_SAMPLER_BORDER_COLOR_STATE(p->dev,
- samplers[i], p->cp) : 0;
+ gen6_SAMPLER_BORDER_COLOR_STATE(&p->cp->builder, samplers[i]) : 0;
}
}
/* should we take the minimum of num_samplers and num_views? */
- *sampler_state = gen6_emit_SAMPLER_STATE(p->dev,
+ *sampler_state = gen6_SAMPLER_STATE(&p->cp->builder,
samplers, views,
border_color_state,
- MIN2(num_samplers, num_views), p->cp);
+ MIN2(num_samplers, num_views));
}
static void
void *pcb;
p->state.vs.PUSH_CONSTANT_BUFFER =
- gen6_emit_push_constant_buffer(p->dev, total_size, &pcb, p->cp);
+ gen6_push_constant_buffer(&p->cp->builder, total_size, &pcb);
p->state.vs.PUSH_CONSTANT_BUFFER_size = total_size;
if (cbuf0_size) {
void *pcb;
p->state.wm.PUSH_CONSTANT_BUFFER =
- gen6_emit_push_constant_buffer(p->dev, cbuf0_size, &pcb, p->cp);
+ gen6_push_constant_buffer(&p->cp->builder, cbuf0_size, &pcb);
p->state.wm.PUSH_CONSTANT_BUFFER_size = cbuf0_size;
if (cbuf0_size <= cbuf->cso[0].user_buffer_size) {
{
if (blitter->uses & ILO_BLITTER_USE_DSA) {
session->DEPTH_STENCIL_STATE =
- gen6_emit_DEPTH_STENCIL_STATE(p->dev, &blitter->dsa, p->cp);
+ gen6_DEPTH_STENCIL_STATE(&p->cp->builder, &blitter->dsa);
}
if (blitter->uses & ILO_BLITTER_USE_CC) {
session->COLOR_CALC_STATE =
- gen6_emit_COLOR_CALC_STATE(p->dev, &blitter->cc.stencil_ref,
- blitter->cc.alpha_ref, &blitter->cc.blend_color, p->cp);
+ gen6_COLOR_CALC_STATE(&p->cp->builder, &blitter->cc.stencil_ref,
+ blitter->cc.alpha_ref, &blitter->cc.blend_color);
}
if (blitter->uses & ILO_BLITTER_USE_VIEWPORT) {
session->CC_VIEWPORT =
- gen6_emit_CC_VIEWPORT(p->dev, &blitter->viewport, 1, p->cp);
+ gen6_CC_VIEWPORT(&p->cp->builder, &blitter->viewport, 1);
}
}
ILO_GPE_VALID_GEN(dev, 6, 6);
assert(buf % 32 == 0);
- /* gen6_emit_push_constant_buffer() allocates buffers in 256-bit units */
+ /* gen6_push_constant_buffer() allocates buffers in 256-bit units */
size = align(size, 32);
ilo_cp_begin(cp, cmd_len);
}
static inline uint32_t
-gen6_emit_INTERFACE_DESCRIPTOR_DATA(const struct ilo_dev_info *dev,
- const struct ilo_shader_state **cs,
- uint32_t *sampler_state,
- int *num_samplers,
- uint32_t *binding_table_state,
- int *num_surfaces,
- int num_ids,
- struct ilo_cp *cp)
+gen6_INTERFACE_DESCRIPTOR_DATA(struct ilo_builder *builder,
+ const struct ilo_shader_state **cs,
+ uint32_t *sampler_state,
+ int *num_samplers,
+ uint32_t *binding_table_state,
+ int *num_surfaces,
+ int num_ids)
{
/*
* From the Sandy Bridge PRM, volume 2 part 2, page 34:
* "(Interface Descriptor Data Start Address) Specifies the 32-byte
* aligned address of the Interface Descriptor data."
*/
- const int state_align = 32 / 4;
+ const int state_align = 32;
const int state_len = (32 / 4) * num_ids;
uint32_t state_offset, *dw;
int i;
- ILO_GPE_VALID_GEN(dev, 6, 6);
+ ILO_GPE_VALID_GEN(builder->dev, 6, 6);
- dw = ilo_cp_steal_ptr(cp, ILO_BUILDER_ITEM_BLOB,
- state_len, state_align, &state_offset);
+ state_offset = ilo_builder_state_pointer(builder,
+ ILO_BUILDER_ITEM_BLOB, state_align, state_len, &dw);
for (i = 0; i < num_ids; i++) {
dw[0] = ilo_shader_get_kernel_offset(cs[i]);
}
static inline uint32_t
-gen6_emit_SF_VIEWPORT(const struct ilo_dev_info *dev,
- const struct ilo_viewport_cso *viewports,
- unsigned num_viewports,
- struct ilo_cp *cp)
+gen6_SF_VIEWPORT(struct ilo_builder *builder,
+ const struct ilo_viewport_cso *viewports,
+ unsigned num_viewports)
{
- const int state_align = 32 / 4;
+ const int state_align = 32;
const int state_len = 8 * num_viewports;
uint32_t state_offset, *dw;
unsigned i;
- ILO_GPE_VALID_GEN(dev, 6, 6);
+ ILO_GPE_VALID_GEN(builder->dev, 6, 6);
/*
* From the Sandy Bridge PRM, volume 2 part 1, page 262:
*/
assert(num_viewports && num_viewports <= 16);
- dw = ilo_cp_steal_ptr(cp, ILO_BUILDER_ITEM_SF_VIEWPORT,
- state_len, state_align, &state_offset);
+ state_offset = ilo_builder_state_pointer(builder,
+ ILO_BUILDER_ITEM_SF_VIEWPORT, state_align, state_len, &dw);
for (i = 0; i < num_viewports; i++) {
const struct ilo_viewport_cso *vp = &viewports[i];
}
static inline uint32_t
-gen6_emit_CLIP_VIEWPORT(const struct ilo_dev_info *dev,
- const struct ilo_viewport_cso *viewports,
- unsigned num_viewports,
- struct ilo_cp *cp)
+gen6_CLIP_VIEWPORT(struct ilo_builder *builder,
+ const struct ilo_viewport_cso *viewports,
+ unsigned num_viewports)
{
- const int state_align = 32 / 4;
+ const int state_align = 32;
const int state_len = 4 * num_viewports;
uint32_t state_offset, *dw;
unsigned i;
- ILO_GPE_VALID_GEN(dev, 6, 6);
+ ILO_GPE_VALID_GEN(builder->dev, 6, 6);
/*
* From the Sandy Bridge PRM, volume 2 part 1, page 193:
*/
assert(num_viewports && num_viewports <= 16);
- dw = ilo_cp_steal_ptr(cp, ILO_BUILDER_ITEM_CLIP_VIEWPORT,
- state_len, state_align, &state_offset);
+ state_offset = ilo_builder_state_pointer(builder,
+ ILO_BUILDER_ITEM_CLIP_VIEWPORT, state_align, state_len, &dw);
for (i = 0; i < num_viewports; i++) {
const struct ilo_viewport_cso *vp = &viewports[i];
}
static inline uint32_t
-gen6_emit_CC_VIEWPORT(const struct ilo_dev_info *dev,
- const struct ilo_viewport_cso *viewports,
- unsigned num_viewports,
- struct ilo_cp *cp)
+gen6_CC_VIEWPORT(struct ilo_builder *builder,
+ const struct ilo_viewport_cso *viewports,
+ unsigned num_viewports)
{
- const int state_align = 32 / 4;
+ const int state_align = 32;
const int state_len = 2 * num_viewports;
uint32_t state_offset, *dw;
unsigned i;
- ILO_GPE_VALID_GEN(dev, 6, 7.5);
+ ILO_GPE_VALID_GEN(builder->dev, 6, 7.5);
/*
* From the Sandy Bridge PRM, volume 2 part 1, page 385:
*/
assert(num_viewports && num_viewports <= 16);
- dw = ilo_cp_steal_ptr(cp, ILO_BUILDER_ITEM_CC_VIEWPORT,
- state_len, state_align, &state_offset);
+ state_offset = ilo_builder_state_pointer(builder,
+ ILO_BUILDER_ITEM_CC_VIEWPORT, state_align, state_len, &dw);
for (i = 0; i < num_viewports; i++) {
const struct ilo_viewport_cso *vp = &viewports[i];
}
static inline uint32_t
-gen6_emit_COLOR_CALC_STATE(const struct ilo_dev_info *dev,
- const struct pipe_stencil_ref *stencil_ref,
- ubyte alpha_ref,
- const struct pipe_blend_color *blend_color,
- struct ilo_cp *cp)
+gen6_COLOR_CALC_STATE(struct ilo_builder *builder,
+ const struct pipe_stencil_ref *stencil_ref,
+ ubyte alpha_ref,
+ const struct pipe_blend_color *blend_color)
{
- const int state_align = 64 / 4;
+ const int state_align = 64;
const int state_len = 6;
uint32_t state_offset, *dw;
- ILO_GPE_VALID_GEN(dev, 6, 7.5);
+ ILO_GPE_VALID_GEN(builder->dev, 6, 7.5);
- dw = ilo_cp_steal_ptr(cp, ILO_BUILDER_ITEM_COLOR_CALC,
- state_len, state_align, &state_offset);
+ state_offset = ilo_builder_state_pointer(builder,
+ ILO_BUILDER_ITEM_COLOR_CALC, state_align, state_len, &dw);
dw[0] = stencil_ref->ref_value[0] << 24 |
stencil_ref->ref_value[1] << 16 |
}
static inline uint32_t
-gen6_emit_BLEND_STATE(const struct ilo_dev_info *dev,
- const struct ilo_blend_state *blend,
- const struct ilo_fb_state *fb,
- const struct ilo_dsa_state *dsa,
- struct ilo_cp *cp)
+gen6_BLEND_STATE(struct ilo_builder *builder,
+ const struct ilo_blend_state *blend,
+ const struct ilo_fb_state *fb,
+ const struct ilo_dsa_state *dsa)
{
- const int state_align = 64 / 4;
+ const int state_align = 64;
int state_len;
uint32_t state_offset, *dw;
unsigned num_targets, i;
- ILO_GPE_VALID_GEN(dev, 6, 7.5);
+ ILO_GPE_VALID_GEN(builder->dev, 6, 7.5);
/*
* From the Sandy Bridge PRM, volume 2 part 1, page 376:
state_len = 2 * num_targets;
- dw = ilo_cp_steal_ptr(cp, ILO_BUILDER_ITEM_BLEND,
- state_len, state_align, &state_offset);
+ state_offset = ilo_builder_state_pointer(builder,
+ ILO_BUILDER_ITEM_BLEND, state_align, state_len, &dw);
for (i = 0; i < num_targets; i++) {
const unsigned idx = (blend->independent_blend_enable) ? i : 0;
switch (format_desc->format) {
case PIPE_FORMAT_B8G8R8X8_UNORM:
/* force alpha to one when the HW format has alpha */
- assert(ilo_translate_render_format(dev, PIPE_FORMAT_B8G8R8X8_UNORM)
- == GEN6_FORMAT_B8G8R8A8_UNORM);
+ assert(ilo_translate_render_format(builder->dev,
+ PIPE_FORMAT_B8G8R8X8_UNORM) ==
+ GEN6_FORMAT_B8G8R8A8_UNORM);
rt_dst_alpha_forced_one = true;
break;
default:
}
static inline uint32_t
-gen6_emit_DEPTH_STENCIL_STATE(const struct ilo_dev_info *dev,
- const struct ilo_dsa_state *dsa,
- struct ilo_cp *cp)
+gen6_DEPTH_STENCIL_STATE(struct ilo_builder *builder,
+ const struct ilo_dsa_state *dsa)
{
- const int state_align = 64 / 4;
+ const int state_align = 64;
const int state_len = 3;
- uint32_t state_offset, *dw;
-
-
- ILO_GPE_VALID_GEN(dev, 6, 7.5);
- dw = ilo_cp_steal_ptr(cp, ILO_BUILDER_ITEM_DEPTH_STENCIL,
- state_len, state_align, &state_offset);
+ ILO_GPE_VALID_GEN(builder->dev, 6, 7.5);
- dw[0] = dsa->payload[0];
- dw[1] = dsa->payload[1];
- dw[2] = dsa->payload[2];
+ STATIC_ASSERT(Elements(dsa->payload) >= state_len);
- return state_offset;
+ return ilo_builder_state_write(builder, ILO_BUILDER_ITEM_DEPTH_STENCIL,
+ state_align, state_len, dsa->payload);
}
static inline uint32_t
-gen6_emit_SCISSOR_RECT(const struct ilo_dev_info *dev,
- const struct ilo_scissor_state *scissor,
- unsigned num_viewports,
- struct ilo_cp *cp)
+gen6_SCISSOR_RECT(struct ilo_builder *builder,
+ const struct ilo_scissor_state *scissor,
+ unsigned num_viewports)
{
- const int state_align = 32 / 4;
+ const int state_align = 32;
const int state_len = 2 * num_viewports;
- uint32_t state_offset, *dw;
- ILO_GPE_VALID_GEN(dev, 6, 7.5);
+ ILO_GPE_VALID_GEN(builder->dev, 6, 7.5);
/*
* From the Sandy Bridge PRM, volume 2 part 1, page 263:
* stored as an array of up to 16 elements..."
*/
assert(num_viewports && num_viewports <= 16);
+ assert(Elements(scissor->payload) >= state_len);
- dw = ilo_cp_steal_ptr(cp, ILO_BUILDER_ITEM_SCISSOR_RECT,
- state_len, state_align, &state_offset);
-
- memcpy(dw, scissor->payload, state_len * 4);
-
- return state_offset;
+ return ilo_builder_state_write(builder, ILO_BUILDER_ITEM_SCISSOR_RECT,
+ state_align, state_len, scissor->payload);
}
static inline uint32_t
}
static inline 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 *views,
- const uint32_t *sampler_border_colors,
- int num_samplers,
- struct ilo_cp *cp)
-{
- const int state_align = 32 / 4;
+gen6_SAMPLER_STATE(struct ilo_builder *builder,
+ const struct ilo_sampler_cso * const *samplers,
+ const struct pipe_sampler_view * const *views,
+ const uint32_t *sampler_border_colors,
+ int num_samplers)
+{
+ const int state_align = 32;
const int state_len = 4 * num_samplers;
uint32_t state_offset, *dw;
int i;
- ILO_GPE_VALID_GEN(dev, 6, 7.5);
+ ILO_GPE_VALID_GEN(builder->dev, 6, 7.5);
/*
* From the Sandy Bridge PRM, volume 4 part 1, page 101:
if (!num_samplers)
return 0;
- dw = ilo_cp_steal_ptr(cp, ILO_BUILDER_ITEM_SAMPLER,
- state_len, state_align, &state_offset);
+ state_offset = ilo_builder_state_pointer(builder,
+ ILO_BUILDER_ITEM_SAMPLER, state_align, state_len, &dw);
for (i = 0; i < num_samplers; i++) {
const struct ilo_sampler_cso *sampler = samplers[i];
dw[0] |= dw_filter;
- if (dev->gen >= ILO_GEN(7)) {
+ if (builder->dev->gen >= ILO_GEN(7)) {
dw[3] |= dw_wrap;
}
else {
}
static inline uint32_t
-gen6_emit_SAMPLER_BORDER_COLOR_STATE(const struct ilo_dev_info *dev,
- const struct ilo_sampler_cso *sampler,
- struct ilo_cp *cp)
+gen6_SAMPLER_BORDER_COLOR_STATE(struct ilo_builder *builder,
+ const struct ilo_sampler_cso *sampler)
{
- const int state_align = 32 / 4;
- const int state_len = (dev->gen >= ILO_GEN(7)) ? 4 : 12;
- uint32_t state_offset, *dw;
+ const int state_align = 32;
+ const int state_len = (builder->dev->gen >= ILO_GEN(7)) ? 4 : 12;
- ILO_GPE_VALID_GEN(dev, 6, 7.5);
+ ILO_GPE_VALID_GEN(builder->dev, 6, 7.5);
- dw = ilo_cp_steal_ptr(cp, ILO_BUILDER_ITEM_BLOB,
- state_len, state_align, &state_offset);
+ assert(Elements(sampler->payload) >= 3 + state_len);
/* see ilo_gpe_init_sampler_cso() */
- memcpy(dw, &sampler->payload[3], state_len * 4);
-
- return state_offset;
+ return ilo_builder_state_write(builder, ILO_BUILDER_ITEM_BLOB,
+ state_align, state_len, &sampler->payload[3]);
}
static inline uint32_t
-gen6_emit_push_constant_buffer(const struct ilo_dev_info *dev,
- int size, void **pcb,
- struct ilo_cp *cp)
+gen6_push_constant_buffer(struct ilo_builder *builder,
+ int size, void **pcb)
{
/*
* For all VS, GS, FS, and CS push constant buffers, they must be aligned
* to 32 bytes, and their sizes are specified in 256-bit units.
*/
- const int state_align = 32 / 4;
+ const int state_align = 32;
const int state_len = align(size, 32) / 4;
uint32_t state_offset;
char *buf;
- ILO_GPE_VALID_GEN(dev, 6, 7.5);
+ ILO_GPE_VALID_GEN(builder->dev, 6, 7.5);
- buf = ilo_cp_steal_ptr(cp, ILO_BUILDER_ITEM_BLOB,
- state_len, state_align, &state_offset);
+ state_offset = ilo_builder_state_pointer(builder,
+ ILO_BUILDER_ITEM_BLOB, state_align, state_len, (uint32_t **) &buf);
/* zero out the unused range */
if (size < state_len * 4)