From: Mathias Fröhlich Date: Sat, 20 Apr 2019 05:28:19 +0000 (+0200) Subject: i965: Reorder workaround flags computation. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=38db4f17200cb5bfeb550bb732ccace5052afb04;p=mesa.git i965: Reorder workaround flags computation. Vertex processing workaround flags can be split into array and current vertex attributes. By that we can use specific access functions for these different vertex attribute kinds. This finally obsoletes some access functions that I introduced last winter for a smooth transition. v2: Style fixes. Reviewed-by: Matt Turner Signed-off-by: Mathias Fröhlich Part-of: --- diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index 0952687fd06..3b1c95aedb8 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -301,6 +301,35 @@ brw_clear_buffers(struct brw_context *brw) } +static uint8_t get_wa_flags(const struct gl_vertex_format *glformat) +{ + uint8_t wa_flags = 0; + + switch (glformat->Type) { + case GL_FIXED: + wa_flags = glformat->Size; + break; + + case GL_INT_2_10_10_10_REV: + wa_flags |= BRW_ATTRIB_WA_SIGN; + /* fallthough */ + + case GL_UNSIGNED_INT_2_10_10_10_REV: + if (glformat->Format == GL_BGRA) + wa_flags |= BRW_ATTRIB_WA_BGRA; + + if (glformat->Normalized) + wa_flags |= BRW_ATTRIB_WA_NORMALIZE; + else if (!glformat->Integer) + wa_flags |= BRW_ATTRIB_WA_SCALE; + + break; + } + + return wa_flags; +} + + static void brw_merge_inputs(struct brw_context *brw) { @@ -314,38 +343,32 @@ brw_merge_inputs(struct brw_context *brw) } if (devinfo->gen < 8 && !devinfo->is_haswell) { - uint64_t mask = ctx->VertexProgram._Current->info.inputs_read; /* Prior to Haswell, the hardware can't natively support GL_FIXED or * 2_10_10_10_REV vertex formats. Set appropriate workaround flags. */ - while (mask) { - const struct gl_vertex_format *glformat; - uint8_t wa_flags = 0; - const gl_vert_attrib i = u_bit_scan64(&mask); + const struct gl_vertex_array_object *vao = ctx->Array._DrawVAO; + const uint64_t vs_inputs = ctx->VertexProgram._Current->info.inputs_read; + assert((vs_inputs & ~((uint64_t)VERT_BIT_ALL)) == 0); - glformat = &brw->vb.inputs[i].glattrib->Format; + unsigned vaomask = vs_inputs & _mesa_draw_array_bits(ctx); + while (vaomask) { + const gl_vert_attrib i = u_bit_scan(&vaomask); + const struct gl_array_attributes *glattrib = + _mesa_draw_array_attrib(vao, i); + const uint8_t wa_flags = get_wa_flags(&glattrib->Format); - switch (glformat->Type) { - - case GL_FIXED: - wa_flags = glformat->Size; - break; - - case GL_INT_2_10_10_10_REV: - wa_flags |= BRW_ATTRIB_WA_SIGN; - /* fallthough */ - - case GL_UNSIGNED_INT_2_10_10_10_REV: - if (glformat->Format == GL_BGRA) - wa_flags |= BRW_ATTRIB_WA_BGRA; - - if (glformat->Normalized) - wa_flags |= BRW_ATTRIB_WA_NORMALIZE; - else if (!glformat->Integer) - wa_flags |= BRW_ATTRIB_WA_SCALE; - - break; + if (brw->vb.attrib_wa_flags[i] != wa_flags) { + brw->vb.attrib_wa_flags[i] = wa_flags; + brw->ctx.NewDriverState |= BRW_NEW_VS_ATTRIB_WORKAROUNDS; } + } + + unsigned currmask = vs_inputs & _mesa_draw_current_bits(ctx); + while (currmask) { + const gl_vert_attrib i = u_bit_scan(&currmask); + const struct gl_array_attributes *glattrib = + _mesa_draw_current_attrib(ctx, i); + const uint8_t wa_flags = get_wa_flags(&glattrib->Format); if (brw->vb.attrib_wa_flags[i] != wa_flags) { brw->vb.attrib_wa_flags[i] = wa_flags;