From 463ef47b1672003bdf0737fdc63c4ffa985291f1 Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Mon, 18 Feb 2013 10:16:02 -0800 Subject: [PATCH] i965: Store the geometry output VUE map in brw_context. Currently, the GPU pipeline has one active VUE map in effect at any given time--the one representing the layout of vertex data coming from the vertex shader. However, when geometry shaders are added, they will have their own independent VUE map. Later pipeline stages (clip, sf, fs) will need to consult the geometry shader VUE map if a geometry shader is in use, and the vertex shader VUE map otherwise. This patch adds a new field to brw_context, vue_map_geom_out, which contains the VUE map that should be used by later pipeline stages. It also adds a new state flag, BRW_NEW_VUE_MAP_GEOM_OUT, which is signalled whenever the contents of the VUE map changes. Since we don't support geometry shaders yet, vue_map_geom_out is currently set only by the brw_vs_prog state atom. v2: Don't set vue_map_geom_out in do_vs_prog--that's redundant and possibly problematic for precompiles. Only set it in brw_upload_vs_prog. Also, make a copy instead of using a pointer--this makes it possible to detect when the VUE map hasn't changed, so we can avoid redundant state uploads. Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_context.h | 11 +++++++++++ src/mesa/drivers/dri/i965/brw_state_upload.c | 1 + src/mesa/drivers/dri/i965/brw_vs.c | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 83604e5592c..01ef0323c93 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -153,6 +153,7 @@ enum brw_state_id { BRW_STATE_PROGRAM_CACHE, BRW_STATE_STATE_BASE_ADDRESS, BRW_STATE_SOL_INDICES, + BRW_STATE_VUE_MAP_GEOM_OUT, }; #define BRW_NEW_URB_FENCE (1 << BRW_STATE_URB_FENCE) @@ -182,6 +183,7 @@ enum brw_state_id { #define BRW_NEW_PROGRAM_CACHE (1 << BRW_STATE_PROGRAM_CACHE) #define BRW_NEW_STATE_BASE_ADDRESS (1 << BRW_STATE_STATE_BASE_ADDRESS) #define BRW_NEW_SOL_INDICES (1 << BRW_STATE_SOL_INDICES) +#define BRW_NEW_VUE_MAP_GEOM_OUT (1 << BRW_STATE_VUE_MAP_GEOM_OUT) struct brw_state_flags { /** State update flags signalled by mesa internals */ @@ -918,6 +920,15 @@ struct brw_context uint32_t offset; } sampler; + /** + * Layout of vertex data exiting the geometry portion of the pipleine. + * This comes from the geometry shader if one exists, otherwise from the + * vertex shader. + * + * BRW_NEW_VUE_MAP_GEOM_OUT is flagged when the VUE map changes. + */ + struct brw_vue_map vue_map_geom_out; + struct { struct brw_vs_prog_data *prog_data; diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index 41dfdc36efd..5c5c05e3efd 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -376,6 +376,7 @@ static struct dirty_bit_map brw_bits[] = { DEFINE_BIT(BRW_NEW_PROGRAM_CACHE), DEFINE_BIT(BRW_NEW_STATE_BASE_ADDRESS), DEFINE_BIT(BRW_NEW_SOL_INDICES), + DEFINE_BIT(BRW_NEW_VUE_MAP_GEOM_OUT), {0, 0, 0} }; diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index fceabba29ce..1a19a794adb 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -488,6 +488,11 @@ static void brw_upload_vs_prog(struct brw_context *brw) assert(success); } + if (memcmp(&brw->vs.prog_data->vue_map, &brw->vue_map_geom_out, + sizeof(brw->vue_map_geom_out)) != 0) { + brw->vue_map_geom_out = brw->vs.prog_data->vue_map; + brw->state.dirty.brw |= BRW_NEW_VUE_MAP_GEOM_OUT; + } } /* See brw_vs.c: -- 2.30.2