mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-23 15:23:33 +00:00
[hlsl-out] fix member offset consideration for storage buffers
This commit is contained in:
parent
c73c1efe33
commit
021bfd5289
@ -16,6 +16,7 @@ use std::{fmt, mem};
|
||||
|
||||
const STORE_TEMP_NAME: &str = "_value";
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(super) enum SubAccess {
|
||||
Offset(u32),
|
||||
Index {
|
||||
@ -365,7 +366,7 @@ impl<W: fmt::Write> super::Writer<'_, W> {
|
||||
) -> Result<Handle<crate::GlobalVariable>, Error> {
|
||||
self.temp_access_chain.clear();
|
||||
loop {
|
||||
// determine the size of the pontee
|
||||
// determine the size of the pointee
|
||||
let stride = match *func_ctx.info[cur_expr].ty.inner_with(&module.types) {
|
||||
crate::TypeInner::Pointer { base, class: _ } => {
|
||||
module.types[base].inner.span(&module.constants)
|
||||
@ -386,12 +387,16 @@ impl<W: fmt::Write> super::Writer<'_, W> {
|
||||
},
|
||||
),
|
||||
crate::Expression::AccessIndex { base, index } => {
|
||||
match *func_ctx.info[base].ty.inner_with(&module.types) {
|
||||
crate::TypeInner::Struct { ref members, .. } => {
|
||||
(base, SubAccess::Offset(members[index as usize].offset))
|
||||
}
|
||||
_ => (base, SubAccess::Offset(index * stride)),
|
||||
}
|
||||
let sub = match *func_ctx.info[base].ty.inner_with(&module.types) {
|
||||
crate::TypeInner::Pointer { base, .. } => match module.types[base].inner {
|
||||
crate::TypeInner::Struct { ref members, .. } => {
|
||||
SubAccess::Offset(members[index as usize].offset)
|
||||
}
|
||||
_ => SubAccess::Offset(index * stride),
|
||||
},
|
||||
_ => SubAccess::Offset(index * stride),
|
||||
};
|
||||
(base, sub)
|
||||
}
|
||||
ref other => {
|
||||
return Err(Error::Unimplemented(format!(
|
||||
|
@ -20,10 +20,10 @@ float4 foo(VertexInput_foo vertexinput_foo) : SV_Position
|
||||
float baz = foo1;
|
||||
foo1 = 1.0;
|
||||
float4x4 matrix1 = transpose(float4x4(asfloat(bar.Load4(0+0)), asfloat(bar.Load4(0+16)), asfloat(bar.Load4(0+32)), asfloat(bar.Load4(0+48))));
|
||||
uint2 arr[2] = {asuint(bar.Load2(16+0)), asuint(bar.Load2(16+8))};
|
||||
uint2 arr[2] = {asuint(bar.Load2(64+0)), asuint(bar.Load2(64+8))};
|
||||
float4 _expr13 = asfloat(bar.Load4(48+0));
|
||||
float b = _expr13.x;
|
||||
int a = asint(bar.Load((((NagaBufferLengthRW(bar) - 80) / 4) - 2u)*4+8));
|
||||
int a = asint(bar.Load((((NagaBufferLengthRW(bar) - 80) / 4) - 2u)*4+80));
|
||||
bar.Store(8+16+0, asuint(1.0));
|
||||
{
|
||||
float4x4 _value2 = transpose(float4x4(float4(0.0.xxxx), float4(1.0.xxxx), float4(2.0.xxxx), float4(3.0.xxxx)));
|
||||
@ -34,8 +34,8 @@ float4 foo(VertexInput_foo vertexinput_foo) : SV_Position
|
||||
}
|
||||
{
|
||||
uint2 _value2[2] = { uint2(0u.xx), uint2(1u.xx) };
|
||||
bar.Store2(16+0, asuint(_value2[0]));
|
||||
bar.Store2(16+8, asuint(_value2[1]));
|
||||
bar.Store2(64+0, asuint(_value2[0]));
|
||||
bar.Store2(64+8, asuint(_value2[1]));
|
||||
}
|
||||
{
|
||||
int _result[5]={ a, int(b), 3, 4, 5 };
|
||||
|
Loading…
Reference in New Issue
Block a user