Browse Source

Minor changes to the compiler

Panagiotis Christopoulos Charitos 3 years ago
parent
commit
a2dfa0158b

+ 2 - 0
AnKi/Gr/Common.h

@@ -43,6 +43,8 @@ constexpr U32 MAX_DESCRIPTOR_SETS = 2; ///< Groups that can be bound at the same
 constexpr U32 MAX_BINDINGS_PER_DESCRIPTOR_SET = 32;
 constexpr U32 MAX_FRAMES_IN_FLIGHT = 3; ///< Triple buffering.
 constexpr U32 MAX_GR_OBJECT_NAME_LENGTH = 31;
+constexpr U32 MAX_BINDLESS_TEXTURES = 512;
+constexpr U32 MAX_BINDLESS_IMAGES = 64;
 
 /// The number of commands in a command buffer that make it a small batch command buffer.
 constexpr U32 COMMAND_BUFFER_SMALL_BATCH_MAX_COMMANDS = 100;

+ 0 - 2
AnKi/Gr/ConfigVars.defs.h

@@ -10,8 +10,6 @@ ANKI_CONFIG_VAR_BOOL(GrDebugPrintf, false, "Enable or not debug printf")
 ANKI_CONFIG_VAR_BOOL(GrDebugMarkers, false, "Enable or not debug markers")
 ANKI_CONFIG_VAR_BOOL(GrVsync, false, "Enable or not vsync")
 
-ANKI_CONFIG_VAR_U32(GrMaxBindlessTextures, 256, 8, 1024, "Max number of bindless textures")
-ANKI_CONFIG_VAR_U32(GrMaxBindlessImages, 32, 8, 1024, "Max number of bindless images")
 ANKI_CONFIG_VAR_PTR_SIZE(GrDiskShaderCacheMaxSize, 128_MB, 1_MB, 1_GB, "Max size of the pipeline cache file")
 
 ANKI_CONFIG_VAR_BOOL(GrRayTracing, false, "Try enabling ray tracing")

+ 1 - 2
AnKi/Gr/Vulkan/GrManagerImpl.cpp

@@ -188,8 +188,7 @@ Error GrManagerImpl::initInternal(const GrManagerInitInfo& init)
 		}
 	}
 
-	ANKI_CHECK(m_descrFactory.init(getAllocator(), m_device, m_config->getGrMaxBindlessTextures(),
-								   m_config->getGrMaxBindlessImages()));
+	ANKI_CHECK(m_descrFactory.init(getAllocator(), m_device, MAX_BINDLESS_TEXTURES, MAX_BINDLESS_IMAGES));
 	m_pplineLayoutFactory.init(getAllocator(), m_device);
 
 	return Error::NONE;

+ 0 - 1
AnKi/Renderer/LightShading.cpp

@@ -68,7 +68,6 @@ Error LightShading::initLightShading()
 	variantInitInfo.addConstant("TILE_COUNTS", m_r->getTileCounts());
 	variantInitInfo.addConstant("Z_SPLIT_COUNT", m_r->getZSplitCount());
 	variantInitInfo.addConstant("TILE_SIZE", m_r->getTileSize());
-	variantInitInfo.addConstant("IR_MIPMAP_COUNT", U32(m_r->getProbeReflections().getReflectionTextureMipmapCount()));
 	const ShaderProgramResourceVariant* variant;
 
 	variantInitInfo.addMutation("USE_SHADOW_LAYERS", 0);

+ 1 - 2
AnKi/Resource/ShaderProgramResourceSystem.cpp

@@ -67,9 +67,8 @@ Error ShaderProgramResourceSystem::compileAllShaders(CString cacheDir, GrManager
 
 	// Compute hash for both
 	ShaderCompilerOptions compilerOptions;
-	compilerOptions.m_bindlessLimits.m_bindlessTextureCount = gr.getConfig().getGrMaxBindlessTextures();
-	compilerOptions.m_bindlessLimits.m_bindlessImageCount = gr.getConfig().getGrMaxBindlessImages();
 	compilerOptions.m_forceFullFloatingPointPrecision = gr.getConfig().getRsrcForceFullFpPrecision();
+	compilerOptions.m_mobilePlatform = ANKI_PLATFORM_MOBILE;
 	U64 gpuHash = computeHash(&compilerOptions, sizeof(compilerOptions));
 	gpuHash = appendHash(&SHADER_BINARY_VERSION, sizeof(SHADER_BINARY_VERSION), gpuHash);
 

+ 1 - 11
AnKi/ShaderCompiler/Common.h

@@ -47,23 +47,13 @@ public:
 	virtual ANKI_USE_RESULT Error joinTasks() = 0;
 };
 
