[Bf-blender-cvs] [77b39bbaa0c] blender2.8: Cleanup: Rename GPU_* functions to make more sense

Clément Foucault noreply at git.blender.org
Mon Aug 13 23:02:37 CEST 2018


Commit: 77b39bbaa0c796b936f8691c1431f467d4f39981
Author: Clément Foucault
Date:   Mon Aug 13 15:30:29 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB77b39bbaa0c796b936f8691c1431f467d4f39981

Cleanup: Rename GPU_* functions to make more sense

* Remove GPU_link_changed which is unused.
* Remove all GPU link function that are not used anymore.
* GPU_uniform_buffer is now GPU_uniform.
* GPU_texture_ramp is now GPU_color_band.
* GPU_uniform is now GPU_constant.

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

M	source/blender/gpu/GPU_material.h
M	source/blender/gpu/intern/gpu_codegen.c
M	source/blender/gpu/intern/gpu_codegen.h
M	source/blender/gpu/intern/gpu_shader.c
M	source/blender/nodes/shader/node_shader_util.c
M	source/blender/nodes/shader/nodes/node_shader_blackbody.c
M	source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
M	source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
M	source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
M	source/blender/nodes/shader/nodes/node_shader_bump.c
M	source/blender/nodes/shader/nodes/node_shader_curves.c
M	source/blender/nodes/shader/nodes/node_shader_eevee_specular.c
M	source/blender/nodes/shader/nodes/node_shader_mapping.c
M	source/blender/nodes/shader/nodes/node_shader_math.c
M	source/blender/nodes/shader/nodes/node_shader_mixRgb.c
M	source/blender/nodes/shader/nodes/node_shader_normal.c
M	source/blender/nodes/shader/nodes/node_shader_normal_map.c
M	source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
M	source/blender/nodes/shader/nodes/node_shader_tex_brick.c
M	source/blender/nodes/shader/nodes/node_shader_tex_gradient.c
M	source/blender/nodes/shader/nodes/node_shader_tex_image.c
M	source/blender/nodes/shader/nodes/node_shader_tex_magic.c
M	source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c
M	source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
M	source/blender/nodes/shader/nodes/node_shader_tex_wave.c
M	source/blender/nodes/shader/nodes/node_shader_valToRgb.c
M	source/blender/nodes/shader/nodes/node_shader_vectTransform.c
M	source/blender/nodes/shader/nodes/node_shader_volume_principled.c

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

diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index 6b0296361ec..5bbe9d6d904 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -224,16 +224,11 @@ typedef enum GPUDynamicType {
 } GPUDynamicType;
 
 GPUNodeLink *GPU_attribute(CustomDataType type, const char *name);
+GPUNodeLink *GPU_constant(float *num);
 GPUNodeLink *GPU_uniform(float *num);
-GPUNodeLink *GPU_dynamic_uniform(float *num, GPUDynamicType dynamictype, void *data);
-GPUNodeLink *GPU_uniform_buffer(float *num, GPUType gputype);
 GPUNodeLink *GPU_image(struct Image *ima, struct ImageUser *iuser, bool is_data);
-GPUNodeLink *GPU_cube_map(struct Image *ima, struct ImageUser *iuser, bool is_data);
-GPUNodeLink *GPU_image_preview(struct PreviewImage *prv);
-GPUNodeLink *GPU_texture_ramp(GPUMaterial *mat, int size, float *pixels, float *layer);
-GPUNodeLink *GPU_dynamic_texture(struct GPUTexture *tex, GPUDynamicType dynamictype, void *data);
+GPUNodeLink *GPU_color_band(GPUMaterial *mat, int size, float *pixels, float *layer);
 GPUNodeLink *GPU_builtin(GPUBuiltin builtin);
-GPUNodeLink *GPU_opengl_builtin(GPUOpenGLBuiltin builtin);
 void GPU_node_link_set_type(GPUNodeLink *link, GPUType type);
 
 bool GPU_link(GPUMaterial *mat, const char *name, ...);
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 289befe674e..0eee9bf6ead 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -1447,19 +1447,19 @@ static GPUNodeLink *gpu_uniformbuffer_link(
 			case SOCK_FLOAT:
 			{
 				bNodeSocketValueFloat *socket_data = socket->default_value;
-				link = GPU_uniform_buffer(&socket_data->value, GPU_FLOAT);
+				link = GPU_uniform(&socket_data->value);
 				break;
 			}
 			case SOCK_VECTOR:
 			{
 				bNodeSocketValueRGBA *socket_data = socket->default_value;
-				link = GPU_uniform_buffer(socket_data->value, GPU_VEC3);
+				link = GPU_uniform(socket_data->value);
 				break;
 			}
 			case SOCK_RGBA:
 			{
 				bNodeSocketValueRGBA *socket_data = socket->default_value;
-				link = GPU_uniform_buffer(socket_data->value, GPU_VEC4);
+				link = GPU_uniform(socket_data->value);
 				break;
 			}
 			default:
@@ -1612,7 +1612,7 @@ GPUNodeLink *GPU_attribute(const CustomDataType type, const char *name)
 	return link;
 }
 
