Added MOJOSHADER_maxShaderModel().
authorRyan C. Gordon <icculus@icculus.org>
Fri, 07 Nov 2008 20:48:47 -0500
changeset 458 b91904879798
parent 457 96552d8041bf
child 459 6a2e259c132e
Added MOJOSHADER_maxShaderModel().
availableprofiles.c
mojoshader.c
mojoshader.h
--- a/availableprofiles.c	Fri Nov 07 19:32:24 2008 -0500
+++ b/availableprofiles.c	Fri Nov 07 20:48:47 2008 -0500
@@ -27,7 +27,10 @@
     {
         int i;
         for (i = 0; i < total; i++)
-            printf("%s\n", avail[i]);
+        {
+            printf("%s (Shader Model %d)\n", avail[i],
+                   MOJOSHADER_maxShaderModel(avail[i]));
+        } // for
     } // else
 
     return 0;
--- a/mojoshader.c	Fri Nov 07 19:32:24 2008 -0500
+++ b/mojoshader.c	Fri Nov 07 20:48:47 2008 -0500
@@ -7708,5 +7708,21 @@
     return MOJOSHADER_CHANGESET;
 } // MOJOSHADER_changeset
 
+
+int MOJOSHADER_maxShaderModel(const char *profile)
+{
+    #define PROFILE_SHADER_MODEL(p,v) if (strcmp(profile, p) == 0) return v;
+    PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_D3D, 3);
+    PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_PASSTHROUGH, 3);
+    PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_GLSL, 3);
+    PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_GLSL120, 3);
+    PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_ARB1, 2);
+    PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_NV2, 2);
+    PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_NV3, 2);
+    PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_NV4, 3);
+    #undef PROFILE_SHADER_MODEL
+    return -1;  // unknown profile?
+} // MOJOSHADER_maxShaderModel
+
 // end of mojoshader.c ...
 
--- a/mojoshader.h	Fri Nov 07 19:32:24 2008 -0500
+++ b/mojoshader.h	Fri Nov 07 20:48:47 2008 -0500
@@ -417,6 +417,11 @@
  */
 #define MOJOSHADER_PROFILE_NV4 "nv4"
 
+/*
+ * Determine the highest supported Shader Model for a profile.
+ */
+int MOJOSHADER_maxShaderModel(const char *profile);
+
 
 /*
  * Parse a compiled Direct3D shader's bytecode.