HLSL Shader Build Task

This solution is a build task which adds the ability to compile HLSL files referenced in MSBuild projects. Integrates with Visual Studio to make compiling shaders seamless.

C++ (8.3 MB)
3.7 Star
5,593 times
Add to favorites
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

// ShaderBuildTask.h

#pragma once

#include "d3dx9.h"

using namespace System;
using namespace Microsoft::Build::Framework;
using namespace Microsoft::Build::Utilities;
using namespace System::IO;
using namespace System::Diagnostics;
using namespace System::Collections::Generic;

namespace ShaderBuildTask {

public ref class ShaderCompile : Task
			_dxLibraryToUse = String::Empty;
			_calculatedDxLibraryToUse = false;

			EntryPoint = "main";
			PackMatrixRowMajor = true;
			OptimizationLevel = -1;
			Debug = false;
			ExportConstants = true;			

		property array<ITaskItem^>^ Sources;

		property String^ ShaderProfile;

		property String^ EntryPoint;
		property int OptimizationLevel; // O0-O3
		property bool Debug;
		property bool PackMatrixRowMajor;
		property bool ExportConstants;
		property String^ IntermediateOutputPath;

		property array<ITaskItem^>^ Outputs
			array<ITaskItem^>^ get()
				return _outputs->ToArray();

			void set(array<ITaskItem^>^ value)

		virtual bool Execute() override;

		String^ GetDxLibraryToUse();
		String^ GetOutputFileName(String^ inputFileName);
		void WriteConstants(String^ fileName, LPD3DXCONSTANTTABLE constantTable);

		List<ITaskItem^>^ _outputs;
		String^ _dxLibraryToUse;
		bool _calculatedDxLibraryToUse;