Merge topic 'vs-shader-flags'

4775c901 VS: Add source file property to set extra hlsl shader flags
This commit is contained in:
Brad King 2015-01-29 09:13:58 -05:00 committed by CMake Topic Stage
commit 98659aecfd
7 changed files with 33 additions and 0 deletions

View File

@ -294,6 +294,7 @@ Properties on Source Files
/prop_sf/VS_DEPLOYMENT_CONTENT /prop_sf/VS_DEPLOYMENT_CONTENT
/prop_sf/VS_DEPLOYMENT_LOCATION /prop_sf/VS_DEPLOYMENT_LOCATION
/prop_sf/VS_SHADER_ENTRYPOINT /prop_sf/VS_SHADER_ENTRYPOINT
/prop_sf/VS_SHADER_FLAGS
/prop_sf/VS_SHADER_MODEL /prop_sf/VS_SHADER_MODEL
/prop_sf/VS_SHADER_TYPE /prop_sf/VS_SHADER_TYPE
/prop_sf/WRAP_EXCLUDE /prop_sf/WRAP_EXCLUDE

View File

@ -0,0 +1,4 @@
VS_SHADER_FLAGS
---------------
Set additional VS shader flags of a ``.hlsl`` source file.

View File

@ -0,0 +1,5 @@
vs-shader-flags
---------------
* A :prop_sf:`VS_SHADER_FLAGS` source file property was added to specify
additional shader flags to ``.hlsl`` files, for the Visual Studio generators.

View File

@ -1211,6 +1211,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
std::string shaderType; std::string shaderType;
std::string shaderEntryPoint; std::string shaderEntryPoint;
std::string shaderModel; std::string shaderModel;
std::string shaderAdditionalFlags;
std::string ext = cmSystemTools::LowerCase(sf->GetExtension()); std::string ext = cmSystemTools::LowerCase(sf->GetExtension());
if(ext == "hlsl") if(ext == "hlsl")
{ {
@ -1233,6 +1234,12 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
shaderModel = sm; shaderModel = sm;
toolHasSettings = true; toolHasSettings = true;
} }
// Figure out if there's any additional flags to use
if (const char* saf = sf->GetProperty("VS_SHADER_FLAGS"))
{
shaderAdditionalFlags = saf;
toolHasSettings = true;
}
} }
else if(ext == "jpg" || else if(ext == "jpg" ||
ext == "png") ext == "png")
@ -1342,6 +1349,12 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
(*this->BuildFileStream) << cmVS10EscapeXML(shaderModel) (*this->BuildFileStream) << cmVS10EscapeXML(shaderModel)
<< "</ShaderModel>\n"; << "</ShaderModel>\n";
} }
if(!shaderAdditionalFlags.empty())
{
this->WriteString("<AdditionalOptions>", 3);
(*this->BuildFileStream) << cmVS10EscapeXML(shaderAdditionalFlags)
<< "</AdditionalOptions>\n";
}
this->WriteString("</", 2); this->WriteString("</", 2);
(*this->BuildFileStream) << tool << ">\n"; (*this->BuildFileStream) << tool << ">\n";
} }

View File

@ -110,10 +110,12 @@ set_property(SOURCE ${RELEASE_CONTENT_FILES} PROPERTY
set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_TYPE Pixel) set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_TYPE Pixel)
set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_ENTRYPOINT mainPS) set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_ENTRYPOINT mainPS)
set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_MODEL 4.0_level_9_3) set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_MODEL 4.0_level_9_3)
set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED /Fh \"$(OutDir)%(Filename).h\"")
set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_TYPE Vertex) set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_TYPE Vertex)
set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_ENTRYPOINT mainVS) set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_ENTRYPOINT mainVS)
set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_MODEL 4.0_level_9_3) set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_MODEL 4.0_level_9_3)
set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED /Fh \"$(OutDir)%(Filename).h\"")
source_group("Source Files" FILES ${SOURCE_FILES}) source_group("Source Files" FILES ${SOURCE_FILES})

View File

@ -1,3 +1,7 @@
#if !defined(FLAGS_ADDED)
# error FLAGS_ADDED not defined
#endif
struct PixelShaderInput struct PixelShaderInput
{ {
float4 pos : SV_POSITION; float4 pos : SV_POSITION;

View File

@ -1,3 +1,7 @@
#if !defined(FLAGS_ADDED)
# error FLAGS_ADDED not defined
#endif
cbuffer ModelViewProjectionConstantBuffer : register(b0) cbuffer ModelViewProjectionConstantBuffer : register(b0)
{ {
matrix model; matrix model;