-/// Bindless related info.
-ANKI_BEGIN_PACKED_STRUCT
-class BindlessLimits
-{
-public:
-	U32 m_bindlessTextureCount = 0;
-	U32 m_bindlessImageCount = 0;
-};
-ANKI_END_PACKED_STRUCT
-
 /// Options to be passed to the compiler.
 ANKI_BEGIN_PACKED_STRUCT
 class ShaderCompilerOptions
 {
 public:
-	BindlessLimits m_bindlessLimits;
 	Bool m_forceFullFloatingPointPrecision = false;
+	Bool m_mobilePlatform = false;
 };
 ANKI_END_PACKED_STRUCT
 /// @}

+ 2 - 4
AnKi/ShaderCompiler/ShaderProgramParser.cpp

@@ -981,10 +981,8 @@ Error ShaderProgramParser::parse()
 void ShaderProgramParser::generateAnkiShaderHeader(ShaderType shaderType, const ShaderCompilerOptions& compilerOptions,
 												   StringAuto& header)
 {
-	header.sprintf(SHADER_HEADER, SHADER_STAGE_NAMES[shaderType].cstr(), ANKI_PLATFORM_MOBILE,
-				   compilerOptions.m_forceFullFloatingPointPrecision,
-				   compilerOptions.m_bindlessLimits.m_bindlessTextureCount,
-				   compilerOptions.m_bindlessLimits.m_bindlessImageCount);
+	header.sprintf(SHADER_HEADER, SHADER_STAGE_NAMES[shaderType].cstr(), compilerOptions.m_mobilePlatform,
+				   compilerOptions.m_forceFullFloatingPointPrecision, MAX_BINDLESS_TEXTURES, MAX_BINDLESS_IMAGES);
 }
 
 Error ShaderProgramParser::generateVariant(ConstWeakArray<MutatorValue> mutation,

+ 0 - 2
Tests/Gr/Gr.cpp

@@ -332,8 +332,6 @@ static ShaderPtr createShader(CString src, ShaderType type, GrManager& gr,
 	HeapAllocator<U8> alloc(allocAligned, nullptr);
 	StringAuto header(alloc);
 	ShaderCompilerOptions compilerOptions;
-	compilerOptions.m_bindlessLimits.m_bindlessTextureCount = gr.getConfig().getGrMaxBindlessTextures();
-	compilerOptions.m_bindlessLimits.m_bindlessImageCount = gr.getConfig().getGrMaxBindlessImages();
 	ShaderProgramParser::generateAnkiShaderHeader(type, compilerOptions, header);
 	header.append(src);
 	DynamicArrayAuto<U8> spirv(alloc);

+ 18 - 6
Tools/Shader/ShaderProgramCompilerMain.cpp

@@ -9,19 +9,23 @@ using namespace anki;
 
 static const char* USAGE = R"(Usage: %s input_shader_program_file [options]
 Options:
--o <name of output>    : The name of the output binary
--j <thread count>      : Number of threads. Defaults to system's max
--I <include path>      : The path of the #include files
+-o <name of output>  : The name of the output binary
+-j <thread count>    : Number of threads. Defaults to system's max
+-I <include path>    : The path of the #include files
+-force-full-fp       : Force full floating point precision
+-mobile-platform     : Build for mobile
 )";
 
 class CmdLineArgs
 {
 public:
-	HeapAllocator<U8> m_alloc{allocAligned, nullptr};
+	HeapAllocator<U8> m_alloc = {allocAligned, nullptr};
 	StringAuto m_inputFname = {m_alloc};
 	StringAuto m_outFname = {m_alloc};
 	StringAuto m_includePath = {m_alloc};
 	U32 m_threadCount = getCpuCoresCount();
+	Bool m_fullFpPrecision = false;
+	Bool m_mobilePlatform = false;
 };
 
 static Error parseCommandLineArgs(int argc, char** argv, CmdLineArgs& info)
@@ -89,6 +93,14 @@ static Error parseCommandLineArgs(int argc, char** argv, CmdLineArgs& info)
 				return Error::USER_DATA;
 			}
 		}
+		else if(strcmp(argv[i], "-force-full-fp") == 0)
+		{
+			info.m_fullFpPrecision = true;
+		}
+		else if(strcmp(argv[i], "-mobile-platform") == 0)
+		{
+			info.m_mobilePlatform = true;
+		}
 		else
 		{
 			return Error::USER_DATA;
@@ -185,8 +197,8 @@ static Error work(const CmdLineArgs& info)
 
 	// Compiler options
 	ShaderCompilerOptions compilerOptions;
-	compilerOptions.m_bindlessLimits.m_bindlessImageCount = 16;
-	compilerOptions.m_bindlessLimits.m_bindlessTextureCount = 16;
+	compilerOptions.m_forceFullFloatingPointPrecision = info.m_fullFpPrecision;
+	compilerOptions.m_mobilePlatform = info.m_mobilePlatform;
 
 	// Compile
 	ShaderProgramBinaryWrapper binary(alloc);