Explorar el Código

Small improvement in the previous commit

Panagiotis Christopoulos Charitos hace 9 años
padre
commit
9113263313
Se han modificado 5 ficheros con 23 adiciones y 14 borrados
  1. 13 5
      shaders/Common.glsl
  2. 4 5
      shaders/Is.frag.glsl
  3. 1 1
      src/gr/gl/ShaderImpl.cpp
  4. 1 1
      src/gr/vulkan/ShaderImpl.cpp
  5. 4 2
      src/misc/ConfigSet.cpp

+ 13 - 5
shaders/Common.glsl

@@ -31,11 +31,19 @@ const uint UBO_MAX_SIZE = 16384;
 //#define textureRt(tex_, texc_) texture(tex_, texc_)
 #define textureRt(tex_, texc_) textureLod(tex_, texc_, 0.0)
 
-// Binding
-#define UBO_BINDING(slot_, binding_) binding = slot_ * 4 + binding_
-#define SS_BINDING(slot_, binding_) binding = slot_ * 4 + binding_
-#define TEX_BINDING(slot_, binding_) binding = slot_ * 10 + binding_
-#define ATOMIC_BINDING(slot_, binding_) binding = slot_ * 1 + binding_
+// Binding macros
+#if defined(ANKI_GL)
+#define UBO_BINDING(set_, binding_) binding = set_ * 4 + binding_
+#define SS_BINDING(set_, binding_) binding = set_ * 4 + binding_
+#define TEX_BINDING(set_, binding_) binding = set_ * 10 + binding_
+#define ATOMIC_BINDING(set_, binding_) binding = set_ * 1 + binding_
+#elif defined(ANKI_VK)
+#define UBO_BINDING(set_, binding_) set = set_, binding = binding_
+#define SS_BINDING(set_, binding_) set = set_, binding = binding_
+#define TEX_BINDING(set_, binding_) set = set_, binding = binding_
+#else
+#error Missing define
+#endif
 
 // Common locations
 #define POSITION_LOCATION 0

+ 4 - 5
shaders/Is.frag.glsl

@@ -17,10 +17,10 @@
 #undef LIGHT_TEX_BINDING
 #undef LIGHT_UBO_BINDING
 
-layout(binding = 0) uniform sampler2D u_msRt0;
-layout(binding = 1) uniform sampler2D u_msRt1;
-layout(binding = 2) uniform sampler2D u_msRt2;
-layout(binding = 3) uniform sampler2D u_msDepthRt;
+layout(TEX_BINDING(0, 0)) uniform sampler2D u_msRt0;
+layout(TEX_BINDING(0, 1)) uniform sampler2D u_msRt1;
+layout(TEX_BINDING(0, 2)) uniform sampler2D u_msRt2;
+layout(TEX_BINDING(0, 3)) uniform sampler2D u_msDepthRt;
 
 layout(location = 0) in vec2 in_texCoord;
 layout(location = 1) flat in int in_instanceId;
@@ -197,7 +197,6 @@ void main()
 	out_color += specIndirect + diffIndirect;
 #endif
 
-// out_color = diffCol;
 #if 0 && INDIRECT_ENABLED
 	uint count = probeCount;
 	if(count == 0)

+ 1 - 1
src/gr/gl/ShaderImpl.cpp

@@ -81,7 +81,7 @@ Error ShaderImpl::init(ShaderType type, const CString& source)
 	static const char* versionType = "es";
 #endif
 
-	fullSrc.sprintf("#version %d %s\n#define %s\n%s\n",
+	fullSrc.sprintf("#version %d %s\n#define ANKI_GL\n#define %s\n%s\n",
 		version,
 		versionType,
 		shaderName[U(type)],

+ 1 - 1
src/gr/vulkan/ShaderImpl.cpp

@@ -204,7 +204,7 @@ Error ShaderImpl::init(ShaderType shaderType, const CString& source)
 		"FRAGMENT_SHADER",
 		"COMPUTE_SHADER"}};
 
-	fullSrc.sprintf("#version 450 core\n#define %s\n%s\n",
+	fullSrc.sprintf("#version 450 core\n#define ANKI_VK\n#define %s\n%s\n",
 		shaderName[shaderType],
 		&source[0]);
 

+ 4 - 2
src/misc/ConfigSet.cpp

@@ -245,7 +245,8 @@ Error ConfigSet::setFromCommandLineArguments(
 			}
 
 			// Get the option
-			arg = cmdLineArgs[i + 1];
+			++i;
+			arg = cmdLineArgs[i];
 			ANKI_ASSERT(arg);
 			Option* option = tryFind(arg);
 			if(option == nullptr)
@@ -255,7 +256,8 @@ Error ConfigSet::setFromCommandLineArguments(
 			}
 
 			// Set the value
-			arg = cmdLineArgs[i + 2];
+			++i;
+			arg = cmdLineArgs[i];
 			ANKI_ASSERT(arg);
 			if(option->m_type == 0)
 			{