浏览代码

DX12 and VK validation fixes

Panagiotis Christopoulos Charitos 7 月之前
父节点
当前提交
6bc02e38a7

+ 1 - 0
AnKi/Gr/Texture.h

@@ -82,6 +82,7 @@ public:
 		case TextureType::k3D:
 		case TextureType::k3D:
 			ANKI_CHECK_VAL_VALIDITY(m_depth > 0);
 			ANKI_CHECK_VAL_VALIDITY(m_depth > 0);
 			ANKI_CHECK_VAL_VALIDITY(m_layerCount == 1);
 			ANKI_CHECK_VAL_VALIDITY(m_layerCount == 1);
+			ANKI_CHECK_VAL_VALIDITY(!(m_usage & TextureUsageBit::kAllRtvDsv));
 			break;
 			break;
 		case TextureType::k2DArray:
 		case TextureType::k2DArray:
 		case TextureType::kCubeArray:
 		case TextureType::kCubeArray:

+ 2 - 1
AnKi/Renderer/IndirectDiffuseClipmaps.cpp

@@ -319,6 +319,7 @@ void IndirectDiffuseClipmaps::populateRenderGraph(RenderingContext& ctx)
 			pass.newTextureDependency(rtResultHandle, TextureUsageBit::kSrvCompute);
 			pass.newTextureDependency(rtResultHandle, TextureUsageBit::kSrvCompute);
 			pass.newTextureDependency(radianceVolumes[clipmap], TextureUsageBit::kUavCompute);
 			pass.newTextureDependency(radianceVolumes[clipmap], TextureUsageBit::kUavCompute);
 			pass.newTextureDependency(probeValidityRts[clipmap], TextureUsageBit::kUavCompute);
 			pass.newTextureDependency(probeValidityRts[clipmap], TextureUsageBit::kUavCompute);
