[hlsl-out] Validate all entry points in Makefile

This commit is contained in:
Gordon-F 2021-07-19 00:10:07 +03:00 committed by Dzmitry Malyshau
parent f3c7537609
commit 3c98cc5ae1
14 changed files with 96 additions and 64 deletions

View File

@ -65,17 +65,27 @@ validate-wgsl: $(SNAPSHOTS_BASE_OUT)/wgsl/*.wgsl
cargo run $${file}; \
done
validate-hlsl: SHELL:=/bin/bash # required because config files uses arrays
validate-hlsl: $(SNAPSHOTS_BASE_OUT)/hlsl/*.hlsl
@set -e && for file in $^ ; do \
DXC_PARAMS="-Wno-parentheses-equality -Zi -Qembed_debug"; \
echo "Validating" $${file#"$(SNAPSHOTS_BASE_OUT)/"}; \
config="$$(dirname $${file})/$$(basename $${file}).config"; \
vertex=""\
fragment="" \
compute="" \
. $${config}; \
DXC_PARAMS="-Wno-parentheses-equality -Zi -Qembed_debug"; \
[ ! -z "$${vertex}" ] && echo "Vertex Stage:" && dxc $${file} -T $${vertex} -E $${vertex_name} $${DXC_PARAMS} > /dev/null; \
[ ! -z "$${fragment}" ] && echo "Fragment Stage:" && dxc $${file} -T $${fragment} -E $${fragment_name} $${DXC_PARAMS} > /dev/null; \
[ ! -z "$${compute}" ] && echo "Compute Stage:" && dxc $${file} -T $${compute} -E $${compute_name} $${DXC_PARAMS} > /dev/null; \
for (( i=0; i<$${#vertex[@]}; i++ )); do \
name=`echo $${vertex[i]} | cut -d \: -f 1`; \
profile=`echo $${vertex[i]} | cut -d \: -f 2`; \
(set -x; dxc $${file} -T $${profile} -E $${name} $${DXC_PARAMS} > /dev/null); \
done; \
for (( i=0; i<$${#fragment[@]}; i++ )); do \
name=`echo $${fragment[i]} | cut -d \: -f 1`; \
profile=`echo $${fragment[i]} | cut -d \: -f 2`; \
(set -x; dxc $${file} -T $${profile} -E $${name} $${DXC_PARAMS} > /dev/null); \
done; \
for (( i=0; i<$${#compute[@]}; i++ )); do \
name=`echo $${compute[i]} | cut -d \: -f 1`; \
profile=`echo $${compute[i]} | cut -d \: -f 2`; \
(set -x; dxc $${file} -T $${profile} -E $${name} $${DXC_PARAMS} > /dev/null); \
done; \
echo "======================"; \
done

View File

@ -1,2 +1,3 @@
compute=cs_5_0
compute_name=main
vertex=()
fragment=()
compute=(main:cs_5_0 )

View File

@ -1,2 +1,3 @@
compute=cs_5_0
compute_name=main
vertex=()
fragment=()
compute=(main:cs_5_0 )

View File

@ -1,2 +1,3 @@
compute=cs_5_0
compute_name=main
vertex=()
fragment=()
compute=(main:cs_5_0 )

View File

@ -1,8 +1,3 @@
compute=cs_5_0
compute_name=main
vertex=vs_5_0
vertex_name=queries
fragment=ps_5_0
fragment_name=sample1
fragment=ps_5_0
fragment_name=sample_comparison
vertex=(queries:vs_5_0 )
fragment=(sample1:ps_5_0 sample_comparison:ps_5_0 )
compute=(main:cs_5_0 )

View File

@ -1,6 +1,3 @@
vertex=vs_5_0
vertex_name=vertex
fragment=ps_5_0
fragment_name=fragment
compute=cs_5_0
compute_name=compute
vertex=(vertex:vs_5_0 )
fragment=(fragment:ps_5_0 )
compute=(compute:cs_5_0 )

View File

@ -1,4 +1,3 @@
vertex=vs_5_0
vertex_name=main
fragment=ps_5_0
fragment_name=main1
vertex=(main:vs_5_0 )
fragment=(main1:ps_5_0 )
compute=()

View File

@ -1,2 +1,3 @@
compute=cs_5_0
compute_name=main
vertex=()
fragment=()
compute=(main:cs_5_0 )

View File

@ -1,2 +1,3 @@
vertex=vs_5_0
vertex_name=main
vertex=(main:vs_5_0 )
fragment=()
compute=()

View File

@ -1,6 +1,3 @@
vertex=vs_5_0
vertex_name=main
fragment=ps_5_0
fragment_name=main1
fragment=ps_5_0
fragment_name=fs_extra
vertex=(main:vs_5_0 )
fragment=(main1:ps_5_0 fs_extra:ps_5_0 )
compute=()

View File

@ -1,2 +1,3 @@
fragment=ps_5_0
fragment_name=fs_main
vertex=()
fragment=(fs_main:ps_5_0 )
compute=()

View File

@ -1,4 +1,3 @@
vertex=vs_5_1
vertex_name=vs_main
fragment=ps_5_1
fragment_name=fs_main
vertex=(vs_main:vs_5_1 )
fragment=(fs_main:ps_5_1 )
compute=()

View File

@ -1,2 +1,3 @@
fragment=ps_5_0
fragment_name=derivatives
vertex=()
fragment=(derivatives:ps_5_0 )
compute=()

View File

@ -304,27 +304,55 @@ fn write_output_hlsl(
// This file contains an info about profiles (shader stages) contains inside generated shader
// This info will be passed to dxc
let mut config_str = String::new();
let mut vertex_str = String::from("vertex=(");
let mut fragment_str = String::from("fragment=(");
let mut compute_str = String::from("compute=(");
for (index, ep) in module.entry_points.iter().enumerate() {
let name = match reflection_info.entry_point_names[index] {
Ok(ref name) => name,
Err(_) => continue,
};
let stage_str = match ep.stage {
naga::ShaderStage::Vertex => "vertex",
naga::ShaderStage::Fragment => "fragment",
naga::ShaderStage::Compute => "compute",
};
writeln!(
config_str,
"{}={}_{}\n{}_name={}",
stage_str,
ep.stage.to_hlsl_str(),
options.shader_model.to_str(),
stage_str,
name,
)
.unwrap();
match ep.stage {
naga::ShaderStage::Vertex => {
write!(
vertex_str,
"{}:{}_{} ",
name,
ep.stage.to_hlsl_str(),
options.shader_model.to_str(),
)
.unwrap();
}
naga::ShaderStage::Fragment => {
write!(
fragment_str,
"{}:{}_{} ",
name,
ep.stage.to_hlsl_str(),
options.shader_model.to_str(),
)
.unwrap();
}
naga::ShaderStage::Compute => {
write!(
compute_str,
"{}:{}_{} ",
name,
ep.stage.to_hlsl_str(),
options.shader_model.to_str(),
)
.unwrap();
}
}
}
writeln!(
config_str,
"{})\n{})\n{})",
vertex_str, fragment_str, compute_str
)
.unwrap();
fs::write(
destination.join(format!("hlsl/{}.hlsl.config", file_name)),
config_str,