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
/* 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;
}
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;
+ }
}
}
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 */
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;
}
/**
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
{
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));
}
boolean clip_z,
boolean clip_user,
boolean clip_halfz,
- unsigned nr,
+ unsigned ucp_enable,
LLVMValueRef context_ptr)
{
LLVMBuilderRef builder = gallivm->builder;
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);
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, "");
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, "");
}
}
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);
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
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:
*/
/* 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
*/
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;
"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] =
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;
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));
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);
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);
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);
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);
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);
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);
/* Viewport state. */
struct pipe_viewport_state viewport;
- /* Clip state. */
- struct pipe_clip_state clip;
-
/* Destination surface dimensions. */
unsigned dst_width;
unsigned dst_height;
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 =
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) {
* (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)
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,
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];
blitter->saved_viewport = *state;
}
-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,
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);
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);
util_dump_array_end(stream);
util_dump_member_end(stream);
- util_dump_member(stream, uint, state, nr);
-
util_dump_struct_end(stream);
}
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;
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));
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);
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);
}
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);
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;
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;
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;
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.
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
------------------------------------
/* 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:
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);
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:
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;
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;
const struct pipe_rasterizer_state *cso)
{
struct nv50_rasterizer_stateobj *so;
+ uint32_t reg;
so = CALLOC_STRUCT(nv50_rasterizer_stateobj);
if (!so)
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;
}
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;
}
#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
{ 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 },
struct nv50_rasterizer_stateobj {
struct pipe_rasterizer_state pipe;
int size;
- uint32_t state[46];
+ uint32_t state[48];
};
struct nv50_zsa_stateobj {
struct pipe_sampler_view *texture;
struct nv50_tsc_entry *sampler;
unsigned dirty;
- unsigned clip_nr;
} saved;
struct nv50_program vp;
struct nv50_program fp;
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];
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) {
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;
}
}
-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)
{
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);
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);
}
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
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
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;
}
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;
}
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);
}
}
{ 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 },
struct nvc0_rasterizer_stateobj {
struct pipe_rasterizer_state pipe;
int size;
- uint32_t state[41];
+ uint32_t state[43];
};
struct nvc0_zsa_stateobj {
struct pipe_sampler_view *texture;
struct nv50_tsc_entry *sampler;
unsigned dirty;
- unsigned clip_nr;
} saved;
struct nvc0_program vp;
struct nvc0_program fp;
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];
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) {
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
{
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)
{
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
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;
}
/* 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);
}
}
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))
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)
{
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);
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);
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);
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 =
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);
};
struct r300_clip_state {
- struct pipe_clip_state clip;
-
uint32_t cb[29];
};
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. */
if (!r300->screen->caps.has_tcl) {
r300->vs_state.dirty = FALSE;
r300->vs_constants.dirty = FALSE;
+ r300->clip_state.dirty = FALSE;
}
}
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))
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);
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:
(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);
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 */
}
}
+ 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 |
/* 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);
}
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;
}
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);
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;
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);
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:
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;
}
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);
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;
/* 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 ]
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 );
}
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);
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);
trace_dump_array_end();
trace_dump_member_end();
- trace_dump_member(uint, state, nr);
-
trace_dump_struct_end();
}
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,
#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 */
*/
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;
struct pipe_clip_state
{
float ucp[PIPE_MAX_CLIP_PLANES][4];
- unsigned nr;
- unsigned depth_clamp:1;
};
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);
float blend_color[4];
unsigned sample_mask;
unsigned stencil_ref;
- bool depth_clamp;
void* default_input_layout;
void* default_rasterizer;
memset(blend_color, 0, sizeof(blend_color));
sample_mask = ~0;
stencil_ref = 0;
- depth_clamp = 0;
// derived state
primitive_mode = 0;
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;
}
#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)
{
{
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();
- }
}
}
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));
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)
{}
};
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;
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;
}
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 */
/* 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 */
/* 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 */
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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));
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;
#include "pipe/p_context.h"
#include "st_atom.h"
#include "st_program.h"
+#include "util/u_debug.h"
#include "cso_cache/cso_context.h"
{
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. */
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);
}
/* _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);
}
_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 */
/* 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,
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);
}
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);
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);
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);
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);
}
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 */
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;
}