[Bf-blender-cvs] [3414d01] master: Use float format for high bit depth textures if available - storage requirements are the same but we may avoid some clipping of float values for HDRs when used in shaders.

Antony Riakiotakis noreply at git.blender.org
Mon Jan 5 11:24:08 CET 2015


Commit: 3414d014114158444f5d3fe7d307e832683bfebe
Author: Antony Riakiotakis
Date:   Mon Jan 5 11:23:44 2015 +0100
Branches: master
https://developer.blender.org/rB3414d014114158444f5d3fe7d307e832683bfebe

Use float format for high bit depth textures if available - storage
requirements are the same but we may avoid some clipping of float values
for HDRs when used in shaders.

===================================================================

M	source/blender/gpu/intern/gpu_draw.c

===================================================================

diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 6e3fc76..5f58e3f 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -724,8 +724,12 @@ void GPU_create_gl_tex(unsigned int *bind, unsigned int *pix, float *frect, int
 	glBindTexture(GL_TEXTURE_2D, *bind);
 
 	if (!(GPU_get_mipmap() && mipmap)) {
-		if (use_high_bit_depth)
-			glTexImage2D(GL_TEXTURE_2D, 0,  GL_RGBA16,  rectw, recth, 0, GL_RGBA, GL_FLOAT, frect);
+		if (use_high_bit_depth) {
+			if (GLEW_ARB_texture_float)
+				glTexImage2D(GL_TEXTURE_2D, 0,  GL_RGBA16F,  rectw, recth, 0, GL_RGBA, GL_FLOAT, frect);
+			else
+				glTexImage2D(GL_TEXTURE_2D, 0,  GL_RGBA16,  rectw, recth, 0, GL_RGBA, GL_FLOAT, frect);
+		}
 		else
 			glTexImage2D(GL_TEXTURE_2D, 0,  GL_RGBA,  rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, pix);
 		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -733,8 +737,12 @@ void GPU_create_gl_tex(unsigned int *bind, unsigned int *pix, float *frect, int
 	}
 	else {
 		if (GTS.gpu_mipmap) {
-			if (use_high_bit_depth)
-				glTexImage2D(GL_TEXTURE_2D, 0,  GL_RGBA16,  rectw, recth, 0, GL_RGBA, GL_FLOAT, frect);
+			if (use_high_bit_depth) {
+				if (GLEW_ARB_texture_float)
+					glTexImage2D(GL_TEXTURE_2D, 0,  GL_RGBA16F,  rectw, recth, 0, GL_RGBA, GL_FLOAT, frect);
+				else
+					glTexImage2D(GL_TEXTURE_2D, 0,  GL_RGBA16,  rectw, recth, 0, GL_RGBA, GL_FLOAT, frect);
+			}
 			else
 				glTexImage2D(GL_TEXTURE_2D, 0,  GL_RGBA,  rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, pix);




More information about the Bf-blender-cvs mailing list