Skip to content

Commit

Permalink
[hlsl-out] Emit row_major qualifier on matrix uniform globals.
Browse files Browse the repository at this point in the history
Fixes #1836.
  • Loading branch information
jimblandy committed Apr 17, 2022
1 parent c942a90 commit ef387f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/back/hlsl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,12 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {

if global.space == crate::AddressSpace::Uniform {
write!(self.out, " {{ ")?;
// Even though Naga IR matrices are column-major, we must describe
// matrices passed from the CPU as being in row-major order. See
// the module-level comments for details.
if let TypeInner::Matrix { .. } = module.types[global.ty].inner {
write!(self.out, "row_major ")?;
}
self.write_type(module, global.ty)?;
let sub_name = &self.names[&NameKey::GlobalVariable(handle)];
write!(self.out, " {}", sub_name)?;
Expand Down
2 changes: 1 addition & 1 deletion tests/out/hlsl/globals.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RWByteAddressBuffer alignment : register(u1);
ByteAddressBuffer dummy : register(t2);
cbuffer float_vecs : register(b3) { float4 float_vecs[20]; }
cbuffer global_vec : register(b4) { float4 global_vec; }
cbuffer global_mat : register(b5) { float4x4 global_mat; }
cbuffer global_mat : register(b5) { row_major float4x4 global_mat; }

void test_msl_packed_vec3_as_arg(float3 arg)
{
Expand Down

0 comments on commit ef387f7

Please sign in to comment.