-GPUNodeLink *GPU_uniform(float *num)
+GPUNodeLink *GPU_constant(float *num)
 {
 	GPUNodeLink *link = GPU_node_link_create();
 
@@ -1622,30 +1622,13 @@ GPUNodeLink *GPU_uniform(float *num)
 	return link;
 }
 
-GPUNodeLink *GPU_dynamic_uniform(float *num, GPUDynamicType dynamictype, void *data)
-{
-	GPUNodeLink *link = GPU_node_link_create();
-
-	link->ptr1 = num;
-	link->ptr2 = data;
-	link->dynamic = true;
-	link->dynamictype = dynamictype;
-
-
-	return link;
-}
-
-/**
- * Add uniform to UBO struct of GPUMaterial.
- */
-GPUNodeLink *GPU_uniform_buffer(float *num, GPUType gputype)
+GPUNodeLink *GPU_uniform(float *num)
 {
 	GPUNodeLink *link = GPU_node_link_create();
 	link->ptr1 = num;
 	link->ptr2 = NULL;
 	link->dynamic = true;
 	link->dynamictype = GPU_DYNAMIC_UBO;
-	link->type = gputype;
 
 	return link;
 }
@@ -1662,53 +1645,18 @@ GPUNodeLink *GPU_image(Image *ima, ImageUser *iuser, bool is_data)
 	return link;
 }
 
-GPUNodeLink *GPU_cube_map(Image *ima, ImageUser *iuser, bool is_data)
-{
-	GPUNodeLink *link = GPU_node_link_create();
-
-	link->image = GPU_NODE_LINK_IMAGE_CUBE_MAP;
-	link->ptr1 = ima;
-	link->ptr2 = iuser;
-	link->image_isdata = is_data;
-
-	return link;
-}
-
-GPUNodeLink *GPU_image_preview(PreviewImage *prv)
-{
-	GPUNodeLink *link = GPU_node_link_create();
-
-	link->image = GPU_NODE_LINK_IMAGE_PREVIEW;
-	link->ptr1 = prv;
-
-	return link;
-}
-
-
-GPUNodeLink *GPU_texture_ramp(GPUMaterial *mat, int size, float *pixels, float *row)
+GPUNodeLink *GPU_color_band(GPUMaterial *mat, int size, float *pixels, float *layer)
 {
 	GPUNodeLink *link = GPU_node_link_create();
 
 	link->texture = true;
-	link->ptr1 = gpu_material_ramp_texture_row_set(mat, size, pixels, row);
+	link->ptr1 = gpu_material_ramp_texture_row_set(mat, size, pixels, layer);
 
 	MEM_freeN(pixels);
 
 	return link;
 }
 
-GPUNodeLink *GPU_dynamic_texture(GPUTexture *tex, GPUDynamicType dynamictype, void *data)
-{
-	GPUNodeLink *link = GPU_node_link_create();
-
-	link->dynamic = true;
-	link->dynamictex = tex;
-	link->dynamictype = dynamictype;
-	link->ptr2 = data;
-
-	return link;
-}
-
 GPUNodeLink *GPU_builtin(GPUBuiltin builtin)
 {
 	GPUNodeLink *link = GPU_node_link_create();
@@ -1718,15 +1666,6 @@ GPUNodeLink *GPU_builtin(GPUBuiltin builtin)
 	return link;
 }
 
-GPUNodeLink *GPU_opengl_builtin(GPUOpenGLBuiltin builtin)
-{
-	GPUNodeLink *link = GPU_node_link_create();
-
-	link->oglbuiltin = builtin;
-
-	return link;
-}
-
 bool GPU_link(GPUMaterial *mat, const char *name, ...)
 {
 	GPUNode *node;
@@ -1826,27 +1765,6 @@ bool GPU_stack_link(GPUMaterial *material, bNode *bnode, const char *name, GPUNo
 	return true;
 }
 
-int GPU_link_changed(GPUNodeLink *link)
-{
-	GPUNode *node;
-	GPUInput *input;
-	const char *name;
-
-	if (link->output) {
-		node = link->output->node;
-		name = node->name;
-
-		if (STREQ(name, "set_value") || STREQ(name, "set_rgb")) {
-			input = node->inputs.first;
-			return (input->link != NULL);
-		}
-
-		return 1;
-	}
-	else
-		return 0;
-}
-
 GPUNodeLink *GPU_uniformbuffer_link_out(GPUMaterial *mat, bNode *node, GPUNodeStack *stack, const int index)
 {
 	return gpu_uniformbuffer_link(mat, node, stack, index, SOCK_OUT);
diff --git a/source/blender/gpu/intern/gpu_codegen.h b/source/blender/gpu/intern/gpu_codegen.h
index 77e6e5cf4ef..21dcaf6b591 100644
--- a/source/blender/gpu/intern/gpu_codegen.h
+++ b/source/blender/gpu/intern/gpu_codegen.h
@@ -198,6 +198,5 @@ void gpu_codegen_exit(void);
 const char *GPU_builtin_name(GPUBuiltin builtin);
 void gpu_material_add_node(struct GPUMaterial *material, struct GPUNode *node);
 struct GPUTexture **gpu_material_ramp_texture_row_set(GPUMaterial *mat, int size, float *pixels, float *row);
-int GPU_link_changed(struct GPUNodeLink *link);
 
 #endif
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c
index 6560b5e7f13..b812cf61483 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -239,13 +239,8 @@ static void gpu_shader_standard_defines(
         bool use_opensubdiv)
 {
 	/* some useful defines to detect GPU type */
-	if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY)) {
+	if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY))
 		strcat(defines, "#define GPU_ATI\n");
