[Bf-blender-cvs] [2cf79f41fe] clay-engine: Modifications to GPU_texture: -Remove NPOT check as it should be supported by default with OGL 3.3 -All custom texture creation follow the same path now -Now explicit texture format is required when creating a custom texture (Non RGBA8) -Support for arrays of textures

Clément Foucault noreply at git.blender.org
Mon Jan 9 15:07:53 CET 2017


Commit: 2cf79f41fe37a760eedb8bfd206668c17604cc15
Author: Clément Foucault
Date:   Fri Jan 6 14:38:36 2017 +0100
Branches: clay-engine
https://developer.blender.org/rB2cf79f41fe37a760eedb8bfd206668c17604cc15

Modifications to GPU_texture:
-Remove NPOT check as it should be supported by default with OGL 3.3
-All custom texture creation follow the same path now
-Now explicit texture format is required when creating a custom texture (Non RGBA8)
-Support for arrays of textures

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

M	source/blender/editors/space_view3d/drawvolume.c
M	source/blender/gpu/GPU_texture.h
M	source/blender/gpu/intern/gpu_codegen.c
M	source/blender/gpu/intern/gpu_compositing.c
M	source/blender/gpu/intern/gpu_draw.c
M	source/blender/gpu/intern/gpu_framebuffer.c
M	source/blender/gpu/intern/gpu_material.c
M	source/blender/gpu/intern/gpu_texture.c
M	source/blender/gpu/intern/gpu_viewport.c

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

diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c
index 27ecbf83db..debdcb58d7 100644
--- a/source/blender/editors/space_view3d/drawvolume.c
+++ b/source/blender/editors/space_view3d/drawvolume.c
@@ -160,7 +160,7 @@ static GPUTexture *create_field_texture(SmokeDomainSettings *sds)
 		default: return NULL;
 	}
 
