Skip to content

dxilconv.dll misconverts a shader with a dvec2 immediate. #8466

@giomasce

Description

@giomasce

Description
dxilconv.dll misconverts this shader (see it on Shader Playground):

double src0;

void main(out uint4 dst : SV_Target)
{
    double2 a = double2(src0 + 1.0000002433080226l, src0 + 2.000000481493771l);
    asuint(a.x, dst.x, dst.y);
    asuint(a.y, dst.z, dst.w);
}

DXBC:

ps_5_0
dcl_globalFlags refactoringAllowed | enableDoublePrecisionFloatOps
dcl_constantbuffer CB0[1], immediateIndexed
dcl_output o0.xyzw
dcl_temps 1
dadd r0.xyzw, cb0[0].xyxy, d(1.000000l, 2.000000l)
mov o0.xyzw, r0.xyzw
ret 

DXIL as converted by dxilconv.dll:

define void @main() {
entry:
  %0 = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 2, i32 0, i32 0, i1 false)  ; CreateHandle(resourceClass,rangeId,index,nonUniformIndex)
  %1 = call %dx.types.CBufRet.f64 @dx.op.cbufferLoadLegacy.f64(i32 59, %dx.types.Handle %0, i32 0)  ; CBufferLoadLegacy(handle,regIndex)
  %2 = extractvalue %dx.types.CBufRet.f64 %1, 0
  %3 = fadd fast double %2, 0x3FF0000041500000
  %4 = fadd fast double %2, 0.000000e+00
  %5 = call %dx.types.splitdouble @dx.op.splitDouble.f64(i32 102, double %3)  ; SplitDouble(value)
  %6 = extractvalue %dx.types.splitdouble %5, 0
  %7 = extractvalue %dx.types.splitdouble %5, 1
  %8 = call %dx.types.splitdouble @dx.op.splitDouble.f64(i32 102, double %4)  ; SplitDouble(value)
  %9 = extractvalue %dx.types.splitdouble %8, 0
  %10 = extractvalue %dx.types.splitdouble %8, 1
  call void @dx.op.storeOutput.i32(i32 5, i32 0, i32 0, i8 0, i32 %6)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  call void @dx.op.storeOutput.i32(i32 5, i32 0, i32 0, i8 1, i32 %7)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  call void @dx.op.storeOutput.i32(i32 5, i32 0, i32 0, i8 2, i32 %9)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  call void @dx.op.storeOutput.i32(i32 5, i32 0, i32 0, i8 3, i32 %10)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  ret void
}

As you can see, the second double constant became a zero, which is incorrect.

Steps to Reproduce
Compile the shader above with FXC and then convert it to DXIL using dxilconv.dll.

Actual Behavior
Both double constants should be kept intact in the converted shader.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug, regression, crashneeds-triageAwaiting triage

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions