summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/vc4/vc4_emit.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2016-10-26 12:46:58 -0700
committerEric Anholt <eric@anholt.net>2017-06-30 12:25:45 -0700
commit4cef255872e8467aabce52938038a9d2bf27d9b2 (patch)
tree967db9b8853e6a5fb2b9609aafea981cc1b3cffc /src/gallium/drivers/vc4/vc4_emit.c
parent7f80a9ff1312406dcffae88bf6dcaaf99ca9e3a1 (diff)
vc4: Start using the pack header.
This slightly inflates the size of the generated code, in exchange for getting us some convenient tools. before: 4389 0 0 4389 1125 src/gallium/drivers/vc4/.libs/vc4_draw.o 808 0 0 808 328 src/gallium/drivers/vc4/.libs/vc4_emit.o after: 4449 0 0 4449 1161 src/gallium/drivers/vc4/.libs/vc4_draw.o 988 0 0 988 3dc src/gallium/drivers/vc4/.libs/vc4_emit.o
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_emit.c')
-rw-r--r--src/gallium/drivers/vc4/vc4_emit.c65
1 files changed, 41 insertions, 24 deletions
diff --git a/src/gallium/drivers/vc4/vc4_emit.c b/src/gallium/drivers/vc4/vc4_emit.c
index b48d89a0604..9fc266e5baa 100644
--- a/src/gallium/drivers/vc4/vc4_emit.c
+++ b/src/gallium/drivers/vc4/vc4_emit.c
@@ -60,11 +60,12 @@ vc4_emit_state(struct pipe_context *pctx)
maxy = MIN2(vp_maxy, vc4->scissor.maxy);
}
- cl_u8(&bcl, VC4_PACKET_CLIP_WINDOW);
- cl_u16(&bcl, minx);
- cl_u16(&bcl, miny);
- cl_u16(&bcl, maxx - minx);
- cl_u16(&bcl, maxy - miny);
+ cl_emit(&bcl, CLIP_WINDOW, clip) {
+ clip.clip_window_left_pixel_coordinate = minx;
+ clip.clip_window_bottom_pixel_coordinate = miny;
+ clip.clip_window_height_in_pixels = maxy - miny;
+ clip.clip_window_width_in_pixels = maxx - minx;
+ }
job->draw_min_x = MIN2(job->draw_min_x, minx);
job->draw_min_y = MIN2(job->draw_min_y, miny);
@@ -113,35 +114,51 @@ vc4_emit_state(struct pipe_context *pctx)
}
if (vc4->dirty & VC4_DIRTY_RASTERIZER) {
- cl_u8(&bcl, VC4_PACKET_DEPTH_OFFSET);
- cl_u16(&bcl, vc4->rasterizer->offset_factor);
- cl_u16(&bcl, vc4->rasterizer->offset_units);
+ cl_emit(&bcl, DEPTH_OFFSET, depth) {
+ depth.depth_offset_units =
+ vc4->rasterizer->offset_units;
+ depth.depth_offset_factor =
+ vc4->rasterizer->offset_factor;
+ }
- cl_u8(&bcl, VC4_PACKET_POINT_SIZE);
- cl_f(&bcl, vc4->rasterizer->point_size);
+ cl_emit(&bcl, POINT_SIZE, points) {
+ points.point_size = vc4->rasterizer->point_size;
+ }
- cl_u8(&bcl, VC4_PACKET_LINE_WIDTH);
- cl_f(&bcl, vc4->rasterizer->base.line_width);
+ cl_emit(&bcl, LINE_WIDTH, points) {
+ points.line_width = vc4->rasterizer->base.line_width;
+ }
}
if (vc4->dirty & VC4_DIRTY_VIEWPORT) {
- cl_u8(&bcl, VC4_PACKET_CLIPPER_XY_SCALING);
- cl_f(&bcl, vc4->viewport.scale[0] * 16.0f);
- cl_f(&bcl, vc4->viewport.scale[1] * 16.0f);
+ cl_emit(&bcl, CLIPPER_XY_SCALING, clip) {
+ clip.viewport_half_width_in_1_16th_of_pixel =
+ vc4->viewport.scale[0] * 16.0f;
+ clip.viewport_half_height_in_1_16th_of_pixel =
+ vc4->viewport.scale[1] * 16.0f;
+ }
- cl_u8(&bcl, VC4_PACKET_CLIPPER_Z_SCALING);
- cl_f(&bcl, vc4->viewport.translate[2]);
- cl_f(&bcl, vc4->viewport.scale[2]);
+ cl_emit(&bcl, CLIPPER_Z_SCALE_AND_OFFSET, clip) {
+ clip.viewport_z_offset_zc_to_zs =
+ vc4->viewport.translate[2];
+ clip.viewport_z_scale_zc_to_zs =
+ vc4->viewport.scale[2];
+ }
- cl_u8(&bcl, VC4_PACKET_VIEWPORT_OFFSET);
- cl_u16(&bcl, 16 * vc4->viewport.translate[0]);
- cl_u16(&bcl, 16 * vc4->viewport.translate[1]);
+ cl_emit(&bcl, VIEWPORT_OFFSET, vp) {
+ vp.viewport_centre_x_coordinate =
+ 16 * vc4->viewport.translate[0];
+ vp.viewport_centre_y_coordinate =
+ 16 * vc4->viewport.translate[1];
+ }
}
if (vc4->dirty & VC4_DIRTY_FLAT_SHADE_FLAGS) {
- cl_u8(&bcl, VC4_PACKET_FLAT_SHADE_FLAGS);
- cl_u32(&bcl, vc4->rasterizer->base.flatshade ?
- vc4->prog.fs->color_inputs : 0);
+ cl_emit(&bcl, FLAT_SHADE_FLAGS, flags) {
+ if (vc4->rasterizer->base.flatshade)
+ flags.flat_shading_flags =
+ vc4->prog.fs->color_inputs;
+ }
}
cl_end(&job->bcl, bcl);