-	return GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], 1, field);
+	return GPU_texture_create_3D_custom(sds->res[0], sds->res[1], sds->res[2], 1, GPU_R8, field, NULL);
 }
 
 typedef struct VolumeSlicer {
diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h
index 7d12fe0b01..3ddeb9c1f4 100644
--- a/source/blender/gpu/GPU_texture.h
+++ b/source/blender/gpu/GPU_texture.h
@@ -55,26 +55,101 @@ typedef struct GPUTexture GPUTexture;
  *  - if created with from_blender, will not free the texture
  */
 
-typedef enum GPUHDRType {
-	GPU_HDR_NONE =       0,
-	GPU_HDR_HALF_FLOAT = 1,
-	GPU_HDR_FULL_FLOAT = (1 << 1),
-} GPUHDRType;
+/* From OpenGl 3.3 specification */
+typedef enum GPUFormat {
+	/* Formats texture & renderbuffer */
+	GPU_RGBA32F,
+	GPU_RGBA32I,
+	GPU_RGBA32UI,
+	GPU_RGBA16,
+	GPU_RGBA16F,
+	GPU_RGBA16I,
+	GPU_RGBA16UI,
+	GPU_RGBA8,
+	GPU_RGBA8I,
+	GPU_RGBA8UI,
+	GPU_RG32F,
+	GPU_RG32I,
+	GPU_RG32UI,
+	GPU_RG16,
+	GPU_RG16F,
+	GPU_RG16I,
+	GPU_RG16UI,
+	GPU_RG8,
+	GPU_RG8I,
+	GPU_RG8UI,
+	GPU_R32F,
+	GPU_R32I,
+	GPU_R32UI,
+	GPU_R16F,
+	GPU_R16I,
+	GPU_R16UI,
+	GPU_R16,
+	GPU_R8,
+	GPU_R8I,
+	GPU_R8UI,
+
+	/* Special formats texture & renderbuffer */
+	GPU_R11F_G11F_B10F,
+	GPU_RGB10_A2,
+	GPU_RGB10_A2UI,
+	GPU_DEPTH32F_STENCIL8,
+	GPU_DEPTH24_STENCIL8,
+
+	/* Texture only format */
+	GPU_RGBA16_SNORM,
+	GPU_RGBA8_SNORM,
+	GPU_RGB32F,
+	GPU_RGB32I,
+	GPU_RGB32UI,
+	GPU_RGB16_SNORM,
+	GPU_RGB16F,
+	GPU_RGB16I,
+	GPU_RGB16UI,
+	GPU_RGB16,
+	GPU_RGB8_SNORM,
+	GPU_RGB8,
+	GPU_RGB8I,
+	GPU_RGB8UI,
+	GPU_RG16_SNORM,
+	GPU_RG8_SNORM,
+	GPU_R16_SNORM,
+	GPU_R8_SNORM,
+
+	/* Special formats texture only */
+	GPU_SRGB8_A8,
+	GPU_SRGB8,
+	GPU_RGB9_E5,
+	GPU_COMPRESSED_RG_RGTC2,
+	GPU_COMPRESSED_SIGNED_RG_RGTC2,
+	GPU_COMPRESSED_RED_RGTC1,
+	GPU_COMPRESSED_SIGNED_RED_RGTC1,
+
+	/* Depth Formats */
+	GPU_DEPTH_COMPONENT32F,
+	GPU_DEPTH_COMPONENT24,
+	GPU_DEPTH_COMPONENT16,
+} GPUFormat;
 
 GPUTexture *GPU_texture_create_1D(int w, const float *pixels, char err_out[256]);
-GPUTexture *GPU_texture_create_2D(int w, int h, const float *pixels, GPUHDRType hdr, char err_out[256]);
-GPUTexture *GPU_texture_create_3D(int w, int h, int depth, int channels, const float *fpixels);
+GPUTexture *GPU_texture_create_1D_custom(
+        int w, int channels, GPUFormat data_type, const float *pixels, char err_out[256]);
+GPUTexture *GPU_texture_create_2D(int w, int h, const float *pixels, char err_out[256]);
+GPUTexture *GPU_texture_create_2D_custom(
+        int w, int h, int channels, GPUFormat data_type, const float *pixels, char err_out[256]);
+GPUTexture *GPU_texture_create_2D_multisample(int w, int h, const float *pixels, int samples, char err_out[256]);
+GPUTexture *GPU_texture_create_2D_array(int w, int h, int d, const float *pixels, char err_out[256]);
+GPUTexture *GPU_texture_create_3D(int w, int h, int d, const float *pixels, char err_out[256]);
+GPUTexture *GPU_texture_create_3D_custom(
+        int w, int h, int d, int channels, GPUFormat data_type, const float *pixels, char err_out[256]);
 GPUTexture *GPU_texture_create_depth(int w, int h, char err_out[256]);
-GPUTexture *GPU_texture_create_vsm_shadow_map(int size, char err_out[256]);
-GPUTexture *GPU_texture_create_2D_procedural(int w, int h, const float *pixels, bool repeat, char err_out[256]);
-GPUTexture *GPU_texture_create_1D_procedural(int w, const float *pixels, char err_out[256]);
-GPUTexture *GPU_texture_create_2D_array(int w, int h, int d, const float *fpixels);
-GPUTexture *GPU_texture_create_2D_multisample(
-        int w, int h, const float *pixels, GPUHDRType hdr, int samples, char err_out[256]);
 GPUTexture *GPU_texture_create_depth_multisample(int w, int h, int samples, char err_out[256]);
+GPUTexture *GPU_texture_create_vsm_shadow_map(int size, char err_out[256]);
+
 GPUTexture *GPU_texture_from_blender(
         struct Image *ima, struct ImageUser *iuser, int textarget, bool is_data, double time, int mipmap);
 GPUTexture *GPU_texture_from_preview(struct PreviewImage *prv, int mipmap);
+
 void GPU_invalid_tex_init(void);
 void GPU_invalid_tex_bind(int mode);
 void GPU_invalid_tex_free(void);
@@ -82,12 +157,13 @@ void GPU_invalid_tex_free(void);
 void GPU_texture_free(GPUTexture *tex);
 
 void GPU_texture_ref(GPUTexture *tex);
-
 void GPU_texture_bind(GPUTexture *tex, int number);
 void GPU_texture_unbind(GPUTexture *tex);
 int GPU_texture_bound_number(GPUTexture *tex);
 
-void GPU_texture_filter_mode(GPUTexture *tex, bool compare, bool use_filter);
+void GPU_texture_compare_mode(GPUTexture *tex, bool use_compare);
+void GPU_texture_filter_mode(GPUTexture *tex, bool use_filter);
+void GPU_texture_wrap_mode(GPUTexture *tex, bool use_repeat);
 
 struct GPUFrameBuffer *GPU_texture_framebuffer(GPUTexture *tex);
 int GPU_texture_framebuffer_attachment(GPUTexture *tex);
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 211394e793..4223ec54f7 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -1192,7 +1192,7 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const GPUType
 #if 0
 		input->tex = GPU_texture_create_2D(link->texturesize, link->texturesize, link->ptr2, NULL);
 #endif
-		input->tex = GPU_texture_create_2D(link->texturesize, 1, link->ptr1, GPU_HDR_NONE, NULL);
+		input->tex = GPU_texture_create_2D(link->texturesize, 1, link->ptr1, NULL);
 		input->textarget = GL_TEXTURE_2D;
 
 		MEM_freeN(link->ptr1);
diff --git a/source/blender/gpu/intern/gpu_compositing.c b/source/blender/gpu/intern/gpu_compositing.c
index 13596f2a0d..528bdefc20 100644
--- a/source/blender/gpu/intern/gpu_compositing.c
+++ b/source/blender/gpu/intern/gpu_compositing.c
@@ -225,7 +225,13 @@ static GPUTexture * create_concentric_sample_texture(int side)
 		}
 	}
 
