[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28946] branches/soc-2010-moguri: The geometry shader input and output types are now settable.
Mitchell Stokes
mogurijin at gmail.com
Mon May 24 05:33:24 CEST 2010
Revision: 28946
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28946
Author: moguri
Date: 2010-05-24 05:33:13 +0200 (Mon, 24 May 2010)
Log Message:
-----------
The geometry shader input and output types are now settable.
Modified Paths:
--------------
branches/soc-2010-moguri/release/scripts/ui/properties_material.py
branches/soc-2010-moguri/source/blender/blenkernel/intern/material.c
branches/soc-2010-moguri/source/blender/blenloader/intern/readfile.c
branches/soc-2010-moguri/source/blender/gpu/GPU_extensions.h
branches/soc-2010-moguri/source/blender/gpu/intern/gpu_codegen.c
branches/soc-2010-moguri/source/blender/gpu/intern/gpu_codegen.h
branches/soc-2010-moguri/source/blender/gpu/intern/gpu_extensions.c
branches/soc-2010-moguri/source/blender/gpu/intern/gpu_material.c
branches/soc-2010-moguri/source/blender/makesdna/DNA_material_types.h
branches/soc-2010-moguri/source/blender/makesrna/intern/rna_material.c
Modified: branches/soc-2010-moguri/release/scripts/ui/properties_material.py
===================================================================
--- branches/soc-2010-moguri/release/scripts/ui/properties_material.py 2010-05-24 02:23:04 UTC (rev 28945)
+++ branches/soc-2010-moguri/release/scripts/ui/properties_material.py 2010-05-24 03:33:13 UTC (rev 28946)
@@ -801,6 +801,8 @@
col.prop(mat, "geometry_text")
col.prop(mat, "fragment_text")
+ col.prop(mat, "geometry_input")
+ col.prop(mat, "geometry_output")
class VolumeButtonsPanel(bpy.types.Panel):
bl_space_type = 'PROPERTIES'
Modified: branches/soc-2010-moguri/source/blender/blenkernel/intern/material.c
===================================================================
--- branches/soc-2010-moguri/source/blender/blenkernel/intern/material.c 2010-05-24 02:23:04 UTC (rev 28945)
+++ branches/soc-2010-moguri/source/blender/blenkernel/intern/material.c 2010-05-24 03:33:13 UTC (rev 28946)
@@ -193,6 +193,8 @@
ma->preview = NULL;
ma->csi.flag= 0;
+ ma->csi.geom_in= MA_CS_GEOM_IN_TRIS;
+ ma->csi.geom_out= MA_CS_GEOM_OUT_TRIANGLE_STRIP;
}
Material *add_material(char *name)
Modified: branches/soc-2010-moguri/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2010-moguri/source/blender/blenloader/intern/readfile.c 2010-05-24 02:23:04 UTC (rev 28945)
+++ branches/soc-2010-moguri/source/blender/blenloader/intern/readfile.c 2010-05-24 03:33:13 UTC (rev 28946)
@@ -10836,6 +10836,7 @@
if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 5)) {
bScreen *sc;
+ Material *mat;
/* Image editor scopes */
for(sc= main->screen.first; sc; sc= sc->id.next) {
@@ -10850,6 +10851,16 @@
}
}
}
+
+ /* geometry shader flags */
+ for(mat= main->mat.first; mat; mat= mat->id.next) {
+ if (mat->csi.geom_in == 0)
+ {
+ mat->csi.flag = 0;
+ mat->csi.geom_in = MA_CS_GEOM_IN_TRIS;
+ mat->csi.geom_out = MA_CS_GEOM_OUT_TRIANGLE_STRIP;
+ }
+ }
}
/* put 2.50 compatibility code here until next subversion bump */
Modified: branches/soc-2010-moguri/source/blender/gpu/GPU_extensions.h
===================================================================
--- branches/soc-2010-moguri/source/blender/gpu/GPU_extensions.h 2010-05-24 02:23:04 UTC (rev 28945)
+++ branches/soc-2010-moguri/source/blender/gpu/GPU_extensions.h 2010-05-24 03:33:13 UTC (rev 28946)
@@ -151,7 +151,7 @@
- only for fragment shaders now
- must call texture bind before setting a texture as uniform! */
-GPUShader *GPU_shader_create(const char *vertexcode, const char *fragcode, const char *geomcode, const char *libcode); /*GPUShader *lib);*/
+GPUShader *GPU_shader_create(const char *vertexcode, const char *fragcode, const char *geomcode, const char *libcode, short geomin, short geomout); /*GPUShader *lib);*/
/*GPUShader *GPU_shader_create_lib(const char *code);*/
void GPU_shader_free(GPUShader *shader);
Modified: branches/soc-2010-moguri/source/blender/gpu/intern/gpu_codegen.c
===================================================================
--- branches/soc-2010-moguri/source/blender/gpu/intern/gpu_codegen.c 2010-05-24 02:23:04 UTC (rev 28945)
+++ branches/soc-2010-moguri/source/blender/gpu/intern/gpu_codegen.c 2010-05-24 03:33:13 UTC (rev 28946)
@@ -1418,7 +1418,7 @@
return shader;
}
-GPUPass *GPU_generate_pass(ListBase *nodes, GPUNodeLink *outlink, GPUVertexAttribs *attribs, int *builtins, const char *name, char* vert, char* frag, char* geom)
+GPUPass *GPU_generate_pass(ListBase *nodes, GPUNodeLink *outlink, GPUVertexAttribs *attribs, int *builtins, const char *name, char* vert, char* frag, char* geom, short geomin, short geomout)
{
GPUShader *shader;
GPUPass *pass;
@@ -1454,7 +1454,7 @@
else
geometrycode = NULL;
- shader = GPU_shader_create(vertexcode, fragmentcode, geometrycode, libcode);
+ shader = GPU_shader_create(vertexcode, fragmentcode, geometrycode, libcode, geomin, geomout);
MEM_freeN(fragmentcode);
MEM_freeN(vertexcode);
if (geometrycode)
Modified: branches/soc-2010-moguri/source/blender/gpu/intern/gpu_codegen.h
===================================================================
--- branches/soc-2010-moguri/source/blender/gpu/intern/gpu_codegen.h 2010-05-24 02:23:04 UTC (rev 28945)
+++ branches/soc-2010-moguri/source/blender/gpu/intern/gpu_codegen.h 2010-05-24 03:33:13 UTC (rev 28946)
@@ -68,7 +68,7 @@
GPUPass *GPU_generate_pass(ListBase *nodes, struct GPUNodeLink *outlink,
struct GPUVertexAttribs *attribs, int *builtin, const char *name,
- char* vert, char* frag, char* geom);
+ char* vert, char* frag, char* geom, short geomin, short geomout);
struct GPUShader *GPU_pass_shader(GPUPass *pass);
Modified: branches/soc-2010-moguri/source/blender/gpu/intern/gpu_extensions.c
===================================================================
--- branches/soc-2010-moguri/source/blender/gpu/intern/gpu_extensions.c 2010-05-24 02:23:04 UTC (rev 28945)
+++ branches/soc-2010-moguri/source/blender/gpu/intern/gpu_extensions.c 2010-05-24 03:33:13 UTC (rev 28946)
@@ -35,6 +35,7 @@
#include "DNA_listBase.h"
#include "DNA_image_types.h"
#include "DNA_userdef_types.h"
+#include "DNA_material_types.h"
#include "MEM_guardedalloc.h"
@@ -915,10 +916,9 @@
fprintf(stderr, "%s\n", log);
}
-GPUShader *GPU_shader_create(const char *vertexcode, const char *fragcode, const char *geomcode, /*GPUShader *lib,*/ const char *libcode)
+GPUShader *GPU_shader_create(const char *vertexcode, const char *fragcode, const char *geomcode, /*GPUShader *lib,*/ const char *libcode, short geomin, short geomout)
{
GLint status;
- GLint temp;
GLcharARB log[5000];
const char *fragsource[2];
GLsizei length = 0;
@@ -989,15 +989,49 @@
}
if(geomcode && shader->geometry) {
+ GLint temp;
glAttachObjectARB(shader->object, shader->geometry);
glShaderSourceARB(shader->geometry, 1, (const char**)&geomcode, NULL);
glCompileShaderARB(shader->geometry);
glGetObjectParameterivARB(shader->geometry, GL_OBJECT_COMPILE_STATUS_ARB, &status);
- glProgramParameteriEXT(shader->object, GL_GEOMETRY_INPUT_TYPE_EXT, GL_TRIANGLES);
- glProgramParameteriEXT(shader->object, GL_GEOMETRY_OUTPUT_TYPE_EXT, GL_TRIANGLE_STRIP);
+ // Set the geometry intput type
+ if (geomin == MA_CS_GEOM_IN_POINTS)
+ temp = GL_POINTS;
+ else if (geomin == MA_CS_GEOM_IN_LINES)
+ temp = GL_LINES;
+ else if (geomin == MA_CS_GEOM_IN_LINES_ADJ)
+ temp = GL_LINES_ADJACENCY_EXT;
+ else if (geomin == MA_CS_GEOM_IN_TRIS)
+ temp = GL_TRIANGLES;
+ else if (geomin == MA_CS_GEOM_IN_TRIS_ADJ)
+ temp = GL_TRIANGLES_ADJACENCY_EXT;
+ else
+ {
+ // Fall back to triangles
+ printf("Unsupported type found for geometry shader input, falling back to GL_TRIANGLES\n");
+ temp = GL_TRIANGLES;
+ }
+ glProgramParameteriEXT(shader->object, GL_GEOMETRY_INPUT_TYPE_EXT, temp);
+
+ // Set the geometry output type
+ if (geomout == MA_CS_GEOM_OUT_POINTS)
+ temp = GL_POINTS;
+ else if (geomout == MA_CS_GEOM_OUT_LINE_STRIP)
+ temp = GL_LINE_STRIP;
+ else if (geomout == MA_CS_GEOM_OUT_TRIANGLE_STRIP)
+ temp = GL_TRIANGLE_STRIP;
+ else
+ {
+ // Fall back to triangle strip
+ printf("Unsupported type found for geometry shader output, falling back to GL_TRIANGLE_STRIP\n");
+ temp = GL_TRIANGLE_STRIP;
+ }
+
+ glProgramParameteriEXT(shader->object, GL_GEOMETRY_OUTPUT_TYPE_EXT, temp);
+
glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT, &temp);
glProgramParameteriEXT(shader->object, GL_GEOMETRY_VERTICES_OUT_EXT, temp);
Modified: branches/soc-2010-moguri/source/blender/gpu/intern/gpu_material.c
===================================================================
--- branches/soc-2010-moguri/source/blender/gpu/intern/gpu_material.c 2010-05-24 02:23:04 UTC (rev 28945)
+++ branches/soc-2010-moguri/source/blender/gpu/intern/gpu_material.c 2010-05-24 03:33:13 UTC (rev 28946)
@@ -277,7 +277,7 @@
outlink = material->outlink;
material->pass = GPU_generate_pass(&material->nodes, outlink,
&material->attribs, &material->builtins, material->ma->id.name,
- vert, frag, geom);
+ vert, frag, geom, material->ma->csi.geom_in, material->ma->csi.geom_out);
if(!material->pass)
return 0;
Modified: branches/soc-2010-moguri/source/blender/makesdna/DNA_material_types.h
===================================================================
--- branches/soc-2010-moguri/source/blender/makesdna/DNA_material_types.h 2010-05-24 02:23:04 UTC (rev 28945)
+++ branches/soc-2010-moguri/source/blender/makesdna/DNA_material_types.h 2010-05-24 03:33:13 UTC (rev 28946)
@@ -81,7 +81,7 @@
struct Text *frag_text;
struct Text *geom_text;
- short flag, pad[3];
+ short flag, geom_in, geom_out, pad;
} CustomShaderInfo;
typedef struct Material {
@@ -202,10 +202,22 @@
#define MA_DS_SHOW_TEXS 4
/* for custom shaders */
-/* cs_flag */
+/* csi.flag */
/* use external files instead of Text datablocks */
-#define MA_CS_USE_EXTERNAL 1
+#define MA_CS_USE_EXTERNAL 1
+/* csi.geom_in */
+#define MA_CS_GEOM_IN_POINTS 1
+#define MA_CS_GEOM_IN_LINES 2
+#define MA_CS_GEOM_IN_LINES_ADJ 4
+#define MA_CS_GEOM_IN_TRIS 32
+#define MA_CS_GEOM_IN_TRIS_ADJ 64
+
+/* csi.geom_out */
+#define MA_CS_GEOM_OUT_POINTS 1
+#define MA_CS_GEOM_OUT_LINE_STRIP 2
+#define MA_CS_GEOM_OUT_TRIANGLE_STRIP 4
+
/* mode (is int) */
#define MA_TRACEBLE 1
#define MA_SHADOW 2
Modified: branches/soc-2010-moguri/source/blender/makesrna/intern/rna_material.c
===================================================================
--- branches/soc-2010-moguri/source/blender/makesrna/intern/rna_material.c 2010-05-24 02:23:04 UTC (rev 28945)
+++ branches/soc-2010-moguri/source/blender/makesrna/intern/rna_material.c 2010-05-24 03:33:13 UTC (rev 28946)
@@ -812,8 +812,20 @@
{
PropertyRNA *prop;
- //RNA_def_struct_sdna_from(srna, "CustomShaderInfo", "csi");
+ static EnumPropertyItem prop_geomin_items[] = {
+ {MA_CS_GEOM_IN_POINTS, "POINTS", 0, "Points", "Use points as input"},
+ {MA_CS_GEOM_IN_LINES, "LINES", 0, "Lines", "Use lines as input"},
+ {MA_CS_GEOM_IN_LINES_ADJ, "LINES_ADJ", 0, "Lines Adjacency", "Use adjacent lines as input"},
+ {MA_CS_GEOM_IN_TRIS, "TRIS", 0, "Triangles", "Use triangles as input"},
+ {MA_CS_GEOM_IN_TRIS_ADJ, "TRIS_ADJ", 0, "Triangles Adjacency", "Use adjacent triangles as input"},
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list