+			pass.newTextureDependency(distanceMomentsVolumes[clipmap], TextureUsageBit::kUavCompute);
 
 
 			pass.setWork([this, &ctx, clipmap, rtResultHandle, radianceVolume = radianceVolumes[clipmap], validityVolume = probeValidityRts[clipmap],
 			pass.setWork([this, &ctx, clipmap, rtResultHandle, radianceVolume = radianceVolumes[clipmap], validityVolume = probeValidityRts[clipmap],
 						  distanceMomentsVolume = distanceMomentsVolumes[clipmap]](RenderPassWorkContext& rgraphCtx) {
 						  distanceMomentsVolume = distanceMomentsVolumes[clipmap]](RenderPassWorkContext& rgraphCtx) {
@@ -431,7 +432,7 @@ void IndirectDiffuseClipmaps::drawDebugProbes(const RenderingContext& ctx, Rende
 
 
 	cmdb.bindConstantBuffer(0, 0, ctx.m_globalRenderingConstantsBuffer);
 	cmdb.bindConstantBuffer(0, 0, ctx.m_globalRenderingConstantsBuffer);
 
 
-	Texture* visVolume = m_distanceMomentsVolumes[clipmap].get();
+	Texture* visVolume = m_irradianceVolumes[clipmap].get();
 	cmdb.bindSrv(0, 0, TextureView(visVolume, TextureSubresourceDesc::all()));
 	cmdb.bindSrv(0, 0, TextureView(visVolume, TextureSubresourceDesc::all()));
 	rgraphCtx.bindSrv(1, 0, m_runCtx.m_probeValidityRts[clipmap]);
 	rgraphCtx.bindSrv(1, 0, m_runCtx.m_probeValidityRts[clipmap]);
 	cmdb.bindSampler(0, 0, getRenderer().getSamplers().m_trilinearRepeat.get());
 	cmdb.bindSampler(0, 0, getRenderer().getSamplers().m_trilinearRepeat.get());

+ 1 - 0
AnKi/Renderer/Renderer.cpp

@@ -175,6 +175,7 @@ Error Renderer::initInternal(const RendererInitInfo& inf)
 
 
 		texinit.m_depth = 4;
 		texinit.m_depth = 4;
 		texinit.m_type = TextureType::k3D;
 		texinit.m_type = TextureType::k3D;
+		texinit.m_usage = TextureUsageBit::kAllSrv | TextureUsageBit::kAllUav;
 		m_dummyResources.m_texture3DSrv = createAndClearRenderTarget(texinit, TextureUsageBit::kAllSrv);
 		m_dummyResources.m_texture3DSrv = createAndClearRenderTarget(texinit, TextureUsageBit::kAllSrv);
 
 
 		texinit.m_type = TextureType::k2D;
 		texinit.m_type = TextureType::k2D;

+ 1 - 0
AnKi/Renderer/Utils/Drawer.cpp

@@ -82,6 +82,7 @@ void RenderableDrawer::setState(const RenderableDrawerArguments& args, CommandBu
 
 
 void RenderableDrawer::drawMdi(const RenderableDrawerArguments& args, CommandBuffer& cmdb)
 void RenderableDrawer::drawMdi(const RenderableDrawerArguments& args, CommandBuffer& cmdb)
 {
 {
+	ANKI_TRACE_SCOPED_EVENT(DrawMdi);
 	ANKI_ASSERT(args.m_viewport != UVec4(0u));
 	ANKI_ASSERT(args.m_viewport != UVec4(0u));
 
 
 	if(RenderStateBucketContainer::getSingleton().getBucketCount(args.m_renderingTechinuqe) == 0) [[unlikely]]
 	if(RenderStateBucketContainer::getSingleton().getBucketCount(args.m_renderingTechinuqe) == 0) [[unlikely]]

+ 1 - 1
AnKi/Resource/AccelerationStructureScratchAllocator.h

@@ -57,7 +57,7 @@ public:
 		}
 		}
 
 
 		const BufferView view(m_buffer.get(), m_offset, size);
 		const BufferView view(m_buffer.get(), m_offset, size);
-		m_offset += size;
+		m_offset += getAlignedRoundUp(GrManager::getSingleton().getDeviceCapabilities().m_accelerationStructureBuildScratchOffsetAlignment, size);
 
 
 		return view;
 		return view;
 	}
 	}

+ 6 - 0
AnKi/ShaderCompiler/Common.h

@@ -70,6 +70,12 @@ public:
 	CString m_name;
 	CString m_name;
 	I32 m_value;
 	I32 m_value;
 };
 };
+
+enum class ShaderModel : U8
+{
+	k6_7,
+	k6_8
+};
 /// @}
 /// @}
 
 
 } // end namespace anki
 } // end namespace anki

+ 26 - 20
AnKi/ShaderCompiler/Dxc.cpp

@@ -88,33 +88,37 @@ static Error lazyDxcInit(ShaderCompilerString& errorMessage)
 	return Error::kNone;
 	return Error::kNone;
 }
 }
 
 
