mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[hlsl-out] fix array arguments in functions
This commit is contained in:
committed by
Dzmitry Malyshau
parent
6ab6d6fc46
commit
dad4b1bb10
@@ -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)?;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user