forked from bartvdbraak/blender
Gawain: replace switch with lookup table
This function is not performance critical, but I prefer the branch-free code and no hack needed to appease gcc. Follow-up to recent 23035cf46fb4dd6a0bf7e688b0f15128030c77d1 and f637145450010d14660fcb029d41560a138eae14.
This commit is contained in:
parent
845732652f
commit
6cc293a6d9
@ -28,19 +28,12 @@ static GLenum convert_index_type_to_gl(IndexType type)
|
|||||||
unsigned ElementList_size(const ElementList* elem)
|
unsigned ElementList_size(const ElementList* elem)
|
||||||
{
|
{
|
||||||
#if TRACK_INDEX_RANGE
|
#if TRACK_INDEX_RANGE
|
||||||
switch (elem->index_type)
|
static const unsigned table[] = {
|
||||||
{
|
[INDEX_U8] = sizeof(GLubyte), // GL has this, Vulkan does not
|
||||||
case INDEX_U8: return elem->index_ct * sizeof(GLubyte);
|
[INDEX_U16] = sizeof(GLushort),
|
||||||
case INDEX_U16: return elem->index_ct * sizeof(GLushort);
|
[INDEX_U32] = sizeof(GLuint)
|
||||||
case INDEX_U32: return elem->index_ct * sizeof(GLuint);
|
};
|
||||||
|
return elem->index_ct * table[elem->index_type];
|
||||||
default:
|
|
||||||
#if TRUST_NO_ONE
|
|
||||||
assert(false);
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
return elem->index_ct * sizeof(GLuint);
|
return elem->index_ct * sizeof(GLuint);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user