[Mesa-dev] [PATCH 01/11] vbo: lift common code out of switch cases
Ian Romanick
idr at freedesktop.org
Wed Jan 17 18:32:25 UTC 2018
On 01/17/2018 09:39 AM, Brian Paul wrote:
> On 01/17/2018 10:08 AM, Ian Romanick wrote:
>> Should probably also change the assert(0) to unreachable(). It's
>> possible that will help the compiler generate slightly better code in
>> release builds.
>
> There's a bunch of assert(0) calls in the VBO code. How about I take
> care of those in a separate patch?
That works for me... maybe just send that with the next round of
optimizations?
> I added the const keywords in patch 7.
>
> -Brian
>
>
>>
>> On 01/16/2018 09:17 PM, Brian Paul wrote:
>>> Both switch cases began with the same code.
>>> ---
>>> src/mesa/vbo/vbo_exec_draw.c | 15 ++++++---------
>>> src/mesa/vbo/vbo_save_draw.c | 15 ++++++---------
>>> 2 files changed, 12 insertions(+), 18 deletions(-)
>>>
>>> diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
>>> index 34cb4ff..de17322 100644
>>> --- a/src/mesa/vbo/vbo_exec_draw.c
>>> +++ b/src/mesa/vbo/vbo_exec_draw.c
>>> @@ -180,14 +180,14 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
>>> GLbitfield varying_inputs = 0x0;
>>> bool swap_pos = false;
>>> - /* Install the default (ie Current) attributes first, then overlay
>>> - * all active ones.
>>> - */
>>> + /* Install the default (ie Current) attributes first */
>>> + for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
>>> + exec->vtx.inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr];
>>> + }
>>> +
>>> + /* Overlay other active attributes */
>>> switch (get_program_mode(exec->ctx)) {
>>> case VP_NONE:
>>> - for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
>>> - exec->vtx.inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr];
>>> - }
>>> for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) {
>>> assert(VERT_ATTRIB_GENERIC(attr) <
>>> ARRAY_SIZE(exec->vtx.inputs));
>>> exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] =
>>> @@ -196,9 +196,6 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
>>> map = vbo->map_vp_none;
>>> break;
>>> case VP_ARB:
>>> - for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
>>> - exec->vtx.inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr];
>>> - }
>>> for (attr = 0; attr < VERT_ATTRIB_GENERIC_MAX; attr++) {
>>> assert(VERT_ATTRIB_GENERIC(attr) <
>>> ARRAY_SIZE(exec->vtx.inputs));
>>> exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] =
>>> diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
>>> index b63a9a8..4101022 100644
>>> --- a/src/mesa/vbo/vbo_save_draw.c
>>> +++ b/src/mesa/vbo/vbo_save_draw.c
>>> @@ -158,14 +158,14 @@ bind_vertex_list(struct gl_context *ctx,
>>> buffer_offset = 0;
>>> }
>>> - /* Install the default (ie Current) attributes first, then overlay
>>> - * all active ones.
>>> - */
>>> + /* Install the default (ie Current) attributes first */
>>> + for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
>>> + save->inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr];
>>> + }
>>> +
>>> + /* Overlay other active attributes */
>>> switch (get_program_mode(ctx)) {
>>> case VP_NONE:
>>> - for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
>>> - save->inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr];
>>> - }
>>> for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) {
>>> save->inputs[VERT_ATTRIB_GENERIC(attr)] =
>>> &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT+attr];
>>> @@ -173,9 +173,6 @@ bind_vertex_list(struct gl_context *ctx,
>>> map = vbo->map_vp_none;
>>> break;
>>> case VP_ARB:
>>> - for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
>>> - save->inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr];
>>> - }
>>> for (attr = 0; attr < VERT_ATTRIB_GENERIC_MAX; attr++) {
>>> save->inputs[VERT_ATTRIB_GENERIC(attr)] =
>>> &vbo->currval[VBO_ATTRIB_GENERIC0+attr];
>>>
>>
>
More information about the mesa-dev
mailing list