This commit is contained in:
Dr. Chat 2016-02-21 16:42:58 -06:00
parent d217f7b3c3
commit 3877afe90a
1 changed files with 18 additions and 4 deletions

View File

@ -962,6 +962,21 @@ void SpirvShaderTranslator::ProcessScalarAluInstruction(
dest = b.makeFloatConstant(0.f); dest = b.makeFloatConstant(0.f);
} break; } break;
case AluScalarOpcode::kMaxAsf: {
auto addr =
b.createUnaryOp(spv::Op::OpConvertFToS, int_type_, sources[0]);
addr = CreateGlslStd450InstructionCall(
spv::Decoration::DecorationInvariant, int_type_,
spv::GLSLstd450::kSClamp,
{addr, b.makeIntConstant(-256), b.makeIntConstant(255)});
b.createStore(addr, a0_);
// dest = src0 >= src1 ? src0 : src1
dest = CreateGlslStd450InstructionCall(
spv::Decoration::DecorationInvariant, float_type_,
spv::GLSLstd450::kFMax, {sources[0], sources[1]});
} break;
case AluScalarOpcode::kMaxAs: { case AluScalarOpcode::kMaxAs: {
// a0 = clamp(floor(src0 + 0.5), -256, 255) // a0 = clamp(floor(src0 + 0.5), -256, 255)
auto addr = b.createBinOp(spv::Op::OpFAdd, float_type_, sources[0], auto addr = b.createBinOp(spv::Op::OpFAdd, float_type_, sources[0],
@ -974,10 +989,9 @@ void SpirvShaderTranslator::ProcessScalarAluInstruction(
b.createStore(addr, a0_); b.createStore(addr, a0_);
// dest = src0 >= src1 ? src0 : src1 // dest = src0 >= src1 ? src0 : src1
auto cond = b.createBinOp(spv::Op::OpFOrdGreaterThanEqual, bool_type_, dest = CreateGlslStd450InstructionCall(
sources[0], sources[1]); spv::Decoration::DecorationInvariant, float_type_,
dest = b.createTriOp(spv::Op::OpSelect, float_type_, cond, sources[0], spv::GLSLstd450::kFMax, {sources[0], sources[1]});
sources[1]);
} break; } break;
case AluScalarOpcode::kMaxs: { case AluScalarOpcode::kMaxs: {