Przeglądaj źródła

Move Bloom to the new format

Panagiotis Christopoulos Charitos 5 lat temu
rodzic
commit
14f0b8a04f

+ 2 - 2
shaders/Bloom.glslp → shaders/Bloom.ankiprog

@@ -3,8 +3,8 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
-#pragma anki input const UVec2 FB_SIZE
-#pragma anki input const UVec2 WORKGROUP_SIZE
+ANKI_SPECIALIZATION_CONSTANT_IVEC2(FB_SIZE, 0, IVec2(1));
+const UVec2 WORKGROUP_SIZE = UVec2(16, 16);
 
 #pragma anki start comp
 #include <shaders/Common.glsl>

+ 8 - 6
src/anki/renderer/Bloom.cpp

@@ -36,15 +36,17 @@ Error Bloom::initExposure(const ConfigSet& config)
 	m_exposure.m_rtDescr.bake();
 
 	// init shaders
-	ANKI_CHECK(getResourceManager().loadResource("shaders/Bloom.glslp", m_exposure.m_prog));
+	ANKI_CHECK(getResourceManager().loadResource("shaders/Bloom.ankiprog", m_exposure.m_prog));
 
-	ShaderProgramResourceConstantValueInitList<2> consts(m_exposure.m_prog);
-	consts.add("FB_SIZE", UVec2(m_exposure.m_width, m_exposure.m_height))
-		.add("WORKGROUP_SIZE", UVec2(m_workgroupSize[0], m_workgroupSize[1]));
+	ShaderProgramResourceVariantInitInfo2 variantInitInfo(m_exposure.m_prog);
+	variantInitInfo.addConstant("FB_SIZE", IVec2(m_exposure.m_width, m_exposure.m_height));
 
-	const ShaderProgramResourceVariant* variant;
-	m_exposure.m_prog->getOrCreateVariant(consts.get(), variant);
+	const ShaderProgramResourceVariant2* variant;
+	m_exposure.m_prog->getOrCreateVariant(variantInitInfo, variant);
 	m_exposure.m_grProg = variant->getProgram();
+	ANKI_ASSERT(variant->getWorkgroupSizes()[0] == m_workgroupSize[0]
+				&& variant->getWorkgroupSizes()[1] == m_workgroupSize[1]
+				&& variant->getWorkgroupSizes()[2] == m_workgroupSize[2]);
 
 	return Error::NONE;
 }

+ 1 - 1
src/anki/renderer/Bloom.h

@@ -50,7 +50,7 @@ private:
 	class
 	{
 	public:
-		ShaderProgramResourcePtr m_prog;
+		ShaderProgramResource2Ptr m_prog;
 		ShaderProgramPtr m_grProg;
 
 		F32 m_threshold = 10.0; ///< How bright it is

+ 1 - 0
src/anki/renderer/RendererObject.h

@@ -10,6 +10,7 @@
 #include <anki/Gr.h>
 #include <anki/resource/ResourceManager.h>
 #include <anki/resource/ShaderProgramResource.h>
+#include <anki/resource/ShaderProgramResource2.h>
 #include <anki/core/StagingGpuMemoryManager.h>
 
 namespace anki

+ 2 - 2
src/anki/resource/ShaderProgramResource2.cpp

@@ -169,11 +169,11 @@ Error ShaderProgramResource2::parseConst(CString constName, U32& componentIdx, U
 	}
 
 	Array<char, 2> number;
-	number[0] = constName[prefixName.getLength() + 1];
+	number[0] = constName[prefixName.getLength()];
 	number[1] = '\0';
 	ANKI_CHECK(CString(number.getBegin()).toNumber(componentIdx));
 
-	number[0] = constName[prefixName.getLength() + 3];
+	number[0] = constName[prefixName.getLength() + 2];
 	ANKI_CHECK(CString(number.getBegin()).toNumber(componentCount));
 
 	name = constName.getBegin() + prefixName.getLength() + 4;

+ 2 - 2
src/anki/shader_compiler/ShaderProgramCompiler.cpp

@@ -297,7 +297,7 @@ public:
 			}
 			else
 			{
-				m_workgroupSizes[i] = x;
+				m_workgroupSizes[i] = input[i];
 			}
 		}
 
@@ -1071,7 +1071,7 @@ void dumpShaderProgramBinary(const ShaderProgramBinary& binary, StringAuto& huma
 		}
 		else
 		{
-			lines.pushBack("N/A");
+			lines.pushBack("N/A)");
 		}
 
 		lines.pushBack("\n");

+ 9 - 9
src/anki/shader_compiler/ShaderProgramParser.cpp