-static const WChar* profile(ShaderType shaderType)
+static const WChar* profile(ShaderType shaderType, ShaderModel sm)
 {
 {
+#define ANKI_SM(stage) out = (sm == ShaderModel::k6_7) ? L"" #stage "_6_7" : L"" #stage "_6_8"
+
+	const WChar* out = L"";
+
 	switch(shaderType)
 	switch(shaderType)
 	{
 	{
 	case ShaderType::kVertex:
 	case ShaderType::kVertex:
-		return L"vs_6_8";
+		ANKI_SM(vs);
 		break;
 		break;
 	case ShaderType::kPixel:
 	case ShaderType::kPixel:
-		return L"ps_6_8";
+		ANKI_SM(ps);
 		break;
 		break;
 	case ShaderType::kDomain:
 	case ShaderType::kDomain:
-		return L"ds_6_8";
+		ANKI_SM(ds);
 		break;
 		break;
 	case ShaderType::kHull:
 	case ShaderType::kHull:
-		return L"ds_6_8";
+		ANKI_SM(hs);
 		break;
 		break;
 	case ShaderType::kGeometry:
 	case ShaderType::kGeometry:
-		return L"gs_6_8";
+		ANKI_SM(gs);
 		break;
 		break;
 	case ShaderType::kAmplification:
 	case ShaderType::kAmplification:
-		return L"as_6_8";
+		ANKI_SM(as);
 		break;
 		break;
 	case ShaderType::kMesh:
 	case ShaderType::kMesh:
-		return L"ms_6_8";
+		ANKI_SM(ms);
 		break;
 		break;
 	case ShaderType::kCompute:
 	case ShaderType::kCompute:
-		return L"cs_6_8";
+		ANKI_SM(cs);
 		break;
 		break;
 	case ShaderType::kRayGen:
 	case ShaderType::kRayGen:
 	case ShaderType::kAnyHit:
 	case ShaderType::kAnyHit:
@@ -123,17 +127,19 @@ static const WChar* profile(ShaderType shaderType)
 	case ShaderType::kIntersection:
 	case ShaderType::kIntersection:
 	case ShaderType::kCallable:
 	case ShaderType::kCallable:
 	case ShaderType::kWorkGraph:
 	case ShaderType::kWorkGraph:
-		return L"lib_6_8";
+		ANKI_SM(lib);
 		break;
 		break;
 	default:
 	default:
 		ANKI_ASSERT(0);
 		ANKI_ASSERT(0);
 	};
 	};
 
 
-	return L"";
+	return out;
+
+#undef ANKI_SM
 }
 }
 
 
