[Mesa-dev] [PATCH 09/14] anv: Set clip/cull distances fields in packets.
Jason Ekstrand
jason at jlekstrand.net
Thu Nov 17 04:41:59 UTC 2016
On Mon, Nov 14, 2016 at 5:41 PM, Kenneth Graunke <kenneth at whitecape.org>
wrote:
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
> src/intel/vulkan/anv_private.h | 18 ++++++++++++++++++
> src/intel/vulkan/gen8_pipeline.c | 15 ++++++++-------
> src/intel/vulkan/genX_pipeline_util.h | 5 +++++
> 3 files changed, 31 insertions(+), 7 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_
> private.h
> index 30deb02..eef2926 100644
> --- a/src/intel/vulkan/anv_private.h
> +++ b/src/intel/vulkan/anv_private.h
> @@ -1445,6 +1445,24 @@ ANV_DECL_GET_PROG_DATA_FUNC(gs,
> MESA_SHADER_GEOMETRY)
> ANV_DECL_GET_PROG_DATA_FUNC(wm, MESA_SHADER_FRAGMENT)
> ANV_DECL_GET_PROG_DATA_FUNC(cs, MESA_SHADER_COMPUTE)
>
> +/**
> + * Get the brw_vue_prog_data for the last stage which outputs VUEs.
> + */
> +static inline struct brw_vue_prog_data *
> +get_last_vue_prog_data(struct anv_pipeline *pipeline)
> +{
> + const unsigned pre_clip_stages =
> + pipeline->active_stages & (VK_SHADER_STAGE_FRAGMENT_BIT - 1);
> + const unsigned last_bit = util_last_bit(pre_clip_stages);
>
This seems a bit... over-designed?
for (int s = MESA_SHADER_GEOMETRY; s >= 0; s--) {
if (pipeline->shaders[s])
return (struct brw_vue_prog_data *)pipeline->shaders[s]->prog_data;
}
would work just as well.
> +
> + if (last_bit == 0)
> + return NULL;
> +
> + struct anv_shader_bin *bin = pipeline->shaders[last_bit - 1];
> +
> + return (struct brw_vue_prog_data *) bin->prog_data;
> +}
> +
> VkResult
> anv_pipeline_init(struct anv_pipeline *pipeline, struct anv_device
> *device,
> struct anv_pipeline_cache *cache,
> diff --git a/src/intel/vulkan/gen8_pipeline.c b/src/intel/vulkan/gen8_
> pipeline.c
> index 6cf55f5..4fad8cd 100644
> --- a/src/intel/vulkan/gen8_pipeline.c
> +++ b/src/intel/vulkan/gen8_pipeline.c
> @@ -158,10 +158,10 @@ genX(graphics_pipeline_create)(
> gs_prog_data->static_vertex_count >= 0 ?
> gs_prog_data->static_vertex_count : 0;
>
> - /* FIXME: mesa sets this based on ctx->Transform.
> ClipPlanesEnabled:
> - * UserClipDistanceClipTestEnableBitmask_3DSTATE_GS(v)
> - * UserClipDistanceCullTestEnableBitmask(v)
> - */
> + gs.UserClipDistanceClipTestEnableBitmask =
> + gs_prog_data->base.clip_distance_mask;
> + gs.UserClipDistanceCullTestEnableBitmask =
> + gs_prog_data->base.cull_distance_mask;
>
> gs.VertexURBEntryOutputReadOffset = offset;
> gs.VertexURBEntryOutputLength = length;
> @@ -224,9 +224,10 @@ genX(graphics_pipeline_create)(
> vs.VertexURBEntryOutputReadOffset = offset;
> vs.VertexURBEntryOutputLength = length;
>
> - /* TODO */
> - vs.UserClipDistanceClipTestEnableBitmask = 0;
> - vs.UserClipDistanceCullTestEnableBitmask = 0;
> + vs.UserClipDistanceClipTestEnableBitmask =
> + vs_prog_data->base.clip_distance_mask;
> + vs.UserClipDistanceCullTestEnableBitmask =
> + vs_prog_data->base.cull_distance_mask;
> }
> }
>
> diff --git a/src/intel/vulkan/genX_pipeline_util.h
> b/src/intel/vulkan/genX_pipeline_util.h
> index 129ae94..5bee80c 100644
> --- a/src/intel/vulkan/genX_pipeline_util.h
> +++ b/src/intel/vulkan/genX_pipeline_util.h
> @@ -940,6 +940,11 @@ emit_3dstate_clip(struct anv_pipeline *pipeline,
> clip.FrontWinding = vk_to_gen_front_face[rs_info->
> frontFace];
> clip.CullMode = vk_to_gen_cullmode[rs_info->
> cullMode];
> clip.ViewportZClipTestEnable = !pipeline->depth_clamp_enable;
> + const struct brw_vue_prog_data *last = get_last_vue_prog_data(
> pipeline);
> + if (last) {
> + clip.UserClipDistanceClipTestEnableBitmask =
> last->clip_distance_mask;
> + clip.UserClipDistanceCullTestEnableBitmask =
> last->cull_distance_mask;
> + }
> #else
> clip.NonPerspectiveBarycentricEnable = wm_prog_data ?
> (wm_prog_data->barycentric_interp_modes & 0x38) != 0 : 0;
> --
> 2.10.2
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20161116/1c84f9aa/attachment.html>
More information about the mesa-dev
mailing list