@@ -76,8 +76,8 @@ static const char* SHADER_HEADER = R"(#version 450 core
 #define ANKI_SPECIALIZATION_CONSTANT_X2(type, componentType, n, id, defltVal) \
 	layout(constant_id = id + 0) const componentType ANKI_CONCATENATE(_anki_const_0_2_, n) = defltVal[0]; \
 	layout(constant_id = id + 1) const componentType ANKI_CONCATENATE(_anki_const_1_2_, n) = defltVal[1]; \
-	const componentType ANKI_CONCATENATE(n, _X) = ANKI_CONCATENATE(_anki_const_0_2_, n); \
-	const componentType ANKI_CONCATENATE(n, _Y) = ANKI_CONCATENATE(_anki_const_1_2_, n); \
+	const componentType ANKI_CONCATENATE(n, _X) = ANKI_CONCATENATE(_anki_const_0_2_, n) + componentType(0); \
+	const componentType ANKI_CONCATENATE(n, _Y) = ANKI_CONCATENATE(_anki_const_1_2_, n) + componentType(0); \
 	const type n = type(ANKI_CONCATENATE(n, _X), ANKI_CONCATENATE(n, _Y)); \
 	const UVec2 ANKI_CONCATENATE(n, _CONST_ID) = UVec2(id, id + 1)
 
@@ -85,9 +85,9 @@ static const char* SHADER_HEADER = R"(#version 450 core
 	layout(constant_id = id + 0) const componentType ANKI_CONCATENATE(_anki_const_0_3_, n) = defltVal[0]; \
 	layout(constant_id = id + 1) const componentType ANKI_CONCATENATE(_anki_const_1_3_, n) = defltVal[1]; \
 	layout(constant_id = id + 2) const componentType ANKI_CONCATENATE(_anki_const_2_3_, n) = defltVal[2]; \
-	const componentType ANKI_CONCATENATE(n, _X) = ANKI_CONCATENATE(_anki_const_0_3_, n); \
-	const componentType ANKI_CONCATENATE(n, _Y) = ANKI_CONCATENATE(_anki_const_1_3_, n); \
-	const componentType ANKI_CONCATENATE(n, _Z) = ANKI_CONCATENATE(_anki_const_2_3_, n); \
+	const componentType ANKI_CONCATENATE(n, _X) = ANKI_CONCATENATE(_anki_const_0_3_, n) + componentType(0); \
+	const componentType ANKI_CONCATENATE(n, _Y) = ANKI_CONCATENATE(_anki_const_1_3_, n) + componentType(0); \
+	const componentType ANKI_CONCATENATE(n, _Z) = ANKI_CONCATENATE(_anki_const_2_3_, n) + componentType(0); \
 	const type n = type(ANKI_CONCATENATE(n, _X), ANKI_CONCATENATE(n, _Y), ANKI_CONCATENATE(n, _Z)); \
 	const UVec3 ANKI_CONCATENATE(n, _CONST_ID) = UVec3(id, id + 1, id + 2)
 
@@ -96,10 +96,10 @@ static const char* SHADER_HEADER = R"(#version 450 core
 	layout(constant_id = id + 1) const componentType ANKI_CONCATENATE(_anki_const_1_4_, n) = defltVal[1]; \
 	layout(constant_id = id + 2) const componentType ANKI_CONCATENATE(_anki_const_2_4_, n) = defltVal[2]; \
 	layout(constant_id = id + 3) const componentType ANKI_CONCATENATE(_anki_const_3_4_, n) = defltVal[3]; \
-	const componentType ANKI_CONCATENATE(n, _X) = ANKI_CONCATENATE(_anki_const_0_4_, n); \
-	const componentType ANKI_CONCATENATE(n, _Y) = ANKI_CONCATENATE(_anki_const_1_4_, n); \
-	const componentType ANKI_CONCATENATE(n, _Z) = ANKI_CONCATENATE(_anki_const_2_4_, n); \
-	const componentType ANKI_CONCATENATE(n, _W) = ANKI_CONCATENATE(_anki_const_3_4_, n); \
+	const componentType ANKI_CONCATENATE(n, _X) = ANKI_CONCATENATE(_anki_const_0_4_, n) + componentType(0); \
+	const componentType ANKI_CONCATENATE(n, _Y) = ANKI_CONCATENATE(_anki_const_1_4_, n) + componentType(0); \
+	const componentType ANKI_CONCATENATE(n, _Z) = ANKI_CONCATENATE(_anki_const_2_4_, n) + componentType(0); \
+	const componentType ANKI_CONCATENATE(n, _W) = ANKI_CONCATENATE(_anki_const_3_4_, n) + componentType(0); \
 	const type n = type(ANKI_CONCATENATE(n, _X), ANKI_CONCATENATE(n, _Y), ANKI_CONCATENATE(n, _Z), \
 		ANKI_CONCATENATE(n, _W)); \
 	const UVec4 ANKI_CONCATENATE(n, _CONST_ID) = UVec4(id, id + 1, id + 2, id + 3)