-static Error compileHlsl(CString src, ShaderType shaderType, Bool compileWith16bitTypes, Bool debugInfo, ConstWeakArray<CString> compilerArgs,
-						 Bool spirv, ShaderCompilerDynamicArray<U8>& bin, ShaderCompilerString& errorMessage)
+static Error compileHlsl(CString src, ShaderType shaderType, Bool compileWith16bitTypes, Bool debugInfo, ShaderModel sm,
+						 ConstWeakArray<CString> compilerArgs, Bool spirv, ShaderCompilerDynamicArray<U8>& bin, ShaderCompilerString& errorMessage)
 {
 {
 	ANKI_CHECK(lazyDxcInit(errorMessage));
 	ANKI_CHECK(lazyDxcInit(errorMessage));
 
 
@@ -155,7 +161,7 @@ static Error compileHlsl(CString src, ShaderType shaderType, Bool compileWith16b
 	dxcArgs.push_back(L"-E");
 	dxcArgs.push_back(L"-E");
 	dxcArgs.push_back(L"main");
 	dxcArgs.push_back(L"main");
 	dxcArgs.push_back(L"-T");
 	dxcArgs.push_back(L"-T");
-	dxcArgs.push_back(profile(shaderType));
+	dxcArgs.push_back(profile(shaderType, sm));
 
 
 	if(ANKI_COMPILER_MSVC)
 	if(ANKI_COMPILER_MSVC)
 	{
 	{
@@ -251,16 +257,16 @@ static Error compileHlsl(CString src, ShaderType shaderType, Bool compileWith16b
 	return Error::kNone;
 	return Error::kNone;
 }
 }
 
 
-Error compileHlslToSpirv(CString src, ShaderType shaderType, Bool compileWith16bitTypes, Bool debugInfo, ConstWeakArray<CString> compilerArgs,
-						 ShaderCompilerDynamicArray<U8>& spirv, ShaderCompilerString& errorMessage)
+Error compileHlslToSpirv(CString src, ShaderType shaderType, Bool compileWith16bitTypes, Bool debugInfo, ShaderModel sm,
+						 ConstWeakArray<CString> compilerArgs, ShaderCompilerDynamicArray<U8>& spirv, ShaderCompilerString& errorMessage)
 {
 {
-	return compileHlsl(src, shaderType, compileWith16bitTypes, debugInfo, compilerArgs, true, spirv, errorMessage);
+	return compileHlsl(src, shaderType, compileWith16bitTypes, debugInfo, sm, compilerArgs, true, spirv, errorMessage);
 }
 }
 
 
-Error compileHlslToDxil(CString src, ShaderType shaderType, Bool compileWith16bitTypes, Bool debugInfo, ConstWeakArray<CString> compilerArgs,
-						ShaderCompilerDynamicArray<U8>& dxil, ShaderCompilerString& errorMessage)
+Error compileHlslToDxil(CString src, ShaderType shaderType, Bool compileWith16bitTypes, Bool debugInfo, ShaderModel sm,
+						ConstWeakArray<CString> compilerArgs, ShaderCompilerDynamicArray<U8>& dxil, ShaderCompilerString& errorMessage)
 {
 {
-	return compileHlsl(src, shaderType, compileWith16bitTypes, debugInfo, compilerArgs, false, dxil, errorMessage);
+	return compileHlsl(src, shaderType, compileWith16bitTypes, debugInfo, sm, compilerArgs, false, dxil, errorMessage);
 }
 }
 
 
 #if ANKI_OS_WINDOWS
 #if ANKI_OS_WINDOWS

+ 4 - 4
AnKi/ShaderCompiler/Dxc.h

@@ -21,12 +21,12 @@ inline constexpr Array2d<U32, kMaxRegisterSpaces, U32(HlslResourceType::kCount)>
 inline constexpr U32 kDxcVkBindlessRegisterSpace = 1000000;
 inline constexpr U32 kDxcVkBindlessRegisterSpace = 1000000;
 
 
 /// Compile HLSL to SPIR-V.
 /// Compile HLSL to SPIR-V.
-Error compileHlslToSpirv(CString src, ShaderType shaderType, Bool compileWith16bitTypes, Bool debugInfo, ConstWeakArray<CString> compilerArgs,
-						 ShaderCompilerDynamicArray<U8>& spirv, ShaderCompilerString& errorMessage);
+Error compileHlslToSpirv(CString src, ShaderType shaderType, Bool compileWith16bitTypes, Bool debugInfo, ShaderModel sm,
+						 ConstWeakArray<CString> compilerArgs, ShaderCompilerDynamicArray<U8>& spirv, ShaderCompilerString& errorMessage);
 
 
 /// Compile HLSL to DXIL.
 /// Compile HLSL to DXIL.
-Error compileHlslToDxil(CString src, ShaderType shaderType, Bool compileWith16bitTypes, Bool debugInfo, ConstWeakArray<CString> compilerArgs,
-						ShaderCompilerDynamicArray<U8>& dxil, ShaderCompilerString& errorMessage);
+Error compileHlslToDxil(CString src, ShaderType shaderType, Bool compileWith16bitTypes, Bool debugInfo, ShaderModel sm,
+						ConstWeakArray<CString> compilerArgs, ShaderCompilerDynamicArray<U8>& dxil, ShaderCompilerString& errorMessage);
 
 
 Error doReflectionDxil(ConstWeakArray<U8> dxil, ShaderType type, ShaderReflection& refl, ShaderCompilerString& errorMessage);
 Error doReflectionDxil(ConstWeakArray<U8> dxil, ShaderType type, ShaderReflection& refl, ShaderCompilerString& errorMessage);
 /// @}
 /// @}

+ 11 - 8
AnKi/ShaderCompiler/ShaderCompiler.cpp

@@ -94,7 +94,7 @@ static Bool spinDials(ShaderCompilerDynamicArray<U32>& dials, ConstWeakArray<Sha
 	return done;
 	return done;
 }
 }
 
 
-static void compileVariantAsync(const ShaderParser& parser, Bool spirv, Bool debugInfo, ShaderBinaryMutation& mutation,
+static void compileVariantAsync(const ShaderParser& parser, Bool spirv, Bool debugInfo, ShaderModel sm, ShaderBinaryMutation& mutation,
 								ShaderCompilerDynamicArray<ShaderBinaryVariant>& variants,
 								ShaderCompilerDynamicArray<ShaderBinaryVariant>& variants,
 								ShaderCompilerDynamicArray<ShaderBinaryCodeBlock>& codeBlocks, ShaderCompilerDynamicArray<U64>& sourceCodeHashes,
 								ShaderCompilerDynamicArray<ShaderBinaryCodeBlock>& codeBlocks, ShaderCompilerDynamicArray<U64>& sourceCodeHashes,
 								ShaderCompilerAsyncTaskInterface& taskManager, Mutex& mtx, Atomic<I32>& error)
 								ShaderCompilerAsyncTaskInterface& taskManager, Mutex& mtx, Atomic<I32>& error)
@@ -111,6 +111,7 @@ static void compileVariantAsync(const ShaderParser& parser, Bool spirv, Bool deb
 		Atomic<I32>* m_err;
 		Atomic<I32>* m_err;
 		Bool m_spirv;
 		Bool m_spirv;
 		Bool m_debugInfo;
 		Bool m_debugInfo;
+		ShaderModel m_sm;
 	};
 	};
 
 
 	Ctx* ctx = newInstance<Ctx>(ShaderCompilerMemoryPool::getSingleton());
 	Ctx* ctx = newInstance<Ctx>(ShaderCompilerMemoryPool::getSingleton());
@@ -123,6 +124,7 @@ static void compileVariantAsync(const ShaderParser& parser, Bool spirv, Bool deb
 	ctx->m_err = &error;
 	ctx->m_err = &error;
 	ctx->m_spirv = spirv;
 	ctx->m_spirv = spirv;
 	ctx->m_debugInfo = debugInfo;
 	ctx->m_debugInfo = debugInfo;
+	ctx->m_sm = sm;
 
 
 	auto callback = [](void* userData) {
 	auto callback = [](void* userData) {
 		Ctx& ctx = *static_cast<Ctx*>(userData);
 		Ctx& ctx = *static_cast<Ctx*>(userData);
@@ -193,12 +195,12 @@ static void compileVariantAsync(const ShaderParser& parser, Bool spirv, Bool deb
 				ShaderCompilerDynamicArray<U8> il;
 				ShaderCompilerDynamicArray<U8> il;
 				if(ctx.m_spirv)
 				if(ctx.m_spirv)
 				{
 				{
-					err = compileHlslToSpirv(source, shaderType, ctx.m_parser->compileWith16bitTypes(), ctx.m_debugInfo,
+					err = compileHlslToSpirv(source, shaderType, ctx.m_parser->compileWith16bitTypes(), ctx.m_debugInfo, ctx.m_sm,
 											 ctx.m_parser->getExtraCompilerArgs(), il, compilerErrorLog);
 											 ctx.m_parser->getExtraCompilerArgs(), il, compilerErrorLog);
 				}
 				}
 				else
 				else
 				{
 				{
-					err = compileHlslToDxil(source, shaderType, ctx.m_parser->compileWith16bitTypes(), ctx.m_debugInfo,
+					err = compileHlslToDxil(source, shaderType, ctx.m_parser->compileWith16bitTypes(), ctx.m_debugInfo, ctx.m_sm,
 											ctx.m_parser->getExtraCompilerArgs(), il, compilerErrorLog);
 											ctx.m_parser->getExtraCompilerArgs(), il, compilerErrorLog);
 				}
 				}
 
 
@@ -323,7 +325,7 @@ static void compileVariantAsync(const ShaderParser& parser, Bool spirv, Bool deb
 	taskManager.enqueueTask(callback, ctx);
 	taskManager.enqueueTask(callback, ctx);
 }
 }
 
 
-static Error compileShaderProgramInternal(CString fname, Bool spirv, Bool debugInfo, ShaderCompilerFilesystemInterface& fsystem,
+static Error compileShaderProgramInternal(CString fname, Bool spirv, Bool debugInfo, ShaderModel sm, ShaderCompilerFilesystemInterface& fsystem,
 										  ShaderCompilerPostParseInterface* postParseCallback, ShaderCompilerAsyncTaskInterface* taskManager_,
 										  ShaderCompilerPostParseInterface* postParseCallback, ShaderCompilerAsyncTaskInterface* taskManager_,
 										  ConstWeakArray<ShaderCompilerDefine> defines_, ShaderBinary*& binary)
 										  ConstWeakArray<ShaderCompilerDefine> defines_, ShaderBinary*& binary)
 {
 {
@@ -439,7 +441,7 @@ static Error compileShaderProgramInternal(CString fname, Bool spirv, Bool debugI
 			{
 			{
 				// New and unique mutation and thus variant, add it
 				// New and unique mutation and thus variant, add it
 
 
-				compileVariantAsync(parser, spirv, debugInfo, mutation, variants, codeBlocks, sourceCodeHashes, taskManager, mtx, errorAtomic);
+				compileVariantAsync(parser, spirv, debugInfo, sm, mutation, variants, codeBlocks, sourceCodeHashes, taskManager, mtx, errorAtomic);
 
 
 				ANKI_ASSERT(mutationHashToIdx.find(mutation.m_hash) == mutationHashToIdx.getEnd());
 				ANKI_ASSERT(mutationHashToIdx.find(mutation.m_hash) == mutationHashToIdx.getEnd());
 				mutationHashToIdx.emplace(mutation.m_hash, mutationCount - 1);
 				mutationHashToIdx.emplace(mutation.m_hash, mutationCount - 1);
@@ -466,7 +468,8 @@ static Error compileShaderProgramInternal(CString fname, Bool spirv, Bool debugI
 		ShaderCompilerDynamicArray<ShaderBinaryCodeBlock> codeBlocks;
 		ShaderCompilerDynamicArray<ShaderBinaryCodeBlock> codeBlocks;
 		ShaderCompilerDynamicArray<U64> sourceCodeHashes;
 		ShaderCompilerDynamicArray<U64> sourceCodeHashes;
 
 
-		compileVariantAsync(parser, spirv, debugInfo, binary->m_mutations[0], variants, codeBlocks, sourceCodeHashes, taskManager, mtx, errorAtomic);
+		compileVariantAsync(parser, spirv, debugInfo, sm, binary->m_mutations[0], variants, codeBlocks, sourceCodeHashes, taskManager, mtx,
+							errorAtomic);
 
 
 		ANKI_CHECK(taskManager.joinTasks());
 		ANKI_CHECK(taskManager.joinTasks());
 		ANKI_CHECK(Error(errorAtomic.getNonAtomically()));
 		ANKI_CHECK(Error(errorAtomic.getNonAtomically()));
@@ -531,11 +534,11 @@ static Error compileShaderProgramInternal(CString fname, Bool spirv, Bool debugI
 	return Error::kNone;
 	return Error::kNone;
 }
 }
 
 
-Error compileShaderProgram(CString fname, Bool spirv, Bool debugInfo, ShaderCompilerFilesystemInterface& fsystem,
+Error compileShaderProgram(CString fname, Bool spirv, Bool debugInfo, ShaderModel sm, ShaderCompilerFilesystemInterface& fsystem,
 						   ShaderCompilerPostParseInterface* postParseCallback, ShaderCompilerAsyncTaskInterface* taskManager,
 						   ShaderCompilerPostParseInterface* postParseCallback, ShaderCompilerAsyncTaskInterface* taskManager,
 						   ConstWeakArray<ShaderCompilerDefine> defines, ShaderBinary*& binary)
 						   ConstWeakArray<ShaderCompilerDefine> defines, ShaderBinary*& binary)
 {
 {
-	const Error err = compileShaderProgramInternal(fname, spirv, debugInfo, fsystem, postParseCallback, taskManager, defines, binary);
+	const Error err = compileShaderProgramInternal(fname, spirv, debugInfo, sm, fsystem, postParseCallback, taskManager, defines, binary);
 	if(err)
 	if(err)
 	{
 	{
 		ANKI_SHADER_COMPILER_LOGE("Failed to compile: %s", fname.cstr());
 		ANKI_SHADER_COMPILER_LOGE("Failed to compile: %s", fname.cstr());

+ 1 - 1
AnKi/ShaderCompiler/ShaderCompiler.h

@@ -40,7 +40,7 @@ inline Error deserializeShaderBinaryFromFile(CString fname, ShaderBinary*& binar
 }
 }
 
 
 /// Takes an AnKi special shader program and spits a binary.
 /// Takes an AnKi special shader program and spits a binary.
-Error compileShaderProgram(CString fname, Bool spirv, Bool debugInfo, ShaderCompilerFilesystemInterface& fsystem,
+Error compileShaderProgram(CString fname, Bool spirv, Bool debugInfo, ShaderModel sm, ShaderCompilerFilesystemInterface& fsystem,
 						   ShaderCompilerPostParseInterface* postParseCallback, ShaderCompilerAsyncTaskInterface* taskManager,
 						   ShaderCompilerPostParseInterface* postParseCallback, ShaderCompilerAsyncTaskInterface* taskManager,
 						   ConstWeakArray<ShaderCompilerDefine> defines, ShaderBinary*& binary);
 						   ConstWeakArray<ShaderCompilerDefine> defines, ShaderBinary*& binary);
 
 

+ 8 - 0
AnKi/Shaders/CMakeLists.txt

@@ -42,6 +42,14 @@ else()
 	set(extra_compiler_args ${extra_compiler_args} "-dxil")
 	set(extra_compiler_args ${extra_compiler_args} "-dxil")
 endif()
 endif()
 
 
+if(DIRECTX)
+	if(ANKI_D3D_EXPERIMENTAL)
+		set(extra_compiler_args ${extra_compiler_args} "-sm" "6_8")
+	else()
+		set(extra_compiler_args ${extra_compiler_args} "-sm" "6_7")
+	endif()
+endif()
+
 include(FindPythonInterp)
 include(FindPythonInterp)
 
 
 foreach(prog_fname ${prog_fnames})
 foreach(prog_fname ${prog_fnames})

+ 1 - 0
CMakeLists.txt

@@ -179,6 +179,7 @@ else()
 endif()
 endif()
 
 
 set(ANKI_GR_BACKEND "VULKAN" CACHE STRING "The graphics API to use (VULKAN or DIRECTX)")
 set(ANKI_GR_BACKEND "VULKAN" CACHE STRING "The graphics API to use (VULKAN or DIRECTX)")
+option(ANKI_D3D_EXPERIMENTAL "Enable some experimental DX features" ON)
 
 
 if(${ANKI_GR_BACKEND} STREQUAL "DIRECTX")
 if(${ANKI_GR_BACKEND} STREQUAL "DIRECTX")
 	set(DIRECTX TRUE)
 	set(DIRECTX TRUE)

+ 2 - 2
Tests/Gr/GrCommon.h

@@ -20,9 +20,9 @@ inline ShaderPtr createShader(CString src, ShaderType type, ConstWeakArray<CStri
 	ShaderCompilerString errorLog;
 	ShaderCompilerString errorLog;
 
 
 #if ANKI_GR_BACKEND_VULKAN
 #if ANKI_GR_BACKEND_VULKAN
-	Error err = compileHlslToSpirv(header, type, false, true, extraCompilerArgs, bin, errorLog);
+	Error err = compileHlslToSpirv(header, type, false, true, ShaderModel::k6_8, extraCompilerArgs, bin, errorLog);
 #else
 #else
-	Error err = compileHlslToDxil(header, type, false, true, extraCompilerArgs, bin, errorLog);
+	Error err = compileHlslToDxil(header, type, false, true, ShaderModel::k6_8, extraCompilerArgs, bin, errorLog);
 #endif
 #endif
 	if(err)
 	if(err)
 	{
 	{

+ 2 - 2
Tests/ShaderCompiler/ShaderProgramCompiler.cpp

@@ -138,7 +138,7 @@ void main()
 	taskManager.m_pool = &pool;
 	taskManager.m_pool = &pool;
 
 
 	ShaderBinary* binary;
 	ShaderBinary* binary;
-	ANKI_TEST_EXPECT_NO_ERR(compileShaderProgram("test.glslp", true, true, fsystem, nullptr, &taskManager, {}, binary));
+	ANKI_TEST_EXPECT_NO_ERR(compileShaderProgram("test.glslp", true, true, ShaderModel::k6_8, fsystem, nullptr, &taskManager, {}, binary));
 
 
 #if 1
 #if 1
 	ShaderCompilerString dis;
 	ShaderCompilerString dis;
@@ -333,7 +333,7 @@ void main()
 	taskManager.m_pool = &pool;
 	taskManager.m_pool = &pool;
 
 
 	ShaderBinary* binary;
 	ShaderBinary* binary;
-	ANKI_TEST_EXPECT_NO_ERR(compileShaderProgram("test.glslp", true, true, fsystem, nullptr, &taskManager, {}, binary));
+	ANKI_TEST_EXPECT_NO_ERR(compileShaderProgram("test.glslp", true, true, ShaderModel::k6_8, fsystem, nullptr, &taskManager, {}, binary));
 
 
 #if 1
 #if 1
 	ShaderCompilerString dis;
 	ShaderCompilerString dis;

+ 27 - 1
Tools/Shader/ShaderProgramCompilerMain.cpp

@@ -17,6 +17,7 @@ Options:
 -spirv               : Compile SPIR-V
 -spirv               : Compile SPIR-V
 -dxil                : Compile DXIL
 -dxil                : Compile DXIL
 -g                   : Include debug info
 -g                   : Include debug info
+-sm                  : Shader mode. "6_7" or "6_8". Default "6_8"
 )";
 )";
 
 
 class CmdLineArgs
 class CmdLineArgs
@@ -31,6 +32,7 @@ public:
 	Bool m_spirv = false;
 	Bool m_spirv = false;
 	Bool m_dxil = false;
 	Bool m_dxil = false;
 	Bool m_debugInfo = false;
 	Bool m_debugInfo = false;
+	ShaderModel m_sm = ShaderModel::k6_8;
 };
 };
 
 
 static Error parseCommandLineArgs(int argc, char** argv, CmdLineArgs& info)
 static Error parseCommandLineArgs(int argc, char** argv, CmdLineArgs& info)
@@ -136,6 +138,30 @@ static Error parseCommandLineArgs(int argc, char** argv, CmdLineArgs& info)
 		{
 		{
 			info.m_debugInfo = true;
 			info.m_debugInfo = true;
 		}
 		}
+		else if(strcmp(argv[i], "-sm") == 0)
+		{
+			++i;
+
+			if(i < argc)
+			{
+				if(argv[i] == CString("6_7"))
+				{
+					info.m_sm = ShaderModel::k6_7;
+				}
+				else if(argv[i] == CString("6_8"))
+				{
+					info.m_sm = ShaderModel::k6_8;
+				}
+				else
+				{
+					return Error::kUserData;
+				}
+			}
+			else
+			{
+				return Error::kUserData;
+			}
+		}
 		else
 		else
 		{
 		{
 			return Error::kUserData;
 			return Error::kUserData;
@@ -216,7 +242,7 @@ static Error work(const CmdLineArgs& info)
 
 
 	// Compile
 	// Compile
 	ShaderBinary* binary = nullptr;
 	ShaderBinary* binary = nullptr;
-	ANKI_CHECK(compileShaderProgram(info.m_inputFname, info.m_spirv, info.m_debugInfo, fsystem, nullptr,
+	ANKI_CHECK(compileShaderProgram(info.m_inputFname, info.m_spirv, info.m_debugInfo, info.m_sm, fsystem, nullptr,
 									(info.m_threadCount) ? &taskManager : nullptr, info.m_defines, binary));
 									(info.m_threadCount) ? &taskManager : nullptr, info.m_defines, binary));
 
 
 	class Dummy
 	class Dummy