-	tex = GPU_texture_create_1D_procedural(side * side, texels, NULL);
+	tex = GPU_texture_create_1D_custom(side * side, 2, GPU_RG16F, (float *)texels, NULL);
+
+	/* Set parameters */
+	GPU_texture_bind(tex, 0);
+	GPU_texture_filter_mode(tex, false);
+	GPU_texture_unbind(tex);
+
 	MEM_freeN(texels);
 	return tex;
 }
@@ -247,7 +253,13 @@ static GPUTexture *create_spiral_sample_texture(int numsaples)
 		texels[i][1] = r * sinf(phi);
 	}
 
-	tex = GPU_texture_create_1D_procedural(numsaples, (float *)texels, NULL);
+	tex = GPU_texture_create_1D_custom(numsaples, 2, GPU_RG16F, (float *)texels, NULL);
+
+	/* Set parameters */
+	GPU_texture_bind(tex, 0);
+	GPU_texture_filter_mode(tex, false);
+	GPU_texture_unbind(tex);
+
 	MEM_freeN(texels);
 	return tex;
 }
@@ -358,6 +370,7 @@ void GPU_fx_compositor_destroy(GPUFX *fx)
 
 static GPUTexture * create_jitter_texture(void)
 {
+	GPUTexture *tex;
 	float jitter[64 * 64][2];
 	int i;
 
@@ -367,7 +380,15 @@ static GPUTexture * create_jitter_texture(void)
 		normalize_v2(jitter[i]);
 	}
 
-	return GPU_texture_create_2D_procedural(64, 64, &jitter[0][0], true, NULL);
+	tex = GPU_texture_create_2D_custom(64, 64, 2, GPU_RG16F, &jitter[0][0], NULL);
+
+	/* Set parameters */
+	GPU_texture_bind(tex, 0);
+	GPU_texture_filter_mode(tex, false);
+	GPU_texture_wrap_mode(tex, true);
+	GPU_texture_unbind(tex);
+
+	return tex;
 }
 
 
