Lines Matching refs:ice
686 static bool check_urb_layout(struct crocus_context *ice)
688 ice->urb.vs_start = 0;
689 ice->urb.gs_start = ice->urb.nr_vs_entries * ice->urb.vsize;
690 ice->urb.clip_start = ice->urb.gs_start + ice->urb.nr_gs_entries * ice->urb.vsize;
691 ice->urb.sf_start = ice->urb.clip_start + ice->urb.nr_clip_entries * ice->urb.vsize;
692 ice->urb.cs_start = ice->urb.sf_start + ice->urb.nr_sf_entries * ice->urb.sfsize;
694 return ice->urb.cs_start + ice->urb.nr_cs_entries *
695 ice->urb.csize <= ice->urb.size;
703 struct crocus_context *ice = batch->ice;
713 if (ice->urb.vsize < vsize ||
714 ice->urb.sfsize < sfsize ||
715 ice->urb.csize < csize ||
716 (ice->urb.constrained && (ice->urb.vsize > vsize ||
717 ice->urb.sfsize > sfsize ||
718 ice->urb.csize > csize))) {
721 ice->urb.csize = csize;
722 ice->urb.sfsize = sfsize;
723 ice->urb.vsize = vsize;
725 ice->urb.nr_vs_entries = limits[URB_VS].preferred_nr_entries;
726 ice->urb.nr_gs_entries = limits[URB_GS].preferred_nr_entries;
727 ice->urb.nr_clip_entries = limits[URB_CLP].preferred_nr_entries;
728 ice->urb.nr_sf_entries = limits[URB_SF].preferred_nr_entries;
729 ice->urb.nr_cs_entries = limits[URB_CS].preferred_nr_entries;
731 ice->urb.constrained = 0;
734 ice->urb.nr_vs_entries = 128;
735 ice->urb.nr_sf_entries = 48;
736 if (check_urb_layout(ice)) {
739 ice->urb.constrained = 1;
740 ice->urb.nr_vs_entries = limits[URB_VS].preferred_nr_entries;
741 ice->urb.nr_sf_entries = limits[URB_SF].preferred_nr_entries;
744 ice->urb.nr_vs_entries = 64;
745 if (check_urb_layout(ice)) {
748 ice->urb.constrained = 1;
749 ice->urb.nr_vs_entries = limits[URB_VS].preferred_nr_entries;
753 if (!check_urb_layout(ice)) {
754 ice->urb.nr_vs_entries = limits[URB_VS].min_nr_entries;
755 ice->urb.nr_gs_entries = limits[URB_GS].min_nr_entries;
756 ice->urb.nr_clip_entries = limits[URB_CLP].min_nr_entries;
757 ice->urb.nr_sf_entries = limits[URB_SF].min_nr_entries;
758 ice->urb.nr_cs_entries = limits[URB_CS].min_nr_entries;
764 ice->urb.constrained = 1;
766 if (!check_urb_layout(ice)) {
783 ice->urb.vs_start,
784 ice->urb.gs_start,
785 ice->urb.clip_start,
786 ice->urb.sf_start,
787 ice->urb.cs_start,
788 ice->urb.size);
806 urb.VSFence = batch->ice->urb.gs_start;
807 urb.GSFence = batch->ice->urb.clip_start;
808 urb.CLIPFence = batch->ice->urb.sf_start;
809 urb.SFFence = batch->ice->urb.cs_start;
810 urb.CSFence = batch->ice->urb.size;
828 struct crocus_context *ice = batch->ice;
835 const struct brw_ubo_range *range = &ice->shaders.prog[MESA_SHADER_FRAGMENT]->prog_data->ubo_ranges[i];
843 if (ice->state.cso_rast->cso.clip_plane_enable) {
844 unsigned nr_planes = 6 + util_bitcount(ice->state.cso_rast->cso.clip_plane_enable);
850 const struct brw_ubo_range *range = &ice->shaders.prog[MESA_SHADER_VERTEX]->prog_data->ubo_ranges[i];
879 if (nr_fp_regs > ice->curbe.wm_size ||
880 nr_vp_regs > ice->curbe.vs_size ||
881 nr_clip_regs != ice->curbe.clip_size ||
882 (total_regs < ice->curbe.total_size / 4 &&
883 ice->curbe.total_size > 16)) {
890 ice->curbe.wm_start = reg;
891 ice->curbe.wm_size = nr_fp_regs; reg += nr_fp_regs;
892 ice->curbe.clip_start = reg;
893 ice->curbe.clip_size = nr_clip_regs; reg += nr_clip_regs;
894 ice->curbe.vs_start = reg;
895 ice->curbe.vs_size = nr_vp_regs; reg += nr_vp_regs;
896 ice->curbe.total_size = reg;
900 ice->curbe.wm_start,
901 ice->curbe.wm_size,
902 ice->curbe.clip_start,
903 ice->curbe.clip_size,
904 ice->curbe.vs_start,
905 ice->curbe.vs_size );
912 upload_shader_consts(struct crocus_context *ice,
917 struct crocus_compiled_shader *shader = ice->shaders.prog[stage];
935 cmap = pipe_buffer_map_range(&ice->ctx, ice->state.shaders[stage].constbufs[block_index].buffer,
936 ice->state.shaders[stage].constbufs[block_index].buffer_offset + start, len,
940 pipe_buffer_unmap(&ice->ctx, transfer);
966 struct crocus_context *ice = batch->ice;
967 const unsigned sz = ice->curbe.total_size;
974 u_upload_alloc(ice->ctx.const_uploader, 0, buf_sz, 64,
975 &ice->curbe.curbe_offset, (struct pipe_resource **)&ice->curbe.curbe_res, (void **) &map);
978 if (ice->curbe.wm_size) {
979 upload_shader_consts(ice, MESA_SHADER_FRAGMENT, map, ice->curbe.wm_start);
983 if (ice->curbe.clip_size) {
984 unsigned offset = ice->curbe.clip_start * 16;
996 unsigned mask = ice->state.cso_rast->cso.clip_plane_enable;
997 struct pipe_clip_state *cp = &ice->state.clip_planes;
1009 if (ice->curbe.vs_size) {
1010 upload_shader_consts(ice, MESA_SHADER_VERTEX, map, ice->curbe.vs_start);
1022 if (ice->curbe.curbe_res) {
1023 cb.BufferLength = ice->curbe.total_size - 1;
1025 cb.BufferStartingAddress = ro_bo(ice->curbe.curbe_res->bo, ice->curbe.curbe_offset);
1047 crocus_get_shader_info(ice, MESA_SHADER_FRAGMENT);
1050 ice->state.global_depth_offset_clamp = 0;
1216 batch->ice->workaround_bo,
1217 batch->ice->workaround_offset, 0);
1427 * Generation-specific context state (ice->state.genx->...).
1453 struct crocus_context *ice = (struct crocus_context *) ctx;
1456 memcpy(&ice->state.blend_color, state, sizeof(struct pipe_blend_color));
1458 ice->state.dirty |= CROCUS_DIRTY_GEN4_CONSTANT_COLOR;
1460 ice->state.dirty |= CROCUS_DIRTY_COLOR_CALC_STATE;
1507 can_emit_logic_op(struct crocus_context *ice)
1511 for (unsigned i = 0; i < ice->state.framebuffer.nr_cbufs; i++) {
1512 if (ice->state.framebuffer.cbufs[i]) {
1513 pformat = ice->state.framebuffer.cbufs[i]->format;
1525 struct crocus_context *ice = batch->ice;
1544 if (GFX_VER >= 8 || can_emit_logic_op(ice)) {
1550 struct crocus_compiled_shader *shader = ice->shaders.prog[MESA_SHADER_FRAGMENT];
1569 struct crocus_compiled_shader *shader = ice->shaders.prog[MESA_SHADER_FRAGMENT];
1662 struct crocus_context *ice = (struct crocus_context *) ctx;
1665 ice->state.cso_blend = cso;
1666 ice->state.blend_enables = cso ? cso->blend_enables : 0;
1668 ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_BINDINGS_FS;
1669 ice->state.dirty |= CROCUS_DIRTY_WM;
1671 ice->state.dirty |= CROCUS_DIRTY_GEN6_BLEND_STATE;
1674 ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_FS;
1677 ice->state.dirty |= CROCUS_DIRTY_GEN8_PMA_FIX;
1678 ice->state.dirty |= CROCUS_DIRTY_GEN8_PS_BLEND;
1680 ice->state.dirty |= CROCUS_DIRTY_COLOR_CALC_STATE;
1681 ice->state.dirty |= CROCUS_DIRTY_RENDER_RESOLVES_AND_FLUSHES;
1682 ice->state.stage_dirty |= ice->state.stage_dirty_for_nos[CROCUS_NOS_BLEND];
1749 struct crocus_context *ice = (struct crocus_context *) ctx;
1750 struct crocus_depth_stencil_alpha_state *old_cso = ice->state.cso_zsa;
1755 ice->state.dirty |= CROCUS_DIRTY_COLOR_CALC_STATE;
1758 ice->state.dirty |= CROCUS_DIRTY_WM;
1761 ice->state.dirty |= CROCUS_DIRTY_GEN6_BLEND_STATE;
1764 ice->state.dirty |= CROCUS_DIRTY_GEN6_BLEND_STATE;
1768 ice->state.dirty |= CROCUS_DIRTY_GEN8_PS_BLEND;
1772 ice->state.dirty |= CROCUS_DIRTY_RENDER_RESOLVES_AND_FLUSHES;
1774 ice->state.depth_writes_enabled = new_cso->depth_writes_enabled;
1775 ice->state.stencil_writes_enabled = new_cso->stencil_writes_enabled;
1778 ice->state.dirty |= CROCUS_DIRTY_COLOR_CALC_STATE;
1782 ice->state.cso_zsa = new_cso;
1783 ice->state.dirty |= CROCUS_DIRTY_CC_VIEWPORT;
1785 ice->state.dirty |= CROCUS_DIRTY_GEN6_WM_DEPTH_STENCIL;
1788 ice->state.dirty |= CROCUS_DIRTY_GEN8_PMA_FIX;
1790 ice->state.stage_dirty |= ice->state.stage_dirty_for_nos[CROCUS_NOS_DEPTH_STENCIL_ALPHA];
1795 want_pma_fix(struct crocus_context *ice)
1797 UNUSED struct crocus_screen *screen = (void *) ice->ctx.screen;
1800 ice->shaders.prog[MESA_SHADER_FRAGMENT]->prog_data;
1801 const struct pipe_framebuffer_state *cso_fb = &ice->state.framebuffer;
1802 const struct crocus_depth_stencil_alpha_state *cso_zsa = ice->state.cso_zsa;
1803 const struct crocus_blend_state *cso_blend = ice->state.cso_blend;
1917 genX(crocus_update_pma_fix)(struct crocus_context *ice,
1922 struct crocus_genx_state *genx = ice->state.genx;
2160 struct crocus_context *ice = (struct crocus_context *) ctx;
2161 struct crocus_rasterizer_state *old_cso = ice->state.cso_rast;
2167 ice->state.dirty |= CROCUS_DIRTY_LINE_STIPPLE;
2170 ice->state.dirty |= CROCUS_DIRTY_GEN6_MULTISAMPLE;
2172 ice->state.dirty |= CROCUS_DIRTY_GEN6_SCISSOR_RECT;
2174 ice->state.dirty |= CROCUS_DIRTY_WM;
2177 ice->state.dirty |= CROCUS_DIRTY_SF_CL_VIEWPORT;
2181 ice->state.dirty |= CROCUS_DIRTY_WM;
2185 ice->state.dirty |= CROCUS_DIRTY_STREAMOUT | CROCUS_DIRTY_CLIP;
2188 ice->state.dirty |= CROCUS_DIRTY_STREAMOUT;
2193 ice->state.dirty |= CROCUS_DIRTY_CC_VIEWPORT;
2199 ice->state.dirty |= CROCUS_DIRTY_GEN7_SBE;
2203 ice->state.dirty |= CROCUS_DIRTY_GEN4_CURBE;
2207 ice->state.cso_rast = new_cso;
2208 ice->state.dirty |= CROCUS_DIRTY_RASTER;
2209 ice->state.dirty |= CROCUS_DIRTY_CLIP;
2211 ice->state.dirty |= CROCUS_DIRTY_GEN4_CLIP_PROG | CROCUS_DIRTY_GEN4_SF_PROG;
2212 ice->state.dirty |= CROCUS_DIRTY_WM;
2215 ice->state.dirty |= CROCUS_DIRTY_GEN4_FF_GS_PROG;
2217 ice->state.stage_dirty |= ice->state.stage_dirty_for_nos[CROCUS_NOS_RASTERIZER];
2305 struct crocus_context *ice = (struct crocus_context *) ctx;
2307 struct crocus_shader_state *shs = &ice->state.shaders[stage];
2323 ice->state.dirty |= CROCUS_DIRTY_WM;
2325 ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_VS;
2327 ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_SAMPLER_STATES_VS << stage;
2328 ice->state.stage_dirty |= ice->state.stage_dirty_for_nos[CROCUS_NOS_TEXTURES];
2596 crocus_upload_sampler_states(struct crocus_context *ice,
2599 struct crocus_shader_state *shs = &ice->state.shaders[stage];
2600 const struct shader_info *info = crocus_get_shader_info(ice, stage);
3056 struct crocus_context *ice = (struct crocus_context *) ctx;
3060 struct crocus_shader_state *shs = &ice->state.shaders[stage];
3061 struct crocus_genx_state *genx = ice->state.genx;
3131 ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_BINDINGS_VS << stage;
3132 ice->state.dirty |=
3137 ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_CONSTANTS_VS << stage;
3154 struct crocus_context *ice = (struct crocus_context *) ctx;
3156 struct crocus_shader_state *shs = &ice->state.shaders[stage];
3182 ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_SAMPLER_STATES_VS << stage;
3184 ice->state.stage_dirty |= (CROCUS_STAGE_DIRTY_BINDINGS_VS << stage);
3185 ice->state.dirty |=
3188 ice->state.stage_dirty |= ice->state.stage_dirty_for_nos[CROCUS_NOS_TEXTURES];
3199 struct crocus_context *ice = (struct crocus_context *) ctx;
3200 struct crocus_shader_state *shs = &ice->state.shaders[MESA_SHADER_TESS_CTRL];
3202 memcpy(&ice->state.default_outer_level[0], &default_outer_level[0], 4 * sizeof(float));
3203 memcpy(&ice->state.default_inner_level[0], &default_inner_level[0], 2 * sizeof(float));
3205 ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_CONSTANTS_TCS;
3212 struct crocus_context *ice = (struct crocus_context *) ctx;
3214 ice->state.patch_vertices = patch_vertices;
3231 struct crocus_context *ice = (struct crocus_context *) ctx;
3232 struct crocus_shader_state *shs = &ice->state.shaders[MESA_SHADER_VERTEX];
3233 struct crocus_shader_state *gshs = &ice->state.shaders[MESA_SHADER_GEOMETRY];
3234 struct crocus_shader_state *tshs = &ice->state.shaders[MESA_SHADER_TESS_EVAL];
3236 memcpy(&ice->state.clip_planes, state, sizeof(*state));
3239 ice->state.dirty |= CROCUS_DIRTY_GEN4_CURBE;
3241 ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_CONSTANTS_VS | CROCUS_STAGE_DIRTY_CONSTANTS_GS |
3255 struct crocus_context *ice = (struct crocus_context *) ctx;
3256 memcpy(&ice->state.poly_stipple, state, sizeof(*state));
3257 ice->state.dirty |= CROCUS_DIRTY_POLYGON_STIPPLE;
3266 struct crocus_context *ice = (struct crocus_context *) ctx;
3271 ice->state.sample_mask = sample_mask & 0xff;
3272 ice->state.dirty |= CROCUS_DIRTY_GEN6_SAMPLE_MASK;
3276 crocus_fill_scissor_rect(struct crocus_context *ice,
3280 struct pipe_framebuffer_state *cso_fb = &ice->state.framebuffer;
3281 struct pipe_rasterizer_state *cso_state = &ice->state.cso_rast->cso;
3282 const struct pipe_viewport_state *vp = &ice->state.viewports[idx];
3290 struct pipe_scissor_state *s = &ice->state.scissors[idx];
3311 struct crocus_context *ice = (struct crocus_context *) ctx;
3321 ice->state.scissors[start_slot + i] = (struct pipe_scissor_state) {
3325 ice->state.scissors[start_slot + i] = (struct pipe_scissor_state) {
3333 ice->state.dirty |= CROCUS_DIRTY_RASTER; /* SF state */
3335 ice->state.dirty |= CROCUS_DIRTY_GEN6_SCISSOR_RECT;
3337 ice->state.dirty |= CROCUS_DIRTY_SF_CL_VIEWPORT;
3350 struct crocus_context *ice = (struct crocus_context *) ctx;
3351 ice->state.stencil_ref = ref;
3352 ice->state.dirty |= CROCUS_DIRTY_COLOR_CALC_STATE;
3376 struct crocus_context *ice = (struct crocus_context *) ctx;
3378 memcpy(&ice->state.viewports[start_slot], states, sizeof(*states) * count);
3380 ice->state.dirty |= CROCUS_DIRTY_SF_CL_VIEWPORT;
3381 ice->state.dirty |= CROCUS_DIRTY_RASTER;
3383 ice->state.dirty |= CROCUS_DIRTY_GEN6_SCISSOR_RECT;
3386 if (ice->state.cso_rast && (!ice->state.cso_rast->cso.depth_clip_near ||
3387 !ice->state.cso_rast->cso.depth_clip_far))
3388 ice->state.dirty |= CROCUS_DIRTY_CC_VIEWPORT;
3401 struct crocus_context *ice = (struct crocus_context *) ctx;
3402 struct pipe_framebuffer_state *cso = &ice->state.framebuffer;
3416 ice->state.dirty |= CROCUS_DIRTY_GEN6_MULTISAMPLE;
3417 ice->state.dirty |= CROCUS_DIRTY_GEN6_SAMPLE_MASK;
3418 ice->state.dirty |= CROCUS_DIRTY_RASTER;
3420 ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_FS;
3426 ice->state.dirty |= CROCUS_DIRTY_GEN6_BLEND_STATE;
3430 ice->state.dirty |= CROCUS_DIRTY_CLIP;
3434 ice->state.dirty |= CROCUS_DIRTY_SF_CL_VIEWPORT;
3435 ice->state.dirty |= CROCUS_DIRTY_RASTER;
3436 ice->state.dirty |= CROCUS_DIRTY_DRAWING_RECTANGLE;
3438 ice->state.dirty |= CROCUS_DIRTY_GEN6_SCISSOR_RECT;
3443 ice->state.dirty |= CROCUS_DIRTY_DEPTH_BUFFER;
3447 ice->state.dirty |= CROCUS_DIRTY_RASTER;
3451 ice->state.dirty |= CROCUS_DIRTY_WM;
3465 ice->state.hiz_usage = aux_usage;
3469 ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_BINDINGS_FS;
3471 ice->state.dirty |= CROCUS_DIRTY_RENDER_RESOLVES_AND_FLUSHES;
3473 ice->state.stage_dirty |= ice->state.stage_dirty_for_nos[CROCUS_NOS_FRAMEBUFFER];
3488 struct crocus_context *ice = (struct crocus_context *) ctx;
3490 struct crocus_shader_state *shs = &ice->state.shaders[stage];
3501 u_upload_alloc(ice->ctx.const_uploader, 0, input->buffer_size, 64,
3524 ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_CONSTANTS_VS << stage;
3528 upload_sysvals(struct crocus_context *ice,
3531 UNUSED struct crocus_genx_state *genx = ice->state.genx;
3532 struct crocus_shader_state *shs = &ice->state.shaders[stage];
3534 struct crocus_compiled_shader *shader = ice->shaders.prog[stage];
3546 u_upload_alloc(ice->ctx.const_uploader, 0, upload_size, 64,
3568 value = fui(ice->state.clip_planes.ucp[plane][comp]);
3571 value = ice->state.vertices_per_patch;
3575 crocus_get_shader_info(ice, MESA_SHADER_TESS_CTRL);
3579 value = ice->state.vertices_per_patch;
3584 value = fui(ice->state.default_outer_level[i]);
3586 value = fui(ice->state.default_inner_level[0]);
3588 value = fui(ice->state.default_inner_level[1]);
3592 value = ice->state.last_block[i];
3617 struct crocus_context *ice = (struct crocus_context *) ctx;
3619 struct crocus_shader_state *shs = &ice->state.shaders[stage];
3648 ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_BINDINGS_VS << stage;
3669 struct crocus_context *ice = (struct crocus_context *) ctx;
3673 ice->state.bound_vertex_buffers &=
3676 util_set_vertex_buffers_mask(ice->state.vertex_buffers, &ice->state.bound_vertex_buffers,
3682 &ice->state.vertex_buffers[start_slot + i];
3692 ice->state.vb_end[start_slot + i] = end;
3694 ice->state.dirty |= CROCUS_DIRTY_VERTEX_BUFFERS;
3921 struct crocus_context *ice = (struct crocus_context *) ctx;
3923 struct crocus_vertex_element_state *old_cso = ice->state.cso_vertex_elements;
3927 ice->state.dirty |= CROCUS_DIRTY_GEN8_VF_SGVS;
3929 ice->state.cso_vertex_elements = state;
3930 ice->state.dirty |= CROCUS_DIRTY_VERTEX_ELEMENTS | CROCUS_DIRTY_VERTEX_BUFFERS;
3931 ice->state.stage_dirty |= ice->state.stage_dirty_for_nos[CROCUS_NOS_VERTEX_ELEMENTS];
3990 compute_vertices_written_so_far(struct crocus_context *ice,
3999 struct crocus_context *ice = (void *)so->context;
4002 compute_vertices_written_so_far(ice, tgt, &tgt->prev_count, &vert_written);
4037 struct crocus_context *ice = (struct crocus_context *) ctx;
4039 u_upload_alloc(ice->ctx.stream_uploader, 0, sizeof(uint32_t), 4,
4072 batch->ice->ctx.flush(&batch->ice->ctx, &out_fence, 0);
4073 batch->screen->base.fence_finish(&batch->screen->base, &batch->ice->ctx, out_fence, UINT64_MAX);
4088 u_upload_alloc(batch->ice->ctx.stream_uploader, 0, 4096, 4,
4108 compute_vertices_written_so_far(struct crocus_context *ice,
4114 aggregate_stream_counter(&ice->batches[0], tgt, counter);
4116 *svbi = counter->accum * ice->state.last_xfb_verts_per_prim;
4132 struct crocus_context *ice = (struct crocus_context *) ctx;
4133 struct crocus_batch *batch = &ice->batches[CROCUS_BATCH_RENDER];
4136 if (ice->state.streamout_active != active) {
4137 ice->state.streamout_active = active;
4139 ice->state.dirty |= CROCUS_DIRTY_STREAMOUT;
4141 ice->state.dirty |= CROCUS_DIRTY_GEN4_FF_GS_PROG;
4151 ice->state.dirty |= CROCUS_DIRTY_SO_DECL_LIST;
4157 (void *) ice->state.so_target[i];
4162 crocus_dirty_for_history(ice, res);
4165 crocus_emit_pipe_control_flush(&ice->batches[CROCUS_BATCH_RENDER],
4170 ice->state.so_targets = num_targets;
4172 pipe_so_target_reference(&old_tgt[i], ice->state.so_target[i]);
4173 pipe_so_target_reference(&ice->state.so_target[i],
4182 (void *) ice->state.so_target[i];
4192 ice->state.svbi = 0;
4195 compute_vertices_written_so_far(ice, tgt, &tgt->count, &ice->state.svbi);
4220 ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_BINDINGS_GS;
4225 (void *) ice->state.so_target[i];
4253 ice->state.dirty |= CROCUS_DIRTY_GEN7_SO_BUFFERS;
4255 ice->state.dirty |= CROCUS_DIRTY_GEN6_SVBI;
4401 crocus_emit_so_svbi(struct crocus_context *ice)
4403 struct crocus_batch *batch = &ice->batches[CROCUS_BATCH_RENDER];
4408 (void *) ice->state.so_target[i];
4415 svbi.StreamedVertexBufferIndex = (uint32_t)ice->state.svbi; /* fix when resuming, based on target's prim count */
4436 crocus_is_drawing_points(const struct crocus_context *ice)
4438 const struct crocus_rasterizer_state *cso_rast = ice->state.cso_rast;
4444 if (ice->shaders.prog[MESA_SHADER_GEOMETRY]) {
4446 (void *) ice->shaders.prog[MESA_SHADER_GEOMETRY]->prog_data;
4448 } else if (ice->shaders.prog[MESA_SHADER_TESS_EVAL]) {
4450 (void *) ice->shaders.prog[MESA_SHADER_TESS_EVAL]->prog_data;
4453 return ice->state.prim_mode == PIPE_PRIM_POINTS;
4555 const struct crocus_context *ice,
4562 ice->shaders.prog[MESA_SHADER_FRAGMENT]->prog_data;
4563 const struct brw_vue_map *vue_map = ice->shaders.last_vue_map;
4564 const struct crocus_rasterizer_state *cso_rast = ice->state.cso_rast;
4567 crocus_get_shader_info(ice, MESA_SHADER_FRAGMENT);
4584 if (crocus_is_drawing_points(ice)) {
4635 crocus_emit_sbe(struct crocus_batch *batch, const struct crocus_context *ice)
4637 const struct crocus_rasterizer_state *cso_rast = ice->state.cso_rast;
4639 ice->shaders.prog[MESA_SHADER_FRAGMENT]->prog_data;
4655 calculate_attr_overrides(ice,
4684 crocus_populate_vs_key(const struct crocus_context *ice,
4689 const struct crocus_rasterizer_state *cso_rast = ice->state.cso_rast;
4713 key->gl_attrib_wa_flags[i] = ice->state.cso_vertex_elements->wa_flags[ve_idx];
4723 crocus_populate_tcs_key(const struct crocus_context *ice,
4732 crocus_populate_tes_key(const struct crocus_context *ice,
4737 const struct crocus_rasterizer_state *cso_rast = ice->state.cso_rast;
4753 crocus_populate_gs_key(const struct crocus_context *ice,
4758 const struct crocus_rasterizer_state *cso_rast = ice->state.cso_rast;
4774 crocus_populate_fs_key(const struct crocus_context *ice,
4778 struct crocus_screen *screen = (void *) ice->ctx.screen;
4779 const struct pipe_framebuffer_state *fb = &ice->state.framebuffer;
4780 const struct crocus_depth_stencil_alpha_state *zsa = ice->state.cso_zsa;
4781 const struct crocus_rasterizer_state *rast = ice->state.cso_rast;
4782 const struct crocus_blend_state *blend = ice->state.cso_blend;
4806 key->stats_wm = ice->state.stats_wm;
4811 int reduced_prim = ice->state.reduced_prim_mode;
4862 crocus_populate_cs_key(const struct crocus_context *ice,
4868 #define KSP(ice, shader) ro_bo((ice)->shaders.cache_bo, (shader)->offset);
4871 KSP(const struct crocus_context *ice, const struct crocus_compiled_shader *shader)
4885 pkt.KernelStartPointer = KSP(ice, shader); \
4899 crocus_get_scratch_space(ice, prog_data->total_scratch, stage); \
4942 struct crocus_context *ice,
4947 if (ice->state.framebuffer.width == 0 && ice->state.framebuffer.height == 0) {
4952 struct pipe_framebuffer_state *cso = &ice->state.framebuffer;
5120 emit_grid(struct crocus_context *ice,
5125 struct crocus_state_ref *grid_ref = &ice->state.grid_size;
5141 emit_ubo_buffer(struct crocus_context *ice,
5165 emit_ssbo_buffer(struct crocus_context *ice,
5192 emit_sampler_view(struct crocus_context *ice,
5232 emit_image_view(struct crocus_context *ice,
5291 struct crocus_context *ice = batch->ice;
5293 if (idx >= so_info->num_outputs || !ice->state.streamout_active)
5299 struct crocus_resource *buf = (struct crocus_resource *)ice->state.so_target[buffer]->buffer;
5301 unsigned offset_dwords = ice->state.so_target[buffer]->buffer_offset / 4 + output->dst_offset;
5303 size_t size_dwords = (ice->state.so_target[buffer]->buffer_offset + ice->state.so_target[buffer]->buffer_size) / 4;
5371 crocus_populate_binding_table(struct crocus_context *ice,
5375 struct crocus_compiled_shader *shader = ff_gs ? ice->shaders.ff_gs_prog : ice->shaders.prog[stage];
5376 struct crocus_shader_state *shs = ff_gs ? NULL : &ice->state.shaders[stage];
5385 const struct shader_info *info = crocus_get_shader_info(ice, stage);
5389 struct pipe_framebuffer_state *cso_fb = &ice->state.framebuffer;
5397 &ice->state.cso_blend->cso.rt[ice->state.cso_blend->cso.independent_blend_enable ? i : 0];
5398 struct crocus_compiled_shader *shader = ice->shaders.prog[MESA_SHADER_FRAGMENT];
5410 ice->state.draw_aux_usage[i],
5414 emit_null_fb_surface(batch, ice, &surf_offsets[s]);
5419 emit_null_fb_surface(batch, ice, &surf_offsets[s]);
5424 struct pipe_framebuffer_state *cso_fb = &ice->state.framebuffer;
5428 ice->state.draw_aux_usage[i]);
5435 surf_offsets[s] = emit_grid(ice, batch);
5443 if (ice->shaders.uncompiled[MESA_SHADER_GEOMETRY])
5444 so_info = &ice->shaders.uncompiled[MESA_SHADER_GEOMETRY]->stream_output;
5446 so_info = &ice->shaders.uncompiled[MESA_SHADER_VERTEX]->stream_output;
5458 surf_offsets[s] = emit_sampler_view(ice, batch, false, view);
5469 surf_offsets[s] = emit_sampler_view(ice, batch, true, view);
5480 surf_offsets[s] = emit_image_view(ice, batch, view);
5487 surf_offsets[s] = emit_ubo_buffer(ice, batch, &shs->constbufs[i]);
5494 surf_offsets[s] = emit_ssbo_buffer(ice, batch, &shs->ssbo[i],
5504 crocus_upload_binding_table(struct crocus_context *ice,
5545 sba.InstructionBaseAddress = ro_bo(batch->ice->shaders.cache_bo, 0); // TODO!
5618 batch->ice->state.dirty |= CROCUS_DIRTY_GEN5_PIPELINED_POINTERS | CROCUS_DIRTY_GEN5_BINDING_TABLE_POINTERS;
5620 batch->ice->state.dirty |= CROCUS_DIRTY_GEN5_BINDING_TABLE_POINTERS | CROCUS_DIRTY_GEN6_SAMPLER_STATE_POINTERS;
5648 setup_constant_buffers(struct crocus_context *ice,
5653 struct crocus_shader_state *shs = &ice->state.shaders[stage];
5654 struct crocus_compiled_shader *shader = ice->shaders.prog[stage];
5684 : ro_bo(batch->ice->workaround_bo,
5685 batch->ice->workaround_offset);
5707 batch->ice->workaround_bo,
5708 batch->ice->workaround_offset, 0);
5713 emit_push_constant_packets(struct crocus_context *ice,
5718 struct crocus_compiled_shader *shader = ice->shaders.prog[stage];
5786 set_depth_stencil_bits(struct crocus_context *ice, DEPTH_STENCIL_GENXML *ds)
5788 struct crocus_depth_stencil_alpha_state *cso = ice->state.cso_zsa;
5852 determine_sample_mask(struct crocus_context *ice)
5854 uint32_t num_samples = ice->state.framebuffer.samples;
5860 return ice->state.sample_mask & fb_mask;
5865 crocus_upload_dirty_render_state(struct crocus_context *ice,
5869 uint64_t dirty = ice->state.dirty;
5870 uint64_t stage_dirty = ice->state.stage_dirty;
5894 bool ret = crocus_calculate_urb_fence(batch, ice->curbe.total_size,
5895 brw_vue_prog_data(ice->shaders.prog[MESA_SHADER_VERTEX]->prog_data)->urb_entry_size,
5896 ((struct brw_sf_prog_data *)ice->shaders.sf_prog->prog_data)->urb_entry_size);
5904 const struct crocus_rasterizer_state *cso_rast = ice->state.cso_rast;
5910 4 * ice->state.num_viewports *
5912 for (int i = 0; i < ice->state.num_viewports; i++) {
5914 crocus_viewport_zmin_zmax(&ice->state.viewports[i], cso_rast->cso.clip_halfz,
5915 ice->state.window_space_position,
5940 ice->state.cc_vp_address = cc_vp_address;
5946 struct pipe_framebuffer_state *cso_fb = &ice->state.framebuffer;
5951 4 * ice->state.num_viewports *
5956 4 * ice->state.num_viewports * GENX(SF_VIEWPORT_length),
5957 32, &ice->state.sf_vp_address);
5960 4 * ice->state.num_viewports * GENX(CLIP_VIEWPORT_length),
5961 32, &ice->state.clip_vp_address);
5964 for (unsigned i = 0; i < ice->state.num_viewports; i++) {
5965 const struct pipe_viewport_state *state = &ice->state.viewports[i];
5992 crocus_fill_scissor_rect(ice, 0, &scissor);
6035 vp.PointertoCLIP_VIEWPORT = ice->state.clip_vp_address;
6036 vp.PointertoSF_VIEWPORT = ice->state.sf_vp_address;
6044 bool gs_present = ice->shaders.prog[MESA_SHADER_GEOMETRY] != NULL
6045 || ice->shaders.ff_gs_prog;
6048 (void *) ice->shaders.prog[MESA_SHADER_VERTEX]->prog_data;
6051 if (ice->shaders.prog[MESA_SHADER_GEOMETRY]) {
6053 (void *) ice->shaders.prog[MESA_SHADER_GEOMETRY]->prog_data;
6061 bool gs_present = ice->shaders.prog[MESA_SHADER_GEOMETRY] != NULL;
6062 bool tess_present = ice->shaders.prog[MESA_SHADER_TESS_EVAL] != NULL;
6066 if (!ice->shaders.prog[i]) {
6070 (void *) ice->shaders.prog[i]->prog_data;
6080 if (ice->urb.vsize == entry_size[MESA_SHADER_VERTEX] &&
6081 ice->urb.gs_present == gs_present &&
6082 ice->urb.gsize == entry_size[MESA_SHADER_GEOMETRY] &&
6083 ice->urb.tess_present == tess_present &&
6084 ice->urb.hsize == entry_size[MESA_SHADER_TESS_CTRL] &&
6085 ice->urb.dsize == entry_size[MESA_SHADER_TESS_EVAL]) {
6090 ice->urb.vsize = entry_size[MESA_SHADER_VERTEX];
6091 ice->urb.gs_present = gs_present;
6092 ice->urb.gsize = entry_size[MESA_SHADER_GEOMETRY];
6093 ice->urb.tess_present = tess_present;
6094 ice->urb.hsize = entry_size[MESA_SHADER_TESS_CTRL];
6095 ice->urb.dsize = entry_size[MESA_SHADER_TESS_EVAL];
6124 struct crocus_blend_state *cso_blend = ice->state.cso_blend;
6125 struct pipe_framebuffer_state *cso_fb = &ice->state.framebuffer;
6126 struct crocus_depth_stencil_alpha_state *cso_zsa = ice->state.cso_zsa;
6167 if (GFX_VER >= 8 || can_emit_logic_op(ice)) {
6208 struct crocus_depth_stencil_alpha_state *cso = ice->state.cso_zsa;
6209 UNUSED struct crocus_blend_state *cso_blend = ice->state.cso_blend;
6210 struct pipe_stencil_ref *p_stencil_refs = &ice->state.stencil_ref;
6225 set_depth_stencil_bits(ice, &cc);
6228 if (can_emit_logic_op(ice)) {
6237 if (cso->cso.alpha_enabled && ice->state.framebuffer.nr_cbufs <= 1) {
6241 cc.StatisticsEnable = ice->state.stats_wm ? 1 : 0;
6242 cc.CCViewportStatePointer = ro_bo(batch->state.bo, ice->state.cc_vp_address);
6247 cc.BlendConstantColorRed = ice->state.blend_color.color[0];
6248 cc.BlendConstantColorGreen = ice->state.blend_color.color[1];
6249 cc.BlendConstantColorBlue = ice->state.blend_color.color[2];
6250 cc.BlendConstantColorAlpha = ice->state.blend_color.color[3];
6255 ice->shaders.cc_offset = cc_offset;
6268 blend_cc.BlendConstantColorRed = ice->state.blend_color.color[0];
6269 blend_cc.BlendConstantColorGreen = ice->state.blend_color.color[1];
6270 blend_cc.BlendConstantColorBlue = ice->state.blend_color.color[2];
6271 blend_cc.BlendConstantColorAlpha = ice->state.blend_color.color[3];
6279 struct crocus_shader_state *shs = &ice->state.shaders[stage];
6280 struct crocus_compiled_shader *shader = ice->shaders.prog[stage];
6286 upload_sysvals(ice, stage);
6293 setup_constant_buffers(ice, batch, stage, &push_bos);
6295 emit_push_constant_packets(ice, batch, stage, &push_bos);
6301 if (ice->shaders.prog[stage]) {
6305 crocus_populate_binding_table(ice, batch, stage, false);
6306 ice->shaders.prog[stage]->bind_bo_offset =
6307 crocus_upload_binding_table(ice, batch,
6308 ice->shaders.prog[stage]->surf_offset,
6309 ice->shaders.prog[stage]->bt.size_bytes);
6314 ptr.PointertoVSBindingTable = ice->shaders.prog[stage]->bind_bo_offset;
6318 } else if (stage == MESA_SHADER_GEOMETRY && ice->shaders.ff_gs_prog) {
6320 crocus_populate_binding_table(ice, batch, stage, true);
6321 ice->shaders.ff_gs_prog->bind_bo_offset =
6322 crocus_upload_binding_table(ice, batch,
6323 ice->shaders.ff_gs_prog->surf_offset,
6324 ice->shaders.ff_gs_prog->bt.size_bytes);
6331 struct crocus_compiled_shader *gs = ice->shaders.prog[MESA_SHADER_GEOMETRY];
6333 gs = ice->shaders.ff_gs_prog;
6335 ptr.PointertoVSBindingTable = ice->shaders.prog[MESA_SHADER_VERTEX]->bind_bo_offset;
6336 ptr.PointertoPSBindingTable = ice->shaders.prog[MESA_SHADER_FRAGMENT]->bind_bo_offset;
6350 !ice->shaders.prog[stage])
6353 crocus_upload_sampler_states(ice, batch, stage);
6358 struct crocus_shader_state *shs = &ice->state.shaders[stage];
6369 struct crocus_shader_state *shs_vs = &ice->state.shaders[MESA_SHADER_VERTEX];
6370 struct crocus_shader_state *shs_gs = &ice->state.shaders[MESA_SHADER_GEOMETRY];
6371 struct crocus_shader_state *shs_fs = &ice->state.shaders[MESA_SHADER_FRAGMENT];
6373 if (ice->shaders.prog[MESA_SHADER_VERTEX] &&
6379 if (ice->shaders.prog[MESA_SHADER_GEOMETRY] &&
6385 if (ice->shaders.prog[MESA_SHADER_FRAGMENT] &&
6399 ice->state.cso_rast->cso.half_pixel_center ? CENTER : UL_CORNER;
6400 if (ice->state.framebuffer.samples > 0)
6401 ms.NumberofMultisamples = ffs(ice->state.framebuffer.samples) - 1;
6405 switch (ice->state.framebuffer.samples) {
6427 ms.SampleMask = determine_sample_mask(ice);
6433 struct crocus_compiled_shader *shader = ice->shaders.prog[MESA_SHADER_FRAGMENT];
6457 ps.KernelStartPointer0 = KSP(ice, shader) +
6459 ps.KernelStartPointer1 = KSP(ice, shader) +
6461 ps.KernelStartPointer2 = KSP(ice, shader) +
6465 ps.SampleMask = determine_sample_mask(ice);
6481 ps.DualSourceBlendEnable = wm_prog_data->dual_src_blend && ice->state.cso_blend->dual_color_blending;
6501 struct crocus_bo *bo = crocus_get_scratch_space(ice, wm_prog_data->base.total_scratch, MESA_SHADER_FRAGMENT);
6508 crocus_get_shader_info(ice, MESA_SHADER_FRAGMENT);
6553 !(has_writeable_rt(ice->state.cso_blend, fs_info)))
6561 if (ice->state.streamout_active) {
6565 (void *) ice->state.so_target[i];
6605 if ((dirty & CROCUS_DIRTY_SO_DECL_LIST) && ice->state.streamout) {
6607 ice->state.streamout + GENX(3DSTATE_STREAMOUT_length);
6612 const struct crocus_rasterizer_state *cso_rast = ice->state.cso_rast;
6620 !ice->state.prims_generated_query_active;
6624 assert(ice->state.streamout);
6626 crocus_emit_merge(batch, ice->state.streamout, dynamic_sol,
6636 if (ice->state.streamout_active) {
6638 crocus_emit_so_svbi(ice);
6645 const struct brw_clip_prog_data *clip_prog_data = (struct brw_clip_prog_data *)ice->shaders.clip_prog->prog_data;
6646 struct pipe_rasterizer_state *cso_state = &ice->state.cso_rast->cso;
6648 uint32_t *clip_ptr = stream_state(batch, GENX(CLIP_STATE_length) * 4, 32, &ice->shaders.clip_offset);
6651 clip.KernelStartPointer = KSP(ice, ice->shaders.clip_prog);
6661 clip.ConstantURBEntryReadOffset = ice->curbe.clip_start * 2;
6663 clip.NumberofURBEntries = batch->ice->urb.nr_clip_entries;
6664 clip.URBEntryAllocationSize = batch->ice->urb.vsize - 1;
6666 if (batch->ice->urb.nr_clip_entries >= 10) {
6670 assert(batch->ice->urb.nr_clip_entries % 2 == 0);
6677 assert(batch->ice->urb.nr_clip_entries >= 5);
6684 clip.ClipperViewportStatePointer = ro_bo(batch->state.bo, ice->state.clip_vp_address);
6711 struct crocus_rasterizer_state *cso_rast = ice->state.cso_rast;
6712 const struct brw_wm_prog_data *wm_prog_data = brw_wm_prog_data(ice->shaders.prog[MESA_SHADER_FRAGMENT]->prog_data );
6713 struct pipe_framebuffer_state *cso_fb = &ice->state.framebuffer;
6714 bool gs_or_tes = ice->shaders.prog[MESA_SHADER_GEOMETRY] ||
6715 ice->shaders.prog[MESA_SHADER_TESS_EVAL];
6717 (gs_or_tes ? ice->shaders.output_topology_is_points_or_lines
6718 : ice->state.prim_is_points_or_lines);
6721 cl.StatisticsEnable = ice->state.statistics_counters_enabled;
6724 else if (ice->state.window_space_position)
6729 cl.PerspectiveDivideDisable = ice->state.window_space_position;
6733 brw_vue_prog_data(ice->shaders.prog[MESA_SHADER_VERTEX]->prog_data)->cull_distance_mask;
6738 cl.MaximumVPIndex = ice->state.num_viewports - 1;
6746 struct crocus_compiled_shader *shader = ice->shaders.prog[MESA_SHADER_VERTEX];
6757 setup_constant_buffers(ice, batch, MESA_SHADER_VERTEX, &push_bos);
6759 emit_push_constant_packets(ice, batch, MESA_SHADER_VERTEX, &push_bos);
6765 GENX(VS_STATE_length) * 4, 32, &ice->shaders.vs_offset);
6777 vs.ConstantURBEntryReadOffset = ice->curbe.vs_start * 2;
6779 vs.NumberofURBEntries = batch->ice->urb.nr_vs_entries >> (GFX_VER == 5 ? 2 : 0);
6780 vs.URBEntryAllocationSize = batch->ice->urb.vsize - 1;
6783 CLAMP(batch->ice->urb.nr_vs_entries / 2, 1, batch->screen->devinfo.max_vs_threads) - 1;
6785 vs.SamplerStatePointer = ro_bo(batch->state.bo, ice->state.shaders[MESA_SHADER_VERTEX].sampler_offset);
6818 struct crocus_compiled_shader *shader = ice->shaders.prog[MESA_SHADER_GEOMETRY];
6823 setup_constant_buffers(ice, batch, MESA_SHADER_GEOMETRY, &push_bos);
6825 emit_push_constant_packets(ice, batch, MESA_SHADER_GEOMETRY, &push_bos);
6840 if (batch->screen->devinfo.gt == 2 && ice->state.gs_enabled != active)
6847 GENX(GS_STATE_length) * 4, 32, &ice->shaders.gs_offset);
6906 gs.SVBIPayloadEnable = ice->state.streamout_active;
6940 if (!active && ice->shaders.ff_gs_prog) {
6941 const struct brw_ff_gs_prog_data *gs_prog_data = (struct brw_ff_gs_prog_data *)ice->shaders.ff_gs_prog->prog_data;
6946 gs.KernelStartPointer = KSP(ice, ice->shaders.ff_gs_prog);
6955 gs.NumberofURBEntries = batch->ice->urb.nr_gs_entries;
6956 gs.URBEntryAllocationSize = batch->ice->urb.vsize - 1;
6957 gs.MaximumNumberofThreads = batch->ice->urb.nr_gs_entries >= 8 ? 1 : 0;
6970 if (!active && !ice->shaders.ff_gs_prog) {
6985 gs.MaximumVPIndex = ice->state.num_viewports - 1;
6988 ice->state.gs_enabled = active;
6993 struct crocus_compiled_shader *shader = ice->shaders.prog[MESA_SHADER_TESS_CTRL];
7013 struct crocus_compiled_shader *shader = ice->shaders.prog[MESA_SHADER_TESS_EVAL];
7050 const struct brw_sf_prog_data *sf_prog_data = (struct brw_sf_prog_data *)ice->shaders.sf_prog->prog_data;
7051 struct pipe_rasterizer_state *cso_state = &ice->state.cso_rast->cso;
7053 GENX(SF_STATE_length) * 4, 32, &ice->shaders.sf_offset);
7056 sf.KernelStartPointer = KSP(ice, ice->shaders.sf_prog);
7062 sf.URBEntryAllocationSize = batch->ice->urb.sfsize - 1;
7063 sf.NumberofURBEntries = batch->ice->urb.nr_sf_entries;
7066 sf.SetupViewportStateOffset = ro_bo(batch->state.bo, ice->state.sf_vp_address);
7069 MIN2(GFX_VER == 5 ? 48 : 24, batch->ice->urb.nr_sf_entries) - 1;
7100 struct crocus_rasterizer_state *cso = ice->state.cso_rast;
7103 sf.ViewportTransformEnable = !ice->state.window_space_position;
7106 const struct brw_wm_prog_data *wm_prog_data = brw_wm_prog_data(ice->shaders.prog[MESA_SHADER_FRAGMENT]->prog_data);
7110 calculate_attr_overrides(ice, sf.Attribute, &point_sprite_enables,
7121 if (ice->state.framebuffer.samples > 1 && ice->state.cso_rast->cso.multisample)
7125 if (ice->state.framebuffer.zsbuf) {
7128 ice->state.framebuffer.zsbuf->texture,
7146 struct crocus_rasterizer_state *cso = ice->state.cso_rast;
7147 const struct brw_wm_prog_data *wm_prog_data = brw_wm_prog_data(ice->shaders.prog[MESA_SHADER_FRAGMENT]->prog_data);
7150 crocus_get_shader_info(ice, MESA_SHADER_FRAGMENT);
7154 setup_constant_buffers(ice, batch, MESA_SHADER_FRAGMENT, &push_bos);
7156 emit_push_constant_packets(ice, batch, MESA_SHADER_FRAGMENT, &push_bos);
7162 GENX(WM_STATE_length) * 4, 32, &ice->shaders.wm_offset);
7177 wm.KernelStartPointer0 = KSP(ice, ice->shaders.prog[MESA_SHADER_FRAGMENT]);
7183 wm.KernelStartPointer0 = KSP(ice, ice->shaders.prog[MESA_SHADER_FRAGMENT]) +
7185 wm.KernelStartPointer1 = KSP(ice, ice->shaders.prog[MESA_SHADER_FRAGMENT]) +
7187 wm.KernelStartPointer2 = KSP(ice, ice->shaders.prog[MESA_SHADER_FRAGMENT]) +
7197 wm.KernelStartPointer0 = KSP(ice, ice->shaders.prog[MESA_SHADER_FRAGMENT]) +
7199 wm.KernelStartPointer1 = KSP(ice, ice->shaders.prog[MESA_SHADER_FRAGMENT]) +
7201 wm.KernelStartPointer2 = KSP(ice, ice->shaders.prog[MESA_SHADER_FRAGMENT]) +
7213 wm.ConstantURBEntryReadOffset = ice->curbe.wm_start * 2;
7233 ice->state.shaders[MESA_SHADER_FRAGMENT].sampler_offset);
7236 wm.StatisticsEnable = (GFX_VER >= 6 || ice->state.stats_wm) ?
7237 ice->state.statistics_counters_enabled : 0;
7248 ice->state.cso_blend->dual_color_blending;
7275 wm.BindingTableEntryCount = ice->shaders.prog[MESA_SHADER_FRAGMENT]->bt.size_bytes / 4;
7283 struct pipe_framebuffer_state *fb = &ice->state.framebuffer;
7303 ice->state.cso_zsa->cso.alpha_enabled ||
7304 ice->state.cso_blend->cso.alpha_to_coverage ||
7308 if (has_writeable_rt(ice->state.cso_blend, fs_info) ||
7318 struct crocus_bo *bo = crocus_get_scratch_space(ice, wm_prog_data->base.total_scratch,
7337 if (!(has_writeable_rt(ice->state.cso_blend, fs_info) || writes_depth) &&
7357 if (ice->state.global_depth_offset_clamp != cso->cso.offset_clamp) {
7361 ice->state.global_depth_offset_clamp = cso->cso.offset_clamp;
7368 crocus_emit_sbe(batch, ice);
7374 struct crocus_compiled_shader *shader = ice->shaders.prog[MESA_SHADER_FRAGMENT];
7375 struct crocus_blend_state *cso_blend = ice->state.cso_blend;
7376 struct crocus_depth_stencil_alpha_state *cso_zsa = ice->state.cso_zsa;
7379 crocus_get_shader_info(ice, MESA_SHADER_FRAGMENT);
7397 set_depth_stencil_bits(ice, &wmds);
7405 set_depth_stencil_bits(ice, &ds);
7425 stream_state(batch, sizeof(struct pipe_scissor_state) * ice->state.num_viewports,
7427 for (int i = 0; i < ice->state.num_viewports; i++) {
7429 crocus_fill_scissor_rect(ice, i, &scissor);
7446 struct pipe_framebuffer_state *cso = &ice->state.framebuffer;
7538 poly.PatternRow[i] = ice->state.poly_stipple.stipple[i];
7544 struct crocus_rasterizer_state *cso = ice->state.cso_rast;
7552 translate_prim_type(draw->mode, ice->state.patch_vertices);
7559 upload_pipelined_state_pointers(batch, ice->shaders.ff_gs_prog ? true : false, ice->shaders.gs_offset,
7560 ice->shaders.vs_offset, ice->shaders.sf_offset,
7561 ice->shaders.clip_offset, ice->shaders.wm_offset, ice->shaders.cc_offset);
7565 cs.NumberofURBEntries = ice->urb.nr_cs_entries;
7566 cs.URBEntryAllocationSize = ice->urb.csize - 1;
7572 struct pipe_framebuffer_state *fb = &ice->state.framebuffer;
7582 const uint32_t user_count = util_bitcount(ice->state.bound_vertex_buffers);
7584 ice->state.vs_uses_draw_params + ice->state.vs_uses_derived_draw_params;
7585 uint32_t dynamic_bound = ice->state.bound_vertex_buffers;
7601 struct pipe_vertex_buffer *buf = &ice->state.vertex_buffers[i];
7603 uint32_t step_rate = ice->state.cso_vertex_elements->step_rate[i];
7607 ice->state.vb_end[i],
7613 if (ice->state.vs_uses_draw_params) {
7614 struct crocus_resource *res = (struct crocus_resource *)ice->draw.draw_params.res;
7617 ice->draw.draw_params.offset,
7618 ice->draw.draw_params.res->width0,
7621 if (ice->state.vs_uses_derived_draw_params) {
7622 struct crocus_resource *res = (struct crocus_resource *)ice->draw.derived_draw_params.res;
7625 ice->draw.derived_draw_params.offset,
7626 ice->draw.derived_draw_params.res->width0,
7633 struct crocus_vertex_element_state *cso = ice->state.cso_vertex_elements;
7635 if (!(ice->state.vs_needs_sgvs_element ||
7636 ice->state.vs_uses_derived_draw_params ||
7637 ice->state.vs_needs_edge_flag)) {
7643 ice->state.vs_needs_sgvs_element +
7644 ice->state.vs_uses_derived_draw_params;
7652 (cso->count - ice->state.vs_needs_edge_flag) *
7655 &dynamic_ves[1 + (cso->count - ice->state.vs_needs_edge_flag) *
7658 if (ice->state.vs_needs_sgvs_element) {
7659 uint32_t base_ctrl = ice->state.vs_uses_draw_params ?
7664 util_bitcount64(ice->state.bound_vertex_buffers);
7669 ve.Component2Control = ice->state.vs_uses_vertexid ? VFCOMP_STORE_VID : VFCOMP_STORE_0;
7670 ve.Component3Control = ice->state.vs_uses_instanceid ? VFCOMP_STORE_IID : VFCOMP_STORE_0;
7681 if (ice->state.vs_uses_derived_draw_params) {
7685 util_bitcount64(ice->state.bound_vertex_buffers) +
7686 ice->state.vs_uses_draw_params;
7693 ve.DestinationElementOffset = (cso->count + ice->state.vs_needs_sgvs_element) * 4;
7698 if (ice->state.vs_needs_edge_flag) {
7708 if (!ice->state.vs_needs_edge_flag) {
7722 ice->state.vs_needs_sgvs_element +
7723 ice->state.vs_uses_derived_draw_params;
7737 ice->shaders.prog[MESA_SHADER_VERTEX]->prog_data;
7738 struct crocus_vertex_element_state *cso = ice->state.cso_vertex_elements;
7745 cso->count - ice->state.vs_needs_edge_flag;
7752 cso->count - ice->state.vs_needs_edge_flag;
7770 bool enable = want_pma_fix(ice);
7771 genX(crocus_update_pma_fix)(ice, batch, enable);
7783 crocus_upload_render_state(struct crocus_context *ice,
7791 bool use_predicate = ice->state.predicate == CROCUS_PREDICATE_STATE_USE_BIT;
7799 crocus_upload_dirty_render_state(ice, batch, draw);
7809 u_upload_data(ice->ctx.stream_uploader, 0,
7812 &offset, &ice->state.index_buffer.res);
7819 if (ice->state.index_buffer.res != draw->index.resource) {
7821 pipe_resource_reference(&ice->state.index_buffer.res,
7830 (ice->state.index_buffer.size != size ||
7831 ice->state.index_buffer.index_size != draw->index_size
7833 || ice->state.index_buffer.prim_restart != draw->primitive_restart
7840 struct crocus_bo *bo = crocus_resource_bo(ice->state.index_buffer.res);
7857 ice->state.index_buffer.size = size;
7858 ice->state.index_buffer.offset = offset;
7859 ice->state.index_buffer.index_size = draw->index_size;
7861 ice->state.index_buffer.prim_restart = draw->primitive_restart;
7886 if (ice->state.predicate == CROCUS_PREDICATE_STATE_USE_BIT) {
8021 prim.PrimitiveTopologyType = translate_prim_type(ice->state.prim_mode, ice->state.patch_vertices);
8046 crocus_upload_compute_state(struct crocus_context *ice,
8050 const uint64_t stage_dirty = ice->state.stage_dirty;
8053 struct crocus_shader_state *shs = &ice->state.shaders[MESA_SHADER_COMPUTE];
8055 ice->shaders.prog[MESA_SHADER_COMPUTE];
8063 upload_sysvals(ice, MESA_SHADER_COMPUTE);
8066 crocus_populate_binding_table(ice, batch, MESA_SHADER_COMPUTE, false);
8067 ice->shaders.prog[MESA_SHADER_COMPUTE]->bind_bo_offset =
8068 crocus_upload_binding_table(ice, batch,
8069 ice->shaders.prog[MESA_SHADER_COMPUTE]->surf_offset,
8070 ice->shaders.prog[MESA_SHADER_COMPUTE]->bt.size_bytes);
8074 crocus_upload_sampler_states(ice, batch, MESA_SHADER_COMPUTE);
8093 crocus_get_scratch_space(ice, prog_data->total_scratch,
8163 const uint64_t ksp = KSP(ice,shader) + brw_cs_prog_data_prog_offset(cs_prog_data, dispatch.simd_size);
8167 idd.BindingTablePointer = ice->shaders.prog[MESA_SHADER_COMPUTE]->bind_bo_offset;
8192 struct crocus_state_ref *grid_size = &ice->state.grid_size;
8277 crocus_destroy_state(struct crocus_context *ice)
8279 pipe_resource_reference(&ice->draw.draw_params.res, NULL);
8280 pipe_resource_reference(&ice->draw.derived_draw_params.res, NULL);
8282 free(ice->state.genx);
8285 pipe_so_target_reference(&ice->state.so_target[i], NULL);
8288 for (unsigned i = 0; i < ice->state.framebuffer.nr_cbufs; i++) {
8289 pipe_surface_reference(&ice->state.framebuffer.cbufs[i], NULL);
8291 pipe_surface_reference(&ice->state.framebuffer.zsbuf, NULL);
8294 struct crocus_shader_state *shs = &ice->state.shaders[stage];
8311 pipe_resource_reference(&ice->state.vertex_buffers[i].buffer.resource, NULL);
8312 pipe_resource_reference(&ice->state.grid_size.res, NULL);
8314 pipe_resource_reference(&ice->state.index_buffer.res, NULL);
8320 crocus_rebind_buffer(struct crocus_context *ice,
8323 struct pipe_context *ctx = &ice->ctx;
8339 uint64_t bound_vbs = ice->state.bound_vertex_buffers;
8342 struct pipe_vertex_buffer *buffer = &ice->state.vertex_buffers[i];
8345 ice->state.dirty |= CROCUS_DIRTY_VERTEX_BUFFERS;
8350 ice->state.index_buffer.res) {
8351 if (res->bo == crocus_resource_bo(ice->state.index_buffer.res))
8352 pipe_resource_reference(&ice->state.index_buffer.res, NULL);
8362 if (ice->state.so_target[i] &&
8363 (ice->state.so_target[i]->buffer == &res->base.b)) {
8365 ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_BINDINGS_GS;
8367 ice->state.dirty |= CROCUS_DIRTY_GEN7_SO_BUFFERS;
8374 struct crocus_shader_state *shs = &ice->state.shaders[s];
8388 ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_CONSTANTS_VS << s;
8419 ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_BINDINGS_VS << s;
8432 ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_BINDINGS_VS << s;
8533 bo = batch->ice->workaround_bo;
8534 offset = batch->ice->workaround_offset;
8918 struct crocus_context *ice = batch->ice;
8920 int total_urb_size = ice->urb.size * 1024; /* in bytes */
8940 ice->urb.nr_vs_entries = ROUND_DOWN_TO(nr_vs_entries, 4);
8941 ice->urb.nr_gs_entries = ROUND_DOWN_TO(nr_gs_entries, 4);
8943 assert(ice->urb.nr_vs_entries >=
8945 assert(ice->urb.nr_vs_entries % 4 == 0);
8946 assert(ice->urb.nr_gs_entries % 4 == 0);
8951 urb.VSNumberofURBEntries = ice->urb.nr_vs_entries;
8954 urb.GSNumberofURBEntries = ice->urb.nr_gs_entries;
8969 if (ice->urb.gs_present && !gs_present)
8971 ice->urb.gs_present = gs_present;
8976 crocus_lost_genx_state(struct crocus_context *ice, struct crocus_batch *batch)
9044 struct crocus_context *ice = batch->ice;
9045 ice->state.stage_dirty |= (CROCUS_STAGE_DIRTY_CONSTANTS_VS |
9061 ptr.ColorCalcStatePointer = batch->ice->shaders.cc_offset;
9076 pipe_resource_reference(&batch->ice->state.index_buffer.res, NULL);
9081 batch->ice->state.dirty |= CROCUS_DIRTY_DEPTH_BUFFER |
9084 batch->ice->state.dirty |= CROCUS_DIRTY_VERTEX_ELEMENTS | CROCUS_DIRTY_VERTEX_BUFFERS;
9086 batch->ice->state.stage_dirty |= CROCUS_ALL_STAGE_DIRTY_BINDINGS;
9087 batch->ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_SAMPLER_STATES_VS;
9088 batch->ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_SAMPLER_STATES_TES;
9089 batch->ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_SAMPLER_STATES_TCS;
9090 batch->ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_SAMPLER_STATES_GS;
9091 batch->ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_SAMPLER_STATES_PS;
9092 batch->ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_SAMPLER_STATES_CS;
9094 batch->ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_CONSTANTS_VS;
9095 batch->ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_CONSTANTS_TES;
9096 batch->ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_CONSTANTS_TCS;
9097 batch->ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_CONSTANTS_GS;
9098 batch->ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_CONSTANTS_FS;
9099 batch->ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_CONSTANTS_CS;
9101 batch->ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_VS;
9102 batch->ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_GS;
9103 batch->ice->state.stage_dirty |= CROCUS_STAGE_DIRTY_CS;
9104 batch->ice->state.dirty |= CROCUS_DIRTY_CC_VIEWPORT | CROCUS_DIRTY_SF_CL_VIEWPORT;
9108 batch->ice->state.dirty |= CROCUS_DIRTY_GEN6_BLEND_STATE;
9109 batch->ice->state.dirty |= CROCUS_DIRTY_GEN6_SCISSOR_RECT;
9110 batch->ice->state.dirty |= CROCUS_DIRTY_GEN6_WM_DEPTH_STENCIL;
9115 batch->ice->state.dirty |= CROCUS_DIRTY_RASTER;
9116 batch->ice->state.dirty |= CROCUS_DIRTY_GEN4_CURBE;
9117 batch->ice->state.dirty |= CROCUS_DIRTY_CLIP;
9118 batch->ice->state.dirty |= CROCUS_DIRTY_WM;
9122 batch->ice->state.dirty |= CROCUS_DIRTY_STREAMOUT;
9123 batch->ice->state.dirty |= CROCUS_DIRTY_SO_DECL_LIST;
9124 batch->ice->state.dirty |= CROCUS_DIRTY_GEN7_SO_BUFFERS;
9129 struct pipe_rasterizer_state *crocus_get_rast_state(struct crocus_context *ice)
9131 return &ice->state.cso_rast->cso;
9136 static void update_so_strides(struct crocus_context *ice,
9140 struct crocus_stream_output_target *so = (void *)ice->state.so_target[i];
9167 struct crocus_context *ice = (struct crocus_context *) ctx;
9169 if (crocus_batch_prepare_noop(&ice->batches[CROCUS_BATCH_RENDER], enable)) {
9170 ice->state.dirty |= CROCUS_ALL_DIRTY_FOR_RENDER;
9171 ice->state.stage_dirty |= CROCUS_ALL_STAGE_DIRTY_FOR_RENDER;
9174 if (ice->batch_count == 1)
9177 if (crocus_batch_prepare_noop(&ice->batches[CROCUS_BATCH_COMPUTE], enable)) {
9178 ice->state.dirty |= CROCUS_ALL_DIRTY_FOR_COMPUTE;
9179 ice->state.stage_dirty |= CROCUS_ALL_STAGE_DIRTY_FOR_COMPUTE;
9243 genX(crocus_init_state)(struct crocus_context *ice)
9245 struct pipe_context *ctx = &ice->ctx;
9292 ice->state.dirty = ~0ull;
9293 ice->state.stage_dirty = ~0ull;
9295 ice->state.statistics_counters_enabled = true;
9297 ice->state.sample_mask = 0xff;
9298 ice->state.num_viewports = 1;
9299 ice->state.prim_mode = PIPE_PRIM_MAX;
9300 ice->state.reduced_prim_mode = PIPE_PRIM_MAX;
9301 ice->state.genx = calloc(1, sizeof(struct crocus_genx_state));
9302 ice->draw.derived_params.drawid = -1;
9306 ice->state.scissors[i] = (struct pipe_scissor_state) {