Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit OpModfStruct for GLSL EOpModf instead of OpModf #3757

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion SPIRV/GlslangToSpv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8805,7 +8805,17 @@ 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)
// Using 16-bit whole number operand, enable extension E_SPV_AMD_gpu_shader_half_float
builder.addExtension(spv::E_SPV_AMD_gpu_shader_half_float);
// The two members of the returned struct and x must all be the same type.
typeId = builder.makeStructResultType(typeId0, typeId0);
consumedOperands = 1;
}
break;
case glslang::EOpMax:
if (isFloat)
Expand Down Expand Up @@ -9428,6 +9438,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.