Commit 49dab3eb authored by Kevin M. Godby's avatar Kevin M. Godby Committed by Brad King

VS: Add VS_SHADER_OUTPUT_HEADER_FILE and VS_SHADER_VARIABLE_NAME properties.

The VS_SHADER_OUTPUT_HEADER_FILE property is the name of the generated
header file containing the object code of the shader.

The VS_SHADER_VARIABLE_NAME property is the name of the variable
containing the object code in the above header file.
Signed-off-by: Kevin M. Godby's avatarKevin M. Godby <kevin@godby.org>
parent c40d1300
This diff is collapsed.
......@@ -392,7 +392,9 @@ Properties on Source Files
/prop_sf/VS_SHADER_ENTRYPOINT
/prop_sf/VS_SHADER_FLAGS
/prop_sf/VS_SHADER_MODEL
/prop_sf/VS_SHADER_OUTPUT_HEADER_FILE
/prop_sf/VS_SHADER_TYPE
/prop_sf/VS_SHADER_VARIABLE_NAME
/prop_sf/VS_TOOL_OVERRIDE.rst
/prop_sf/VS_XAML_TYPE
/prop_sf/WRAP_EXCLUDE
......
VS_SHADER_OUTPUT_HEADER_FILE
----------------------------
Set filename for output header file containing object code of a ``.hlsl``
source file.
VS_SHADER_VARIABLE_NAME
-----------------------
Set name of variable in header file containing object code of a ``.hlsl``
source file.
add-vs-shader-properties
------------------------
* Source file properties :prop_sf:`VS_SHADER_OUTPUT_HEADER_FILE` and
:prop_sf:`VS_SHADER_VARIABLE_NAME` have been added to specify more
details of ``.hlsl`` sources with :ref:`Visual Studio Generators`.
......@@ -1592,6 +1592,8 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
std::string shaderEntryPoint;
std::string shaderModel;
std::string shaderAdditionalFlags;
std::string outputHeaderFile;
std::string variableName;
std::string settingsGenerator;
std::string settingsLastGenOutput;
std::string sourceLink;
......@@ -1641,6 +1643,16 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
shaderModel = sm;
toolHasSettings = true;
}
// Figure out which output header file to use if any
if (const char* ohf = sf->GetProperty("VS_SHADER_OUTPUT_HEADER_FILE")) {
outputHeaderFile = ohf;
toolHasSettings = true;
}
// Figure out which variable name to use if any
if (const char* vn = sf->GetProperty("VS_SHADER_VARIABLE_NAME")) {
variableName = vn;
toolHasSettings = true;
}
// Figure out if there's any additional flags to use
if (const char* saf = sf->GetProperty("VS_SHADER_FLAGS")) {
shaderAdditionalFlags = saf;
......@@ -1765,6 +1777,28 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
(*this->BuildFileStream) << cmVS10EscapeXML(shaderModel)
<< "</ShaderModel>\n";
}
if (!outputHeaderFile.empty()) {
for (size_t i = 0; i != this->Configurations.size(); ++i) {
this->WriteString("<HeaderFileOutput Condition=\""
"'$(Configuration)|$(Platform)'=='",
3);
(*this->BuildFileStream) << this->Configurations[i] << "|"
<< this->Platform << "'\">"
<< cmVS10EscapeXML(outputHeaderFile);
this->WriteString("</HeaderFileOutput>\n", 0);
}
}
if (!variableName.empty()) {
for (size_t i = 0; i != this->Configurations.size(); ++i) {
this->WriteString("<VariableName Condition=\""
"'$(Configuration)|$(Platform)'=='",
3);
(*this->BuildFileStream) << this->Configurations[i] << "|"
<< this->Platform << "'\">"
<< cmVS10EscapeXML(variableName);
this->WriteString("</VariableName>\n", 0);
}
}
if (!shaderAdditionalFlags.empty()) {
this->WriteString("<AdditionalOptions>", 3);
(*this->BuildFileStream) << cmVS10EscapeXML(shaderAdditionalFlags)
......
......@@ -116,12 +116,14 @@ 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_ENTRYPOINT mainPS)
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 ${PIXELSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED")
set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_OUTPUT_HEADER_FILE "$(OutDir)%(Filename).h")
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_MODEL 4.0_level_9_3)
set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED /Fh \"$(OutDir)%(Filename).h\"")
set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED")
set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_OUTPUT_HEADER_FILE "$(OutDir)%(Filename).h")
source_group("Source Files" FILES ${SOURCE_FILES})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment