Output code for OpFMod in HLSL when required

This commit is contained in:
Robert Konrad 2016-08-18 12:54:22 +02:00
parent 8e9bf1f7af
commit 1a48d7d4fc
2 changed files with 20 additions and 3 deletions

View File

@ -138,8 +138,11 @@ void CompilerHLSL::emit_header()
for (auto &header : header_lines)
statement(header);
if (header_lines.size() > 0)
{
statement("");
}
}
void CompilerHLSL::emit_interface_block_globally(const SPIRVariable &var)
{
@ -295,7 +298,6 @@ void CompilerHLSL::emit_resources()
for (auto var : variables)
{
emit_interface_block_in_struct(*var, binding_number);
emitted = true;
}
end_scope_decl();
statement("");
@ -329,7 +331,6 @@ void CompilerHLSL::emit_resources()
for (auto var : variables)
{
emit_interface_block_in_struct(*var, binding_number);
emitted = true;
}
end_scope_decl();
statement("");
@ -348,6 +349,15 @@ void CompilerHLSL::emit_resources()
if (emitted)
statement("");
if (requires_op_fmod)
{
statement("float mod(float x, float y)");
begin_scope();
statement("return x - y * floor(x / y);");
end_scope();
statement("");
}
}
void CompilerHLSL::emit_function_prototype(SPIRFunction &func, uint64_t return_flags)
@ -845,6 +855,12 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
emit_binary_func_op_transpose_all(ops[0], ops[1], ops[2], ops[3], "mul");
break;
}
case OpFMod:
{
requires_op_fmod = true;
CompilerGLSL::emit_instruction(instruction);
break;
}
default:
CompilerGLSL::emit_instruction(instruction);
break;

View File

@ -67,6 +67,7 @@ private:
void emit_glsl_op(uint32_t result_type, uint32_t result_id, uint32_t op, const uint32_t *args, uint32_t count) override;
Options options;
bool requires_op_fmod = false;
};
}