diff options
79 files changed, 330 insertions, 322 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index b46e668..c95a1ba 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -858,27 +858,14 @@ static INLINE void clip_state_cpy(struct pipe_clip_state *dst, const struct pipe_clip_state *src) { - dst->depth_clamp = src->depth_clamp; - dst->nr = src->nr; - if (src->nr) { - memcpy(dst->ucp, src->ucp, src->nr * sizeof(src->ucp[0])); - } + memcpy(dst->ucp, src->ucp, sizeof(dst->ucp)); } static INLINE int clip_state_cmp(const struct pipe_clip_state *a, const struct pipe_clip_state *b) { - if (a->depth_clamp != b->depth_clamp) { - return 1; - } - if (a->nr != b->nr) { - return 1; - } - if (a->nr) { - return memcmp(a->ucp, b->ucp, a->nr * sizeof(a->ucp[0])); - } - return 0; + return memcmp(a->ucp, b->ucp, sizeof(a->ucp)); } void diff --git a/src/gallium/auxiliary/draw/draw_cliptest_tmp.h b/src/gallium/auxiliary/draw/draw_cliptest_tmp.h index 1ca1529..9e6827c 100644 --- a/src/gallium/auxiliary/draw/draw_cliptest_tmp.h +++ b/src/gallium/auxiliary/draw/draw_cliptest_tmp.h @@ -36,7 +36,7 @@ static boolean TAG(do_cliptest)( struct pt_post_vs *pvs, /* const */ float (*plane)[4] = pvs->draw->plane; const unsigned pos = draw_current_shader_position_output(pvs->draw); const unsigned ef = pvs->draw->vs.edgeflag_output; - const unsigned nr = pvs->draw->nr_planes; + const unsigned ucp_enable = pvs->draw->rasterizer->clip_plane_enable; const unsigned flags = (FLAGS); unsigned need_pipeline = 0; unsigned j; @@ -81,10 +81,16 @@ static boolean TAG(do_cliptest)( struct pt_post_vs *pvs, } if (flags & DO_CLIP_USER) { - unsigned i; - for (i = 6; i < nr; i++) { - if (dot4(position, plane[i]) < 0) - mask |= (1<<i); + unsigned ucp_mask = ucp_enable; + + while (ucp_mask) { + unsigned plane_idx = ffs(ucp_mask)-1; + ucp_mask &= ~(1 << plane_idx); + plane_idx += 6; + + if (dot4(position, plane[plane_idx]) < 0) { + mask |= 1 << plane_idx; + } } } diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index f6db95d..f91e408 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -151,11 +151,10 @@ boolean draw_init(struct draw_context *draw) ASSIGN_4V( draw->plane[3], 0, 1, 0, 1 ); ASSIGN_4V( draw->plane[4], 0, 0, 1, 1 ); /* yes these are correct */ ASSIGN_4V( draw->plane[5], 0, 0, -1, 1 ); /* mesa's a bit wonky */ - draw->nr_planes = 6; draw->clip_xy = TRUE; draw->clip_z = TRUE; - + draw->pt.user.planes = (float (*) [DRAW_TOTAL_CLIP_PLANES][4]) &(draw->plane[0]); draw->reduced_prim = ~0; /* != any of PIPE_PRIM_x */ @@ -247,8 +246,9 @@ static void update_clip_flags( struct draw_context *draw ) draw->guard_band_xy = (!draw->driver.bypass_clip_xy && draw->driver.guard_band_xy); draw->clip_z = (!draw->driver.bypass_clip_z && - !draw->depth_clamp); - draw->clip_user = (draw->nr_planes > 6); + draw->rasterizer && draw->rasterizer->depth_clip); + draw->clip_user = draw->rasterizer && + draw->rasterizer->clip_plane_enable != 0; } /** @@ -264,8 +264,8 @@ void draw_set_rasterizer_state( struct draw_context *draw, draw->rasterizer = raster; draw->rast_handle = rast_handle; - - } + update_clip_flags(draw); + } } /* With a little more work, llvmpipe will be able to turn this off and @@ -311,14 +311,7 @@ void draw_set_clip_state( struct draw_context *draw, { draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); - assert(clip->nr <= PIPE_MAX_CLIP_PLANES); - memcpy(&draw->plane[6], clip->ucp, clip->nr * sizeof(clip->ucp[0])); - draw->nr_planes = 6 + clip->nr; - draw->depth_clamp = clip->depth_clamp; - - draw->pt.user.planes = (float (*) [DRAW_TOTAL_CLIP_PLANES][4]) &(draw->plane[0]); - - update_clip_flags(draw); + memcpy(&draw->plane[6], clip->ucp, sizeof(clip->ucp)); } diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 296c8fd..cf97e82 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -1021,7 +1021,7 @@ generate_clipmask(struct gallivm_state *gallivm, boolean clip_z, boolean clip_user, boolean clip_halfz, - unsigned nr, + unsigned ucp_enable, LLVMValueRef context_ptr) { LLVMBuilderRef builder = gallivm->builder; @@ -1030,7 +1030,6 @@ generate_clipmask(struct gallivm_state *gallivm, LLVMValueRef zero, shift; LLVMValueRef pos_x, pos_y, pos_z, pos_w; LLVMValueRef plane1, planes, plane_ptr, sum; - unsigned i; struct lp_type f32_type = lp_type_float_vec(32); mask = lp_build_const_int_vec(gallivm, lp_type_int_vec(32), 0); @@ -1098,12 +1097,15 @@ generate_clipmask(struct gallivm_state *gallivm, if (clip_user) { LLVMValueRef planes_ptr = draw_jit_context_planes(gallivm, context_ptr); LLVMValueRef indices[3]; - temp = lp_build_const_int_vec(gallivm, lp_type_int_vec(32), 32); /* userclip planes */ - for (i = 6; i < nr; i++) { + while (ucp_enable) { + unsigned plane_idx = ffs(ucp_enable)-1; + ucp_enable &= ~(1 << plane_idx); + plane_idx += 6; + indices[0] = lp_build_const_int32(gallivm, 0); - indices[1] = lp_build_const_int32(gallivm, i); + indices[1] = lp_build_const_int32(gallivm, plane_idx); indices[2] = lp_build_const_int32(gallivm, 0); plane_ptr = LLVMBuildGEP(builder, planes_ptr, indices, 3, ""); @@ -1133,8 +1135,8 @@ generate_clipmask(struct gallivm_state *gallivm, sum = LLVMBuildFAdd(builder, sum, test, ""); test = lp_build_compare(gallivm, f32_type, PIPE_FUNC_GREATER, zero, sum); - temp = LLVMBuildShl(builder, temp, shift, ""); - test = LLVMBuildAnd(builder, test, temp, ""); + temp = lp_build_const_int_vec(gallivm, lp_type_int_vec(32), 1 << plane_idx); + test = LLVMBuildAnd(builder, test, temp, ""); mask = LLVMBuildOr(builder, mask, test, ""); } } @@ -1365,7 +1367,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant, variant->key.clip_z, variant->key.clip_user, variant->key.clip_halfz, - variant->key.nr_planes, + variant->key.ucp_enable, context_ptr); /* return clipping boolean value for function */ clipmask_bool(gallivm, clipmask, ret_ptr); @@ -1447,7 +1449,7 @@ draw_llvm_make_variant_key(struct draw_llvm *llvm, char *store) key->bypass_viewport = llvm->draw->identity_viewport; key->clip_halfz = !llvm->draw->rasterizer->gl_rasterization_rules; key->need_edgeflags = (llvm->draw->vs.edgeflag_output ? TRUE : FALSE); - key->nr_planes = llvm->draw->nr_planes; + key->ucp_enable = llvm->draw->rasterizer->clip_plane_enable; key->pad = 0; /* All variants of this shader will have the same value for diff --git a/src/gallium/auxiliary/draw/draw_llvm.h b/src/gallium/auxiliary/draw/draw_llvm.h index bc36135..edd1a08 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.h +++ b/src/gallium/auxiliary/draw/draw_llvm.h @@ -171,8 +171,8 @@ struct draw_llvm_variant_key unsigned clip_halfz:1; unsigned bypass_viewport:1; unsigned need_edgeflags:1; - unsigned nr_planes:4; - unsigned pad:5; + unsigned ucp_enable:PIPE_MAX_CLIP_PLANES; + unsigned pad:9-PIPE_MAX_CLIP_PLANES; /* Variable number of vertex elements: */ diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index 89653e1..c0ef18e 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -278,8 +278,6 @@ struct draw_context /* Clip derived state: */ float plane[DRAW_TOTAL_CLIP_PLANES][4]; - unsigned nr_planes; - boolean depth_clamp; /* If a prim stage introduces new vertex attributes, they'll be stored here */ diff --git a/src/gallium/auxiliary/postprocess/pp_program.c b/src/gallium/auxiliary/postprocess/pp_program.c index 1a8a584..5c819a9 100644 --- a/src/gallium/auxiliary/postprocess/pp_program.c +++ b/src/gallium/auxiliary/postprocess/pp_program.c @@ -88,6 +88,7 @@ pp_init_prog(struct pp_queue_t *ppq, struct pipe_screen *pscreen) p->rasterizer.cull_face = PIPE_FACE_NONE; p->rasterizer.gl_rasterization_rules = 1; + p->rasterizer.depth_clip = 1; p->sampler.wrap_s = p->sampler.wrap_t = p->sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE; diff --git a/src/gallium/auxiliary/tgsi/tgsi_strings.c b/src/gallium/auxiliary/tgsi/tgsi_strings.c index 973b9fe..aa12493 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_strings.c +++ b/src/gallium/auxiliary/tgsi/tgsi_strings.c @@ -100,7 +100,8 @@ const char *tgsi_property_names[TGSI_PROPERTY_COUNT] = "FS_COORD_ORIGIN", "FS_COORD_PIXEL_CENTER", "FS_COLOR0_WRITES_ALL_CBUFS", - "FS_DEPTH_LAYOUT" + "FS_DEPTH_LAYOUT", + "VS_PROHIBIT_UCPS" }; const char *tgsi_type_names[5] = diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index bba0031..a10fd17 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -62,7 +62,6 @@ struct blit_state struct pipe_rasterizer_state rasterizer; struct pipe_sampler_state sampler; struct pipe_viewport_state viewport; - struct pipe_clip_state clip; struct pipe_vertex_element velem[2]; enum pipe_texture_target internal_target; @@ -109,6 +108,7 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso) memset(&ctx->rasterizer, 0, sizeof(ctx->rasterizer)); ctx->rasterizer.cull_face = PIPE_FACE_NONE; ctx->rasterizer.gl_rasterization_rules = 1; + ctx->rasterizer.depth_clip = 1; /* samplers */ memset(&ctx->sampler, 0, sizeof(ctx->sampler)); @@ -535,7 +535,6 @@ util_blit_pixels_writemask(struct blit_state *ctx, cso_save_fragment_shader(ctx->cso); cso_save_vertex_shader(ctx->cso); cso_save_geometry_shader(ctx->cso); - cso_save_clip(ctx->cso); cso_save_vertex_elements(ctx->cso); cso_save_vertex_buffers(ctx->cso); @@ -545,7 +544,6 @@ util_blit_pixels_writemask(struct blit_state *ctx, dst_is_depth ? &ctx->depthstencil_write : &ctx->depthstencil_keep); cso_set_rasterizer(ctx->cso, &ctx->rasterizer); - cso_set_clip(ctx->cso, &ctx->clip); cso_set_vertex_elements(ctx->cso, 2, ctx->velem); cso_set_stream_outputs(ctx->cso, 0, NULL, 0); @@ -621,7 +619,6 @@ util_blit_pixels_writemask(struct blit_state *ctx, cso_restore_fragment_shader(ctx->cso); cso_restore_vertex_shader(ctx->cso); cso_restore_geometry_shader(ctx->cso); - cso_restore_clip(ctx->cso); cso_restore_vertex_elements(ctx->cso); cso_restore_vertex_buffers(ctx->cso); cso_restore_stream_outputs(ctx->cso); @@ -731,7 +728,6 @@ util_blit_pixels_tex(struct blit_state *ctx, cso_save_fragment_shader(ctx->cso); cso_save_vertex_shader(ctx->cso); cso_save_geometry_shader(ctx->cso); - cso_save_clip(ctx->cso); cso_save_vertex_elements(ctx->cso); cso_save_vertex_buffers(ctx->cso); @@ -739,7 +735,6 @@ util_blit_pixels_tex(struct blit_state *ctx, cso_set_blend(ctx->cso, &ctx->blend); cso_set_depth_stencil_alpha(ctx->cso, &ctx->depthstencil_keep); cso_set_rasterizer(ctx->cso, &ctx->rasterizer); - cso_set_clip(ctx->cso, &ctx->clip); cso_set_vertex_elements(ctx->cso, 2, ctx->velem); cso_set_stream_outputs(ctx->cso, 0, NULL, 0); @@ -803,7 +798,6 @@ util_blit_pixels_tex(struct blit_state *ctx, cso_restore_fragment_shader(ctx->cso); cso_restore_vertex_shader(ctx->cso); cso_restore_geometry_shader(ctx->cso); - cso_restore_clip(ctx->cso); cso_restore_vertex_elements(ctx->cso); cso_restore_vertex_buffers(ctx->cso); cso_restore_stream_outputs(ctx->cso); diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 80fdfe0..59940d9 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -104,9 +104,6 @@ struct blitter_context_priv /* Viewport state. */ struct pipe_viewport_state viewport; - /* Clip state. */ - struct pipe_clip_state clip; - /* Destination surface dimensions. */ unsigned dst_width; unsigned dst_height; @@ -193,7 +190,6 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) ctx->dsa_write_depth_stencil = pipe->create_depth_stencil_alpha_state(pipe, &dsa); - dsa.depth.enabled = 0; dsa.depth.writemask = 0; ctx->dsa_keep_depth_write_stencil = @@ -212,6 +208,7 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) rs_state.cull_face = PIPE_FACE_NONE; rs_state.gl_rasterization_rules = 1; rs_state.flatshade = 1; + rs_state.depth_clip = 1; ctx->rs_state = pipe->create_rasterizer_state(pipe, &rs_state); if (ctx->has_stream_out) { @@ -439,7 +436,6 @@ static void blitter_restore_fragment_states(struct blitter_context_priv *ctx) * (depending on the operation) */ pipe->set_stencil_ref(pipe, &ctx->base.saved_stencil_ref); pipe->set_viewport_state(pipe, &ctx->base.saved_viewport); - pipe->set_clip_state(pipe, &ctx->base.saved_clip); } static void blitter_check_saved_fb_state(struct blitter_context_priv *ctx) @@ -516,9 +512,6 @@ static void blitter_set_rectangle(struct blitter_context_priv *ctx, ctx->viewport.translate[2] = 0.0f; ctx->viewport.translate[3] = 0.0f; ctx->base.pipe->set_viewport_state(ctx->base.pipe, &ctx->viewport); - - /* clip */ - ctx->base.pipe->set_clip_state(ctx->base.pipe, &ctx->clip); } static void blitter_set_clear_color(struct blitter_context_priv *ctx, diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h index 4dd64c5..d4d3085 100644 --- a/src/gallium/auxiliary/util/u_blitter.h +++ b/src/gallium/auxiliary/util/u_blitter.h @@ -94,7 +94,6 @@ struct blitter_context struct pipe_framebuffer_state saved_fb_state; /**< framebuffer state */ struct pipe_stencil_ref saved_stencil_ref; /**< stencil ref */ struct pipe_viewport_state saved_viewport; - struct pipe_clip_state saved_clip; int saved_num_sampler_states; void *saved_sampler_states[PIPE_MAX_SAMPLERS]; @@ -365,13 +364,6 @@ void util_blitter_save_viewport(struct blitter_context *blitter, } static INLINE -void util_blitter_save_clip(struct blitter_context *blitter, - struct pipe_clip_state *state) -{ - blitter->saved_clip = *state; -} - -static INLINE void util_blitter_save_fragment_sampler_states( struct blitter_context *blitter, int num_sampler_states, diff --git a/src/gallium/auxiliary/util/u_dump_state.c b/src/gallium/auxiliary/util/u_dump_state.c index e44c619..c728bc4 100644 --- a/src/gallium/auxiliary/util/u_dump_state.c +++ b/src/gallium/auxiliary/util/u_dump_state.c @@ -303,6 +303,8 @@ util_dump_rasterizer_state(FILE *stream, const struct pipe_rasterizer_state *sta util_dump_member(stream, bool, state, flatshade); util_dump_member(stream, bool, state, light_twoside); + util_dump_member(stream, bool, state, clamp_vertex_color); + util_dump_member(stream, bool, state, clamp_fragment_color); util_dump_member(stream, uint, state, front_ccw); util_dump_member(stream, uint, state, cull_face); util_dump_member(stream, uint, state, fill_front); @@ -326,6 +328,9 @@ util_dump_rasterizer_state(FILE *stream, const struct pipe_rasterizer_state *sta util_dump_member(stream, bool, state, line_last_pixel); util_dump_member(stream, bool, state, flatshade_first); util_dump_member(stream, bool, state, gl_rasterization_rules); + util_dump_member(stream, bool, state, rasterizer_discard); + util_dump_member(stream, bool, state, depth_clip); + util_dump_member(stream, uint, state, clip_plane_enable); util_dump_member(stream, float, state, line_width); util_dump_member(stream, float, state, point_size); @@ -413,8 +418,6 @@ util_dump_clip_state(FILE *stream, const struct pipe_clip_state *state) util_dump_array_end(stream); util_dump_member_end(stream); - util_dump_member(stream, uint, state, nr); - util_dump_struct_end(stream); } diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index 7cce815..a28d418 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -63,7 +63,6 @@ struct gen_mipmap_state struct pipe_depth_stencil_alpha_state depthstencil; struct pipe_rasterizer_state rasterizer; struct pipe_sampler_state sampler; - struct pipe_clip_state clip; struct pipe_vertex_element velem[2]; void *vs; @@ -1283,6 +1282,7 @@ util_create_gen_mipmap(struct pipe_context *pipe, memset(&ctx->rasterizer, 0, sizeof(ctx->rasterizer)); ctx->rasterizer.cull_face = PIPE_FACE_NONE; ctx->rasterizer.gl_rasterization_rules = 1; + ctx->rasterizer.depth_clip = 1; /* sampler state */ memset(&ctx->sampler, 0, sizeof(ctx->sampler)); @@ -1564,14 +1564,12 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, cso_save_vertex_shader(ctx->cso); cso_save_geometry_shader(ctx->cso); cso_save_viewport(ctx->cso); - cso_save_clip(ctx->cso); cso_save_vertex_elements(ctx->cso); /* bind our state */ cso_set_blend(ctx->cso, &ctx->blend); cso_set_depth_stencil_alpha(ctx->cso, &ctx->depthstencil); cso_set_rasterizer(ctx->cso, &ctx->rasterizer); - cso_set_clip(ctx->cso, &ctx->clip); cso_set_vertex_elements(ctx->cso, 2, ctx->velem); cso_set_stream_outputs(ctx->cso, 0, NULL, 0); @@ -1688,7 +1686,6 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, cso_restore_vertex_shader(ctx->cso); cso_restore_geometry_shader(ctx->cso); cso_restore_viewport(ctx->cso); - cso_restore_clip(ctx->cso); cso_restore_vertex_elements(ctx->cso); cso_restore_stream_outputs(ctx->cso); } diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c index 3631145..0f2210c 100644 --- a/src/gallium/auxiliary/vl/vl_compositor.c +++ b/src/gallium/auxiliary/vl/vl_compositor.c @@ -305,6 +305,7 @@ init_pipe_state(struct vl_compositor *c) rast.offset_units = 1; rast.offset_scale = 1; rast.gl_rasterization_rules = 1; + rast.depth_clip = 1; c->rast = c->pipe->create_rasterizer_state(c->pipe, &rast); diff --git a/src/gallium/auxiliary/vl/vl_idct.c b/src/gallium/auxiliary/vl/vl_idct.c index 1486c00..1166de0 100644 --- a/src/gallium/auxiliary/vl/vl_idct.c +++ b/src/gallium/auxiliary/vl/vl_idct.c @@ -517,6 +517,7 @@ init_state(struct vl_idct *idct) memset(&rs_state, 0, sizeof(rs_state)); rs_state.point_size = 1; rs_state.gl_rasterization_rules = true; + rs_state.depth_clip = 1; idct->rs_state = idct->pipe->create_rasterizer_state(idct->pipe, &rs_state); if (!idct->rs_state) goto error_rs_state; diff --git a/src/gallium/auxiliary/vl/vl_mc.c b/src/gallium/auxiliary/vl/vl_mc.c index 0f41c68..976b526 100644 --- a/src/gallium/auxiliary/vl/vl_mc.c +++ b/src/gallium/auxiliary/vl/vl_mc.c @@ -429,6 +429,7 @@ init_pipe_state(struct vl_mc *r) rs_state.point_quad_rasterization = true; rs_state.point_size = BLOCK_WIDTH; rs_state.gl_rasterization_rules = true; + rs_state.depth_clip = 1; r->rs_state = r->pipe->create_rasterizer_state(r->pipe, &rs_state); if (!r->rs_state) goto error_rs_state; diff --git a/src/gallium/auxiliary/vl/vl_zscan.c b/src/gallium/auxiliary/vl/vl_zscan.c index 730074c..6ff4056 100644 --- a/src/gallium/auxiliary/vl/vl_zscan.c +++ b/src/gallium/auxiliary/vl/vl_zscan.c @@ -270,6 +270,7 @@ init_state(struct vl_zscan *zscan) memset(&rs_state, 0, sizeof(rs_state)); rs_state.gl_rasterization_rules = true; + rs_state.depth_clip = 1; zscan->rs_state = zscan->pipe->create_rasterizer_state(zscan->pipe, &rs_state); if (!zscan->rs_state) goto error_rs_state; diff --git a/src/gallium/docs/source/cso/rasterizer.rst b/src/gallium/docs/source/cso/rasterizer.rst index a3836d9..482b1ea 100644 --- a/src/gallium/docs/source/cso/rasterizer.rst +++ b/src/gallium/docs/source/cso/rasterizer.rst @@ -227,3 +227,17 @@ gl_rasterization_rules Whether the rasterizer should use (0.5, 0.5) pixel centers. When not set, the rasterizer will use (0, 0) for pixel centers. +depth_clip + When false, the near and far depth clipping planes of the view volume are + disabled and the depth value will be clamped at the per-pixel level, after + polygon offset has been applied and before depth testing. + +clip_plane_enable + For each k in [0, PIPE_MAX_CLIP_PLANES), if bit k of this field is set, + clipping half-space k is enabled, if it is clear, it is disabled. + The clipping half-spaces are defined either by the user clip planes in + ``pipe_clip_state``, or by the clip distance outputs of the shader stage + preceding the fragment shader. + If any clip distance output is written, those half-spaces for which no + clip distance is written count as disabled; i.e. user clip planes and + shader clip distances cannot be mixed, and clip distances take precedence. diff --git a/src/gallium/docs/source/tgsi.rst b/src/gallium/docs/source/tgsi.rst index 7e7010f..fda21a2 100644 --- a/src/gallium/docs/source/tgsi.rst +++ b/src/gallium/docs/source/tgsi.rst @@ -1754,6 +1754,17 @@ Specifies that writes to the fragment shader color 0 are replicated to all bound cbufs. This facilitates OpenGL's fragColor output vs fragData[0] where fragData is directed to a single color buffer, but fragColor is broadcast. +VS_PROHIBIT_UCPS +"""""""""""""""""""""""""" +If this property is set on the program bound to the shader stage before the +fragment shader, user clip planes should have no effect (be disabled) even if +that shader does not write to any clip distance outputs and the rasterizer's +clip_plane_enable is non-zero. +This property is only supported by drivers that also support shader clip +distance outputs. +This is useful for APIs that don't have UCPs and where clip distances written +by a shader cannot be disabled. + Texture Sampling and Texture Formats ------------------------------------ diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c index 2a64ba4..5444425 100644 --- a/src/gallium/drivers/i915/i915_screen.c +++ b/src/gallium/drivers/i915/i915_screen.c @@ -185,7 +185,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap) /* Unsupported features (boolean caps). */ case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS: - case PIPE_CAP_DEPTH_CLAMP: + case PIPE_CAP_DEPTH_CLIP_DISABLE: case PIPE_CAP_INDEP_BLEND_ENABLE: case PIPE_CAP_INDEP_BLEND_FUNC: case PIPE_CAP_SHADER_STENCIL_EXPORT: diff --git a/src/gallium/drivers/i915/i915_surface.c b/src/gallium/drivers/i915/i915_surface.c index 731d2f6..1d1b6f7 100644 --- a/src/gallium/drivers/i915/i915_surface.c +++ b/src/gallium/drivers/i915/i915_surface.c @@ -66,7 +66,6 @@ i915_surface_copy_render(struct pipe_context *pipe, util_blitter_save_fragment_shader(i915->blitter, i915->saved_fs); util_blitter_save_vertex_shader(i915->blitter, i915->saved_vs); util_blitter_save_viewport(i915->blitter, &i915->viewport); - util_blitter_save_clip(i915->blitter, &i915->saved_clip); util_blitter_save_vertex_elements(i915->blitter, i915->saved_velems); util_blitter_save_vertex_buffers(i915->blitter, i915->saved_nr_vertex_buffers, i915->saved_vertex_buffers); diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 98b838b..5798a19 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -150,7 +150,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param) return 1; case PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE: return 1; - case PIPE_CAP_DEPTH_CLAMP: + case PIPE_CAP_DEPTH_CLIP_DISABLE: return 0; case PIPE_CAP_TGSI_INSTANCEID: case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR: diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 15f579e..4f22284 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -103,7 +103,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE: return 0; case PIPE_CAP_TWO_SIDED_STENCIL: - case PIPE_CAP_DEPTH_CLAMP: + case PIPE_CAP_DEPTH_CLIP_DISABLE: case PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE: case PIPE_CAP_POINT_SPRITE: return 1; diff --git a/src/gallium/drivers/nv50/nv50_shader_state.c b/src/gallium/drivers/nv50/nv50_shader_state.c index d73f7c7..d3cdb69 100644 --- a/src/gallium/drivers/nv50/nv50_shader_state.c +++ b/src/gallium/drivers/nv50/nv50_shader_state.c @@ -171,12 +171,6 @@ nv50_vertprog_validate(struct nv50_context *nv50) struct nouveau_channel *chan = nv50->screen->base.channel; struct nv50_program *vp = nv50->vertprog; - if (nv50->clip.nr > vp->vp.clpd_nr) { - if (vp->translated) - nv50_program_destroy(nv50, vp); - vp->vp.clpd_nr = nv50->clip.nr; - } - if (!nv50_program_validate(nv50, vp)) return; diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c index ede8713..0f46afb 100644 --- a/src/gallium/drivers/nv50/nv50_state.c +++ b/src/gallium/drivers/nv50/nv50_state.c @@ -225,6 +225,7 @@ nv50_rasterizer_state_create(struct pipe_context *pipe, const struct pipe_rasterizer_state *cso) { struct nv50_rasterizer_stateobj *so; + uint32_t reg; so = CALLOC_STRUCT(nv50_rasterizer_stateobj); if (!so) @@ -312,6 +313,22 @@ nv50_rasterizer_state_create(struct pipe_context *pipe, SB_DATA (so, fui(cso->offset_clamp)); } + if (cso->depth_clip) { + reg = 0; + } else { + reg = + NV50_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_CLAMP_NEAR | + NV50_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_CLAMP_FAR | + NV50_3D_VIEW_VOLUME_CLIP_CTRL_UNK12_UNK1; + } +#ifndef NV50_SCISSORS_CLIPPING + reg |= + NV50_3D_VIEW_VOLUME_CLIP_CTRL_UNK7 | + NV50_3D_VIEW_VOLUME_CLIP_CTRL_UNK12_UNK1; +#endif + SB_BEGIN_3D(so, VIEW_VOLUME_CLIP_CTRL, 1); + SB_DATA (so, reg); + assert(so->size <= (sizeof(so->state) / sizeof(so->state[0]))); return (void *)so; } @@ -763,12 +780,8 @@ nv50_set_clip_state(struct pipe_context *pipe, const struct pipe_clip_state *clip) { struct nv50_context *nv50 = nv50_context(pipe); - const unsigned size = clip->nr * sizeof(clip->ucp[0]); - - memcpy(&nv50->clip.ucp[0][0], &clip->ucp[0][0], size); - nv50->clip.nr = clip->nr; - nv50->clip.depth_clamp = clip->depth_clamp; + memcpy(nv50->clip.ucp, clip->ucp, sizeof(clip->ucp)); nv50->dirty |= NV50_NEW_CLIP; } diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index 05f32ea..edf648e 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -213,42 +213,48 @@ nv50_validate_viewport(struct nv50_context *nv50) #endif } +static INLINE void +nv50_check_program_ucps(struct nv50_context *nv50, + struct nv50_program *vp, uint8_t mask) +{ + const unsigned n = util_logbase2(mask) + 1; + + if (vp->vp.clpd_nr >= n) + return; + nv50_program_destroy(nv50, vp); + + vp->vp.clpd_nr = n; + if (likely(vp == nv50->vertprog)) + nv50_vertprog_validate(nv50); + else + nv50_gmtyprog_validate(nv50); + nv50_fp_linkage_validate(nv50); +} + static void nv50_validate_clip(struct nv50_context *nv50) { struct nouveau_channel *chan = nv50->screen->base.channel; - uint32_t clip; - - if (nv50->clip.depth_clamp) { - clip = - NV50_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_CLAMP_NEAR | - NV50_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_CLAMP_FAR | - NV50_3D_VIEW_VOLUME_CLIP_CTRL_UNK12_UNK1; - } else { - clip = 0; - } - -#ifndef NV50_SCISSORS_CLIPPING - clip |= - NV50_3D_VIEW_VOLUME_CLIP_CTRL_UNK7 | - NV50_3D_VIEW_VOLUME_CLIP_CTRL_UNK12_UNK1; -#endif - - BEGIN_RING(chan, RING_3D(VIEW_VOLUME_CLIP_CTRL), 1); - OUT_RING (chan, clip); + struct nv50_program *vp; + uint8_t clip_enable; - if (nv50->clip.nr) { + if (nv50->dirty & NV50_NEW_CLIP) { BEGIN_RING(chan, RING_3D(CB_ADDR), 1); OUT_RING (chan, (0 << 8) | NV50_CB_AUX); - BEGIN_RING_NI(chan, RING_3D(CB_DATA(0)), nv50->clip.nr * 4); - OUT_RINGp (chan, &nv50->clip.ucp[0][0], nv50->clip.nr * 4); + BEGIN_RING_NI(chan, RING_3D(CB_DATA(0)), PIPE_MAX_CLIP_PLANES * 4); + OUT_RINGp (chan, &nv50->clip.ucp[0][0], PIPE_MAX_CLIP_PLANES * 4); } + vp = nv50->gmtyprog; + if (likely(!vp)) + vp = nv50->vertprog; + + clip_enable = nv50->rast->pipe.clip_plane_enable; + BEGIN_RING(chan, RING_3D(VP_CLIP_DISTANCE_ENABLE), 1); - OUT_RING (chan, (1 << nv50->clip.nr) - 1); + OUT_RING (chan, clip_enable); - if (nv50->vertprog && nv50->clip.nr > nv50->vertprog->vp.clpd_nr) - nv50->dirty |= NV50_NEW_VERTPROG; + nv50_check_program_ucps(nv50, vp, clip_enable); } static void @@ -350,7 +356,8 @@ static struct state_validate { { nv50_validate_scissor, NV50_NEW_SCISSOR }, #endif { nv50_validate_viewport, NV50_NEW_VIEWPORT }, - { nv50_validate_clip, NV50_NEW_CLIP }, + { nv50_validate_clip, NV50_NEW_CLIP | NV50_NEW_RASTERIZER | + NV50_NEW_VERTPROG | NV50_NEW_GMTYPROG }, { nv50_vertprog_validate, NV50_NEW_VERTPROG }, { nv50_gmtyprog_validate, NV50_NEW_GMTYPROG }, { nv50_fragprog_validate, NV50_NEW_FRAGPROG }, diff --git a/src/gallium/drivers/nv50/nv50_stateobj.h b/src/gallium/drivers/nv50/nv50_stateobj.h index 83a08b0..c443dfb 100644 --- a/src/gallium/drivers/nv50/nv50_stateobj.h +++ b/src/gallium/drivers/nv50/nv50_stateobj.h @@ -27,7 +27,7 @@ struct nv50_blend_stateobj { struct nv50_rasterizer_stateobj { struct pipe_rasterizer_state pipe; int size; - uint32_t state[46]; + uint32_t state[48]; }; struct nv50_zsa_stateobj { diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c index 910e18f..28e34bd 100644 --- a/src/gallium/drivers/nv50/nv50_surface.c +++ b/src/gallium/drivers/nv50/nv50_surface.c @@ -433,7 +433,6 @@ struct nv50_blitctx struct pipe_sampler_view *texture; struct nv50_tsc_entry *sampler; unsigned dirty; - unsigned clip_nr; } saved; struct nv50_program vp; struct nv50_program fp; @@ -775,10 +774,6 @@ nv50_blitctx_pre_blit(struct nv50_blitctx *blit, struct nv50_context *nv50) nv50->gmtyprog = NULL; nv50->fragprog = &blit->fp; - blit->saved.clip_nr = nv50->clip.nr; - - nv50->clip.nr = 0; - for (s = 0; s < 3; ++s) { blit->saved.num_textures[s] = nv50->num_textures[s]; blit->saved.num_samplers[s] = nv50->num_samplers[s]; @@ -816,8 +811,6 @@ nv50_blitctx_post_blit(struct nv50_context *nv50, struct nv50_blitctx *blit) nv50->gmtyprog = blit->saved.gp; nv50->fragprog = blit->saved.fp; - nv50->clip.nr = blit->saved.clip_nr; - pipe_sampler_view_reference(&nv50->textures[2][0], NULL); for (s = 0; s < 3; ++s) { diff --git a/src/gallium/drivers/nvc0/nvc0_screen.c b/src/gallium/drivers/nvc0/nvc0_screen.c index 8c14f9e..069e68f 100644 --- a/src/gallium/drivers/nvc0/nvc0_screen.c +++ b/src/gallium/drivers/nvc0/nvc0_screen.c @@ -92,7 +92,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE: return 0; case PIPE_CAP_TWO_SIDED_STENCIL: - case PIPE_CAP_DEPTH_CLAMP: + case PIPE_CAP_DEPTH_CLIP_DISABLE: case PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE: case PIPE_CAP_POINT_SPRITE: return 1; diff --git a/src/gallium/drivers/nvc0/nvc0_shader_state.c b/src/gallium/drivers/nvc0/nvc0_shader_state.c index 446bd94..630ad20 100644 --- a/src/gallium/drivers/nvc0/nvc0_shader_state.c +++ b/src/gallium/drivers/nvc0/nvc0_shader_state.c @@ -59,25 +59,6 @@ nvc0_program_update_context_state(struct nvc0_context *nvc0, } } -static void -nvc0_program_validate_clip(struct nvc0_context *nvc0, struct nvc0_program *vp) -{ - struct nouveau_channel *chan = nvc0->screen->base.channel; - - if (nvc0->vertprog->vp.num_ucps) - return; - - if (nvc0->state.clip_enable != vp->vp.clip_enable) { - nvc0->state.clip_enable = vp->vp.clip_enable; - IMMED_RING(chan, RING_3D(CLIP_DISTANCE_ENABLE), vp->vp.clip_enable); - } - if (nvc0->state.clip_mode != vp->vp.clip_mode) { - nvc0->state.clip_mode = vp->vp.clip_mode; - BEGIN_RING(chan, RING_3D(CLIP_DISTANCE_MODE), 1); - OUT_RING (chan, vp->vp.clip_mode); - } -} - static INLINE boolean nvc0_program_validate(struct nvc0_context *nvc0, struct nvc0_program *prog) { @@ -101,14 +82,6 @@ nvc0_vertprog_validate(struct nvc0_context *nvc0) struct nouveau_channel *chan = nvc0->screen->base.channel; struct nvc0_program *vp = nvc0->vertprog; - if (nvc0->clip.nr > vp->vp.num_ucps) { - assert(nvc0->clip.nr <= 6); - vp->vp.num_ucps = 6; - - if (vp->translated) - nvc0_program_destroy(nvc0, vp); - } - if (!nvc0_program_validate(nvc0, vp)) return; nvc0_program_update_context_state(nvc0, vp, 0); @@ -119,9 +92,6 @@ nvc0_vertprog_validate(struct nvc0_context *nvc0) BEGIN_RING(chan, RING_3D(SP_GPR_ALLOC(1)), 1); OUT_RING (chan, vp->max_gpr); - if (!nvc0->gmtyprog && !nvc0->tevlprog) - nvc0_program_validate_clip(nvc0, vp); - // BEGIN_RING(chan, RING_3D_(0x163c), 1); // OUT_RING (chan, 0); } @@ -203,9 +173,6 @@ nvc0_tevlprog_validate(struct nvc0_context *nvc0) OUT_RING (chan, tp->code_base); BEGIN_RING(chan, RING_3D(SP_GPR_ALLOC(3)), 1); OUT_RING (chan, tp->max_gpr); - - if (!nvc0->gmtyprog) - nvc0_program_validate_clip(nvc0, tp); } void @@ -233,8 +200,6 @@ nvc0_gmtyprog_validate(struct nvc0_context *nvc0) OUT_RING (chan, gp->max_gpr); BEGIN_RING(chan, RING_3D(LAYER), 1); OUT_RING (chan, (gp->hdr[13] & (1 << 9)) ? NVC0_3D_LAYER_USE_GP : 0); - - nvc0_program_validate_clip(nvc0, gp); } void diff --git a/src/gallium/drivers/nvc0/nvc0_state.c b/src/gallium/drivers/nvc0/nvc0_state.c index 1e334a0..32b7a8a 100644 --- a/src/gallium/drivers/nvc0/nvc0_state.c +++ b/src/gallium/drivers/nvc0/nvc0_state.c @@ -270,6 +270,18 @@ nvc0_rasterizer_state_create(struct pipe_context *pipe, SB_DATA (so, fui(cso->offset_clamp)); } + if (cso->depth_clip) + reg = NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK1_UNK1; + else + reg = + NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK1_UNK1 | + NVC0_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_CLAMP_NEAR | + NVC0_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_CLAMP_FAR | + NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK12_UNK2; + + SB_BEGIN_3D(so, VIEW_VOLUME_CLIP_CTRL, 1); + SB_DATA (so, reg); + assert(so->size <= (sizeof(so->state) / sizeof(so->state[0]))); return (void *)so; } @@ -647,12 +659,8 @@ nvc0_set_clip_state(struct pipe_context *pipe, const struct pipe_clip_state *clip) { struct nvc0_context *nvc0 = nvc0_context(pipe); - const unsigned size = clip->nr * sizeof(clip->ucp[0]); - - memcpy(&nvc0->clip.ucp[0][0], &clip->ucp[0][0], size); - nvc0->clip.nr = clip->nr; - nvc0->clip.depth_clamp = clip->depth_clamp; + memcpy(nvc0->clip.ucp, clip->ucp, sizeof(clip->ucp)); nvc0->dirty |= NVC0_NEW_CLIP; } diff --git a/src/gallium/drivers/nvc0/nvc0_state_validate.c b/src/gallium/drivers/nvc0/nvc0_state_validate.c index 0dc822a..472ddee 100644 --- a/src/gallium/drivers/nvc0/nvc0_state_validate.c +++ b/src/gallium/drivers/nvc0/nvc0_state_validate.c @@ -260,43 +260,74 @@ nvc0_validate_viewport(struct nvc0_context *nvc0) OUT_RINGf (chan, zmax); } +static INLINE void +nvc0_upload_uclip_planes(struct nvc0_context *nvc0) +{ + struct nouveau_channel *chan = nvc0->screen->base.channel; + struct nouveau_bo *bo = nvc0->screen->uniforms; + + MARK_RING (chan, 6 + PIPE_MAX_CLIP_PLANES * 4, 2); + BEGIN_RING(chan, RING_3D(CB_SIZE), 3); + OUT_RING (chan, 256); + OUT_RELOCh(chan, bo, 5 << 16, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); + OUT_RELOCl(chan, bo, 5 << 16, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); + BEGIN_RING_1I(chan, RING_3D(CB_POS), PIPE_MAX_CLIP_PLANES * 4 + 1); + OUT_RING (chan, 0); + OUT_RINGp (chan, &nvc0->clip.ucp[0][0], PIPE_MAX_CLIP_PLANES * 4); +} + +static INLINE void +nvc0_check_program_ucps(struct nvc0_context *nvc0, + struct nvc0_program *vp, uint8_t mask) +{ + const unsigned n = util_logbase2(mask) + 1; + + if (vp->vp.num_ucps >= n) + return; + nvc0_program_destroy(nvc0, vp); + + vp->vp.num_ucps = n; + if (likely(vp == nvc0->vertprog)) + nvc0_vertprog_validate(nvc0); + else + if (likely(vp == nvc0->gmtyprog)) + nvc0_vertprog_validate(nvc0); + else + nvc0_tevlprog_validate(nvc0); +} + static void nvc0_validate_clip(struct nvc0_context *nvc0) { struct nouveau_channel *chan = nvc0->screen->base.channel; - uint32_t clip; - - if (nvc0->clip.depth_clamp) { - clip = - NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK1_UNK1 | - NVC0_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_CLAMP_NEAR | - NVC0_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_CLAMP_FAR | - NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK12_UNK2; - } else { - clip = NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK1_UNK1; - } + struct nvc0_program *vp; + uint8_t clip_enable; - BEGIN_RING(chan, RING_3D(VIEW_VOLUME_CLIP_CTRL), 1); - OUT_RING (chan, clip); + if (nvc0->dirty & NVC0_NEW_CLIP) + nvc0_upload_uclip_planes(nvc0); - if (nvc0->clip.nr) { - struct nouveau_bo *bo = nvc0->screen->uniforms; + vp = nvc0->gmtyprog; + if (!vp) { + vp = nvc0->tevlprog; + if (!vp) + vp = nvc0->vertprog; + } + clip_enable = vp->vp.clip_enable; - MARK_RING (chan, 6 + nvc0->clip.nr * 4, 2); - BEGIN_RING(chan, RING_3D(CB_SIZE), 3); - OUT_RING (chan, 256); - OUT_RELOCh(chan, bo, 5 << 16, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); - OUT_RELOCl(chan, bo, 5 << 16, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); - BEGIN_RING_1I(chan, RING_3D(CB_POS), nvc0->clip.nr * 4 + 1); - OUT_RING (chan, 0); - OUT_RINGp (chan, &nvc0->clip.ucp[0][0], nvc0->clip.nr * 4); + if (!clip_enable) { + clip_enable = nvc0->rast->pipe.clip_plane_enable; + if (unlikely(clip_enable)) + nvc0_check_program_ucps(nvc0, vp, clip_enable); } - if (nvc0->vertprog->vp.num_ucps) { - nvc0->state.clip_mode = 0; - nvc0->state.clip_enable = (1 << nvc0->clip.nr) - 1; - IMMED_RING(chan, RING_3D(CLIP_DISTANCE_ENABLE), nvc0->state.clip_enable); - IMMED_RING(chan, RING_3D(CLIP_DISTANCE_MODE), 0); + if (nvc0->state.clip_enable != clip_enable) { + nvc0->state.clip_enable = clip_enable; + IMMED_RING(chan, RING_3D(CLIP_DISTANCE_ENABLE), clip_enable); + } + if (nvc0->state.clip_mode != vp->vp.clip_mode) { + nvc0->state.clip_mode = vp->vp.clip_mode; + BEGIN_RING(chan, RING_3D(CLIP_DISTANCE_MODE), 1); + OUT_RING (chan, vp->vp.clip_mode); } } @@ -497,7 +528,10 @@ static struct state_validate { { nvc0_fragprog_validate, NVC0_NEW_FRAGPROG }, { nvc0_validate_derived_1, NVC0_NEW_FRAGPROG | NVC0_NEW_ZSA | NVC0_NEW_RASTERIZER }, - { nvc0_validate_clip, NVC0_NEW_CLIP }, + { nvc0_validate_clip, NVC0_NEW_CLIP | NVC0_NEW_RASTERIZER | + NVC0_NEW_VERTPROG | + NVC0_NEW_TEVLPROG | + NVC0_NEW_GMTYPROG }, { nvc0_constbufs_validate, NVC0_NEW_CONSTBUF }, { nvc0_validate_textures, NVC0_NEW_TEXTURES }, { nvc0_validate_samplers, NVC0_NEW_SAMPLERS }, diff --git a/src/gallium/drivers/nvc0/nvc0_stateobj.h b/src/gallium/drivers/nvc0/nvc0_stateobj.h index 5c0d0c1..dc5771a 100644 --- a/src/gallium/drivers/nvc0/nvc0_stateobj.h +++ b/src/gallium/drivers/nvc0/nvc0_stateobj.h @@ -25,7 +25,7 @@ struct nvc0_blend_stateobj { struct nvc0_rasterizer_stateobj { struct pipe_rasterizer_state pipe; int size; - uint32_t state[41]; + uint32_t state[43]; }; struct nvc0_zsa_stateobj { diff --git a/src/gallium/drivers/nvc0/nvc0_surface.c b/src/gallium/drivers/nvc0/nvc0_surface.c index a2e1a85..46b5da5 100644 --- a/src/gallium/drivers/nvc0/nvc0_surface.c +++ b/src/gallium/drivers/nvc0/nvc0_surface.c @@ -461,7 +461,6 @@ struct nvc0_blitctx struct pipe_sampler_view *texture; struct nv50_tsc_entry *sampler; unsigned dirty; - unsigned clip_nr; } saved; struct nvc0_program vp; struct nvc0_program fp; @@ -771,10 +770,6 @@ nvc0_blitctx_pre_blit(struct nvc0_blitctx *blit, struct nvc0_context *nvc0) nvc0->tevlprog = NULL; nvc0->gmtyprog = NULL; - blit->saved.clip_nr = nvc0->clip.nr; - - nvc0->clip.nr = 0; - for (s = 0; s <= 4; ++s) { blit->saved.num_textures[s] = nvc0->num_textures[s]; blit->saved.num_samplers[s] = nvc0->num_samplers[s]; @@ -815,8 +810,6 @@ nvc0_blitctx_post_blit(struct nvc0_context *nvc0, struct nvc0_blitctx *blit) nvc0->gmtyprog = blit->saved.gp; nvc0->fragprog = blit->saved.fp; - nvc0->clip.nr = blit->saved.clip_nr; - pipe_sampler_view_reference(&nvc0->textures[4][0], NULL); for (s = 0; s <= 4; ++s) { diff --git a/src/gallium/drivers/nvfx/nvfx_screen.c b/src/gallium/drivers/nvfx/nvfx_screen.c index abf4937..b4a1b3a 100644 --- a/src/gallium/drivers/nvfx/nvfx_screen.c +++ b/src/gallium/drivers/nvfx/nvfx_screen.c @@ -73,7 +73,7 @@ nvfx_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: return 1; - case PIPE_CAP_DEPTH_CLAMP: + case PIPE_CAP_DEPTH_CLIP_DISABLE: return 0; // TODO: implement depth clamp case PIPE_CAP_PRIMITIVE_RESTART: return 0; // TODO: implement primitive restart diff --git a/src/gallium/drivers/nvfx/nvfx_state_emit.c b/src/gallium/drivers/nvfx/nvfx_state_emit.c index ae9c314..25da80e 100644 --- a/src/gallium/drivers/nvfx/nvfx_state_emit.c +++ b/src/gallium/drivers/nvfx/nvfx_state_emit.c @@ -114,16 +114,23 @@ nvfx_ucp_validate(struct nvfx_context* nvfx) { struct nouveau_channel* chan = nvfx->screen->base.channel; struct nouveau_grobj *eng3d = nvfx->screen->eng3d; - unsigned enables[7] = + unsigned enables[] = { - 0, NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE0, - NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE0 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE1, - NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE0 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE1 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE2, - NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE0 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE1 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE2 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE3, - NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE0 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE1 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE2 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE3 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE4, - NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE0 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE1 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE2 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE3 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE4 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE5, + NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE1, + NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE2, + NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE3, + NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE4, + NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE5 }; + unsigned i, enable = 0, nr = 0; + + for (i = 0; i < 6; i++) { + if (nvfx->rasterizer->pipe.clip_plane_enable & (1 << i)) { + enable |= enables[i]; + nr = i+1; + } + } if(!nvfx->use_vp_clipping) { @@ -131,12 +138,12 @@ nvfx_ucp_validate(struct nvfx_context* nvfx) OUT_RING(chan, 0); BEGIN_RING(chan, eng3d, NV30_3D_VP_CLIP_PLANE(0, 0), - nvfx->clip.nr * 4); - OUT_RINGp(chan, &nvfx->clip.ucp[0][0], nvfx->clip.nr * 4); + nr * 4); + OUT_RINGp(chan, &nvfx->clip.ucp[0][0], nr * 4); } BEGIN_RING(chan, eng3d, NV30_3D_VP_CLIP_PLANES_ENABLE, 1); - OUT_RING(chan, enables[nvfx->clip.nr]); + OUT_RING(chan, enable); } static void @@ -146,7 +153,10 @@ nvfx_vertprog_ucp_validate(struct nvfx_context* nvfx) struct nouveau_grobj *eng3d = nvfx->screen->eng3d; unsigned i; struct nvfx_vertex_program* vp = nvfx->hw_vertprog; - if(nvfx->clip.nr != vp->clip_nr) + unsigned enable = nvfx->rasterizer->pipe.clip_plane_enable; + unsigned nr = util_bitcount(enable); + + if(nr != vp->clip_nr) { unsigned idx; @@ -161,21 +171,24 @@ nvfx_vertprog_ucp_validate(struct nvfx_context* nvfx) } /* set last instruction bit */ - idx = vp->nr_insns - 7 + nvfx->clip.nr; + idx = vp->nr_insns - 7 + nr; BEGIN_RING(chan, eng3d, NV30_3D_VP_UPLOAD_FROM_ID, 1); OUT_RING(chan, vp->exec->start + idx); BEGIN_RING(chan, eng3d, NV30_3D_VP_UPLOAD_INST(0), 4); OUT_RINGp(chan, vp->insns[idx].data, 3); OUT_RING(chan, vp->insns[idx].data[3] | 1); - vp->clip_nr = nvfx->clip.nr; + vp->clip_nr = nr; } // TODO: only do this for the ones changed - for(i = 0; i < nvfx->clip.nr; ++i) + for(i = 0; enable; ++i) { + unsigned index = ffs(enable) - 1; + enable &= ~(1 << index); + BEGIN_RING(chan, eng3d, NV30_3D_VP_UPLOAD_CONST_ID, 5); OUT_RING(chan, vp->data->start + i); - OUT_RINGp (chan, nvfx->clip.ucp[i], 4); + OUT_RINGp (chan, nvfx->clip.ucp[index], 4); } } @@ -266,10 +279,10 @@ nvfx_state_validate_common(struct nvfx_context *nvfx) if(dirty & NVFX_NEW_STIPPLE) nvfx_state_stipple_validate(nvfx); - if(nvfx->dirty & NVFX_NEW_UCP) + if(nvfx->dirty & (NVFX_NEW_UCP | NVFX_NEW_RAST)) nvfx_ucp_validate(nvfx); - if(nvfx->use_vp_clipping && (nvfx->dirty & (NVFX_NEW_UCP | NVFX_NEW_VERTPROG))) + if(nvfx->use_vp_clipping && (nvfx->dirty & (NVFX_NEW_UCP | NVFX_NEW_VERTPROG | NVFX_NEW_RAST))) nvfx_vertprog_ucp_validate(nvfx); if(dirty & (NVFX_NEW_FRAGPROG | NVFX_NEW_FRAGCONST | NVFX_NEW_VERTPROG | NVFX_NEW_SPRITE)) @@ -282,7 +295,7 @@ nvfx_state_validate_common(struct nvfx_context *nvfx) if(nvfx->is_nv4x) { unsigned vp_output = nvfx->hw_vertprog->or | nvfx->hw_fragprog->or; - vp_output |= (1 << (nvfx->clip.nr + 6)) - (1 << 6); + vp_output |= ((1 << (nvfx->rasterizer->pipe.clip_plane_enable & 63)) - 1) << 6; if(vp_output != nvfx->hw_vp_output) { diff --git a/src/gallium/drivers/nvfx/nvfx_surface.c b/src/gallium/drivers/nvfx/nvfx_surface.c index d489bbf..cac3fca 100644 --- a/src/gallium/drivers/nvfx/nvfx_surface.c +++ b/src/gallium/drivers/nvfx/nvfx_surface.c @@ -187,7 +187,6 @@ nvfx_get_blitter(struct pipe_context* pipe, int copy) util_blitter_save_vertex_shader(blitter, nvfx->vertprog); util_blitter_save_viewport(blitter, &nvfx->viewport); util_blitter_save_framebuffer(blitter, &nvfx->framebuffer); - util_blitter_save_clip(blitter, &nvfx->clip); util_blitter_save_vertex_elements(blitter, nvfx->vtxelt); util_blitter_save_vertex_buffers(blitter, nvfx->vtxbuf_nr, nvfx->vtxbuf); diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index c780c8d..d132638 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -62,7 +62,6 @@ static void r300_blitter_begin(struct r300_context* r300, enum r300_blitter_op o util_blitter_save_fragment_shader(r300->blitter, r300->fs.state); util_blitter_save_vertex_shader(r300->blitter, r300->vs_state.state); util_blitter_save_viewport(r300->blitter, &r300->viewport); - util_blitter_save_clip(r300->blitter, (struct pipe_clip_state*)r300->clip_state.state); util_blitter_save_vertex_elements(r300->blitter, r300->velems); util_blitter_save_vertex_buffers(r300->blitter, r300->vbuf_mgr->nr_vertex_buffers, r300->vbuf_mgr->vertex_buffer); diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index fb9f34a..7d289ca 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -204,7 +204,7 @@ static boolean r300_setup_atoms(struct r300_context* r300) R300_INIT_ATOM(vertex_stream_state, 0); R300_INIT_ATOM(vs_state, 0); R300_INIT_ATOM(vs_constants, 0); - R300_INIT_ATOM(clip_state, has_tcl ? 5 + (6 * 4) : 2); + R300_INIT_ATOM(clip_state, has_tcl ? 3 + (6 * 4) : 0); /* VAP, RS, GA, GB, SU, SC. */ R300_INIT_ATOM(rs_block_state, 0); R300_INIT_ATOM(rs_state, 0); @@ -277,8 +277,6 @@ static void r300_init_states(struct pipe_context *pipe) struct pipe_blend_color bc = {{0}}; struct pipe_clip_state cs = {{{0}}}; struct pipe_scissor_state ss = {0}; - struct r300_clip_state *clip = - (struct r300_clip_state*)r300->clip_state.state; struct r300_gpu_flush *gpuflush = (struct r300_gpu_flush*)r300->gpu_flush.state; struct r300_vap_invariant_state *vap_invariant = @@ -289,17 +287,9 @@ static void r300_init_states(struct pipe_context *pipe) CB_LOCALS; pipe->set_blend_color(pipe, &bc); + pipe->set_clip_state(pipe, &cs); pipe->set_scissor_state(pipe, &ss); - /* Initialize the clip state. */ - if (r300->screen->caps.has_tcl) { - pipe->set_clip_state(pipe, &cs); - } else { - BEGIN_CB(clip->cb, 2); - OUT_CB_REG(R300_VAP_CLIP_CNTL, R300_CLIP_DISABLE); - END_CB; - } - /* Initialize the GPU flush. */ { BEGIN_CB(gpuflush->cb_flush_clean, 6); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 5588e51..e40b7af 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -78,8 +78,6 @@ struct r300_blend_color_state { }; struct r300_clip_state { - struct pipe_clip_state clip; - uint32_t cb[29]; }; @@ -139,7 +137,7 @@ struct r300_gpu_flush { uint32_t cb_flush_clean[6]; }; -#define RS_STATE_MAIN_SIZE 25 +#define RS_STATE_MAIN_SIZE 27 struct r300_rs_state { /* Original rasterizer state. */ diff --git a/src/gallium/drivers/r300/r300_flush.c b/src/gallium/drivers/r300/r300_flush.c index f854644..2266b48 100644 --- a/src/gallium/drivers/r300/r300_flush.c +++ b/src/gallium/drivers/r300/r300_flush.c @@ -59,6 +59,7 @@ static void r300_flush_and_cleanup(struct r300_context *r300, unsigned flags) if (!r300->screen->caps.has_tcl) { r300->vs_state.dirty = FALSE; r300->vs_constants.dirty = FALSE; + r300->clip_state.dirty = FALSE; } } diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 7f04c93..83cad42 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -1194,7 +1194,6 @@ static void r300_blitter_draw_rectangle(struct blitter_context *blitter, r300_update_derived_state(r300); /* Mark some states we don't care about as non-dirty. */ - r300->clip_state.dirty = FALSE; r300->viewport_state.dirty = FALSE; if (!r300_prepare_for_rendering(r300, PREP_EMIT_STATES, NULL, dwords, 0, 0, -1)) @@ -1244,7 +1243,6 @@ static void r300_blitter_draw_rectangle(struct blitter_context *blitter, done: /* Restore the state. */ - r300_mark_atom_dirty(r300, &r300->clip_state); r300_mark_atom_dirty(r300, &r300->rs_state); r300_mark_atom_dirty(r300, &r300->viewport_state); diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index d79ed99..763321b 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -119,7 +119,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param) case PIPE_CAP_DUAL_SOURCE_BLEND: case PIPE_CAP_INDEP_BLEND_ENABLE: case PIPE_CAP_INDEP_BLEND_FUNC: - case PIPE_CAP_DEPTH_CLAMP: + case PIPE_CAP_DEPTH_CLIP_DISABLE: case PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE: case PIPE_CAP_SHADER_STENCIL_EXPORT: case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS: diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 3606e0b..2bc7036 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -493,21 +493,13 @@ static void r300_set_clip_state(struct pipe_context* pipe, (struct r300_clip_state*)r300->clip_state.state; CB_LOCALS; - clip->clip = *state; - if (r300->screen->caps.has_tcl) { - r300->clip_state.size = 2 + !!state->nr * 3 + state->nr * 4; - BEGIN_CB(clip->cb, r300->clip_state.size); - if (state->nr) { - OUT_CB_REG(R300_VAP_PVS_VECTOR_INDX_REG, + OUT_CB_REG(R300_VAP_PVS_VECTOR_INDX_REG, (r300->screen->caps.is_r500 ? R500_PVS_UCP_START : R300_PVS_UCP_START)); - OUT_CB_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, state->nr * 4); - OUT_CB_TABLE(state->ucp, state->nr * 4); - } - OUT_CB_REG(R300_VAP_CLIP_CNTL, ((1 << state->nr) - 1) | - R300_PS_UCP_MODE_CLIP_AS_TRIFAN); + OUT_CB_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, 6 * 4); + OUT_CB_TABLE(state->ucp, 6 * 4); END_CB; r300_mark_atom_dirty(r300, &r300->clip_state); @@ -1027,6 +1019,7 @@ static void* r300_create_rs_state(struct pipe_context* pipe, struct r300_rs_state* rs = CALLOC_STRUCT(r300_rs_state); float psiz; uint32_t vap_control_status; /* R300_VAP_CNTL_STATUS: 0x2140 */ + uint32_t vap_clip_cntl; /* R300_VAP_CLIP_CNTL: 0x221C */ uint32_t point_size; /* R300_GA_POINT_SIZE: 0x421c */ uint32_t point_minmax; /* R300_GA_POINT_MINMAX: 0x4230 */ uint32_t line_control; /* R300_GA_LINE_CNTL: 0x4234 */ @@ -1166,6 +1159,13 @@ static void* r300_create_rs_state(struct pipe_context* pipe, } } + if (r300_screen(pipe->screen)->caps.has_tcl) { + vap_clip_cntl = (state->clip_plane_enable & 63) | + R300_PS_UCP_MODE_CLIP_AS_TRIFAN; + } else { + vap_clip_cntl = R300_CLIP_DISABLE; + } + /* Vertex color clamping. FP20 means no clamping. */ round_mode = R300_GA_ROUND_MODE_GEOMETRY_ROUND_NEAREST | @@ -1175,13 +1175,14 @@ static void* r300_create_rs_state(struct pipe_context* pipe, /* Build the main command buffer. */ BEGIN_CB(rs->cb_main, RS_STATE_MAIN_SIZE); OUT_CB_REG(R300_VAP_CNTL_STATUS, vap_control_status); + OUT_CB_REG(R300_VAP_CLIP_CNTL, vap_clip_cntl); OUT_CB_REG(R300_GA_POINT_SIZE, point_size); OUT_CB_REG_SEQ(R300_GA_POINT_MINMAX, 2); OUT_CB(point_minmax); OUT_CB(line_control); OUT_CB_REG_SEQ(R300_SU_POLY_OFFSET_ENABLE, 2); OUT_CB(polygon_offset_enable); - rs->cull_mode_index = 9; + rs->cull_mode_index = 11; OUT_CB(cull_mode); OUT_CB_REG(R300_GA_LINE_STIPPLE_CONFIG, line_stipple_config); OUT_CB_REG(R300_GA_LINE_STIPPLE_VALUE, line_stipple_value); diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index 7ded03d..f3aab69 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -986,6 +986,10 @@ static void *evergreen_create_rs_state(struct pipe_context *ctx, } r600_pipe_state_add_reg(rstate, R_028B7C_PA_SU_POLY_OFFSET_CLAMP, fui(state->offset_clamp), 0xFFFFFFFF, NULL, 0); r600_pipe_state_add_reg(rstate, R_02820C_PA_SC_CLIPRECT_RULE, clip_rule, 0xFFFFFFFF, NULL, 0); + r600_pipe_state_add_reg(rstate, R_028810_PA_CL_CLIP_CNTL, + S_028810_PS_UCP_MODE(3) | (state->clip_plane_enable & 63) | + S_028810_ZCLIP_NEAR_DISABLE(!state->depth_clip) | + S_028810_ZCLIP_FAR_DISABLE(!state->depth_clip), 0xFFFFFFFF, NULL, 0); return rstate; } @@ -1206,7 +1210,7 @@ static void evergreen_set_clip_state(struct pipe_context *ctx, rctx->clip = *state; rstate->id = R600_PIPE_STATE_CLIP; - for (int i = 0; i < state->nr; i++) { + for (int i = 0; i < 6; i++) { r600_pipe_state_add_reg(rstate, R_0285BC_PA_CL_UCP0_X + i * 16, fui(state->ucp[i][0]), 0xFFFFFFFF, NULL, 0); @@ -1220,10 +1224,6 @@ static void evergreen_set_clip_state(struct pipe_context *ctx, R_0285C8_PA_CL_UCP0_W + i * 16, fui(state->ucp[i][3]), 0xFFFFFFFF, NULL, 0); } - r600_pipe_state_add_reg(rstate, R_028810_PA_CL_CLIP_CNTL, - S_028810_PS_UCP_MODE(3) | ((1 << state->nr) - 1) | - S_028810_ZCLIP_NEAR_DISABLE(state->depth_clamp) | - S_028810_ZCLIP_FAR_DISABLE(state->depth_clamp), 0xFFFFFFFF, NULL, 0); free(rctx->states[R600_PIPE_STATE_CLIP]); rctx->states[R600_PIPE_STATE_CLIP] = rstate; diff --git a/src/gallium/drivers/r600/r600_blit.c b/src/gallium/drivers/r600/r600_blit.c index 9ad247a..6947c99 100644 --- a/src/gallium/drivers/r600/r600_blit.c +++ b/src/gallium/drivers/r600/r600_blit.c @@ -59,9 +59,6 @@ static void r600_blitter_begin(struct pipe_context *ctx, enum r600_blitter_op op if (rctx->states[R600_PIPE_STATE_VIEWPORT]) { util_blitter_save_viewport(rctx->blitter, &rctx->viewport); } - if (rctx->states[R600_PIPE_STATE_CLIP]) { - util_blitter_save_clip(rctx->blitter, &rctx->clip); - } util_blitter_save_vertex_buffers(rctx->blitter, rctx->vbuf_mgr->nr_vertex_buffers, rctx->vbuf_mgr->vertex_buffer); diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c index 4a31b43..e50b5cc 100644 --- a/src/gallium/drivers/r600/r600_pipe.c +++ b/src/gallium/drivers/r600/r600_pipe.c @@ -353,7 +353,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param) case PIPE_CAP_BLEND_EQUATION_SEPARATE: case PIPE_CAP_TEXTURE_SWIZZLE: case PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE: - case PIPE_CAP_DEPTH_CLAMP: + case PIPE_CAP_DEPTH_CLIP_DISABLE: case PIPE_CAP_SHADER_STENCIL_EXPORT: case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR: case PIPE_CAP_MIXED_COLORBUFFER_FORMATS: diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c index 12157ff..5fe038e 100644 --- a/src/gallium/drivers/r600/r600_state.c +++ b/src/gallium/drivers/r600/r600_state.c @@ -1029,6 +1029,10 @@ static void *r600_create_rs_state(struct pipe_context *ctx, r600_pipe_state_add_reg(rstate, R_028C18_PA_CL_GB_HORZ_DISC_ADJ, 0x3F800000, 0xFFFFFFFF, NULL, 0); r600_pipe_state_add_reg(rstate, R_028DFC_PA_SU_POLY_OFFSET_CLAMP, fui(state->offset_clamp), 0xFFFFFFFF, NULL, 0); r600_pipe_state_add_reg(rstate, R_02820C_PA_SC_CLIPRECT_RULE, clip_rule, 0xFFFFFFFF, NULL, 0); + r600_pipe_state_add_reg(rstate, R_028810_PA_CL_CLIP_CNTL, + S_028810_PS_UCP_MODE(3) | (state->clip_plane_enable & 63) | + S_028810_ZCLIP_NEAR_DISABLE(!state->depth_clip) | + S_028810_ZCLIP_FAR_DISABLE(!state->depth_clip), 0xFFFFFFFF, NULL, 0); return rstate; } @@ -1313,7 +1317,7 @@ static void r600_set_clip_state(struct pipe_context *ctx, rctx->clip = *state; rstate->id = R600_PIPE_STATE_CLIP; - for (int i = 0; i < state->nr; i++) { + for (int i = 0; i < 6; i++) { r600_pipe_state_add_reg(rstate, R_028E20_PA_CL_UCP0_X + i * 16, fui(state->ucp[i][0]), 0xFFFFFFFF, NULL, 0); @@ -1327,10 +1331,6 @@ static void r600_set_clip_state(struct pipe_context *ctx, R_028E2C_PA_CL_UCP0_W + i * 16, fui(state->ucp[i][3]), 0xFFFFFFFF, NULL, 0); } - r600_pipe_state_add_reg(rstate, R_028810_PA_CL_CLIP_CNTL, - S_028810_PS_UCP_MODE(3) | ((1 << state->nr) - 1) | - S_028810_ZCLIP_NEAR_DISABLE(state->depth_clamp) | - S_028810_ZCLIP_FAR_DISABLE(state->depth_clamp), 0xFFFFFFFF, NULL, 0); free(rctx->states[R600_PIPE_STATE_CLIP]); rctx->states[R600_PIPE_STATE_CLIP] = rstate; diff --git a/src/gallium/drivers/svga/svga_state_framebuffer.c b/src/gallium/drivers/svga/svga_state_framebuffer.c index 8c0dddf..f3625e0 100644 --- a/src/gallium/drivers/svga/svga_state_framebuffer.c +++ b/src/gallium/drivers/svga/svga_state_framebuffer.c @@ -477,7 +477,7 @@ emit_clip_planes( struct svga_context *svga, /* TODO: just emit directly from svga_set_clip_state()? */ - for (i = 0; i < svga->curr.clip.nr; i++) { + for (i = 0; i < 6; i++) { /* need to express the plane in D3D-style coordinate space. * GL coords get converted to D3D coords with the matrix: * [ 1 0 0 0 ] diff --git a/src/gallium/drivers/svga/svga_state_rss.c b/src/gallium/drivers/svga/svga_state_rss.c index a4d56bd..d94ac35 100644 --- a/src/gallium/drivers/svga/svga_state_rss.c +++ b/src/gallium/drivers/svga/svga_state_rss.c @@ -246,7 +246,7 @@ static int emit_rss( struct svga_context *svga, if (dirty & SVGA_NEW_CLIP) { /* the number of clip planes is how many planes to enable */ - unsigned enabled = (1 << svga->curr.clip.nr) - 1; + unsigned enabled = svga->curr.rast->templ.clip_plane_enable; EMIT_RS( svga, enabled, CLIPPLANEENABLE, fail ); } diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c index 038a80e..8af084c 100644 --- a/src/gallium/drivers/trace/tr_dump_state.c +++ b/src/gallium/drivers/trace/tr_dump_state.c @@ -121,6 +121,8 @@ void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state) trace_dump_member(bool, state, flatshade); trace_dump_member(bool, state, light_twoside); + trace_dump_member(bool, state, clamp_vertex_color); + trace_dump_member(bool, state, clamp_fragment_color); trace_dump_member(uint, state, front_ccw); trace_dump_member(uint, state, cull_face); trace_dump_member(uint, state, fill_front); @@ -144,6 +146,9 @@ void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state) trace_dump_member(bool, state, line_last_pixel); trace_dump_member(bool, state, flatshade_first); trace_dump_member(bool, state, gl_rasterization_rules); + trace_dump_member(bool, state, rasterizer_discard); + trace_dump_member(bool, state, depth_clip); + trace_dump_member(uint, state, clip_plane_enable); trace_dump_member(float, state, line_width); trace_dump_member(float, state, point_size); @@ -241,8 +246,6 @@ void trace_dump_clip_state(const struct pipe_clip_state *state) trace_dump_array_end(); trace_dump_member_end(); - trace_dump_member(uint, state, nr); - trace_dump_struct_end(); } diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 91d8b1e..4425fc9 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -468,7 +468,7 @@ enum pipe_cap { PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT = 38, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER = 39, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER = 40, - PIPE_CAP_DEPTH_CLAMP = 41, + PIPE_CAP_DEPTH_CLIP_DISABLE = 41, PIPE_CAP_SHADER_STENCIL_EXPORT = 42, PIPE_CAP_TGSI_INSTANCEID = 43, PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR = 44, diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h index 75e17a1..2fbe1df 100644 --- a/src/gallium/include/pipe/p_shader_tokens.h +++ b/src/gallium/include/pipe/p_shader_tokens.h @@ -191,7 +191,8 @@ union tgsi_immediate_data #define TGSI_PROPERTY_FS_COORD_PIXEL_CENTER 4 #define TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS 5 #define TGSI_PROPERTY_FS_DEPTH_LAYOUT 6 -#define TGSI_PROPERTY_COUNT 7 +#define TGSI_PROPERTY_VS_PROHIBIT_UCPS 7 +#define TGSI_PROPERTY_COUNT 8 struct tgsi_property { unsigned Type : 4; /**< TGSI_TOKEN_TYPE_PROPERTY */ diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index f943ca5..024d544 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -127,6 +127,22 @@ struct pipe_rasterizer_state */ unsigned rasterizer_discard:1; + /** + * When false, depth clipping is disabled and the depth value will be + * clamped later at the per-pixel level before depth testing. + * This depends on PIPE_CAP_DEPTH_CLIP_DISABLE. + */ + unsigned depth_clip:1; + + /** + * Enable bits for clipping half-spaces. + * This applies to both user clip planes and shader clip distances. + * Note that if the bound shader exports any clip distances, these + * replace all user clip planes, and clip half-spaces enabled here + * but not written by the shader count as disabled. + */ + unsigned clip_plane_enable:PIPE_MAX_CLIP_PLANES; + unsigned line_stipple_factor:8; /**< [1..256] actually */ unsigned line_stipple_pattern:16; @@ -165,8 +181,6 @@ struct pipe_scissor_state struct pipe_clip_state { float ucp[PIPE_MAX_CLIP_PLANES][4]; - unsigned nr; - unsigned depth_clamp:1; }; diff --git a/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp b/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp index 2828389..5d581aa 100644 --- a/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp +++ b/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp @@ -754,6 +754,7 @@ struct dxgi_blitter memset(&rs_state, 0, sizeof(rs_state)); rs_state.cull_face = PIPE_FACE_NONE; rs_state.gl_rasterization_rules = 1; + rs_state.depth_clip = 1; rs_state.flatshade = 1; rasterizer = pipe->create_rasterizer_state(pipe, &rs_state); diff --git a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h index a64e8d1..da3cc23 100644 --- a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h +++ b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h @@ -75,7 +75,6 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe> float blend_color[4]; unsigned sample_mask; unsigned stencil_ref; - bool depth_clamp; void* default_input_layout; void* default_rasterizer; @@ -169,7 +168,6 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe> memset(blend_color, 0, sizeof(blend_color)); sample_mask = ~0; stencil_ref = 0; - depth_clamp = 0; // derived state primitive_mode = 0; @@ -194,6 +192,7 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe> rasterizerd.flatshade_first = 1; rasterizerd.line_width = 1.0f; rasterizerd.point_size = 1.0f; + rasterizerd.depth_clip = TRUE; default_rasterizer = pipe->create_rasterizer_state(pipe, &rasterizerd); struct pipe_depth_stencil_alpha_state depth_stencild; @@ -938,14 +937,6 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe> } #endif - void set_clip() - { - pipe_clip_state clip; - clip.nr = 0; - clip.depth_clamp = depth_clamp; - pipe->set_clip_state(pipe, &clip); - } - virtual void STDMETHODCALLTYPE RSSetState( ID3D11RasterizerState *new_rasterizer_state) { @@ -954,12 +945,6 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe> { rasterizer_state = new_rasterizer_state; pipe->bind_rasterizer_state(pipe, new_rasterizer_state ? ((GalliumD3D11RasterizerState*)new_rasterizer_state)->object : default_rasterizer); - bool new_depth_clamp = new_rasterizer_state ? ((GalliumD3D11RasterizerState*)new_rasterizer_state)->depth_clamp : false; - if(depth_clamp != new_depth_clamp) - { - depth_clamp = new_depth_clamp; - set_clip(); - } } } @@ -1688,7 +1673,6 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe> pipe->set_stream_output_targets(pipe, num_so_targets, so_targets, ~0); set_framebuffer(); set_viewport(); - set_clip(); set_render_condition(); update_flags |= UPDATE_VERTEX_BUFFERS | (1 << (UPDATE_SAMPLERS_SHIFT + D3D11_STAGE_PS)) | (1 << (UPDATE_VIEWS_SHIFT + D3D11_STAGE_PS)); diff --git a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_objects.h b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_objects.h index e1ef7b8..faeb306 100644 --- a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_objects.h +++ b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_objects.h @@ -210,10 +210,8 @@ struct GalliumD3D10BlendState : public GalliumD3D10BlendStateBase struct GalliumD3D11RasterizerState : public GalliumD3D11RasterizerStateBase { - bool depth_clamp; - - GalliumD3D11RasterizerState(GalliumD3D11Screen* device, void* object, const D3D11_RASTERIZER_DESC& desc, bool depth_clamp) - : GalliumD3D11RasterizerStateBase(device, object, desc), depth_clamp(depth_clamp) + GalliumD3D11RasterizerState(GalliumD3D11Screen* device, void* object, const D3D11_RASTERIZER_DESC& desc) + : GalliumD3D11RasterizerStateBase(device, object, desc) {} }; diff --git a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_screen.h b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_screen.h index e64e1f6..31e59bf 100644 --- a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_screen.h +++ b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_screen.h @@ -578,6 +578,7 @@ struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen state.offset_scale = rasterizer_desc->SlopeScaledDepthBias; state.offset_units = rasterizer_desc->DepthBias; state.offset_clamp = rasterizer_desc->DepthBiasClamp; + state.depth_clip = rasterizer_desc->DepthClipEnable; state.scissor = !!rasterizer_desc->ScissorEnable; state.multisample = !!rasterizer_desc->MultisampleEnable; state.line_smooth = !!rasterizer_desc->AntialiasedLineEnable; @@ -595,7 +596,7 @@ struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen if(!object) return E_FAIL; - *out_rasterizer_state = new GalliumD3D11RasterizerState(this, object, *rasterizer_desc, !rasterizer_desc->DepthClipEnable); + *out_rasterizer_state = new GalliumD3D11RasterizerState(this, object, *rasterizer_desc); return S_OK; } diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c index e4c1fd5..add1eec 100644 --- a/src/gallium/state_trackers/vega/renderer.c +++ b/src/gallium/state_trackers/vega/renderer.c @@ -1187,6 +1187,7 @@ struct renderer * renderer_create(struct vg_context *owner) raster = &renderer->g3d.rasterizer; memset(raster, 0, sizeof(*raster)); raster->gl_rasterization_rules = 1; + raster->depth_clip = 1; cso_set_rasterizer(renderer->cso, raster); /* fixed at 0 */ diff --git a/src/gallium/state_trackers/xa/xa_renderer.c b/src/gallium/state_trackers/xa/xa_renderer.c index 5496fc0..7052f39 100644 --- a/src/gallium/state_trackers/xa/xa_renderer.c +++ b/src/gallium/state_trackers/xa/xa_renderer.c @@ -130,6 +130,7 @@ renderer_init_state(struct xa_context *r) /* XXX: move to renderer_init_state? */ memset(&raster, 0, sizeof(struct pipe_rasterizer_state)); raster.gl_rasterization_rules = 1; + raster.depth_clip = 1; cso_set_rasterizer(r->cso, &raster); /* vertex elements state */ diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c index 6b799af..eba72d8 100644 --- a/src/gallium/state_trackers/xorg/xorg_renderer.c +++ b/src/gallium/state_trackers/xorg/xorg_renderer.c @@ -107,6 +107,7 @@ renderer_init_state(struct xorg_renderer *r) /* XXX: move to renderer_init_state? */ memset(&raster, 0, sizeof(struct pipe_rasterizer_state)); raster.gl_rasterization_rules = 1; + raster.depth_clip = 1; cso_set_rasterizer(r->cso, &raster); /* vertex elements state */ diff --git a/src/gallium/tests/graw/fs-test.c b/src/gallium/tests/graw/fs-test.c index d9e70f0..f8b2a0a 100644 --- a/src/gallium/tests/graw/fs-test.c +++ b/src/gallium/tests/graw/fs-test.c @@ -504,6 +504,7 @@ static void init( void ) memset(&rasterizer, 0, sizeof rasterizer); rasterizer.cull_face = PIPE_FACE_NONE; rasterizer.gl_rasterization_rules = 1; + rasterizer.depth_clip = 1; handle = ctx->create_rasterizer_state(ctx, &rasterizer); ctx->bind_rasterizer_state(ctx, handle); } diff --git a/src/gallium/tests/graw/gs-test.c b/src/gallium/tests/graw/gs-test.c index e95306e..ef24402 100644 --- a/src/gallium/tests/graw/gs-test.c +++ b/src/gallium/tests/graw/gs-test.c @@ -567,6 +567,7 @@ static void init( void ) memset(&rasterizer, 0, sizeof rasterizer); rasterizer.cull_face = PIPE_FACE_NONE; rasterizer.gl_rasterization_rules = 1; + rasterizer.depth_clip = 1; handle = ctx->create_rasterizer_state(ctx, &rasterizer); ctx->bind_rasterizer_state(ctx, handle); } diff --git a/src/gallium/tests/graw/quad-sample.c b/src/gallium/tests/graw/quad-sample.c index 5612346..712ff51 100644 --- a/src/gallium/tests/graw/quad-sample.c +++ b/src/gallium/tests/graw/quad-sample.c @@ -377,6 +377,7 @@ static void init( void ) memset(&rasterizer, 0, sizeof rasterizer); rasterizer.cull_face = PIPE_FACE_NONE; rasterizer.gl_rasterization_rules = 1; + rasterizer.depth_clip = 1; handle = ctx->create_rasterizer_state(ctx, &rasterizer); ctx->bind_rasterizer_state(ctx, handle); } diff --git a/src/gallium/tests/graw/quad-tex.c b/src/gallium/tests/graw/quad-tex.c index a2749ca..96c6f3f 100644 --- a/src/gallium/tests/graw/quad-tex.c +++ b/src/gallium/tests/graw/quad-tex.c @@ -375,6 +375,7 @@ static void init( void ) memset(&rasterizer, 0, sizeof rasterizer); rasterizer.cull_face = PIPE_FACE_NONE; rasterizer.gl_rasterization_rules = 1; + rasterizer.depth_clip = 1; handle = ctx->create_rasterizer_state(ctx, &rasterizer); ctx->bind_rasterizer_state(ctx, handle); } diff --git a/src/gallium/tests/graw/shader-leak.c b/src/gallium/tests/graw/shader-leak.c index 57cd2dc..103aa6d 100644 --- a/src/gallium/tests/graw/shader-leak.c +++ b/src/gallium/tests/graw/shader-leak.c @@ -249,6 +249,7 @@ static void init( void ) memset(&rasterizer, 0, sizeof rasterizer); rasterizer.cull_face = PIPE_FACE_NONE; rasterizer.gl_rasterization_rules = 1; + rasterizer.depth_clip = 1; handle = ctx->create_rasterizer_state(ctx, &rasterizer); ctx->bind_rasterizer_state(ctx, handle); } diff --git a/src/gallium/tests/graw/tri-gs.c b/src/gallium/tests/graw/tri-gs.c index 4348663..7332631 100644 --- a/src/gallium/tests/graw/tri-gs.c +++ b/src/gallium/tests/graw/tri-gs.c @@ -254,6 +254,7 @@ static void init( void ) memset(&rasterizer, 0, sizeof rasterizer); rasterizer.cull_face = PIPE_FACE_NONE; rasterizer.gl_rasterization_rules = 1; + rasterizer.depth_clip = 1; handle = ctx->create_rasterizer_state(ctx, &rasterizer); ctx->bind_rasterizer_state(ctx, handle); } diff --git a/src/gallium/tests/graw/tri-instanced.c b/src/gallium/tests/graw/tri-instanced.c index 521dab0..8373815 100644 --- a/src/gallium/tests/graw/tri-instanced.c +++ b/src/gallium/tests/graw/tri-instanced.c @@ -304,6 +304,7 @@ static void init( void ) memset(&rasterizer, 0, sizeof rasterizer); rasterizer.cull_face = PIPE_FACE_NONE; rasterizer.gl_rasterization_rules = 1; + rasterizer.depth_clip = 1; handle = ctx->create_rasterizer_state(ctx, &rasterizer); ctx->bind_rasterizer_state(ctx, handle); } diff --git a/src/gallium/tests/graw/tri.c b/src/gallium/tests/graw/tri.c index 11f8bb3..fc5d66a 100644 --- a/src/gallium/tests/graw/tri.c +++ b/src/gallium/tests/graw/tri.c @@ -239,6 +239,7 @@ static void init( void ) memset(&rasterizer, 0, sizeof rasterizer); rasterizer.cull_face = PIPE_FACE_NONE; rasterizer.gl_rasterization_rules = 1; + rasterizer.depth_clip = 1; handle = ctx->create_rasterizer_state(ctx, &rasterizer); ctx->bind_rasterizer_state(ctx, handle); } diff --git a/src/gallium/tests/graw/vs-test.c b/src/gallium/tests/graw/vs-test.c index 74b3273..83d86fb 100644 --- a/src/gallium/tests/graw/vs-test.c +++ b/src/gallium/tests/graw/vs-test.c @@ -456,6 +456,7 @@ static void init( void ) rasterizer.cull_face = PIPE_FACE_NONE; rasterizer.point_size = 8.0; rasterizer.gl_rasterization_rules = 1; + rasterizer.depth_clip = 1; handle = ctx->create_rasterizer_state(ctx, &rasterizer); ctx->bind_rasterizer_state(ctx, handle); } diff --git a/src/gallium/tests/trivial/quad-tex.c b/src/gallium/tests/trivial/quad-tex.c index 79c66e0..cc19e8d 100644 --- a/src/gallium/tests/trivial/quad-tex.c +++ b/src/gallium/tests/trivial/quad-tex.c @@ -201,6 +201,7 @@ static void init_prog(struct program *p) memset(&p->rasterizer, 0, sizeof(p->rasterizer)); p->rasterizer.cull_face = PIPE_FACE_NONE; p->rasterizer.gl_rasterization_rules = 1; + p->rasterizer.depth_clip = 1; /* sampler */ memset(&p->sampler, 0, sizeof(p->sampler)); diff --git a/src/gallium/tests/trivial/tri.c b/src/gallium/tests/trivial/tri.c index d036db8..9190f78 100644 --- a/src/gallium/tests/trivial/tri.c +++ b/src/gallium/tests/trivial/tri.c @@ -152,6 +152,7 @@ static void init_prog(struct program *p) memset(&p->rasterizer, 0, sizeof(p->rasterizer)); p->rasterizer.cull_face = PIPE_FACE_NONE; p->rasterizer.gl_rasterization_rules = 1; + p->rasterizer.depth_clip = 1; surf_tmpl.format = PIPE_FORMAT_B8G8R8A8_UNORM; surf_tmpl.usage = PIPE_BIND_RENDER_TARGET; diff --git a/src/mesa/state_tracker/st_atom_clip.c b/src/mesa/state_tracker/st_atom_clip.c index 236d3cf..2a51100 100644 --- a/src/mesa/state_tracker/st_atom_clip.c +++ b/src/mesa/state_tracker/st_atom_clip.c @@ -35,6 +35,7 @@ #include "pipe/p_context.h" #include "st_atom.h" #include "st_program.h" +#include "util/u_debug.h" #include "cso_cache/cso_context.h" @@ -44,10 +45,9 @@ static void update_clip( struct st_context *st ) { struct pipe_clip_state clip; const struct gl_context *ctx = st->ctx; - GLuint i; bool use_eye = FALSE; - memset(&clip, 0, sizeof(clip)); + assert(sizeof(clip.ucp) <= sizeof(ctx->Transform._ClipUserPlane)); /* if we have a vertex shader that writes clip vertex we need to pass the pre-projection transformed coordinates into the driver. */ @@ -56,21 +56,11 @@ static void update_clip( struct st_context *st ) use_eye = TRUE; } - for (i = 0; i < PIPE_MAX_CLIP_PLANES; i++) { - if (ctx->Transform.ClipPlanesEnabled & (1 << i)) { - memcpy(clip.ucp[clip.nr], - use_eye ? ctx->Transform.EyeUserPlane[i] : ctx->Transform._ClipUserPlane[i], - sizeof(clip.ucp[0])); - clip.nr++; - } - } - - clip.depth_clamp = ctx->Transform.DepthClamp != GL_FALSE; - - if (memcmp(&clip, &st->state.clip, sizeof(clip)) != 0) { - st->state.clip = clip; - cso_set_clip(st->cso_context, &clip); - } + memcpy(clip.ucp, + use_eye ? ctx->Transform.EyeUserPlane + : ctx->Transform._ClipUserPlane, sizeof(clip.ucp)); + st->state.clip = clip; + cso_set_clip(st->cso_context, &clip); } diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 2d6ad45..f3d28e6 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -261,6 +261,10 @@ static void update_raster_state( struct st_context *st ) /* _NEW_RASTERIZER_DISCARD */ raster->rasterizer_discard = ctx->RasterDiscard; + /* _NEW_TRANSFORM */ + raster->depth_clip = ctx->Transform.DepthClamp == GL_FALSE; + raster->clip_plane_enable = ctx->Transform.ClipPlanesEnabled; + cso_set_rasterizer(st->cso_context, raster); } @@ -276,7 +280,8 @@ const struct st_tracked_state st_update_rasterizer = { _NEW_PROGRAM | _NEW_SCISSOR | _NEW_FRAG_CLAMP | - _NEW_RASTERIZER_DISCARD), /* mesa state dependencies*/ + _NEW_RASTERIZER_DISCARD | + _NEW_TRANSFORM), /* mesa state dependencies*/ ST_NEW_VERTEX_PROGRAM, /* state tracker dependencies */ }, update_raster_state /* update function */ diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index af33bcf..a970968 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -870,6 +870,7 @@ st_init_bitmap(struct st_context *st) /* init baseline rasterizer state once */ memset(&st->bitmap.rasterizer, 0, sizeof(st->bitmap.rasterizer)); st->bitmap.rasterizer.gl_rasterization_rules = 1; + st->bitmap.rasterizer.depth_clip = 1; /* find a usable texture format */ if (screen->is_format_supported(screen, PIPE_FORMAT_I8_UNORM, diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 23700ee..a8365a7 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -68,6 +68,7 @@ st_init_clear(struct st_context *st) memset(&st->clear, 0, sizeof(st->clear)); st->clear.raster.gl_rasterization_rules = 1; + st->clear.raster.depth_clip = 1; st->clear.enable_ds_separate = pscreen->get_param(pscreen, PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE); } @@ -248,7 +249,6 @@ clear_with_quad(struct gl_context *ctx, cso_save_depth_stencil_alpha(st->cso_context); cso_save_rasterizer(st->cso_context); cso_save_viewport(st->cso_context); - cso_save_clip(st->cso_context); cso_save_fragment_shader(st->cso_context); cso_save_stream_outputs(st->cso_context); cso_save_vertex_shader(st->cso_context); @@ -326,7 +326,6 @@ clear_with_quad(struct gl_context *ctx, cso_set_viewport(st->cso_context, &vp); } - cso_set_clip(st->cso_context, &st->clear.clip); set_fragment_shader(st); set_vertex_shader(st); cso_set_geometry_shader_handle(st->cso_context, NULL); @@ -346,7 +345,6 @@ clear_with_quad(struct gl_context *ctx, cso_restore_depth_stencil_alpha(st->cso_context); cso_restore_rasterizer(st->cso_context); cso_restore_viewport(st->cso_context); - cso_restore_clip(st->cso_context); cso_restore_fragment_shader(st->cso_context); cso_restore_vertex_shader(st->cso_context); cso_restore_geometry_shader(st->cso_context); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 0609a54..13c4f33 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -686,6 +686,7 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z, memset(&rasterizer, 0, sizeof(rasterizer)); rasterizer.clamp_fragment_color = ctx->Color._ClampFragmentColor; rasterizer.gl_rasterization_rules = 1; + rasterizer.depth_clip = !ctx->Transform.DepthClamp; rasterizer.scissor = ctx->Scissor.Enabled; cso_set_rasterizer(cso, &rasterizer); } diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index c607809..9db50b3 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -167,7 +167,6 @@ struct st_context struct { struct pipe_rasterizer_state raster; struct pipe_viewport_state viewport; - struct pipe_clip_state clip; void *vs; void *fs; float vertices[4][2][4]; /**< vertex pos + color */ diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 4c8c67f..a9d4054 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -592,7 +592,7 @@ void st_init_extensions(struct st_context *st) st->sw_primitive_restart = GL_TRUE; } - if (screen->get_param(screen, PIPE_CAP_DEPTH_CLAMP)) { + if (screen->get_param(screen, PIPE_CAP_DEPTH_CLIP_DISABLE)) { ctx->Extensions.ARB_depth_clamp = GL_TRUE; } |