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

[SPIRV] Implement Gis option for spir-v #6840

Merged
merged 2 commits into from
Jul 31, 2024
Merged
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
1 change: 1 addition & 0 deletions include/dxc/Support/SPIRVOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ struct SpirvCodeGenOptions {
bool fixFuncCallArguments;
bool allowRWStructuredBufferArrays;
bool enableMaximalReconvergence;
bool IEEEStrict;
/// Maximum length in words for the OpString literal containing the shader
/// source for DebugSource and DebugSourceContinued. If the source code length
/// is larger than this number, we will use DebugSourceContinued instructions
Expand Down
2 changes: 1 addition & 1 deletion lib/DxcSupport/HLSLOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ static bool hasUnsupportedSpirvOption(const InputArgList &args,
// available options and their current compatibility is needed to generate a
// complete list.
std::vector<OptSpecifier> unsupportedOpts = {OPT_Fd, OPT_Fre, OPT_Gec,
OPT_Gis, OPT_Qstrip_reflect};
OPT_Qstrip_reflect};

for (const auto &id : unsupportedOpts) {
if (Arg *arg = args.getLastArg(id)) {
Expand Down
3 changes: 2 additions & 1 deletion tools/clang/lib/SPIRV/EmitVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@ void EmitVisitor::initInstruction(SpirvInstruction *inst) {
spv::Decoration::RelaxedPrecision, {});
}
// Emit NoContraction decoration (if any).
if (inst->isPrecise() && inst->isArithmeticInstruction()) {
if ((spvOptions.IEEEStrict || inst->isPrecise()) &&
inst->isArithmeticInstruction()) {
typeHandler.emitDecoration(getOrAssignResultId<SpirvInstruction>(inst),
spv::Decoration::NoContraction, {});
}
Expand Down
13 changes: 10 additions & 3 deletions tools/clang/test/CodeGenSPIRV/spirv.opt.gis.hlsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
// RUN: not %dxc -T ps_6_0 -E main -spirv -Gis %s 2>&1 | FileCheck %s
// RUN: %dxc -T ps_6_0 -E main -spirv -Gis %s 2>&1 | FileCheck %s

void main() {}
// Make sure the no-contraction is added for the arithmetic operation.
// CHECK: OpDecorate [[op:%[0-9]+]] NoContraction

float4 v;
float4 main(uint col : COLOR) : SV_Target0
{
// [[op]] = OpVectorTimesScalar
return 3*v;
}
Keenuts marked this conversation as resolved.
Show resolved Hide resolved

// CHECK: -Gis is not supported with -spirv
1 change: 1 addition & 0 deletions tools/clang/tools/dxcompiler/dxcompilerobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,7 @@ class DxcCompiler : public IDxcCompiler3,
opts.SpirvOptions.codeGenHighLevel = opts.CodeGenHighLevel;
opts.SpirvOptions.defaultRowMajor = opts.DefaultRowMajor;
opts.SpirvOptions.disableValidation = opts.DisableValidation;
opts.SpirvOptions.IEEEStrict = opts.IEEEStrict;
// Save a string representation of command line options and
// input file name.
if (opts.DebugInfo) {
Expand Down
Loading