@@ -433,7 +454,7 @@ bool GPU_fx_compositor_initialize_passes(
 	if (!fx->color_buffer || !fx->depth_buffer || w != fx->gbuffer_dim[0] || h != fx->gbuffer_dim[1]) {
 		cleanup_fx_gl_data(fx, false);
 
-		if (!(fx->color_buffer = GPU_texture_create_2D(w, h, NULL, GPU_HDR_NONE, err_out))) {
+		if (!(fx->color_buffer = GPU_texture_create_2D(w, h, NULL, err_out))) {
 			printf(".256%s\n", err_out);
 			cleanup_fx_gl_data(fx, true);
 			return false;
@@ -485,38 +506,42 @@ bool GPU_fx_compositor_initialize_passes(
 			{
 
 				if (!(fx->dof_half_downsampled_near = GPU_texture_create_2D(
-				      fx->dof_downsampled_w, fx->dof_downsampled_h, NULL, GPU_HDR_NONE, err_out)))
+				      fx->dof_downsampled_w, fx->dof_downsampled_h, NULL, err_out)))
 				{
 					printf("%.256s\n", err_out);
 					cleanup_fx_gl_data(fx, true);
 					return false;
 				}
 				if (!(fx->dof_half_downsampled_far = GPU_texture_create_2D(
-				      fx->dof_downsampled_w, fx->dof_downsampled_h, NULL, GPU_HDR_NONE, err_out)))
+				      fx->dof_downsampled_w, fx->dof_downsampled_h, NULL, err_out)))
 				{
 					printf("%.256s\n", err_out);
 					cleanup_fx_gl_data(fx, true);
 					return false;
 				}
-				if (!(fx->dof_nearfar_coc = GPU_texture_create_2D_procedural(
-				      fx->dof_downsampled_w, fx->dof_downsampled_h, NULL, false, err_out)))
+
+				if (!(fx->dof_nearfar_coc = GPU_texture_create_2D_custom(
+				    fx->dof_downsampled_w, fx->dof_downsampled_h, 2, GPU_RG16F, NULL, err_out)))
 				{
 					printf("%.256s\n", err_out);
 					cleanup_fx_gl_data(fx, true);
 					return false;
 				}
+				GPU_texture_bind(fx->dof_nearfar_coc, 0);
+				GPU_texture_filter_mode(fx->dof_nearfar_coc, false);
+				GPU_texture_wrap_mode(fx->dof_nearfar_coc, false);
+				GPU_texture_unbind(fx->dof_nearfar_coc);
 
-
-				if (!(fx->dof_near_blur = GPU_texture_create_2D(
-				    fx->dof_downsampled_w, fx->dof_downsampled_h, NULL, GPU_HDR_HALF_FLOAT, err_out)))
+				if (!(fx->dof_near_blur = GPU_texture_create_2D_custom(
+				    fx->dof_downsampled_w, fx->dof_downsampled_h, 2, GPU_RGBA16F, NULL, err_out)))
 				{
 					printf("%.256s\n", err_out);
 					cleanup_fx_gl_data(fx, true);
 					return false;
 				}
 
-				if (!(fx->dof_far_blur = GPU_texture_create_2D(
-				    fx->dof_downsampled_w, fx->dof_downsampled_h, NULL, GPU_HDR_HALF_FLOAT, err_out)))
+				if (!(fx->dof_far_blur = GPU_texture_create_2D_custom(
+				    fx->dof_downsampled_w, fx->dof_downsampled_h, 2, GPU_RGBA16F, NULL, err_out)))
 				{
 					printf("%.256s\n", err_out);
 					cleanup_fx_gl_data(fx, true);
@@ -531,21 +556,21 @@ bool GPU_fx_compositor_initialize_passes

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list