Integer texture formats for 8-bit R, RG, RGB and RGBA channels

This commit is contained in:
tzaeru 2014-12-22 20:34:43 +02:00 committed by rdb
parent f189290dfe
commit 9c137426e3
3 changed files with 79 additions and 0 deletions

View File

@ -7327,12 +7327,14 @@ get_external_image_format(Texture *tex) const {
case Texture::F_rgba12: case Texture::F_rgba12:
case Texture::F_rgba16: case Texture::F_rgba16:
case Texture::F_rgba32: case Texture::F_rgba32:
case Texture::F_rgba8i:
return GL_COMPRESSED_RGBA; return GL_COMPRESSED_RGBA;
case Texture::F_rgb: case Texture::F_rgb:
case Texture::F_rgb5: case Texture::F_rgb5:
case Texture::F_rgba5: case Texture::F_rgba5:
case Texture::F_rgb8: case Texture::F_rgb8:
case Texture::F_rgb8i:
case Texture::F_rgb12: case Texture::F_rgb12:
case Texture::F_rgb332: case Texture::F_rgb332:
case Texture::F_rgb16: case Texture::F_rgb16:
@ -7345,11 +7347,13 @@ get_external_image_format(Texture *tex) const {
case Texture::F_red: case Texture::F_red:
case Texture::F_green: case Texture::F_green:
case Texture::F_blue: case Texture::F_blue:
case Texture::F_r8i:
case Texture::F_r16: case Texture::F_r16:
case Texture::F_r32: case Texture::F_r32:
case Texture::F_r32i: case Texture::F_r32i:
return GL_COMPRESSED_RED; return GL_COMPRESSED_RED;
case Texture::F_rg8i:
case Texture::F_rg16: case Texture::F_rg16:
case Texture::F_rg32: case Texture::F_rg32:
return GL_COMPRESSED_RG; return GL_COMPRESSED_RG;
@ -7517,8 +7521,16 @@ get_external_image_format(Texture *tex) const {
return GL_LUMINANCE_ALPHA; return GL_LUMINANCE_ALPHA;
#ifndef OPENGLES #ifndef OPENGLES
case Texture::F_r8i:
case Texture::F_r32i: case Texture::F_r32i:
return GL_RED_INTEGER; return GL_RED_INTEGER;
case Texture::F_rg8i:
return GL_RG_INTEGER;
case Texture::F_rgb8i:
return GL_RGB_INTEGER;
case Texture::F_rgba8i:
return GL_RGBA_INTEGER;
#endif #endif
} }
GLCAT.error() GLCAT.error()
@ -7565,6 +7577,10 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
case Texture::F_depth_component24: case Texture::F_depth_component24:
case Texture::F_depth_component32: case Texture::F_depth_component32:
case Texture::F_depth_stencil: case Texture::F_depth_stencil:
case Texture::F_r8i:
case Texture::F_rg8i:
case Texture::F_rgb8i:
case Texture::F_rgba8i:
case Texture::F_r32i: case Texture::F_r32i:
// Unsupported; fall through to below. // Unsupported; fall through to below.
break; break;
@ -7840,6 +7856,30 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
#else #else
case Texture::F_rgba8: case Texture::F_rgba8:
return GL_RGBA8; return GL_RGBA8;
case Texture::F_r8i:
if (tex->get_component_type() == Texture::T_unsigned_byte) {
return GL_R8UI;
} else {
return GL_R8I;
}
case Texture::F_rg8i:
if (tex->get_component_type() == Texture::T_unsigned_byte) {
return GL_RG8UI;
} else {
return GL_RG8I;
}
case Texture::F_rgb8i:
if (tex->get_component_type() == Texture::T_unsigned_byte) {
return GL_RGB8UI;
} else {
return GL_RGB8I;
}
case Texture::F_rgba8i:
if (tex->get_component_type() == Texture::T_unsigned_byte) {
return GL_RGBA8UI;
} else {
return GL_RGBA8I;
}
case Texture::F_rgba12: case Texture::F_rgba12:
return GL_RGBA12; return GL_RGBA12;
#endif // OPENGLES #endif // OPENGLES
@ -11261,6 +11301,36 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
case GL_R3_G3_B2: case GL_R3_G3_B2:
format = Texture::F_rgb332; format = Texture::F_rgb332;
break; break;
case GL_R8I:
format = Texture::F_r8i;
break;
case GL_RG8I:
format = Texture::F_rg8i;
break;
case GL_RGB8I:
format = Texture::F_rgb8i;
break;
case GL_RGBA8I:
format = Texture::F_rgba8i;
break;
case GL_R8UI:
type = Texture::T_unsigned_byte;
format = Texture::F_r8i;
break;
case GL_RG8UI:
type = Texture::T_unsigned_byte;
format = Texture::F_rg8i;
break;
case GL_RGB8UI:
type = Texture::T_unsigned_byte;
format = Texture::F_rgb8i;
break;
case GL_RGBA8UI:
type = Texture::T_unsigned_byte;
format = Texture::F_rgba8i;
break;
#endif #endif
#ifndef OPENGLES_1 #ifndef OPENGLES_1

View File

@ -562,6 +562,8 @@ estimate_texture_memory() const {
case Texture::F_rgb8: case Texture::F_rgb8:
case Texture::F_rgba8: case Texture::F_rgba8:
case Texture::F_srgb_alpha: case Texture::F_srgb_alpha:
case Texture::F_rgb8i:
case Texture::F_rgba8i:
bpp = 4; bpp = 4;
break; break;
@ -583,6 +585,8 @@ estimate_texture_memory() const {
break; break;
case Texture::F_r16: case Texture::F_r16:
case Texture::F_r8i:
case Texture::F_rg8i:
bpp = 2; bpp = 2;
break; break;
case Texture::F_rg16: case Texture::F_rg16:

View File

@ -146,6 +146,11 @@ PUBLISHED:
F_r32, F_r32,
F_rg32, F_rg32,
F_rgb32, F_rgb32,
F_r8i, // 8 integer bits per R channel
F_rg8i, // 8 integer bits per R,G channel
F_rgb8i, // 8 integer bits per R,G,B channel
F_rgba8i, // 8 integer bits per R,G,B,A channel
}; };
// Deprecated. See SamplerState.FilterType. // Deprecated. See SamplerState.FilterType.