summaryrefslogtreecommitdiff
path: root/lib/rendercopy_gen9.c
diff options
context:
space:
mode:
authorZbigniew Kempczyński <zbigniew.kempczynski@intel.com>2020-09-11 10:07:27 +0200
committerChris Wilson <chris@chris-wilson.co.uk>2020-09-16 14:51:23 +0100
commit87b62ab548692d258c060539f10a14d0035bba18 (patch)
tree36db12b8ed924da198da44bd24c27cbec692c233 /lib/rendercopy_gen9.c
parent70f4572b2b08dc077f34b61020424a66c08aa9cb (diff)
lib/rendercopy: remove libdrm dependency
Use intel_bb as main batch implementation to remove libdrm dependency. Rewrite all pipelines to use intel_bb and update render|vebox_copy function prototypes. Note that this will introduce compile failures into the indiviual users until they are transitioned over to the new interface in the following patches. The process is completed with "lib/rendercopy_bufmgr: remove rendercopy_bufmgr." Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> Cc: Dominik Grzegorzek <dominik.grzegorzek@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/rendercopy_gen9.c')
-rw-r--r--lib/rendercopy_gen9.c1145
1 files changed, 512 insertions, 633 deletions
diff --git a/lib/rendercopy_gen9.c b/lib/rendercopy_gen9.c
index 85ae4cab..6bad7bb6 100644
--- a/lib/rendercopy_gen9.c
+++ b/lib/rendercopy_gen9.c
@@ -16,7 +16,7 @@
#include "drmtest.h"
#include "intel_aux_pgtable.h"
-#include "intel_bufmgr.h"
+#include "intel_bufops.h"
#include "intel_batchbuffer.h"
#include "intel_io.h"
#include "rendercopy.h"
@@ -24,17 +24,12 @@
#include "intel_reg.h"
#include "igt_aux.h"
-#include "intel_aub.h"
-
#define VERTEX_SIZE (3*4)
#if DEBUG_RENDERCPY
-static void dump_batch(struct intel_batchbuffer *batch) {
- int fd = open("/tmp/i965-batchbuffers.dump", O_WRONLY | O_CREAT, 0666);
- if (fd != -1) {
- igt_assert_eq(write(fd, batch->buffer, 4096), 4096);
- fd = close(fd);
- }
+static void dump_batch(struct intel_bb *ibb)
+{
+ intel_bb_dump(ibb, "/tmp/gen9-batchbuffers.dump");
}
#else
#define dump_batch(x) do { } while(0)
@@ -120,87 +115,16 @@ static const uint32_t gen12_render_copy[][4] = {
{ 0x80040131, 0x00000004, 0x50007144, 0x00c40000 },
};
-/* AUB annotation support */
-#define MAX_ANNOTATIONS 33
-struct annotations_context {
- drm_intel_aub_annotation annotations[MAX_ANNOTATIONS];
- int index;
- uint32_t offset;
-} aub_annotations;
-
-static void annotation_init(struct annotations_context *ctx)
-{
- /* ctx->annotations is an array keeping a list of annotations of the
- * batch buffer ordered by offset. ctx->annotations[0] is thus left
- * for the command stream and will be filled just before executing
- * the batch buffer with annotations_add_batch() */
- ctx->index = 1;
-}
-
-static void add_annotation(drm_intel_aub_annotation *a,
- uint32_t type, uint32_t subtype,
- uint32_t ending_offset)
-{
- a->type = type;
- a->subtype = subtype;
- a->ending_offset = ending_offset;
-}
-
-static void annotation_add_batch(struct annotations_context *ctx, size_t size)
-{
- add_annotation(&ctx->annotations[0], AUB_TRACE_TYPE_BATCH, 0, size);
-}
-
-static void annotation_add_state(struct annotations_context *ctx,
- uint32_t state_type,
- uint32_t start_offset,
- size_t size)
-{
- assert(ctx->index < MAX_ANNOTATIONS);
-
- add_annotation(&ctx->annotations[ctx->index++],
- AUB_TRACE_TYPE_NOTYPE, 0,
- start_offset);
- add_annotation(&ctx->annotations[ctx->index++],
- AUB_TRACE_TYPE(state_type),
- AUB_TRACE_SUBTYPE(state_type),
- start_offset + size);
-}
-
-static void annotation_flush(struct annotations_context *ctx,
- struct intel_batchbuffer *batch)
-{
- if (!igt_aub_dump_enabled())
- return;
-
- drm_intel_bufmgr_gem_set_aub_annotations(batch->bo,
- ctx->annotations,
- ctx->index);
-}
-
-static void
-gen6_render_flush(struct intel_batchbuffer *batch,
- drm_intel_context *context, uint32_t batch_end)
-{
- igt_assert_eq(drm_intel_bo_subdata(batch->bo,
- 0, 4096, batch->buffer),
- 0);
- igt_assert_eq(drm_intel_gem_bo_context_exec(batch->bo,
- context, batch_end, 0),
- 0);
-}
-
/* Mostly copy+paste from gen6, except height, width, pitch moved */
static uint32_t
-gen8_bind_buf(struct intel_batchbuffer *batch, const struct igt_buf *buf,
- int is_dst) {
+gen8_bind_buf(struct intel_bb *ibb, const struct intel_buf *buf, int is_dst) {
struct gen9_surface_state *ss;
- uint32_t write_domain, read_domain, offset;
- int ret;
+ uint32_t write_domain, read_domain;
+ uint64_t address;
igt_assert_lte(buf->surface[0].stride, 256*1024);
- igt_assert_lte(igt_buf_width(buf), 16384);
- igt_assert_lte(igt_buf_height(buf), 16384);
+ igt_assert_lte(intel_buf_width(buf), 16384);
+ igt_assert_lte(intel_buf_height(buf), 16384);
if (is_dst) {
write_domain = read_domain = I915_GEM_DOMAIN_RENDER;
@@ -209,10 +133,7 @@ gen8_bind_buf(struct intel_batchbuffer *batch, const struct igt_buf *buf,
read_domain = I915_GEM_DOMAIN_SAMPLER;
}
- ss = intel_batchbuffer_subdata_alloc(batch, sizeof(*ss), 64);
- offset = intel_batchbuffer_subdata_offset(batch, ss);
- annotation_add_state(&aub_annotations, AUB_TRACE_SURFACE_STATE,
- offset, sizeof(*ss));
+ ss = intel_bb_ptr_align(ibb, 64);
ss->ss0.surface_type = SURFACE_2D;
switch (buf->bpp) {
@@ -238,17 +159,15 @@ gen8_bind_buf(struct intel_batchbuffer *batch, const struct igt_buf *buf,
ss->ss5.trmode = 2;
ss->ss5.mip_tail_start_lod = 1; /* needed with trmode */
- ss->ss8.base_addr = buf->bo->offset64;
- ss->ss9.base_addr_hi = buf->bo->offset64 >> 32;
+ address = intel_bb_offset_reloc(ibb, buf->handle,
+ read_domain, write_domain,
+ intel_bb_offset(ibb) + 4 * 8,
+ buf->addr.offset);
+ ss->ss8.base_addr = address;
+ ss->ss9.base_addr_hi = address >> 32;
- ret = drm_intel_bo_emit_reloc(batch->bo,
- intel_batchbuffer_subdata_offset(batch, &ss->ss8),
- buf->bo, 0,
- read_domain, write_domain);
- assert(ret == 0);
-
- ss->ss2.height = igt_buf_height(buf) - 1;
- ss->ss2.width = igt_buf_width(buf) - 1;
+ ss->ss2.height = intel_buf_height(buf) - 1;
+ ss->ss2.width = intel_buf_width(buf) - 1;
ss->ss3.pitch = buf->surface[0].stride - 1;
ss->ss7.skl.shader_chanel_select_r = 4;
@@ -264,60 +183,52 @@ gen8_bind_buf(struct intel_batchbuffer *batch, const struct igt_buf *buf,
ss->ss6.aux_mode = 0x5; /* AUX_CCS_E */
ss->ss6.aux_pitch = (buf->ccs[0].stride / 128) - 1;
- ss->ss10.aux_base_addr = buf->bo->offset64 + buf->ccs[0].offset;
- ss->ss11.aux_base_addr_hi = (buf->bo->offset64 + buf->ccs[0].offset) >> 32;
-
- ret = drm_intel_bo_emit_reloc(batch->bo,
- intel_batchbuffer_subdata_offset(batch, &ss->ss10),
- buf->bo, buf->ccs[0].offset,
- read_domain, write_domain);
- assert(ret == 0);
+ address = intel_bb_offset_reloc_with_delta(ibb, buf->handle,
+ read_domain, write_domain,
+ buf->ccs[0].offset,
+ intel_bb_offset(ibb) + 4 * 10,
+ buf->addr.offset);
+ ss->ss10.aux_base_addr = (address + buf->ccs[0].offset);
+ ss->ss11.aux_base_addr_hi = (address + buf->ccs[0].offset) >> 32;
}
if (buf->cc.offset) {
igt_assert(buf->compression == I915_COMPRESSION_RENDER);
- ss->ss12.clear_address = buf->bo->offset64 + buf->cc.offset;
- ss->ss13.clear_address_hi = (buf->bo->offset64 + buf->cc.offset) >> 32;
-
- ret = drm_intel_bo_emit_reloc(batch->bo,
- intel_batchbuffer_subdata_offset(batch, &ss->ss12),
- buf->bo, buf->cc.offset,
- read_domain, write_domain);
- assert(ret == 0);
+ address = intel_bb_offset_reloc_with_delta(ibb, buf->handle,
+ read_domain, write_domain,
+ buf->cc.offset,
+ intel_bb_offset(ibb) + 4 * 12,
+ buf->addr.offset);
+ ss->ss12.clear_address = address + buf->cc.offset;
+ ss->ss13.clear_address_hi = (address + buf->cc.offset) >> 32;
}
- return offset;
+ return intel_bb_ptr_add_return_prev_offset(ibb, sizeof(*ss));
}
static uint32_t
-gen8_bind_surfaces(struct intel_batchbuffer *batch,
- const struct igt_buf *src,
- const struct igt_buf *dst)
+gen8_bind_surfaces(struct intel_bb *ibb,
+ const struct intel_buf *src,
+ const struct intel_buf *dst)
{
- uint32_t *binding_table, offset;
+ uint32_t *binding_table, binding_table_offset;
- binding_table = intel_batchbuffer_subdata_alloc(batch, 8, 32);
- offset = intel_batchbuffer_subdata_offset(batch, binding_table);
- annotation_add_state(&aub_annotations, AUB_TRACE_BINDING_TABLE,
- offset, 8);
+ binding_table = intel_bb_ptr_align(ibb, 32);
+ binding_table_offset = intel_bb_ptr_add_return_prev_offset(ibb, 32);
- binding_table[0] = gen8_bind_buf(batch, dst, 1);
- binding_table[1] = gen8_bind_buf(batch, src, 0);
+ binding_table[0] = gen8_bind_buf(ibb, dst, 1);
+ binding_table[1] = gen8_bind_buf(ibb, src, 0);
- return offset;
+ return binding_table_offset;
}
/* Mostly copy+paste from gen6, except wrap modes moved */
static uint32_t
-gen8_create_sampler(struct intel_batchbuffer *batch) {
+gen8_create_sampler(struct intel_bb *ibb) {
struct gen8_sampler_state *ss;
- uint32_t offset;
- ss = intel_batchbuffer_subdata_alloc(batch, sizeof(*ss), 64);
- offset = intel_batchbuffer_subdata_offset(batch, ss);
- annotation_add_state(&aub_annotations, AUB_TRACE_SAMPLER_STATE,
- offset, sizeof(*ss));
+ ss = intel_bb_ptr_align(ibb, 64);
ss->ss0.min_filter = GEN4_MAPFILTER_NEAREST;
ss->ss0.mag_filter = GEN4_MAPFILTER_NEAREST;
@@ -329,21 +240,15 @@ gen8_create_sampler(struct intel_batchbuffer *batch) {
* sampler fetch, but couldn't make it work. */
ss->ss3.non_normalized_coord = 0;
- return offset;
+ return intel_bb_ptr_add_return_prev_offset(ibb, sizeof(*ss));
}
static uint32_t
-gen8_fill_ps(struct intel_batchbuffer *batch,
+gen8_fill_ps(struct intel_bb *ibb,
const uint32_t kernel[][4],
size_t size)
{
- uint32_t offset;
-
- offset = intel_batchbuffer_copy_data(batch, kernel, size, 64);
- annotation_add_state(&aub_annotations, AUB_TRACE_KERNEL_INSTRUCTIONS,
- offset, size);
-
- return offset;
+ return intel_bb_copy_data(ibb, kernel, size, 64);
}
/*
@@ -357,33 +262,29 @@ gen8_fill_ps(struct intel_batchbuffer *batch,
* see gen6_emit_vertex_elements
*/
static uint32_t
-gen7_fill_vertex_buffer_data(struct intel_batchbuffer *batch,
- const struct igt_buf *src,
+gen7_fill_vertex_buffer_data(struct intel_bb *ibb,
+ const struct intel_buf *src,
uint32_t src_x, uint32_t src_y,
uint32_t dst_x, uint32_t dst_y,
uint32_t width, uint32_t height)
{
- void *start;
uint32_t offset;
- intel_batchbuffer_align(batch, 8);
- start = batch->ptr;
+ intel_bb_ptr_align(ibb, 8);
+ offset = intel_bb_offset(ibb);
- emit_vertex_2s(batch, dst_x + width, dst_y + height);
- emit_vertex_normalized(batch, src_x + width, igt_buf_width(src));
- emit_vertex_normalized(batch, src_y + height, igt_buf_height(src));
+ emit_vertex_2s(ibb, dst_x + width, dst_y + height);
+ emit_vertex_normalized(ibb, src_x + width, intel_buf_width(src));
+ emit_vertex_normalized(ibb, src_y + height, intel_buf_height(src));
- emit_vertex_2s(batch, dst_x, dst_y + height);
- emit_vertex_normalized(batch, src_x, igt_buf_width(src));
- emit_vertex_normalized(batch, src_y + height, igt_buf_height(src));
+ emit_vertex_2s(ibb, dst_x, dst_y + height);
+ emit_vertex_normalized(ibb, src_x, intel_buf_width(src));
+ emit_vertex_normalized(ibb, src_y + height, intel_buf_height(src));
- emit_vertex_2s(batch, dst_x, dst_y);
- emit_vertex_normalized(batch, src_x, igt_buf_width(src));
- emit_vertex_normalized(batch, src_y, igt_buf_height(src));
+ emit_vertex_2s(ibb, dst_x, dst_y);
+ emit_vertex_normalized(ibb, src_x, intel_buf_width(src));
+ emit_vertex_normalized(ibb, src_y, intel_buf_height(src));
- offset = intel_batchbuffer_subdata_offset(batch, start);
- annotation_add_state(&aub_annotations, AUB_TRACE_VERTEX_BUFFER,
- offset, 3 * VERTEX_SIZE);
return offset;
}
@@ -397,25 +298,25 @@ gen7_fill_vertex_buffer_data(struct intel_batchbuffer *batch,
* packed.
*/
static void
-gen6_emit_vertex_elements(struct intel_batchbuffer *batch) {
+gen6_emit_vertex_elements(struct intel_bb *ibb) {
/*
* The VUE layout
* dword 0-3: pad (0, 0, 0. 0)
* dword 4-7: position (x, y, 0, 1.0),
* dword 8-11: texture coordinate 0 (u0, v0, 0, 1.0)
*/
- OUT_BATCH(GEN4_3DSTATE_VERTEX_ELEMENTS | (3 * 2 + 1 - 2));
+ intel_bb_out(ibb, GEN4_3DSTATE_VERTEX_ELEMENTS | (3 * 2 + 1 - 2));
/* Element state 0. These are 4 dwords of 0 required for the VUE format.
* We don't really know or care what they do.
*/
- OUT_BATCH(0 << GEN6_VE0_VERTEX_BUFFER_INDEX_SHIFT | GEN6_VE0_VALID |
- SURFACEFORMAT_R32G32B32A32_FLOAT << VE0_FORMAT_SHIFT |
- 0 << VE0_OFFSET_SHIFT); /* we specify 0, but it's really does not exist */
- OUT_BATCH(GEN4_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_0_SHIFT |
- GEN4_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_1_SHIFT |
- GEN4_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_2_SHIFT |
- GEN4_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_3_SHIFT);
+ intel_bb_out(ibb, 0 << GEN6_VE0_VERTEX_BUFFER_INDEX_SHIFT | GEN6_VE0_VALID |
+ SURFACEFORMAT_R32G32B32A32_FLOAT << VE0_FORMAT_SHIFT |
+ 0 << VE0_OFFSET_SHIFT); /* we specify 0, but it's really does not exist */
+ intel_bb_out(ibb, GEN4_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_0_SHIFT |
+ GEN4_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_1_SHIFT |
+ GEN4_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_2_SHIFT |
+ GEN4_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_3_SHIFT);
/* Element state 1 - Our "destination" vertices. These are passed down
* through the pipeline, and eventually make it to the pixel shader as
@@ -423,25 +324,25 @@ gen6_emit_vertex_elements(struct intel_batchbuffer *batch) {
* signed/scaled because of gen6 rendercopy. I see no particular reason
* for doing this though.
*/
- OUT_BATCH(0 << GEN6_VE0_VERTEX_BUFFER_INDEX_SHIFT | GEN6_VE0_VALID |
- SURFACEFORMAT_R16G16_SSCALED << VE0_FORMAT_SHIFT |
- 0 << VE0_OFFSET_SHIFT); /* offsets vb in bytes */
- OUT_BATCH(GEN4_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT |
- GEN4_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT |
- GEN4_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_2_SHIFT |
- GEN4_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT);
+ intel_bb_out(ibb, 0 << GEN6_VE0_VERTEX_BUFFER_INDEX_SHIFT | GEN6_VE0_VALID |
+ SURFACEFORMAT_R16G16_SSCALED << VE0_FORMAT_SHIFT |
+ 0 << VE0_OFFSET_SHIFT); /* offsets vb in bytes */
+ intel_bb_out(ibb, GEN4_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT |
+ GEN4_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT |
+ GEN4_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_2_SHIFT |
+ GEN4_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT);
/* Element state 2. Last but not least we store the U,V components as
* normalized floats. These will be used in the pixel shader to sample
* from the source buffer.
*/
- OUT_BATCH(0 << GEN6_VE0_VERTEX_BUFFER_INDEX_SHIFT | GEN6_VE0_VALID |
- SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT |
- 4 << VE0_OFFSET_SHIFT); /* offset vb in bytes */
- OUT_BATCH(GEN4_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT |
- GEN4_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT |
- GEN4_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_2_SHIFT |
- GEN4_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT);
+ intel_bb_out(ibb, 0 << GEN6_VE0_VERTEX_BUFFER_INDEX_SHIFT | GEN6_VE0_VALID |
+ SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT |
+ 4 << VE0_OFFSET_SHIFT); /* offset vb in bytes */
+ intel_bb_out(ibb, GEN4_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT |
+ GEN4_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT |
+ GEN4_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_2_SHIFT |
+ GEN4_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT);
}
/*
@@ -450,42 +351,35 @@ gen6_emit_vertex_elements(struct intel_batchbuffer *batch) {
* @batch
* @offset - bytw offset within the @batch where the vertex buffer starts.
*/
-static void gen7_emit_vertex_buffer(struct intel_batchbuffer *batch,
- uint32_t offset) {
- OUT_BATCH(GEN4_3DSTATE_VERTEX_BUFFERS | (1 + (4 * 1) - 2));
- OUT_BATCH(0 << GEN6_VB0_BUFFER_INDEX_SHIFT | /* VB 0th index */
- GEN8_VB0_BUFFER_ADDR_MOD_EN | /* Address Modify Enable */
- VERTEX_SIZE << VB0_BUFFER_PITCH_SHIFT);
- OUT_RELOC(batch->bo, I915_GEM_DOMAIN_VERTEX, 0, offset);
- OUT_BATCH(3 * VERTEX_SIZE);
+static void gen7_emit_vertex_buffer(struct intel_bb *ibb, uint32_t offset)
+{
+ intel_bb_out(ibb, GEN4_3DSTATE_VERTEX_BUFFERS | (1 + (4 * 1) - 2));
+ intel_bb_out(ibb, 0 << GEN6_VB0_BUFFER_INDEX_SHIFT | /* VB 0th index */
+ GEN8_VB0_BUFFER_ADDR_MOD_EN | /* Address Modify Enable */
+ VERTEX_SIZE << VB0_BUFFER_PITCH_SHIFT);
+ intel_bb_emit_reloc(ibb, ibb->handle,
+ I915_GEM_DOMAIN_VERTEX, 0,
+ offset, ibb->batch_offset);
+ intel_bb_out(ibb, 3 * VERTEX_SIZE);
}
static uint32_t
-gen6_create_cc_state(struct intel_batchbuffer *batch)
+gen6_create_cc_state(struct intel_bb *ibb)
{
struct gen6_color_calc_state *cc_state;
- uint32_t offset;
- cc_state = intel_batchbuffer_subdata_alloc(batch,
- sizeof(*cc_state), 64);
- offset = intel_batchbuffer_subdata_offset(batch, cc_state);
- annotation_add_state(&aub_annotations, AUB_TRACE_CC_STATE,
- offset, sizeof(*cc_state));
+ cc_state = intel_bb_ptr_align(ibb, 64);
- return offset;
+ return intel_bb_ptr_add_return_prev_offset(ibb, sizeof(*cc_state));
}
static uint32_t
-gen8_create_blend_state(struct intel_batchbuffer *batch)
+gen8_create_blend_state(struct intel_bb *ibb)
{
struct gen8_blend_state *blend;
int i;
- uint32_t offset;
- blend = intel_batchbuffer_subdata_alloc(batch, sizeof(*blend), 64);
- offset = intel_batchbuffer_subdata_offset(batch, blend);
- annotation_add_state(&aub_annotations, AUB_TRACE_BLEND_STATE,
- offset, sizeof(*blend));
+ blend = intel_bb_ptr_align(ibb, 64);
for (i = 0; i < 16; i++) {
blend->bs[i].dest_blend_factor = GEN6_BLENDFACTOR_ZERO;
@@ -495,466 +389,458 @@ gen8_create_blend_state(struct intel_batchbuffer *batch)
blend->bs[i].color_buffer_blend = 0;
}
- return offset;
+ return intel_bb_ptr_add_return_prev_offset(ibb, sizeof(*blend));
}
static uint32_t
-gen6_create_cc_viewport(struct intel_batchbuffer *batch)
+gen6_create_cc_viewport(struct intel_bb *ibb)
{
struct gen4_cc_viewport *vp;
- uint32_t offset;
- vp = intel_batchbuffer_subdata_alloc(batch, sizeof(*vp), 32);
- offset = intel_batchbuffer_subdata_offset(batch, vp);
- annotation_add_state(&aub_annotations, AUB_TRACE_CC_VP_STATE,
- offset, sizeof(*vp));
+ vp = intel_bb_ptr_align(ibb, 32);
/* XXX I don't understand this */
vp->min_depth = -1.e35;
vp->max_depth = 1.e35;
- return offset;
+ return intel_bb_ptr_add_return_prev_offset(ibb, sizeof(*vp));
}
static uint32_t
-gen7_create_sf_clip_viewport(struct intel_batchbuffer *batch) {
+gen7_create_sf_clip_viewport(struct intel_bb *ibb) {
/* XXX these are likely not needed */
struct gen7_sf_clip_viewport *scv_state;
- uint32_t offset;
- scv_state = intel_batchbuffer_subdata_alloc(batch,
- sizeof(*scv_state), 64);
- offset = intel_batchbuffer_subdata_offset(batch, scv_state);
- annotation_add_state(&aub_annotations, AUB_TRACE_CLIP_VP_STATE,
- offset, sizeof(*scv_state));
+ scv_state = intel_bb_ptr_align(ibb, 64);
scv_state->guardband.xmin = 0;
scv_state->guardband.xmax = 1.0f;
scv_state->guardband.ymin = 0;
scv_state->guardband.ymax = 1.0f;
- return offset;
+ return intel_bb_ptr_add_return_prev_offset(ibb, sizeof(*scv_state));
}
static uint32_t
-gen6_create_scissor_rect(struct intel_batchbuffer *batch)
+gen6_create_scissor_rect(struct intel_bb *ibb)
{
struct gen6_scissor_rect *scissor;
- uint32_t offset;
- scissor = intel_batchbuffer_subdata_alloc(batch, sizeof(*scissor), 64);
- offset = intel_batchbuffer_subdata_offset(batch, scissor);
- annotation_add_state(&aub_annotations, AUB_TRACE_SCISSOR_STATE,
- offset, sizeof(*scissor));
+ scissor = intel_bb_ptr_align(ibb, 64);
- return offset;
+ return intel_bb_ptr_add_return_prev_offset(ibb, sizeof(*scissor));
}
static void
-gen8_emit_sip(struct intel_batchbuffer *batch) {
- OUT_BATCH(GEN4_STATE_SIP | (3 - 2));
- OUT_BATCH(0);
- OUT_BATCH(0);
+gen8_emit_sip(struct intel_bb *ibb) {
+ intel_bb_out(ibb, GEN4_STATE_SIP | (3 - 2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
}
static void
-gen7_emit_push_constants(struct intel_batchbuffer *batch) {
- OUT_BATCH(GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_VS);
- OUT_BATCH(0);
- OUT_BATCH(GEN8_3DSTATE_PUSH_CONSTANT_ALLOC_HS);
- OUT_BATCH(0);
- OUT_BATCH(GEN8_3DSTATE_PUSH_CONSTANT_ALLOC_DS);
- OUT_BATCH(0);
- OUT_BATCH(GEN8_3DSTATE_PUSH_CONSTANT_ALLOC_GS);
- OUT_BATCH(0);
- OUT_BATCH(GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_PS);
- OUT_BATCH(0);
+gen7_emit_push_constants(struct intel_bb *ibb) {
+ intel_bb_out(ibb, GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_VS);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, GEN8_3DSTATE_PUSH_CONSTANT_ALLOC_HS);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, GEN8_3DSTATE_PUSH_CONSTANT_ALLOC_DS);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, GEN8_3DSTATE_PUSH_CONSTANT_ALLOC_GS);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_PS);
+ intel_bb_out(ibb, 0);
}
static void
-gen9_emit_state_base_address(struct intel_batchbuffer *batch) {
+gen9_emit_state_base_address(struct intel_bb *ibb) {
/* WaBindlessSurfaceStateModifyEnable:skl,bxt */
/* The length has to be one less if we dont modify
bindless state */
- OUT_BATCH(GEN4_STATE_BASE_ADDRESS | (19 - 1 - 2));
+ intel_bb_out(ibb, GEN4_STATE_BASE_ADDRESS | (19 - 1 - 2));
/* general */
- OUT_BATCH(0 | BASE_ADDRESS_MODIFY);
- OUT_BATCH(0);
+ intel_bb_out(ibb, 0 | BASE_ADDRESS_MODIFY);
+ intel_bb_out(ibb, 0);
/* stateless data port */
- OUT_BATCH(0 | BASE_ADDRESS_MODIFY);
+ intel_bb_out(ibb, 0 | BASE_ADDRESS_MODIFY);
/* surface */
- OUT_RELOC(batch->bo, I915_GEM_DOMAIN_SAMPLER, 0, BASE_ADDRESS_MODIFY);
+ intel_bb_emit_reloc(ibb, ibb->handle,
+ I915_GEM_DOMAIN_SAMPLER, 0,
+ BASE_ADDRESS_MODIFY, ibb->batch_offset);
/* dynamic */
- OUT_RELOC(batch->bo, I915_GEM_DOMAIN_RENDER | I915_GEM_DOMAIN_INSTRUCTION,
- 0, BASE_ADDRESS_MODIFY);
+ intel_bb_emit_reloc(ibb, ibb->handle,
+ I915_GEM_DOMAIN_RENDER | I915_GEM_DOMAIN_INSTRUCTION, 0,
+ BASE_ADDRESS_MODIFY, ibb->batch_offset);
/* indirect */
- OUT_BATCH(0);
- OUT_BATCH(0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
/* instruction */
- OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0, BASE_ADDRESS_MODIFY);
+ intel_bb_emit_reloc(ibb, ibb->handle,
+ I915_GEM_DOMAIN_INSTRUCTION, 0,
+ BASE_ADDRESS_MODIFY, ibb->batch_offset);
/* general state buffer size */
- OUT_BATCH(0xfffff000 | 1);
+ intel_bb_out(ibb, 0xfffff000 | 1);
/* dynamic state buffer size */
- OUT_BATCH(1 << 12 | 1);
+ intel_bb_out(ibb, 1 << 12 | 1);
/* indirect object buffer size */
- OUT_BATCH(0xfffff000 | 1);
+ intel_bb_out(ibb, 0xfffff000 | 1);
/* intruction buffer size */
- OUT_BATCH(1 << 12 | 1);
+ intel_bb_out(ibb, 1 << 12 | 1);
/* Bindless surface state base address */
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
}
static void
-gen7_emit_urb(struct intel_batchbuffer *batch) {
+gen7_emit_urb(struct intel_bb *ibb) {
/* XXX: Min valid values from mesa */
const int vs_entries = 64;
const int vs_size = 2;
const int vs_start = 4;
- OUT_BATCH(GEN7_3DSTATE_URB_VS);
- OUT_BATCH(vs_entries | ((vs_size - 1) << 16) | (vs_start << 25));
- OUT_BATCH(GEN7_3DSTATE_URB_GS);
- OUT_BATCH(vs_start << 25);
- OUT_BATCH(GEN7_3DSTATE_URB_HS);
- OUT_BATCH(vs_start << 25);
- OUT_BATCH(GEN7_3DSTATE_URB_DS);
- OUT_BATCH(vs_start << 25);
+ intel_bb_out(ibb, GEN7_3DSTATE_URB_VS);
+ intel_bb_out(ibb, vs_entries | ((vs_size - 1) << 16) | (vs_start << 25));
+ intel_bb_out(ibb, GEN7_3DSTATE_URB_GS);
+ intel_bb_out(ibb, vs_start << 25);
+ intel_bb_out(ibb, GEN7_3DSTATE_URB_HS);
+ intel_bb_out(ibb, vs_start << 25);
+ intel_bb_out(ibb, GEN7_3DSTATE_URB_DS);
+ intel_bb_out(ibb, vs_start << 25);
}
static void
-gen8_emit_cc(struct intel_batchbuffer *batch) {
- OUT_BATCH(GEN7_3DSTATE_BLEND_STATE_POINTERS);
- OUT_BATCH(cc.blend_state | 1);
+gen8_emit_cc(struct intel_bb *ibb) {
+ intel_bb_out(ibb, GEN7_3DSTATE_BLEND_STATE_POINTERS);
+ intel_bb_out(ibb, cc.blend_state | 1);
- OUT_BATCH(GEN6_3DSTATE_CC_STATE_POINTERS);
- OUT_BATCH(cc.cc_state | 1);
+ intel_bb_out(ibb, GEN6_3DSTATE_CC_STATE_POINTERS);
+ intel_bb_out(ibb, cc.cc_state | 1);
}
static void
-gen8_emit_multisample(struct intel_batchbuffer *batch) {
- OUT_BATCH(GEN8_3DSTATE_MULTISAMPLE | 0);
- OUT_BATCH(0);
+gen8_emit_multisample(struct intel_bb *ibb) {
+ intel_bb_out(ibb, GEN8_3DSTATE_MULTISAMPLE | 0);
+ intel_bb_out(ibb, 0);
- OUT_BATCH(GEN6_3DSTATE_SAMPLE_MASK);
- OUT_BATCH(1);
+ intel_bb_out(ibb, GEN6_3DSTATE_SAMPLE_MASK);
+ intel_bb_out(ibb, 1);
}
static void
-gen8_emit_vs(struct intel_batchbuffer *batch) {
- OUT_BATCH(GEN6_3DSTATE_CONSTANT_VS | (11-2));
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
-
- OUT_BATCH(GEN7_3DSTATE_BINDING_TABLE_POINTERS_VS);
- OUT_BATCH(0);
-
- OUT_BATCH(GEN7_3DSTATE_SAMPLER_STATE_POINTERS_VS);
- OUT_BATCH(0);
-
- OUT_BATCH(GEN6_3DSTATE_VS | (9-2));
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
+gen8_emit_vs(struct intel_bb *ibb) {
+ intel_bb_out(ibb, GEN6_3DSTATE_CONSTANT_VS | (11-2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+
+ intel_bb_out(ibb, GEN7_3DSTATE_BINDING_TABLE_POINTERS_VS);
+ intel_bb_out(ibb, 0);
+
+ intel_bb_out(ibb, GEN7_3DSTATE_SAMPLER_STATE_POINTERS_VS);
+ intel_bb_out(ibb, 0);
+
+ intel_bb_out(ibb, GEN6_3DSTATE_VS | (9-2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
}
static void
-gen8_emit_hs(struct intel_batchbuffer *batch) {
- OUT_BATCH(GEN7_3DSTATE_CONSTANT_HS | (11-2));
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
-
- OUT_BATCH(GEN7_3DSTATE_HS | (9-2));
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
-
- OUT_BATCH(GEN7_3DSTATE_BINDING_TABLE_POINTERS_HS);
- OUT_BATCH(0);
-
- OUT_BATCH(GEN8_3DSTATE_SAMPLER_STATE_POINTERS_HS);
- OUT_BATCH(0);
+gen8_emit_hs(struct intel_bb *ibb) {
+ intel_bb_out(ibb, GEN7_3DSTATE_CONSTANT_HS | (11-2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+
+ intel_bb_out(ibb, GEN7_3DSTATE_HS | (9-2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+
+ intel_bb_out(ibb, GEN7_3DSTATE_BINDING_TABLE_POINTERS_HS);
+ intel_bb_out(ibb, 0);
+
+ intel_bb_out(ibb, GEN8_3DSTATE_SAMPLER_STATE_POINTERS_HS);
+ intel_bb_out(ibb, 0);
}
static void
-gen8_emit_gs(struct intel_batchbuffer *batch) {
- OUT_BATCH(GEN6_3DSTATE_CONSTANT_GS | (11-2));
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
-
- OUT_BATCH(GEN6_3DSTATE_GS | (10-2));
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
-
- OUT_BATCH(GEN7_3DSTATE_BINDING_TABLE_POINTERS_GS);
- OUT_BATCH(0);
-
- OUT_BATCH(GEN7_3DSTATE_SAMPLER_STATE_POINTERS_GS);
- OUT_BATCH(0);
+gen8_emit_gs(struct intel_bb *ibb) {
+ intel_bb_out(ibb, GEN6_3DSTATE_CONSTANT_GS | (11-2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+
+ intel_bb_out(ibb, GEN6_3DSTATE_GS | (10-2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+
+ intel_bb_out(ibb, GEN7_3DSTATE_BINDING_TABLE_POINTERS_GS);
+ intel_bb_out(ibb, 0);
+
+ intel_bb_out(ibb, GEN7_3DSTATE_SAMPLER_STATE_POINTERS_GS);
+ intel_bb_out(ibb, 0);
}
static void
-gen9_emit_ds(struct intel_batchbuffer *batch) {
- OUT_BATCH(GEN7_3DSTATE_CONSTANT_DS | (11-2));
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
-
- OUT_BATCH(GEN7_3DSTATE_DS | (11-2));
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
-
- OUT_BATCH(GEN7_3DSTATE_BINDING_TABLE_POINTERS_DS);
- OUT_BATCH(0);
-
- OUT_BATCH(GEN8_3DSTATE_SAMPLER_STATE_POINTERS_DS);
- OUT_BATCH(0);
+gen9_emit_ds(struct intel_bb *ibb) {
+ intel_bb_out(ibb, GEN7_3DSTATE_CONSTANT_DS | (11-2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+
+ intel_bb_out(ibb, GEN7_3DSTATE_DS | (11-2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+
+ intel_bb_out(ibb, GEN7_3DSTATE_BINDING_TABLE_POINTERS_DS);
+ intel_bb_out(ibb, 0);
+
+ intel_bb_out(ibb, GEN8_3DSTATE_SAMPLER_STATE_POINTERS_DS);
+ intel_bb_out(ibb, 0);
}
static void
-gen8_emit_wm_hz_op(struct intel_batchbuffer *batch) {
- OUT_BATCH(GEN8_3DSTATE_WM_HZ_OP | (5-2));
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
+gen8_emit_wm_hz_op(struct intel_bb *ibb) {
+ intel_bb_out(ibb, GEN8_3DSTATE_WM_HZ_OP | (5-2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
}
static void
-gen8_emit_null_state(struct intel_batchbuffer *batch) {
- gen8_emit_wm_hz_op(batch);
- gen8_emit_hs(batch);
- OUT_BATCH(GEN7_3DSTATE_TE | (4-2));
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- gen8_emit_gs(batch);
- gen9_emit_ds(batch);
- gen8_emit_vs(batch);
+gen8_emit_null_state(struct intel_bb *ibb) {
+ gen8_emit_wm_hz_op(ibb);
+ gen8_emit_hs(ibb);
+ intel_bb_out(ibb, GEN7_3DSTATE_TE | (4-2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ gen8_emit_gs(ibb);
+ gen9_emit_ds(ibb);
+ gen8_emit_vs(ibb);
}
static void
-gen7_emit_clip(struct intel_batchbuffer *batch) {
- OUT_BATCH(GEN6_3DSTATE_CLIP | (4 - 2));
- OUT_BATCH(0);
- OUT_BATCH(0); /* pass-through */
- OUT_BATCH(0);
+gen7_emit_clip(struct intel_bb *ibb) {
+ intel_bb_out(ibb, GEN6_3DSTATE_CLIP | (4 - 2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0); /* pass-through */
+ intel_bb_out(ibb, 0);
}
static void
-gen8_emit_sf(struct intel_batchbuffer *batch)
+gen8_emit_sf(struct intel_bb *ibb)
{
int i;
- OUT_BATCH(GEN7_3DSTATE_SBE | (6 - 2));
- OUT_BATCH(1 << GEN7_SBE_NUM_OUTPUTS_SHIFT |
- GEN8_SBE_FORCE_URB_ENTRY_READ_LENGTH |
- GEN8_SBE_FORCE_URB_ENTRY_READ_OFFSET |
- 1 << GEN7_SBE_URB_ENTRY_READ_LENGTH_SHIFT |
- 1 << GEN8_SBE_URB_ENTRY_READ_OFFSET_SHIFT);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(GEN9_SBE_ACTIVE_COMPONENT_XYZW << 0);
- OUT_BATCH(0);
-
- OUT_BATCH(GEN8_3DSTATE_SBE_SWIZ | (11 - 2));
+ intel_bb_out(ibb, GEN7_3DSTATE_SBE | (6 - 2));
+ intel_bb_out(ibb, 1 << GEN7_SBE_NUM_OUTPUTS_SHIFT |
+ GEN8_SBE_FORCE_URB_ENTRY_READ_LENGTH |
+ GEN8_SBE_FORCE_URB_ENTRY_READ_OFFSET |
+ 1 << GEN7_SBE_URB_ENTRY_READ_LENGTH_SHIFT |
+ 1 << GEN8_SBE_URB_ENTRY_READ_OFFSET_SHIFT);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, GEN9_SBE_ACTIVE_COMPONENT_XYZW << 0);
+ intel_bb_out(ibb, 0);
+
+ intel_bb_out(ibb, GEN8_3DSTATE_SBE_SWIZ | (11 - 2));
for (i = 0; i < 8; i++)
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
-
- OUT_BATCH(GEN8_3DSTATE_RASTER | (5 - 2));
- OUT_BATCH(GEN8_RASTER_FRONT_WINDING_CCW | GEN8_RASTER_CULL_NONE);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
-
- OUT_BATCH(GEN6_3DSTATE_SF | (4 - 2));
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+
+ intel_bb_out(ibb, GEN8_3DSTATE_RASTER | (5 - 2));
+ intel_bb_out(ibb, GEN8_RASTER_FRONT_WINDING_CCW | GEN8_RASTER_CULL_NONE);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+
+ intel_bb_out(ibb, GEN6_3DSTATE_SF | (4 - 2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
}
static void
-gen8_emit_ps(struct intel_batchbuffer *batch, uint32_t kernel) {
+gen8_emit_ps(struct intel_bb *ibb, uint32_t kernel) {
const int max_threads = 63;
- OUT_BATCH(GEN6_3DSTATE_WM | (2 - 2));
- OUT_BATCH(/* XXX: I don't understand the BARYCENTRIC stuff, but it
+ intel_bb_out(ibb, GEN6_3DSTATE_WM | (2 - 2));
+ intel_bb_out(ibb, /* XXX: I don't understand the BARYCENTRIC stuff, but it
* appears we need it to put our setup data in the place we
* expect (g6, see below) */
- GEN8_3DSTATE_PS_PERSPECTIVE_PIXEL_BARYCENTRIC);
-
- OUT_BATCH(GEN6_3DSTATE_CONSTANT_PS | (11-2));
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
-
- OUT_BATCH(GEN7_3DSTATE_PS | (12-2));
- OUT_BATCH(kernel);
- OUT_BATCH(0); /* kernel hi */
- OUT_BATCH(1 << GEN6_3DSTATE_WM_SAMPLER_COUNT_SHIFT |
- 2 << GEN6_3DSTATE_WM_BINDING_TABLE_ENTRY_COUNT_SHIFT);
- OUT_BATCH(0); /* scratch space stuff */
- OUT_BATCH(0); /* scratch hi */
- OUT_BATCH((max_threads - 1) << GEN8_3DSTATE_PS_MAX_THREADS_SHIFT |
- GEN6_3DSTATE_WM_16_DISPATCH_ENABLE);
- OUT_BATCH(6 << GEN6_3DSTATE_WM_DISPATCH_START_GRF_0_SHIFT);
- OUT_BATCH(0); // kernel 1
- OUT_BATCH(0); /* kernel 1 hi */
- OUT_BATCH(0); // kernel 2
- OUT_BATCH(0); /* kernel 2 hi */
-
- OUT_BATCH(GEN8_3DSTATE_PS_BLEND | (2 - 2));
- OUT_BATCH(GEN8_PS_BLEND_HAS_WRITEABLE_RT);
-
- OUT_BATCH(GEN8_3DSTATE_PS_EXTRA | (2 - 2));
- OUT_BATCH(GEN8_PSX_PIXEL_SHADER_VALID | GEN8_PSX_ATTRIBUTE_ENABLE);
+ GEN8_3DSTATE_PS_PERSPECTIVE_PIXEL_BARYCENTRIC);
+
+ intel_bb_out(ibb, GEN6_3DSTATE_CONSTANT_PS | (11-2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+
+ intel_bb_out(ibb, GEN7_3DSTATE_PS | (12-2));
+ intel_bb_out(ibb, kernel);
+ intel_bb_out(ibb, 0); /* kernel hi */
+ intel_bb_out(ibb, 1 << GEN6_3DSTATE_WM_SAMPLER_COUNT_SHIFT |
+ 2 << GEN6_3DSTATE_WM_BINDING_TABLE_ENTRY_COUNT_SHIFT);
+ intel_bb_out(ibb, 0); /* scratch space stuff */
+ intel_bb_out(ibb, 0); /* scratch hi */
+ intel_bb_out(ibb, (max_threads - 1) << GEN8_3DSTATE_PS_MAX_THREADS_SHIFT |
+ GEN6_3DSTATE_WM_16_DISPATCH_ENABLE);
+ intel_bb_out(ibb, 6 << GEN6_3DSTATE_WM_DISPATCH_START_GRF_0_SHIFT);
+ intel_bb_out(ibb, 0); // kernel 1
+ intel_bb_out(ibb, 0); /* kernel 1 hi */
+ intel_bb_out(ibb, 0); // kernel 2
+ intel_bb_out(ibb, 0); /* kernel 2 hi */
+
+ intel_bb_out(ibb, GEN8_3DSTATE_PS_BLEND | (2 - 2));
+ intel_bb_out(ibb, GEN8_PS_BLEND_HAS_WRITEABLE_RT);
+
+ intel_bb_out(ibb, GEN8_3DSTATE_PS_EXTRA | (2 - 2));
+ intel_bb_out(ibb, GEN8_PSX_PIXEL_SHADER_VALID | GEN8_PSX_ATTRIBUTE_ENABLE);
}
static void
-gen9_emit_depth(struct intel_batchbuffer *batch)
+gen9_emit_depth(struct intel_bb *ibb)
{
- OUT_BATCH(GEN8_3DSTATE_WM_DEPTH_STENCIL | (4 - 2));
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
-
- OUT_BATCH(GEN7_3DSTATE_DEPTH_BUFFER | (8-2));
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
-
- OUT_BATCH(GEN8_3DSTATE_HIER_DEPTH_BUFFER | (5-2));
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
-
- OUT_BATCH(GEN8_3DSTATE_STENCIL_BUFFER | (5-2));
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
+ intel_bb_out(ibb, GEN8_3DSTATE_WM_DEPTH_STENCIL | (4 - 2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+
+ intel_bb_out(ibb, GEN7_3DSTATE_DEPTH_BUFFER | (8-2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+
+ intel_bb_out(ibb, GEN8_3DSTATE_HIER_DEPTH_BUFFER | (5-2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+
+ intel_bb_out(ibb, GEN8_3DSTATE_STENCIL_BUFFER | (5-2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
}
static void
-gen7_emit_clear(struct intel_batchbuffer *batch) {
- OUT_BATCH(GEN7_3DSTATE_CLEAR_PARAMS | (3-2));
- OUT_BATCH(0);
- OUT_BATCH(1); // clear valid
+gen7_emit_clear(struct intel_bb *ibb) {
+ intel_bb_out(ibb, GEN7_3DSTATE_CLEAR_PARAMS | (3-2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 1); // clear valid
}
static void
-gen6_emit_drawing_rectangle(struct intel_batchbuffer *batch, const struct igt_buf *dst)
+gen6_emit_drawing_rectangle(struct intel_bb *ibb, const struct intel_buf *dst)
{
- OUT_BATCH(GEN4_3DSTATE_DRAWING_RECTANGLE | (4 - 2));
- OUT_BATCH(0);
- OUT_BATCH((igt_buf_height(dst) - 1) << 16 | (igt_buf_width(dst) - 1));
- OUT_BATCH(0);
+ intel_bb_out(ibb, GEN4_3DSTATE_DRAWING_RECTANGLE | (4 - 2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, (intel_buf_height(dst) - 1) << 16 | (intel_buf_width(dst) - 1));
+ intel_bb_out(ibb, 0);
}
-static void gen8_emit_vf_topology(struct intel_batchbuffer *batch)
+static void gen8_emit_vf_topology(struct intel_bb *ibb)
{
- OUT_BATCH(GEN8_3DSTATE_VF_TOPOLOGY);
- OUT_BATCH(_3DPRIM_RECTLIST);
+ intel_bb_out(ibb, GEN8_3DSTATE_VF_TOPOLOGY);
+ intel_bb_out(ibb, _3DPRIM_RECTLIST);
}
/* Vertex elements MUST be defined before this according to spec */
-static void gen8_emit_primitive(struct intel_batchbuffer *batch, uint32_t offset)
+static void gen8_emit_primitive(struct intel_bb *ibb, uint32_t offset)
{
- OUT_BATCH(GEN8_3DSTATE_VF | (2 - 2));
- OUT_BATCH(0);
-
- OUT_BATCH(GEN8_3DSTATE_VF_INSTANCING | (3 - 2));
- OUT_BATCH(0);
- OUT_BATCH(0);
-
- OUT_BATCH(GEN4_3DPRIMITIVE | (7-2));
- OUT_BATCH(0); /* gen8+ ignore the topology type field */
- OUT_BATCH(3); /* vertex count */
- OUT_BATCH(0); /* We're specifying this instead with offset in GEN6_3DSTATE_VERTEX_BUFFERS */
- OUT_BATCH(1); /* single instance */
- OUT_BATCH(0); /* start instance location */
- OUT_BATCH(0); /* index buffer offset, ignored */
+ intel_bb_out(ibb, GEN8_3DSTATE_VF | (2 - 2));
+ intel_bb_out(ibb, 0);
+
+ intel_bb_out(ibb, GEN8_3DSTATE_VF_INSTANCING | (3 - 2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+
+ intel_bb_out(ibb, GEN4_3DPRIMITIVE | (7-2));
+ intel_bb_out(ibb, 0); /* gen8+ ignore the topology type field */
+ intel_bb_out(ibb, 3); /* vertex count */
+ intel_bb_out(ibb, 0); /* We're specifying this instead with offset in GEN6_3DSTATE_VERTEX_BUFFERS */
+ intel_bb_out(ibb, 1); /* single instance */
+ intel_bb_out(ibb, 0); /* start instance location */
+ intel_bb_out(ibb, 0); /* index buffer offset, ignored */
}
/* The general rule is if it's named gen6 it is directly copied from
@@ -990,166 +876,159 @@ static void gen8_emit_primitive(struct intel_batchbuffer *batch, uint32_t offset
#define BATCH_STATE_SPLIT 2048
static
-void _gen9_render_copyfunc(struct intel_batchbuffer *batch,
- drm_intel_context *context,
- const struct igt_buf *src, unsigned src_x,
- unsigned src_y, unsigned width, unsigned height,
- const struct igt_buf *dst, unsigned dst_x,
- unsigned dst_y,
- drm_intel_bo *aux_pgtable_bo,
- const uint32_t ps_kernel[][4],
- uint32_t ps_kernel_size)
+void _gen9_render_copyfunc(struct intel_bb *ibb,
+ uint32_t ctx,
+ struct intel_buf *src,
+ unsigned int src_x, unsigned int src_y,
+ unsigned int width, unsigned int height,
+ struct intel_buf *dst,
+ unsigned int dst_x, unsigned int dst_y,
+ struct intel_buf *aux_pgtable_buf,
+ const uint32_t ps_kernel[][4],
+ uint32_t ps_kernel_size)
{
uint32_t ps_sampler_state, ps_kernel_off, ps_binding_table;
uint32_t scissor_state;
uint32_t vertex_buffer;
- uint32_t batch_end;
uint32_t aux_pgtable_state;
igt_assert(src->bpp == dst->bpp);
- intel_batchbuffer_flush_with_context(batch, context);
- intel_batchbuffer_align(batch, 8);
+ intel_bb_flush_render_with_context(ibb, ctx);
- batch->ptr = &batch->buffer[BATCH_STATE_SPLIT];
+ intel_bb_add_intel_buf(ibb, dst, true);
+ intel_bb_add_intel_buf(ibb, src, false);
- annotation_init(&aub_annotations);
+ intel_bb_ptr_set(ibb, BATCH_STATE_SPLIT);
- ps_binding_table = gen8_bind_surfaces(batch, src, dst);
- ps_sampler_state = gen8_create_sampler(batch);
- ps_kernel_off = gen8_fill_ps(batch, ps_kernel, ps_kernel_size);
- vertex_buffer = gen7_fill_vertex_buffer_data(batch, src,
+ ps_binding_table = gen8_bind_surfaces(ibb, src, dst);
+ ps_sampler_state = gen8_create_sampler(ibb);
+ ps_kernel_off = gen8_fill_ps(ibb, ps_kernel, ps_kernel_size);
+ vertex_buffer = gen7_fill_vertex_buffer_data(ibb, src,
src_x, src_y,
dst_x, dst_y,
width, height);
- cc.cc_state = gen6_create_cc_state(batch);
- cc.blend_state = gen8_create_blend_state(batch);
- viewport.cc_state = gen6_create_cc_viewport(batch);
- viewport.sf_clip_state = gen7_create_sf_clip_viewport(batch);
- scissor_state = gen6_create_scissor_rect(batch);
-
- aux_pgtable_state = gen12_create_aux_pgtable_state(batch,
- aux_pgtable_bo);
-
- /* TODO: theree is other state which isn't setup */
+ cc.cc_state = gen6_create_cc_state(ibb);
+ cc.blend_state = gen8_create_blend_state(ibb);
+ viewport.cc_state = gen6_create_cc_viewport(ibb);
+ viewport.sf_clip_state = gen7_create_sf_clip_viewport(ibb);
+ scissor_state = gen6_create_scissor_rect(ibb);
+ aux_pgtable_state = gen12_create_aux_pgtable_state(ibb, aux_pgtable_buf);
- assert(batch->ptr < &batch->buffer[4095]);
-
- batch->ptr = batch->buffer;
+ /* TODO: there is other state which isn't setup */
+ intel_bb_ptr_set(ibb, 0);
/* Start emitting the commands. The order roughly follows the mesa blorp
* order */
- OUT_BATCH(G4X_PIPELINE_SELECT | PIPELINE_SELECT_3D |
- GEN9_PIPELINE_SELECTION_MASK);
-
- gen12_emit_aux_pgtable_state(batch, aux_pgtable_state, true);
-
- gen8_emit_sip(batch);
-
- gen7_emit_push_constants(batch);
+ intel_bb_out(ibb, G4X_PIPELINE_SELECT | PIPELINE_SELECT_3D |
+ GEN9_PIPELINE_SELECTION_MASK);
- gen9_emit_state_base_address(batch);
+ gen12_emit_aux_pgtable_state(ibb, aux_pgtable_state, true);
- OUT_BATCH(GEN7_3DSTATE_VIEWPORT_STATE_POINTERS_CC);
- OUT_BATCH(viewport.cc_state);
- OUT_BATCH(GEN8_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP);
- OUT_BATCH(viewport.sf_clip_state);
+ gen8_emit_sip(ibb);
- gen7_emit_urb(batch);
+ gen7_emit_push_constants(ibb);
- gen8_emit_cc(batch);
+ gen9_emit_state_base_address(ibb);
- gen8_emit_multisample(batch);
+ intel_bb_out(ibb, GEN7_3DSTATE_VIEWPORT_STATE_POINTERS_CC);
+ intel_bb_out(ibb, viewport.cc_state);
+ intel_bb_out(ibb, GEN8_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP);
+ intel_bb_out(ibb, viewport.sf_clip_state);
- gen8_emit_null_state(batch);
+ gen7_emit_urb(ibb);
- OUT_BATCH(GEN7_3DSTATE_STREAMOUT | (5 - 2));
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
+ gen8_emit_cc(ibb);
- gen7_emit_clip(batch);
+ gen8_emit_multisample(ibb);
- gen8_emit_sf(batch);
+ gen8_emit_null_state(ibb);
- gen8_emit_ps(batch, ps_kernel_off);
+ intel_bb_out(ibb, GEN7_3DSTATE_STREAMOUT | (5 - 2));
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_out(ibb, 0);
- OUT_BATCH(GEN7_3DSTATE_BINDING_TABLE_POINTERS_PS);
- OUT_BATCH(ps_binding_table);
+ gen7_emit_clip(ibb);
- OUT_BATCH(GEN7_3DSTATE_SAMPLER_STATE_POINTERS_PS);
- OUT_BATCH(ps_sampler_state);
+ gen8_emit_sf(ibb);
- OUT_BATCH(GEN8_3DSTATE_SCISSOR_STATE_POINTERS);
- OUT_BATCH(scissor_state);
+ gen8_emit_ps(ibb, ps_kernel_off);
- gen9_emit_depth(batch);
+ intel_bb_out(ibb, GEN7_3DSTATE_BINDING_TABLE_POINTERS_PS);
+ intel_bb_out(ibb, ps_binding_table);
- gen7_emit_clear(batch);
+ intel_bb_out(ibb, GEN7_3DSTATE_SAMPLER_STATE_POINTERS_PS);
+ intel_bb_out(ibb, ps_sampler_state);
- gen6_emit_drawing_rectangle(batch, dst);
+ intel_bb_out(ibb, GEN8_3DSTATE_SCISSOR_STATE_POINTERS);
+ intel_bb_out(ibb, scissor_state);
- gen7_emit_vertex_buffer(batch, vertex_buffer);
- gen6_emit_vertex_elements(batch);
+ gen9_emit_depth(ibb);
- gen8_emit_vf_topology(batch);
- gen8_emit_primitive(batch, vertex_buffer);
+ gen7_emit_clear(ibb);
- OUT_BATCH(MI_BATCH_BUFFER_END);
+ gen6_emit_drawing_rectangle(ibb, dst);
- batch_end = intel_batchbuffer_align(batch, 8);
- assert(batch_end < BATCH_STATE_SPLIT);
- annotation_add_batch(&aub_annotations, batch_end);
+ gen7_emit_vertex_buffer(ibb, vertex_buffer);
+ gen6_emit_vertex_elements(ibb);
- dump_batch(batch);
+ gen8_emit_vf_topology(ibb);
+ gen8_emit_primitive(ibb, vertex_buffer);
- annotation_flush(&aub_annotations, batch);
-
- gen6_render_flush(batch, context, batch_end);
- intel_batchbuffer_reset(batch);
+ intel_bb_emit_bbe(ibb);
+ intel_bb_exec_with_context(ibb, intel_bb_offset(ibb), ctx,
+ I915_EXEC_RENDER | I915_EXEC_NO_RELOC,
+ false);
+ dump_batch(ibb);
+ intel_bb_reset(ibb, false);
}
-void gen9_render_copyfunc(struct intel_batchbuffer *batch,
- drm_intel_context *context,
- const struct igt_buf *src, unsigned src_x, unsigned src_y,
- unsigned width, unsigned height,
- const struct igt_buf *dst, unsigned dst_x, unsigned dst_y)
+void gen9_render_copyfunc(struct intel_bb *ibb,
+ uint32_t ctx,
+ struct intel_buf *src,
+ unsigned int src_x, unsigned int src_y,
+ unsigned int width, unsigned int height,
+ struct intel_buf *dst,
+ unsigned int dst_x, unsigned int dst_y)
{
- _gen9_render_copyfunc(batch, context, src, src_x, src_y,
+ _gen9_render_copyfunc(ibb, ctx, src, src_x, src_y,
width, height, dst, dst_x, dst_y, NULL,
ps_kernel_gen9, sizeof(ps_kernel_gen9));
}
-void gen11_render_copyfunc(struct intel_batchbuffer *batch,
- drm_intel_context *context,
- const struct igt_buf *src, unsigned src_x, unsigned src_y,
- unsigned width, unsigned height,
- const struct igt_buf *dst, unsigned dst_x, unsigned dst_y)
-
+void gen11_render_copyfunc(struct intel_bb *ibb,
+ uint32_t ctx,
+ struct intel_buf *src,
+ unsigned int src_x, unsigned int src_y,
+ unsigned int width, unsigned int height,
+ struct intel_buf *dst,
+ unsigned int dst_x, unsigned int dst_y)
{
- _gen9_render_copyfunc(batch, context, src, src_x, src_y,
+ _gen9_render_copyfunc(ibb, ctx, src, src_x, src_y,
width, height, dst, dst_x, dst_y, NULL,
ps_kernel_gen11, sizeof(ps_kernel_gen11));
}
-void gen12_render_copyfunc(struct intel_batchbuffer *batch,
- drm_intel_context *context,
- const struct igt_buf *src, unsigned src_x, unsigned src_y,
- unsigned width, unsigned height,
- const struct igt_buf *dst, unsigned dst_x, unsigned dst_y)
-
+void gen12_render_copyfunc(struct intel_bb *ibb,
+ uint32_t ctx,
+ struct intel_buf *src,
+ unsigned int src_x, unsigned int src_y,
+ unsigned int width, unsigned int height,
+ struct intel_buf *dst,
+ unsigned int dst_x, unsigned int dst_y)
{
struct aux_pgtable_info pgtable_info = { };
- gen12_aux_pgtable_init(&pgtable_info, batch->bufmgr, src, dst);
+ gen12_aux_pgtable_init(&pgtable_info, ibb, src, dst);
- _gen9_render_copyfunc(batch, context, src, src_x, src_y,
+ _gen9_render_copyfunc(ibb, ctx, src, src_x, src_y,
width, height, dst, dst_x, dst_y,
- pgtable_info.pgtable_bo,
+ pgtable_info.pgtable_buf,
gen12_render_copy,
sizeof(gen12_render_copy));
- gen12_aux_pgtable_cleanup(&pgtable_info);
+ gen12_aux_pgtable_cleanup(ibb, &pgtable_info);
}