[Bf-blender-cvs] [6741f8e] soc-2014-viewport_fx: Accidentally committed some backup copies of some files in gpu.

Jason Wilkins noreply at git.blender.org
Sat Jun 28 11:03:13 CEST 2014


Commit: 6741f8e7a0a35ac3df2f2cb71e6598dc13091b21
Author: Jason Wilkins
Date:   Sat Jun 28 04:02:55 2014 -0500
https://developer.blender.org/rB6741f8e7a0a35ac3df2f2cb71e6598dc13091b21

Accidentally committed some backup copies of some files in gpu.

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

D	source/blender/gpu/intern/gpu_buffers - Copy.c
D	source/blender/gpu/intern/gpu_draw - Copy.c
D	source/blender/gpu/intern/gpu_extensions - Copy.c
D	source/blender/gpu/shaders/gpu_shader_material - Copy.glsl
D	source/blender/gpu/shaders/gpu_shader_vertex - Copy.glsl

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

diff --git a/source/blender/gpu/intern/gpu_buffers - Copy.c b/source/blender/gpu/intern/gpu_buffers - Copy.c
deleted file mode 100644
index d1e3a38..0000000
--- a/source/blender/gpu/intern/gpu_buffers - Copy.c	
+++ /dev/null
@@ -1,2756 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2005 Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Brecht Van Lommel.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/gpu/intern/gpu_buffers.c
- *  \ingroup gpu
- *
- * Mesh drawing using OpenGL VBO (Vertex Buffer Objects),
- * with fall-back to vertex arrays.
- */
-
-/* my interface */
-#include "GPU_buffers.h"
-/* my library */
-#include "GPU_basic.h"
-#include "GPU_blender_aspect.h"
-#include "GPU_common.h"
-#include "GPU_draw.h"
-#include "GPU_glew.h"
-#include "GPU_immediate.h"
-#include "GPU_raster.h"
-
-
-/* internal */
-#include "intern/gpu_extensions_intern.h"
-
-/* external */
-
-#include "BKE_ccg.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_paint.h"
-#include "BKE_pbvh.h"
-
-#include "BLI_bitmap.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-#include "BLI_ghash.h"
-#include "BLI_threads.h"
-
-#include "bmesh.h"
-
-#include "DNA_meshdata_types.h"
-#include "DNA_userdef_types.h"
-
-#include "MEM_guardedalloc.h"
-
-/* standard */
-#include <limits.h>
-#include <stddef.h>
-#include <string.h>
-
-
-
-typedef enum {
-	GPU_BUFFER_VERTEX_STATE = 1,
-	GPU_BUFFER_NORMAL_STATE = 2,
-	GPU_BUFFER_TEXCOORD_STATE = 4,
-	GPU_BUFFER_COLOR_STATE = 8,
-	GPU_BUFFER_ELEMENT_STATE = 16,
-} GPUBufferState;
-
-#define MAX_GPU_ATTRIB_DATA 32
-
-/* -1 - undefined, 0 - vertex arrays, 1 - VBOs */
-static int useVBOs = -1;
-static GPUBufferState GLStates = 0;
-static GPUAttrib attribData[MAX_GPU_ATTRIB_DATA] = { { -1, 0, 0 } };
-
-static ThreadMutex buffer_mutex = BLI_MUTEX_INITIALIZER;
-
-/* stores recently-deleted buffers so that new buffers won't have to
- * be recreated as often
- *
- * only one instance of this pool is created, stored in
- * gpu_buffer_pool
- *
- * note that the number of buffers in the pool is usually limited to
- * MAX_FREE_GPU_BUFFERS, but this limit may be exceeded temporarily
- * when a GPUBuffer is released outside the main thread; due to OpenGL
- * restrictions it cannot be immediately released
- */
-typedef struct GPUBufferPool {
-	/* number of allocated buffers stored */
-	int totbuf;
-	int totpbvhbufids;
-	/* actual allocated length of the arrays */
-	int maxsize;
-	int maxpbvhsize;
-	GPUBuffer **buffers;
-	GLuint *pbvhbufids;
-} GPUBufferPool;
-#define MAX_FREE_GPU_BUFFERS 8
-#define MAX_FREE_GPU_BUFF_IDS 100
-
-/* create a new GPUBufferPool */
-static GPUBufferPool *gpu_buffer_pool_new(void)
-{
-	GPUBufferPool *pool;
-
-	/* enable VBOs if supported */
-	if (useVBOs == -1)
-		useVBOs = (GLEW_ARB_vertex_buffer_object ? 1 : 0);
-
-	pool = MEM_callocN(sizeof(GPUBufferPool), "GPUBuffer_Pool");
-
-	pool->maxsize = MAX_FREE_GPU_BUFFERS;
-	pool->maxpbvhsize = MAX_FREE_GPU_BUFF_IDS;
-	pool->buffers = MEM_mallocN(sizeof(*pool->buffers) * pool->maxsize,
-	                            "GPUBufferPool.buffers");
-	pool->pbvhbufids = MEM_mallocN(sizeof(*pool->pbvhbufids) * pool->maxpbvhsize,
-	                               "GPUBufferPool.pbvhbuffers");
-	return pool;
-}
-
-/* remove a GPUBuffer from the pool (does not free the GPUBuffer) */
-static void gpu_buffer_pool_remove_index(GPUBufferPool *pool, int index)
-{
-	int i;
-
-	if (!pool || index < 0 || index >= pool->totbuf)
-		return;
-
-	/* shift entries down, overwriting the buffer at `index' */
-	for (i = index; i < pool->totbuf - 1; i++)
-		pool->buffers[i] = pool->buffers[i + 1];
-
-	/* clear the last entry */
-	if (pool->totbuf > 0)
-		pool->buffers[pool->totbuf - 1] = NULL;
-
-	pool->totbuf--;
-}
-
-/* delete the last entry in the pool */
-static void gpu_buffer_pool_delete_last(GPUBufferPool *pool)
-{
-	GPUBuffer *last;
-
-	if (pool->totbuf <= 0)
-		return;
-
-	/* get the last entry */
-	if (!(last = pool->buffers[pool->totbuf - 1]))
-		return;
-
-	/* delete the buffer's data */
-	if (useVBOs)
-		gpu_glDeleteBuffers(1, &last->id);
-	else
-		MEM_freeN(last->pointer);
-
-	/* delete the buffer and remove from pool */
-	MEM_freeN(last);
-	pool->totbuf--;
-	pool->buffers[pool->totbuf] = NULL;
-}
-
-/* free a GPUBufferPool; also frees the data in the pool's
- * GPUBuffers */
-static void gpu_buffer_pool_free(GPUBufferPool *pool)
-{
-	if (!pool)
-		return;
-	
-	while (pool->totbuf)
-		gpu_buffer_pool_delete_last(pool);
-
-	MEM_freeN(pool->buffers);
-	MEM_freeN(pool->pbvhbufids);
-	MEM_freeN(pool);
-}
-
-static void gpu_buffer_pool_free_unused(GPUBufferPool *pool)
-{
-	if (!pool)
-		return;
-
-	BLI_mutex_lock(&buffer_mutex);
-	
-	while (pool->totbuf)
-		gpu_buffer_pool_delete_last(pool);
-
-	glDeleteBuffersARB(pool->totpbvhbufids, pool->pbvhbufids);
-	pool->totpbvhbufids = 0;
-
-	BLI_mutex_unlock(&buffer_mutex);
-}
-
-static GPUBufferPool *gpu_buffer_pool = NULL;
-static GPUBufferPool *gpu_get_global_buffer_pool(void)
-{
-	/* initialize the pool */
-	if (!gpu_buffer_pool)
-		gpu_buffer_pool = gpu_buffer_pool_new();
-
-	return gpu_buffer_pool;
-}
-
-void GPU_global_buffer_pool_free(void)
-{
-	gpu_buffer_pool_free(gpu_buffer_pool);
-	gpu_buffer_pool = NULL;
-}
-
-void GPU_global_buffer_pool_free_unused(void)
-{
-	gpu_buffer_pool_free_unused(gpu_buffer_pool);
-}
-
-/* get a GPUBuffer of at least `size' bytes; uses one from the buffer
- * pool if possible, otherwise creates a new one
- *
- * Thread-unsafe version for internal usage only.
- */
-static GPUBuffer *gpu_buffer_alloc_intern(int size)
-{
-	GPUBufferPool *pool;
-	GPUBuffer *buf;
-	int i, bufsize, bestfit = -1;
-
-	/* bad case, leads to leak of buf since buf->pointer will allocate
-	 * NULL, leading to return without cleanup. In any case better detect early
-	 * psy-fi */
-	if (size == 0)
-		return NULL;
-
-	pool = gpu_get_global_buffer_pool();
-
-	/* not sure if this buffer pool code has been profiled much,
-	 * seems to me that the graphics driver and system memory
-	 * management might do this stuff anyway. --nicholas
-	 */
-
-	/* check the global buffer pool for a recently-deleted buffer
-	 * that is at least as big as the request, but not more than
-	 * twice as big */
-	for (i = 0; i < pool->totbuf; i++) {
-		bufsize = pool->buffers[i]->size;
-
-		/* check for an exact size match */
-		if (bufsize == size) {
-			bestfit = i;
-			break;
-		}
-		/* smaller buffers won't fit data and buffers at least
-		 * twice as big are a waste of memory */
-		else if (bufsize > size && size > (bufsize / 2)) {
-			/* is it closer to the required size than the
-			 * last appropriate buffer found. try to save
-			 * memory */
-			if (bestfit == -1 || pool->buffers[bestfit]->size > bufsize) {
-				bestfit = i;
-			}
-		}
-	}
-
-	/* if an acceptable buffer was found in the pool, remove it
-	 * from the pool and return it */
-	if (bestfit != -1) {
-		buf = pool->buffers[bestfit];
-		gpu_buffer_pool_remove_index(pool, bestfit);
-		return buf;
-	}
-
-	/* no acceptable buffer found in the pool, create a new one */
-	buf = MEM_callocN(sizeof(GPUBuffer), "GPUBuffer");
-	buf->size = size;
-
-	if (useVBOs == 1) {
-		/* create a new VBO and initialize it to the requested
-		 * size */
-		gpu_glGenBuffers(1, &buf->id);
-		gpu_glBindBuffer(GL_ARRAY_BUFFER, buf->id);
-		gpu_glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_STATIC_DRAW);
-		gpu_glBindBuffer(GL_ARRAY_BUFFER, 0);
-	}
-	else {
-		buf->pointer = MEM_mallocN(size, "GPUBuffer.pointer");
-		
-		/* purpose of this seems to be dealing with
-		 * out-of-memory errors? looks a bit iffy to me
-		 * though, at least on Linux I expect malloc() would
-		 * just overcommit. --nicholas */
-		while (!buf->pointer && pool->totbuf > 0) {
-			gpu_buffer_pool_delete_last(pool);
-			buf->pointer = MEM_mallocN(size, "GPUBuffer.pointer");
-		}
-		if (!buf->pointer)
-			return NULL;
-	}
-
-	return buf;
-}
-
-/* Same as above, but safe for threading. */
-GPUBuffer *GPU_buffer_alloc(int size)
-{
-	GPUBuffer *buffer;
-
-	if (size == 0) {
-		/* Early out, no lock needed in this case. */
-		return NULL;
-	}
-
-	BLI_mutex_lock(&buffer_mutex);
-	buffer = gpu_buffer_alloc_intern(size);
-	BLI_mutex_unlock(&buffer_mutex);
-
-	return buffer;
-}
-
-/* release a GPUBuffer; does not free the actual buffer or its data,
- * but rather moves it to the pool of recently-freed buffers for
- * possible re-use
- *
- * Thread-unsafe version for internal usage only.
- */
-static void gpu_buffer_free_intern(GPUBuffer *buffer)
-{
-	GPUBufferPool *pool;
-	int i;
-
-	if (!buffer)
-		return;
-
-	pool = gpu_get_global_buffer_pool();
-
-	/* free the last used buffer in the queue if no more space, but only
-	 * if we are in the main thread. for e.g. rendering or baking it can
-	 * happen that we are in other thread and can't call OpenGL, in that
-	 * case cleanup will be done GPU_buffer_pool_free_unused */
-	if (BLI_thread_is_main()) {
-		/* in main thread, safe to decrease size of pool back
-		 * down to MAX_FREE_GPU_BUFFERS */
-		while (pool->totbuf >= MAX_FREE_GPU_BUFFERS)
-			gpu_buffer_pool_delete_last(pool);
-	}
-	else {
-		/* outside of main thread, can't safely delete the
-		 * buffer, so increase pool size */
-		if (pool->maxsize == pool->totbuf) {
-			pool->maxsize += MAX_FREE_GPU_BUFFERS;
-			pool->buffers = (GPUBuffer**)MEM_reallocN(pool->buffers, sizeof(GPUBuffer *) * pool->maxsize);
-		}
-	}
-
-	/

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list