Refactor reflection.cpp to silence fallthrough warnings
Since assert(0) compiles to nothing on release builds, it's not sufficient to silence a fallthrough warning. Instead, some switch statements are changed into if/else and others have the assert(0) replaced with "return 0".
This commit is contained in:
parent
7ffa289495
commit
1fc174387d
1 changed files with 76 additions and 82 deletions
|
|
@ -704,80 +704,73 @@ public:
|
|||
case EbtFloat:
|
||||
switch ((int)sampler.dim) {
|
||||
case Esd1D:
|
||||
switch ((int)sampler.shadow) {
|
||||
case false: return sampler.arrayed ? GL_SAMPLER_1D_ARRAY : GL_SAMPLER_1D;
|
||||
case true: return sampler.arrayed ? GL_SAMPLER_1D_ARRAY_SHADOW : GL_SAMPLER_1D_SHADOW;
|
||||
default: assert(0);
|
||||
}
|
||||
if (sampler.shadow)
|
||||
return sampler.arrayed ? GL_SAMPLER_1D_ARRAY_SHADOW : GL_SAMPLER_1D_SHADOW;
|
||||
else
|
||||
return sampler.arrayed ? GL_SAMPLER_1D_ARRAY : GL_SAMPLER_1D;
|
||||
case Esd2D:
|
||||
switch ((int)sampler.ms) {
|
||||
case false:
|
||||
switch ((int)sampler.shadow) {
|
||||
case false: return sampler.arrayed ? GL_SAMPLER_2D_ARRAY : GL_SAMPLER_2D;
|
||||
case true: return sampler.arrayed ? GL_SAMPLER_2D_ARRAY_SHADOW : GL_SAMPLER_2D_SHADOW;
|
||||
default: assert(0);
|
||||
}
|
||||
case true: return sampler.arrayed ? GL_SAMPLER_2D_MULTISAMPLE_ARRAY : GL_SAMPLER_2D_MULTISAMPLE;
|
||||
default: assert(0);
|
||||
if (sampler.ms) {
|
||||
return sampler.arrayed ? GL_SAMPLER_2D_MULTISAMPLE_ARRAY : GL_SAMPLER_2D_MULTISAMPLE;
|
||||
} else {
|
||||
if (sampler.shadow)
|
||||
return sampler.arrayed ? GL_SAMPLER_2D_ARRAY_SHADOW : GL_SAMPLER_2D_SHADOW;
|
||||
else
|
||||
return sampler.arrayed ? GL_SAMPLER_2D_ARRAY : GL_SAMPLER_2D;
|
||||
}
|
||||
case Esd3D:
|
||||
return GL_SAMPLER_3D;
|
||||
case EsdCube:
|
||||
switch ((int)sampler.shadow) {
|
||||
case false: return sampler.arrayed ? GL_SAMPLER_CUBE_MAP_ARRAY : GL_SAMPLER_CUBE;
|
||||
case true: return sampler.arrayed ? GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW : GL_SAMPLER_CUBE_SHADOW;
|
||||
default: assert(0);
|
||||
}
|
||||
if (sampler.shadow)
|
||||
return sampler.arrayed ? GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW : GL_SAMPLER_CUBE_SHADOW;
|
||||
else
|
||||
return sampler.arrayed ? GL_SAMPLER_CUBE_MAP_ARRAY : GL_SAMPLER_CUBE;
|
||||
case EsdRect:
|
||||
return sampler.shadow ? GL_SAMPLER_2D_RECT_SHADOW : GL_SAMPLER_2D_RECT;
|
||||
case EsdBuffer:
|
||||
return GL_SAMPLER_BUFFER;
|
||||
default: assert(0);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
case EbtFloat16:
|
||||
switch ((int)sampler.dim) {
|
||||
case Esd1D:
|
||||
switch ((int)sampler.shadow) {
|
||||
case false: return sampler.arrayed ? GL_FLOAT16_SAMPLER_1D_ARRAY_AMD : GL_FLOAT16_SAMPLER_1D_AMD;
|
||||
case true: return sampler.arrayed ? GL_FLOAT16_SAMPLER_1D_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_1D_SHADOW_AMD;
|
||||
default: assert(0);
|
||||
}
|
||||
if (sampler.shadow)
|
||||
return sampler.arrayed ? GL_FLOAT16_SAMPLER_1D_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_1D_SHADOW_AMD;
|
||||
else
|
||||
return sampler.arrayed ? GL_FLOAT16_SAMPLER_1D_ARRAY_AMD : GL_FLOAT16_SAMPLER_1D_AMD;
|
||||
case Esd2D:
|
||||
switch ((int)sampler.ms) {
|
||||
case false:
|
||||
switch ((int)sampler.shadow) {
|
||||
case false: return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_ARRAY_AMD : GL_FLOAT16_SAMPLER_2D_AMD;
|
||||
case true: return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_2D_SHADOW_AMD;
|
||||
default: assert(0);
|
||||
}
|
||||
case true: return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_MULTISAMPLE_ARRAY_AMD : GL_FLOAT16_SAMPLER_2D_MULTISAMPLE_AMD;
|
||||
default: assert(0);
|
||||
if (sampler.ms) {
|
||||
return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_MULTISAMPLE_ARRAY_AMD : GL_FLOAT16_SAMPLER_2D_MULTISAMPLE_AMD;
|
||||
} else {
|
||||
if (sampler.shadow)
|
||||
return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_2D_SHADOW_AMD;
|
||||
else
|
||||
return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_ARRAY_AMD : GL_FLOAT16_SAMPLER_2D_AMD;
|
||||
}
|
||||
case Esd3D:
|
||||
return GL_FLOAT16_SAMPLER_3D_AMD;
|
||||
case EsdCube:
|
||||
switch ((int)sampler.shadow) {
|
||||
case false: return sampler.arrayed ? GL_FLOAT16_SAMPLER_CUBE_MAP_ARRAY_AMD : GL_FLOAT16_SAMPLER_CUBE_AMD;
|
||||
case true: return sampler.arrayed ? GL_FLOAT16_SAMPLER_CUBE_MAP_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_CUBE_SHADOW_AMD;
|
||||
default: assert(0);
|
||||
}
|
||||
if (sampler.shadow)
|
||||
return sampler.arrayed ? GL_FLOAT16_SAMPLER_CUBE_MAP_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_CUBE_SHADOW_AMD;
|
||||
else
|
||||
return sampler.arrayed ? GL_FLOAT16_SAMPLER_CUBE_MAP_ARRAY_AMD : GL_FLOAT16_SAMPLER_CUBE_AMD;
|
||||
case EsdRect:
|
||||
return sampler.shadow ? GL_FLOAT16_SAMPLER_2D_RECT_SHADOW_AMD : GL_FLOAT16_SAMPLER_2D_RECT_AMD;
|
||||
case EsdBuffer:
|
||||
return GL_FLOAT16_SAMPLER_BUFFER_AMD;
|
||||
default: assert(0);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
case EbtInt:
|
||||
switch ((int)sampler.dim) {
|
||||
case Esd1D:
|
||||
return sampler.arrayed ? GL_INT_SAMPLER_1D_ARRAY : GL_INT_SAMPLER_1D;
|
||||
case Esd2D:
|
||||
switch ((int)sampler.ms) {
|
||||
case false: return sampler.arrayed ? GL_INT_SAMPLER_2D_ARRAY : GL_INT_SAMPLER_2D;
|
||||
case true: return sampler.arrayed ? GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
|
||||
if (sampler.ms)
|
||||
return sampler.arrayed ? GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
|
||||
: GL_INT_SAMPLER_2D_MULTISAMPLE;
|
||||
default: assert(0);
|
||||
}
|
||||
else
|
||||
return sampler.arrayed ? GL_INT_SAMPLER_2D_ARRAY : GL_INT_SAMPLER_2D;
|
||||
case Esd3D:
|
||||
return GL_INT_SAMPLER_3D;
|
||||
case EsdCube:
|
||||
|
|
@ -786,19 +779,19 @@ public:
|
|||
return GL_INT_SAMPLER_2D_RECT;
|
||||
case EsdBuffer:
|
||||
return GL_INT_SAMPLER_BUFFER;
|
||||
default: assert(0);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
case EbtUint:
|
||||
switch ((int)sampler.dim) {
|
||||
case Esd1D:
|
||||
return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_1D_ARRAY : GL_UNSIGNED_INT_SAMPLER_1D;
|
||||
case Esd2D:
|
||||
switch ((int)sampler.ms) {
|
||||
case false: return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_2D_ARRAY : GL_UNSIGNED_INT_SAMPLER_2D;
|
||||
case true: return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
|
||||
if (sampler.ms)
|
||||
return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
|
||||
: GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE;
|
||||
default: assert(0);
|
||||
}
|
||||
else
|
||||
return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_2D_ARRAY : GL_UNSIGNED_INT_SAMPLER_2D;
|
||||
case Esd3D:
|
||||
return GL_UNSIGNED_INT_SAMPLER_3D;
|
||||
case EsdCube:
|
||||
|
|
@ -807,7 +800,8 @@ public:
|
|||
return GL_UNSIGNED_INT_SAMPLER_2D_RECT;
|
||||
case EsdBuffer:
|
||||
return GL_UNSIGNED_INT_SAMPLER_BUFFER;
|
||||
default: assert(0);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
return 0;
|
||||
|
|
@ -820,11 +814,10 @@ public:
|
|||
case Esd1D:
|
||||
return sampler.arrayed ? GL_IMAGE_1D_ARRAY : GL_IMAGE_1D;
|
||||
case Esd2D:
|
||||
switch ((int)sampler.ms) {
|
||||
case false: return sampler.arrayed ? GL_IMAGE_2D_ARRAY : GL_IMAGE_2D;
|
||||
case true: return sampler.arrayed ? GL_IMAGE_2D_MULTISAMPLE_ARRAY : GL_IMAGE_2D_MULTISAMPLE;
|
||||
default: assert(0);
|
||||
}
|
||||
if (sampler.ms)
|
||||
return sampler.arrayed ? GL_IMAGE_2D_MULTISAMPLE_ARRAY : GL_IMAGE_2D_MULTISAMPLE;
|
||||
else
|
||||
return sampler.arrayed ? GL_IMAGE_2D_ARRAY : GL_IMAGE_2D;
|
||||
case Esd3D:
|
||||
return GL_IMAGE_3D;
|
||||
case EsdCube:
|
||||
|
|
@ -833,18 +826,18 @@ public:
|
|||
return GL_IMAGE_2D_RECT;
|
||||
case EsdBuffer:
|
||||
return GL_IMAGE_BUFFER;
|
||||
default: assert(0);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
case EbtFloat16:
|
||||
switch ((int)sampler.dim) {
|
||||
case Esd1D:
|
||||
return sampler.arrayed ? GL_FLOAT16_IMAGE_1D_ARRAY_AMD : GL_FLOAT16_IMAGE_1D_AMD;
|
||||
case Esd2D:
|
||||
switch ((int)sampler.ms) {
|
||||
case false: return sampler.arrayed ? GL_FLOAT16_IMAGE_2D_ARRAY_AMD : GL_FLOAT16_IMAGE_2D_AMD;
|
||||
case true: return sampler.arrayed ? GL_FLOAT16_IMAGE_2D_MULTISAMPLE_ARRAY_AMD : GL_FLOAT16_IMAGE_2D_MULTISAMPLE_AMD;
|
||||
default: assert(0);
|
||||
}
|
||||
if (sampler.ms)
|
||||
return sampler.arrayed ? GL_FLOAT16_IMAGE_2D_MULTISAMPLE_ARRAY_AMD : GL_FLOAT16_IMAGE_2D_MULTISAMPLE_AMD;
|
||||
else
|
||||
return sampler.arrayed ? GL_FLOAT16_IMAGE_2D_ARRAY_AMD : GL_FLOAT16_IMAGE_2D_AMD;
|
||||
case Esd3D:
|
||||
return GL_FLOAT16_IMAGE_3D_AMD;
|
||||
case EsdCube:
|
||||
|
|
@ -853,18 +846,18 @@ public:
|
|||
return GL_FLOAT16_IMAGE_2D_RECT_AMD;
|
||||
case EsdBuffer:
|
||||
return GL_FLOAT16_IMAGE_BUFFER_AMD;
|
||||
default: assert(0);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
case EbtInt:
|
||||
switch ((int)sampler.dim) {
|
||||
case Esd1D:
|
||||
return sampler.arrayed ? GL_INT_IMAGE_1D_ARRAY : GL_INT_IMAGE_1D;
|
||||
case Esd2D:
|
||||
switch ((int)sampler.ms) {
|
||||
case false: return sampler.arrayed ? GL_INT_IMAGE_2D_ARRAY : GL_INT_IMAGE_2D;
|
||||
case true: return sampler.arrayed ? GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY : GL_INT_IMAGE_2D_MULTISAMPLE;
|
||||
default: assert(0);
|
||||
}
|
||||
if (sampler.ms)
|
||||
return sampler.arrayed ? GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY : GL_INT_IMAGE_2D_MULTISAMPLE;
|
||||
else
|
||||
return sampler.arrayed ? GL_INT_IMAGE_2D_ARRAY : GL_INT_IMAGE_2D;
|
||||
case Esd3D:
|
||||
return GL_INT_IMAGE_3D;
|
||||
case EsdCube:
|
||||
|
|
@ -873,19 +866,19 @@ public:
|
|||
return GL_INT_IMAGE_2D_RECT;
|
||||
case EsdBuffer:
|
||||
return GL_INT_IMAGE_BUFFER;
|
||||
default: assert(0);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
case EbtUint:
|
||||
switch ((int)sampler.dim) {
|
||||
case Esd1D:
|
||||
return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_1D_ARRAY : GL_UNSIGNED_INT_IMAGE_1D;
|
||||
case Esd2D:
|
||||
switch ((int)sampler.ms) {
|
||||
case false: return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_2D_ARRAY : GL_UNSIGNED_INT_IMAGE_2D;
|
||||
case true: return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY
|
||||
if (sampler.ms)
|
||||
return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY
|
||||
: GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE;
|
||||
default: assert(0);
|
||||
}
|
||||
else
|
||||
return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_2D_ARRAY : GL_UNSIGNED_INT_IMAGE_2D;
|
||||
case Esd3D:
|
||||
return GL_UNSIGNED_INT_IMAGE_3D;
|
||||
case EsdCube:
|
||||
|
|
@ -894,7 +887,8 @@ public:
|
|||
return GL_UNSIGNED_INT_IMAGE_2D_RECT;
|
||||
case EsdBuffer:
|
||||
return GL_UNSIGNED_INT_IMAGE_BUFFER;
|
||||
default: assert(0);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
return 0;
|
||||
|
|
@ -959,7 +953,7 @@ public:
|
|||
case 4: return GL_FLOAT_MAT4;
|
||||
default: return 0;
|
||||
}
|
||||
default: assert(0);
|
||||
default: return 0;
|
||||
}
|
||||
case EbtDouble:
|
||||
switch (type.getMatrixCols()) {
|
||||
|
|
@ -984,7 +978,7 @@ public:
|
|||
case 4: return GL_DOUBLE_MAT4;
|
||||
default: return 0;
|
||||
}
|
||||
default: assert(0);
|
||||
default: return 0;
|
||||
}
|
||||
case EbtFloat16:
|
||||
switch (type.getMatrixCols()) {
|
||||
|
|
@ -1009,7 +1003,7 @@ public:
|
|||
case 4: return GL_FLOAT16_MAT4_AMD;
|
||||
default: return 0;
|
||||
}
|
||||
default: assert(0);
|
||||
default: return 0;
|
||||
}
|
||||
default:
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue