From 6fa984a1afaadcfd5d7a630da4c44bdee4676bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Sat, 20 Feb 2021 17:01:28 +0100 Subject: GPU: Add RGB10_A2 format support Nice format to output high definition normals or normalized colors. --- source/blender/gpu/GPU_texture.h | 9 +++++---- source/blender/gpu/intern/gpu_texture_private.hh | 7 +++++++ source/blender/gpu/opengl/gl_texture.hh | 5 +++++ 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'source/blender/gpu') diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h index 2b4d8c8f577..d9a01663de0 100644 --- a/source/blender/gpu/GPU_texture.h +++ b/source/blender/gpu/GPU_texture.h @@ -114,15 +114,15 @@ typedef enum eGPUTextureFormat { GPU_R16F, GPU_R16, /* Max texture buffer format. */ -/* Special formats texture & renderbuffer */ -#if 0 + /* Special formats texture & renderbuffer */ GPU_RGB10_A2, - GPU_RGB10_A2UI, -#endif GPU_R11F_G11F_B10F, GPU_DEPTH32F_STENCIL8, GPU_DEPTH24_STENCIL8, GPU_SRGB8_A8, +#if 0 + GPU_RGB10_A2UI, +#endif /* Texture only format */ GPU_RGB16F, @@ -175,6 +175,7 @@ typedef enum eGPUDataFormat { GPU_DATA_UBYTE, GPU_DATA_UINT_24_8, GPU_DATA_10_11_11_REV, + GPU_DATA_2_10_10_10_REV, } eGPUDataFormat; unsigned int GPU_texture_memory_usage_get(void); diff --git a/source/blender/gpu/intern/gpu_texture_private.hh b/source/blender/gpu/intern/gpu_texture_private.hh index e03d5f6e6ce..3d808bce152 100644 --- a/source/blender/gpu/intern/gpu_texture_private.hh +++ b/source/blender/gpu/intern/gpu_texture_private.hh @@ -283,6 +283,7 @@ inline size_t to_bytesize(eGPUTextureFormat format) case GPU_RGBA8UI: case GPU_RGBA8: case GPU_SRGB8_A8: + case GPU_RGB10_A2: case GPU_R11F_G11F_B10F: case GPU_R32F: case GPU_R32UI: @@ -368,6 +369,7 @@ inline int to_component_len(eGPUTextureFormat format) case GPU_RGBA16: case GPU_RGBA32F: case GPU_SRGB8_A8: + case GPU_RGB10_A2: return 4; case GPU_RGB16F: case GPU_R11F_G11F_B10F: @@ -395,6 +397,7 @@ inline size_t to_bytesize(eGPUDataFormat data_format) return 4; case GPU_DATA_UINT_24_8: case GPU_DATA_10_11_11_REV: + case GPU_DATA_2_10_10_10_REV: return 4; default: BLI_assert(!"Data format incorrect or unsupported\n"); @@ -432,6 +435,8 @@ inline bool validate_data_format(eGPUTextureFormat tex_format, eGPUDataFormat da case GPU_RGBA8UI: case GPU_SRGB8_A8: return ELEM(data_format, GPU_DATA_UBYTE, GPU_DATA_FLOAT); + case GPU_RGB10_A2: + return ELEM(data_format, GPU_DATA_2_10_10_10_REV, GPU_DATA_FLOAT); case GPU_R11F_G11F_B10F: return ELEM(data_format, GPU_DATA_10_11_11_REV, GPU_DATA_FLOAT); default: @@ -464,6 +469,8 @@ inline eGPUDataFormat to_data_format(eGPUTextureFormat tex_format) case GPU_RGBA8UI: case GPU_SRGB8_A8: return GPU_DATA_UBYTE; + case GPU_RGB10_A2: + return GPU_DATA_2_10_10_10_REV; case GPU_R11F_G11F_B10F: return GPU_DATA_10_11_11_REV; default: diff --git a/source/blender/gpu/opengl/gl_texture.hh b/source/blender/gpu/opengl/gl_texture.hh index afe0e0195ce..9da27056269 100644 --- a/source/blender/gpu/opengl/gl_texture.hh +++ b/source/blender/gpu/opengl/gl_texture.hh @@ -158,6 +158,8 @@ inline GLenum to_gl_internal_format(eGPUTextureFormat format) case GPU_R16: return GL_R16; /* Special formats texture & renderbuffer */ + case GPU_RGB10_A2: + return GL_RGB10_A2; case GPU_R11F_G11F_B10F: return GL_R11F_G11F_B10F; case GPU_DEPTH32F_STENCIL8: @@ -280,6 +282,8 @@ inline GLenum to_gl(eGPUDataFormat format) return GL_UNSIGNED_BYTE; case GPU_DATA_UINT_24_8: return GL_UNSIGNED_INT_24_8; + case GPU_DATA_2_10_10_10_REV: + return GL_UNSIGNED_INT_2_10_10_10_REV; case GPU_DATA_10_11_11_REV: return GL_UNSIGNED_INT_10F_11F_11F_REV; default: @@ -333,6 +337,7 @@ inline GLenum to_gl_data_format(eGPUTextureFormat format) case GPU_RGBA16: case GPU_RGBA16F: case GPU_RGBA32F: + case GPU_RGB10_A2: return GL_RGBA; case GPU_DEPTH24_STENCIL8: case GPU_DEPTH32F_STENCIL8: -- cgit v1.2.3