Lines Matching refs:state

52 /* r300_state: Functions used to initialize state context by translating
53 * Gallium state objects into semi-native r300 state objects. */
56 if (cso != atom.state) { \
57 atom.state = cso; \
65 * SRC_ALPHA == 0, and the following state is set, the colorbuffer
86 * SRC_ALPHA == 1, and the following state is set, the colorbuffer
105 * SRC_COLOR == (0,0,0), and the following state is set, the colorbuffer
120 * SRC_COLOR == (1,1,1), and the following state is set, the colorbuffer
135 * SRC_ALPHA_COLOR == (0,0,0,0), and the following state is set,
158 * SRC_ALPHA_COLOR == (1,1,1,1), and the following state is set,
331 /* Create a new blend state based on the CSO blend state.
335 const struct pipe_blend_state* state)
351 const unsigned eqRGB = state->rt[0].rgb_func;
352 const unsigned srcRGB = state->rt[0].rgb_src_factor;
353 const unsigned dstRGB = state->rt[0].rgb_dst_factor;
355 const unsigned eqA = state->rt[0].alpha_func;
356 const unsigned srcA = state->rt[0].alpha_src_factor;
357 const unsigned dstA = state->rt[0].alpha_dst_factor;
363 blend->state = *state;
385 if (state->rt[0].blend_enable) {
449 if (state->logicop_enable) {
451 (state->logicop_func) << R300_RB3D_ROPCNTL_ROP_SHIFT;
455 * state. Since it's an optional implementation detail, we can leave it
460 if (state->dither) {
487 OUT_CB(func[i](state->rt[0].colormask));
499 OUT_CB(rgba_cmask(state->rt[0].colormask));
509 OUT_CB(rgba_cmask(state->rt[0].colormask));
526 /* Bind blend state. */
528 void* state)
531 struct r300_blend_state *blend = (struct r300_blend_state*)state;
535 UPDATE_STATE(state, r300->blend_state);
540 r300->alpha_to_one = blend->state.alpha_to_one;
541 r300->alpha_to_coverage = blend->state.alpha_to_coverage;
554 /* Free blend state. */
556 void* state)
558 FREE(state);
573 struct pipe_framebuffer_state *fb = r300->fb_state.state;
574 struct r300_blend_color_state *state =
575 (struct r300_blend_color_state*)r300->blend_color_state.state;
581 state->state = *color; /* Save it, so that we can reuse it in set_fb_state */
619 BEGIN_CB(state->cb, 3);
643 BEGIN_CB(state->cb, 2);
652 const struct pipe_clip_state* state)
656 (struct r300_clip_state*)r300->clip_state.state;
665 OUT_CB_TABLE(state->ucp, 6 * 4);
670 draw_set_clip_state(r300->draw, state);
674 /* Create a new depth, stencil, and alpha state based on the CSO dsa state.
680 const struct pipe_depth_stencil_alpha_state* state)
691 dsa->dsa = *state;
694 if (state->depth_writemask) {
698 if (state->depth_enabled) {
702 (r300_translate_depth_stencil_function(state->depth_func) <<
707 if (state->stencil[0].enabled) {
710 (r300_translate_depth_stencil_function(state->stencil[0].func) <<
712 (r300_translate_stencil_op(state->stencil[0].fail_op) <<
714 (r300_translate_stencil_op(state->stencil[0].zpass_op) <<
716 (r300_translate_stencil_op(state->stencil[0].zfail_op) <<
720 (state->stencil[0].valuemask << R300_STENCILMASK_SHIFT) |
721 (state->stencil[0].writemask << R300_STENCILWRITEMASK_SHIFT);
723 if (state->stencil[1].enabled) {
728 (r300_translate_depth_stencil_function(state->stencil[1].func) <<
730 (r300_translate_stencil_op(state->stencil[1].fail_op) <<
732 (r300_translate_stencil_op(state->stencil[1].zpass_op) <<
734 (r300_translate_stencil_op(state->stencil[1].zfail_op) <<
738 (state->stencil[1].valuemask << R300_STENCILMASK_SHIFT) |
739 (state->stencil[1].writemask << R300_STENCILWRITEMASK_SHIFT);
745 (state->stencil[0].valuemask != state->stencil[1].valuemask ||
746 state->stencil[0].writemask != state->stencil[1].writemask);
752 if (state->alpha_enabled) {
754 r300_translate_alpha_function(state->alpha_func) |
757 dsa->alpha_function |= float_to_ubyte(state->alpha_ref_value);
758 alpha_value_fp16 = _mesa_float_to_half(state->alpha_ref_value);
785 (struct r300_dsa_state*)r300->dsa_state.state;
798 /* Bind DSA state. */
800 void* state)
804 if (!state) {
808 UPDATE_STATE(state, r300->dsa_state);
814 /* Free DSA state. */
816 void* state)
818 FREE(state);
858 struct pipe_framebuffer_state *state = r300->fb_state.state;
867 r300_set_blend_color(&r300->context, r300->blend_color_state.state);
881 r300->fb_state.size = 2 + (8 * state->nr_cbufs);
885 else if (state->zsbuf) {
903 const struct pipe_framebuffer_state* state)
906 struct r300_aa_state *aa = (struct r300_aa_state*)r300->aa_state.state;
907 struct pipe_framebuffer_state *current_state = r300->fb_state.state;
920 if (state->width > max_width || state->height > max_height) {
922 "big in %s, refusing to bind framebuffer state!\n", __FUNCTION__);
928 if (state->zsbuf) {
929 if (!pipe_surface_equal(current_state->zsbuf, state->zsbuf)) {
940 if (state->zsbuf) {
941 if (!pipe_surface_equal(r300->locked_zbuffer, state->zsbuf)) {
952 assert(state->zsbuf || (r300->locked_zbuffer && !unlock_zbuffer) || !r300->zmask_in_use);
955 if (!!current_state->zsbuf != !!state->zsbuf) {
959 util_copy_framebuffer_state(r300->fb_state.state, state);
967 state->nr_cbufs == 1 && state->cbufs[0] &&
968 r300->screen->cmask_resource == state->cbufs[0]->texture;
974 r300_set_blend_color(pipe, &((struct r300_blend_color_state*)r300->blend_color_state.state)->state);
982 if (state->zsbuf) {
983 switch (util_format_get_blocksize(state->zsbuf->format)) {
1001 r300->num_samples = util_framebuffer_get_num_samples(state);
1025 for (i = 0; i < state->nr_cbufs; i++) {
1026 if (state->cbufs[i])
1027 r300_print_fb_surf_info(state->cbufs[i], i, "CB");
1029 if (state->zsbuf) {
1030 r300_print_fb_surf_info(state->zsbuf, 0, "ZB");
1035 /* Create fragment shader state. */
1044 /* Copy state directly into shader. */
1045 fs->state = *shader;
1047 if (fs->state.type == PIPE_SHADER_IR_NIR) {
1050 fs->state.tokens = nir_to_tgsi(shader->ir.nir, pipe->screen);
1052 assert(fs->state.type == PIPE_SHADER_IR_TGSI);
1054 fs->state.tokens = tgsi_dup_tokens(fs->state.tokens);
1064 tgsi_scan_shader(fs->state.tokens, &info);
1094 ((struct r300_constant_buffer*)r300->fs_constants.state)->remap_table =
1098 /* Bind fragment shader state. */
1105 r300->fs.state = NULL;
1109 r300->fs.state = fs;
1115 /* Delete fragment shader state. */
1128 FREE((void*)fs->state.tokens);
1133 const struct pipe_poly_stipple* state)
1137 /* Create a new rasterizer state based on the CSO rasterizer state.
1139 * This is a very large chunk of state, and covers most of the graphics
1142 * In a not entirely unironic sidenote, this state has nearly nothing to do
1145 const struct pipe_rasterizer_state* state)
1169 /* Copy rasterizer state. */
1170 rs->rs = *state;
1171 rs->rs_draw = *state;
1173 rs->rs.sprite_coord_enable = state->point_quad_rasterization *
1174 state->sprite_coord_enable;
1197 pack_float_16_6x(state->point_size) |
1198 (pack_float_16_6x(state->point_size) << R300_POINTSIZE_X_SHIFT);
1201 if (state->point_size_per_vertex) {
1204 float min_psiz = util_get_min_point_size(state);
1213 float psiz = state->point_size;
1220 line_control = pack_float_16_6x(state->line_width) |
1221 (state->line_smooth ? R300_GA_LINE_CNTL_END_TYPE_COMP : R300_GA_LINE_CNTL_END_TYPE_SQR);
1225 if (state->fill_front != PIPE_POLYGON_MODE_FILL ||
1226 state->fill_back != PIPE_POLYGON_MODE_FILL) {
1231 if (state->front_ccw)
1238 if (util_get_offset(state, state->fill_front)) {
1241 if (util_get_offset(state, state->fill_back)) {
1250 r300_translate_polygon_mode_front(state->fill_front);
1252 r300_translate_polygon_mode_back(state->fill_back);
1255 if (state->cull_face & PIPE_FACE_FRONT) {
1258 if (state->cull_face & PIPE_FACE_BACK) {
1262 if (state->line_stipple_enable) {
1265 (fui((float)state->line_stipple_factor) &
1268 line_stipple_value = state->line_stipple_pattern;
1274 if (state->flatshade) {
1280 clip_rule = state->scissor ? 0xAAAA : 0xFFFF;
1284 switch (state->sprite_coord_mode) {
1297 vap_clip_cntl = (state->clip_plane_enable & 63) |
1335 float scale = state->offset_scale * 12;
1336 float offset = state->offset_units * 4;
1346 offset = state->offset_units * 2;
1360 /* Bind rasterizer state. */
1361 static void r300_bind_rs_state(struct pipe_context* pipe, void* state)
1364 struct r300_rs_state* rs = (struct r300_rs_state*)state;
1372 draw_set_rasterizer_state(r300->draw, &rs->rs_draw, state);
1391 UPDATE_STATE(state, r300->rs_state);
1416 /* Free rasterizer state. */
1417 static void r300_delete_rs_state(struct pipe_context* pipe, void* state)
1419 FREE(state);
1424 const struct pipe_sampler_state* state)
1431 sampler->state = *state;
1436 if (sampler->state.min_img_filter == PIPE_TEX_FILTER_NEAREST ||
1437 sampler->state.mag_img_filter == PIPE_TEX_FILTER_NEAREST) {
1439 if (sampler->state.wrap_s == PIPE_TEX_WRAP_CLAMP)
1440 sampler->state.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
1441 else if (sampler->state.wrap_s == PIPE_TEX_WRAP_MIRROR_CLAMP)
1442 sampler->state.wrap_s = PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE;
1445 if (sampler->state.wrap_t == PIPE_TEX_WRAP_CLAMP)
1446 sampler->state.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
1447 else if (sampler->state.wrap_t == PIPE_TEX_WRAP_MIRROR_CLAMP)
1448 sampler->state.wrap_t = PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE;
1451 if (sampler->state.wrap_r == PIPE_TEX_WRAP_CLAMP)
1452 sampler->state.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
1453 else if (sampler->state.wrap_r == PIPE_TEX_WRAP_MIRROR_CLAMP)
1454 sampler->state.wrap_r = PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE;
1458 (r300_translate_wrap(sampler->state.wrap_s) << R300_TX_WRAP_S_SHIFT) |
1459 (r300_translate_wrap(sampler->state.wrap_t) << R300_TX_WRAP_T_SHIFT) |
1460 (r300_translate_wrap(sampler->state.wrap_r) << R300_TX_WRAP_R_SHIFT);
1462 sampler->filter0 |= r300_translate_tex_filters(state->min_img_filter,
1463 state->mag_img_filter,
1464 state->min_mip_filter,
1465 state->max_anisotropy > 1);
1467 sampler->filter0 |= r300_anisotropy(state->max_anisotropy);
1471 sampler->min_lod = (unsigned)MAX2(state->min_lod, 0);
1472 sampler->max_lod = (unsigned)MAX2(ceilf(state->max_lod), 0);
1474 lod_bias = CLAMP((int)(state->lod_bias * 32 + 1), -(1 << 9), (1 << 9) - 1);
1483 sampler->filter1 |= r500_anisotropy(state->max_anisotropy);
1500 struct r300_textures_state* state =
1501 (struct r300_textures_state*)r300->textures_state.state;
1512 memcpy(state->sampler_states, states, sizeof(void*) * count);
1513 state->sampler_state_count = count;
1518 static void r300_delete_sampler_state(struct pipe_context* pipe, void* state)
1520 FREE(state);
1556 struct r300_textures_state* state =
1557 (struct r300_textures_state*)r300->textures_state.state;
1584 (struct pipe_sampler_view**)&state->sampler_views[i], NULL);
1585 state->sampler_views[i] = (struct r300_sampler_view*)views[i];
1588 (struct pipe_sampler_view**)&state->sampler_views[i],
1606 state->sampler_views[i]->texcache_region =
1612 if (state->sampler_views[i]) {
1614 (struct pipe_sampler_view**)&state->sampler_views[i],
1619 state->sampler_view_count = count;
1704 *((unsigned*)r300->sample_mask.state) = mask;
1712 const struct pipe_scissor_state* state)
1716 memcpy(r300->scissor_state.state, state,
1725 const struct pipe_viewport_state* state)
1729 (struct r300_viewport_state*)r300->viewport_state.state;
1731 r300->viewport = *state;
1734 draw_set_viewport_states(r300->draw, start_slot, num_viewports, state);
1742 if (state->scale[0] != 1.0f) {
1743 viewport->xscale = state->scale[0];
1746 if (state->scale[1] != 1.0f) {
1747 viewport->yscale = state->scale[1];
1750 if (state->scale[2] != 1.0f) {
1751 viewport->zscale = state->scale[2];
1754 if (state->translate[0] != 0.0f) {
1755 viewport->xoffset = state->translate[0];
1758 if (state->translate[1] != 0.0f) {
1759 viewport->yoffset = state->translate[1];
1762 if (state->translate[2] != 0.0f) {
1763 viewport->zoffset = state->translate[2];
1768 if (r300->fs.state && r300_fs(r300)->shader &&
1913 void *state)
1916 struct r300_vertex_element_state *velems = state;
1934 static void r300_delete_vertex_elements_state(struct pipe_context *pipe, void *state)
1936 FREE(state);
1945 /* Copy state directly into shader. */
1946 vs->state = *shader;
1948 if (vs->state.type == PIPE_SHADER_IR_NIR) {
1968 vs->state.tokens = nir_to_tgsi_options(shader->ir.nir, pipe->screen,
1971 assert(vs->state.type == PIPE_SHADER_IR_TGSI);
1973 vs->state.tokens = tgsi_dup_tokens(vs->state.tokens);
1993 r300->vs_state.state = NULL;
1996 if (vs == r300->vs_state.state) {
1999 r300->vs_state.state = vs;
2016 ((struct r300_constant_buffer*)r300->vs_constants.state)->remap_table =
2044 FREE((void*)vs->state.tokens);
2062 cbuf = (struct r300_constant_buffer*)r300->vs_constants.state;
2065 cbuf = (struct r300_constant_buffer*)r300->fs_constants.state;