diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-01-13 19:14:01 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-01-15 17:39:03 +0300 |
commit | f5e2d4209234d41cade98660e2e51a06940005e1 (patch) | |
tree | 8db8b3d0cb0e38fd805cf85466c9b97d7455068f /source/blender/gpu | |
parent | 5e6c86cb1fdd3083da331f94424a9fe82704593e (diff) |
GPU Texture: Add GL_RG16I format.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/GPU_texture.h | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_texture.c | 37 |
2 files changed, 28 insertions, 11 deletions
diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h index 3ed9ab4bf2c..1b64d66469b 100644 --- a/source/blender/gpu/GPU_texture.h +++ b/source/blender/gpu/GPU_texture.h @@ -67,6 +67,7 @@ typedef enum GPUTextureFormat { GPU_RGBA8, GPU_RG32F, GPU_RG16F, + GPU_RG16I, GPU_R32F, GPU_R16F, GPU_RG8, @@ -82,7 +83,6 @@ typedef enum GPUTextureFormat { GPU_RG32I, GPU_RG32UI, GPU_RG16, - GPU_RG16I, GPU_RG16UI, GPU_RG8I, GPU_RG8UI, diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c index bcc0bb2649f..d6b641af225 100644 --- a/source/blender/gpu/intern/gpu_texture.c +++ b/source/blender/gpu/intern/gpu_texture.c @@ -115,9 +115,9 @@ static GLenum gpu_texture_get_format( int components, GPUTextureFormat data_type, GLenum *format, GLenum *data_format, bool *is_depth, bool *is_stencil, unsigned int *bytesize) { - if (data_type == GPU_DEPTH_COMPONENT24 || - data_type == GPU_DEPTH_COMPONENT16 || - data_type == GPU_DEPTH_COMPONENT32F) + if (ELEM(data_type, GPU_DEPTH_COMPONENT24, + GPU_DEPTH_COMPONENT16, + GPU_DEPTH_COMPONENT32F)) { *is_depth = true; *is_stencil = false; @@ -133,14 +133,29 @@ static GLenum gpu_texture_get_format( else { *is_depth = false; *is_stencil = false; - *data_format = GL_FLOAT; - switch (components) { - case 1: *format = GL_RED; break; - case 2: *format = GL_RG; break; - case 3: *format = GL_RGB; break; - case 4: *format = GL_RGBA; break; - default: break; + /* Integer formats */ + if (ELEM(data_type, GPU_RG16I)) { + *data_format = GL_INT; + + switch (components) { + case 1: *format = GL_RED_INTEGER; break; + case 2: *format = GL_RG_INTEGER; break; + case 3: *format = GL_RGB_INTEGER; break; + case 4: *format = GL_RGBA_INTEGER; break; + default: break; + } + } + else { + *data_format = GL_FLOAT; + + switch (components) { + case 1: *format = GL_RED; break; + case 2: *format = GL_RG; break; + case 3: *format = GL_RGB; break; + case 4: *format = GL_RGBA; break; + default: break; + } } } @@ -156,6 +171,7 @@ static GLenum gpu_texture_get_format( *bytesize = 12; break; case GPU_RG16F: + case GPU_RG16I: case GPU_DEPTH24_STENCIL8: case GPU_DEPTH_COMPONENT32F: case GPU_RGBA8: @@ -188,6 +204,7 @@ static GLenum gpu_texture_get_format( case GPU_RG32F: return GL_RG32F; case GPU_RGB16F: return GL_RGB16F; case GPU_RG16F: return GL_RG16F; + case GPU_RG16I: return GL_RG16I; case GPU_RGBA8: return GL_RGBA8; case GPU_R32F: return GL_R32F; case GPU_R16F: return GL_R16F; |