#include "ilo_builder_3d_top.h"
#include "ilo_builder_3d_bottom.h"
+struct gen6_3dprimitive_info {
+ enum gen_3dprim_type topology;
+ bool indexed;
+
+ uint32_t vertex_count;
+ uint32_t vertex_start;
+ uint32_t instance_count;
+ uint32_t instance_start;
+ int32_t vertex_base;
+};
+
static inline void
gen6_3DPRIMITIVE(struct ilo_builder *builder,
- const struct pipe_draw_info *info,
- int64_t start_offset)
+ const struct gen6_3dprimitive_info *info)
{
const uint8_t cmd_len = 6;
- const int prim = gen6_3d_translate_pipe_prim(info->mode);
- const int vb_access = (info->indexed) ?
- GEN6_3DPRIM_DW0_ACCESS_RANDOM : GEN6_3DPRIM_DW0_ACCESS_SEQUENTIAL;
uint32_t *dw;
ILO_DEV_ASSERT(builder->dev, 6, 6);
ilo_builder_batch_pointer(builder, cmd_len, &dw);
- dw[0] = GEN6_RENDER_CMD(3D, 3DPRIMITIVE) |
- vb_access |
- prim << GEN6_3DPRIM_DW0_TYPE__SHIFT |
- (cmd_len - 2);
- dw[1] = info->count;
- dw[2] = info->start + start_offset;
+ dw[0] = GEN6_RENDER_CMD(3D, 3DPRIMITIVE) | (cmd_len - 2) |
+ info->topology << GEN6_3DPRIM_DW0_TYPE__SHIFT;
+ if (info->indexed)
+ dw[0] |= GEN6_3DPRIM_DW0_ACCESS_RANDOM;
+
+ dw[1] = info->vertex_count;
+ dw[2] = info->vertex_start;
dw[3] = info->instance_count;
- dw[4] = info->start_instance;
- dw[5] = info->index_bias;
+ dw[4] = info->instance_start;
+ dw[5] = info->vertex_base;
}
static inline void
gen7_3DPRIMITIVE(struct ilo_builder *builder,
- const struct pipe_draw_info *info,
- int64_t start_offset)
+ const struct gen6_3dprimitive_info *info)
{
const uint8_t cmd_len = 7;
- const int prim = gen6_3d_translate_pipe_prim(info->mode);
- const int vb_access = (info->indexed) ?
- GEN7_3DPRIM_DW1_ACCESS_RANDOM : GEN7_3DPRIM_DW1_ACCESS_SEQUENTIAL;
uint32_t *dw;
ILO_DEV_ASSERT(builder->dev, 7, 8);
ilo_builder_batch_pointer(builder, cmd_len, &dw);
dw[0] = GEN6_RENDER_CMD(3D, 3DPRIMITIVE) | (cmd_len - 2);
- dw[1] = vb_access | prim;
- dw[2] = info->count;
- dw[3] = info->start + start_offset;
+
+ dw[1] = info->topology << GEN7_3DPRIM_DW1_TYPE__SHIFT;
+ if (info->indexed)
+ dw[1] |= GEN7_3DPRIM_DW1_ACCESS_RANDOM;
+
+ dw[2] = info->vertex_count;
+ dw[3] = info->vertex_start;
dw[4] = info->instance_count;
- dw[5] = info->start_instance;
- dw[6] = info->index_bias;
+ dw[5] = info->instance_start;
+ dw[6] = info->vertex_base;
}
#endif /* ILO_BUILDER_3D_H */
ilo_builder_batch_write(builder, cmd_len, &dw0);
}
-/**
- * Translate a pipe primitive type to the matching hardware primitive type.
- */
-static inline int
-gen6_3d_translate_pipe_prim(unsigned prim)
-{
- static const int prim_mapping[ILO_PRIM_MAX] = {
- [PIPE_PRIM_POINTS] = GEN6_3DPRIM_POINTLIST,
- [PIPE_PRIM_LINES] = GEN6_3DPRIM_LINELIST,
- [PIPE_PRIM_LINE_LOOP] = GEN6_3DPRIM_LINELOOP,
- [PIPE_PRIM_LINE_STRIP] = GEN6_3DPRIM_LINESTRIP,
- [PIPE_PRIM_TRIANGLES] = GEN6_3DPRIM_TRILIST,
- [PIPE_PRIM_TRIANGLE_STRIP] = GEN6_3DPRIM_TRISTRIP,
- [PIPE_PRIM_TRIANGLE_FAN] = GEN6_3DPRIM_TRIFAN,
- [PIPE_PRIM_QUADS] = GEN6_3DPRIM_QUADLIST,
- [PIPE_PRIM_QUAD_STRIP] = GEN6_3DPRIM_QUADSTRIP,
- [PIPE_PRIM_POLYGON] = GEN6_3DPRIM_POLYGON,
- [PIPE_PRIM_LINES_ADJACENCY] = GEN6_3DPRIM_LINELIST_ADJ,
- [PIPE_PRIM_LINE_STRIP_ADJACENCY] = GEN6_3DPRIM_LINESTRIP_ADJ,
- [PIPE_PRIM_TRIANGLES_ADJACENCY] = GEN6_3DPRIM_TRILIST_ADJ,
- [PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY] = GEN6_3DPRIM_TRISTRIP_ADJ,
- [ILO_PRIM_RECTANGLES] = GEN6_3DPRIM_RECTLIST,
- };
-
- assert(prim_mapping[prim]);
-
- return prim_mapping[prim];
-}
-
static inline void
gen8_3DSTATE_VF_TOPOLOGY(struct ilo_builder *builder,
enum gen_3dprim_type topology)
#include "util/u_memory.h"
#include "util/u_pointer.h"
-#define ILO_PRIM_RECTANGLES PIPE_PRIM_MAX
-#define ILO_PRIM_MAX (PIPE_PRIM_MAX + 1)
-
#endif /* ILO_CORE_H */
bool initialized;
float vertices[3][2];
- struct pipe_draw_info draw;
+ struct gen6_3dprimitive_info draw_info;
uint32_t vf_data[4];
struct ilo_state_vf vf;
return true;
/* a rectangle has 3 vertices in a RECTLIST */
- util_draw_init_info(&blitter->draw);
- blitter->draw.mode = ILO_PRIM_RECTANGLES;
- blitter->draw.count = 3;
+ 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 */
*/
static inline void
ilo_render_3dprimitive(struct ilo_render *r,
- const struct pipe_draw_info *info,
- const struct ilo_ib_state *ib)
+ const struct gen6_3dprimitive_info *info)
{
- const int64_t start_offset = (info->indexed) ? ib->draw_start_offset : 0;
-
ILO_DEV_ASSERT(r->dev, 6, 8);
if (r->state.deferred_pipe_control_dw1)
/* 3DPRIMITIVE */
if (ilo_dev_gen(r->dev) >= ILO_GEN(7))
- gen7_3DPRIMITIVE(r->builder, info, start_offset);
+ gen7_3DPRIMITIVE(r->builder, info);
else
- gen6_3DPRIMITIVE(r->builder, info, start_offset);
+ gen6_3DPRIMITIVE(r->builder, info);
r->state.current_pipe_control_dw1 = 0;
assert(!r->state.deferred_pipe_control_dw1);
gen6_draw_sf_rect(render, vec, session);
gen6_draw_vf(render, vec, session);
- ilo_render_3dprimitive(render, vec->draw, &vec->ib);
+ ilo_render_3dprimitive(render, &vec->draw_info);
}
static void
gen6_3DSTATE_DRAWING_RECTANGLE(r->builder, 0, 0,
blitter->fb.width, blitter->fb.height);
- ilo_render_3dprimitive(r, &blitter->draw, NULL);
+ ilo_render_3dprimitive(r, &blitter->draw_info);
}
int
gen6_draw_sf_rect(render, vec, session);
gen6_draw_vf(render, vec, session);
- ilo_render_3dprimitive(render, vec->draw, &vec->ib);
+ ilo_render_3dprimitive(render, &vec->draw_info);
}
static void
if (ilo_dev_gen(r->dev) == ILO_GEN(7))
gen7_wa_post_ps_and_later(r);
- ilo_render_3dprimitive(r, &blitter->draw, NULL);
+ ilo_render_3dprimitive(r, &blitter->draw_info);
}
int
if (session->vf_delta.dirty & ILO_STATE_VF_3DSTATE_VERTEX_ELEMENTS)
gen6_3DSTATE_VERTEX_ELEMENTS(r->builder, &vec->ve->vf);
- gen8_3DSTATE_VF_TOPOLOGY(r->builder,
- gen6_3d_translate_pipe_prim(vec->draw->mode));
+ gen8_3DSTATE_VF_TOPOLOGY(r->builder, vec->draw_info.topology);
if (session->vf_delta.dirty & ILO_STATE_VF_3DSTATE_VF_INSTANCING) {
const uint8_t attr_count = ilo_state_vf_get_attr_count(&vec->ve->vf);
gen6_draw_sf_rect(render, vec, session);
gen8_draw_vf(render, vec, session);
- ilo_render_3dprimitive(render, vec->draw, &vec->ib);
+ ilo_render_3dprimitive(render, &vec->draw_info);
}
int
* Chia-I Wu <olv@lunarg.com>
*/
-#include "core/ilo_builder_3d.h" /* for gen6_3d_translate_pipe_prim() */
#include "util/u_dual_blend.h"
#include "util/u_dynarray.h"
#include "util/u_framebuffer.h"
#include "ilo_shader.h"
#include "ilo_state.h"
+/**
+ * Translate a pipe primitive type to the matching hardware primitive type.
+ */
+static enum gen_3dprim_type
+ilo_translate_draw_mode(unsigned mode)
+{
+ static const enum gen_3dprim_type prim_mapping[PIPE_PRIM_MAX] = {
+ [PIPE_PRIM_POINTS] = GEN6_3DPRIM_POINTLIST,
+ [PIPE_PRIM_LINES] = GEN6_3DPRIM_LINELIST,
+ [PIPE_PRIM_LINE_LOOP] = GEN6_3DPRIM_LINELOOP,
+ [PIPE_PRIM_LINE_STRIP] = GEN6_3DPRIM_LINESTRIP,
+ [PIPE_PRIM_TRIANGLES] = GEN6_3DPRIM_TRILIST,
+ [PIPE_PRIM_TRIANGLE_STRIP] = GEN6_3DPRIM_TRISTRIP,
+ [PIPE_PRIM_TRIANGLE_FAN] = GEN6_3DPRIM_TRIFAN,
+ [PIPE_PRIM_QUADS] = GEN6_3DPRIM_QUADLIST,
+ [PIPE_PRIM_QUAD_STRIP] = GEN6_3DPRIM_QUADSTRIP,
+ [PIPE_PRIM_POLYGON] = GEN6_3DPRIM_POLYGON,
+ [PIPE_PRIM_LINES_ADJACENCY] = GEN6_3DPRIM_LINELIST_ADJ,
+ [PIPE_PRIM_LINE_STRIP_ADJACENCY] = GEN6_3DPRIM_LINESTRIP_ADJ,
+ [PIPE_PRIM_TRIANGLES_ADJACENCY] = GEN6_3DPRIM_TRILIST_ADJ,
+ [PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY] = GEN6_3DPRIM_TRISTRIP_ADJ,
+ };
+
+ assert(prim_mapping[mode]);
+
+ return prim_mapping[mode];
+}
+
static enum gen_index_format
ilo_translate_index_size(unsigned index_size)
{
vec->ib.state.offset % vec->ib.state.index_size));
struct pipe_resource *current_hw_res = NULL;
struct ilo_state_index_buffer_info info;
+ int64_t vertex_start_bias = 0;
if (!(vec->dirty & ILO_DIRTY_IB) && !need_upload)
return;
/* the HW offset should be aligned */
assert(hw_offset % vec->ib.state.index_size == 0);
- vec->ib.draw_start_offset = hw_offset / vec->ib.state.index_size;
+ vertex_start_bias = hw_offset / vec->ib.state.index_size;
/*
* INDEX[vec->draw->start] in the original buffer is INDEX[0] in the HW
* resource
*/
- vec->ib.draw_start_offset -= vec->draw->start;
+ vertex_start_bias -= vec->draw->start;
} else {
pipe_resource_reference(&vec->ib.hw_resource, vec->ib.state.buffer);
/* note that index size may be zero when the draw is not indexed */
- if (vec->draw->indexed) {
- vec->ib.draw_start_offset =
- vec->ib.state.offset / vec->ib.state.index_size;
- } else {
- vec->ib.draw_start_offset = 0;
- }
+ if (vec->draw->indexed)
+ vertex_start_bias = vec->ib.state.offset / vec->ib.state.index_size;
}
+ vec->draw_info.vertex_start += vertex_start_bias;
+
/* treat the IB as clean if the HW states do not change */
if (vec->ib.hw_resource == current_hw_res &&
vec->ib.hw_index_size == vec->ib.state.index_size)
const struct ilo_dev *dev = ilo->dev;
struct ilo_state_vector *vec = &ilo->state_vector;
struct ilo_ve_state *ve = vec->ve;
- const enum gen_3dprim_type topology =
- gen6_3d_translate_pipe_prim(vec->draw->mode);
const bool last_element_edge_flag = (vec->vs &&
ilo_shader_get_kernel_param(vec->vs, ILO_KERNEL_VS_INPUT_EDGEFLAG));
const bool prepend_vertexid = (vec->vs &&
ilo_translate_index_size(vec->ib.state.index_size) : GEN6_INDEX_DWORD;
/* check for non-orthogonal states */
- if (ve->vf_params.cv_topology != topology ||
+ if (ve->vf_params.cv_topology != vec->draw_info.topology ||
ve->vf_params.prepend_vertexid != prepend_vertexid ||
ve->vf_params.prepend_instanceid != prepend_instanceid ||
ve->vf_params.last_element_edge_flag != last_element_edge_flag ||
ve->vf_params.cv_index_format != index_format ||
ve->vf_params.cut_index_enable != vec->draw->primitive_restart ||
ve->vf_params.cut_index != vec->draw->restart_index) {
- ve->vf_params.cv_topology = topology;
+ ve->vf_params.cv_topology = vec->draw_info.topology;
ve->vf_params.prepend_vertexid = prepend_vertexid;
ve->vf_params.prepend_instanceid = prepend_instanceid;
ve->vf_params.last_element_edge_flag = last_element_edge_flag;
{
ilo->state_vector.draw = draw;
+ ilo->state_vector.draw_info.topology = ilo_translate_draw_mode(draw->mode);
+ ilo->state_vector.draw_info.indexed = draw->indexed;
+ ilo->state_vector.draw_info.vertex_count = draw->count;
+ ilo->state_vector.draw_info.vertex_start = draw->start;
+ ilo->state_vector.draw_info.instance_count = draw->instance_count;
+ ilo->state_vector.draw_info.instance_start = draw->start_instance;
+ ilo->state_vector.draw_info.vertex_base = draw->index_bias;
+
finalize_blend(ilo);
finalize_shader_states(&ilo->state_vector);
finalize_constant_buffers(ilo);
#ifndef ILO_STATE_H
#define ILO_STATE_H
+#include "core/ilo_builder_3d.h" /* for gen6_3dprimitive_info */
#include "core/ilo_state_cc.h"
#include "core/ilo_state_compute.h"
#include "core/ilo_state_raster.h"
struct pipe_resource *hw_resource;
unsigned hw_index_size;
struct ilo_state_index_buffer ib;
- /* an offset to be added to pipe_draw_info::start */
- int64_t draw_start_offset;
};
struct ilo_cbuf_cso {
struct ilo_state_vector {
const struct pipe_draw_info *draw;
+ struct gen6_3dprimitive_info draw_info;
uint32_t dirty;