Lines Matching refs:sub_ctx

465    struct vrend_sub_context *sub_ctx;  member
750 static void vrend_update_viewport_state(struct vrend_sub_context *sub_ctx);
751 static void vrend_update_scissor_state(struct vrend_sub_context *sub_ctx);
754 static void vrend_patch_blend_state(struct vrend_sub_context *sub_ctx);
758 static void vrend_apply_sampler_state(struct vrend_sub_context *sub_ctx,
765 void vrend_update_stencil_state(struct vrend_sub_context *sub_ctx);
1114 static bool vrend_compile_shader(struct vrend_sub_context *sub_ctx, in vrend_compile_shader() argument
1129 vrend_report_context_error(sub_ctx->parent, VIRGL_ERROR_CTX_ILLEGAL_SHADER, 0); in vrend_compile_shader()
1212 static void vrend_use_program(struct vrend_sub_context *sub_ctx, GLuint program_id) in vrend_use_program() argument
1214 if (sub_ctx->program_id != program_id) { in vrend_use_program()
1216 sub_ctx->program_id = program_id; in vrend_use_program()
1259 static void vrend_stencil_test_enable(struct vrend_sub_context *sub_ctx, bool stencil_test_enable) in vrend_stencil_test_enable() argument
1261 if (sub_ctx->stencil_test_enabled != stencil_test_enable) { in vrend_stencil_test_enable()
1262 sub_ctx->stencil_test_enabled = stencil_test_enable; in vrend_stencil_test_enable()
1318 static void set_stream_out_varyings(MAYBE_UNUSED struct vrend_sub_context *sub_ctx, in set_stream_out_varyings() argument
1333 VREND_DEBUG_EXT(dbg_shader_streamout, sub_ctx->parent, dump_stream_out(so)); in set_stream_out_varyings()
1569 static struct vrend_linked_shader_program *add_shader_program(struct vrend_sub_context *sub_ctx, in add_shader_program() argument
1596 set_stream_out_varyings(sub_ctx, prog_id, &gs->sel->sinfo); in add_shader_program()
1598 set_stream_out_varyings(sub_ctx, prog_id, &tes->sel->sinfo); in add_shader_program()
1600 set_stream_out_varyings(sub_ctx, prog_id, &vs->sel->sinfo); in add_shader_program()
1604 if (util_blend_state_is_dual(&sub_ctx->blend_state, 0)) { in add_shader_program()
1609 vrend_report_context_error(sub_ctx->parent, VIRGL_ERROR_CTX_ILLEGAL_DUAL_SRC_BLEND, 0); in add_shader_program()
1640 vrend_report_context_error(sub_ctx->parent, VIRGL_ERROR_CTX_ILLEGAL_SHADER, 0); in add_shader_program()
1671 list_addtail(&sprog->head, &sub_ctx->gl_programs[vs->id & VREND_PROGRAM_NQUEUE_MASK]); in add_shader_program()
1683 vrend_use_program(sub_ctx, prog_id); in add_shader_program()
1733 static struct vrend_linked_shader_program *lookup_shader_program(struct vrend_sub_context *sub_ctx, in lookup_shader_program() argument
1746 struct list_head *programs = &sub_ctx->gl_programs[vs_id & VREND_PROGRAM_NQUEUE_MASK]; in lookup_shader_program()
1925 struct vrend_sub_context *sub_ctx = target->sub_ctx; in vrend_destroy_so_target_object() local
1930 LIST_FOR_EACH_ENTRY_SAFE(obj, tmp, &sub_ctx->streamout_list, head) { in vrend_destroy_so_target_object()
1939 if (obj == sub_ctx->current_so) in vrend_destroy_so_target_object()
1940 sub_ctx->current_so = NULL; in vrend_destroy_so_target_object()
1945 if (sub_ctx->current_so && has_feature(feat_transform_feedback2)) in vrend_destroy_so_target_object()
1946 glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, sub_ctx->current_so->id); in vrend_destroy_so_target_object()
2415 static void vrend_hw_set_color_surface(struct vrend_sub_context *sub_ctx, int index) in vrend_hw_set_color_surface() argument
2417 struct vrend_surface *surf = sub_ctx->surf[index]; in vrend_hw_set_color_surface()
2425 uint32_t first_layer = sub_ctx->surf[index]->val1 & 0xffff; in vrend_hw_set_color_surface()
2426 uint32_t last_layer = (sub_ctx->surf[index]->val1 >> 16) & 0xffff; in vrend_hw_set_color_surface()
2433 static void vrend_hw_emit_framebuffer_state(struct vrend_sub_context *sub_ctx) in vrend_hw_emit_framebuffer_state() argument
2446 if (sub_ctx->nr_cbufs == 0) { in vrend_hw_emit_framebuffer_state()
2450 sub_ctx->framebuffer_srgb_enabled = false; in vrend_hw_emit_framebuffer_state()
2456 for (i = 0; i < sub_ctx->nr_cbufs; i++) { in vrend_hw_emit_framebuffer_state()
2457 if (sub_ctx->surf[i]) { in vrend_hw_emit_framebuffer_state()
2458 surf = sub_ctx->surf[i]; in vrend_hw_emit_framebuffer_state()
2469 sub_ctx->framebuffer_srgb_enabled = use_srgb; in vrend_hw_emit_framebuffer_state()
2473 vrend_get_tweak_is_active(&sub_ctx->tweaks, virgl_tweak_gles_brga_apply_dest_swizzle)) { in vrend_hw_emit_framebuffer_state()
2474 sub_ctx->swizzle_output_rgb_to_bgr = 0; in vrend_hw_emit_framebuffer_state()
2475 for (int i = 0; i < sub_ctx->nr_cbufs; i++) { in vrend_hw_emit_framebuffer_state()
2476 if (sub_ctx->surf[i]) { in vrend_hw_emit_framebuffer_state()
2477 struct vrend_surface *surf = sub_ctx->surf[i]; in vrend_hw_emit_framebuffer_state()
2479 …VREND_DEBUG(dbg_tweak, sub_ctx->parent, "Swizzled BGRA output for 0x%x (%s)\n", i, util_format_nam… in vrend_hw_emit_framebuffer_state()
2480 sub_ctx->swizzle_output_rgb_to_bgr |= 1 << i; in vrend_hw_emit_framebuffer_state()
2487 glDrawBuffers(sub_ctx->nr_cbufs, buffers); in vrend_hw_emit_framebuffer_state()
2501 struct vrend_sub_context *sub_ctx = ctx->sub; in vrend_set_framebuffer_state() local
2503 glBindFramebuffer(GL_FRAMEBUFFER, sub_ctx->fb_id); in vrend_set_framebuffer_state()
2506 zsurf = vrend_object_lookup(sub_ctx->object_hash, zsurf_handle, VIRGL_OBJECT_SURFACE); in vrend_set_framebuffer_state()
2514 if (sub_ctx->zsurf != zsurf) { in vrend_set_framebuffer_state()
2515 vrend_surface_reference(&sub_ctx->zsurf, zsurf); in vrend_set_framebuffer_state()
2519 old_num = sub_ctx->nr_cbufs; in vrend_set_framebuffer_state()
2520 sub_ctx->nr_cbufs = nr_cbufs; in vrend_set_framebuffer_state()
2521 sub_ctx->old_nr_cbufs = old_num; in vrend_set_framebuffer_state()
2525 surf = vrend_object_lookup(sub_ctx->object_hash, surf_handle[i], VIRGL_OBJECT_SURFACE); in vrend_set_framebuffer_state()
2533 if (sub_ctx->surf[i] != surf) { in vrend_set_framebuffer_state()
2534 vrend_surface_reference(&sub_ctx->surf[i], surf); in vrend_set_framebuffer_state()
2535 vrend_hw_set_color_surface(sub_ctx, i); in vrend_set_framebuffer_state()
2539 if (old_num > sub_ctx->nr_cbufs) { in vrend_set_framebuffer_state()
2540 for (i = sub_ctx->nr_cbufs; i < old_num; i++) { in vrend_set_framebuffer_state()
2541 vrend_surface_reference(&sub_ctx->surf[i], NULL); in vrend_set_framebuffer_state()
2542 vrend_hw_set_color_surface(sub_ctx, i); in vrend_set_framebuffer_state()
2547 if (sub_ctx->nr_cbufs == 0 && !sub_ctx->zsurf) { in vrend_set_framebuffer_state()
2550 } else if (sub_ctx->nr_cbufs == 0) { in vrend_set_framebuffer_state()
2551 new_height = u_minify(sub_ctx->zsurf->texture->base.height0, sub_ctx->zsurf->val0); in vrend_set_framebuffer_state()
2552 new_ibf = sub_ctx->zsurf->texture->y_0_top ? true : false; in vrend_set_framebuffer_state()
2556 for (i = 0; i < sub_ctx->nr_cbufs; i++) { in vrend_set_framebuffer_state()
2557 if (sub_ctx->surf[i]) { in vrend_set_framebuffer_state()
2558 surf = sub_ctx->surf[i]; in vrend_set_framebuffer_state()
2571 if (sub_ctx->fb_height != (uint32_t)new_height || sub_ctx->inverted_fbo_content != new_ibf) { in vrend_set_framebuffer_state()
2572 sub_ctx->fb_height = new_height; in vrend_set_framebuffer_state()
2573 sub_ctx->inverted_fbo_content = new_ibf; in vrend_set_framebuffer_state()
2574 sub_ctx->viewport_state_dirty = (1 << 0); in vrend_set_framebuffer_state()
2578 vrend_hw_emit_framebuffer_state(sub_ctx); in vrend_set_framebuffer_state()
2580 if (sub_ctx->nr_cbufs > 0 || sub_ctx->zsurf) { in vrend_set_framebuffer_state()
2586 sub_ctx->shader_dirty = true; in vrend_set_framebuffer_state()
2587 sub_ctx->blend_state_dirty = true; in vrend_set_framebuffer_state()
3238 static inline void vrend_fill_shader_key(struct vrend_sub_context *sub_ctx, in vrend_fill_shader_key() argument
3249 if (vrend_state.use_integer && sub_ctx->drawing) { in vrend_fill_shader_key()
3250 key->attrib_signed_int_bitmask = sub_ctx->ve->signed_int_bitmask; in vrend_fill_shader_key()
3251 key->attrib_unsigned_int_bitmask = sub_ctx->ve->unsigned_int_bitmask; in vrend_fill_shader_key()
3253 for (i = 0; i < sub_ctx->nr_cbufs; i++) { in vrend_fill_shader_key()
3254 if (!sub_ctx->surf[i]) in vrend_fill_shader_key()
3256 if (vrend_format_is_emulated_alpha(sub_ctx->surf[i]->format)) in vrend_fill_shader_key()
3258 if (util_format_is_pure_integer(sub_ctx->surf[i]->format)) { in vrend_fill_shader_key()
3260 update_int_sign_masks(sub_ctx->surf[i]->format, i, in vrend_fill_shader_key()
3264 …key->surface_component_bits[i] = util_format_get_component_bits(sub_ctx->surf[i]->format, UTIL_FOR… in vrend_fill_shader_key()
3267 key->add_alpha_test = sub_ctx->dsa_state.alpha.enabled; in vrend_fill_shader_key()
3268 key->alpha_test = sub_ctx->dsa_state.alpha.func; in vrend_fill_shader_key()
3271 key->pstipple_tex = sub_ctx->rs_state.poly_stipple_enable; in vrend_fill_shader_key()
3272 key->color_two_side = sub_ctx->rs_state.light_twoside; in vrend_fill_shader_key()
3274 key->clip_plane_enable = sub_ctx->rs_state.clip_plane_enable; in vrend_fill_shader_key()
3275 key->flatshade = sub_ctx->rs_state.flatshade ? true : false; in vrend_fill_shader_key()
3281 …if (type == PIPE_SHADER_FRAGMENT && vrend_state.use_gles && can_emulate_logicop(sub_ctx->blend_sta… in vrend_fill_shader_key()
3282 key->fs_logicop_enabled = sub_ctx->blend_state.logicop_enable; in vrend_fill_shader_key()
3283 key->fs_logicop_func = sub_ctx->blend_state.logicop_func; in vrend_fill_shader_key()
3287 key->invert_fs_origin = !sub_ctx->inverted_fbo_content; in vrend_fill_shader_key()
3290 key->fs_swizzle_output_rgb_to_bgr = sub_ctx->swizzle_output_rgb_to_bgr; in vrend_fill_shader_key()
3292 if (sub_ctx->shaders[PIPE_SHADER_GEOMETRY]) in vrend_fill_shader_key()
3294 if (sub_ctx->shaders[PIPE_SHADER_TESS_CTRL]) in vrend_fill_shader_key()
3296 if (sub_ctx->shaders[PIPE_SHADER_TESS_EVAL]) in vrend_fill_shader_key()
3305 if (sub_ctx->shaders[type] == sel) { in vrend_fill_shader_key()
3335 if (prev_type != -1 && sub_ctx->shaders[prev_type]) { in vrend_fill_shader_key()
3336 key->prev_stage_num_clip_out = sub_ctx->shaders[prev_type]->sinfo.num_clip_out; in vrend_fill_shader_key()
3337 key->prev_stage_num_cull_out = sub_ctx->shaders[prev_type]->sinfo.num_cull_out; in vrend_fill_shader_key()
3338 …key->num_indirect_generic_inputs = sub_ctx->shaders[prev_type]->sinfo.num_indirect_generic_outputs; in vrend_fill_shader_key()
3339 … key->num_indirect_patch_inputs = sub_ctx->shaders[prev_type]->sinfo.num_indirect_patch_outputs; in vrend_fill_shader_key()
3340 …key->num_prev_generic_and_patch_outputs = sub_ctx->shaders[prev_type]->sinfo.num_generic_and_patch… in vrend_fill_shader_key()
3341 key->guest_sent_io_arrays = sub_ctx->shaders[prev_type]->sinfo.guest_sent_io_arrays; in vrend_fill_shader_key()
3344 sub_ctx->shaders[prev_type]->sinfo.generic_outputs_layout, in vrend_fill_shader_key()
3346 key->force_invariant_inputs = sub_ctx->shaders[prev_type]->sinfo.invariant_outputs; in vrend_fill_shader_key()
3351 int fs_prim_mode = sub_ctx->prim_mode; // inherit draw-call's mode in vrend_fill_shader_key()
3354 if (sub_ctx->shaders[PIPE_SHADER_TESS_EVAL]->sinfo.tes_point_mode) in vrend_fill_shader_key()
3358 fs_prim_mode = sub_ctx->shaders[PIPE_SHADER_GEOMETRY]->sinfo.gs_out_prim; in vrend_fill_shader_key()
3362 key->coord_replace = sub_ctx->rs_state.point_quad_rasterization in vrend_fill_shader_key()
3364 ? sub_ctx->rs_state.sprite_coord_enable in vrend_fill_shader_key()
3398 if (next_type != -1 && sub_ctx->shaders[next_type]) { in vrend_fill_shader_key()
3399 key->next_stage_pervertex_in = sub_ctx->shaders[next_type]->sinfo.has_pervertex_in; in vrend_fill_shader_key()
3400 …key->num_indirect_generic_outputs = sub_ctx->shaders[next_type]->sinfo.num_indirect_generic_inputs; in vrend_fill_shader_key()
3401 … key->num_indirect_patch_outputs = sub_ctx->shaders[next_type]->sinfo.num_indirect_patch_inputs; in vrend_fill_shader_key()
3402 …key->generic_outputs_expected_mask = sub_ctx->shaders[next_type]->sinfo.generic_inputs_emitted_mas… in vrend_fill_shader_key()
3406 sub_ctx->shaders[PIPE_SHADER_FRAGMENT]) { in vrend_fill_shader_key()
3408 sub_ctx->shaders[PIPE_SHADER_FRAGMENT]->current; in vrend_fill_shader_key()
3465 static int vrend_shader_select(struct vrend_sub_context *sub_ctx, in vrend_shader_select() argument
3474 vrend_fill_shader_key(sub_ctx, sel, &key); in vrend_shader_select()
3498 r = vrend_shader_create(sub_ctx->parent, shader, &key); in vrend_shader_select()
3580 struct vrend_sub_context *sub_ctx = ctx->sub; in vrend_create_shader() local
3584 if (sub_ctx->long_shader_in_progress_handle[type]) { in vrend_create_shader()
3587 if (handle != sub_ctx->long_shader_in_progress_handle[type]) in vrend_create_shader()
3605 sub_ctx->long_shader_in_progress_handle[type] = handle; in vrend_create_shader()
3609 sel = vrend_object_lookup(sub_ctx->object_hash, handle, VIRGL_OBJECT_SHADER); in vrend_create_shader()
3681 sub_ctx->long_shader_in_progress_handle[type] = 0; in vrend_create_shader()
3711 struct vrend_sub_context *sub_ctx = ctx->sub; in vrend_bind_shader() local
3715 sub_ctx->cs_shader_dirty = true; in vrend_bind_shader()
3717 sub_ctx->shader_dirty = true; in vrend_bind_shader()
3718 vrend_shader_state_reference(&sub_ctx->shaders[type], NULL); in vrend_bind_shader()
3722 sel = vrend_object_lookup(sub_ctx->object_hash, handle, VIRGL_OBJECT_SHADER); in vrend_bind_shader()
3729 if (sub_ctx->shaders[sel->type] != sel) { in vrend_bind_shader()
3731 sub_ctx->cs_shader_dirty = true; in vrend_bind_shader()
3733 sub_ctx->shader_dirty = true; in vrend_bind_shader()
3734 sub_ctx->prog_ids[sel->type] = 0; in vrend_bind_shader()
3737 vrend_shader_state_reference(&sub_ctx->shaders[sel->type], sel); in vrend_bind_shader()
3746 struct vrend_sub_context *sub_ctx = ctx->sub; in vrend_clear() local
3754 vrend_update_frontface_state(sub_ctx); in vrend_clear()
3755 if (sub_ctx->stencil_state_dirty) in vrend_clear()
3756 vrend_update_stencil_state(sub_ctx); in vrend_clear()
3757 if (sub_ctx->scissor_state_dirty) in vrend_clear()
3758 vrend_update_scissor_state(sub_ctx); in vrend_clear()
3759 if (sub_ctx->viewport_state_dirty) in vrend_clear()
3760 vrend_update_viewport_state(sub_ctx); in vrend_clear()
3762 vrend_use_program(sub_ctx, 0); in vrend_clear()
3767 …if (sub_ctx->nr_cbufs && sub_ctx->surf[0] && vrend_format_is_emulated_alpha(sub_ctx->surf[0]->form… in vrend_clear()
3776 if (sub_ctx->hw_blend_state.independent_blend_enable && in vrend_clear()
3804 if (sub_ctx->hw_rs_state.rasterizer_discard) in vrend_clear()
3810 for (i = 0; i < sub_ctx->nr_cbufs; i++) { in vrend_clear()
3811 if (sub_ctx->surf[i]) in vrend_clear()
3818 …if (i < PIPE_MAX_COLOR_BUFS && sub_ctx->surf[i] && util_format_is_pure_uint(sub_ctx->surf[i] && su… in vrend_clear()
3821 …else if (i < PIPE_MAX_COLOR_BUFS && sub_ctx->surf[i] && util_format_is_pure_sint(sub_ctx->surf[i] … in vrend_clear()
3844 if (sub_ctx->hw_rs_state.rasterizer_discard) in vrend_clear()
3848 if (!sub_ctx->dsa_state.depth.writemask) in vrend_clear()
3854 glStencilMaskSeparate(GL_FRONT, sub_ctx->dsa_state.stencil[0].writemask); in vrend_clear()
3855 glStencilMaskSeparate(GL_BACK, sub_ctx->dsa_state.stencil[1].writemask); in vrend_clear()
3860 if (sub_ctx->hw_blend_state.independent_blend_enable && in vrend_clear()
3864 struct pipe_blend_state *blend = &sub_ctx->hw_blend_state; in vrend_clear()
3871 glColorMask(sub_ctx->hw_blend_state.rt[0].colormask & PIPE_MASK_R ? GL_TRUE : GL_FALSE, in vrend_clear()
3872 sub_ctx->hw_blend_state.rt[0].colormask & PIPE_MASK_G ? GL_TRUE : GL_FALSE, in vrend_clear()
3873 sub_ctx->hw_blend_state.rt[0].colormask & PIPE_MASK_B ? GL_TRUE : GL_FALSE, in vrend_clear()
3874 sub_ctx->hw_blend_state.rt[0].colormask & PIPE_MASK_A ? GL_TRUE : GL_FALSE); in vrend_clear()
3877 if (sub_ctx->hw_rs_state.scissor) in vrend_clear()
3915 static void vrend_update_scissor_state(struct vrend_sub_context *sub_ctx) in vrend_update_scissor_state() argument
3920 unsigned mask = sub_ctx->scissor_state_dirty; in vrend_update_scissor_state()
3925 vrend_report_buffer_error(sub_ctx->parent, 0); in vrend_update_scissor_state()
3928 ss = &sub_ctx->ss[idx]; in vrend_update_scissor_state()
3936 sub_ctx->scissor_state_dirty = 0; in vrend_update_scissor_state()
3939 static void vrend_update_viewport_state(struct vrend_sub_context *sub_ctx) in vrend_update_viewport_state() argument
3942 unsigned mask = sub_ctx->viewport_state_dirty; in vrend_update_viewport_state()
3947 if (sub_ctx->viewport_is_negative) in vrend_update_viewport_state()
3948 cy = sub_ctx->vps[idx].cur_y - sub_ctx->vps[idx].height; in vrend_update_viewport_state()
3950 cy = sub_ctx->vps[idx].cur_y; in vrend_update_viewport_state()
3952 …glViewportIndexedf(idx, sub_ctx->vps[idx].cur_x, cy, sub_ctx->vps[idx].width, sub_ctx->vps[idx].he… in vrend_update_viewport_state()
3954 glViewport(sub_ctx->vps[idx].cur_x, cy, sub_ctx->vps[idx].width, sub_ctx->vps[idx].height); in vrend_update_viewport_state()
3958 glDepthRangeIndexedfOES(idx, sub_ctx->vps[idx].near_val, sub_ctx->vps[idx].far_val); in vrend_update_viewport_state()
3960 glDepthRangeIndexed(idx, sub_ctx->vps[idx].near_val, sub_ctx->vps[idx].far_val); in vrend_update_viewport_state()
3963 glDepthRangefOES(sub_ctx->vps[idx].near_val, sub_ctx->vps[idx].far_val); in vrend_update_viewport_state()
3965 glDepthRange(sub_ctx->vps[idx].near_val, sub_ctx->vps[idx].far_val); in vrend_update_viewport_state()
3968 sub_ctx->viewport_state_dirty = 0; in vrend_update_viewport_state()
4180 static int vrend_draw_bind_samplers_shader(struct vrend_sub_context *sub_ctx, in vrend_draw_bind_samplers_shader() argument
4186 uint32_t dirty = sub_ctx->sampler_views_dirty[shader_type]; in vrend_draw_bind_samplers_shader()
4188 uint32_t mask = sub_ctx->prog->samplers_used_mask[shader_type]; in vrend_draw_bind_samplers_shader()
4190 struct vrend_shader_view *sviews = &sub_ctx->views[shader_type]; in vrend_draw_bind_samplers_shader()
4200 if (sub_ctx->prog->shadow_samp_mask[shader_type] & (1 << i)) { in vrend_draw_bind_samplers_shader()
4201 glUniform4f(sub_ctx->prog->shadow_samp_mask_locs[shader_type][index], in vrend_draw_bind_samplers_shader()
4206 glUniform4f(sub_ctx->prog->shadow_samp_add_locs[shader_type][index], in vrend_draw_bind_samplers_shader()
4229 sub_ctx->sampler_views_dirty[shader_type] & (1 << i)) { in vrend_draw_bind_samplers_shader()
4230 vrend_apply_sampler_state(sub_ctx, texture, shader_type, i, in vrend_draw_bind_samplers_shader()
4240 sub_ctx->sampler_views_dirty[shader_type] = dirty; in vrend_draw_bind_samplers_shader()
4245 static int vrend_draw_bind_ubo_shader(struct vrend_sub_context *sub_ctx, in vrend_draw_bind_ubo_shader() argument
4255 mask = sub_ctx->prog->ubo_used_mask[shader_type]; in vrend_draw_bind_ubo_shader()
4256 dirty = sub_ctx->const_bufs_dirty[shader_type]; in vrend_draw_bind_ubo_shader()
4257 update = dirty & sub_ctx->const_bufs_used_mask[shader_type]; in vrend_draw_bind_ubo_shader()
4268 cb = &sub_ctx->cbs[shader_type][i]; in vrend_draw_bind_ubo_shader()
4277 sub_ctx->const_bufs_dirty[shader_type] = dirty; in vrend_draw_bind_ubo_shader()
4282 static void vrend_draw_bind_const_shader(struct vrend_sub_context *sub_ctx, in vrend_draw_bind_const_shader() argument
4285 if (sub_ctx->consts[shader_type].consts && in vrend_draw_bind_const_shader()
4286 sub_ctx->shaders[shader_type] && in vrend_draw_bind_const_shader()
4287 (sub_ctx->prog->const_location[shader_type] != -1) && in vrend_draw_bind_const_shader()
4288 (sub_ctx->const_dirty[shader_type] || new_program)) { in vrend_draw_bind_const_shader()
4289 glUniform4uiv(sub_ctx->prog->const_location[shader_type], in vrend_draw_bind_const_shader()
4290 sub_ctx->shaders[shader_type]->sinfo.num_consts, in vrend_draw_bind_const_shader()
4291 sub_ctx->consts[shader_type].consts); in vrend_draw_bind_const_shader()
4292 sub_ctx->const_dirty[shader_type] = false; in vrend_draw_bind_const_shader()
4296 static void vrend_draw_bind_ssbo_shader(struct vrend_sub_context *sub_ctx, int shader_type) in vrend_draw_bind_ssbo_shader() argument
4306 if (!sub_ctx->prog->ssbo_locs[shader_type]) in vrend_draw_bind_ssbo_shader()
4309 if (!sub_ctx->ssbo_used_mask[shader_type]) in vrend_draw_bind_ssbo_shader()
4312 mask = sub_ctx->ssbo_used_mask[shader_type]; in vrend_draw_bind_ssbo_shader()
4316 ssbo = &sub_ctx->ssbo[shader_type][i]; in vrend_draw_bind_ssbo_shader()
4320 if (sub_ctx->prog->ssbo_locs[shader_type][i] != GL_INVALID_INDEX) { in vrend_draw_bind_ssbo_shader()
4322 … glShaderStorageBlockBinding(sub_ctx->prog->id, sub_ctx->prog->ssbo_locs[shader_type][i], i); in vrend_draw_bind_ssbo_shader()
4329 static void vrend_draw_bind_abo_shader(struct vrend_sub_context *sub_ctx) in vrend_draw_bind_abo_shader() argument
4339 mask = sub_ctx->abo_used_mask; in vrend_draw_bind_abo_shader()
4343 abo = &sub_ctx->abo[i]; in vrend_draw_bind_abo_shader()
4350 static void vrend_draw_bind_images_shader(struct vrend_sub_context *sub_ctx, int shader_type) in vrend_draw_bind_images_shader() argument
4358 if (!sub_ctx->images_used_mask[shader_type]) in vrend_draw_bind_images_shader()
4361 if (!sub_ctx->prog->img_locs[shader_type]) in vrend_draw_bind_images_shader()
4367 mask = sub_ctx->images_used_mask[shader_type]; in vrend_draw_bind_images_shader()
4371 if (!(sub_ctx->prog->images_used_mask[shader_type] & (1 << i))) in vrend_draw_bind_images_shader()
4373 iview = &sub_ctx->image_views[shader_type][i]; in vrend_draw_bind_images_shader()
4399 glUniform1i(sub_ctx->prog->img_locs[shader_type][i], i); in vrend_draw_bind_images_shader()
4420 static void vrend_draw_bind_objects(struct vrend_sub_context *sub_ctx, bool new_program) in vrend_draw_bind_objects() argument
4423 …for (int shader_type = PIPE_SHADER_VERTEX; shader_type <= sub_ctx->last_shader_idx; shader_type++)… in vrend_draw_bind_objects()
4424 next_ubo_id = vrend_draw_bind_ubo_shader(sub_ctx, shader_type, next_ubo_id); in vrend_draw_bind_objects()
4425 vrend_draw_bind_const_shader(sub_ctx, shader_type, new_program); in vrend_draw_bind_objects()
4426 next_sampler_id = vrend_draw_bind_samplers_shader(sub_ctx, shader_type, in vrend_draw_bind_objects()
4428 vrend_draw_bind_images_shader(sub_ctx, shader_type); in vrend_draw_bind_objects()
4429 vrend_draw_bind_ssbo_shader(sub_ctx, shader_type); in vrend_draw_bind_objects()
4432 vrend_draw_bind_abo_shader(sub_ctx); in vrend_draw_bind_objects()
4434 if (vrend_state.use_core_profile && sub_ctx->prog->fs_stipple_loc != -1) { in vrend_draw_bind_objects()
4436 glBindTexture(GL_TEXTURE_2D, sub_ctx->parent->pstipple_tex_id); in vrend_draw_bind_objects()
4437 glUniform1i(sub_ctx->prog->fs_stipple_loc, next_sampler_id); in vrend_draw_bind_objects()
4440 if (vrend_state.use_core_profile && sub_ctx->prog->fs_alpha_ref_val_loc != -1) { in vrend_draw_bind_objects()
4441 glUniform1f(sub_ctx->prog->fs_alpha_ref_val_loc, sub_ctx->dsa_state.alpha.ref_value); in vrend_draw_bind_objects()
4446 void vrend_inject_tcs(struct vrend_sub_context *sub_ctx, int vertices_per_patch) in vrend_inject_tcs() argument
4455 vrend_fill_shader_key(sub_ctx, sel, &shader->key); in vrend_inject_tcs()
4461 vrend_shader_create_passthrough_tcs(sub_ctx->parent, &sub_ctx->parent->shader_cfg, in vrend_inject_tcs()
4462 sub_ctx->shaders[PIPE_SHADER_VERTEX]->tokens, in vrend_inject_tcs()
4469 sub_ctx->shaders[PIPE_SHADER_TESS_CTRL] = sel; in vrend_inject_tcs()
4470 sub_ctx->shaders[PIPE_SHADER_TESS_CTRL]->num_shaders = 1; in vrend_inject_tcs()
4473 vrend_compile_shader(sub_ctx, shader); in vrend_inject_tcs()
4478 vrend_select_program(struct vrend_sub_context *sub_ctx, const struct pipe_draw_info *info) in vrend_select_program() argument
4482 bool dual_src = util_blend_state_is_dual(&sub_ctx->blend_state, 0); in vrend_select_program()
4485 struct vrend_shader_selector **shaders = sub_ctx->shaders; in vrend_select_program()
4487 sub_ctx->shader_dirty = false; in vrend_select_program()
4490 vrend_printf("dropping rendering due to missing shaders: %s\n", sub_ctx->parent->debug_name); in vrend_select_program()
4499 sub_ctx->drawing = true; in vrend_select_program()
4500 vrend_shader_select(sub_ctx, shaders[PIPE_SHADER_VERTEX], &vs_dirty); in vrend_select_program()
4501 sub_ctx->drawing = false; in vrend_select_program()
4504 vrend_shader_select(sub_ctx, shaders[PIPE_SHADER_TESS_CTRL], &tcs_dirty); in vrend_select_program()
4506 VREND_DEBUG(dbg_shader, sub_ctx->parent, "Need to inject a TCS\n"); in vrend_select_program()
4507 vrend_inject_tcs(sub_ctx, info->vertices_per_patch); in vrend_select_program()
4509 vrend_shader_select(sub_ctx, shaders[PIPE_SHADER_VERTEX], &vs_dirty); in vrend_select_program()
4513 vrend_shader_select(sub_ctx, shaders[PIPE_SHADER_TESS_EVAL], &tes_dirty); in vrend_select_program()
4515 vrend_shader_select(sub_ctx, shaders[PIPE_SHADER_GEOMETRY], &gs_dirty); in vrend_select_program()
4516 vrend_shader_select(sub_ctx, shaders[PIPE_SHADER_FRAGMENT], &fs_dirty); in vrend_select_program()
4523 vrend_printf( "failure to compile shader variants: %s\n", sub_ctx->parent->debug_name); in vrend_select_program()
4533 bool same_prog = sub_ctx->prog && in vrend_select_program()
4534 vs_id == sub_ctx->prog_ids[PIPE_SHADER_VERTEX] && in vrend_select_program()
4535 fs_id == sub_ctx->prog_ids[PIPE_SHADER_FRAGMENT] && in vrend_select_program()
4536 gs_id == sub_ctx->prog_ids[PIPE_SHADER_GEOMETRY] && in vrend_select_program()
4537 tcs_id == sub_ctx->prog_ids[PIPE_SHADER_TESS_CTRL] && in vrend_select_program()
4538 tes_id == sub_ctx->prog_ids[PIPE_SHADER_TESS_EVAL] && in vrend_select_program()
4539 sub_ctx->prog->dual_src_linked == dual_src; in vrend_select_program()
4542 prog = lookup_shader_program(sub_ctx, vs_id, fs_id, gs_id, tcs_id, tes_id, dual_src); in vrend_select_program()
4544 prog = add_shader_program(sub_ctx, in vrend_select_program()
4545 sub_ctx->shaders[PIPE_SHADER_VERTEX]->current, in vrend_select_program()
4546 sub_ctx->shaders[PIPE_SHADER_FRAGMENT]->current, in vrend_select_program()
4547 gs_id ? sub_ctx->shaders[PIPE_SHADER_GEOMETRY]->current : NULL, in vrend_select_program()
4548 tcs_id ? sub_ctx->shaders[PIPE_SHADER_TESS_CTRL]->current : NULL, in vrend_select_program()
4549 … tes_id ? sub_ctx->shaders[PIPE_SHADER_TESS_EVAL]->current : NULL); in vrend_select_program()
4554sub_ctx->last_shader_idx = sub_ctx->shaders[PIPE_SHADER_TESS_EVAL] ? PIPE_SHADER_TESS_EVAL : (sub_… in vrend_select_program()
4556 prog = sub_ctx->prog; in vrend_select_program()
4557 if (sub_ctx->prog != prog) { in vrend_select_program()
4559 sub_ctx->prog_ids[PIPE_SHADER_VERTEX] = vs_id; in vrend_select_program()
4560 sub_ctx->prog_ids[PIPE_SHADER_FRAGMENT] = fs_id; in vrend_select_program()
4561 sub_ctx->prog_ids[PIPE_SHADER_GEOMETRY] = gs_id; in vrend_select_program()
4562 sub_ctx->prog_ids[PIPE_SHADER_TESS_CTRL] = tcs_id; in vrend_select_program()
4563 sub_ctx->prog_ids[PIPE_SHADER_TESS_EVAL] = tes_id; in vrend_select_program()
4564 sub_ctx->prog_ids[PIPE_SHADER_COMPUTE] = 0; in vrend_select_program()
4565 sub_ctx->prog = prog; in vrend_select_program()
4569 sub_ctx->const_bufs_dirty[stage] = ~0; in vrend_select_program()
4570 sub_ctx->sampler_views_dirty[stage] = ~0; in vrend_select_program()
4573 prog->ref_context = sub_ctx; in vrend_select_program()
4587 struct vrend_sub_context *sub_ctx = ctx->sub; in vrend_draw_vbo() local
4626 vrend_update_frontface_state(sub_ctx); in vrend_draw_vbo()
4628 vrend_update_stencil_state(sub_ctx); in vrend_draw_vbo()
4630 vrend_update_scissor_state(sub_ctx); in vrend_draw_vbo()
4633 vrend_update_viewport_state(sub_ctx); in vrend_draw_vbo()
4636 vrend_patch_blend_state(sub_ctx); in vrend_draw_vbo()
4639 if (sub_ctx->prim_mode != (int)info->mode) { in vrend_draw_vbo()
4641 if (sub_ctx->prim_mode == PIPE_PRIM_POINTS in vrend_draw_vbo()
4643 sub_ctx->shader_dirty = true; in vrend_draw_vbo()
4645 sub_ctx->prim_mode = (int)info->mode; in vrend_draw_vbo()
4648 if (sub_ctx->shader_dirty || sub_ctx->swizzle_output_rgb_to_bgr) in vrend_draw_vbo()
4649 new_program = vrend_select_program(sub_ctx, info); in vrend_draw_vbo()
4651 if (!sub_ctx->prog) { in vrend_draw_vbo()
4656 vrend_use_program(sub_ctx, sub_ctx->prog->id); in vrend_draw_vbo()
4658 vrend_draw_bind_objects(sub_ctx, new_program); in vrend_draw_vbo()
4660 if (!sub_ctx->ve) { in vrend_draw_vbo()
4664 float viewport_neg_val = sub_ctx->viewport_is_negative ? -1.0 : 1.0; in vrend_draw_vbo()
4665 if (sub_ctx->prog->viewport_neg_val != viewport_neg_val) { in vrend_draw_vbo()
4666 glUniform1f(sub_ctx->prog->vs_ws_adjust_loc, viewport_neg_val); in vrend_draw_vbo()
4667 sub_ctx->prog->viewport_neg_val = viewport_neg_val; in vrend_draw_vbo()
4670 if (sub_ctx->rs_state.clip_plane_enable) { in vrend_draw_vbo()
4672 glUniform4fv(sub_ctx->prog->clip_locs[i], 1, (const GLfloat *)&sub_ctx->ucp_state.ucp[i]); in vrend_draw_vbo()
4677 vrend_draw_bind_vertex_binding(ctx, sub_ctx->ve); in vrend_draw_vbo()
4679 vrend_draw_bind_vertex_legacy(ctx, sub_ctx->ve); in vrend_draw_vbo()
4682 struct vrend_resource *res = (struct vrend_resource *)sub_ctx->ib.buffer; in vrend_draw_vbo()
4691 if (sub_ctx->current_so) { in vrend_draw_vbo()
4692 if (sub_ctx->current_so->xfb_state == XFB_STATE_STARTED_NEED_BEGIN) { in vrend_draw_vbo()
4693 if (sub_ctx->shaders[PIPE_SHADER_GEOMETRY]) in vrend_draw_vbo()
4694 …glBeginTransformFeedback(get_gs_xfb_mode(sub_ctx->shaders[PIPE_SHADER_GEOMETRY]->sinfo.gs_out_prim… in vrend_draw_vbo()
4695 else if (sub_ctx->shaders[PIPE_SHADER_TESS_EVAL]) in vrend_draw_vbo()
4696 …glBeginTransformFeedback(get_tess_xfb_mode(sub_ctx->shaders[PIPE_SHADER_TESS_EVAL]->sinfo.tes_prim, in vrend_draw_vbo()
4697 sub_ctx->shaders[PIPE_SHADER_TESS_EVAL]->sinfo.tes_point_mode)); in vrend_draw_vbo()
4700 sub_ctx->current_so->xfb_state = XFB_STATE_STARTED; in vrend_draw_vbo()
4701 } else if (sub_ctx->current_so->xfb_state == XFB_STATE_PAUSED) { in vrend_draw_vbo()
4703 sub_ctx->current_so->xfb_state = XFB_STATE_STARTED; in vrend_draw_vbo()
4721 if (sub_ctx->draw_indirect_buffer != buf) { in vrend_draw_vbo()
4723 sub_ctx->draw_indirect_buffer = buf; in vrend_draw_vbo()
4728 if (sub_ctx->draw_indirect_params_buffer != buf) { in vrend_draw_vbo()
4730 sub_ctx->draw_indirect_params_buffer = buf; in vrend_draw_vbo()
4743 …uint32_t blend_mask_shader = sub_ctx->shaders[PIPE_SHADER_FRAGMENT]->sinfo.fs_blend_equation_advan… in vrend_draw_vbo()
4744 uint32_t blend_mode = sub_ctx->blend_state.rt[0].alpha_src_factor; in vrend_draw_vbo()
4745 uint32_t alpha_dst_factor = sub_ctx->blend_state.rt[0].alpha_dst_factor; in vrend_draw_vbo()
4780 switch (sub_ctx->ib.index_size) { in vrend_draw_vbo()
4803 …mentsInstancedBaseVertex(mode, info->count, elsz, (void *)(unsigned long)sub_ctx->ib.offset, info-… in vrend_draw_vbo()
4805 …o->min_index, info->max_index, info->count, elsz, (void *)(unsigned long)sub_ctx->ib.offset, info-… in vrend_draw_vbo()
4807 …glDrawElementsBaseVertex(mode, info->count, elsz, (void *)(unsigned long)sub_ctx->ib.offset, info-… in vrend_draw_vbo()
4809 …glDrawElementsInstancedARB(mode, info->count, elsz, (void *)(unsigned long)sub_ctx->ib.offset, inf… in vrend_draw_vbo()
4811 …e, info->min_index, info->max_index, info->count, elsz, (void *)(unsigned long)sub_ctx->ib.offset); in vrend_draw_vbo()
4813 glDrawElements(mode, info->count, elsz, (void *)(unsigned long)sub_ctx->ib.offset); in vrend_draw_vbo()
4826 if (sub_ctx->current_so && has_feature(feat_transform_feedback2)) { in vrend_draw_vbo()
4827 if (sub_ctx->current_so->xfb_state == XFB_STATE_STARTED) { in vrend_draw_vbo()
4829 sub_ctx->current_so->xfb_state = XFB_STATE_PAUSED; in vrend_draw_vbo()
4847 struct vrend_sub_context *sub_ctx = ctx->sub; in vrend_launch_grid() local
4849 if (sub_ctx->cs_shader_dirty) { in vrend_launch_grid()
4853 sub_ctx->cs_shader_dirty = false; in vrend_launch_grid()
4855 if (!sub_ctx->shaders[PIPE_SHADER_COMPUTE]) { in vrend_launch_grid()
4860 vrend_shader_select(sub_ctx, sub_ctx->shaders[PIPE_SHADER_COMPUTE], &cs_dirty); in vrend_launch_grid()
4861 if (!sub_ctx->shaders[PIPE_SHADER_COMPUTE]->current) { in vrend_launch_grid()
4865 …if (sub_ctx->shaders[PIPE_SHADER_COMPUTE]->current->id != (GLuint)sub_ctx->prog_ids[PIPE_SHADER_CO… in vrend_launch_grid()
4866 prog = lookup_cs_shader_program(ctx, sub_ctx->shaders[PIPE_SHADER_COMPUTE]->current->id); in vrend_launch_grid()
4868 prog = add_cs_shader_program(ctx, sub_ctx->shaders[PIPE_SHADER_COMPUTE]->current); in vrend_launch_grid()
4873 prog = sub_ctx->prog; in vrend_launch_grid()
4875 if (sub_ctx->prog != prog) { in vrend_launch_grid()
4877 sub_ctx->prog_ids[PIPE_SHADER_VERTEX] = 0; in vrend_launch_grid()
4878sub_ctx->prog_ids[PIPE_SHADER_COMPUTE] = sub_ctx->shaders[PIPE_SHADER_COMPUTE]->current->id; in vrend_launch_grid()
4879 sub_ctx->prog = prog; in vrend_launch_grid()
4880 prog->ref_context = sub_ctx; in vrend_launch_grid()
4882 sub_ctx->shader_dirty = true; in vrend_launch_grid()
4885 if (!sub_ctx->prog) { in vrend_launch_grid()
4891 vrend_use_program(sub_ctx, sub_ctx->prog->id); in vrend_launch_grid()
4893 vrend_draw_bind_ubo_shader(sub_ctx, PIPE_SHADER_COMPUTE, 0); in vrend_launch_grid()
4894 vrend_draw_bind_const_shader(sub_ctx, PIPE_SHADER_COMPUTE, new_program); in vrend_launch_grid()
4895 vrend_draw_bind_samplers_shader(sub_ctx, PIPE_SHADER_COMPUTE, 0); in vrend_launch_grid()
4896 vrend_draw_bind_images_shader(sub_ctx, PIPE_SHADER_COMPUTE); in vrend_launch_grid()
4897 vrend_draw_bind_ssbo_shader(sub_ctx, PIPE_SHADER_COMPUTE); in vrend_launch_grid()
4898 vrend_draw_bind_abo_shader(sub_ctx); in vrend_launch_grid()
5051 static void vrend_hw_emit_blend(struct vrend_sub_context *sub_ctx, struct pipe_blend_state *state) in vrend_hw_emit_blend() argument
5053 if (state->logicop_enable != sub_ctx->hw_blend_state.logicop_enable) { in vrend_hw_emit_blend()
5054 sub_ctx->hw_blend_state.logicop_enable = state->logicop_enable; in vrend_hw_emit_blend()
5057 sub_ctx->shader_dirty = true; in vrend_hw_emit_blend()
5059 report_gles_warn(sub_ctx->parent, GLES_WARN_LOGIC_OP); in vrend_hw_emit_blend()
5077 bool dual_src = util_blend_state_is_dual(&sub_ctx->blend_state, i); in vrend_hw_emit_blend()
5093 if (state->rt[i].colormask != sub_ctx->hw_blend_state.rt[i].colormask) { in vrend_hw_emit_blend()
5094 sub_ctx->hw_blend_state.rt[i].colormask = state->rt[i].colormask; in vrend_hw_emit_blend()
5103 bool dual_src = util_blend_state_is_dual(&sub_ctx->blend_state, 0); in vrend_hw_emit_blend()
5118 if (state->rt[0].colormask != sub_ctx->hw_blend_state.rt[0].colormask || in vrend_hw_emit_blend()
5119 (sub_ctx->hw_blend_state.independent_blend_enable && in vrend_hw_emit_blend()
5123 sub_ctx->hw_blend_state.rt[i].colormask = state->rt[i].colormask; in vrend_hw_emit_blend()
5130 sub_ctx->hw_blend_state.independent_blend_enable = state->independent_blend_enable; in vrend_hw_emit_blend()
5157 static void vrend_patch_blend_state(struct vrend_sub_context *sub_ctx) in vrend_patch_blend_state() argument
5159 struct pipe_blend_state new_state = sub_ctx->blend_state; in vrend_patch_blend_state()
5160 struct pipe_blend_state *state = &sub_ctx->blend_state; in vrend_patch_blend_state()
5162 struct pipe_blend_color blend_color = sub_ctx->blend_color; in vrend_patch_blend_state()
5165 if (sub_ctx->nr_cbufs == 0) { in vrend_patch_blend_state()
5166 sub_ctx->blend_state_dirty = false; in vrend_patch_blend_state()
5171 if (i < sub_ctx->nr_cbufs && sub_ctx->surf[i]) { in vrend_patch_blend_state()
5172 if (vrend_format_is_emulated_alpha(sub_ctx->surf[i]->format)) { in vrend_patch_blend_state()
5186 } else if (!util_format_has_alpha(sub_ctx->surf[i]->format)) { in vrend_patch_blend_state()
5200 vrend_hw_emit_blend(sub_ctx, &new_state); in vrend_patch_blend_state()
5214 sub_ctx->blend_state_dirty = false; in vrend_patch_blend_state()
5292 static void vrend_update_frontface_state(struct vrend_sub_context *sub_ctx) in vrend_update_frontface_state() argument
5294 struct pipe_rasterizer_state *state = &sub_ctx->rs_state; in vrend_update_frontface_state()
5297 front_ccw ^= (sub_ctx->inverted_fbo_content ? 0 : 1); in vrend_update_frontface_state()
5304 void vrend_update_stencil_state(struct vrend_sub_context *sub_ctx) in vrend_update_stencil_state() argument
5306 struct pipe_depth_stencil_alpha_state *state = sub_ctx->dsa; in vrend_update_stencil_state()
5313 vrend_stencil_test_enable(sub_ctx, true); in vrend_update_stencil_state()
5320 sub_ctx->stencil_refs[0], in vrend_update_stencil_state()
5324 vrend_stencil_test_enable(sub_ctx, false); in vrend_update_stencil_state()
5326 vrend_stencil_test_enable(sub_ctx, true); in vrend_update_stencil_state()
5336 sub_ctx->stencil_refs[i], in vrend_update_stencil_state()
5341 sub_ctx->stencil_state_dirty = false; in vrend_update_stencil_state()
5703 static void vrend_apply_sampler_state(struct vrend_sub_context *sub_ctx, in vrend_apply_sampler_state() argument
5711 struct vrend_sampler_state *vstate = sub_ctx->sampler_state[shader_type][id]; in vrend_apply_sampler_state()
5776 report_gles_warn(sub_ctx->parent, GLES_WARN_LOD_BIAS); in vrend_apply_sampler_state()
9793 target->sub_ctx = ctx->sub; in vrend_create_so_target()