-		if (GLEW_VERSION_3_0) {
-			/* TODO(merwin): revisit this version check; GLEW_VERSION_3_0 means GL 3.0 or newer */
-			strcat(defines, "#define CLIP_WORKAROUND\n");
-		}
-	}
 	else if (GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_ANY, GPU_DRIVER_ANY))
 		strcat(defines, "#define GPU_NVIDIA\n");
 	else if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY))
diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c
index 63c1cac566d..80cfba00e0a 100644
--- a/source/blender/nodes/shader/node_shader_util.c
+++ b/source/blender/nodes/shader/node_shader_util.c
@@ -257,12 +257,12 @@ void node_shader_gpu_tex_mapping(GPUMaterial *mat, bNode *node, GPUNodeStack *in
 		static float min[3] = {-FLT_MAX, -FLT_MAX, -FLT_MAX};
 		GPUNodeLink *tmin, *tmax, *tmat0, *tmat1, *tmat2, *tmat3;
 
-		tmin = GPU_uniform_buffer((domin) ? texmap->min : min, GPU_VEC3);
-		tmax = GPU_uniform_buffer((domax) ? texmap->max : max, GPU_VEC3);
-		tmat0 = GPU_uniform_buffer((float *)texmap->mat[0], GPU_VEC4);
-		tmat1 = GPU_uniform_buffer((float *)texmap->mat[1], GPU_VEC4);
-		tmat2 = GPU_uniform_buffer((float *)texmap->mat[2], GPU_VEC4);
-		tmat3 = GPU_uniform_buffer((float *)texmap->mat[3], GPU_VEC4);
+		tmin = GPU_uniform((domin) ? texmap->min : min);
+		tmax = GPU_uniform((domax) ? texmap->max : max);
+		tmat0 = GPU_uniform((float *)texmap->mat[0]);
+		tmat1 = GPU_uniform((float *)texmap->mat[1]);
+		tmat2 = GPU_uniform((float *)texmap->mat[2]);
+		tmat3 = GPU_uniform((float *)texmap->mat[3]);
 
 		GPU_link(mat, "mapping", in[0].link, tmat0, tmat1, tmat2, tmat3, tmin, tmax, &in[0].link);
 
diff --git a/source/blender/nodes/shader/nodes/node_shader_blackbody.c b/source/blender/nodes/shader/nodes/node_shader_blackbody.c
index e57f5e0d6cf..28ba3d2c5c8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_blackbody.c
+++ b/source/blender/nodes/shader/nodes/node_shader_blackbody.c
@@ -46,9 +46,9 @@ static int node_shader_gpu_blackbody(GPUMaterial *mat, bNode *node, bNodeExecDat
 	blackbody_temperature_to_rgb_table(data, size, 965.0f, 12000.0f);
 
 	float layer;
-	GPUNodeLink *ramp_texture = GPU_texture_ramp(mat, size, data, &layer);
+	GPUNodeLink *ramp_texture = GPU_color_band(mat, size, data, &layer);
 
-	return GPU_stack_link(mat, node, "node_blackbody", in, out, ramp_texture, GPU_uniform(&layer));
+	return GPU_stack_link(mat, node, "node_blackbody", in, out, ramp_texture, GPU_constant(&layer));
 }
 
 /* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
index ada6e21356f..b18dcacb98f 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
@@ -54,7 +54,7 @@ static int node_shader_gpu_bsdf_glass(GPUMaterial *mat, bNode *node, bNodeExecDa
 
 	GPU_material_flag_set(mat, GPU_MATFLAG_GLOSSY | GPU_MATFLAG_REFRACT);
 
-	return GPU_stack_link(mat, node, "node_bsdf_glass", in, out, GPU_uniform(&node->ssr_id));
+	return GPU_stack_link(mat, node, "node_bsdf_glass", in, out, GPU_constant(&node->ssr_id));
 }
 
 /* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
index f56837de261..342b3a67ffb 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
@@ -53,7 +53,7 @@ static int node_shader_gpu_bsdf_glossy(GPUMa

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list