#include "util/u_draw.h"
#include "util/u_pack_color.h"
-#include "ilo_3d.h"
-#include "ilo_3d_pipeline.h"
-#include "ilo_builder_3d_top.h" /* for ve_init_cso_with_components() */
-#include "ilo_gpe_gen6.h" /* for zs_align_surface() */
+#include "ilo_draw.h"
+#include "ilo_state.h"
#include "ilo_blit.h"
-#include "ilo_gpe.h"
#include "ilo_blitter.h"
/**
static bool
ilo_blitter_set_invariants(struct ilo_blitter *blitter)
{
- struct pipe_screen *screen = blitter->ilo->base.screen;
- struct pipe_resource templ;
- struct pipe_vertex_element velems[2];
- struct pipe_viewport_state vp;
+ struct ilo_state_vf_element_info elem;
if (blitter->initialized)
return true;
- blitter->buffer.size = 4096;
-
- /* allocate the vertex buffer */
- memset(&templ, 0, sizeof(templ));
- templ.target = PIPE_BUFFER;
- templ.width0 = blitter->buffer.size;
- templ.usage = PIPE_USAGE_STREAM;
- templ.bind = PIPE_BIND_VERTEX_BUFFER;
- blitter->buffer.res = screen->resource_create(screen, &templ);
- if (!blitter->buffer.res)
- return false;
-
- /* do not increase reference count */
- blitter->vb.states[0].buffer = blitter->buffer.res;
+ /* a rectangle has 3 vertices in a RECTLIST */
+ blitter->draw_info.topology = GEN6_3DPRIM_RECTLIST;
+ blitter->draw_info.vertex_count = 3;
+ blitter->draw_info.instance_count = 1;
+ memset(&elem, 0, sizeof(elem));
/* only vertex X and Y */
- blitter->vb.states[0].stride = 2 * sizeof(float);
- blitter->vb.enabled_mask = 0x1;
- memset(&velems, 0, sizeof(velems));
- velems[1].src_format = PIPE_FORMAT_R32G32_FLOAT;
- ilo_gpe_init_ve(blitter->ilo->dev, 2, velems, &blitter->ve);
-
- /* override first VE to be VUE header */
- ve_init_cso_with_components(blitter->ilo->dev,
- GEN6_VFCOMP_STORE_0, /* Reserved */
- GEN6_VFCOMP_STORE_0, /* Render Target Array Index */
- GEN6_VFCOMP_STORE_0, /* Viewport Index */
- GEN6_VFCOMP_STORE_0, /* Point Width */
- &blitter->ve.cso[0]);
+ elem.format = GEN6_FORMAT_R32G32_FLOAT;
+ elem.format_size = 8;
+ elem.component_count = 2;
- /* a rectangle has 3 vertices in a RECTLIST */
- util_draw_init_info(&blitter->draw);
- blitter->draw.mode = ILO_PRIM_RECTANGLES;
- blitter->draw.count = 3;
+ ilo_state_vf_init_for_rectlist(&blitter->vf, blitter->ilo->dev,
+ blitter->vf_data, sizeof(blitter->vf_data), &elem, 1);
+
+ ilo_state_vs_init_disabled(&blitter->vs, blitter->ilo->dev);
+ ilo_state_hs_init_disabled(&blitter->hs, blitter->ilo->dev);
+ ilo_state_ds_init_disabled(&blitter->ds, blitter->ilo->dev);
+ ilo_state_gs_init_disabled(&blitter->gs, blitter->ilo->dev);
+ ilo_state_sol_init_disabled(&blitter->sol, blitter->ilo->dev, false);
/**
* From the Haswell PRM, volume 7, page 615:
*
* "The clear value must be between the min and max depth values
- * (inclusive) defined in the CC_VIEWPORT."
+ * (inclusive) defined in the CC_VIEWPORT."
*
* Even though clipping and viewport transformation will be disabled, we
* still need to set up the viewport states.
*/
- memset(&vp, 0, sizeof(vp));
- vp.scale[0] = 1.0f;
- vp.scale[1] = 1.0f;
- vp.scale[2] = 1.0f;
- vp.scale[3] = 1.0f;
- ilo_gpe_set_viewport_cso(blitter->ilo->dev, &vp, &blitter->viewport);
+ ilo_state_viewport_init_for_rectlist(&blitter->vp, blitter->ilo->dev,
+ blitter->vp_data, sizeof(blitter->vp_data));
+
+ ilo_state_sbe_init_for_rectlist(&blitter->sbe, blitter->ilo->dev, 0, 0);
+ ilo_state_ps_init_disabled(&blitter->ps, blitter->ilo->dev);
+
+ ilo_state_urb_init_for_rectlist(&blitter->urb, blitter->ilo->dev,
+ ilo_state_vf_get_attr_count(&blitter->vf));
blitter->initialized = true;
}
static void
-ilo_blitter_set_op(struct ilo_blitter *blitter,
- enum ilo_blitter_rectlist_op op)
+ilo_blitter_set_earlyz_op(struct ilo_blitter *blitter,
+ enum ilo_state_raster_earlyz_op op,
+ bool earlyz_stencil_clear)
{
- blitter->op = op;
+ blitter->earlyz_op = op;
+ blitter->earlyz_stencil_clear = earlyz_stencil_clear;
}
/**
unsigned x, unsigned y,
unsigned width, unsigned height)
{
- unsigned usage = PIPE_TRANSFER_WRITE | PIPE_TRANSFER_UNSYNCHRONIZED;
- float vertices[3][2];
- struct pipe_box box;
-
/*
* From the Sandy Bridge PRM, volume 2 part 1, page 11:
*
* by the definition of a rectangle. V0=LowerRight, V1=LowerLeft,
* V2=UpperLeft. Implied V3 = V0- V1+V2."
*/
- vertices[0][0] = (float) (x + width);
- vertices[0][1] = (float) (y + height);
- vertices[1][0] = (float) x;
- vertices[1][1] = (float) (y + height);
- vertices[2][0] = (float) x;
- vertices[2][1] = (float) y;
-
- /* buffer is full */
- if (blitter->buffer.offset + sizeof(vertices) > blitter->buffer.size) {
- if (!ilo_buffer_rename_bo(ilo_buffer(blitter->buffer.res)))
- usage &= ~PIPE_TRANSFER_UNSYNCHRONIZED;
-
- blitter->buffer.offset = 0;
- }
-
- u_box_1d(blitter->buffer.offset, sizeof(vertices), &box);
-
- blitter->ilo->base.transfer_inline_write(&blitter->ilo->base,
- blitter->buffer.res, 0, usage, &box, vertices, 0, 0);
-
- blitter->vb.states[0].buffer_offset = blitter->buffer.offset;
- blitter->buffer.offset += sizeof(vertices);
+ blitter->vertices[0][0] = (float) (x + width);
+ blitter->vertices[0][1] = (float) (y + height);
+ blitter->vertices[1][0] = (float) x;
+ blitter->vertices[1][1] = (float) (y + height);
+ blitter->vertices[2][0] = (float) x;
+ blitter->vertices[2][1] = (float) y;
}
static void
-ilo_blitter_set_clear_values(struct ilo_blitter *blitter,
- uint32_t depth, ubyte stencil)
+ilo_blitter_set_depth_clear_value(struct ilo_blitter *blitter,
+ uint32_t depth)
{
blitter->depth_clear_value = depth;
- blitter->cc.stencil_ref.ref_value[0] = stencil;
}
static void
-ilo_blitter_set_dsa(struct ilo_blitter *blitter,
- const struct pipe_depth_stencil_alpha_state *state)
+ilo_blitter_set_cc(struct ilo_blitter *blitter,
+ const struct ilo_state_cc_info *info)
+{
+ memset(&blitter->cc, 0, sizeof(blitter->cc));
+ ilo_state_cc_init(&blitter->cc, blitter->ilo->dev, info);
+}
+
+static void
+ilo_blitter_set_fb_rs(struct ilo_blitter *blitter)
{
- ilo_gpe_init_dsa(blitter->ilo->dev, state, &blitter->dsa);
+ memset(&blitter->fb.rs, 0, sizeof(blitter->fb.rs));
+ ilo_state_raster_init_for_rectlist(&blitter->fb.rs, blitter->ilo->dev,
+ blitter->fb.num_samples, blitter->earlyz_op,
+ blitter->earlyz_stencil_clear);
}
static void
{
struct ilo_texture *tex = ilo_texture(res);
- blitter->fb.width = u_minify(tex->layout.width0, level);
- blitter->fb.height = u_minify(tex->layout.height0, level);
+ blitter->fb.width = u_minify(tex->image.width0, level);
+ blitter->fb.height = u_minify(tex->image.height0, level);
blitter->fb.num_samples = res->nr_samples;
if (!blitter->fb.num_samples)
blitter->fb.num_samples = 1;
memcpy(&blitter->fb.dst, cso, sizeof(*cso));
+
+ ilo_blitter_set_fb_rs(blitter);
}
static void
{
unsigned align_w, align_h;
- switch (blitter->op) {
- case ILO_BLITTER_RECTLIST_CLEAR_ZS:
- case ILO_BLITTER_RECTLIST_RESOLVE_Z:
+ switch (blitter->earlyz_op) {
+ case ILO_STATE_RASTER_EARLYZ_DEPTH_CLEAR:
+ case ILO_STATE_RASTER_EARLYZ_DEPTH_RESOLVE:
break;
default:
return;
if (blitter->fb.width % align_w || blitter->fb.height % align_h) {
blitter->fb.width = align(blitter->fb.width, align_w);
blitter->fb.height = align(blitter->fb.height, align_h);
-
- assert(!blitter->fb.dst.is_rt);
- zs_align_surface(blitter->ilo->dev, align_w, align_h,
- &blitter->fb.dst.u.zs);
}
}
static void
hiz_emit_rectlist(struct ilo_blitter *blitter)
{
- struct ilo_3d *hw3d = blitter->ilo->hw3d;
- struct ilo_3d_pipeline *p = hw3d->pipeline;
-
hiz_align_fb(blitter);
ilo_blitter_set_rectlist(blitter, 0, 0,
blitter->fb.width, blitter->fb.height);
- ilo_3d_own_render_ring(hw3d);
-
- /*
- * From the Sandy Bridge PRM, volume 2 part 1, page 313:
- *
- * "If other rendering operations have preceded this clear, a
- * PIPE_CONTROL with write cache flush enabled and Z-inhibit
- * disabled must be issued before the rectangle primitive used for
- * the depth buffer clear operation."
- *
- * From the Sandy Bridge PRM, volume 2 part 1, page 314:
- *
- * "Depth buffer clear pass must be followed by a PIPE_CONTROL
- * command with DEPTH_STALL bit set and Then followed by Depth
- * FLUSH"
- *
- * But the pipeline has to be flushed both before and after not only
- * because of these workarounds. We need them for reasons such as
- *
- * - we may sample from a texture that was rendered to
- * - we may sample from the fb shortly after
- */
- if (!ilo_cp_empty(p->cp))
- ilo_3d_pipeline_emit_flush(p);
-
- ilo_3d_pipeline_emit_rectlist(p, blitter);
-
- ilo_3d_pipeline_emit_flush(p);
+ ilo_draw_rectlist(blitter->ilo);
}
static bool
* The truth is when HiZ is enabled, separate stencil is also enabled on
* all GENs. The depth buffer format cannot be combined depth/stencil.
*/
- switch (tex->layout.format) {
+ switch (tex->image_format) {
case PIPE_FORMAT_Z16_UNORM:
if (ilo_dev_gen(blitter->ilo->dev) == ILO_GEN(6) &&
tex->base.width0 % 16)
double depth, unsigned stencil)
{
struct ilo_texture *tex = ilo_texture(zs->texture);
- struct pipe_depth_stencil_alpha_state dsa_state;
+ struct ilo_state_cc_info info;
uint32_t uses, clear_value;
- if (!ilo_texture_can_enable_hiz(tex,
- zs->u.tex.level, zs->u.tex.first_layer,
- zs->u.tex.last_layer - zs->u.tex.first_layer + 1))
+ if (!ilo_image_can_enable_aux(&tex->image, zs->u.tex.level))
return false;
if (!hiz_can_clear_zs(blitter, tex))
return false;
- clear_value = util_pack_z(tex->layout.format, depth);
+ if (ilo_dev_gen(blitter->ilo->dev) >= ILO_GEN(8))
+ clear_value = fui(depth);
+ else
+ clear_value = util_pack_z(tex->image_format, depth);
ilo_blit_resolve_surface(blitter->ilo, zs,
ILO_TEXTURE_RENDER_WRITE | ILO_TEXTURE_CLEAR);
* - [DevSNB] errata: For stencil buffer only clear, the previous
* depth clear value must be delivered during the clear."
*/
- memset(&dsa_state, 0, sizeof(dsa_state));
+ memset(&info, 0, sizeof(info));
- if (clear_flags & PIPE_CLEAR_DEPTH)
- dsa_state.depth.writemask = true;
+ if (clear_flags & PIPE_CLEAR_DEPTH) {
+ info.depth.cv_has_buffer = true;
+ info.depth.write_enable = true;
+ }
if (clear_flags & PIPE_CLEAR_STENCIL) {
- dsa_state.stencil[0].enabled = true;
- dsa_state.stencil[0].func = PIPE_FUNC_ALWAYS;
- dsa_state.stencil[0].fail_op = PIPE_STENCIL_OP_KEEP;
- dsa_state.stencil[0].zpass_op = PIPE_STENCIL_OP_REPLACE;
- dsa_state.stencil[0].zfail_op = PIPE_STENCIL_OP_KEEP;
+ info.stencil.cv_has_buffer = true;
+ info.stencil.test_enable = true;
+ info.stencil.front.test_func = GEN6_COMPAREFUNCTION_ALWAYS;
+ info.stencil.front.fail_op = GEN6_STENCILOP_KEEP;
+ info.stencil.front.zfail_op = GEN6_STENCILOP_KEEP;
+ info.stencil.front.zpass_op = GEN6_STENCILOP_REPLACE;
/*
* From the Ivy Bridge PRM, volume 2 part 1, page 277:
* - DEPTH_STENCIL_STATE::Stencil Test Mask must be 0xFF
* - DEPTH_STENCIL_STATE::Back Face Stencil Write Mask must be 0xFF
* - DEPTH_STENCIL_STATE::Back Face Stencil Test Mask must be 0xFF"
+ *
+ * Back frace masks will be copied from front face masks.
*/
- dsa_state.stencil[0].valuemask = 0xff;
- dsa_state.stencil[0].writemask = 0xff;
- dsa_state.stencil[1].valuemask = 0xff;
- dsa_state.stencil[1].writemask = 0xff;
+ info.params.stencil_front.test_ref = (uint8_t) stencil;
+ info.params.stencil_front.test_mask = 0xff;
+ info.params.stencil_front.write_mask = 0xff;
}
ilo_blitter_set_invariants(blitter);
- ilo_blitter_set_op(blitter, ILO_BLITTER_RECTLIST_CLEAR_ZS);
+ ilo_blitter_set_earlyz_op(blitter,
+ ILO_STATE_RASTER_EARLYZ_DEPTH_CLEAR,
+ clear_flags & PIPE_CLEAR_STENCIL);
- ilo_blitter_set_dsa(blitter, &dsa_state);
- ilo_blitter_set_clear_values(blitter, clear_value, (ubyte) stencil);
+ ilo_blitter_set_cc(blitter, &info);
+ ilo_blitter_set_depth_clear_value(blitter, clear_value);
ilo_blitter_set_fb_from_surface(blitter, zs);
uses = ILO_BLITTER_USE_DSA;
unsigned level, unsigned slice)
{
struct ilo_texture *tex = ilo_texture(res);
- struct pipe_depth_stencil_alpha_state dsa_state;
+ struct ilo_state_cc_info info;
const struct ilo_texture_slice *s =
ilo_texture_get_slice(tex, level, slice);
- if (!ilo_texture_can_enable_hiz(tex, level, slice, 1))
+ if (!ilo_image_can_enable_aux(&tex->image, level))
return;
/*
* to NEVER. Depth Buffer Write Enable must be enabled. Stencil Test
* Enable and Stencil Buffer Write Enable must be disabled."
*/
- memset(&dsa_state, 0, sizeof(dsa_state));
- dsa_state.depth.writemask = true;
- dsa_state.depth.enabled = true;
- dsa_state.depth.func = PIPE_FUNC_NEVER;
+ memset(&info, 0, sizeof(info));
+ info.depth.cv_has_buffer = true;
+ info.depth.test_enable = true;
+ info.depth.write_enable = true;
+ info.depth.test_func = GEN6_COMPAREFUNCTION_NEVER;
ilo_blitter_set_invariants(blitter);
- ilo_blitter_set_op(blitter, ILO_BLITTER_RECTLIST_RESOLVE_Z);
+ ilo_blitter_set_earlyz_op(blitter,
+ ILO_STATE_RASTER_EARLYZ_DEPTH_RESOLVE, false);
- ilo_blitter_set_dsa(blitter, &dsa_state);
- ilo_blitter_set_clear_values(blitter, s->clear_value, 0);
+ ilo_blitter_set_cc(blitter, &info);
+ ilo_blitter_set_depth_clear_value(blitter, s->clear_value);
ilo_blitter_set_fb_from_resource(blitter, res, res->format, level, slice);
ilo_blitter_set_uses(blitter,
ILO_BLITTER_USE_DSA | ILO_BLITTER_USE_FB_DEPTH);
unsigned level, unsigned slice)
{
struct ilo_texture *tex = ilo_texture(res);
- struct pipe_depth_stencil_alpha_state dsa_state;
+ struct ilo_state_cc_info info;
- if (!ilo_texture_can_enable_hiz(tex, level, slice, 1))
+ if (!ilo_image_can_enable_aux(&tex->image, level))
return;
/*
* disabled. Depth Buffer Write Enable must be enabled. Stencil Test
* Enable and Stencil Buffer Write Enable must be disabled."
*/
- memset(&dsa_state, 0, sizeof(dsa_state));
- dsa_state.depth.writemask = true;
+ memset(&info, 0, sizeof(info));
+ info.depth.cv_has_buffer = true;
+ info.depth.write_enable = true;
ilo_blitter_set_invariants(blitter);
- ilo_blitter_set_op(blitter, ILO_BLITTER_RECTLIST_RESOLVE_HIZ);
+ ilo_blitter_set_earlyz_op(blitter,
+ ILO_STATE_RASTER_EARLYZ_HIZ_RESOLVE, false);
- ilo_blitter_set_dsa(blitter, &dsa_state);
+ ilo_blitter_set_cc(blitter, &info);
ilo_blitter_set_fb_from_resource(blitter, res, res->format, level, slice);
ilo_blitter_set_uses(blitter,
ILO_BLITTER_USE_DSA | ILO_BLITTER_USE_FB_DEPTH);