[Bf-blender-cvs] [c56cf0b] viewport_experiments: WIP, beginning of renderer system that should take care of sorting materials properly for rendering.

Antony Riakiotakis noreply at git.blender.org
Tue Sep 16 19:24:41 CEST 2014


Commit: c56cf0b8873b655c09ab766afeb4e2b034dda3d5
Author: Antony Riakiotakis
Date:   Tue Sep 16 19:07:56 2014 +0200
Branches: viewport_experiments
https://developer.blender.org/rBc56cf0b8873b655c09ab766afeb4e2b034dda3d5

WIP, beginning of renderer system that should take care of sorting
materials properly for rendering.

-Need to check aspect system first before going too much into this-

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

M	source/blender/blenloader/intern/readfile.c
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/gpu/CMakeLists.txt
A	source/blender/gpu/GPU_renderer.h
A	source/blender/gpu/intern/gpu_renderer.c
M	source/blender/makesdna/DNA_view3d_types.h

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

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 5397bb1..3a77b29 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6388,6 +6388,7 @@ static bool direct_link_screen(FileData *fd, bScreen *sc)
 				}
 				v3d->localvd = newdataadr(fd, v3d->localvd);
 				BLI_listbase_clear(&v3d->afterdraw_transp);
+				BLI_listbase_clear(&v3d->gpu_material);
 				BLI_listbase_clear(&v3d->afterdraw_xray);
 				BLI_listbase_clear(&v3d->afterdraw_xraytransp);
 				v3d->properties_storage = NULL;
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 3b0caf5..fe18c8d 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -95,6 +95,7 @@
 #include "GPU_material.h"
 #include "GPU_extensions.h"
 #include "GPU_compositing.h"
+#include "GPU_renderer.h"
 
 #include "view3d_intern.h"  /* own include */
 
@@ -2736,6 +2737,9 @@ static void view3d_draw_objects(
 		if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
 	}
 
+	/* draw sorted materials in the gpu renderer */
+	if (v3d->gpu_material.first)         GPU_renderer_material_draw(&v3d->gpu_material);
+	
 	/* transp and X-ray afterdraw stuff */
 	if (v3d->afterdraw_transp.first)     view3d_draw_transp(scene, ar, v3d);
 	if (v3d->afterdraw_xray.first)       view3d_draw_xray(scene, ar, v3d, true);
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index 91b176e..c1691f6 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -53,6 +53,7 @@ set(SRC
 	intern/gpu_simple_shader.c
 	intern/gpu_select.c
 	intern/gpu_compositing.c
+	intern/gpu_renderer.c
 
 	GPU_buffers.h
 	GPU_draw.h
@@ -61,6 +62,7 @@ set(SRC
 	GPU_simple_shader.h
 	GPU_select.h
 	GPU_compositing.h
+        GPU_renderer.h
 	intern/gpu_codegen.h
 )
 
diff --git a/source/blender/gpu/GPU_renderer.h b/source/blender/gpu/GPU_renderer.h
new file mode 100644
index 0000000..7ebc864
--- /dev/null
+++ b/source/blender/gpu/GPU_renderer.h
@@ -0,0 +1,58 @@
+/*
+ * ***** 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) 2014 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Antony Riakiotakis.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __GPU_RENDERER_H__
+#define __GPU_RENDERER_H__
+
+#include "DNA_listBase.h"
+
+struct Object;
+
+/* batches per material sorted by some criterion, ie texture image changes */
+typedef struct SubBatch {
+	int start;
+	int len;
+	void *data; /* extra data relevant to the subbatch, such as image */
+} SubBatch;
+
+
+/* stores data related to the object that can be used for rendering */
+typedef struct MaterialBatch {
+	int start;
+	int len;
+	ListBase subbatches;
+	struct Object *ob;
+	void *data;
+} MaterialBatch;
+
+
+/* new type of material */
+typedef struct GPUMaterialX {
+	int datarequest; /* type of data requested from objects */
+} GPUMaterialX;
+
+void GPU_renderer_material_draw(struct ListBase *materials);
+
+#endif // __GPU_RENDERER_H__
diff --git a/source/blender/gpu/intern/gpu_renderer.c b/source/blender/gpu/intern/gpu_renderer.c
new file mode 100644
index 0000000..f4c0b8d
--- /dev/null
+++ b/source/blender/gpu/intern/gpu_renderer.c
@@ -0,0 +1,36 @@
+/*
+ * ***** 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) 2006 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Antony Riakiotakis.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+
+#include "GPU_renderer.h"
+
+
+/* iterates through all added materials, prepares data if needed and draws their meshes */
+void GPU_renderer_material_draw(struct ListBase *materials)
+{
+	
+}
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 23dbcdc..91a51fb 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -211,6 +211,9 @@ typedef struct View3D {
 	struct ListBase afterdraw_transp;
 	struct ListBase afterdraw_xray;
 	struct ListBase afterdraw_xraytransp;
+
+	/* list of gpu materials to draw */
+	struct ListBase gpu_material;
 	
 	/* drawflags, denoting state */
 	char zbuf, transp, xray;




More information about the Bf-blender-cvs mailing list