This repository has been archived by the owner on Jan 29, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 193
[hlsl-out] Misalligned Float Loads in Push Constants #2095
Labels
area: back-end
Outputs of shader conversion
lang: HLSL
High-Level Shading Language
resolution: invalid
This doesn't seem right
Comments
cwfitzgerald
added
kind: bug
Something isn't working
area: back-end
Outputs of shader conversion
lang: HLSL
High-Level Shading Language
labels
Oct 20, 2022
Alright, I'm getting FXC bug vibes from this. AMD and Nvidia give different answers from Intel, and WARP segfaults. FXC generates some DXBC which looks totally wacky and not remotely sane https://shader-playground.timjones.io/0cc29a22f8b96926ba3ad2cbb15bcbd3
Compare that to the generated DXIL which looks sane, loading [0, 1, 2, 3]: define void @cs_main() {
%1 = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 0, i32 0, i32 0, i8 1 }, i32 0, i1 false) ; CreateHandleFromBinding(bind,index,nonUniformIndex)
%2 = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 0, i32 0, i32 0, i8 2 }, i32 0, i1 false) ; CreateHandleFromBinding(bind,index,nonUniformIndex)
%3 = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %2, %dx.types.ResourceProperties { i32 13, i32 16 }) ; AnnotateHandle(res,props) resource: CBuffer
%4 = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %3, i32 0) ; CBufferLoadLegacy(handle,regIndex)
%5 = extractvalue %dx.types.CBufRet.f32 %4, 0
%6 = bitcast float %5 to i32
%7 = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %1, %dx.types.ResourceProperties { i32 4107, i32 0 }) ; AnnotateHandle(res,props) resource: RWByteAddressBuffer
call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %7, i32 0, i32 undef, i32 %6, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
%8 = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %3, i32 0) ; CBufferLoadLegacy(handle,regIndex)
%9 = extractvalue %dx.types.CBufRet.f32 %8, 1
%10 = bitcast float %9 to i32
%11 = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %1, %dx.types.ResourceProperties { i32 4107, i32 0 }) ; AnnotateHandle(res,props) resource: RWByteAddressBuffer
call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %11, i32 4, i32 undef, i32 %10, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
%12 = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %3, i32 0) ; CBufferLoadLegacy(handle,regIndex)
%13 = extractvalue %dx.types.CBufRet.f32 %12, 2
%14 = bitcast float %13 to i32
%15 = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %1, %dx.types.ResourceProperties { i32 4107, i32 0 }) ; AnnotateHandle(res,props) resource: RWByteAddressBuffer
call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %15, i32 8, i32 undef, i32 %14, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
%16 = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %3, i32 0) ; CBufferLoadLegacy(handle,regIndex)
%17 = extractvalue %dx.types.CBufRet.f32 %16, 3
%18 = bitcast float %17 to i32
%19 = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %1, %dx.types.ResourceProperties { i32 4107, i32 0 }) ; AnnotateHandle(res,props) resource: RWByteAddressBuffer
call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %19, i32 12, i32 undef, i32 %18, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
ret void
} |
cwfitzgerald
added
resolution: invalid
This doesn't seem right
and removed
kind: bug
Something isn't working
labels
Oct 20, 2022
Further argument for gfx-rs/wgpu#2722 |
The issue appears to be double indexing the matrix like |
cwfitzgerald
added a commit
to cwfitzgerald/naga
that referenced
this issue
Oct 20, 2022
cwfitzgerald
added a commit
to cwfitzgerald/naga
that referenced
this issue
Oct 20, 2022
cwfitzgerald
added a commit
to cwfitzgerald/naga
that referenced
this issue
Oct 20, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
area: back-end
Outputs of shader conversion
lang: HLSL
High-Level Shading Language
resolution: invalid
This doesn't seem right
Very similar to #2093, but likely an unrelated cause.
Found as part of gfx-rs/wgpu#3125.
When loading individual values from any matrix in a push constant, all the offsets loaded are weird. Only when loading individual values is it a problem, not when loading the entire matrix.
Here are the expected vs actual offsets when loading individual floats from matrices.
To give a concrete test case, here are the inputs and outputs for two of the loading styles for push constants.
mat2x2
mat2x3
The text was updated successfully, but these errors were encountered: