[Bf-blender-cvs] [0911acb5cf4] blender2.8: Merge branch 'master' into blender2.8

Campbell Barton noreply at git.blender.org
Mon Jun 4 09:12:50 CEST 2018


Commit: 0911acb5cf49c5ba05b1df045b41697704aa288a
Author: Campbell Barton
Date:   Mon Jun 4 09:10:51 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB0911acb5cf49c5ba05b1df045b41697704aa288a

Merge branch 'master' into blender2.8

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



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

diff --cc source/blender/gpu/GPU_texture.h
index 2427301782c,1ae3d73991e..cc1a26f57f7
--- a/source/blender/gpu/GPU_texture.h
+++ b/source/blender/gpu/GPU_texture.h
@@@ -39,8 -39,7 +39,8 @@@ extern "C" 
  struct Image;
  struct ImageUser;
  struct PreviewImage;
 +struct Gwn_VertBuf;
- 	
+ 
  struct GPUFrameBuffer;
  typedef struct GPUTexture GPUTexture;
  
diff --cc source/blender/gpu/intern/gpu_basic_shader.c
index 620a06ae606,5d23de78451..b720bed2d0c
--- a/source/blender/gpu/intern/gpu_basic_shader.c
+++ b/source/blender/gpu/intern/gpu_basic_shader.c
@@@ -237,8 -388,8 +237,8 @@@ static GPUShader *gpu_basic_shader(int 
  			datatoc_gpu_shader_basic_frag_glsl,
  			geom_glsl,
  			NULL,
 -			defines, 0, 0, 0);
 +			defines);
- 		
+ 
  		if (shader) {
  			/* set texture map to first texture unit */
  			if (options & (GPU_SHADER_TEXTURE_2D | GPU_SHADER_TEXTURE_RECT)) {
diff --cc source/blender/gpu/intern/gpu_buffers.c
index 9d2a0ceef4d,a35f678f8dc..df8dbb03284
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@@ -438,30 -1283,29 +438,30 @@@ void GPU_pbvh_grid_buffers_update
  				for (y = 0; y < key->grid_size; y++) {
  					for (x = 0; x < key->grid_size; x++) {
  						CCGElem *elem = CCG_grid_elem(key, grid, x, y);
 +						GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index, CCG_elem_co(key, elem));
  
 -						copy_v3_v3(vd->co, CCG_elem_co(key, elem));
  						if (buffers->smooth) {
 -							normal_float_to_short_v3(vd->no, CCG_elem_no(key, elem));
 +							short no_short[3];
 +							normal_float_to_short_v3(no_short, CCG_elem_no(key, elem));
 +							GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no_short);
  
  							if (has_mask) {
 +								uchar color_ub[3];
  								if (show_mask) {
  									gpu_color_from_mask_copy(*CCG_elem_mask(key, elem),
 -									                         diffuse_color, vd->color);
 +									                         diffuse_color, color_ub);
  								}
  								else {
 -									unit_float_to_uchar_clamp_v3(vd->color, diffuse_color);
 +									unit_float_to_uchar_clamp_v3(color_ub, diffuse_color);
  								}
 +								GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub);
  							}
  						}
 -						vd++;
 +						vbo_index += 1;
  					}
  				}
