spv-out: option to emit PointSize

This commit is contained in:
Dzmitry Malyshau 2021-09-15 14:43:52 -04:00 committed by Dzmitry Malyshau
parent 5d3c93e8c7
commit 52d74e91a4
30 changed files with 331 additions and 212 deletions

View File

@ -565,6 +565,9 @@ bitflags::bitflags! {
/// Contrary to spec, some drivers treat it as semantic, not allowing
/// any conflicts.
const LABEL_VARYINGS = 0x4;
/// Emit `PointSize` output builtin to vertex shaders, which is
/// required for drawing with `PointList` topology.
const FORCE_POINT_SIZE = 0x8;
}
}

View File

@ -13,6 +13,11 @@ use crate::{
use spirv::Word;
use std::collections::hash_map::Entry;
struct FunctionInterface<'a> {
varying_ids: &'a mut Vec<Word>,
stage: crate::ShaderStage,
}
impl Function {
fn to_words(&self, sink: &mut impl Extend<Word>) {
self.signature.as_ref().unwrap().to_words(sink);
@ -223,6 +228,35 @@ impl Writer {
self.get_type_id(local_type.into())
}
pub(super) fn get_float_type_id(&mut self) -> Word {
let local_type = LocalType::Value {
vector_size: None,
kind: crate::ScalarKind::Float,
width: 4,
pointer_class: None,
};
self.get_type_id(local_type.into())
}
pub(super) fn get_float_pointer_type_id(&mut self, class: spirv::StorageClass) -> Word {
let lookup_type = LookupType::Local(LocalType::Value {
vector_size: None,
kind: crate::ScalarKind::Float,
width: 4,
pointer_class: Some(class),
});
if let Some(&id) = self.lookup_type.get(&lookup_type) {
id
} else {
let id = self.id_gen.next();
let ty_id = self.get_float_type_id();
let instruction = Instruction::type_pointer(id, class, ty_id);
instruction.to_words(&mut self.logical_layout.declarations);
self.lookup_type.insert(lookup_type, id);
id
}
}
pub(super) fn get_bool_type_id(&mut self) -> Word {
let local_type = LocalType::Value {
vector_size: None,
@ -243,7 +277,7 @@ impl Writer {
ir_function: &crate::Function,
info: &FunctionInfo,
ir_module: &crate::Module,
mut varying_ids: Option<&mut Vec<Word>>,
mut interface: Option<FunctionInterface>,
) -> Result<Word, Error> {
let mut function = Function::default();
@ -291,12 +325,13 @@ impl Writer {
)?,
false => self.get_type_id(LookupType::Handle(argument.ty)),
};
if let Some(ref mut list) = varying_ids {
if let Some(ref mut iface) = interface {
let id = if let Some(ref binding) = argument.binding {
let name = argument.name.as_ref().map(AsRef::as_ref);
let varying_id =
self.write_varying(ir_module, class, name, argument.ty, binding)?;
list.push(varying_id);
iface.varying_ids.push(varying_id);
let id = self.id_gen.next();
prelude
.body
@ -313,7 +348,7 @@ impl Writer {
let binding = member.binding.as_ref().unwrap();
let varying_id =
self.write_varying(ir_module, class, name, member.ty, binding)?;
list.push(varying_id);
iface.varying_ids.push(varying_id);
let id = self.id_gen.next();
prelude
.body
@ -354,13 +389,16 @@ impl Writer {
let return_type_id = match ir_function.result {
Some(ref result) => {
if let Some(ref mut list) = varying_ids {
if let Some(ref mut iface) = interface {
let mut has_point_size = false;
let class = spirv::StorageClass::Output;
if let Some(ref binding) = result.binding {
has_point_size |=
*binding == crate::Binding::BuiltIn(crate::BuiltIn::PointSize);
let type_id = self.get_type_id(LookupType::Handle(result.ty));
let varying_id =
self.write_varying(ir_module, class, None, result.ty, binding)?;
list.push(varying_id);
iface.varying_ids.push(varying_id);
ep_context.results.push(ResultMember {
id: varying_id,
type_id,
@ -373,9 +411,11 @@ impl Writer {
let type_id = self.get_type_id(LookupType::Handle(member.ty));
let name = member.name.as_ref().map(AsRef::as_ref);
let binding = member.binding.as_ref().unwrap();
has_point_size |=
*binding == crate::Binding::BuiltIn(crate::BuiltIn::PointSize);
let varying_id =
self.write_varying(ir_module, class, name, member.ty, binding)?;
list.push(varying_id);
iface.varying_ids.push(varying_id);
ep_context.results.push(ResultMember {
id: varying_id,
type_id,
@ -385,6 +425,29 @@ impl Writer {
} else {
unreachable!("Missing result binding on an entry point");
}
if self.flags.contains(WriterFlags::FORCE_POINT_SIZE)
&& iface.stage == crate::ShaderStage::Vertex
&& !has_point_size
{
// add point size artificially
let varying_id = self.id_gen.next();
let pointer_type_id = self.get_float_pointer_type_id(class);
Instruction::variable(pointer_type_id, varying_id, class, None)
.to_words(&mut self.logical_layout.declarations);
self.decorate(
varying_id,
spirv::Decoration::BuiltIn,
&[spirv::BuiltIn::PointSize as u32],
);
iface.varying_ids.push(varying_id);
let default_value_id =
self.get_constant_scalar(crate::ScalarValue::Float(1.0), 4);
prelude
.body
.push(Instruction::store(varying_id, default_value_id, None));
}
self.void_type
} else {
self.get_type_id(LookupType::Handle(result.ty))
@ -413,7 +476,7 @@ impl Writer {
function_type,
));
if varying_ids.is_some() {
if interface.is_some() {
function.entry_point_context = Some(ep_context);
}
@ -501,7 +564,10 @@ impl Writer {
&entry_point.function,
info,
ir_module,
Some(&mut interface_ids),
Some(FunctionInterface {
varying_ids: &mut interface_ids,
stage: entry_point.stage,
}),
)?;
let exec_model = match entry_point.stage {

View File

@ -1,7 +1,9 @@
(
spv_version: (1, 1),
spv_debug: true,
spv_adjust_coordinate_space: false,
spv: (
version: (1, 1),
debug: true,
adjust_coordinate_space: false,
),
msl_custom: true,
msl: (
lang_version: (2, 0),

View File

@ -1,7 +1,9 @@
(
spv_version: (1, 0),
spv_debug: true,
spv_adjust_coordinate_space: false,
spv: (
version: (1, 0),
debug: true,
adjust_coordinate_space: false,
),
msl_custom: true,
msl: (
lang_version: (2, 0),

View File

@ -1,5 +1,7 @@
(
image_bounds_check_policy: Restrict,
spv_version: (1, 1),
spv_debug: true,
spv: (
version: (1, 1),
debug: true,
),
)

View File

@ -1,5 +1,7 @@
(
image_bounds_check_policy: ReadZeroSkipWrite,
spv_version: (1, 1),
spv_debug: true,
image_bounds_check_policy: ReadZeroSkipWrite,
spv: (
version: (1, 1),
debug: true,
),
)

View File

@ -1,5 +1,4 @@
(
index_bounds_check_policy: ReadZeroSkipWrite,
buffer_bounds_check_policy: ReadZeroSkipWrite,
spv_version: (1, 1),
index_bounds_check_policy: ReadZeroSkipWrite,
buffer_bounds_check_policy: ReadZeroSkipWrite,
)

View File

@ -1,4 +1,6 @@
(
spv_version: (1, 0),
spv_debug: true,
spv: (
version: (1, 0),
debug: true,
),
)

View File

@ -1,3 +1,2 @@
(
spv_version: (1, 1),
)

View File

@ -1,3 +1,2 @@
(
spv_version: (1, 1),
)

View File

@ -1,6 +1,8 @@
(
god_mode: true,
spv_version: (1, 0),
spv: (
version: (1, 2),
),
msl_custom: true,
msl: (
lang_version: (2, 2),

View File

@ -1,3 +1,2 @@
(
spv_version: (1, 0),
)

View File

@ -1,4 +1,6 @@
(
spv_version: (1, 1),
spv_debug: true,
spv: (
version: (1, 1),
debug: true,
),
)

View File

@ -1,8 +1,11 @@
(
spv_version: (1, 0),
spv_capabilities: [ Shader, SampleRateShading ],
spv_adjust_coordinate_space: false,
spv_separate_entry_points: true,
spv: (
version: (1, 0),
capabilities: [ Shader, SampleRateShading ],
adjust_coordinate_space: false,
force_point_size: true,
separate_entry_points: true,
),
hlsl_custom: true,
hlsl: (
shader_model: V5_1,

View File

@ -1,8 +1,11 @@
(
spv_version: (1, 0),
spv_capabilities: [ Shader, SampleRateShading ],
spv_debug: true,
spv_adjust_coordinate_space: true,
spv: (
version: (1, 0),
capabilities: [ Shader, SampleRateShading ],
debug: true,
force_point_size: true,
adjust_coordinate_space: true,
),
glsl: (
version: Desktop(400),
writer_flags: (bits: 0),

View File

@ -1,3 +1,2 @@
(
spv_version: (1, 0),
)

View File

@ -1,5 +1,7 @@
(
spv_version: (1, 0),
spv_debug: true,
spv_adjust_coordinate_space: true,
spv: (
version: (1, 0),
debug: true,
adjust_coordinate_space: true,
),
)

View File

@ -1,7 +1,9 @@
(
index_bounds_check_policy: Restrict,
buffer_bounds_check_policy: Unchecked,
image_bounds_check_policy: ReadZeroSkipWrite,
spv_version: (1, 1),
spv_debug: true,
index_bounds_check_policy: Restrict,
buffer_bounds_check_policy: Unchecked,
image_bounds_check_policy: ReadZeroSkipWrite,
spv: (
version: (1, 1),
debug: true,
),
)

View File

@ -1,7 +1,9 @@
(
spv_version: (1, 0),
spv_debug: true,
spv_adjust_coordinate_space: true,
spv: (
version: (1, 0),
debug: true,
adjust_coordinate_space: true,
),
glsl_custom: true,
glsl: (
version: Embedded(300),

View File

@ -1,5 +1,7 @@
(
spv_version: (1, 2),
spv_debug: true,
spv_adjust_coordinate_space: true,
spv: (
version: (1, 2),
debug: true,
adjust_coordinate_space: true,
),
)

View File

@ -1,8 +1,10 @@
(
spv_flow_dump_prefix: "",
spv_version: (1, 0),
spv_debug: false,
spv_adjust_coordinate_space: false,
spv: (
version: (1, 0),
debug: false,
adjust_coordinate_space: false,
),
msl_custom: true,
msl: (
lang_version: (2, 1),

View File

@ -1,4 +1,2 @@
(
spv_version: (1, 0),
spv_adjust_coordinate_space: false,
)

View File

@ -1,5 +1,7 @@
(
spv_version: (1, 0),
spv_debug: true,
spv_adjust_coordinate_space: true,
spv: (
version: (1, 0),
debug: true,
adjust_coordinate_space: true,
),
)

View File

@ -1,5 +1,5 @@
; SPIR-V
; Version: 1.0
; Version: 1.2
; Generator: rspirv
; Bound: 44
OpCapability Shader

View File

@ -1,5 +1,5 @@
; SPIR-V
; Version: 1.0
; Version: 1.1
; Generator: rspirv
; Bound: 26
OpCapability Shader

View File

@ -1,11 +1,11 @@
; SPIR-V
; Version: 1.0
; Generator: rspirv
; Bound: 39
; Bound: 41
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %29 "vertex" %18 %21 %23 %25 %27
OpEntryPoint Vertex %31 "vertex" %18 %21 %23 %25 %27 %29
OpMemberDecorate %12 0 Offset 0
OpMemberDecorate %12 1 Offset 16
OpMemberDecorate %13 0 Offset 0
@ -17,6 +17,7 @@ OpDecorate %21 BuiltIn InstanceIndex
OpDecorate %23 Location 10
OpDecorate %25 BuiltIn Position
OpDecorate %27 Location 1
OpDecorate %29 BuiltIn PointSize
%2 = OpTypeVoid
%4 = OpTypeFloat 32
%3 = OpConstant %4 1.0
@ -40,22 +41,25 @@ OpDecorate %27 Location 1
%25 = OpVariable %26 Output
%28 = OpTypePointer Output %4
%27 = OpVariable %28 Output
%30 = OpTypeFunction %2
%29 = OpFunction %2 None %30
%30 = OpTypePointer Output %4
%29 = OpVariable %30 Output
%32 = OpTypeFunction %2
%31 = OpFunction %2 None %32
%17 = OpLabel
%20 = OpLoad %6 %18
%22 = OpLoad %6 %21
%24 = OpLoad %6 %23
OpBranch %31
%31 = OpLabel
%32 = OpIAdd %6 %20 %22
%33 = OpIAdd %6 %32 %24
%34 = OpCompositeConstruct %11 %3 %3 %3 %3
%35 = OpConvertUToF %4 %33
%36 = OpCompositeConstruct %12 %34 %35
%37 = OpCompositeExtract %11 %36 0
OpStore %25 %37
%38 = OpCompositeExtract %4 %36 1
OpStore %27 %38
OpStore %29 %3
OpBranch %33
%33 = OpLabel
%34 = OpIAdd %6 %20 %22
%35 = OpIAdd %6 %34 %24
%36 = OpCompositeConstruct %11 %3 %3 %3 %3
%37 = OpConvertUToF %4 %35
%38 = OpCompositeConstruct %12 %36 %37
%39 = OpCompositeExtract %11 %38 0
OpStore %25 %39
%40 = OpCompositeExtract %4 %38 1
OpStore %27 %40
OpReturn
OpFunctionEnd

View File

@ -1,14 +1,14 @@
; SPIR-V
; Version: 1.0
; Generator: rspirv
; Bound: 108
; Bound: 110
OpCapability Shader
OpCapability SampleRateShading
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %42 "main" %29 %31 %33 %35 %37 %39 %40 %41
OpEntryPoint Fragment %106 "main" %85 %88 %91 %94 %97 %100 %102 %104
OpExecutionMode %106 OriginUpperLeft
OpEntryPoint Vertex %45 "main" %29 %31 %33 %35 %37 %39 %40 %41 %42
OpEntryPoint Fragment %108 "main" %87 %90 %93 %96 %99 %102 %104 %106
OpExecutionMode %108 OriginUpperLeft
OpSource GLSL 450
OpMemberName %25 0 "position"
OpMemberName %25 1 "flat"
@ -28,16 +28,16 @@ OpName %37 "linear_sample"
OpName %39 "perspective"
OpName %40 "perspective_centroid"
OpName %41 "perspective_sample"
OpName %42 "main"
OpName %85 "position"
OpName %88 "flat"
OpName %91 "linear"
OpName %94 "linear_centroid"
OpName %97 "linear_sample"
OpName %100 "perspective"
OpName %102 "perspective_centroid"
OpName %104 "perspective_sample"
OpName %106 "main"
OpName %45 "main"
OpName %87 "position"
OpName %90 "flat"
OpName %93 "linear"
OpName %96 "linear_centroid"
OpName %99 "linear_sample"
OpName %102 "perspective"
OpName %104 "perspective_centroid"
OpName %106 "perspective_sample"
OpName %108 "main"
OpMemberDecorate %25 0 Offset 0
OpMemberDecorate %25 1 Offset 16
OpMemberDecorate %25 2 Offset 20
@ -62,22 +62,23 @@ OpDecorate %40 Location 5
OpDecorate %40 Centroid
OpDecorate %41 Location 6
OpDecorate %41 Sample
OpDecorate %85 BuiltIn FragCoord
OpDecorate %88 Location 0
OpDecorate %88 Flat
OpDecorate %91 Location 1
OpDecorate %91 NoPerspective
OpDecorate %94 Location 2
OpDecorate %94 NoPerspective
OpDecorate %94 Centroid
OpDecorate %97 Location 3
OpDecorate %97 NoPerspective
OpDecorate %97 Sample
OpDecorate %100 Location 4
OpDecorate %102 Location 5
OpDecorate %102 Centroid
OpDecorate %104 Location 6
OpDecorate %104 Sample
OpDecorate %42 BuiltIn PointSize
OpDecorate %87 BuiltIn FragCoord
OpDecorate %90 Location 0
OpDecorate %90 Flat
OpDecorate %93 Location 1
OpDecorate %93 NoPerspective
OpDecorate %96 Location 2
OpDecorate %96 NoPerspective
OpDecorate %96 Centroid
OpDecorate %99 Location 3
OpDecorate %99 NoPerspective
OpDecorate %99 Sample
OpDecorate %102 Location 4
OpDecorate %104 Location 5
OpDecorate %104 Centroid
OpDecorate %106 Location 6
OpDecorate %106 Sample
%2 = OpTypeVoid
%4 = OpTypeFloat 32
%3 = OpConstant %4 2.0
@ -116,94 +117,97 @@ OpDecorate %104 Sample
%39 = OpVariable %30 Output
%40 = OpVariable %34 Output
%41 = OpVariable %34 Output
%43 = OpTypeFunction %2
%45 = OpTypePointer Function %22
%47 = OpConstant %9 0
%49 = OpTypePointer Function %9
%50 = OpConstant %9 1
%52 = OpTypePointer Function %4
%53 = OpConstant %9 2
%55 = OpTypePointer Function %23
%57 = OpConstant %9 3
%59 = OpTypePointer Function %24
%61 = OpConstant %9 4
%64 = OpConstant %9 5
%66 = OpConstant %9 6
%68 = OpConstant %9 7
%73 = OpTypePointer Output %4
%86 = OpTypePointer Input %22
%85 = OpVariable %86 Input
%89 = OpTypePointer Input %9
%88 = OpVariable %89 Input
%92 = OpTypePointer Input %4
%91 = OpVariable %92 Input
%95 = OpTypePointer Input %23
%94 = OpVariable %95 Input
%98 = OpTypePointer Input %24
%97 = OpVariable %98 Input
%100 = OpVariable %86 Input
%102 = OpVariable %92 Input
%104 = OpVariable %92 Input
%42 = OpFunction %2 None %43
%43 = OpTypePointer Output %4
%42 = OpVariable %43 Output
%44 = OpConstant %4 1.0
%46 = OpTypeFunction %2
%48 = OpTypePointer Function %22
%50 = OpConstant %9 0
%52 = OpTypePointer Function %9
%53 = OpConstant %9 1
%55 = OpTypePointer Function %4
%56 = OpConstant %9 2
%58 = OpTypePointer Function %23
%60 = OpConstant %9 3
%62 = OpTypePointer Function %24
%64 = OpConstant %9 4
%67 = OpConstant %9 5
%69 = OpConstant %9 6
%71 = OpConstant %9 7
%88 = OpTypePointer Input %22
%87 = OpVariable %88 Input
%91 = OpTypePointer Input %9
%90 = OpVariable %91 Input
%94 = OpTypePointer Input %4
%93 = OpVariable %94 Input
%97 = OpTypePointer Input %23
%96 = OpVariable %97 Input
%100 = OpTypePointer Input %24
%99 = OpVariable %100 Input
%102 = OpVariable %88 Input
%104 = OpVariable %94 Input
%106 = OpVariable %94 Input
%45 = OpFunction %2 None %46
%28 = OpLabel
%26 = OpVariable %27 Function
OpBranch %44
%44 = OpLabel
%46 = OpCompositeConstruct %22 %3 %5 %6 %7
%48 = OpAccessChain %45 %26 %47
OpStore %48 %46
%51 = OpAccessChain %49 %26 %50
OpStore %51 %8
OpStore %42 %44
OpBranch %47
%47 = OpLabel
%49 = OpCompositeConstruct %22 %3 %5 %6 %7
%51 = OpAccessChain %48 %26 %50
OpStore %51 %49
%54 = OpAccessChain %52 %26 %53
OpStore %54 %10
%56 = OpCompositeConstruct %23 %11 %12
%58 = OpAccessChain %55 %26 %57
OpStore %58 %56
%60 = OpCompositeConstruct %24 %13 %14 %15
%62 = OpAccessChain %59 %26 %61
OpStore %62 %60
%63 = OpCompositeConstruct %22 %16 %17 %18 %19
%65 = OpAccessChain %45 %26 %64
OpStore %54 %8
%57 = OpAccessChain %55 %26 %56
OpStore %57 %10
%59 = OpCompositeConstruct %23 %11 %12
%61 = OpAccessChain %58 %26 %60
OpStore %61 %59
%63 = OpCompositeConstruct %24 %13 %14 %15
%65 = OpAccessChain %62 %26 %64
OpStore %65 %63
%67 = OpAccessChain %52 %26 %66
OpStore %67 %20
%69 = OpAccessChain %52 %26 %68
OpStore %69 %21
%70 = OpLoad %25 %26
%71 = OpCompositeExtract %22 %70 0
OpStore %29 %71
%72 = OpAccessChain %73 %29 %50
%74 = OpLoad %4 %72
%75 = OpFNegate %4 %74
OpStore %72 %75
%76 = OpCompositeExtract %9 %70 1
OpStore %31 %76
%77 = OpCompositeExtract %4 %70 2
OpStore %33 %77
%78 = OpCompositeExtract %23 %70 3
OpStore %35 %78
%79 = OpCompositeExtract %24 %70 4
OpStore %37 %79
%80 = OpCompositeExtract %22 %70 5
OpStore %39 %80
%81 = OpCompositeExtract %4 %70 6
OpStore %40 %81
%82 = OpCompositeExtract %4 %70 7
OpStore %41 %82
%66 = OpCompositeConstruct %22 %16 %17 %18 %19
%68 = OpAccessChain %48 %26 %67
OpStore %68 %66
%70 = OpAccessChain %55 %26 %69
OpStore %70 %20
%72 = OpAccessChain %55 %26 %71
OpStore %72 %21
%73 = OpLoad %25 %26
%74 = OpCompositeExtract %22 %73 0
OpStore %29 %74
%75 = OpAccessChain %43 %29 %53
%76 = OpLoad %4 %75
%77 = OpFNegate %4 %76
OpStore %75 %77
%78 = OpCompositeExtract %9 %73 1
OpStore %31 %78
%79 = OpCompositeExtract %4 %73 2
OpStore %33 %79
%80 = OpCompositeExtract %23 %73 3
OpStore %35 %80
%81 = OpCompositeExtract %24 %73 4
OpStore %37 %81
%82 = OpCompositeExtract %22 %73 5
OpStore %39 %82
%83 = OpCompositeExtract %4 %73 6
OpStore %40 %83
%84 = OpCompositeExtract %4 %73 7
OpStore %41 %84
OpReturn
OpFunctionEnd
%106 = OpFunction %2 None %43
%83 = OpLabel
%87 = OpLoad %22 %85
%90 = OpLoad %9 %88
%93 = OpLoad %4 %91
%96 = OpLoad %23 %94
%99 = OpLoad %24 %97
%101 = OpLoad %22 %100
%103 = OpLoad %4 %102
%108 = OpFunction %2 None %46
%85 = OpLabel
%89 = OpLoad %22 %87
%92 = OpLoad %9 %90
%95 = OpLoad %4 %93
%98 = OpLoad %23 %96
%101 = OpLoad %24 %99
%103 = OpLoad %22 %102
%105 = OpLoad %4 %104
%84 = OpCompositeConstruct %25 %87 %90 %93 %96 %99 %101 %103 %105
OpBranch %107
%107 = OpLabel
%107 = OpLoad %4 %106
%86 = OpCompositeConstruct %25 %89 %92 %95 %98 %101 %103 %105 %107
OpBranch %109
%109 = OpLabel
OpReturn
OpFunctionEnd

View File

@ -1,5 +1,5 @@
; SPIR-V
; Version: 1.0
; Version: 1.1
; Generator: rspirv
; Bound: 101
OpCapability Shader

View File

@ -1,5 +1,5 @@
; SPIR-V
; Version: 1.0
; Version: 1.1
; Generator: rspirv
; Bound: 19
OpCapability Shader

View File

@ -40,6 +40,31 @@ impl From<BoundsCheckPolicyArg> for naga::back::BoundsCheckPolicy {
}
}
#[cfg_attr(not(feature = "spv-out"), allow(dead_code))]
#[derive(serde::Deserialize)]
struct SpvOutVersion(u8, u8);
impl Default for SpvOutVersion {
fn default() -> Self {
SpvOutVersion(1, 1)
}
}
#[cfg_attr(not(feature = "spv-out"), allow(dead_code))]
#[derive(Default, serde::Deserialize)]
struct SpirvOutParameters {
version: SpvOutVersion,
#[serde(default)]
capabilities: naga::FastHashSet<spirv::Capability>,
#[serde(default)]
debug: bool,
#[serde(default)]
adjust_coordinate_space: bool,
#[serde(default)]
force_point_size: bool,
#[serde(default)]
separate_entry_points: bool,
}
#[derive(Default, serde::Deserialize)]
struct Parameters {
#[serde(default)]
@ -54,21 +79,9 @@ struct Parameters {
#[allow(dead_code)]
#[serde(default)]
image_bounds_check_policy: BoundsCheckPolicyArg,
#[cfg_attr(not(feature = "spv-out"), allow(dead_code))]
spv_version: (u8, u8),
#[cfg_attr(not(feature = "spv-out"), allow(dead_code))]
#[serde(default)]
spv_capabilities: naga::FastHashSet<spirv::Capability>,
#[cfg_attr(not(feature = "spv-out"), allow(dead_code))]
#[serde(default)]
spv_debug: bool,
#[cfg_attr(not(feature = "spv-out"), allow(dead_code))]
#[serde(default)]
spv_adjust_coordinate_space: bool,
#[cfg_attr(not(feature = "spv-out"), allow(dead_code))]
#[serde(default)]
spv_separate_entry_points: bool,
spv: SpirvOutParameters,
#[cfg(all(feature = "deserialize", feature = "msl-out"))]
#[serde(default)]
msl: naga::back::msl::Options,
@ -179,18 +192,22 @@ fn write_output_spv(
use rspirv::binary::Disassemble;
let mut flags = spv::WriterFlags::LABEL_VARYINGS;
flags.set(spv::WriterFlags::DEBUG, params.spv_debug);
flags.set(spv::WriterFlags::DEBUG, params.spv.debug);
flags.set(
spv::WriterFlags::ADJUST_COORDINATE_SPACE,
params.spv_adjust_coordinate_space,
params.spv.adjust_coordinate_space,
);
flags.set(
spv::WriterFlags::FORCE_POINT_SIZE,
params.spv.force_point_size,
);
let options = spv::Options {
lang_version: params.spv_version,
lang_version: (params.spv.version.0, params.spv.version.1),
flags,
capabilities: if params.spv_capabilities.is_empty() {
capabilities: if params.spv.capabilities.is_empty() {
None
} else {
Some(params.spv_capabilities.clone())
Some(params.spv.capabilities.clone())
},
bounds_check_policies: naga::back::BoundsCheckPolicies {
@ -202,7 +219,7 @@ fn write_output_spv(
..spv::Options::default()
};
if params.spv_separate_entry_points {
if params.spv.separate_entry_points {
for ep in module.entry_points.iter() {
let pipeline_options = spv::PipelineOptions {
entry_point: ep.name.clone(),