Skip to content

Commit

Permalink
Emit OpModfStruct for GLSL EOpModf instead of OpModf
Browse files Browse the repository at this point in the history
* Update tests to account for `OpModfStruct`
  • Loading branch information
chyyran authored Oct 25, 2024
1 parent 2fed4fc commit 3454c36
Show file tree
Hide file tree
Showing 7 changed files with 3,784 additions and 3,705 deletions.
18 changes: 17 additions & 1 deletion SPIRV/GlslangToSpv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8805,7 +8805,16 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv::
builder.promoteScalar(precision, operands.front(), operands.back());
break;
case glslang::EOpModf:
libCall = spv::GLSLstd450Modf;
{
libCall = spv::GLSLstd450ModfStruct;
assert(builder.isFloatType(builder.getScalarTypeId(typeId0)));
int width = builder.getScalarTypeWidth(typeId0);
if (width == 16)
builder.addExtension(spv::E_SPV_AMD_gpu_shader_half_float);
// The returned struct has two members of the same type as the first argument
typeId = builder.makeStructResultType(typeId0, typeId0);
consumedOperands = 1;
}
break;
case glslang::EOpMax:
if (isFloat)
Expand Down Expand Up @@ -9428,6 +9437,13 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv::
builder.createStore(builder.createCompositeExtract(id, typeId0, 0), operands[3]);
builder.createStore(builder.createCompositeExtract(id, typeId0, 1), operands[2]);
break;
case glslang::EOpModf:
{
assert(operands.size() == 2);
builder.createStore(builder.createCompositeExtract(id, typeId0, 1), operands[1]);
id = builder.createCompositeExtract(id, typeId0, 0);
}
break;
case glslang::EOpFrexp:
{
assert(operands.size() == 2);
Expand Down
2,082 changes: 1,051 additions & 1,031 deletions Test/baseResults/spv.400.frag.nanclamp.out

Large diffs are not rendered by default.

2,082 changes: 1,051 additions & 1,031 deletions Test/baseResults/spv.400.frag.out

Large diffs are not rendered by default.

1,064 changes: 536 additions & 528 deletions Test/baseResults/spv.Operations.frag.out

Large diffs are not rendered by default.

815 changes: 410 additions & 405 deletions Test/baseResults/spv.float16.frag.out

Large diffs are not rendered by default.

711 changes: 358 additions & 353 deletions Test/baseResults/spv.float32.frag.out

Large diffs are not rendered by default.

717 changes: 361 additions & 356 deletions Test/baseResults/spv.float64.frag.out

Large diffs are not rendered by default.

0 comments on commit 3454c36

Please sign in to comment.