microsoft / microsoft/DirectXShaderCompiler
dxilconv.dll misconverts a shader with a dvec2 immediate.
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the shader conversion using FXC and dxilconv.dll, starting from the dxilconv.dll path that converts DXBC double constants to DXIL. Compare the generated DXIL with the example and verify that both immediate double constants remain intact rather than the second becoming zero.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100