(Android) Another potential buildfix; define ENABLE_HLSL

(slang_process) Put HLSL/Cg code around ENABLE_HLSL ifdef
(SPIRV-Cross) Make sure macros no longer need to be redefined; make them
unique in both glsl and hlsl files; needed for Griffin builds
This commit is contained in:
twinaphex 2018-06-26 13:18:17 +02:00
parent 3bbf34aa58
commit 8a1c0be83c
4 changed files with 153 additions and 159 deletions

View File

@ -2544,48 +2544,48 @@ string CompilerGLSL::constant_op_expression(const SPIRConstantOp &cop)
op = type_to_glsl_constructor(type); op = type_to_glsl_constructor(type);
break; break;
#define BOP(opname, x) \ #define GLSL_BOP(opname, x) \
case Op##opname: \ case Op##opname: \
binary = true; \ binary = true; \
op = x; \ op = x; \
break break
#define UOP(opname, x) \ #define GLSL_UOP(opname, x) \
case Op##opname: \ case Op##opname: \
unary = true; \ unary = true; \
op = x; \ op = x; \
break break
UOP(SNegate, "-"); GLSL_UOP(SNegate, "-");
UOP(Not, "~"); GLSL_UOP(Not, "~");
BOP(IAdd, "+"); GLSL_BOP(IAdd, "+");
BOP(ISub, "-"); GLSL_BOP(ISub, "-");
BOP(IMul, "*"); GLSL_BOP(IMul, "*");
BOP(SDiv, "/"); GLSL_BOP(SDiv, "/");
BOP(UDiv, "/"); GLSL_BOP(UDiv, "/");
BOP(UMod, "%"); GLSL_BOP(UMod, "%");
BOP(SMod, "%"); GLSL_BOP(SMod, "%");
BOP(ShiftRightLogical, ">>"); GLSL_BOP(ShiftRightLogical, ">>");
BOP(ShiftRightArithmetic, ">>"); GLSL_BOP(ShiftRightArithmetic, ">>");
BOP(ShiftLeftLogical, "<<"); GLSL_BOP(ShiftLeftLogical, "<<");
BOP(BitwiseOr, "|"); GLSL_BOP(BitwiseOr, "|");
BOP(BitwiseXor, "^"); GLSL_BOP(BitwiseXor, "^");
BOP(BitwiseAnd, "&"); GLSL_BOP(BitwiseAnd, "&");
BOP(LogicalOr, "||"); GLSL_BOP(LogicalOr, "||");
BOP(LogicalAnd, "&&"); GLSL_BOP(LogicalAnd, "&&");
UOP(LogicalNot, "!"); GLSL_UOP(LogicalNot, "!");
BOP(LogicalEqual, "=="); GLSL_BOP(LogicalEqual, "==");
BOP(LogicalNotEqual, "!="); GLSL_BOP(LogicalNotEqual, "!=");
BOP(IEqual, "=="); GLSL_BOP(IEqual, "==");
BOP(INotEqual, "!="); GLSL_BOP(INotEqual, "!=");
BOP(ULessThan, "<"); GLSL_BOP(ULessThan, "<");
BOP(SLessThan, "<"); GLSL_BOP(SLessThan, "<");
BOP(ULessThanEqual, "<="); GLSL_BOP(ULessThanEqual, "<=");
BOP(SLessThanEqual, "<="); GLSL_BOP(SLessThanEqual, "<=");
BOP(UGreaterThan, ">"); GLSL_BOP(UGreaterThan, ">");
BOP(SGreaterThan, ">"); GLSL_BOP(SGreaterThan, ">");
BOP(UGreaterThanEqual, ">="); GLSL_BOP(UGreaterThanEqual, ">=");
BOP(SGreaterThanEqual, ">="); GLSL_BOP(SGreaterThanEqual, ">=");
case OpSelect: case OpSelect:
{ {
@ -2661,8 +2661,8 @@ string CompilerGLSL::constant_op_expression(const SPIRConstantOp &cop)
break; break;
} }
#undef BOP #undef GLSL_BOP
#undef UOP #undef GLSL_UOP
if (binary) if (binary)
{ {
if (cop.arguments.size() < 2) if (cop.arguments.size() < 2)
@ -6081,17 +6081,17 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
auto opcode = static_cast<Op>(instruction.op); auto opcode = static_cast<Op>(instruction.op);
uint32_t length = instruction.length; uint32_t length = instruction.length;
#define BOP(op) emit_binary_op(ops[0], ops[1], ops[2], ops[3], #op) #define GLSL_BOP(op) emit_binary_op(ops[0], ops[1], ops[2], ops[3], #op)
#define BOP_CAST(op, type) \ #define GLSL_BOP_CAST(op, type) \
emit_binary_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, glsl_opcode_is_sign_invariant(opcode)) emit_binary_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, glsl_opcode_is_sign_invariant(opcode))
#define UOP(op) emit_unary_op(ops[0], ops[1], ops[2], #op) #define GLSL_UOP(op) emit_unary_op(ops[0], ops[1], ops[2], #op)
#define QFOP(op) emit_quaternary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], ops[5], #op) #define QFOP(op) emit_quaternary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], ops[5], #op)
#define TFOP(op) emit_trinary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], #op) #define GLSL_TFOP(op) emit_trinary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], #op)
#define BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op) #define GLSL_BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op)
#define BFOP_CAST(op, type) \ #define GLSL_GLSL_BFOP_CAST(op, type) \
emit_binary_func_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, glsl_opcode_is_sign_invariant(opcode)) emit_binary_func_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, glsl_opcode_is_sign_invariant(opcode))
#define BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op) #define GLSL_BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op)
#define UFOP(op) emit_unary_func_op(ops[0], ops[1], ops[2], #op) #define GLSL_UFOP(op) emit_unary_func_op(ops[0], ops[1], ops[2], #op)
switch (opcode) switch (opcode)
{ {
@ -6617,45 +6617,45 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
// ALU // ALU
case OpIsNan: case OpIsNan:
UFOP(isnan); GLSL_UFOP(isnan);
break; break;
case OpIsInf: case OpIsInf:
UFOP(isinf); GLSL_UFOP(isinf);
break; break;
case OpSNegate: case OpSNegate:
case OpFNegate: case OpFNegate:
UOP(-); GLSL_UOP(-);
break; break;
case OpIAdd: case OpIAdd:
{ {
// For simple arith ops, prefer the output type if there's a mismatch to avoid extra bitcasts. // For simple arith ops, prefer the output type if there's a mismatch to avoid extra bitcasts.
auto type = get<SPIRType>(ops[0]).basetype; auto type = get<SPIRType>(ops[0]).basetype;
BOP_CAST(+, type); GLSL_BOP_CAST(+, type);
break; break;
} }
case OpFAdd: case OpFAdd:
BOP(+); GLSL_BOP(+);
break; break;
case OpISub: case OpISub:
{ {
auto type = get<SPIRType>(ops[0]).basetype; auto type = get<SPIRType>(ops[0]).basetype;
BOP_CAST(-, type); GLSL_BOP_CAST(-, type);
break; break;
} }
case OpFSub: case OpFSub:
BOP(-); GLSL_BOP(-);
break; break;
case OpIMul: case OpIMul:
{ {
auto type = get<SPIRType>(ops[0]).basetype; auto type = get<SPIRType>(ops[0]).basetype;
BOP_CAST(*, type); GLSL_BOP_CAST(*, type);
break; break;
} }
@ -6671,7 +6671,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
e->need_transpose = true; e->need_transpose = true;
} }
else else
BOP(*); GLSL_BOP(*);
break; break;
} }
@ -6679,19 +6679,19 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
case OpMatrixTimesScalar: case OpMatrixTimesScalar:
case OpVectorTimesScalar: case OpVectorTimesScalar:
case OpMatrixTimesMatrix: case OpMatrixTimesMatrix:
BOP(*); GLSL_BOP(*);
break; break;
case OpOuterProduct: case OpOuterProduct:
BFOP(outerProduct); GLSL_BFOP(outerProduct);
break; break;
case OpDot: case OpDot:
BFOP(dot); GLSL_BFOP(dot);
break; break;
case OpTranspose: case OpTranspose:
UFOP(transpose); GLSL_UFOP(transpose);
break; break;
case OpSRem: case OpSRem:
@ -6713,67 +6713,67 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
} }
case OpSDiv: case OpSDiv:
BOP_CAST(/, SPIRType::Int); GLSL_BOP_CAST(/, SPIRType::Int);
break; break;
case OpUDiv: case OpUDiv:
BOP_CAST(/, SPIRType::UInt); GLSL_BOP_CAST(/, SPIRType::UInt);
break; break;
case OpFDiv: case OpFDiv:
BOP(/); GLSL_BOP(/);
break; break;
case OpShiftRightLogical: case OpShiftRightLogical:
BOP_CAST(>>, SPIRType::UInt); GLSL_BOP_CAST(>>, SPIRType::UInt);
break; break;
case OpShiftRightArithmetic: case OpShiftRightArithmetic:
BOP_CAST(>>, SPIRType::Int); GLSL_BOP_CAST(>>, SPIRType::Int);
break; break;
case OpShiftLeftLogical: case OpShiftLeftLogical:
{ {
auto type = get<SPIRType>(ops[0]).basetype; auto type = get<SPIRType>(ops[0]).basetype;
BOP_CAST(<<, type); GLSL_BOP_CAST(<<, type);
break; break;
} }
case OpBitwiseOr: case OpBitwiseOr:
{ {
auto type = get<SPIRType>(ops[0]).basetype; auto type = get<SPIRType>(ops[0]).basetype;
BOP_CAST(|, type); GLSL_BOP_CAST(|, type);
break; break;
} }
case OpBitwiseXor: case OpBitwiseXor:
{ {
auto type = get<SPIRType>(ops[0]).basetype; auto type = get<SPIRType>(ops[0]).basetype;
BOP_CAST (^, type); GLSL_BOP_CAST (^, type);
break; break;
} }
case OpBitwiseAnd: case OpBitwiseAnd:
{ {
auto type = get<SPIRType>(ops[0]).basetype; auto type = get<SPIRType>(ops[0]).basetype;
BOP_CAST(&, type); GLSL_BOP_CAST(&, type);
break; break;
} }
case OpNot: case OpNot:
UOP(~); GLSL_UOP(~);
break; break;
case OpUMod: case OpUMod:
BOP_CAST(%, SPIRType::UInt); GLSL_BOP_CAST(%, SPIRType::UInt);
break; break;
case OpSMod: case OpSMod:
BOP_CAST(%, SPIRType::Int); GLSL_BOP_CAST(%, SPIRType::Int);
break; break;
case OpFMod: case OpFMod:
BFOP(mod); GLSL_BFOP(mod);
break; break;
case OpFRem: case OpFRem:
@ -6800,11 +6800,11 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
// Relational // Relational
case OpAny: case OpAny:
UFOP(any); GLSL_UFOP(any);
break; break;
case OpAll: case OpAll:
UFOP(all); GLSL_UFOP(all);
break; break;
case OpSelect: case OpSelect:
@ -6821,7 +6821,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
if (type.vecsize > 1) if (type.vecsize > 1)
emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "||"); emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "||");
else else
BOP(||); GLSL_BOP(||);
break; break;
} }
@ -6835,7 +6835,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
if (type.vecsize > 1) if (type.vecsize > 1)
emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "&&"); emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "&&");
else else
BOP(&&); GLSL_BOP(&&);
break; break;
} }
@ -6843,18 +6843,18 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
{ {
auto &type = get<SPIRType>(ops[0]); auto &type = get<SPIRType>(ops[0]);
if (type.vecsize > 1) if (type.vecsize > 1)
UFOP(not); GLSL_UFOP(not);
else else
UOP(!); GLSL_UOP(!);
break; break;
} }
case OpIEqual: case OpIEqual:
{ {
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
BFOP_CAST(equal, SPIRType::Int); GLSL_GLSL_BFOP_CAST(equal, SPIRType::Int);
else else
BOP_CAST(==, SPIRType::Int); GLSL_BOP_CAST(==, SPIRType::Int);
break; break;
} }
@ -6862,18 +6862,18 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
case OpFOrdEqual: case OpFOrdEqual:
{ {
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
BFOP(equal); GLSL_BFOP(equal);
else else
BOP(==); GLSL_BOP(==);
break; break;
} }
case OpINotEqual: case OpINotEqual:
{ {
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
BFOP_CAST(notEqual, SPIRType::Int); GLSL_GLSL_BFOP_CAST(notEqual, SPIRType::Int);
else else
BOP_CAST(!=, SPIRType::Int); GLSL_BOP_CAST(!=, SPIRType::Int);
break; break;
} }
@ -6881,9 +6881,9 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
case OpFOrdNotEqual: case OpFOrdNotEqual:
{ {
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
BFOP(notEqual); GLSL_BFOP(notEqual);
else else
BOP(!=); GLSL_BOP(!=);
break; break;
} }
@ -6892,18 +6892,18 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
{ {
auto type = opcode == OpUGreaterThan ? SPIRType::UInt : SPIRType::Int; auto type = opcode == OpUGreaterThan ? SPIRType::UInt : SPIRType::Int;
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
BFOP_CAST(greaterThan, type); GLSL_GLSL_BFOP_CAST(greaterThan, type);
else else
BOP_CAST(>, type); GLSL_BOP_CAST(>, type);
break; break;
} }
case OpFOrdGreaterThan: case OpFOrdGreaterThan:
{ {
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
BFOP(greaterThan); GLSL_BFOP(greaterThan);
else else
BOP(>); GLSL_BOP(>);
break; break;
} }
@ -6912,18 +6912,18 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
{ {
auto type = opcode == OpUGreaterThanEqual ? SPIRType::UInt : SPIRType::Int; auto type = opcode == OpUGreaterThanEqual ? SPIRType::UInt : SPIRType::Int;
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
BFOP_CAST(greaterThanEqual, type); GLSL_GLSL_BFOP_CAST(greaterThanEqual, type);
else else
BOP_CAST(>=, type); GLSL_BOP_CAST(>=, type);
break; break;
} }
case OpFOrdGreaterThanEqual: case OpFOrdGreaterThanEqual:
{ {
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
BFOP(greaterThanEqual); GLSL_BFOP(greaterThanEqual);
else else
BOP(>=); GLSL_BOP(>=);
break; break;
} }
@ -6932,18 +6932,18 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
{ {
auto type = opcode == OpULessThan ? SPIRType::UInt : SPIRType::Int; auto type = opcode == OpULessThan ? SPIRType::UInt : SPIRType::Int;
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
BFOP_CAST(lessThan, type); GLSL_GLSL_BFOP_CAST(lessThan, type);
else else
BOP_CAST(<, type); GLSL_BOP_CAST(<, type);
break; break;
} }
case OpFOrdLessThan: case OpFOrdLessThan:
{ {
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
BFOP(lessThan); GLSL_BFOP(lessThan);
else else
BOP(<); GLSL_BOP(<);
break; break;
} }
@ -6952,18 +6952,18 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
{ {
auto type = opcode == OpULessThanEqual ? SPIRType::UInt : SPIRType::Int; auto type = opcode == OpULessThanEqual ? SPIRType::UInt : SPIRType::Int;
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
BFOP_CAST(lessThanEqual, type); GLSL_GLSL_BFOP_CAST(lessThanEqual, type);
else else
BOP_CAST(<=, type); GLSL_BOP_CAST(<=, type);
break; break;
} }
case OpFOrdLessThanEqual: case OpFOrdLessThanEqual:
{ {
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
BFOP(lessThanEqual); GLSL_BFOP(lessThanEqual);
else else
BOP(<=); GLSL_BOP(<=);
break; break;
} }
@ -7037,21 +7037,21 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
// Derivatives // Derivatives
case OpDPdx: case OpDPdx:
UFOP(dFdx); GLSL_UFOP(dFdx);
if (is_legacy_es()) if (is_legacy_es())
require_extension_internal("GL_OES_standard_derivatives"); require_extension_internal("GL_OES_standard_derivatives");
register_control_dependent_expression(ops[1]); register_control_dependent_expression(ops[1]);
break; break;
case OpDPdy: case OpDPdy:
UFOP(dFdy); GLSL_UFOP(dFdy);
if (is_legacy_es()) if (is_legacy_es())
require_extension_internal("GL_OES_standard_derivatives"); require_extension_internal("GL_OES_standard_derivatives");
register_control_dependent_expression(ops[1]); register_control_dependent_expression(ops[1]);
break; break;
case OpDPdxFine: case OpDPdxFine:
UFOP(dFdxFine); GLSL_UFOP(dFdxFine);
if (options.es) if (options.es)
{ {
SPIRV_CROSS_THROW("GL_ARB_derivative_control is unavailable in OpenGL ES."); SPIRV_CROSS_THROW("GL_ARB_derivative_control is unavailable in OpenGL ES.");
@ -7062,7 +7062,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
break; break;
case OpDPdyFine: case OpDPdyFine:
UFOP(dFdyFine); GLSL_UFOP(dFdyFine);
if (options.es) if (options.es)
{ {
SPIRV_CROSS_THROW("GL_ARB_derivative_control is unavailable in OpenGL ES."); SPIRV_CROSS_THROW("GL_ARB_derivative_control is unavailable in OpenGL ES.");
@ -7077,14 +7077,14 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
{ {
SPIRV_CROSS_THROW("GL_ARB_derivative_control is unavailable in OpenGL ES."); SPIRV_CROSS_THROW("GL_ARB_derivative_control is unavailable in OpenGL ES.");
} }
UFOP(dFdxCoarse); GLSL_UFOP(dFdxCoarse);
if (options.version < 450) if (options.version < 450)
require_extension_internal("GL_ARB_derivative_control"); require_extension_internal("GL_ARB_derivative_control");
register_control_dependent_expression(ops[1]); register_control_dependent_expression(ops[1]);
break; break;
case OpDPdyCoarse: case OpDPdyCoarse:
UFOP(dFdyCoarse); GLSL_UFOP(dFdyCoarse);
if (options.es) if (options.es)
{ {
SPIRV_CROSS_THROW("GL_ARB_derivative_control is unavailable in OpenGL ES."); SPIRV_CROSS_THROW("GL_ARB_derivative_control is unavailable in OpenGL ES.");
@ -7095,14 +7095,14 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
break; break;
case OpFwidth: case OpFwidth:
UFOP(fwidth); GLSL_UFOP(fwidth);
if (is_legacy_es()) if (is_legacy_es())
require_extension_internal("GL_OES_standard_derivatives"); require_extension_internal("GL_OES_standard_derivatives");
register_control_dependent_expression(ops[1]); register_control_dependent_expression(ops[1]);
break; break;
case OpFwidthCoarse: case OpFwidthCoarse:
UFOP(fwidthCoarse); GLSL_UFOP(fwidthCoarse);
if (options.es) if (options.es)
{ {
SPIRV_CROSS_THROW("GL_ARB_derivative_control is unavailable in OpenGL ES."); SPIRV_CROSS_THROW("GL_ARB_derivative_control is unavailable in OpenGL ES.");
@ -7113,7 +7113,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
break; break;
case OpFwidthFine: case OpFwidthFine:
UFOP(fwidthFine); GLSL_UFOP(fwidthFine);
if (options.es) if (options.es)
{ {
SPIRV_CROSS_THROW("GL_ARB_derivative_control is unavailable in OpenGL ES."); SPIRV_CROSS_THROW("GL_ARB_derivative_control is unavailable in OpenGL ES.");
@ -7132,15 +7132,15 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
case OpBitFieldSExtract: case OpBitFieldSExtract:
case OpBitFieldUExtract: case OpBitFieldUExtract:
// TODO: The signedness of inputs is strict in GLSL, but not in SPIR-V, bitcast if necessary. // TODO: The signedness of inputs is strict in GLSL, but not in SPIR-V, bitcast if necessary.
TFOP(bitfieldExtract); GLSL_TFOP(bitfieldExtract);
break; break;
case OpBitReverse: case OpBitReverse:
UFOP(bitfieldReverse); GLSL_UFOP(bitfieldReverse);
break; break;
case OpBitCount: case OpBitCount:
UFOP(bitCount); GLSL_UFOP(bitCount);
break; break;
// Atomics // Atomics
@ -7177,7 +7177,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
flush_all_atomic_capable_variables(); flush_all_atomic_capable_variables();
// FIXME: Image? // FIXME: Image?
// OpAtomicLoad seems to only be relevant for atomic counters. // OpAtomicLoad seems to only be relevant for atomic counters.
UFOP(atomicCounter); GLSL_UFOP(atomicCounter);
register_read(ops[1], ops[2], should_forward(ops[2])); register_read(ops[1], ops[2], should_forward(ops[2]));
break; break;
@ -7187,7 +7187,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
case OpAtomicIIncrement: case OpAtomicIIncrement:
forced_temporaries.insert(ops[1]); forced_temporaries.insert(ops[1]);
// FIXME: Image? // FIXME: Image?
UFOP(atomicCounterIncrement); GLSL_UFOP(atomicCounterIncrement);
flush_all_atomic_capable_variables(); flush_all_atomic_capable_variables();
register_read(ops[1], ops[2], should_forward(ops[2])); register_read(ops[1], ops[2], should_forward(ops[2]));
break; break;
@ -7195,7 +7195,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
case OpAtomicIDecrement: case OpAtomicIDecrement:
forced_temporaries.insert(ops[1]); forced_temporaries.insert(ops[1]);
// FIXME: Image? // FIXME: Image?
UFOP(atomicCounterDecrement); GLSL_UFOP(atomicCounterDecrement);
flush_all_atomic_capable_variables(); flush_all_atomic_capable_variables();
register_read(ops[1], ops[2], should_forward(ops[2])); register_read(ops[1], ops[2], should_forward(ops[2]));
break; break;
@ -7326,12 +7326,12 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
{ {
require_extension_internal("GL_ARB_texture_query_lod"); require_extension_internal("GL_ARB_texture_query_lod");
// For some reason, the ARB spec is all-caps. // For some reason, the ARB spec is all-caps.
BFOP(textureQueryLOD); GLSL_BFOP(textureQueryLOD);
} }
else if (options.es) else if (options.es)
SPIRV_CROSS_THROW("textureQueryLod not supported in ES profile."); SPIRV_CROSS_THROW("textureQueryLod not supported in ES profile.");
else else
BFOP(textureQueryLod); GLSL_BFOP(textureQueryLod);
register_control_dependent_expression(ops[1]); register_control_dependent_expression(ops[1]);
break; break;
} }

View File

@ -3835,26 +3835,17 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
auto ops = stream(instruction); auto ops = stream(instruction);
auto opcode = static_cast<Op>(instruction.op); auto opcode = static_cast<Op>(instruction.op);
#undef BOP #define HLSL_BOP(op) emit_binary_op(ops[0], ops[1], ops[2], ops[3], #op)
#undef BOP_CAST #define HLSL_BOP_CAST(op, type) \
#undef UOP
#undef QFOP
#undef TFOP
#undef BFOP
#undef BFOP_CAST
#undef BFOP
#undef UFOP
#define BOP(op) emit_binary_op(ops[0], ops[1], ops[2], ops[3], #op)
#define BOP_CAST(op, type) \
emit_binary_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, hlsl_opcode_is_sign_invariant(opcode)) emit_binary_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, hlsl_opcode_is_sign_invariant(opcode))
#define UOP(op) emit_unary_op(ops[0], ops[1], ops[2], #op) #define HLSL_UOP(op) emit_unary_op(ops[0], ops[1], ops[2], #op)
#define QFOP(op) emit_quaternary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], ops[5], #op) #define HLS_QFOP(op) emit_quaternary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], ops[5], #op)
#define TFOP(op) emit_trinary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], #op) #define HLSL_TFOP(op) emit_trinary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], #op)
#define BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op) #define HLSL_BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op)
#define BFOP_CAST(op, type) \ #define HLSL_BFOP_CAST(op, type) \
emit_binary_func_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, hlsl_opcode_is_sign_invariant(opcode)) emit_binary_func_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, hlsl_opcode_is_sign_invariant(opcode))
#define BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op) #define HLSL_BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op)
#define UFOP(op) emit_unary_func_op(ops[0], ops[1], ops[2], #op) #define HLSL_UFOP(op) emit_unary_func_op(ops[0], ops[1], ops[2], #op)
switch (opcode) switch (opcode)
{ {
@ -3923,39 +3914,39 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
} }
case OpDPdx: case OpDPdx:
UFOP(ddx); HLSL_UFOP(ddx);
register_control_dependent_expression(ops[1]); register_control_dependent_expression(ops[1]);
break; break;
case OpDPdy: case OpDPdy:
UFOP(ddy); HLSL_UFOP(ddy);
register_control_dependent_expression(ops[1]); register_control_dependent_expression(ops[1]);
break; break;
case OpDPdxFine: case OpDPdxFine:
UFOP(ddx_fine); HLSL_UFOP(ddx_fine);
register_control_dependent_expression(ops[1]); register_control_dependent_expression(ops[1]);
break; break;
case OpDPdyFine: case OpDPdyFine:
UFOP(ddy_fine); HLSL_UFOP(ddy_fine);
register_control_dependent_expression(ops[1]); register_control_dependent_expression(ops[1]);
break; break;
case OpDPdxCoarse: case OpDPdxCoarse:
UFOP(ddx_coarse); HLSL_UFOP(ddx_coarse);
register_control_dependent_expression(ops[1]); register_control_dependent_expression(ops[1]);
break; break;
case OpDPdyCoarse: case OpDPdyCoarse:
UFOP(ddy_coarse); HLSL_UFOP(ddy_coarse);
register_control_dependent_expression(ops[1]); register_control_dependent_expression(ops[1]);
break; break;
case OpFwidth: case OpFwidth:
case OpFwidthCoarse: case OpFwidthCoarse:
case OpFwidthFine: case OpFwidthFine:
UFOP(fwidth); HLSL_UFOP(fwidth);
register_control_dependent_expression(ops[1]); register_control_dependent_expression(ops[1]);
break; break;
@ -3968,7 +3959,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
if (type.vecsize > 1) if (type.vecsize > 1)
emit_unrolled_unary_op(result_type, id, ops[2], "!"); emit_unrolled_unary_op(result_type, id, ops[2], "!");
else else
UOP(!); HLSL_UOP(!);
break; break;
} }
@ -3980,7 +3971,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "=="); emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "==");
else else
BOP_CAST(==, SPIRType::Int); HLSL_BOP_CAST(==, SPIRType::Int);
break; break;
} }
@ -3993,7 +3984,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "=="); emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "==");
else else
BOP(==); HLSL_BOP(==);
break; break;
} }
@ -4005,7 +3996,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "!="); emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "!=");
else else
BOP_CAST(!=, SPIRType::Int); HLSL_BOP_CAST(!=, SPIRType::Int);
break; break;
} }
@ -4018,7 +4009,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "!="); emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "!=");
else else
BOP(!=); HLSL_BOP(!=);
break; break;
} }
@ -4032,7 +4023,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
emit_unrolled_binary_op(result_type, id, ops[2], ops[3], ">"); emit_unrolled_binary_op(result_type, id, ops[2], ops[3], ">");
else else
BOP_CAST(>, type); HLSL_BOP_CAST(>, type);
break; break;
} }
@ -4044,7 +4035,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
emit_unrolled_binary_op(result_type, id, ops[2], ops[3], ">"); emit_unrolled_binary_op(result_type, id, ops[2], ops[3], ">");
else else
BOP(>); HLSL_BOP(>);
break; break;
} }
@ -4058,7 +4049,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
emit_unrolled_binary_op(result_type, id, ops[2], ops[3], ">="); emit_unrolled_binary_op(result_type, id, ops[2], ops[3], ">=");
else else
BOP_CAST(>=, type); HLSL_BOP_CAST(>=, type);
break; break;
} }
@ -4070,7 +4061,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
emit_unrolled_binary_op(result_type, id, ops[2], ops[3], ">="); emit_unrolled_binary_op(result_type, id, ops[2], ops[3], ">=");
else else
BOP(>=); HLSL_BOP(>=);
break; break;
} }
@ -4084,7 +4075,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "<"); emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "<");
else else
BOP_CAST(<, type); HLSL_BOP_CAST(<, type);
break; break;
} }
@ -4096,7 +4087,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "<"); emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "<");
else else
BOP(<); HLSL_BOP(<);
break; break;
} }
@ -4110,7 +4101,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "<="); emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "<=");
else else
BOP_CAST(<=, type); HLSL_BOP_CAST(<=, type);
break; break;
} }
@ -4122,7 +4113,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
if (expression_type(ops[2]).vecsize > 1) if (expression_type(ops[2]).vecsize > 1)
emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "<="); emit_unrolled_binary_op(result_type, id, ops[2], ops[3], "<=");
else else
BOP(<=); HLSL_BOP(<=);
break; break;
} }
@ -4427,18 +4418,18 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
} }
if (opcode == OpBitFieldSExtract) if (opcode == OpBitFieldSExtract)
TFOP(SPIRV_Cross_bitfieldSExtract); HLSL_TFOP(SPIRV_Cross_bitfieldSExtract);
else else
TFOP(SPIRV_Cross_bitfieldUExtract); HLSL_TFOP(SPIRV_Cross_bitfieldUExtract);
break; break;
} }
case OpBitCount: case OpBitCount:
UFOP(countbits); HLSL_UFOP(countbits);
break; break;
case OpBitReverse: case OpBitReverse:
UFOP(reversebits); HLSL_UFOP(reversebits);
break; break;
default: default:

