[hlsl-out] fix array arguments in functions

This commit is contained in:
Dzmitry Malyshau
2021-08-19 10:02:24 -04:00
committed by Dzmitry Malyshau
parent 6ab6d6fc46
commit dad4b1bb10
2 changed files with 7 additions and 3 deletions

View File

@@ -773,7 +773,8 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
back::FunctionType::Function(handle) => {
for (index, arg) in func.arguments.iter().enumerate() {
// Write argument type
let arg_ty = match module.types[arg.ty].inner {
let ty_inner = &module.types[arg.ty].inner;
let arg_ty = match *ty_inner {
// pointers in function arguments are expected and resolve to `inout`
TypeInner::Pointer { base, .. } => {
//TODO: can we narrow this down to just `in` when possible?
@@ -789,6 +790,9 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
// Write argument name. Space is important.
write!(self.out, " {}", argument_name)?;
if let TypeInner::Array { size, .. } = *ty_inner {
self.write_array_size(module, size)?;
}
if index < func.arguments.len() - 1 {
// Add a separator between args
write!(self.out, ", ")?;
@@ -1858,7 +1862,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
components: &[Handle<crate::Constant>],
) -> BackendResult {
let (open_b, close_b) = match module.types[ty].inner {
TypeInner::Struct { .. } => ("{ ", " }"),
TypeInner::Array { .. } | TypeInner::Struct { .. } => ("{ ", " }"),
_ => {
// We should write type only for non struct constants
self.write_type(module, ty)?;

View File

@@ -16,7 +16,7 @@ struct type10 {
static float2 v_uv = (float2)0;
static float2 a_uv1 = (float2)0;
static gl_PerVertex perVertexStruct = { float4(0.0, 0.0, 0.0, 1.0), 1.0, float(0.0), float(0.0) };
static gl_PerVertex perVertexStruct = { float4(0.0, 0.0, 0.0, 1.0), 1.0, { 0.0 }, { 0.0 } };
static float2 a_pos1 = (float2)0;
struct VertexInput_main {