Browse Source

Add GL_EXT_control_flow_attributes support

Panagiotis Christopoulos Charitos 7 năm trước cách đây
mục cha
commit
13bb9b5f8c
3 tập tin đã thay đổi với 14 bổ sung4 xóa
  1. 2 3
      programs/Reflections.ankiprog
  2. 11 0
      src/anki/gr/ShaderCompiler.cpp
  3. 1 1
      thirdparty

+ 2 - 3
programs/Reflections.ankiprog

@@ -121,8 +121,7 @@ vec4 doSslr(vec3 r, vec3 n, vec3 viewPos, vec2 uv, float depth, float roughness)
 	// Iterate
 	bool found = false;
 	vec3 raySample;
-	uint iterations = 0u;
-	for(; iterations < MAX_STEPS; ++iterations)
+	ANKI_LOOP for(uint iterations = 0u; iterations < MAX_STEPS; ++iterations)
 	{
 		raySample = start + ray * (float(step) * stepSize);
 
@@ -177,7 +176,7 @@ void readReflectionsAndIrradianceFromProbes(
 
 	// Check proxy
 	uint count = u_lightIndices[idxOffset++];
-	while(count-- != 0)
+	ANKI_LOOP while(count-- != 0)
 	{
 		ReflectionProbe probe = u_reflectionProbes[u_lightIndices[idxOffset++]];
 

+ 11 - 0
src/anki/gr/ShaderCompiler.cpp

@@ -41,6 +41,11 @@ static const char* SHADER_HEADER = R"(#version 450 core
 #	define ANKI_IMAGE_BINDING(set_, binding_) binding = (set_) * (%u) + (binding_)
 #	define ANKI_SPEC_CONST(binding_, type_, name_) const type_ name_ = _anki_spec_const_ ## binding_
 #	define ANKI_PUSH_CONSTANTS(struct_, name_) layout(location = (%u)) uniform struct_ name_
+
+#	define ANKI_UNROLL
+#	define ANKI_LOOP
+#	define ANKI_BRANCH
+#	define ANKI_FLATTEN
 #else
 #	define gl_VertexID gl_VertexIndex
 #	define gl_InstanceID gl_InstanceIndex
@@ -51,6 +56,12 @@ static const char* SHADER_HEADER = R"(#version 450 core
 #	define ANKI_SPEC_CONST(binding_, type_, name_) layout(constant_id = (binding_)) const type_ name_ = type_(0)
 #	define ANKI_PUSH_CONSTANTS(struct_, name_) layout(push_constant, row_major, std140) \
 		uniform pushConst_ {struct_ name_;}
+
+#	extension GL_EXT_control_flow_attributes : require
+#	define ANKI_UNROLL [[unroll]]
+#	define ANKI_LOOP [[dont_unroll]]
+#	define ANKI_BRANCH [[branch]]
+#	define ANKI_FLATTEN [[flatten]]
 #endif
 
 #if %u

+ 1 - 1
thirdparty

@@ -1 +1 @@
-Subproject commit 2e44ed9366a0f030bf8d9c168f83faaf259a222b
+Subproject commit 940c8fa270cd31574e79cf755dcf202855509a6e