View File

@ -422,6 +422,7 @@ bool slang_process(
ps_compiler->set_decoration( ps_compiler->set_decoration(
ps_resources.push_constant_buffers[0].id, spv::DecorationBinding, 1); ps_resources.push_constant_buffers[0].id, spv::DecorationBinding, 1);
#ifdef ENABLE_HLSL
if (dst_type == RARCH_SHADER_HLSL || dst_type == RARCH_SHADER_CG) if (dst_type == RARCH_SHADER_HLSL || dst_type == RARCH_SHADER_CG)
{ {
CompilerHLSL::Options options; CompilerHLSL::Options options;
@ -460,7 +461,9 @@ bool slang_process(
vs_code = vs->compile(); vs_code = vs->compile();
ps_code = ps->compile(ps_attrib_remap); ps_code = ps->compile(ps_attrib_remap);
} }
else if (dst_type == RARCH_SHADER_METAL) else
#endif
if (dst_type == RARCH_SHADER_METAL)
{ {
CompilerMSL::Options options; CompilerMSL::Options options;
CompilerMSL* vs = (CompilerMSL*)vs_compiler; CompilerMSL* vs = (CompilerMSL*)vs_compiler;

View File

@ -67,7 +67,7 @@ else
DEFINES += -DHAVE_OPENGLES2 DEFINES += -DHAVE_OPENGLES2
endif endif
DEFINES += -DRARCH_MOBILE -DHAVE_GRIFFIN -DHAVE_STB_VORBIS -DHAVE_LANGEXTRA -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_OVERLAY -DHAVE_OPENGLES -DGLSL_DEBUG -DHAVE_DYLIB -DHAVE_EGL -DHAVE_GLSL -DHAVE_MENU -DHAVE_RGUI -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DINLINE=inline -DHAVE_THREADS -D__LIBRETRO__ -DHAVE_RSOUND -DHAVE_NETWORKGAMEPAD -DHAVE_NETWORKING -DRARCH_INTERNAL -DHAVE_FILTERS_BUILTIN -DHAVE_MATERIALUI -DHAVE_XMB -DHAVE_SHADERPIPELINE -DHAVE_LIBRETRODB -DHAVE_STB_FONT -DHAVE_IMAGEVIEWER -DHAVE_UPDATE_ASSETS -DHAVE_CC_RESAMPLER -DHAVE_MINIUPNPC -DHAVE_BUILTINMINIUPNPC -DMINIUPNPC_SET_SOCKET_TIMEOUT -DMINIUPNPC_GET_SRC_ADDR -DHAVE_KEYMAPPER -DHAVE_NETWORKGAMEPAD -DHAVE_FLAC -DHAVE_DR_FLAC -DHAVE_DR_MP3 -DHAVE_CHD -DHAVE_RUNAHEAD DEFINES += -DRARCH_MOBILE -DHAVE_GRIFFIN -DHAVE_STB_VORBIS -DHAVE_LANGEXTRA -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_OVERLAY -DHAVE_OPENGLES -DGLSL_DEBUG -DHAVE_DYLIB -DHAVE_EGL -DHAVE_GLSL -DHAVE_MENU -DHAVE_RGUI -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DINLINE=inline -DHAVE_THREADS -D__LIBRETRO__ -DHAVE_RSOUND -DHAVE_NETWORKGAMEPAD -DHAVE_NETWORKING -DRARCH_INTERNAL -DHAVE_FILTERS_BUILTIN -DHAVE_MATERIALUI -DHAVE_XMB -DHAVE_SHADERPIPELINE -DHAVE_LIBRETRODB -DHAVE_STB_FONT -DHAVE_IMAGEVIEWER -DHAVE_UPDATE_ASSETS -DHAVE_CC_RESAMPLER -DHAVE_MINIUPNPC -DHAVE_BUILTINMINIUPNPC -DMINIUPNPC_SET_SOCKET_TIMEOUT -DMINIUPNPC_GET_SRC_ADDR -DHAVE_KEYMAPPER -DHAVE_NETWORKGAMEPAD -DHAVE_FLAC -DHAVE_DR_FLAC -DHAVE_DR_MP3 -DHAVE_CHD -DHAVE_RUNAHEAD -DENABLE_HLSL
DEFINES += -DWANT_IFADDRS DEFINES += -DWANT_IFADDRS
ifeq ($(HAVE_VULKAN),1) ifeq ($(HAVE_VULKAN),1)