- 				
+ 
  				if (!buffers->smooth) {
 -					/* for flat shading, recalc normals and set the last vertex of
 -					 * each triangle in the index buffer to have the flat normal as
 -					 * that is what opengl will use */
  					for (j = 0; j < key->grid_size - 1; j++) {
  						for (k = 0; k < key->grid_size - 1; k++) {
  							CCGElem *elems[4] = {
@@@ -865,13 -1739,12 +865,13 @@@ void GPU_pbvh_bmesh_buffers_update
  						fmask += BM_ELEM_CD_GET_FLOAT(v[i], cd_vert_mask_offset);
  					}
  					fmask /= 3.0f;
- 					
+ 
  					for (i = 0; i < 3; i++) {
 -						gpu_bmesh_vert_to_buffer_copy(v[i], vert_data,
 -						                              &v_index, f->no, &fmask,
 -						                              cd_vert_mask_offset, diffuse_color,
 -						                              show_mask);
 +						gpu_bmesh_vert_to_buffer_copy__gwn(
 +						        v[i], buffers->vert_buf,
 +						        &v_index, f->no, &fmask,
 +						        cd_vert_mask_offset, diffuse_color,
 +						        show_mask);
  					}
  				}
  			}
diff --cc source/blender/gpu/intern/gpu_framebuffer.c
index 75576c35f51,eafa29e6739..f86da2eb064
--- a/source/blender/gpu/intern/gpu_framebuffer.c
+++ b/source/blender/gpu/intern/gpu_framebuffer.c
@@@ -679,8 -503,7 +679,8 @@@ GPUOffScreen *GPU_offscreen_create(int 
  	/* check validity at the very end! */
  	if (!GPU_framebuffer_check_valid(ofs->fb, err_out)) {
  		GPU_offscreen_free(ofs);
 +		gpuPopAttrib();
- 		return NULL;		
+ 		return NULL;
  	}
  
  	GPU_framebuffer_restore();
diff --cc source/blender/gpu/intern/gpu_material.c
index 1d3c1d13be3,40ff9ca629b..7b3750c970b
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@@ -82,12 -97,8 +82,12 @@@ struct GPUMaterial 
  
  	/* material for mesh surface, worlds or something else.
  	 * some code generation is done differently depending on the use case */
 -	int type;
 +	int type; /* DEPRECATED */
 +	GPUMaterialStatus status;
 +
 +	const void *engine_type;   /* attached engine type */
 +	int options;    /* to identify shader variations (shadow, probe, world background...) */
- 	
+ 
  	/* for creating the material */
  	ListBase nodes;
  	GPUNodeLink *outlink;
@@@ -670,6 -2228,686 +670,6 @@@ void GPU_materials_free(void
  
  	for (wo = G.main->world.first; wo; wo = wo->id.next)
  		GPU_material_free(&wo->gpumaterial);
- 	
+ 
  	GPU_material_free(&defmaterial.gpumaterial);
 -
 -	for (ob = G.main->object.first; ob; ob = ob->id.next)
 -		GPU_lamp_free(ob);
  }
 -
 -/* Lamps and shadow buffers */
 -
 -static void gpu_lamp_calc_winmat(GPULamp *lamp)
 -{
 -	float temp, angle, pixsize, wsize;
 -
 -	if (lamp->type == LA_SUN) {
 -		wsize = lamp->la->shadow_frustum_size;
 -		orthographic_m4(lamp->winmat, -wsize, wsize, -wsize, wsize, lamp->d, lamp->clipend);
 -	}
 -	else if (lamp->type == LA_SPOT) {
 -		angle = saacos(lamp->spotsi);
 -		temp = 0.5f * lamp->size * cosf(angle) / sinf(angle);
 -		pixsize = lamp->d / temp;
 -		wsize = pixsize * 0.5f * lamp->size;
 -		/* compute shadows according to X and Y scaling factors */
 -		perspective_m4(
 -		        lamp->winmat,
 -		        -wsize * lamp->spotvec[0], wsize * lamp->spotvec[0],
 -		        -wsize * lamp->spotvec[1], wsize * lamp->spotvec[1],
 -		        lamp->d, lamp->clipend);
 -	}
 -}
 -
 -void GPU_lamp_update(GPULamp *lamp, int lay, int hide, float obmat[4][4])
 -{
 -	float mat[4][4];
 -	float obmat_scale[3];
 -
 -	lamp->lay = lay;
 -	lamp->hide = hide;
 -
 -	normalize_m4_m4_ex(mat, obmat, obmat_scale);
 -
 -	copy_v3_v3(lamp->vec, mat[2]);
 -	copy_v3_v3(lamp->co, mat[3]);
 -	copy_m4_m4(lamp->obmat, mat);
 -	invert_m4_m4(lamp->imat, mat);
 -
 -	if (lamp->type == LA_SPOT) {
 -		/* update spotlamp scale on X and Y axis */
 -		lamp->spotvec[0] = obmat_scale[0] / obmat_scale[2];
 -		lamp->spotvec[1] = obmat_scale[1] / obmat_scale[2];
 -	}
 -
 -	if (GPU_lamp_has_shadow_buffer(lamp)) {
 -		/* makeshadowbuf */
 -		gpu_lamp_calc_winmat(lamp);
 -	}
 -}
 -
 -void GPU_lamp_update_colors(GPULamp *lamp, float r, float g, float b, float energy)
 -{
 -	lamp->energy = energy;
 -	if (lamp->mode & LA_NEG) lamp->energy = -lamp->energy;
 -
 -	lamp->col[0] = r;
 -	lamp->col[1] = g;
 -	lamp->col[2] = b;
 -}
 -
 -void GPU_lamp_update_distance(GPULamp *lamp, float distance, float att1, float att2,
 -                              float coeff_const, float coeff_lin, float coeff_quad)
 -{
 -	lamp->dist = distance;
 -	lamp->att1 = att1;
 -	lamp->att2 = att2;
 -	lamp->coeff_const = coeff_const;
 -	lamp->coeff_lin = coeff_lin;
 -	lamp->coeff_quad = coeff_quad;
 -}
 -
 -void GPU_lamp_update_spot(GPULamp *lamp, float spotsize, float spotblend)
 -{
 -	lamp->spotsi = cosf(spotsize * 0.5f);
 -	lamp->spotbl = (1.0f - lamp->spotsi) * spotblend;
 -}
 -
 -static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *la, GPULamp *lamp)
 -{
 -	lamp->scene = scene;
 -	lamp->ob = ob;
 -	lamp->par = par;
 -	lamp->la = la;
 -
 -	/* add_render_lamp */
 -	lamp->mode = la->mode;
 -	lamp->type = la->type;
 -
 -	lamp->energy = la->energy;
 -	if (lamp->mode & LA_NEG) lamp->energy = -lamp->energy;
 -
 -	lamp->col[0] = la->r;
 -	lamp->col[1] = la->g;
 -	lamp->col[2] = la->b;
 -
 -	GPU_lamp_update(lamp, ob->lay, (ob->restrictflag & OB_RESTRICT_RENDER), ob->obmat);
 -
 -	lamp->spotsi = la->spotsize;
 -	if (lamp->mode & LA_HALO)
 -		if (lamp->spotsi > DEG2RADF(170.0f))
 -			lamp->spotsi = DEG2RADF(170.0f);
 -	lamp->spotsi = cosf(lamp->spotsi * 0.5f);
 -	lamp->spotbl = (1.0f - lamp->spotsi) * la->spotblend;
 -	lamp->k = la->k;
 -
 -	lamp->dist = la->dist;
 -	lamp->falloff_type = la->falloff_type;
 -	lamp->att1 = la->att1;
 -	lamp->att2 = la->att2;
 -	lamp->coeff_const = la->coeff_const;
 -	lamp->coeff_lin = la->coeff_lin;
 -	lamp->coeff_quad = la->coeff_quad;
 -	lamp->curfalloff = la->curfalloff;
 -
 -	/* initshadowbuf */
 -	lamp->bias = 0.02f * la->bias;
 -	lamp->size = la->bufsize;
 -	lamp->d = la->clipsta;
 -	lamp->clipend = la->clipend;
 -
 -	/* arbitrary correction for the fact we do no soft transition */
 -	lamp->bias *= 0.25f;
 -}
 -
 -static void gpu_lamp_shadow_free(GPULamp *lamp)
 -{
 -	if (lamp->tex) {
 -		GPU_texture_free(lamp->tex);
 -		lamp->tex = NULL;
 -	}
 -	if (lamp->depthtex) {
 -		GPU_texture_free(lamp->depthtex);
 -		lamp->depthtex = NULL;
 -	}
 -	if (lamp->fb) {
 -		GPU_framebuffer_free(lamp->fb);
 -		lamp->fb = NULL;
 -	}
 -	if (lamp->blurtex) {
 -		GPU_texture_free(lamp->blurtex);
 -		lamp->blurtex = NULL;
 -	}
 -	if (lamp->blurfb) {
 -		GPU_framebuffer_free(lamp->blurfb);
 -		lamp->blurfb = NULL;
 -	}
 -}
 -
 -GPULamp *GPU_lamp_from_blender(Scene *scene, Object *ob, Object *par)
 -{
 -	Lamp *la;
 -	GPULamp *lamp;
 -	LinkData *link;
 -
 -	for (link = ob->gpulamp.first; link; link = link->next) {
 -		lamp = (GPULamp *)link->data;
 -
 -		if (lamp->par == par && lamp->scene == scene)
 -			return link->data;
 -	}
 -
 -	lamp = MEM_callocN(sizeof(GPULamp), "GPULamp");
 -
 -	link = MEM_callocN(sizeof(LinkData), "GPULampLink");
 -	link->data = lamp;
 -	BLI_addtail(&ob->gpulamp, link);
 -
 -	la = ob->data;
 -	gpu_lamp_from_blender(scene, ob, par, la, lamp);
 -
 -	if ((la->type == LA_SPOT && (la->mode & (LA_SHAD_BUF | LA_SHAD_RAY))) ||
 -	    (la->type == LA_SUN && (la->mode & LA_SHAD_RAY)))
 -	{
 -		/* opengl */
 -		lamp->fb = GPU_framebuffer_create();
 -		if (!lamp->fb) {
 -			gpu_lamp_shadow_free(lamp);
 -			return lamp;
 -		}
 -
 -		if (lamp->la->shadowmap_type == LA_SHADMAP_VARIANCE) {
 -			/* Shadow depth map */
 -			lamp->depthtex = GPU_texture_create_depth(lamp->size, lamp->size, NULL);
 -			if (!lamp->depthtex) {
 -				gpu_lamp_shadow_free(lamp);
 -				return lamp;
 -			}
 -
 -			if (!GPU_framebuffer_texture_attach(lamp->fb, lamp->depthtex, 0, NULL)) {
 -				gpu_lamp_shadow_free(lamp);
 -				return lamp;
 -			}
 -
 -			/* Shadow color map */
 -			lamp->tex = GPU_texture_create_vsm_shadow_map(lamp->size, NULL);
 -			if (!lamp->tex) {


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list