summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965/brw_draw_upload.c
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2014-09-10 15:41:40 -0700
committerIan Romanick <ian.d.romanick@intel.com>2014-09-12 16:35:35 -0700
commit6b6145204dd4a1112f6e1fe10162636141495b79 (patch)
tree30809a5f9ef2d22f67b7a3677e75c2025b81ee4f /src/mesa/drivers/dri/i965/brw_draw_upload.c
parente980fe607155c79ccba56ef78854093b7730bef6 (diff)
downloadexternal_mesa3d-6b6145204dd4a1112f6e1fe10162636141495b79.zip
external_mesa3d-6b6145204dd4a1112f6e1fe10162636141495b79.tar.gz
external_mesa3d-6b6145204dd4a1112f6e1fe10162636141495b79.tar.bz2
i965: Separate gl_InstanceID and gl_VertexID uploading.
We always uploaded them together, mostly out of laziness - both required an additional vertex element. However, gl_VertexID now also requires an additional vertex buffer for storing gl_BaseVertex; for non-indirect draws this also means uploading (a small amount of) data. This is extra overhead we don't need if the shader only uses gl_InstanceID. In particular, our clear shaders currently use gl_InstanceID for doing layered clears, but don't need gl_VertexID. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Cc: "10.3" <mesa-stable@lists.freedesktop.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Tested-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_draw_upload.c')
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw_upload.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index d59ca8b..2162624 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -671,14 +671,16 @@ emit_vertex_buffer_state(struct brw_context *brw,
static void brw_emit_vertices(struct brw_context *brw)
{
- GLuint i, nr_elements;
+ GLuint i;
brw_prepare_vertices(brw);
brw_prepare_shader_draw_parameters(brw);
brw_emit_query_begin(brw);
- nr_elements = brw->vb.nr_enabled + brw->vs.prog_data->uses_vertexid;
+ unsigned nr_elements = brw->vb.nr_enabled;
+ if (brw->vs.prog_data->uses_vertexid || brw->vs.prog_data->uses_instanceid)
+ ++nr_elements;
/* If the VS doesn't read any inputs (calculating vertex position from
* a state variable for some reason, for example), emit a single pad
@@ -824,13 +826,26 @@ static void brw_emit_vertices(struct brw_context *brw)
(BRW_VE1_COMPONENT_STORE_0 << BRW_VE1_COMPONENT_3_SHIFT));
}
- if (brw->vs.prog_data->uses_vertexid) {
+ if (brw->vs.prog_data->uses_vertexid || brw->vs.prog_data->uses_instanceid) {
uint32_t dw0 = 0, dw1 = 0;
+ uint32_t comp0 = BRW_VE1_COMPONENT_STORE_0;
+ uint32_t comp1 = BRW_VE1_COMPONENT_STORE_0;
+ uint32_t comp2 = BRW_VE1_COMPONENT_STORE_0;
+ uint32_t comp3 = BRW_VE1_COMPONENT_STORE_0;
- dw1 = (BRW_VE1_COMPONENT_STORE_SRC << BRW_VE1_COMPONENT_0_SHIFT) |
- (BRW_VE1_COMPONENT_STORE_0 << BRW_VE1_COMPONENT_1_SHIFT) |
- (BRW_VE1_COMPONENT_STORE_VID << BRW_VE1_COMPONENT_2_SHIFT) |
- (BRW_VE1_COMPONENT_STORE_IID << BRW_VE1_COMPONENT_3_SHIFT);
+ if (brw->vs.prog_data->uses_vertexid) {
+ comp0 = BRW_VE1_COMPONENT_STORE_SRC;
+ comp2 = BRW_VE1_COMPONENT_STORE_VID;
+ }
+
+ if (brw->vs.prog_data->uses_instanceid) {
+ comp3 = BRW_VE1_COMPONENT_STORE_IID;
+ }
+
+ dw1 = (comp0 << BRW_VE1_COMPONENT_0_SHIFT) |
+ (comp1 << BRW_VE1_COMPONENT_1_SHIFT) |
+ (comp2 << BRW_VE1_COMPONENT_2_SHIFT) |
+ (comp3 << BRW_VE1_COMPONENT_3_SHIFT);
if (brw->gen >= 6) {
dw0 |= GEN6_VE0_VALID |